This repository has been archived by the owner on May 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #224 from codiga/rosie-javascript-support
#221: Added JavaScript and TypeScript language support.
- Loading branch information
Showing
11 changed files
with
233 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/main/java/io/codiga/plugins/jetbrains/model/rosie/RosieRuleAstTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package io.codiga.plugins.jetbrains.model.rosie; | ||
|
||
import io.codiga.api.type.ElementCheckedEnumeration; | ||
|
||
/** | ||
* Provides values and mapping logic for rule AST types. | ||
*/ | ||
final class RosieRuleAstTypes { | ||
private final static String ENTITY_CHECKED_FUNCTION_CALL = "functioncall"; | ||
private final static String ENTITY_CHECKED_IF_CONDITION = "ifcondition"; | ||
private final static String ENTITY_CHECKED_IMPORT = "import"; | ||
private final static String ENTITY_CHECKED_ASSIGNMENT = "assign"; | ||
private final static String ENTITY_CHECKED_FOR_LOOP = "forloop"; | ||
private final static String ENTITY_CHECKED_FUNCTION_DEFINITION = "functiondefinition"; | ||
private final static String ENTITY_CHECKED_TRY_BLOCK = "tryblock"; | ||
private final static String ENTITY_CHECKED_TYPE = "type"; | ||
private final static String ENTITY_CHECKED_INTERFACE = "interface"; | ||
private final static String ENTITY_CHECKED_HTML_ELEMENT = "htmlelement"; | ||
private final static String ENTITY_CHECKED_CLASS_DEFINITION = "classdefinition"; | ||
private final static String ENTITY_CHECKED_FUNCTION_EXPRESSION = "functionexpression"; | ||
|
||
/** | ||
* Maps the argument element checked to its Rosie counterpart value. | ||
*/ | ||
static String elementCheckedToRosieEntityChecked(ElementCheckedEnumeration elementChecked) { | ||
if (elementChecked == null) { | ||
return null; | ||
} | ||
switch (elementChecked) { | ||
case FORLOOP: | ||
return ENTITY_CHECKED_FOR_LOOP; | ||
case ASSIGNMENT: | ||
return ENTITY_CHECKED_ASSIGNMENT; | ||
case FUNCTIONDEFINITION: | ||
return ENTITY_CHECKED_FUNCTION_DEFINITION; | ||
case TRYBLOCK: | ||
return ENTITY_CHECKED_TRY_BLOCK; | ||
case IMPORT: | ||
return ENTITY_CHECKED_IMPORT; | ||
case IFCONDITION: | ||
return ENTITY_CHECKED_IF_CONDITION; | ||
case FUNCTIONCALL: | ||
return ENTITY_CHECKED_FUNCTION_CALL; | ||
case TYPE: | ||
return ENTITY_CHECKED_TYPE; | ||
case INTERFACE: | ||
return ENTITY_CHECKED_INTERFACE; | ||
case HTMLELEMENT: | ||
return ENTITY_CHECKED_HTML_ELEMENT; | ||
case CLASSDEFINITION: | ||
return ENTITY_CHECKED_CLASS_DEFINITION; | ||
case FUNCTIONEXPRESSION: | ||
return ENTITY_CHECKED_FUNCTION_EXPRESSION; | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
private RosieRuleAstTypes() { | ||
//Utility class | ||
} | ||
} |
4 changes: 1 addition & 3 deletions
4
src/main/java/io/codiga/plugins/jetbrains/rosie/CodigaRulesetConfigs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/io/codiga/plugins/jetbrains/utils/RosieLanguageSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package io.codiga.plugins.jetbrains.utils; | ||
|
||
import io.codiga.api.type.LanguageEnumeration; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* Utility for the Rosie integration. | ||
*/ | ||
public final class RosieLanguageSupport { | ||
|
||
/** | ||
* Currently supported languages by Rosie. | ||
*/ | ||
private static final Set<LanguageEnumeration> SUPPORTED_LANGUAGES = Set.of( | ||
LanguageEnumeration.PYTHON, | ||
LanguageEnumeration.JAVASCRIPT, | ||
LanguageEnumeration.TYPESCRIPT); | ||
|
||
/** | ||
* Returns whether the argument language is supported by Rosie. | ||
* | ||
* @param fileLanguage the language to check | ||
*/ | ||
public static boolean isLanguageSupported(LanguageEnumeration fileLanguage) { | ||
return SUPPORTED_LANGUAGES.contains(fileLanguage); | ||
} | ||
|
||
/** | ||
* Returns the Rosie language string of the argument Codiga language. | ||
* | ||
* @param language the Codiga language to map to Rosie language | ||
*/ | ||
public static String getRosieLanguage(LanguageEnumeration language) { | ||
switch (language) { | ||
case PYTHON: | ||
return "python"; | ||
case JAVASCRIPT: | ||
return "javascript"; | ||
case TYPESCRIPT: | ||
return "typescript"; | ||
default: | ||
return "unknown"; | ||
} | ||
} | ||
|
||
private RosieLanguageSupport() { | ||
//Utility class | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
src/main/java/io/codiga/plugins/jetbrains/utils/RosieUtils.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.