|
1 | 1 | package com.sgaop.idea.annotator; |
2 | 2 |
|
3 | | -import com.intellij.lang.annotation.Annotation; |
| 3 | +import com.intellij.lang.annotation.AnnotationBuilder; |
4 | 4 | import com.intellij.lang.annotation.AnnotationHolder; |
5 | 5 | import com.intellij.lang.annotation.HighlightSeverity; |
6 | 6 | import com.intellij.openapi.util.TextRange; |
@@ -33,16 +33,22 @@ public boolean isSqlsXml(@NotNull PsiElement psiElement) { |
33 | 33 | */ |
34 | 34 | @Override |
35 | 35 | public void process(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) { |
36 | | - List<VirtualFile> virtualFileList = SqlsXmlUtil.findTemplteFileList(psiElement); |
37 | | - if (virtualFileList.size() == 0) { |
38 | | - TextRange textRange; |
39 | | - if (psiElement.getNextSibling().getChildren().length == 0) { |
40 | | - textRange = psiElement.getTextRange(); |
41 | | - } else { |
42 | | - textRange = new TextRange(psiElement.getTextRange().getStartOffset(), psiElement.getNextSibling().getTextRange().getEndOffset()); |
| 36 | + try { |
| 37 | + List<VirtualFile> virtualFileList = SqlsXmlUtil.findTemplteFileList(psiElement); |
| 38 | + if (virtualFileList.size() == 0) { |
| 39 | + TextRange textRange; |
| 40 | + if (psiElement.getNextSibling().getChildren().length == 0) { |
| 41 | + textRange = psiElement.getTextRange(); |
| 42 | + } else { |
| 43 | + textRange = new TextRange(psiElement.getTextRange().getStartOffset(), psiElement.getNextSibling().getTextRange().getEndOffset()); |
| 44 | + } |
| 45 | + AnnotationBuilder annotationBuilder = annotationHolder.newAnnotation(HighlightSeverity.ERROR, ERR_MSG); |
| 46 | + annotationBuilder.range(textRange); |
| 47 | + AnnotationBuilder.FixBuilder fixBuilder = annotationBuilder.newFix(new GenerateSqlXmlIntention()); |
| 48 | + fixBuilder.registerFix(); |
| 49 | + annotationBuilder.create(); |
43 | 50 | } |
44 | | - Annotation annotation = new Annotation(textRange.getStartOffset(), textRange.getEndOffset(), HighlightSeverity.ERROR, ERR_MSG, null); |
45 | | - annotation.registerFix(new GenerateSqlXmlIntention()); |
| 51 | + } catch (Exception e) { |
46 | 52 | } |
47 | 53 | } |
48 | 54 | } |
0 commit comments