Xtext indentation with single line comment - comments

I was having problems with indentation and single line comments in my xtext grammar. I tried the same thing in xtext example project
org.eclipse.xtext.example.homeautomation
(with Xtext installed, you can import this project like this:
File → New → Example → Xtext Examples → Xtext Home Automation Example)
and results were the same. Is this and xtext bug? If so how can i open document and preparse it (to get rid of sl comments) and then give it to xtext lexer?
Device Window can be open, closed
Device Heater can be on, off, error
Rule 'Save energy' when Window.open then //asdasdd
fire(Heater.off)
println('Another penny to the piggy bank!')
Marker text:
1: - missing RULE_BEGIN at 'fire'
2: - mismatched input ''expecting RULE_END
Thanks.

can you file a ticket at eclipse for that
you may use the following workaround (dont know if there are negative side effects
terminal SL_COMMENT: '//' !('\n'|'\r')*;

Related

Validating YAML file in PhpStorm

I'm working on a project where YAMLs are used (among other use cases) for storing synonym lists. A file may look a little like this:
- "streifen,gestreift"
- "fleeceoverall,fleeceanzug"- "federball,badminton"
- "hochgarage,parkgarage"
In this case - "federball,badminton" is on the same row as - "fleeceoverall,fleeceanzug" which causes the build of the application to fail with an error stating
Unexpected characters near "- "federball,badminton".
I tried to configure a code style profile for code inspections as mentioned here in the PhpStorm documentation:
https://www.jetbrains.com/help/phpstorm/customizing-profiles.html?keymap=secondary_default_for_macos
But I don't know what to adjust here. I using the IDE-Standard which looks like this for wrapping and braces (which I guess is what I'm looking for ;) :
I also took a look at validating my YAML against a JSON file as mentioned here: https://www.jetbrains.com/help/phpstorm/yaml.html# but ultimately I don't understand how this works :/
So I guess I'm a little lost on how to avoid the errors at build time beforehand and would love some advice!

ESlint: Expected !== and instead saw !=

