How to add a document as a child of another document in a Roslyn project? - roslyn

In Roslyn, I can add a new document to a project like this:
var documentId = DocumentId.CreateNewId(currentProject.Id);
var newSolution =
currentSolution.AddDocument(documentId, "myfile.cs", code);
Using the Visual Studio SDK, I can add a new file as a child of another file like this:
parentFileItem.ProjectItems.AddFromFile(newFilePath);
Where parentFileItem is the document - of type ProjectItem - under which I want to add the new file. And newFilePath is the path of the new file.
I want to be able to do a similar thing to a Roslyn solution. Is this possible?
If that is not possible, can I "move" an existing ProjectItem to become a child under another existing ProjectItem via the Visual Studio SDK?
That is, I will add the new document via Roslyn, and once changes are applied, I want to move the file created via Roslyn under another existing file.

Related

vs2022 filetemplate for multiple projects

I'm looking for a way to setup a file template for vs2022/clie to add with one single action, multiple files into my solution in a standard way.
Is this possible (without writing the entire cli myself?). for example when i select 'add new item' and a give it a new 'StorePerson'. I would like it to add the following files
Core\StorePersonCommand
Core\StorePersonCommandHandler
Core\StorePersonValidator
UnitTest\StorePersonCommandHandlerSpecification
UnitTest\StorePersonCommandValidatorSpecification

Is it possible to modify the templates used during creation of a C++ class by the Unreal Editor's Class Wizard?

I am starting a new project and it will require the creation of many C++ classes. In order to keep the project organized I created coded standards that will keep methods and member variables organized using regions, nothing too complex. However, I do not want to have to modify every new class I make adding the separators(regions) by hand or have to copy paste from another file.
In unity it is possible to modify the template used in the creation of a new script, but i am having trouble finding the same information for the Unreal Engine. I am not using source and if it is required to do so I will probably just copy paste it for every class.
I tried searching online for information on the subject, but the results were less than useful.
You can modify, create, and delete templates in Unreal Engine. Since you are not using Unreal Engine source, the templates are all located in the C:\Program Files\Epic Games\UE_{version}\Templates directory. If you are using Unreal Engine source, then the location will instead be {engine-location}\Templates. In these directories, you can modify the configs, the content, and the source code of each template. And of course, you can create new templates and delete existing ones.
If you do create a new template, then make sure that you do the following steps:
Move the project that you want to make a template out of to one of the Templates folders mentioned above depending on the verison of Unreal Engine you have (source vs non-source).
Update the ProjectName variable in your template's Config\DefaultGame.ini file.
Copy any of the existing templates' Config\TemplateDefs.ini file to your template's Config folder.
Modify the copied TemplateDefs.ini file, specifically the LocalizedDisplayNames and LocalizedDescriptions variables. These are the name and description of your template that show when the template is selected while trying to make a new project in Unreal Engine. Note that you may have to modify the other parts of the TemplateDefs.ini file depending on your project/template.
Lastly, add pictures in your new template's Media folder. Add one picture named {new-template-name}.png, which will be the icon of the template and another picture named {new-template-name}_Preview.png, which will be be the preview of the template that appears alongside the name and description after one clicks on the template icon while trying to make a new project.
For more information, check out these resources:
https://docs.unrealengine.com/en-US/Engine/Basics/Projects/CreatingTemplates/index.html
https://www.youtube.com/watch?v=MYM7iSh-uac

Bitrix component and module customisation

I am working with Bitrix24. I want to customise the component and module of Bitrix24.
But I didn't have the standard documentation for this.
Some one help me for the same,how we can work with local folder for customise component and module etc.
If you need to change logic of component you may do through this way:
create the local folder in your documet_root path
create components folder in the local folder
create bitrix folder in the components folder
copy component folder from /bitrix/components/bitrix to
/local/components/bitrix
edit logic in the component.php file (or in class.php file if
component using new bitrix core - D7) in the copied folder
If you need to change only the view, this is another way:
Instead of creating the /local/components/bitrix you have to
create /local/templates/.default/ folder
Copy there only the .default template of a needed component
Edit template.php file
With the second way, you also may change (or rich it) some data in final $arResult array provided for the template.php, just create result_modifier.php file in the template directory.
You can find this and other information in the free course Bitrix Framework, pay attention to this link, it will be very helpful

Creating new JS file from the selected code

Is there a way in Webstorm to quickly create a new file from the selection?
For example, lets say I am working in product.js on a Product class and realize I also need a new Manager class. In C# via Resharper, I can write the new class right there in product.js, then select it and ask Resharper to move it to its own file. Resharper would create a new file and move the code there.
In WebStorm I need to do these steps manually:
Create new file
Write code there (or cut-paste it if I already wrote it else wrote it elsewhere)
Add a reference to my html.
Is there a way to speed up that process in Webstorm?
this option is only available for javascript embedded in HTML: Refactor/Extract/Extract Include File...

List all available models in EMF application

I'm working on a project consisting of two Eclipse plugin projects. One is an EMF project and contains the metamodel for the application. The other one is the acctual plugin working on that metamodel.
I'm now looking for a way to list all types of models available in the metamodel project. Since I basically need all generated classes I could use reflections to iterate through the metamodel package but I'd prefer an easier way if there is one.
The models are already listed as extensions in the plugin.xml like this:
<plugin>
<extension point="org.eclipse.emf.ecore.generated_package">
<package
uri="MyModel"
class="org.myproject.metamodel.MyModel.MyModelPackage"
genModel="model/MetaModel.genmodel"/>
</extension>
</plugin>
where the class MyModelPackage extends EPackage and org.myproject.metamodel.MyModel also contains all the other generated classes I need to list. I'm guessing that I can use that information but I still don't know how.
Update
The project I'm working on is based on EMFStore. Running it offers the EMFStore perspective. If I have the Navigator view with a project I can right click on that project and select New Model Element. This opens a dialog where all the model elements from my metamodel are listed so it is possible. It must be done somewhere in EMFStore or one of it's dependencies. I looked through the source code but can't seem to find where it's done.
The plugin.xml of the project org.eclipse.emf.emfstore.perspective refers to the class org.eclipse.emf.emfstore.emfperspective.EMFStorePerspective which I can't find in the sources. I imported the project via the Eclipse Import Plug-Ins and Fragments functionality and it has no source folder. In the EMFStore git repositories I can't even find that project.
Update
I now got the registry that contains the generated packages using EPackage.Registry.INSTANCE. Unfortunately it contains more than the EPackages from the one project containing the metadata (org.myproject.metamodel). Now I'm just looking for a proper way to filter it, but still can't get the hang of it.
Update
As the filtering is not part of my original question I accepted the answer by #SpaceTrucker. For those who are curious, this is how I've done it now:
Registry registry = EPackage.Registry.INSTANCE;
for (String key : new HashSet<String>(registry.keySet())) {
EPackage ePackage = registry.getEPackage(key);
if (ePackage.getClass().getName().startsWith("org.myproject.metamodel")) {
//do stuf
}
}
I found no way to filter for the project but luckily all the packages start with the same prefix.
EPackages may be registered via an EPackage.Registry. There seems to be a globally used instance available via ECorePlugin.getDefaultRegistryImplementation(). However I'm not 100% sure on that.
MoDisco comes with a EMF Model Browser, where you are also able to select any registered EMF model. So you also could have a look at those sources.