xText: doGenerate method is not called - xtext

I'm developing a DSL using xText (version 2.10.0) and i would like to add also a code generator.
When running the plug-ins, as I understood, the code generator should be invoked automatically upon a change in a file.
This is not happening.
Using a debugger I've noticed that the doGenerate function is not invoked.
What can I do so the doGenerate function will be invoked automatically?
Thanks.

Your file needs the right file extension (case sensitive) the project needs xtext nature and build automatically needs to be enabled. Then the generator will be called upon save of error free models

Related

How to use the erlang-server stubs from OpenAPI generator?

I am currently trying to develop a REST API using Erlang. I used OpenAPI (Swagger) to define the API and wanted to use their openapi-generator to create the stubs and some helper code. This also works and some code is generated, but I cannot find any documentation on what I have to do from there.
For the explanation of my problem, I will refer to their sample output from code generation for erlang-server.
I have two main problems at the moment:
I cannot find an entry point into the code (e.g. a init/0 or start/0 function)
I am not sure which function I have to implement to execute my code on each endpoint. I think that I have to implement handle_request, but the execution path seems a bit weird to me.
Which function to implement
In openapi_router they define openapi_pet_handler to be the handler for 'AddPet'. In that module, there is a function called handle_request_json, which tries to populate the request and in case of OK executes openapi_logic_handler:handle_request(LogicHandler, ...).
openapi_logic_handler:handle_request(Handler, ...) takes that handler and executes Handler:handle_request(OperationID, Req, Context).. This leads me to the conclusion, that I probably have to implement openapi_pet_handler:handle_request with my custom code.
How to start the server
I checked the code and it seems to use cowboy as a web server. At least it includes dependencies to cowboy in the generated openapi.app.src. However, in rebar.config there is no reference to cowboy.
In the cowboy tutorial, they use erlang.mk to build their project. This allows them to run the code with make run. With rebar this does not seem to be possible. I did not find a specific command for rebar to start a program. You seem to have to know the entrypoint (init function) if you use rebar.
However, I am not able to find any function that looks like it could be an init function in the generated stub code.
Summary
Can somebody explain what has to be done to use the stub generated by openapi-generator for erlang-server? Do I have to setup my own cowboy project and then somehow link the stubs into it? If yes, how?

VSCode extension IPC with UI inside HTML preview

I wish to develop a unit test runner extension for VSCode. The extension should display discovered tests grouped into expandable hierarchy, annotate run status, display output and errors for each test, provide run/debug commands on different levels, and of course the red/green bar.
Roughly spearating this into "model" and "view", I plan to implement the model in the extension process, and I plan to implement the view as HTML preview based on a TextDocumentContentProvider. (Is there a better approach?)
Now, the model and the view should communicate with each other. I want to implement the view as a single-page application. The view will send commands to the model, and the model will send events to the view (or the view will poll the model for events). The view will update itself according to received events.
My question is, what communication technique should I use? Can HTML page inside the HTML preview access VSCode/Atom/Electron/Node APIs? Can I share object instances, or do some lightweight IPC? By far I didn't figure out.
I've found that I can invoke VSCode commands or refresh the entire page, when the user clicks a link with href set to specific scheme (command:// or the one I registered for my TextDocumentContentProvider).
I do succeed to open an HTTP listener (http.createServer) in the extension process, and communicate through XMLHttpRequest on the HTML preview side. But it looks to me like a heavy overkill.
I wonder if there are more appropriate ways to do this?
Almenon is referring to the currently proposed Webview API that was released in version 1.21 (Feb 2018). For the time being, this appears to be a much better approach for HTML previews. But in order to use the API, there are special instructions. From the release notes:
These APIs are still proposed, so in order to use it, you must opt into it by adding a "enableProposedApi": true to package.json and you'll have to copy the vscode.proposed.d.ts into your extension project.
What isn't clarified (and probably should be) is how to add the downloaded declaration file to a project. One way to do it is place the file in $/node_modules/vscode, next to vscode.d.ts, which is generated during postinstall. Then add the following line to the top of vscode.d.ts:
/// <reference path="vscode.proposed.d.ts" />
That will link the type declaration files. To make this part of the installation process, write a build task to do it and then call it in the vscode:postinstall script in package.json.
VSCode has a new API that makes this easier.
https://github.com/Microsoft/vscode/issues/43713
You can find the new API here
To try the new API:
Add "enableProposedApi": true to your package.json
Manually download vscode.proposed.d.ts and add it to your project: https://raw.githubusercontent.com/Microsoft/vscode/master/src/vs/vscode.proposed.d.ts
Run your extension with the latest VS Code insiders build

