mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
Daemon highlighting API implemented (look for Language.getAnnotator()). JavaScript plugin searches for unresolved references.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package com.intellij.lang;
|
||||
|
||||
import com.intellij.codeFormatting.PseudoTextBuilder;
|
||||
import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.lang.cacheBuilder.WordsScanner;
|
||||
import com.intellij.lang.folding.FoldingBuilder;
|
||||
import com.intellij.lang.validation.Validator;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.PlainSyntaxHighlighter;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
||||
@@ -67,7 +67,7 @@ public abstract class Language {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Validator getValidator() {
|
||||
public Annotator getAnnotator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
134
openapi/src/com/intellij/lang/annotation/Annotation.java
Normal file
134
openapi/src/com/intellij/lang/annotation/Annotation.java
Normal file
@@ -0,0 +1,134 @@
|
||||
package com.intellij.lang.annotation;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightColors;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.openapi.editor.HighlighterColors;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: max
|
||||
* Date: Feb 3, 2005
|
||||
* Time: 6:42:42 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public final class Annotation {
|
||||
private final int myStartOffset;
|
||||
private final int myEndOffset;
|
||||
private final HighlightSeverity mySeverity;
|
||||
private final String myMessage;
|
||||
|
||||
private ProblemHighlightType myHighlightType = ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
|
||||
private TextAttributesKey myEnforcedAttributes = null;
|
||||
private List<Pair<IntentionAction, TextRange>> myQuickFixes = null;
|
||||
private Boolean myNeedsUpdateOnTyping = null;
|
||||
private String myTooltip;
|
||||
private boolean myAfterEndOfLine = false;
|
||||
|
||||
public Annotation(final int startOffset, final int endOffset, final HighlightSeverity severity, final String message, String tooltip) {
|
||||
myStartOffset = startOffset;
|
||||
myEndOffset = endOffset;
|
||||
myMessage = message;
|
||||
myTooltip = tooltip;
|
||||
mySeverity = severity;
|
||||
}
|
||||
|
||||
public void registerFix(IntentionAction fix) {
|
||||
registerFix(fix, null);
|
||||
}
|
||||
|
||||
public void registerFix(IntentionAction fix, TextRange range) {
|
||||
if (range == null) {
|
||||
range = new TextRange(myStartOffset, myEndOffset);
|
||||
}
|
||||
if (myQuickFixes == null) {
|
||||
myQuickFixes = new ArrayList<Pair<IntentionAction, TextRange>>();
|
||||
}
|
||||
myQuickFixes.add(new Pair<IntentionAction, TextRange>(fix, range));
|
||||
}
|
||||
|
||||
public void setNeedsUpdateOnTyping(boolean b) {
|
||||
myNeedsUpdateOnTyping = Boolean.valueOf(b);
|
||||
}
|
||||
|
||||
public boolean needsUpdateOnTyping() {
|
||||
if (myNeedsUpdateOnTyping == null) {
|
||||
return mySeverity != HighlightSeverity.INFORMATION;
|
||||
}
|
||||
|
||||
return myNeedsUpdateOnTyping.booleanValue();
|
||||
}
|
||||
|
||||
public int getStartOffset() {
|
||||
return myStartOffset;
|
||||
}
|
||||
|
||||
public int getEndOffset() {
|
||||
return myEndOffset;
|
||||
}
|
||||
|
||||
public HighlightSeverity getSeverity() {
|
||||
return mySeverity;
|
||||
}
|
||||
|
||||
public ProblemHighlightType getHighlightType() {
|
||||
return myHighlightType;
|
||||
}
|
||||
|
||||
public TextAttributesKey getTextAttributes() {
|
||||
if (myEnforcedAttributes != null) return myEnforcedAttributes;
|
||||
|
||||
if (myHighlightType == ProblemHighlightType.GENERIC_ERROR_OR_WARNING) {
|
||||
if (mySeverity == HighlightSeverity.ERROR) return CodeInsightColors.ERRORS_ATTRIBUTES;
|
||||
if (mySeverity == HighlightSeverity.WARNING) return CodeInsightColors.WARNINGS_ATTRIBUTES;
|
||||
}
|
||||
else if (myHighlightType == ProblemHighlightType.LIKE_DEPRECATED) {
|
||||
return CodeInsightColors.DEPRECATED_ATTRIBUTES;
|
||||
}
|
||||
else if (myHighlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL) {
|
||||
return CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES;
|
||||
}
|
||||
else if (myHighlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
|
||||
return CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES;
|
||||
}
|
||||
return HighlighterColors.TEXT;
|
||||
}
|
||||
|
||||
public List<Pair<IntentionAction, TextRange>> getQuickFixes() {
|
||||
return myQuickFixes;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return myMessage;
|
||||
}
|
||||
|
||||
public String getTooltip() {
|
||||
return myTooltip;
|
||||
}
|
||||
|
||||
public void setTooltip(final String tooltip) {
|
||||
myTooltip = tooltip;
|
||||
}
|
||||
|
||||
public void setHighlightType(final ProblemHighlightType highlightType) {
|
||||
myHighlightType = highlightType;
|
||||
}
|
||||
|
||||
public void setTextAttributes(final TextAttributesKey enforcedAttributes) {
|
||||
myEnforcedAttributes = enforcedAttributes;
|
||||
}
|
||||
|
||||
public boolean isAfterEndOfLine() {
|
||||
return myAfterEndOfLine;
|
||||
}
|
||||
|
||||
public void setAfterEndOfLine(final boolean afterEndOfLine) {
|
||||
myAfterEndOfLine = afterEndOfLine;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.intellij.lang.annotation;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: max
|
||||
* Date: Feb 3, 2005
|
||||
* Time: 3:08:54 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface AnnotationHolder {
|
||||
Annotation createErrorAnnotation(PsiElement elt, String message);
|
||||
Annotation createErrorAnnotation(ASTNode node, String message);
|
||||
Annotation createErrorAnnotation(TextRange range, String message);
|
||||
|
||||
Annotation createWarningAnnotation(PsiElement elt, String message);
|
||||
Annotation createWarningAnnotation(ASTNode node, String message);
|
||||
Annotation createWarningAnnotation(TextRange range, String message);
|
||||
|
||||
Annotation createInfoAnnotation(PsiElement elt, String message);
|
||||
Annotation createInfoAnnotation(ASTNode node, String message);
|
||||
Annotation createInfoAnnotation(TextRange range, String message);
|
||||
|
||||
boolean hasAnnotations();
|
||||
}
|
||||
14
openapi/src/com/intellij/lang/annotation/Annotator.java
Normal file
14
openapi/src/com/intellij/lang/annotation/Annotator.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.intellij.lang.annotation;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: max
|
||||
* Date: Feb 3, 2005
|
||||
* Time: 2:13:42 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface Annotator {
|
||||
void annotate(PsiElement psiElement, AnnotationHolder holder);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.intellij.lang.annotation;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: max
|
||||
* Date: Feb 6, 2005
|
||||
* Time: 4:23:09 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class HighlightSeverity {
|
||||
private final String myName; // for debug only
|
||||
private final int myVal;
|
||||
public static final HighlightSeverity INFORMATION = new HighlightSeverity("INFORMATION", 0);
|
||||
public static final HighlightSeverity WARNING = new HighlightSeverity("WARNING", 100);
|
||||
public static final HighlightSeverity ERROR = new HighlightSeverity("ERROR", 200);
|
||||
|
||||
public HighlightSeverity(String name, int val) {
|
||||
myName = name;
|
||||
myVal = val;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public boolean isGreaterOrEqual(HighlightSeverity severity) {
|
||||
return myVal >= severity.myVal;
|
||||
}
|
||||
|
||||
public boolean isLess(HighlightSeverity severity) {
|
||||
return myVal < severity.myVal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.intellij.codeInsight.daemon.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.xml.util.XmlUtil;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: max
|
||||
* Date: Feb 6, 2005
|
||||
* Time: 5:37:26 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class AnnotationHolderImpl extends SmartList<Annotation> implements AnnotationHolder {
|
||||
public Annotation createErrorAnnotation(PsiElement elt, String message) {
|
||||
return createAnnotation(elt.getTextRange(), HighlightSeverity.ERROR, message);
|
||||
}
|
||||
|
||||
public Annotation createErrorAnnotation(ASTNode node, String message) {
|
||||
return createAnnotation(node.getTextRange(), HighlightSeverity.ERROR, message);
|
||||
}
|
||||
|
||||
public Annotation createErrorAnnotation(TextRange range, String message) {
|
||||
return createAnnotation(range, HighlightSeverity.ERROR, message);
|
||||
}
|
||||
|
||||
public Annotation createWarningAnnotation(PsiElement elt, String message) {
|
||||
return createAnnotation(elt.getTextRange(), HighlightSeverity.WARNING, message);
|
||||
}
|
||||
|
||||
public Annotation createWarningAnnotation(ASTNode node, String message) {
|
||||
return createAnnotation(node.getTextRange(), HighlightSeverity.WARNING, message);
|
||||
}
|
||||
|
||||
public Annotation createWarningAnnotation(TextRange range, String message) {
|
||||
return createAnnotation(range, HighlightSeverity.WARNING, message);
|
||||
}
|
||||
|
||||
public Annotation createInfoAnnotation(PsiElement elt, String message) {
|
||||
return createAnnotation(elt.getTextRange(), HighlightSeverity.INFORMATION, message);
|
||||
}
|
||||
|
||||
public Annotation createInfoAnnotation(ASTNode node, String message) {
|
||||
return createAnnotation(node.getTextRange(), HighlightSeverity.INFORMATION, message);
|
||||
}
|
||||
|
||||
public Annotation createInfoAnnotation(TextRange range, String message) {
|
||||
return createAnnotation(range, HighlightSeverity.INFORMATION, message);
|
||||
}
|
||||
|
||||
private final Annotation createAnnotation(TextRange range, HighlightSeverity severity, String message) {
|
||||
Annotation annotation = new Annotation(range.getStartOffset(), range.getEndOffset(), severity, message, "<html><body>" + XmlUtil.escapeString(message) + "</body></html>");
|
||||
add(annotation);
|
||||
return annotation;
|
||||
}
|
||||
|
||||
public boolean hasAnnotations() {
|
||||
return size() > 0;
|
||||
}
|
||||
|
||||
public Annotation[] getResult() {
|
||||
return toArray(new Annotation[size()]);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import com.intellij.codeInsight.intention.impl.IntentionHintComponent;
|
||||
import com.intellij.ide.todo.TodoConfiguration;
|
||||
import com.intellij.j2ee.extResources.ExternalResourceListener;
|
||||
import com.intellij.j2ee.openapi.ex.ExternalResourceManagerEx;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
@@ -381,7 +382,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
return markup.getUserData(HIGHLIGHTS_IN_EDITOR_DOCUMENT_KEY);
|
||||
}
|
||||
|
||||
public static HighlightInfo[] getHighlights(Document document, HighlightInfo.Severity minSeverity, Project project) {
|
||||
public static HighlightInfo[] getHighlights(Document document, HighlightSeverity minSeverity, Project project) {
|
||||
LOG.assertTrue(ApplicationManager.getApplication().isDispatchThread());
|
||||
HighlightInfo[] highlights = getHighlights(document, project);
|
||||
if (highlights == null) return null;
|
||||
@@ -457,14 +458,14 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
List<HighlightInfo> errors = new ArrayList<HighlightInfo>();
|
||||
for (int i = 0; i < highlights.length; i++) {
|
||||
HighlightInfo highlight = highlights[i];
|
||||
if (highlight.getSeverity() == HighlightInfo.ERROR) {
|
||||
if (highlight.getSeverity() == HighlightSeverity.ERROR) {
|
||||
errors.add(highlight);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < highlights.length; i++) {
|
||||
HighlightInfo highlight = highlights[i];
|
||||
if (highlight.getSeverity() == HighlightInfo.WARNING) {
|
||||
if (highlight.getSeverity() == HighlightSeverity.WARNING) {
|
||||
for (int j = 0; j < errors.size(); j++) {
|
||||
HighlightInfo errorInfo = errors.get(j);
|
||||
if (isCoveredBy(highlight, errorInfo)) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.intellij.j2ee.J2EERolesUtil;
|
||||
import com.intellij.j2ee.ejb.EjbUtil;
|
||||
import com.intellij.j2ee.ejb.role.EjbImplMethodRole;
|
||||
import com.intellij.j2ee.ejb.role.EjbMethodRole;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -23,10 +24,10 @@ import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.packageDependencies.ForwardDependenciesBuilder;
|
||||
import com.intellij.packageDependencies.DependenciesBuilder;
|
||||
import com.intellij.packageDependencies.DependencyRule;
|
||||
import com.intellij.packageDependencies.DependencyValidationManager;
|
||||
import com.intellij.packageDependencies.DependenciesBuilder;
|
||||
import com.intellij.packageDependencies.ForwardDependenciesBuilder;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.PsiSearchHelper;
|
||||
import com.intellij.psi.search.TodoItem;
|
||||
@@ -148,7 +149,7 @@ public class GeneralHighlightingPass extends TextEditorHighlightingPass {
|
||||
if (myCompiled) {
|
||||
for (Iterator<HighlightInfo> iterator = highlights.iterator(); iterator.hasNext();) {
|
||||
final HighlightInfo info = iterator.next();
|
||||
if (info.getSeverity() == HighlightInfo.INFORMATION) {
|
||||
if (info.getSeverity() == HighlightSeverity.INFORMATION) {
|
||||
result.add(info);
|
||||
}
|
||||
}
|
||||
@@ -233,7 +234,7 @@ public class GeneralHighlightingPass extends TextEditorHighlightingPass {
|
||||
if (gotHighlights.contains(info)) continue;
|
||||
|
||||
gotHighlights.add(info);
|
||||
if (info.getSeverity() == HighlightInfo.ERROR) {
|
||||
if (info.getSeverity() == HighlightSeverity.ERROR) {
|
||||
skipParentsSet.add(element.getParent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package com.intellij.codeInsight.daemon.impl;
|
||||
import com.intellij.codeInsight.CodeInsightActionHandler;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
@@ -32,7 +33,7 @@ public class GotoNextErrorHandler implements CodeInsightActionHandler {
|
||||
}
|
||||
|
||||
private void gotoNextError(final Project project, final Editor editor, final PsiFile file, int caretOffset) {
|
||||
HighlightInfo[] highlights = DaemonCodeAnalyzerImpl.getHighlights(editor.getDocument(), HighlightInfo.WARNING, project);
|
||||
HighlightInfo[] highlights = DaemonCodeAnalyzerImpl.getHighlights(editor.getDocument(), HighlightSeverity.WARNING, project);
|
||||
if (highlights == null || highlights.length == 0){
|
||||
showMessageWhenNoHighlights(project, file, editor);
|
||||
return;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.codeInsight.daemon.impl;
|
||||
import com.intellij.codeInsight.CodeInsightColors;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
@@ -24,12 +25,9 @@ import java.util.List;
|
||||
public class HighlightInfo {
|
||||
public static final HighlightInfo[] EMPTY_ARRAY = new HighlightInfo[0];
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.HighlightInfo");
|
||||
private Boolean myNeedsUpdateOnTyping = null;
|
||||
|
||||
public static final Severity INFORMATION = new Severity("INFORMATION", 0);
|
||||
public static final Severity WARNING = new Severity("WARNING", 100);
|
||||
public static final Severity ERROR = new Severity("ERROR", 200);
|
||||
|
||||
public Severity getSeverity() {
|
||||
public HighlightSeverity getSeverity() {
|
||||
return severity;
|
||||
}
|
||||
|
||||
@@ -48,11 +46,11 @@ public class HighlightInfo {
|
||||
if (forcedTextAttributes != null) {
|
||||
return forcedTextAttributes.getErrorStripeColor();
|
||||
}
|
||||
Severity severity = getSeverity();
|
||||
if (severity == ERROR) {
|
||||
HighlightSeverity severity = getSeverity();
|
||||
if (severity == HighlightSeverity.ERROR) {
|
||||
return EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.ERRORS_ATTRIBUTES).getErrorStripeColor();
|
||||
}
|
||||
if (severity == WARNING) {
|
||||
if (severity == HighlightSeverity.WARNING) {
|
||||
return EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.WARNINGS_ATTRIBUTES).getErrorStripeColor();
|
||||
}
|
||||
return getAttributesByType(type).getErrorStripeColor();
|
||||
@@ -103,6 +101,8 @@ public class HighlightInfo {
|
||||
}
|
||||
|
||||
public boolean needUpdateOnTyping() {
|
||||
if (myNeedsUpdateOnTyping != null) return myNeedsUpdateOnTyping.booleanValue();
|
||||
|
||||
if (type == HighlightInfoType.TODO) return false;
|
||||
if (type == HighlightInfoType.LOCAL_VAR) return false;
|
||||
if (type == HighlightInfoType.INSTANCE_FIELD) return false;
|
||||
@@ -129,7 +129,7 @@ public class HighlightInfo {
|
||||
|
||||
public String description;
|
||||
public String toolTip;
|
||||
public Severity severity;
|
||||
public HighlightSeverity severity;
|
||||
|
||||
public boolean isAfterEndOfLine = false;
|
||||
public int navigationShift = 0;
|
||||
@@ -140,7 +140,7 @@ public class HighlightInfo {
|
||||
public List<Pair<IntentionAction, TextRange>> quickFixActionRanges;
|
||||
public List<Pair<IntentionAction, RangeMarker>> quickFixActionMarkers;
|
||||
|
||||
protected HighlightInfo(HighlightInfoType type, int startOffset, int endOffset, String description, String toolTip) {
|
||||
public HighlightInfo(HighlightInfoType type, int startOffset, int endOffset, String description, String toolTip) {
|
||||
this.type = type;
|
||||
this.startOffset = startOffset;
|
||||
this.endOffset = endOffset;
|
||||
@@ -153,6 +153,26 @@ public class HighlightInfo {
|
||||
LOG.assertTrue(startOffset <= endOffset);
|
||||
}
|
||||
|
||||
public HighlightInfo(final TextAttributesKey textAttributes,
|
||||
final HighlightInfoType type,
|
||||
final int startOffset,
|
||||
final int endOffset,
|
||||
final String description,
|
||||
final String toolTip,
|
||||
final HighlightSeverity severity,
|
||||
final boolean afterEndOfLine,
|
||||
final boolean needsUpdateOnTyping) {
|
||||
this.forcedTextAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(textAttributes);
|
||||
this.type = type;
|
||||
this.startOffset = startOffset;
|
||||
this.endOffset = endOffset;
|
||||
this.description = description;
|
||||
this.toolTip = toolTip;
|
||||
this.severity = severity;
|
||||
isAfterEndOfLine = afterEndOfLine;
|
||||
myNeedsUpdateOnTyping = Boolean.valueOf(needsUpdateOnTyping);
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
return obj == this ||
|
||||
(obj instanceof HighlightInfo &&
|
||||
@@ -181,25 +201,4 @@ public class HighlightInfo {
|
||||
return createHighlightInfo(type, SourceTreeToPsiMap.treeElementToPsi(childByRole), localizedMessage);
|
||||
}
|
||||
|
||||
public static class Severity {
|
||||
private final String myName; // for debug only
|
||||
private final int myVal;
|
||||
|
||||
public Severity(String name, int val) {
|
||||
myName = name;
|
||||
myVal = val;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public boolean isGreaterOrEqual(Severity severity) {
|
||||
return myVal >= severity.myVal;
|
||||
}
|
||||
|
||||
public boolean isLess(Severity severity) {
|
||||
return myVal < severity.myVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.intellij.codeInsight.daemon.impl;
|
||||
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -7,7 +8,7 @@ import com.intellij.psi.PsiFile;
|
||||
public class HighlightInfoFilterImpl implements HighlightInfoFilter, ApplicationComponent {
|
||||
public boolean accept(HighlightInfoType type, PsiFile file) {
|
||||
TextAttributes attributes = HighlightInfo.getAttributesByType(type);
|
||||
if (attributes == null || attributes.isEmpty() && type.getSeverity() == HighlightInfo.INFORMATION) return false; // optimization
|
||||
if (attributes == null || attributes.isEmpty() && type.getSeverity() == HighlightSeverity.INFORMATION) return false; // optimization
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,23 +4,24 @@ import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInsight.CodeInsightColors;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings;
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.HighlighterColors;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
|
||||
public interface HighlightInfoType {
|
||||
HighlightInfoType WRONG_REF = new HighlightInfoTypeImpl(HighlightInfo.ERROR, CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES);
|
||||
HighlightInfoType ERROR = new HighlightInfoTypeImpl(HighlightInfo.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
|
||||
HighlightInfoType WRONG_REF = new HighlightInfoTypeImpl(HighlightSeverity.ERROR, CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES);
|
||||
HighlightInfoType ERROR = new HighlightInfoTypeImpl(HighlightSeverity.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
|
||||
|
||||
HighlightInfoType ASPECT_ERROR = new HighlightInfoTypeImpl(HighlightInfo.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
|
||||
HighlightInfoType ASPECT_WARNING = new HighlightInfoTypeImpl(HighlightInfo.WARNING, CodeInsightColors.WARNINGS_ATTRIBUTES);
|
||||
HighlightInfoType ASPECT_ERROR = new HighlightInfoTypeImpl(HighlightSeverity.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
|
||||
HighlightInfoType ASPECT_WARNING = new HighlightInfoTypeImpl(HighlightSeverity.WARNING, CodeInsightColors.WARNINGS_ATTRIBUTES);
|
||||
|
||||
HighlightInfoType EJB_ERROR = new HighlightInfoTypeSeverityByKeyAttrBySeverity(HighlightDisplayKey.EJB_ERROR);
|
||||
HighlightInfoType EJB_WARNING = new HighlightInfoTypeSeverityByKeyAttrBySeverity(HighlightDisplayKey.EJB_WARNING);
|
||||
|
||||
HighlightInfoType ILLEGAL_DEPENDENCY = new HighlightInfoTypeSeverityByKeyAttrBySeverity(HighlightDisplayKey.ILLEGAL_DEPENDENCY);
|
||||
|
||||
HighlightInfoType WRONG_ELEMENT_NAME = new HighlightInfoTypeImpl(HighlightInfo.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
|
||||
HighlightInfoType WRONG_ELEMENT_NAME = new HighlightInfoTypeImpl(HighlightSeverity.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
|
||||
|
||||
HighlightInfoType UNUSED_SYMBOL = new HighlightInfoTypeSeverityByKey(HighlightDisplayKey.UNUSED_SYMBOL,
|
||||
CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES);
|
||||
@@ -42,50 +43,50 @@ public interface HighlightInfoType {
|
||||
HighlightInfoType UNKNOWN_JAVADOC_TAG = new HighlightInfoTypeSeverityByKeyAttrBySeverity(HighlightDisplayKey.UNKNOWN_JAVADOC_TAG);
|
||||
|
||||
|
||||
HighlightInfoType LOCAL_VAR = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION, CodeInsightColors.LOCAL_VARIABLE_ATTRIBUTES);
|
||||
HighlightInfoType INSTANCE_FIELD = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION, CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES);
|
||||
HighlightInfoType STATIC_FIELD = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION, CodeInsightColors.STATIC_FIELD_ATTRIBUTES);
|
||||
HighlightInfoType PARAMETER = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION, CodeInsightColors.PARAMETER_ATTRIBUTES);
|
||||
HighlightInfoType LOCAL_VAR = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.LOCAL_VARIABLE_ATTRIBUTES);
|
||||
HighlightInfoType INSTANCE_FIELD = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES);
|
||||
HighlightInfoType STATIC_FIELD = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.STATIC_FIELD_ATTRIBUTES);
|
||||
HighlightInfoType PARAMETER = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.PARAMETER_ATTRIBUTES);
|
||||
// t.o.d.o attributes depend on the t.o.d.o text
|
||||
HighlightInfoType TODO = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION, null);
|
||||
HighlightInfoType JOIN_POINT = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION, CodeInsightColors.JOIN_POINT);
|
||||
HighlightInfoType METHOD_CALL = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION, CodeInsightColors.METHOD_CALL_ATTRIBUTES);
|
||||
HighlightInfoType METHOD_DECLARATION = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION,
|
||||
HighlightInfoType TODO = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, null);
|
||||
HighlightInfoType JOIN_POINT = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.JOIN_POINT);
|
||||
HighlightInfoType METHOD_CALL = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.METHOD_CALL_ATTRIBUTES);
|
||||
HighlightInfoType METHOD_DECLARATION = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION,
|
||||
CodeInsightColors.METHOD_DECLARATION_ATTRIBUTES);
|
||||
HighlightInfoType CONSTRUCTOR_CALL = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION, CodeInsightColors.CONSTRUCTOR_CALL_ATTRIBUTES);
|
||||
HighlightInfoType CONSTRUCTOR_DECLARATION = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION,
|
||||
HighlightInfoType CONSTRUCTOR_CALL = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.CONSTRUCTOR_CALL_ATTRIBUTES);
|
||||
HighlightInfoType CONSTRUCTOR_DECLARATION = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION,
|
||||
CodeInsightColors.CONSTRUCTOR_DECLARATION_ATTRIBUTES);
|
||||
HighlightInfoType STATIC_METHOD = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION, CodeInsightColors.STATIC_METHOD_ATTRIBUTES);
|
||||
HighlightInfoType CLASS_NAME = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION, CodeInsightColors.CLASS_NAME_ATTRIBUTES);
|
||||
HighlightInfoType INTERFACE_NAME = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION, CodeInsightColors.INTERFACE_NAME_ATTRIBUTES);
|
||||
HighlightInfoType JAVA_KEYWORD = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION, HighlighterColors.JAVA_KEYWORD);
|
||||
HighlightInfoType ANNOTATION_NAME = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION, CodeInsightColors.ANNOTATION_NAME_ATTRIBUTES);
|
||||
HighlightInfoType ANNOTATION_ATTRIBUTE_NAME = new HighlightInfoTypeImpl(HighlightInfo.INFORMATION,
|
||||
HighlightInfoType STATIC_METHOD = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.STATIC_METHOD_ATTRIBUTES);
|
||||
HighlightInfoType CLASS_NAME = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.CLASS_NAME_ATTRIBUTES);
|
||||
HighlightInfoType INTERFACE_NAME = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.INTERFACE_NAME_ATTRIBUTES);
|
||||
HighlightInfoType JAVA_KEYWORD = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, HighlighterColors.JAVA_KEYWORD);
|
||||
HighlightInfoType ANNOTATION_NAME = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, CodeInsightColors.ANNOTATION_NAME_ATTRIBUTES);
|
||||
HighlightInfoType ANNOTATION_ATTRIBUTE_NAME = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION,
|
||||
CodeInsightColors.ANNOTATION_ATTRIBUTE_NAME_ATTRIBUTES);
|
||||
|
||||
HighlightInfoType SUSPICIOUS_METHOD_NAME = new HighlightInfoTypeImpl(HighlightInfo.WARNING, CodeInsightColors.WARNINGS_ATTRIBUTES);
|
||||
HighlightInfoType SUSPICIOUS_METHOD_NAME = new HighlightInfoTypeImpl(HighlightSeverity.WARNING, CodeInsightColors.WARNINGS_ATTRIBUTES);
|
||||
|
||||
HighlightInfoType WARNING = new HighlightInfoTypeImpl(HighlightInfo.WARNING, CodeInsightColors.WARNINGS_ATTRIBUTES);
|
||||
HighlightInfoType OVERFLOW_WARNING = new HighlightInfoTypeImpl(HighlightInfo.WARNING, CodeInsightColors.ERRORS_ATTRIBUTES);
|
||||
HighlightInfoType UNRESOLVED_SOFT_REFERENCE = new HighlightInfoTypeImpl(HighlightInfo.WARNING, CodeInsightColors.WARNINGS_ATTRIBUTES);
|
||||
HighlightInfoType WARNING = new HighlightInfoTypeImpl(HighlightSeverity.WARNING, CodeInsightColors.WARNINGS_ATTRIBUTES);
|
||||
HighlightInfoType OVERFLOW_WARNING = new HighlightInfoTypeImpl(HighlightSeverity.WARNING, CodeInsightColors.ERRORS_ATTRIBUTES);
|
||||
HighlightInfoType UNRESOLVED_SOFT_REFERENCE = new HighlightInfoTypeImpl(HighlightSeverity.WARNING, CodeInsightColors.WARNINGS_ATTRIBUTES);
|
||||
|
||||
HighlightInfoType RETURN_OUTSIDE_METHOD = new HighlightInfoTypeImpl(HighlightInfo.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
|
||||
HighlightInfoType UNHANDLED_EXCEPTION = new HighlightInfoTypeImpl(HighlightInfo.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
|
||||
HighlightInfoType RETURN_OUTSIDE_METHOD = new HighlightInfoTypeImpl(HighlightSeverity.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
|
||||
HighlightInfoType UNHANDLED_EXCEPTION = new HighlightInfoTypeImpl(HighlightSeverity.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
|
||||
|
||||
HighlightInfo.Severity getSeverity();
|
||||
HighlightSeverity getSeverity();
|
||||
|
||||
TextAttributesKey getAttributesKey();
|
||||
|
||||
class HighlightInfoTypeImpl implements HighlightInfoType {
|
||||
private final HighlightInfo.Severity mySeverity;
|
||||
private final HighlightSeverity mySeverity;
|
||||
private final TextAttributesKey myAttributesKey;
|
||||
|
||||
public HighlightInfoTypeImpl(HighlightInfo.Severity severity, TextAttributesKey attributesKey) {
|
||||
public HighlightInfoTypeImpl(HighlightSeverity severity, TextAttributesKey attributesKey) {
|
||||
mySeverity = severity;
|
||||
myAttributesKey = attributesKey;
|
||||
}
|
||||
|
||||
public HighlightInfo.Severity getSeverity() {
|
||||
public HighlightSeverity getSeverity() {
|
||||
return mySeverity;
|
||||
}
|
||||
|
||||
@@ -109,11 +110,11 @@ public interface HighlightInfoType {
|
||||
myAttributesKey = attributesKey;
|
||||
}
|
||||
|
||||
public HighlightInfo.Severity getSeverity() {
|
||||
public HighlightSeverity getSeverity() {
|
||||
DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance();
|
||||
HighlightDisplayLevel level = settings.getInspectionProfile().getErrorLevel(mySeverityKey);
|
||||
LOG.assertTrue(level != HighlightDisplayLevel.DO_NOT_SHOW);
|
||||
return level == HighlightDisplayLevel.ERROR ? HighlightInfo.ERROR : HighlightInfo.WARNING;
|
||||
return level == HighlightDisplayLevel.ERROR ? HighlightSeverity.ERROR : HighlightSeverity.WARNING;
|
||||
}
|
||||
|
||||
public TextAttributesKey getAttributesKey() {
|
||||
@@ -135,15 +136,15 @@ public interface HighlightInfoType {
|
||||
mySeverityKey = severityKey;
|
||||
}
|
||||
|
||||
public HighlightInfo.Severity getSeverity() {
|
||||
public HighlightSeverity getSeverity() {
|
||||
DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance();
|
||||
HighlightDisplayLevel level = settings.getInspectionProfile().getErrorLevel(mySeverityKey);
|
||||
LOG.assertTrue(level != HighlightDisplayLevel.DO_NOT_SHOW);
|
||||
return level == HighlightDisplayLevel.ERROR ? HighlightInfo.ERROR : HighlightInfo.WARNING;
|
||||
return level == HighlightDisplayLevel.ERROR ? HighlightSeverity.ERROR : HighlightSeverity.WARNING;
|
||||
}
|
||||
|
||||
public TextAttributesKey getAttributesKey() {
|
||||
return getSeverity() == HighlightInfo.ERROR ? CodeInsightColors.ERRORS_ATTRIBUTES : CodeInsightColors.WARNINGS_ATTRIBUTES;
|
||||
return getSeverity() == HighlightSeverity.ERROR ? CodeInsightColors.ERRORS_ATTRIBUTES : CodeInsightColors.WARNINGS_ATTRIBUTES;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.codeInspection.ex.InspectionManagerEx;
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.codeInspection.ex.QuickFixWrapper;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -189,7 +190,7 @@ public class LocalInspectionsPass extends TextEditorHighlightingPass {
|
||||
|
||||
final HighlightInfo highlightInfo = HighlightInfo.createHighlightInfo(level, psiElement, message, message);
|
||||
infos.add(highlightInfo);
|
||||
highlightInfo.severity = isError ? HighlightInfo.ERROR : HighlightInfo.WARNING;
|
||||
highlightInfo.severity = isError ? HighlightSeverity.ERROR : HighlightSeverity.WARNING;
|
||||
if (descriptor.getFix() != null) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new QuickFixWrapper(descriptor));
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.*;
|
||||
import com.intellij.codeInsight.intention.impl.CreateFieldFromParameterAction;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -461,7 +462,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
|
||||
if (file == null || !codeAnalyzer.isHighlightingAvailable(file)) return false;
|
||||
|
||||
if (!codeAnalyzer.isErrorAnalyzingFinished(file)) return false;
|
||||
HighlightInfo[] errors = DaemonCodeAnalyzerImpl.getHighlights(myDocument, HighlightInfo.ERROR, myProject);
|
||||
HighlightInfo[] errors = DaemonCodeAnalyzerImpl.getHighlights(myDocument, HighlightSeverity.ERROR, myProject);
|
||||
if (errors != null && errors.length != 0) return false;
|
||||
|
||||
if (fileHasUnchangedStatus()) return false;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.intellij.codeInsight.daemon.impl;
|
||||
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.actionSystem.impl.EmptyIcon;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.markup.ErrorStripeRenderer;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.actionSystem.impl.EmptyIcon;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.ui.LayeredIcon;
|
||||
|
||||
@@ -37,9 +38,9 @@ public class RefreshStatusRenderer implements ErrorStripeRenderer {
|
||||
|
||||
if (myHighlighter.isErrorAnalyzingFinished(myFile)) {
|
||||
status.errorAnalyzingFinished = true;
|
||||
HighlightInfo[] infos = DaemonCodeAnalyzerImpl.getHighlights(myDocument, HighlightInfo.WARNING, myProject);
|
||||
HighlightInfo[] infos = DaemonCodeAnalyzerImpl.getHighlights(myDocument, HighlightSeverity.WARNING, myProject);
|
||||
status.warningErrorCount = infos == null ? 0 : infos.length;
|
||||
infos = DaemonCodeAnalyzerImpl.getHighlights(myDocument, HighlightInfo.ERROR, myProject);
|
||||
infos = DaemonCodeAnalyzerImpl.getHighlights(myDocument, HighlightSeverity.ERROR, myProject);
|
||||
status.errorCount = infos == null ? 0 : infos.length;
|
||||
|
||||
status.inspectionFinished = myHighlighter.isInspectionCompleted(myFile);
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.intellij.codeInsight.intention.impl.config.IntentionManagerSettings;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -149,7 +150,7 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass {
|
||||
|
||||
int offset = myEditor.getCaretModel().getOffset();
|
||||
HighlightInfo info = codeAnalyzer.findHighlightByOffset(myEditor.getDocument(), offset, true);
|
||||
if (info == null || info.getSeverity() == HighlightInfo.ERROR) {
|
||||
if (info == null || info.getSeverity() == HighlightSeverity.ERROR) {
|
||||
fixesToShow.addAll(availableActions);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.intellij.codeInsight.daemon.impl;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -76,11 +77,11 @@ public class UpdateHighlightersUtil {
|
||||
HighlightInfo info = highlights[i];
|
||||
int layer;
|
||||
if (info.startOffset < startOffset || info.endOffset > endOffset) continue;
|
||||
HighlightInfo.Severity severity = info.getSeverity();
|
||||
if (severity == HighlightInfo.INFORMATION) {
|
||||
HighlightSeverity severity = info.getSeverity();
|
||||
if (severity == HighlightSeverity.INFORMATION) {
|
||||
layer = HighlighterLayer.ADDITIONAL_SYNTAX;
|
||||
}
|
||||
else if (severity == HighlightInfo.WARNING) {
|
||||
else if (severity == HighlightSeverity.WARNING) {
|
||||
layer = HighlighterLayer.WARNING;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -5,9 +5,10 @@ package com.intellij.codeInsight.daemon.impl.analysis;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoFilter;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
@@ -30,14 +31,14 @@ public class HighlightInfoHolder extends SmartList<HighlightInfo>{
|
||||
public boolean add(HighlightInfo info) {
|
||||
if (info == null || !accepted(info)) return false;
|
||||
|
||||
final HighlightInfo.Severity severity = info.getSeverity();
|
||||
if (severity == HighlightInfo.ERROR) {
|
||||
final HighlightSeverity severity = info.getSeverity();
|
||||
if (severity == HighlightSeverity.ERROR) {
|
||||
myErrorCount++;
|
||||
}
|
||||
else if (severity == HighlightInfo.WARNING) {
|
||||
else if (severity == HighlightSeverity.WARNING) {
|
||||
myWarningCount++;
|
||||
}
|
||||
else if (severity == HighlightInfo.INFORMATION) {
|
||||
else if (severity == HighlightSeverity.INFORMATION) {
|
||||
myInfoCount++;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,18 +4,22 @@ import com.intellij.aspects.psi.PsiAspectFile;
|
||||
import com.intellij.aspects.psi.PsiPointcutDef;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings;
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightVisitor;
|
||||
import com.intellij.codeInsight.daemon.impl.RefCountHolder;
|
||||
import com.intellij.codeInsight.daemon.impl.*;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.aspect.AspectHighlighter;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.ejb.EjbHighlightVisitor;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.SetupJDKFix;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.j2ee.ejb.EjbUtil;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
@@ -68,6 +72,7 @@ public class HighlightVisitorImpl extends PsiElementVisitor implements Highlight
|
||||
private final Map<String, PsiClass> mySingleImportedClasses = new THashMap<String, PsiClass>();
|
||||
private final Map<String, PsiElement> mySingleImportedFields = new THashMap<String, PsiElement>();
|
||||
private final Map<MethodSignature, PsiElement> mySingleImportedMethods = new THashMap<MethodSignature, PsiElement>();
|
||||
private final AnnotationHolderImpl myAnnotationHolder = new AnnotationHolderImpl();
|
||||
|
||||
public String getComponentName() {
|
||||
return "HighlightVisitorImpl";
|
||||
@@ -144,6 +149,45 @@ public class HighlightVisitorImpl extends PsiElementVisitor implements Highlight
|
||||
myRefCountHolder = refCountHolder;
|
||||
}
|
||||
|
||||
public void visitElement(PsiElement element) {
|
||||
final Language lang = element.getLanguage();
|
||||
if (lang != null) {
|
||||
final Annotator annotator = lang.getAnnotator();
|
||||
if (annotator != null) {
|
||||
annotator.annotate(element, myAnnotationHolder);
|
||||
if (myAnnotationHolder.hasAnnotations()) {
|
||||
final Annotation[] annotations = myAnnotationHolder.getResult();
|
||||
for (int i = 0; i < annotations.length; i++) {
|
||||
Annotation annotation = annotations[i];
|
||||
myHolder.add(convertToHighlightInfo(annotation));
|
||||
}
|
||||
}
|
||||
myAnnotationHolder.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private HighlightInfo convertToHighlightInfo(final Annotation annotation) {
|
||||
final HighlightInfo info = new HighlightInfo(annotation.getTextAttributes(), convertType(annotation), annotation.getStartOffset(), annotation.getEndOffset(),
|
||||
annotation.getMessage(), annotation.getTooltip(), annotation.getSeverity(), annotation.isAfterEndOfLine(), annotation.needsUpdateOnTyping());
|
||||
final List<Pair<IntentionAction, TextRange>> fixes = annotation.getQuickFixes();
|
||||
if (fixes != null) {
|
||||
for (int i = 0; i < fixes.size(); i++) {
|
||||
Pair<IntentionAction, TextRange> pair = fixes.get(i);
|
||||
QuickFixAction.registerQuickFixAction(info, pair.getSecond(), pair.getFirst());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
private HighlightInfoType convertType(Annotation annotation) {
|
||||
final ProblemHighlightType type = annotation.getHighlightType();
|
||||
if (type == ProblemHighlightType.LIKE_UNUSED_SYMBOL) return HighlightInfoType.UNUSED_SYMBOL;
|
||||
if (type == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL) return HighlightInfoType.WRONG_REF;
|
||||
if (type == ProblemHighlightType.LIKE_DEPRECATED) return HighlightInfoType.DEPRECATED;
|
||||
return annotation.getSeverity() == HighlightSeverity.ERROR ? HighlightInfoType.ERROR : HighlightInfoType.WARNING;
|
||||
}
|
||||
|
||||
public void visitArrayInitializerExpression(PsiArrayInitializerExpression expression) {
|
||||
super.visitArrayInitializerExpression(expression);
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkArrayInitializerApplicable(expression));
|
||||
|
||||
@@ -239,10 +239,27 @@ public class IdTableBuilding {
|
||||
myScanner = scanner;
|
||||
}
|
||||
|
||||
public void build(char[] chars, int length, final TIntIntHashMap wordsTable, TodoPattern[] todoPatterns, int[] todoCounts) {
|
||||
public void build(char[] chars, int length, final TIntIntHashMap wordsTable, final TodoPattern[] todoPatterns, final int[] todoCounts) {
|
||||
myScanner.processWords(new CharArrayCharSequence(chars, 0, length), new Processor<WordOccurence>() {
|
||||
public boolean process(final WordOccurence t) {
|
||||
IdCacheUtil.addOccurrence(wordsTable, t.getText().toString().hashCode(), convertToMask(t.getKind()));
|
||||
IdCacheUtil.addOccurrence(wordsTable, StringUtil.stringHashCode(t.getText()), convertToMask(t.getKind()));
|
||||
|
||||
if (t.getKind() == WordOccurence.Kind.COMMENTS) {
|
||||
if (todoCounts != null) {
|
||||
for (int index = 0; index < todoPatterns.length; index++) {
|
||||
Pattern pattern = todoPatterns[index].getPattern();
|
||||
if (pattern != null) {
|
||||
CharSequence input = t.getText();
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
while (matcher.find()) {
|
||||
if (matcher.start() != matcher.end()) {
|
||||
todoCounts[index]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ import com.intellij.j2ee.J2EERolesUtil;
|
||||
import com.intellij.j2ee.ejb.role.EjbClassRole;
|
||||
import com.intellij.j2ee.ejb.role.EjbDeclMethodRole;
|
||||
import com.intellij.j2ee.ejb.role.EjbMethodRole;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.ParserDefinition;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
@@ -44,7 +47,6 @@ import com.intellij.uiDesigner.compiler.Utils;
|
||||
import com.intellij.uiDesigner.lw.LwRootContainer;
|
||||
import com.intellij.util.text.CharArrayCharSequence;
|
||||
import com.intellij.util.text.StringSearcher;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import gnu.trove.TIntArrayList;
|
||||
|
||||
import java.util.*;
|
||||
@@ -1116,18 +1118,25 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
// collect comment offsets to prevent long locks by PsiManagerImpl.LOCK
|
||||
synchronized (PsiLock.LOCK) {
|
||||
final Lexer lexer = ((PsiFileImpl)file).createLexer();
|
||||
TokenSet COMMENT_TOKEN_BIT_SET;
|
||||
TokenSet commentTokens = null;
|
||||
if (file instanceof PsiJavaFile || file instanceof JspFile) {
|
||||
COMMENT_TOKEN_BIT_SET = ElementType.COMMENT_BIT_SET;
|
||||
commentTokens = ElementType.COMMENT_BIT_SET;
|
||||
}
|
||||
else if (file instanceof XmlFile) {
|
||||
COMMENT_TOKEN_BIT_SET = XML_COMMENT_BIT_SET;
|
||||
commentTokens = XML_COMMENT_BIT_SET;
|
||||
}
|
||||
else {
|
||||
// TODO: ask the lexer about comment types!
|
||||
//LOG.assertTrue(false);
|
||||
return EMPTY_TODO_ITEMS;
|
||||
final Language lang = file.getLanguage();
|
||||
if (lang != null) {
|
||||
final ParserDefinition parserDefinition = lang.getParserDefinition();
|
||||
if (parserDefinition != null) {
|
||||
commentTokens = parserDefinition.getCommentTokens();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (commentTokens == null) return EMPTY_TODO_ITEMS;
|
||||
|
||||
for (lexer.start(chars); ; lexer.advance()) {
|
||||
IElementType tokenType = lexer.getTokenType();
|
||||
if (tokenType == null) break;
|
||||
@@ -1137,7 +1146,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
if (lexer.getTokenStart() >= range.getEndOffset()) break;
|
||||
}
|
||||
|
||||
if (COMMENT_TOKEN_BIT_SET.isInSet(tokenType)) {
|
||||
if (commentTokens.isInSet(tokenType)) {
|
||||
commentStarts.add(lexer.getTokenStart());
|
||||
commentEnds.add(lexer.getTokenEnd());
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ package com.intellij.codeInsight.daemon;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
@@ -33,9 +34,9 @@ class ExpectedHighlightingData {
|
||||
final boolean enabled;
|
||||
Set<HighlightInfo> infos;
|
||||
HighlightInfoType defaultErrorType;
|
||||
HighlightInfo.Severity severity;
|
||||
HighlightSeverity severity;
|
||||
|
||||
public ExpectedHighlightingSet(String marker, HighlightInfoType defaultErrorType,HighlightInfo.Severity severity, boolean endOfLine, boolean enabled) {
|
||||
public ExpectedHighlightingSet(String marker, HighlightInfoType defaultErrorType,HighlightSeverity severity, boolean endOfLine, boolean enabled) {
|
||||
this.marker = marker;
|
||||
this.endOfLine = endOfLine;
|
||||
this.enabled = enabled;
|
||||
@@ -48,10 +49,10 @@ class ExpectedHighlightingData {
|
||||
|
||||
public ExpectedHighlightingData(Document document,boolean checkWarnings, boolean checkInfos) {
|
||||
highlightingTypes = new com.intellij.util.containers.HashMap<String,ExpectedHighlightingSet>();
|
||||
highlightingTypes.put(ERROR_MARKER, new ExpectedHighlightingSet(ERROR_MARKER, HighlightInfoType.ERROR, HighlightInfo.ERROR, false, true));
|
||||
highlightingTypes.put(WARNING_MARKER, new ExpectedHighlightingSet(WARNING_MARKER, HighlightInfoType.UNUSED_SYMBOL, HighlightInfo.WARNING, false, checkWarnings));
|
||||
highlightingTypes.put(INFO_MARKER, new ExpectedHighlightingSet(INFO_MARKER, HighlightInfoType.TODO, HighlightInfo.INFORMATION, false, checkInfos));
|
||||
highlightingTypes.put(END_LINE_HIGHLIGHT_MARKER, new ExpectedHighlightingSet(END_LINE_HIGHLIGHT_MARKER, HighlightInfoType.ERROR, HighlightInfo.ERROR, true, true));
|
||||
highlightingTypes.put(ERROR_MARKER, new ExpectedHighlightingSet(ERROR_MARKER, HighlightInfoType.ERROR, HighlightSeverity.ERROR, false, true));
|
||||
highlightingTypes.put(WARNING_MARKER, new ExpectedHighlightingSet(WARNING_MARKER, HighlightInfoType.UNUSED_SYMBOL, HighlightSeverity.WARNING, false, checkWarnings));
|
||||
highlightingTypes.put(INFO_MARKER, new ExpectedHighlightingSet(INFO_MARKER, HighlightInfoType.TODO, HighlightSeverity.INFORMATION, false, checkInfos));
|
||||
highlightingTypes.put(END_LINE_HIGHLIGHT_MARKER, new ExpectedHighlightingSet(END_LINE_HIGHLIGHT_MARKER, HighlightInfoType.ERROR, HighlightSeverity.ERROR, true, true));
|
||||
extractExpectedHighlightsSet(document);
|
||||
}
|
||||
|
||||
|
||||
@@ -423,6 +423,15 @@ public class StringUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int stringHashCode(CharSequence chars) {
|
||||
int h = 0;
|
||||
int to = chars.length();
|
||||
for( int off = 0; off < to; ) {
|
||||
h = 31*h + chars.charAt(off++);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
public static int stringHashCode( char chars[], int from, int len ) {
|
||||
int h = 0;
|
||||
int to = from + len;
|
||||
|
||||
Reference in New Issue
Block a user