Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,11 @@ private static List<SemanticTokensEdit> computeEdits(int[] prev, int[] curr) {
* При вставке текста без перевода строки (lineOffset == 0), первый токен
* может иметь смещённый deltaStart.
*/
private static int findSuffixMatchWithOffset(int[] prev, int[] curr, int firstDiffToken, int lineOffset, int tokenSize) {
private static int findSuffixMatchWithOffset(int[] prev,
int[] curr,
int firstDiffToken,
int lineOffset,
int tokenSize) {
final int DELTA_LINE_INDEX = 0;
final int DELTA_START_INDEX = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ private void addBslDocTokensWithMultilineSupport(
String lineText = lines[lineIdx];
int charOffset = (lineIdx == 0) ? fileStartChar : 0;

var lineElements = elementsByLine.getOrDefault(lineIdx, List.of());
var lineElements = elementsByLine.getOrDefault(fileLine, List.of());

if (lineElements.isEmpty()) {
int startLineIdx = lineIdx;

while (lineIdx < lines.length) {
var nextLineElements = elementsByLine.getOrDefault(lineIdx, List.of());
var nextLineElements = elementsByLine.getOrDefault(fileLine, List.of());
if (!nextLineElements.isEmpty()) {
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,34 +102,38 @@ private void addDirectives(List<SemanticTokenEntry> entries, BSLParser.FileConte
// excluding region start/end, native, use (handled as Namespace)
private void addOtherPreprocs(List<SemanticTokenEntry> entries, BSLParser.FileContext ast) {
for (var preprocessor : Trees.<BSLParser.PreprocessorContext>findAllRuleNodes(ast, BSLParser.RULE_preprocessor)) {
boolean containsRegion = (preprocessor.regionStart() != null) || (preprocessor.regionEnd() != null);
var containsRegion = (preprocessor.regionStart() != null) || (preprocessor.regionEnd() != null);
if (containsRegion) {
continue; // region handled as Namespace above
}

// Find HASH token and keyword tokens to combine them into single token
Token hashToken = null;
boolean firstKeywordCombined = false;
addOtherPreprocs(entries, preprocessor);
}
}

for (Token token : Trees.getTokens(preprocessor)) {
if (token.getChannel() != Token.DEFAULT_CHANNEL) {
continue;
}
if (token.getType() == BSLLexer.HASH) {
hashToken = token;
} else {
String symbolicName = BSLLexer.VOCABULARY.getSymbolicName(token.getType());
if (symbolicName != null && symbolicName.startsWith("PREPROC_")) {
// Track keyword tokens for combining with HASH
if (hashToken != null && !firstKeywordCombined) {
// First keyword after HASH - combine them into single token
helper.addRange(entries, Ranges.create(hashToken, token), SemanticTokenTypes.Macro);
firstKeywordCombined = true;
} else {
// Subsequent keywords (e.g., "Сервер", "Тогда" in "#Если Сервер Тогда")
// or keyword without preceding HASH (shouldn't happen in valid syntax)
helper.addRange(entries, Ranges.create(token), SemanticTokenTypes.Macro);
}
private void addOtherPreprocs(List<SemanticTokenEntry> entries, BSLParser.PreprocessorContext preprocessor) {
// Find HASH token and keyword tokens to combine them into single token
Token hashToken = null;
var firstKeywordCombined = false;

for (Token token : Trees.getTokens(preprocessor)) {
if (token.getChannel() != Token.DEFAULT_CHANNEL) {
continue;
}
if (token.getType() == BSLLexer.HASH) {
hashToken = token;
} else {
var symbolicName = BSLLexer.VOCABULARY.getSymbolicName(token.getType());
if (symbolicName != null && symbolicName.startsWith("PREPROC_")) {
// Track keyword tokens for combining with HASH
if (hashToken != null && !firstKeywordCombined) {
// First keyword after HASH - combine them into single token
helper.addRange(entries, Ranges.create(hashToken, token), SemanticTokenTypes.Macro);
firstKeywordCombined = true;
} else {
// Subsequent keywords (e.g., "Сервер", "Тогда" in "#Если Сервер Тогда")
// or keyword without preceding HASH (shouldn't happen in valid syntax)
helper.addRange(entries, Ranges.create(token), SemanticTokenTypes.Macro);
}
}
}
Expand Down
Loading