From 7b5d0ef6cce4e6aeafbd39c89ee2314b61ccd8ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Kr=C3=A1sa?= Date: Mon, 11 Jan 2021 02:07:51 +0100 Subject: [PATCH] cleanup --- .../annotator/PlantUmlExternalAnnotator.java | 10 ++++----- .../annotator/SourceAnnotationResult.java | 22 ++++++------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/org/plantuml/idea/lang/annotator/PlantUmlExternalAnnotator.java b/src/org/plantuml/idea/lang/annotator/PlantUmlExternalAnnotator.java index 007e4ee1..7a1edc06 100644 --- a/src/org/plantuml/idea/lang/annotator/PlantUmlExternalAnnotator.java +++ b/src/org/plantuml/idea/lang/annotator/PlantUmlExternalAnnotator.java @@ -52,10 +52,10 @@ public FileAnnotationResult doAnnotate(PsiFile file) { String source = sourceData.getValue(); sourceAnnotationResult.addAll(PlantUmlFacade.get().annotateSyntaxErrors(file, source)); - List blockComments = annotateBlockComments(source); + List blockComments = annotateBlockComments(source); sourceAnnotationResult.addBlockComments(blockComments); - annotateByLine(sourceAnnotationResult, source, blockComments); + annotateByLine(sourceAnnotationResult, source); result.add(sourceAnnotationResult); } @@ -63,7 +63,7 @@ public FileAnnotationResult doAnnotate(PsiFile file) { return result; } - public void annotateByLine(SourceAnnotationResult result, String source, List blockComments) { + public void annotateByLine(SourceAnnotationResult result, String source) { Matcher keywords = LanguagePatternHolder.INSTANCE.keywordsPattern.matcher(""); Matcher pluginSettings = LanguagePatternHolder.INSTANCE.pluginSettingsPattern.matcher(""); Matcher types = LanguagePatternHolder.INSTANCE.typesPattern.matcher(""); @@ -97,8 +97,8 @@ private void annotate(SourceAnnotationResult result, String line, int i, TextAtt } } - private List annotateBlockComments(String source) { - List result = new ArrayList(); + private List annotateBlockComments(String source) { + List result = new ArrayList<>(); Matcher matcher = LanguagePatternHolder.INSTANCE.startBlockComment.matcher(source); Matcher endMatcher = null; diff --git a/src/org/plantuml/idea/lang/annotator/SourceAnnotationResult.java b/src/org/plantuml/idea/lang/annotator/SourceAnnotationResult.java index 3aadcf91..b07c293e 100644 --- a/src/org/plantuml/idea/lang/annotator/SourceAnnotationResult.java +++ b/src/org/plantuml/idea/lang/annotator/SourceAnnotationResult.java @@ -15,13 +15,13 @@ public class SourceAnnotationResult { private int sourceOffset; private final Collection annotations = new ArrayList(); - private int[][] skip; + private List blockComments; public SourceAnnotationResult(int sourceOffset) { this.sourceOffset = sourceOffset; } - public void addAll(Collection sourceAnnotations) { + public void addAll(Collection sourceAnnotations) { annotations.addAll(sourceAnnotations); } @@ -42,26 +42,18 @@ public void addWithBlockCommentCheck(SyntaxHighlightAnnotation syntaxHighlightAn } private boolean inBlockComment(SyntaxHighlightAnnotation syntaxHighlightAnnotation) { - for (int i = 0, skipLength = skip.length; i < skipLength; i++) { - int[] range = skip[i]; + for (int i = 0, blockCommentsSize = blockComments.size(); i < blockCommentsSize; i++) { + SyntaxHighlightAnnotation blockComment = blockComments.get(i); int startSourceOffset = syntaxHighlightAnnotation.startSourceOffset; - if (range[0] < startSourceOffset && startSourceOffset < range[1]) { + if (blockComment.getStartSourceOffset() < startSourceOffset && startSourceOffset < blockComment.getEndSourceOffset()) { return true; } } return false; } - public void addBlockComments(List blockComments) { - skip = new int[blockComments.size()][2]; - for (int i = 0, blockCommentsSize = blockComments.size(); i < blockCommentsSize; i++) { - SourceAnnotation blockComment = blockComments.get(i); - SyntaxHighlightAnnotation b = (SyntaxHighlightAnnotation) blockComment; - int startSourceOffset = b.getStartSourceOffset(); - int endSourceOffset = b.getEndSourceOffset(); - skip[i][0] = startSourceOffset; - skip[i][1] = endSourceOffset; - } + public void addBlockComments(List blockComments) { + this.blockComments = blockComments; addAll(blockComments); } } \ No newline at end of file