i have already tried to find eslint rules or options in the project but i could not find these.
i am using angularjs with mvc5 template type of aspnet zero.
How to disable eqeqeq in visual studio for eslint in aspnet zero ?
The OP is asking how to disable this One Rule for the Entire Project.
The eqeqeq rule is explained here: https://eslint.org/docs/rules/eqeqeq
Disable One Rule at the Project Level:
To change one rule for the entire project, you should edit the .eslintrc file.
To find this file, you could look up the file path in Visual Studio 2017 using:
Tools -> Options -> TextEditor -> JavaScript/TypeScript -> Linting
It'll probably be somewhere like: C:\Users\<UserName>\.eslintrc
Editing the file you will see this near the top (around Line 20):
"rules": {
"eqeqeq": 2,
The following are synonymous: 0 = "off", 1 = "warn", and 2 = "error".
You may disable the rule by changing the 2nd line to this:
"eqeqeq": "off",
I based this off of the information found here:
https://eslint.org/docs/user-guide/configuring#configuring-rules
Disable One Rule at the File Level:
Add this line in your File:
/*eslint-disable eqeqeq*/
OR
/*eslint eqeqeq: "off"*/
It is important you add this near the top of your Javascript file before your scripts.
This is because it takes affect after the line you add this comment to.
How to do this is buried in this link under the section "Disabling Rules with Inline Comments":
https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments
Smarter is Better Than Disabling
If you're interested in changing the equality-operator warnings so they are "smarter" and won't always throw warnings (when it is obvious they do not apply), then this may be the better option.
This way you still keep these warnings when it really matters.
At the Project Level, use this in the .eslintrc file:
"eqeqeq": ["error", "smart"],
OR
At the File Level, use this:
/*eslint eqeqeq: ["error", "smart"]*/
This "Smart" feature is further explained here:
https://eslint.org/docs/rules/eqeqeq#smart
Dislaimer: I have verified this works at the File Level, but have not tested at the Project Level.
The .eslintrc file appears to be in Json, and these proposed edits fit the expected format.
It also follows the examples I found in the links above.
Add the below line to the JavaScript code to disable checking.
/*eslint eqeqeq: ["error", "smart"]*/
Create this file ".eslintrc" in the project's root directory and add the below code.
{
"rules": {
"eqeqeq": "off"
}
}
Note: for more info go to this page: https://eslint.org/docs/latest/user-guide/configuring/rules#disabling-rules

Strange compile-time representation of cyrillic string in Websharper

I crete new Websharper Sitlet project and declare string within main module like this
Next, I set a breakpoint, start debugging and found that the string does not contain what I wrote in it.
But how could it be?
And all cyrilic outup, which was created by the project by default, looks like this
Upd
Here is full solution with correct strings: https://yadi.sk/d/z-wOkQGQf7QTS
And here is the same with bad output: https://yadi.sk/d/Vy2hmOudf7QaT
I can not realise what is the difference.
Just open and save your files, containing Cyrillic characters: Client.fs, Main.fs ... to Unicode, rebuild the solution and it will show Cyrillic on the application web page.

RMarkdown error in YAML

I watched a great webinar by RStudio the other day about RMarkdown. After the webinar they posted the code used in the demonstrations online and I wanted to check out one example. I took their code, put it in my RStudio (which says it's fully up-to-date, v0.98.978), installed or updated all the necessary packages and hit "Run Document"
I receive an error which I do not understand and for which Google has been very unhelpful. What is this mysterious <document start> and how do I include it? I assumed all necessary components would be included given the source of the code.
Error in yaml::yaml.load(front_matter) :
Parser error: did not find expected <document start> at line 2, column 1
Calls: <Anonymous> -> parse_yaml_front_matter -> <Anonymous> -> .Call
Execution halted
The issue came from copying the code from the browser to Rstudio.
The original header information was:
---
title: "Linked brushing"
output: html_document
runtime: shiny
---
the pasted text was:
---
title: "Linked brushing"
output: html_document
runtime: shiny
---
The missing <document start> was an unequal amount of white space before each element of the header. This can be fixed by adding white space to the 'output' and 'runtime' lines or by removing the white space of the 'title' line.
Another frequent cause of this error message is using tabs instead of spaces to indent your YAML code. You can only use SPACES to indent YAML, not TABS. I am writing this for my future self to find here.
title: "Initial Results"
output:
pdf_document:
toc: true
This is not the case but the same type of error can occur when using pkgdown::build_site or, more viciously, pkgdown::build_article. When using the latter to build a specific vignette for a package, I noticed that internally the headers of all the vignettes are parsed. Therefore, even if the specific vignette you are building is correct, the error occurs without specification of which file's header is corrupt. So, you might find yourself struggling to debug a header which is in fact correct, when the problem is in another file.
In my case, I needed to add a single space after the three dashes at the top of the YAML header:
---[single space here -without the squared brackets]
title: "Linked brushing"
output: html_document
runtime: shiny
Delete a file from the directory may cause a similar problem as well. Yaml, markdown, knitr should be reinstall after removing from where ever it is located .../R/library.

Custom syntax highlighting in Geany

I am trying to create custom syntax highlighting for Kivy '.kv' files in the Geany editor. Although the specific filetype seems irrelavant to the issue I'm having, as any efforts I make at getting syntax highlighting to work for a custom filetype results in a completely non-highlighted file. I believe I have done my homework on this, and nothing seems to work.
I have added the following to ~/.config/geany/filetype_extensions.conf
Kivy=*.kv;
I also have a custom type definition file named 'filetypes.Kivy.conf' in ~/.config/geany/filedefs/. I have tried basing this file off several of the stock type definition files in /usr/share/geany/ and the file never gets any syntax highlighting applied in Geany. Right now, just for experimentation's sake, my 'filetypes.Kivy.conf' file looks like this:
# For complete documentation of this file, please see Geany's main documentation
[settings]
# default extension used when saving files
extension=kv
# single comments, like # in this file
comment_single=#
[keywords]
# all items must be in one line
primary=size canvas
secondary=pos size
[indentation]
width=4
# 0 is spaces, 1 is tabs, 2 is tab & spaces
type=0
This is very loosly based on the stock XML definition file, but like I said I've tried many other stock files. In many cases I only changed the 'extension=' value to kv and still no highlighting was applied, even though going to Document>Set Filetype in Geany and choosing virtually any random filetype (besides my custom entry) would yeild some sort of highlighting within my .kv file. This is even the case when using the unmodified contents of a stock definition which otherwise works fine on my .kv file when specifically selected in Geany!
Also, the Kivy filetype is listed and selected by default in Document>Set Filetype within Geany, so I must be doing something right here!
I realize this similar question has been asked, but the solutions seem irrelavent to my case, as I've tried every related topic on this and many other sites. My Geany version is 1.22 and I'm running Arch Linux. This is driving me nuts - any suggestions?
Thank you!
Set lexer_filetype= property in the [settings] section of your filetype file. Working highlighting requires that there is a lexer that could be used for highlighting the .kv-files.
For more info see http://www.geany.org/manual/#lexer-filetype
There are three important things to obey:
the configuration file should be placed in "~/.config/geany/filedefs"
the configuration file must have the extension ".conf" - otherwise it won't show up at all (the files in "/usr/share/geany/filesdefs", where I copied my base file from, do not have a ".conf" extension!)
you must set the "lexer_filetype" to an existing (presumably builtin) configuration; e.g. "lexer_filetype=Python"

Resources