Skip to content

Commit

Permalink
add support BSLParser 0.23
Browse files Browse the repository at this point in the history
  • Loading branch information
bia-tech committed Dec 18, 2023
1 parent 7f29d83 commit 3dc9e5d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class BSLHighlighter {
private static final Set<Integer> SDBL_STRINGS = createSdblStrings();
private static final Set<Integer> SDBL_COMMENTS = createSdblComments();
private static final Set<Integer> SDBL_PARAMETERS = createSdblParameters();
private static final Set<Integer> SDBL_EDS = createSdblEDS();

private final SensorContext context;

Expand Down Expand Up @@ -258,6 +259,8 @@ private static TypeOfText getTypeOfTextSDBL(int tokenType) {
typeOfText = TypeOfText.COMMENT;
} else if (SDBL_PARAMETERS.contains(tokenType)) {
typeOfText = TypeOfText.ANNOTATION;
} else if (SDBL_EDS.contains(tokenType)) {
typeOfText = TypeOfText.KEYWORD_LIGHT;
} else {
typeOfText = null;
}
Expand Down Expand Up @@ -525,7 +528,30 @@ private static Set<Integer> createSdblFunctions() {
SDBLLexer.VALUETYPE,
SDBLLexer.WEEK,
SDBLLexer.WEEKDAY,
SDBLLexer.YEAR
SDBLLexer.YEAR,
SDBLLexer.INT,
SDBLLexer.ACOS,
SDBLLexer.ASIN,
SDBLLexer.ATAN,
SDBLLexer.COS,
SDBLLexer.SIN,
SDBLLexer.TAN,
SDBLLexer.LOG,
SDBLLexer.LOG10,
SDBLLexer.EXP,
SDBLLexer.POW,
SDBLLexer.SQRT,
SDBLLexer.LOWER,
SDBLLexer.STRINGLENGTH,
SDBLLexer.TRIMALL,
SDBLLexer.TRIML,
SDBLLexer.TRIMR,
SDBLLexer.UPPER,
SDBLLexer.ROUND,
SDBLLexer.STOREDDATASIZE,
SDBLLexer.UUID,
SDBLLexer.STRFIND,
SDBLLexer.STRREPLACE
);
}

Expand Down Expand Up @@ -610,6 +636,14 @@ private static Set<Integer> createSdblParameters() {
);
}

private static Set<Integer> createSdblEDS() {
return Set.of(
SDBLLexer.EDS_CUBE,
SDBLLexer.EDS_TABLE,
SDBLLexer.EDS_CUBE_DIMTABLE
);
}

@Data
@RequiredArgsConstructor
@EqualsAndHashCode(exclude = "active")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,30 @@ private Map<String, TypeOfText> getHighlightingMapSDBL(Vocabulary vocabulary) {
"VALUETYPE",
"WEEK",
"WEEKDAY",
"YEAR"
"YEAR",
"INT",
"ACOS",
"ASIN",
"ATAN",
"COS",
"SIN",
"TAN",
"LOG",
"LOG10",
"EXP",
"POW",
"SQRT",
"LOWER",
"STRINGLENGTH",
"TRIMALL",
"TRIML",
"TRIMR",
"UPPER",
"ROUND",
"STOREDDATASIZE",
"UUID",
"STRFIND",
"STRREPLACE"
);

Set<String> metadataTypes = Set.of(
Expand Down Expand Up @@ -460,6 +483,12 @@ private Map<String, TypeOfText> getHighlightingMapSDBL(Vocabulary vocabulary) {
"BAR" // TODO: Убрать из лексера
);

Set<String> eds = Set.of(
"EDS_CUBE",
"EDS_TABLE",
"EDS_CUBE_DIMTABLE"
);

var maxTokenType = vocabulary.getMaxTokenType();

Map<String, TypeOfText> highlightingMap = new HashMap<>();
Expand All @@ -485,6 +514,8 @@ private Map<String, TypeOfText> getHighlightingMapSDBL(Vocabulary vocabulary) {
typeOfText = TypeOfText.KEYWORD_LIGHT;
} else if (virtualTables.contains(ruleName)) {
typeOfText = TypeOfText.KEYWORD_LIGHT;
} else if (eds.contains(ruleName)) {
typeOfText = TypeOfText.KEYWORD_LIGHT;
} else if (ruleName.equals("STR")) {
typeOfText = TypeOfText.STRING;
} else if (ruleName.contains("LINE_COMMENT")) {
Expand Down

0 comments on commit 3dc9e5d

Please sign in to comment.