Single Xtext Language Server for two extensions - xtext

I have two Eclipse plugin Xtext(2.11) projects.(Called Project A and B) Project B grammar file is dependent on Project A grammar file. Project A's grammar file extension is a and Project B is b.
I am able to generate the language server for Project B. I want to generate the single language server for both projects.(Currently, in project B it includes project A.)
Depend on extension type it needs invoke respective Xtext grammar functionality.
In above scenario, I have below questions:
Does Xtext can handle this kind of scenario seamlessly? Do I need to generate the language server for Project A also and need to add in Project B? What is the best way to do this?
What kind of Xtext changes required?
What kind of changes required at client side also? like in Visual code/ Che?

Xtext LS can be used with multiple Xtext languages. It uses java service loading to look up language setups: https://github.com/eclipse/xtext-core/blob/master/org.eclipse.xtext/src/org/eclipse/xtext/resource/ResourceServiceProviderServiceLoader.xtend#L25. In ide project of your language you should be able to find META-INF/services/org.ecalipse.xtext.ISetup file that says java what implementations should be used for ISetup interface.
Having jars for ide projects on the classpath should be enough. No changes are required.
VS code and Che does not care about implementation details of Xtext LS, but both languages should be registered for them

Related

Xtext language Server and Global Scoping

I've implemented a Language Server for a Java-like "toy" DSL based on Xtext together with a VS code extension and everything worked like a charm.
Trying to improve my language server a bit, I've added "imports" support and have leveraged the scoping system to resolve cross-file references and global scoping. Once again, it worked like a charm. Nonetheless, for the language server to be able to resolve imported classifiers, both files should live within the same workspace.
In order to enable global scoping outside the workspace boundaries, I am thinking of adding classpath definition file in YML, containing path to the other files that are referenced to by and that live outside the workspace boundaries.
The idea would be to lazily resolve them when referenced to by other files. Let's say that the classpath specification will be in the same project as the referencing files.
Is this something we can do in Xtext? If so, can you please point me to some code snippets?
Thank you in advance,

xText parser usage during runtime configuration

I want to use the runtime configuration for running an xText parser. In an example xText project I get the standalone and the runtime configuration for using the parser.
Please can somebody indicate the steps needed to use the parser during runtime in another Eclipse plug-in project. I have no experience with the plugin.xml file and I know I need to create there some extension points.
The xText sample project contain also an ui project which uses the obtained parser during runtime. Still I was not able to understand what things I need from that configuration an what not.
Help is highly appreciated.

listener and visitor ANTLRworks 2

I dont know how to make visitor and listener to work via ANTLRworks 2, I managed to create them, but do I need to write code via cmd or can I use them directly through ANTLRworks 2?
ANTLRWorks 2 is currently designed as an IDE for ANTLR grammars themselves. The generated visitors and listeners, along with any implementation(s) of them, would be developed as part of a separate project in the target language (currently Java and C# are supported).
If you have ANTLRWorks 2 installed as a plugin for NetBeans (as opposed to the alone application), you can work with ANTLR 4 grammars directly within the context of a Java project, which may better fit your needs.

How to get type info from Go compiled packages in language x?

I want to write a simple editor with basic autocomplete functionality for the Go language as a pet project. How would one go about doing it? I took a look at the Go plugins for Eclipse and IntelliJ, but they were too big for me to comprehend (not to mention getting one to compile).
The Go standard library offers the building blocks for a Go parser which
you can use to parse the source files and look for function definitions and the like.
There's also the godoc command which
already does what you want: extracting method definitions and it's documentation. You may look in the
source code to see how godoc is
working or use godoc directly.
This editor written in Go projects has a manageable amount of code,
you may look into it.
The de facto standard approach to this problem is to use nsf's gocode. I have tried it only in Vim - it works very well.
Even though there's ready made support for specific editors, gocode is not editor specific. It's a daemon with a communication protocol. It is thus usable from any program.

Does a separate .exe always require a separate project in Delphi?

Our application requires quite a few tools and utilities we have written to support our product. Things like data converters, backup utilities etc. Currently, each of these utilities is a separate Delphi Project. On top of that, many of these projects also have a corresponding DUnit project for unit testing, which also have to be a separate project. We currently have 13 separate Delphi projects. These projects are all in one Project Group.
Is this necessary? Do we have to have so many separate projects, or is there a way in Delphi to have multiple entry points into the same project?
Also, sometimes it would be convenient during development to just write some code and 'run' it. To do this now I end up hacking the project file; commenting out the normal behaviour and replacing it with the code I want to run. Is this the only way?
We use Delphi 2010 if that makes a difference.
You can do either of these pretty easily:
Combine your projects into a project group, to be able to work with them together more easily.
(My preference) Separate your projects into different units (instead of project files), create a single application that uses all those units, and call different functionality based on command-line parameters (see ParamCount and ParamStr in the documentation) You can then easily write unit tests by testing each of the units (pun not intended) separately.
Regarding your edit: Delphi is a compiled, not interpreted, language. You can't just "run" code without compiling it, unless you can use functionality that's in your app using the Evaluate/Modify menu item during debugging. (Set a breakpoint and run your app. When it hits the breakpoint, use Ctrl+F7 to open the Evaluate/Modify dialog. Note that this has limited functionality due to the nature of the optimizer and compiler.
Organize your project in one or more Project Groups, and you could use project (exe) parameters to execute just some part of your exe.
As it was already mentioned you can convert mini projects into units. Then use compile conditionals ($ifdef etc.) to select which unit is being included in the compiled program. It would be also handy to be able to automatically switch the name of the generated executable file. I think it would be possible to create a relatively simple OTA (Open Tools API) plugin that could control all those features.
To run small parts of code you can create a separate lightweight console project where you can paste the code to the main function.

Resources