Skip to content

Commit

Permalink
fixed handling of line breaks after a bnd.bnd comment
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarks2 committed Jan 10, 2022
1 parent f3f950c commit 8be0e07
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ private static void _annotate(
PsiElement psiElement, TextAttributesKey textAttributesKey, AnnotationHolder annotationHolder) {

if (psiElement != null) {
annotationHolder.newAnnotation(
HighlightSeverity.INFORMATION, ""
annotationHolder.newSilentAnnotation(
HighlightSeverity.INFORMATION
).range(
psiElement
).textAttributes(
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/de/dm/intellij/bndtools/lexer/BndLexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void parseNextToken() {
if (c == '\n') {
break;
}
commentEnd++;
++commentEnd;
}

tokenType = BndTokenType.COMMENT;
Expand Down Expand Up @@ -150,8 +150,14 @@ else if (!defaultState && c == ' ') {
defaultState = true;
IElementType special;
if (c == '\n') {
tokenType = BndTokenType.NEWLINE;
tokenEnd = tokenStart + 1;
if (tokenType == BndTokenType.COMMENT) {
//end of comment
tokenType = BndTokenType.SECTION_END;
tokenEnd = tokenStart + 1;
} else {
tokenType = BndTokenType.NEWLINE;
tokenEnd = tokenStart + 1;
}
}
else if ((special = SPECIAL_CHARACTERS_TOKEN_MAP.get(c)) != null) {
tokenType = special;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.dm.intellij.bndtools;

import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.markup.TextAttributes;
Expand Down Expand Up @@ -28,8 +29,12 @@ public void testLineCommentHighlighting() {

List<HighlightInfo> highlightInfos = myFixture.doHighlighting();

HighlightInfo highlightInfo = highlightInfos.get(0);

assertEquals(lineCommentTextAttributes, highlightInfo.getTextAttributes(null, globalScheme));
for (HighlightInfo highlightInfo : highlightInfos) {
if (highlightInfo.getSeverity() == HighlightSeverity.INFORMATION) {
assertEquals(lineCommentTextAttributes, highlightInfo.getTextAttributes(null, globalScheme));
} else {
fail("unexpected Highlighting Info found: " + highlightInfo);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#This is a <caret>comment
#This is a <caret>comment

0 comments on commit 8be0e07

Please sign in to comment.