How to check naming conventions violations in Notepad++? - naming-conventions

We use Notepad++ for Java coding. We need to follow some project specific naming conventions.
For instance, String should starts with an S, and Map, M.
In Notepad++, how can I highlight if any mismatches in the naming convention are there, while coding?

I recommend maintaining your current convention for syntax highlighting, but not for style checks.
Use checkstyle with your own custom rules, and consider adding it to your build process.

Related

Xtext based language within Intellij Idea

I want to make a plugin for a language for the Intellij Idea IDE. The language has been developped using Eclipse Xtext and is open source. A plugin already exists for Eclipse.
My goal is to port this language to Intellij Idea. I want to be able to use Intellij to create source files, to have the specific syntax highlighting and to be able to compile and run programs written with this language.
Is there a simple way to generate the Intellij Idea plugin using the Xtext project?
If not is there an efficient solution to be able to have the specific syntax highlighting in Intellij? (an automatic way if possible, I would prefer not rewriting everything everytime the Xtext project is updated)
Short answer
Yes, with a bit of work.
Long Answer
Sadly, Xtext uses antlr in the background and IntelliJ use their own grammar kit based on Parsing Expression Grammars. As such, the parsing and editor code generated by XText, as you might have guessed, will not work.
In order to get your language working in IntelliJ you will need to:
Create grammar *.bnf file
Generate lexer *.flex file, possibly tweak it and then run JFlex generator
Implement helper classes to provide, among others, file recognition via file extension, syntax highlighting, color settings page, folding, etc.
The *.flex file is generated from the bnf. Luckily, most of the classes in step 3 follow a very similar structure so they can be easily generated (more on that later). So basically, if you manage to generate the *.bnf file, you are 80% there.
Although from different technologies, the syntax of bnf files is very similar to XText files. I recently migrated some antlr grammars to IntelliJ's bnf and I had to do very small changes. Thus, it should be possible to autogenerate the bnf files from your XText ones.
That brings me back to point 3. Using XTend, Epsilon's EGL, or similar, it would be easy to generate all the boiler plate classes. As part of the migration I mentioned before I also did this. I am in the process of making the code public, so I will post it here when done and add some details.

IntelliJ: custom language: combine fragments in other languages

I am creating a custom language plugin for IntelliJ.
I would like it to be possible for a file in the new language to contain fragments of text in other languages.
The specific languages I would like to support are HTML, JS, CSS, and SQL.
I would also like to support other custom languages (i.e. languages I would define the syntax for).
The main feature I want is syntax coloring, but if I can get stuff like "go to declaration" and refactoring out of the box then all the better.
My last requirement is that it would be possible to use my own code to tell IntelliJ which language a fragment contains; fragments containing different languages will not be distinguishable at the lexer / parser level.
In short, I would like to implement something similar to what PhpStorm does when it detects, say, SQL inside a string:
I looked at IntelliJ's source code and found the ILazyParseableElementType interface which seemed relevant, but I'm not sure if this is the way to go (and if so - how to use it in my code exactly...)
Any pointers would be highly appreciated...
The Intellij feature/terminology you are looking for is Language Injections.
Here is a github PR which implements a very similar feature for JFLex files.
In short you need to implement a LanguageInjector and add it to your plugin.xml as a <languageInjector implementation="YourImplClass">.

Removing numerous annotations automatically in IntelliJ

I have a package that contains lots of classes, each having lots of annotations. Is there any way to delete all the annotations automatically, rather than manually deleting them one by one?
I'm using the latest version of IntelliJ IDEA. I cannot use search and replace, because there are a lot of different annotations.
IntelliJ has a feature called Structural Search and Replace. You could use it to find all annotations and replace with nothing. I have never really used this feature so can't offer you the exact search you need to use. The best I can offer is a link to the documentation for this feature. I am sure this feature can do what you want though:
http://www.jetbrains.com/idea/webhelp/structural-search-and-replace.html

How to Implement org.eclipse.wst.sse.ui.semanticHighlighting

I'm trying to implement content-assist and some custom highlighting as a plugin for Eclipse, after a lot of research I found this eclipse document.
I got content-assist working for XML documents, the problem is the part about SemanticHighlighting, I didn't find any information about how to implement this extension-point and I'm a bit lost. The only info that I found is the XSD for the extension point.
I'm trying to make some customs expressions on XML get a different color Ex:
<span>%%colored_text%%</span>
Where can I get more information about this org.eclipse.wst.sse.ui.semanticHighlighting and how to implement it?
I don't think there's a lot of a documentation on the semantic highlighting for SSE. The document that you found is a little light on details. For an example, the XSL project implemented semantic highlighting using the extension point.
The basic idea behind the semantic highlighting extension point is that when a change occurs, implementors will be asked if it can 'consume' a region of the document. If it can, it will return an array of Positions that can be highlighted by that particular highlighter. It can apply only one style, so it ends up being very specific. For example, you wouldn't be able to say 'color this part of the region blue and this other part of the region red'. You would need two separate highlighters to accomplish that.
The highlighter obtains style information for the highlight by using a preference store that you return from getPreferenceStore(). You'll then need to set up keys that the highlighter will use to look up styles from that preference store. If you use the styleStringKey on the extension point, the only key of importance from the semantic highlighting implementation is the one returned from getEnabledPreferenceKey(). This is kind of the condensed way to declare a style, as it only takes 2 preferences to get going. The semantic highlighting framework knows how the parse the string value returned by the preference store for the styleStringKey into the appropriate style components. Just follow the format as defined on the New Help for Old Friends document that you linked to.
Now, if you want to keep all the style components separate, the other get*PreferenceKey() methods become important. You'll have to define keys for each of them, and then add default values for each of those keys in your preference initializer.
org.eclipse.wst.xsl.ui.internal.preferences.XSLUIPreferenceInitializer has examples of both ways to define these style defaults.

Hungarian notation in Intellij IDEA

I have to do some maintenance on legacy code that uses Hungarian notation (and Systems Hungarian at that). Unfortunately, it's not practical for me to just clean it all out of the codebase.
Local Eclipse users claim that Eclipse can be configured so that auto-generated accessors and whatnot ignore the Hungarian prefixes (which is probably why they've been able to live with them for so long).
Is there any similar functionality in IDEA 10.5? It'd be nice if 'find usages' on m_sInstruction was smart enough to realize that getInstruction() is a getter, and give me the 'do you want to search for accessors?' prompt, for instance, or if 'generate getters and setters' could tell that this class already has them for almost all fields.
Settings | Code Style | Java | Code Generation, set the Name prefix for Field and Static field.