com.intellij.codeInspection.ProblemHighlightType Java Examples
The following examples show how to use
com.intellij.codeInspection.ProblemHighlightType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RouteSettingDeprecatedInspection.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void registerAttributeRequirementProblem(@NotNull ProblemsHolder holder, @NotNull XmlAttributeValue xmlAttributeValue, @NotNull final String requirementAttribute) { if(!xmlAttributeValue.getValue().equals(requirementAttribute)) { return; } XmlAttribute xmlAttributeKey = PsiElementAssertUtil.getParentOfTypeWithNameOrNull(xmlAttributeValue, XmlAttribute.class, "key"); if(xmlAttributeKey != null) { XmlTag xmlTagDefault = PsiElementAssertUtil.getParentOfTypeWithNameOrNull(xmlAttributeKey, XmlTag.class, "requirement"); if(xmlTagDefault != null) { XmlTag xmlTagRoute = PsiElementAssertUtil.getParentOfTypeWithNameOrNull(xmlTagDefault, XmlTag.class, "route"); if(xmlTagRoute != null) { // attach to attribute token only we dont want " or ' char included PsiElement target = findAttributeValueToken(xmlAttributeValue, requirementAttribute); holder.registerProblem(target != null ? target : xmlAttributeValue, String.format("The '%s' requirement is deprecated", requirementAttribute), ProblemHighlightType.LIKE_DEPRECATED); } } } }
Example #2
Source File: PythonFacetInspection.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
@Override @Nullable public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { if (shouldAddPythonSdk(file)) { LocalQuickFix[] fixes = new LocalQuickFix[]{new AddPythonFacetQuickFix()}; ProblemDescriptor descriptor = manager.createProblemDescriptor( file.getNavigationElement(), PantsBundle.message("pants.info.python.facet.missing"), isOnTheFly, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING ); return new ProblemDescriptor[]{descriptor}; } return null; }
Example #3
Source File: LegacyClassesForIDEInspection.java From idea-php-typo3-plugin with MIT License | 6 votes |
@NotNull @Override public PsiElementVisitor buildRealVisitor(@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); } }; }
Example #4
Source File: UndefinedVariableInspection.java From idea-php-typo3-plugin with MIT License | 6 votes |
@NotNull @Override public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) { return new PsiElementVisitor() { @Override public void visitElement(PsiElement element) { if (!PlatformPatterns.psiElement(FluidTypes.IDENTIFIER).withParent( PlatformPatterns.psiElement(FluidFieldChain.class).withParent(FluidFieldExpr.class)) .accepts(element)) { super.visitElement(element); return; } if (!FluidUtil.findVariablesInCurrentContext(element).containsKey(element.getText())) { holder.registerProblem(element, String.format(MESSAGE, element.getText()), ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } super.visitElement(element); } }; }
Example #5
Source File: EventMethodCallInspection.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void registerMethodProblem(final @NotNull PsiElement psiElement, @NotNull ProblemsHolder holder, @Nullable PhpClass phpClass) { if(phpClass == null) { return; } final String methodName = PsiElementUtils.trimQuote(psiElement.getText()); if(phpClass.findMethodByName(methodName) != null) { return; } holder.registerProblem( psiElement, "Missing Method", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new CreateMethodQuickFix(phpClass, methodName, new MyCreateMethodQuickFix()) ); }
Example #6
Source File: YamlParameterInspection.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void invoke(@NotNull final PsiElement psiElement, @NotNull ProblemsHolder holder) { // at least %a% // and not this one: %kernel.root_dir%/../web/ // %kernel.root_dir%/../web/%webpath_modelmasks% String parameterName = PsiElementUtils.getText(psiElement); if(!YamlHelper.isValidParameterName(parameterName)) { return; } // strip "%" parameterName = parameterName.substring(1, parameterName.length() - 1); // parameter a always lowercase see #179 parameterName = parameterName.toLowerCase(); if (!ContainerCollectionResolver.getParameterNames(psiElement.getProject()).contains(parameterName)) { holder.registerProblem(psiElement, "Missing Parameter", ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } }
Example #7
Source File: BuildFileTypeInspection.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
@Override @Nullable public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { if (PantsUtil.isBUILDFileName(file.getName()) && PantsUtil.isPythonAvailable() && PantsUtil.isPantsProject(file.getProject())) { if (file.getFileType() != PythonFileType.INSTANCE) { LocalQuickFix[] fixes = new LocalQuickFix[]{new TypeAssociationFix()}; ProblemDescriptor descriptor = manager.createProblemDescriptor( file.getNavigationElement(), PantsBundle.message("pants.info.mistreated.build.file"), isOnTheFly, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING ); return new ProblemDescriptor[]{descriptor}; } } return null; }
Example #8
Source File: ContainerConstantInspection.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void yamlVisitor(@NotNull ProblemsHolder holder, @NotNull PsiFile psiFile) { psiFile.acceptChildren(new PsiRecursiveElementVisitor() { @Override public void visitElement(PsiElement psiElement) { if(psiElement instanceof YAMLScalar) { String textValue = ((YAMLScalar) psiElement).getTextValue(); if(textValue.length() > 0 && textValue.startsWith("!php/const:")) { String constantName = textValue.substring(11); if(StringUtils.isNotBlank(constantName) && ServiceContainerUtil.getTargetsForConstant(psiElement.getProject(), constantName).size() == 0) { holder.registerProblem(psiElement, MESSAGE, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } } } super.visitElement(psiElement); } }); }
Example #9
Source File: XmlServiceInstanceInspection.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void attachMethodInstances(@NotNull PsiElement target, @NotNull String serviceName, @NotNull Method method, int parameterIndex, @NotNull ProblemsHolder holder) { Parameter[] constructorParameter = method.getParameters(); if(parameterIndex >= constructorParameter.length) { return; } String className = constructorParameter[parameterIndex].getDeclaredType().toString(); PhpClass expectedClass = PhpElementsUtil.getClassInterface(method.getProject(), className); if(expectedClass == null) { return; } PhpClass serviceParameterClass = ServiceUtil.getResolvedClassDefinition(method.getProject(), serviceName); if(serviceParameterClass != null && !PhpElementsUtil.isInstanceOf(serviceParameterClass, expectedClass)) { holder.registerProblem( target, "Expect instance of: " + expectedClass.getPresentableFQN(), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new XmlServiceSuggestIntentionAction(expectedClass.getFQN(), target) ); } }
Example #10
Source File: CommandCamelCaseInspection.java From arma-intellij-plugin with MIT License | 6 votes |
@Override public void visitCommand(@NotNull SQFPsiCommand o) { super.visitCommand(o); for (String command : SQFStatic.COMMANDS_SET) { 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; } } }
Example #11
Source File: DeprecatedLombokAnnotationInspection.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void checkFor(String deprecatedAnnotationFQN, String newAnnotationFQN, PsiAnnotation psiAnnotation) { final String annotationQualifiedName = psiAnnotation.getQualifiedName(); if (Objects.equals(deprecatedAnnotationFQN, annotationQualifiedName)) { final PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(psiAnnotation, PsiModifierListOwner.class, false); if (null != listOwner) { holder.registerProblem(psiAnnotation, "Lombok annotation '" + deprecatedAnnotationFQN + "' is deprecated and " + "not supported by lombok-plugin any more. Use '" + newAnnotationFQN + "' instead.", ProblemHighlightType.ERROR, new AddAnnotationFix(newAnnotationFQN, listOwner, psiAnnotation.getParameterList().getAttributes(), deprecatedAnnotationFQN)); } } }
Example #12
Source File: XmlServiceArgumentInspection.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void visitService(XmlTag xmlTag, @NotNull ProblemsHolder holder) { if(!ServiceActionUtil.isValidXmlParameterInspectionService(xmlTag)) { return; } final List<String> args = ServiceActionUtil.getXmlMissingArgumentTypes(xmlTag, false, getLazyServiceCollector(xmlTag)); if (args.size() == 0) { return; } PsiElement childrenOfType = PsiElementUtils.getChildrenOfType(xmlTag, PlatformPatterns.psiElement(XmlTokenType.XML_NAME)); if(childrenOfType == null) { return; } holder.registerProblem(childrenOfType, "Missing argument", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new AddServiceXmlArgumentLocalQuickFix(args)); }
Example #13
Source File: YamlClassInspection.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void invoke(@NotNull final PsiElement psiElement, @NotNull ProblemsHolder holder) { String className = PsiElementUtils.getText(psiElement); if (YamlHelper.isValidParameterName(className)) { String resolvedParameter = ContainerCollectionResolver.resolveParameter(psiElement.getProject(), className); if (resolvedParameter != null && PhpIndex.getInstance(psiElement.getProject()).getAnyByFQN(resolvedParameter).size() > 0) { return; } } PhpClass foundClass = PhpElementsUtil.getClassInterface(psiElement.getProject(), className); if (foundClass == null) { holder.registerProblem(psiElement, MESSAGE_MISSING_CLASS, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } else if (!foundClass.getPresentableFQN().equals(className)) { holder.registerProblem(psiElement, MESSAGE_WRONG_CASING, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new CorrectClassNameCasingYamlLocalQuickFix(foundClass.getPresentableFQN())); } }
Example #14
Source File: ValProcessor.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void verifyParameter(@NotNull final PsiParameter psiParameter, @NotNull final ProblemsHolder holder) { final PsiTypeElement typeElement = psiParameter.getTypeElement(); final String typeElementText = null != typeElement ? typeElement.getText() : null; boolean isVal = isPossibleVal(typeElementText) && isVal(resolveQualifiedName(typeElement)); boolean isVar = isPossibleVar(typeElementText) && isVar(resolveQualifiedName(typeElement)); if (isVar || isVal) { PsiElement scope = psiParameter.getDeclarationScope(); boolean isForeachStatement = scope instanceof PsiForeachStatement; boolean isForStatement = scope instanceof PsiForStatement; if (isVal && !isForeachStatement) { holder.registerProblem(psiParameter, "'val' works only on local variables and on foreach loops", ProblemHighlightType.ERROR); } else if (isVar && !(isForeachStatement || isForStatement)) { holder.registerProblem(psiParameter, "'var' works only on local variables and on for/foreach loops", ProblemHighlightType.ERROR); } } }
Example #15
Source File: HaxeUnresolvedSymbolInspection.java From intellij-haxe with Apache License 2.0 | 6 votes |
@Nullable @Override public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) { if (!(file instanceof HaxeFile)) return null; final List<ProblemDescriptor> result = new ArrayList<ProblemDescriptor>(); new HaxeAnnotatingVisitor() { @Override protected void handleUnresolvedReference(HaxeReferenceExpression reference) { PsiElement nameIdentifier = reference.getReferenceNameElement(); if (nameIdentifier == null) return; result.add(manager.createProblemDescriptor( nameIdentifier, TextRange.from(0, nameIdentifier.getTextLength()), getDisplayName(), ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, isOnTheFly )); } }.visitFile(file); return ArrayUtil.toObjectArray(result, ProblemDescriptor.class); }
Example #16
Source File: ObsoleteInspection.java From consulo-csharp with Apache License 2.0 | 6 votes |
@RequiredReadAction private static void process(@Nonnull ProblemsHolder holder, @Nullable PsiElement range, @Nonnull PsiElement target) { if(range == null) { return; } // #hasAttribute() is cache result, #findAttribute() not if(DotNetAttributeUtil.hasAttribute(target, DotNetTypes.System.ObsoleteAttribute)) { DotNetAttribute attribute = DotNetAttributeUtil.findAttribute(target, DotNetTypes.System.ObsoleteAttribute); if(attribute == null) { return; } String message = getMessage(attribute); if(message == null) { message = CSharpInspectionBundle.message("target.is.obsolete", CSharpElementTreeNode.getPresentableText((PsiNamedElement) target)); } holder.registerProblem(range, message, ProblemHighlightType.LIKE_DEPRECATED); } }
Example #17
Source File: CommandCamelCaseInspection.java From arma-intellij-plugin with MIT License | 6 votes |
@Override public void visitCommand(@NotNull SQFPsiCommand o) { super.visitCommand(o); for (String command : SQFStatic.COMMANDS_SET) { 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; } } }
Example #18
Source File: GloballyRegisteredVariableInspection.java From BashSupport with Apache License 2.0 | 6 votes |
@Override public void visitVarUse(BashVar bashVar) { if (bashVar.isBuiltinVar()) { return; } if (!globalVariableNames.contains(bashVar.getReferenceName())) { return; } BashReference ref = bashVar.getReference(); if (ref.resolve() == null) { holder.registerProblem(bashVar, "This variable is unresolved, but registered as a global variable", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, ref.getRangeInElement(), new GlobalVariableQuickfix(bashVar, false)); } }
Example #19
Source File: PhpTranslationDomainInspection.java From idea-php-symfony2-plugin with MIT License | 5 votes |
private void annotateTranslationDomain(StringLiteralExpression psiElement, @NotNull ProblemsHolder holder) { String contents = psiElement.getContents(); if(StringUtils.isBlank(contents) || TranslationUtil.hasDomain(psiElement.getProject(), contents)) { return; } holder.registerProblem(psiElement, MESSAGE, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); }
Example #20
Source File: GhcMod.java From intellij-haskforce with Apache License 2.0 | 5 votes |
/** * Create an annotation from this problem and add it to the annotation holder. */ @Override public void createAnnotations(@NotNull PsiFile psiFile, @NotNull HaskellAnnotationHolder holder) { // TODO: There is probably a better way to compare these two file paths. // The problem might not be ours; ignore this problem in that case. // Note that Windows paths end up with different slashes, so getPresentableUrl() normalizes them. final VirtualFile vFile = psiFile.getVirtualFile(); if (!(file.equals(vFile.getCanonicalPath()) || file.equals(vFile.getPresentableUrl()))) { return; } final TextRange range = getTextRange(psiFile); if (range == null) return; final Annotation annotation; if (isError) { annotation = holder.createErrorAnnotation(range, message); } else { annotation = holder.createWeakWarningAnnotation(range, message); } if (annotation == null) return; if (isUnknownSymbol) { annotation.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL); } else if (isUnusedSymbol) { annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL); } else if (isUnusedImport) { annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL); } registerFix(psiFile, annotation); }
Example #21
Source File: LoadStatementAnnotator.java From intellij with Apache License 2.0 | 5 votes |
private void validateImportTarget(@Nullable StringLiteral target) { if (target == null) { return; } String targetString = target.getStringContents(); if (targetString == null || targetString.startsWith(":") || targetString.startsWith("//") || targetString.startsWith("@") || targetString.length() < 2) { return; } if (targetString.startsWith("/")) { Annotation annotation = markWarning( target, "Deprecated load syntax; loaded Starlark module should by in label format."); InspectionManager inspectionManager = InspectionManager.getInstance(target.getProject()); ProblemDescriptor descriptor = inspectionManager.createProblemDescriptor( target, annotation.getMessage(), DeprecatedLoadQuickFix.INSTANCE, ProblemHighlightType.LIKE_DEPRECATED, true); annotation.registerFix(DeprecatedLoadQuickFix.INSTANCE, null, null, descriptor); return; } markError(target, "Invalid load syntax: missing Starlark module."); }
Example #22
Source File: ShopwareBoostrapInspection.java From idea-php-shopware-plugin with MIT License | 5 votes |
@NotNull @Override public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) { PsiFile psiFile = holder.getFile(); if(!ShopwareProjectComponent.isValidForProject(psiFile)) { return super.buildVisitor(holder, isOnTheFly); } if(!"Bootstrap.php".equals(psiFile.getName())) { return super.buildVisitor(holder, isOnTheFly); } return new PsiElementVisitor() { @Override public void visitElement(PsiElement element) { if(element instanceof Method) { String methodName = ((Method) element).getName(); if(INSTALL_METHODS.contains(((Method) element).getName())) { if(PsiTreeUtil.collectElementsOfType(element, PhpReturn.class).size() == 0) { PsiElement psiElement = PsiElementUtils.getChildrenOfType(element, PlatformPatterns.psiElement(PhpTokenTypes.IDENTIFIER).withText(methodName)); if(psiElement != null) { holder.registerProblem(psiElement, "Shopware need return statement", ProblemHighlightType.GENERIC_ERROR); } } } } super.visitElement(element); } }; }
Example #23
Source File: GaugeInspectionProvider.java From Intellij-Plugin with Apache License 2.0 | 5 votes |
private ProblemDescriptor[] getDescriptors(List<GaugeError> errors, InspectionManager manager, PsiFile file) { List<ProblemDescriptor> descriptors = new ArrayList<>(); for (GaugeError e : errors) { if (!e.isFrom(file.getVirtualFile().getPath())) continue; PsiElement element = getElement(file.findElementAt(e.getOffset(file.getText()))); if (element == null) continue; descriptors.add(manager.createProblemDescriptor(element, e.getMessage(), null, ProblemHighlightType.ERROR, false, false)); } return descriptors.toArray(new ProblemDescriptor[0]); }
Example #24
Source File: LambdaBlockStatementCanReplacedByExpressionInspection.java From consulo-csharp with Apache License 2.0 | 5 votes |
@RequiredReadAction private void report(@Nonnull PsiElement elementToHighlight, @Nonnull CSharpLambdaExpressionImpl lambdaExpression, ProblemsHolder holder) { int textLength = elementToHighlight.getTextLength(); holder.registerProblem(elementToHighlight, "Statement body can be replaced by expression body", ProblemHighlightType.LIKE_UNUSED_SYMBOL, new TextRange(0, textLength), new ReplaceStatementByExpressionFix(lambdaExpression)); }
Example #25
Source File: RedundantSlf4jDefinitionInspection.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void findRedundantDefinition(PsiVariable field, PsiClass containingClass) { if (field.getType().equalsToText(LOGGER_SLF4J_FQCN)) { final PsiExpression initializer = field.getInitializer(); if (initializer != null && containingClass != null) { if (initializer.getText().contains(format(LOGGER_INITIALIZATION, containingClass.getQualifiedName()))) { holder.registerProblem(field, "Slf4j Logger is defined explicitly. Use Lombok @Slf4j annotation instead.", ProblemHighlightType.WARNING, new UseSlf4jAnnotationQuickFix(field, containingClass)); } } } }
Example #26
Source File: SimpleArrayUseInspection.java From BashSupport with Apache License 2.0 | 5 votes |
@NotNull @Override public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) { return new BashVisitor() { @Override public void visitVarUse(BashVar var) { BashVarDef definition = (BashVarDef) var.getReference().resolve(); if (definition != null) { boolean defIsArray = definition.isArray(); boolean arrayUse = var.isArrayUse(); if (arrayUse && !defIsArray) { //there's the special case that ${#arrayVar} and ${#nonArrayVar} are both valid (length of array and length of string) //this can't be detected with arrayUse and defIsArray if (!isStringLengthExpr(var)) { holder.registerProblem(var, "Array use of non-array variable", ProblemHighlightType.WEAK_WARNING); } } else if (!arrayUse && defIsArray && !BashPsiUtils.hasParentOfType(var, BashString.class, 5) && !BashPsiUtils.hasParentOfType(var, ArithmeticExpression.class, 5)) { holder.registerProblem(var, "Simple use of array variable", ProblemHighlightType.WEAK_WARNING); } } } }; }
Example #27
Source File: ContainerSettingDeprecatedInspection.java From idea-php-symfony2-plugin with MIT License | 5 votes |
private void registerProblem(@NotNull ProblemsHolder holder, @Nullable PsiElement target) { if(target == null) { return; } holder.registerProblem(target, "Symfony: this factory pattern is deprecated use 'factory' instead", ProblemHighlightType.LIKE_DEPRECATED); }
Example #28
Source File: DeprecatedTagInspection.java From intellij-latte with MIT License | 5 votes |
@Nullable @Override public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) { if (!(file instanceof LatteFile)) { return null; } final List<ProblemDescriptor> problems = new ArrayList<>(); file.acceptChildren(new PsiRecursiveElementWalkingVisitor() { @Override public void visitElement(PsiElement element) { if (element instanceof LatteMacroTag) { String macroName = ((LatteMacroTag) element).getMacroName(); LatteTagSettings macro = LatteConfiguration.getInstance(element.getProject()).getTag(macroName); if (macro != null && macro.isDeprecated()) { String description = macro.getDeprecatedMessage() != null && macro.getDeprecatedMessage().length() > 0 ? macro.getDeprecatedMessage() : "Tag {" + macroName + "} is deprecated"; ProblemDescriptor problem = manager.createProblemDescriptor(element, description, true, ProblemHighlightType.LIKE_DEPRECATED, isOnTheFly); problems.add(problem); } } else { super.visitElement(element); } } }); return problems.toArray(new ProblemDescriptor[0]); }
Example #29
Source File: YamlUnquotedColon.java From idea-php-symfony2-plugin with MIT License | 5 votes |
@Override public void visitElement(PsiElement element) { // every array element implements this interface // check for inside "foo: <foo: foo>" if(!isIllegalColonExpression(element)) { super.visitElement(element); return; } // element need to be inside key value PsiElement yamlKeyValue = element.getParent(); if(!(yamlKeyValue instanceof YAMLKeyValue)) { super.visitElement(element); return; } // invalid inline item "foo: foo: foo", also check text length String text = yamlKeyValue.getText(); if(!text.contains(": ") || text.contains("\n") || text.length() > 200) { super.visitElement(element); return; } // attach notification "foo: <foo: foo>" holder.registerProblem( element, YamlUnquotedColon.MESSAGE, ProblemHighlightType.WEAK_WARNING ); super.visitElement(element); }
Example #30
Source File: RouteSettingDeprecatedInspection.java From idea-php-symfony2-plugin with MIT License | 5 votes |
private void registerYmlRoutePatternProblem(@NotNull ProblemsHolder holder, @NotNull YAMLKeyValue element) { String s = PsiElementUtils.trimQuote(element.getKeyText()); if("pattern".equals(s) && YamlHelper.isRoutingFile(element.getContainingFile())) { // pattern: foo holder.registerProblem(element.getKey(), "Pattern is deprecated; use path instead", ProblemHighlightType.LIKE_DEPRECATED); } else if(("_method".equals(s) || "_scheme".equals(s)) && YamlHelper.isRoutingFile(element.getContainingFile())) { // requirements: { _method: 'foo', '_scheme': 'foo' } YAMLKeyValue parentOfType = PsiTreeUtil.getParentOfType(element, YAMLKeyValue.class); if(parentOfType != null && "requirements".equals(parentOfType.getKeyText())) { holder.registerProblem(element.getKey(), String.format("The '%s' requirement is deprecated", s), ProblemHighlightType.LIKE_DEPRECATED); } } }