本文整理匯總了Java中com.intellij.codeInspection.ProblemHighlightType類的典型用法代碼示例。如果您正苦於以下問題:Java ProblemHighlightType類的具體用法?Java ProblemHighlightType怎麽用?Java ProblemHighlightType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ProblemHighlightType類屬於com.intellij.codeInspection包,在下文中一共展示了ProblemHighlightType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildVisitor
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
return new PhpElementVisitor() {
@Override
public void visitPhpClass(PhpClass clazz) {
PhpIndex index = PhpIndex.getInstance(problemsHolder.getProject());
if (DatabaseUtils.HasConnections(problemsHolder.getProject()) &&
ClassUtils.isClassInheritsOrEqual(clazz, ClassUtils.getClass(index, "\\yii\\db\\ActiveRecord"))) {
String table = DatabaseUtils.getTableByActiveRecordClass(clazz);
if (table == null) {
problemsHolder.registerProblem(clazz.getFirstChild(), "Can not detect database table for class " + clazz.getFQN(), ProblemHighlightType.WEAK_WARNING);
} else if (! DatabaseUtils.isTableExists(table, problemsHolder.getProject())) {
problemsHolder.registerProblem(clazz.getFirstChild(), "Table '" + table + "' not found in database connections", ProblemHighlightType.WEAK_WARNING);
}
}
super.visitPhpClass(clazz);
}
};
}
示例2: buildVisitor
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean isOnTheFly) {
return new PhpElementVisitor() {
@Override
public void visitPhpClass(PhpClass clazz) {
if (clazz.getSuperClass() != null && clazz.getSuperClass().getFQN().equals("\\yii\\db\\ActiveQuery")) {
PhpIndex index = PhpIndex.getInstance(clazz.getProject());
PhpClass activeRecordClass = ClassUtils.findClassInSeeTags(index, clazz, "\\yii\\db\\BaseActiveRecord");
if (activeRecordClass == null) {
problemsHolder.registerProblem(clazz.getFirstChild(),
"Can not find connected ActiveRecord class.\nYou should add @see tag with linked ActiveRecord",
ProblemHighlightType.WEAK_WARNING);
}
}
super.visitPhpClass(clazz);
}
};
}
示例3: buildVisitor
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
return new PhpElementVisitor() {
@Override
public void visitPhpClassReference(ClassReference classReference) {
if (classReference.getFQN() != null && LegacyClassesForIDEIndex.isLegacyClass(classReference.getProject(), classReference.getFQN())) {
problemsHolder.registerProblem(classReference, "Legacy class usage", ProblemHighlightType.LIKE_DEPRECATED, new LegacyClassesForIdeQuickFix());
}
super.visitPhpClassReference(classReference);
}
@Override
public void visitPhpClassConstantReference(ClassConstantReference constantReference) {
super.visitPhpClassConstantReference(constantReference);
}
};
}
示例4: createProblem
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
protected ProblemDescriptor createProblem(
@NotNull final ValidateContext context,
@NotNull final Node problemNode,
@NotNull final XmlRule rule
) {
final PsiElement problemPsi = context.mapNodeToPsi(problemNode);
final ProblemHighlightType highlightType = this.computePriority(rule);
return context.getManager().createProblemDescriptor(
problemPsi,
rule.getDescription(),
true,
highlightType,
context.isOnTheFly()
);
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:17,代碼來源:XmlRuleInspection.java
示例5: check
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
protected void check(LuaControlFlowOwner owner, ProblemsHolder problemsHolder) {
try {
Instruction[] flow = owner.getControlFlow();
if (flow == null) return;
ReadWriteVariableInstruction[] reads = ControlFlowUtil.getReadsWithoutPriorWrites(flow);
for (ReadWriteVariableInstruction read : reads) {
PsiElement element = read.getElement();
if (element instanceof LuaReferenceElement) {
if (((LuaReferenceElement) element).getElement() instanceof LuaGlobal)
if (((LuaReferenceElement) element).multiResolve(false).length == 0) {
if (element.getTextLength() > 0)
problemsHolder.registerProblem(element, "Unassigned variable usage",
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}
}
} catch (Exception ignored) {
}
}
示例6: buildVisitor
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new LuaElementVisitor() {
public void visitFile(PsiFile file) {
if (!(file instanceof LuaPsiFile)) return;
LuaStatementElement[] statements = ((LuaPsiFile) file).getStatements();
for (int i = 0; i < statements.length - 1; i++) {
checkPair(statements[i], statements[i + 1]);
}
}
private void checkPair(LuaStatementElement prev, LuaStatementElement statement) {
if (!ControlFlowUtils.statementMayCompleteNormally(prev)) {
holder.registerProblem(statement,
buildErrorString(), ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}
};
}
示例7: processAssignmentWithinMultipleAssignment
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
protected void processAssignmentWithinMultipleAssignment(@NotNull GrExpression lhs,
@NotNull GrExpression rhs,
@NotNull GrExpression context) {
final PsiType targetType = lhs.getType();
final PsiType actualType = rhs.getType();
if (targetType == null || actualType == null) return;
final ConversionResult result = TypesUtil.canAssignWithinMultipleAssignment(targetType, actualType, context);
if (result == ConversionResult.OK) return;
registerError(
rhs,
GroovyBundle.message("cannot.assign", actualType.getPresentableText(), targetType.getPresentableText()),
LocalQuickFix.EMPTY_ARRAY,
result == ConversionResult.ERROR ? ProblemHighlightType.GENERIC_ERROR : ProblemHighlightType.GENERIC_ERROR_OR_WARNING
);
}
示例8: visitCommand
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
@Override
public void visitCommand(@NotNull SQFPsiCommand o) {
super.visitCommand(o);
for (String command : SQFStatic.LIST_COMMANDS) {
if (o.getText().equalsIgnoreCase(command)) {
if (!o.getText().equals(command)) {
holder.registerProblem(
o, SQFStatic.getSQFBundle().getString("Inspections.CommandCamelCase.annotator-problem-description"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
new CamelCaseFixAction(o)
);
}
break;
}
}
}
示例9: checkNewExpression
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
@Nullable
private static ProblemDescriptor checkNewExpression(PsiNewExpression expression, InspectionManager manager, boolean isOnTheFly) {
final Project project = manager.getProject();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
final PsiClass jbColorClass = facade.findClass(JBColor.class.getName(), GlobalSearchScope.allScope(project));
final PsiType type = expression.getType();
if (type != null && jbColorClass != null) {
if (!facade.getResolveHelper().isAccessible(jbColorClass, expression, jbColorClass)) return null;
final PsiExpressionList arguments = expression.getArgumentList();
if (arguments != null) {
if ("java.awt.Color".equals(type.getCanonicalText())) {
final PsiElement parent = expression.getParent();
if (parent instanceof PsiExpressionList && parent.getParent() instanceof PsiNewExpression) {
final PsiType parentType = ((PsiNewExpression)parent.getParent()).getType();
if (parentType == null || JBColor.class.getName().equals(parentType.getCanonicalText())) return null;
}
return manager.createProblemDescriptor(expression, "Replace with JBColor", new ConvertToJBColorQuickFix(),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
}
}
}
return null;
}
示例10: buildInternalVisitor
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
@Override
public PsiElementVisitor buildInternalVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new JavaElementVisitor() {
@Override
public void visitBinaryExpression(@NotNull PsiBinaryExpression expression) {
super.visitBinaryExpression(expression);
if (!ComparisonUtils.isEqualityComparison(expression)) {
return;
}
final PsiExpression lhs = expression.getLOperand();
final PsiExpression rhs = expression.getROperand();
if (rhs == null ||
lhs.textMatches(PsiKeyword.NULL) || rhs.textMatches(PsiKeyword.NULL) ||
lhs.textMatches(PsiKeyword.THIS) || rhs.textMatches(PsiKeyword.THIS)) {
return;
}
if (InheritanceUtil.isInheritor(lhs.getType(), VirtualFile.class.getName()) || InheritanceUtil.isInheritor(rhs.getType(), VirtualFile.class.getName())) {
holder.registerProblem(expression, "VirtualFile objects should be compared by equals(), not ==", ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}
};
}
示例11: highlightInapplicableMethodUsage
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
private void highlightInapplicableMethodUsage(@NotNull GroovyResolveResult methodResolveResult,
@NotNull CallInfo info,
@NotNull PsiMethod method) {
final PsiClass containingClass =
method instanceof GrGdkMethod ? ((GrGdkMethod)method).getStaticMethod().getContainingClass() : method.getContainingClass();
PsiType[] argumentTypes = info.getArgumentTypes();
if (containingClass == null) {
registerCannotApplyError(method.getName(), info);
return;
}
final String typesString = buildArgTypesList(argumentTypes);
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(method.getProject());
final PsiClassType containingType = factory.createType(containingClass, methodResolveResult.getSubstitutor());
final String canonicalText = containingType.getInternalCanonicalText();
String message =
method.isConstructor() ? GroovyBundle.message("cannot.apply.constructor", method.getName(), canonicalText, typesString)
: GroovyBundle.message("cannot.apply.method1", method.getName(), canonicalText, typesString);
registerError(
info.getElementToHighlight(),
message,
genCastFixes(GrClosureSignatureUtil.createSignature(methodResolveResult), argumentTypes, info.getArgumentList()),
ProblemHighlightType.GENERIC_ERROR
);
}
示例12: doApplyInformationToEditor
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
@Override
public void doApplyInformationToEditor() {
if (myUnusedDeclarations == null || myUnusedImports == null) {
return;
}
AnnotationHolder annotationHolder = new AnnotationHolderImpl(new AnnotationSession(myFile));
List<HighlightInfo> infos = new ArrayList<HighlightInfo>(myUnusedDeclarations);
for (GrImportStatement unusedImport : myUnusedImports) {
Annotation annotation = annotationHolder.createWarningAnnotation(calculateRangeToUse(unusedImport), GroovyInspectionBundle.message("unused.import"));
annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL);
annotation.registerFix(GroovyQuickFixFactory.getInstance().createOptimizeImportsFix(false));
infos.add(HighlightInfo.fromAnnotation(annotation));
}
UpdateHighlightersUtil.setHighlightersToEditor(myProject, myDocument, 0, myFile.getTextLength(), infos, getColorsScheme(), getId());
if (myUnusedImports != null && !myUnusedImports.isEmpty()) {
IntentionAction fix = GroovyQuickFixFactory.getInstance().createOptimizeImportsFix(true);
if (fix.isAvailable(myProject, myEditor, myFile) && myFile.isWritable()) {
fix.invoke(myProject, myEditor, myFile);
}
}
}
示例13: visitPyFunction
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
@Override
public void visitPyFunction(final PyFunction node) {
PyDecoratorList decolist = node.getDecoratorList();
if (decolist != null) {
PyDecorator[] decos = decolist.getDecorators();
if (decos.length > 1) {
for (int i = decos.length - 1; i >= 1; i -= 1) {
PyDecorator deco = decos[i];
String deconame = deco.getName();
if ((PyNames.CLASSMETHOD.equals(deconame) || PyNames.STATICMETHOD.equals(deconame)) && deco.isBuiltin()) {
registerProblem(
decos[i-1],
PyBundle.message("INSP.decorator.receives.unexpected.builtin"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, null, new RemoveDecoratorQuickFix()
);
}
}
}
}
}
示例14: visitPyArgumentList
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
@Override
public void visitPyArgumentList(final PyArgumentList node) { //PY-5588
final List<PyElement> problemElements = new ArrayList<PyElement>();
if (node.getParent() instanceof PyClass) {
for (final PyExpression expression : node.getArguments()) {
if (expression instanceof PyKeywordArgument)
problemElements.add(expression);
}
}
final String errorMessage = "This syntax available only since py3";
final boolean isPy3 = LanguageLevel.forElement(node).isPy3K();
if (shouldBeCompatibleWithPy2() || !isPy3) {
for (final PyElement problemElement : problemElements)
myHolder.registerProblem(problemElement, errorMessage, isPy3? ProblemHighlightType.GENERIC_ERROR_OR_WARNING :
ProblemHighlightType.GENERIC_ERROR);
}
}
示例15: checkCallSite
import com.intellij.codeInspection.ProblemHighlightType; //導入依賴的package包/類
private void checkCallSite(@Nullable PyCallSiteExpression callSite) {
final List<PyTypeChecker.AnalyzeCallResults> resultsSet = PyTypeChecker.analyzeCallSite(callSite, myTypeEvalContext);
final List<Map<PyExpression, Pair<String, ProblemHighlightType>>> problemsSet = new ArrayList<Map<PyExpression, Pair<String, ProblemHighlightType>>>();
for (PyTypeChecker.AnalyzeCallResults results : resultsSet) {
problemsSet.add(checkMapping(results.getReceiver(), results.getArguments()));
}
if (!problemsSet.isEmpty()) {
Map<PyExpression, Pair<String, ProblemHighlightType>> minProblems = Collections.min(problemsSet, new Comparator<Map<PyExpression, Pair<String, ProblemHighlightType>>>() {
@Override
public int compare(Map<PyExpression, Pair<String, ProblemHighlightType>> o1,
Map<PyExpression, Pair<String, ProblemHighlightType>> o2) {
return o1.size() - o2.size();
}
});
for (Map.Entry<PyExpression, Pair<String, ProblemHighlightType>> entry : minProblems.entrySet()) {
registerProblem(entry.getKey(), entry.getValue().getFirst(), entry.getValue().getSecond());
}
}
}