You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You must implement the ILanguage interface and override following methods:
getName(): return the display name of the plugin
getId(): return your custom plugin identifier
getFileExtension(): return the list of file extensions that the plugin can analyze
packagefr.cnes.icode.mycustomplugin.language;
importfr.cnes.icode.services.languages.ILanguage;
importjava.util.List;
importjava.util.stream.Collectors;
importjava.util.stream.Stream;
/** * Definition of the C language. */publicclassMyCustomLanguageimplementsILanguage {
/** * @return the name of the language. */@OverridepublicStringgetName() {
return"My Custom Language";
}
/** * @return the id of the language. */@OverridepublicStringgetId() {
return"fr.cnes.icode.mycustomlanguage";
}
/** * @return the list of extensions of the language. */@OverridepublicList<String> getFileExtension() {
returnStream.of(
"bl", "BL", "blue", "BLUE"
).collect(Collectors.toList());
}
}
3. Implement your own checker
3.1. Using plain Java implementation
You can write your own checker in pure Java by overriding AbstractChecker abstract class. You need to implement run() method.
This method should return content the value returned by getCheckResults() which is a list built by calling setError() when your algorithm finds some issue on the file given by getInputFile().
Do not override name, id, languageId and inputFile: they will be automatically built by i-Code framework through information you gave in xml rules definition file.
3.2. Using LEX
For writing some lex checkers you can find examples here:
This code assumes your lex files lay in src/main/resources/lex.
4. Expose your checkers
In the project's resources, add an xml file containing checkers definition.
<?xml version="1.0" encoding="UTF-8"?>
<checkers>
<checkclass="fr.cnes.icode.mycustomplugin.checkers.NoToDo"id="fr.cnes.icode.mycustomplugin.checkers.NoToDo"name="No TODO in comment"languageId="fr.cnes.icode.mycustomlanguage">
</check>
<checkclass="fr.cnes.icode.mycustomplugin.checkers.NoFloat"id="fr.cnes.icode.mycustomplugin.checkers.NoFloat"name="No floating number should be used"languageId="fr.cnes.icode.mycustomlanguage">
</check>
</checkers>
Attribute class shall point to the real implementation class of the checker but attribute id can be set to any unique value.
Then, override CheckersDefinition class to declare your checkers in code by adding your XML definition through addFromResources() method.
packagefr.cnes.icode.mycustomplugin.checkers;
importfr.cnes.icode.data.CheckersDefinition;
/** * Define checkers to be supported by this plugin. */publicclassMyCustomCheckersDefinitionextendsCheckersDefinition {
/** * Override this method to inject checkers in containers field. */@Overridepublicvoiddefine() {
addFromResources("/my-custom-checkers.xml");
}
}
If your xml definition file is in the root of resources directory and is named my-custom-checkers.xml, you should be able to import it in define() thanks to this instruction: addFromResources("/my-custom-checkers.xml");.
5. Test your plugin
Testing your plugin is as easy as copy & paste this generic test class. You just have to provide information about code used to test your plugin: