Skip to content

Commit

Permalink
Fix range must be inside element being annotated exception
Browse files Browse the repository at this point in the history
  • Loading branch information
vilinfield committed Apr 9, 2021
1 parent 5b2dbe3 commit 9e9644a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -42,6 +42,10 @@ Plugin is available through the [Jetbrains plugin repository](https://plugins.je

## Release Notes

**Version 0.4.1**

* Fix range must be inside element being annotated exception

**Version 0.4.0**

* Maintainer change from Yi-Fan Zhang (yifanz) to Victor Linfield (vilinfield)
Expand Down
8 changes: 7 additions & 1 deletion resources/META-INF/plugin.xml
@@ -1,7 +1,7 @@
<idea-plugin url="https://github.com/vilinfield/Intellij-Dust">
<id>com.github.vilinfield.dust</id>
<name>Dust.js</name>
<version>0.4.0</version>
<version>0.4.1</version>
<vendor>Victor Linfield</vendor>

<description><![CDATA[
Expand All @@ -27,6 +27,12 @@
]]></description>

<change-notes><![CDATA[
<b>Version 0.4.1</b>
<ul>
<li>
Fix range must be inside element being annotated exception
</li>
</ul>
<b>Version 0.4.0</b>
<ul>
<li>
Expand Down
16 changes: 6 additions & 10 deletions src/com/github/vilinfield/dust/DustAnnotator.java
@@ -1,13 +1,12 @@
package com.github.vilinfield.dust;

import com.github.vilinfield.dust.psi.DustCloseTag;
import com.github.vilinfield.dust.psi.DustOpenTag;
import com.github.vilinfield.dust.psi.DustTypes;
import com.intellij.lang.annotation.AnnotationHolder;
import com.intellij.lang.annotation.Annotator;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.github.vilinfield.dust.psi.DustCloseTag;
import com.github.vilinfield.dust.psi.DustOpenTag;
import com.github.vilinfield.dust.psi.DustTypes;
import org.jetbrains.annotations.NotNull;

import java.util.regex.MatchResult;
Expand Down Expand Up @@ -40,8 +39,7 @@ public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolde
{
MatchResult mr = m.toMatchResult();
TextRange tr = new TextRange(startOffset + mr.start(), startOffset + mr.end());
holder.newSilentAnnotation(HighlightSeverity.ERROR).range(tr)
.textAttributes(DustSyntaxHighlighter.TODO).create();
holder.createInfoAnnotation(tr, null).setTextAttributes(DustSyntaxHighlighter.TODO);
}
}
}
Expand Down Expand Up @@ -70,13 +68,11 @@ private static void checkMatchingCloseTag(DustOpenTag openTag, AnnotationHolder
sibling = sibling.getNextSibling();
}

holder.newAnnotation(HighlightSeverity.ERROR,
"Could not find matching closing tag " + getTagName(openTag)).range(openTag.getTextRange()).create();
holder.createErrorAnnotation(openTag.getTextRange(), "Could not find matching closing tag " + getTagName(openTag));

if (closeTag != null)
{
holder.newAnnotation(HighlightSeverity.ERROR,
"Could not find matching opening tag " + getTagName(closeTag)).range(closeTag.getTextRange()).create();
holder.createErrorAnnotation(closeTag.getTextRange(), "Could not find matching opening tag " + getTagName(closeTag));
}
}

Expand Down

0 comments on commit 9e9644a

Please sign in to comment.