Using javascript library in Dart

I try to use JavaScript library visjs.org in Dart. I prepared ‘adapter’ code according examples on Dart site pub.dartlang.org/packages/js and github.com/google/chartjs.dart/blob/master/lib/chartjs.dart.
Also according basic use case example from http://visjs.org I prepare client dart code.
While code compiles without any errors and warnings nothing happens in browser, expected to see graph-tree.
What I did wrong or miss to do?
https://gist.github.com/EdSv/e274a4d12ad3491c383fb4fe76ee671e
The attribute #anonymous is meant to be used when the object you're describing doesn't actually exist in the JS library you're binding, and is only used as a plain old data object. By adding it to all of your objects, my guess is that dart is never attempting to create anything from the visjs library.
Try removing the #anonymous from your Network class and see if that has an effect. You will likely also need to make these abstract classes as well.

Migrating to Vim from RubyMine - Interpreted Auto completion

Up until last week, I had been using RubyMine for my Rails development. I know it has a vim plugin but I have been working on migrating my development to vim and tmux. I don't want to keep using the mouse and VIM gives me a lot more flexibility. I have found plugins and workarounds for almost all the features I care about except the "interpreted auto complete" functionality in my first screenshot below. RubyMine interprets the whole rails application and offers sorted-by-relevance suggestions (as you can see, it's showing me instance variables and methods for the class in question and the modules it includes) THEN it shows (less relevant) methods available on the Object class. It also shows the method signature when there's one.
Also, in my second screenshot, you can see how RubyMine offers autocompletion for core Ruby classes.
Compare this to the bottommost screenshot. I do have completion but there's no way to find what I'm looking for. I'm using ctags , YouCompleteMe, vim-rails, vim-ruby and I also tried installing eclim to see if it makes a difference.
Is there a plugin I've missed that can enhance my auto completion? It doesn't look like RubyMine is doing something super crazy. pry can give me the same 'power' if it were running in the same 'context'.
First Screenshot (RubyMine interpreted auto complete):
Second Screenshot (RubyMine core Ruby classes auto complete):
Third Screenshot (vim omnifunc + ctags):
Important Note
This solution only works for Ruby 1.9+
I forked 'vim-ruby' at https://github.com/zxiest/vim-ruby and modified it as such:
Method signatures now appear in completion.
I disabled sorting by name for methods.
Plugins and Settings
vim-rails
I'm using vim-rails https://github.com/tpope/vim-rails
supertab
I'm using supertab https://github.com/ervandew/supertab instead of YouCompleteMe (mentioned in my question) although YouCompleteMe is super fast and automatic but there are currently some compatibility issues between my it and my vim-ruby fork.
vim-easytags
I'm using vim-easytags https://github.com/xolox/vim-easytags
Add this to your ~/.vimrc
:set tags=./tags;
:let g:easytags_dynamic_files = 1
Make sure to touch ./tags in your project directory.
Issue :UpdateTags -R **/*.* from vim in order for easytags to generate your tags file.
Remap omnicomplete
In order for omnicomplete to pop up, by default, we have to hit <C-X><C-O>. I remapped this to <C-Space> by inserting the following in my ~/.vimrc:
inoremap <C-#> <C-x><C-o>
I now press tab when I want supertab to complete my code and Ctrl+Space when I want omnicomplete to trigger and show method signatures for me. There's definitely a better way to integrate this (i.e. getting supertab to call omnicomplete after a dot)
And here goes the screenshot! Notice that method sorting being off allowed my custom resize method to appear on top and the signatures now appear in the completion (as well as in the editor when enter is pressed!)

Check for a file existence in WIX SEtup

I am creating a Setup for my .Net Application using WIX.
I want to check the existence of a file before installing my WIX SET UP as a Dependency.
If that file not exist then a message should be displayed.
Any help would be appreciated.
To check for the existence of a file you can use the FileSearch-element in combination with the DirectorySearch-element. For an example you can take a look at How To: Check the Version Number of a File During Installation (you don't have to use the version part for your needs).
For displaying the dialog you can create your own SpawnDialog like described here. Another alternative would be to add the text as property to the Welcome-dialog and set the property based on your findings. Still another way would be to include a second Welcome-dialog and then invoke the needed one as described in this stackoverflow-question.

Resources