com.intellij.codeInspection.LocalInspectionToolSession Java Examples
The following examples show how to use
com.intellij.codeInspection.LocalInspectionToolSession.
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: YamlSchemaInspection.java From intellij-swagger with MIT License | 6 votes |
@NotNull @Override public PsiElementVisitor buildVisitor( @NotNull final ProblemsHolder holder, final boolean isOnTheFly, @NotNull final LocalInspectionToolSession session) { PsiFile file = holder.getFile(); if (fileDetector.isMainOpenApiYamlFile(file)) { return createVisitor("openapi.json", holder, session, file); } else if (fileDetector.isMainSwaggerYamlFile(file)) { return createVisitor("swagger.json", holder, session, file); } else { return PsiElementVisitor.EMPTY_VISITOR; } }
Example #2
Source File: JsonSchemaInspection.java From intellij-swagger with MIT License | 6 votes |
@NotNull @Override public PsiElementVisitor buildVisitor( @NotNull final ProblemsHolder holder, final boolean isOnTheFly, @NotNull final LocalInspectionToolSession session) { PsiFile file = holder.getFile(); if (fileDetector.isMainOpenApiJsonFile(file)) { return createVisitor("openapi.json", holder, session, file); } else if (fileDetector.isMainSwaggerJsonFile(file)) { return createVisitor("swagger.json", holder, session, file); } else { return PsiElementVisitor.EMPTY_VISITOR; } }
Example #3
Source File: PluginEnabledJsInspection.java From idea-php-typo3-plugin with MIT License | 5 votes |
@NotNull @Override protected PsiElementVisitor createVisitor(@NotNull ProblemsHolder problemsHolder, @NotNull LocalInspectionToolSession localInspectionToolSession) { if (!TYPO3CMSProjectSettings.getInstance(problemsHolder.getProject()).pluginEnabled) { return new JSElementVisitor() { }; } return buildRealVisitor(problemsHolder, localInspectionToolSession); }
Example #4
Source File: MissingModuleJSInspection.java From idea-php-typo3-plugin with MIT License | 5 votes |
@NotNull @Override public PsiElementVisitor buildRealVisitor(@NotNull ProblemsHolder problemsHolder, @NotNull LocalInspectionToolSession localInspectionToolSession) { return new JSElementVisitor() { @Override public void visitJSLiteralExpression(JSLiteralExpression node) { PsiReference[] references = node.getReferences(); for (PsiReference reference : references) { if (!(reference instanceof JSResolvableModuleReference)) { continue; } JSResolvableModuleReference moduleReference = (JSResolvableModuleReference) reference; String canonicalText = moduleReference.getCanonicalText(); if (!canonicalText.startsWith(JavaScriptUtil.MODULE_PREFIX)) { super.visitJSLiteralExpression(node); return; } if (JavaScriptUtil.getModuleMap(node.getProject()).containsKey(canonicalText)) { super.visitJSLiteralExpression(node); return; } problemsHolder.registerProblem(node, String.format("Unknown JavaScript module \"%s\"", canonicalText)); return; } super.visitJSLiteralExpression(node); } }; }
Example #5
Source File: YamlSchemaInspection.java From intellij-swagger with MIT License | 5 votes |
private PsiElementVisitor createVisitor( final String schemaFileName, final ProblemsHolder holder, final LocalInspectionToolSession session, final PsiFile file) { List<YAMLDocument> documents = ((YAMLFile) file).getDocuments(); if (documents.size() != 1) return PsiElementVisitor.EMPTY_VISITOR; PsiElement root = documents.get(0).getTopLevelValue(); if (root == null) return PsiElementVisitor.EMPTY_VISITOR; JsonSchemaService service = JsonSchemaService.Impl.get(file.getProject()); final URL url = ResourceUtil.getResource(getClass(), "schemas", schemaFileName); final VirtualFile virtualFile = VfsUtil.findFileByURL(url); final JsonSchemaObject schema = service.getSchemaObjectForSchemaFile(virtualFile); return new YamlPsiElementVisitor() { @Override public void visitElement(PsiElement element) { if (element != root) return; final JsonLikePsiWalker walker = JsonLikePsiWalker.getWalker(element, schema); if (walker == null) return; JsonComplianceCheckerOptions options = new JsonComplianceCheckerOptions(false); new JsonSchemaComplianceChecker(schema, holder, walker, session, options).annotate(element); } }; }
Example #6
Source File: JsonSchemaInspection.java From intellij-swagger with MIT License | 5 votes |
private PsiElementVisitor createVisitor( final String schemaFileName, final ProblemsHolder holder, final LocalInspectionToolSession session, final PsiFile file) { JsonValue root = file instanceof JsonFile ? ObjectUtils.tryCast(file.getFirstChild(), JsonValue.class) : null; if (root == null) return PsiElementVisitor.EMPTY_VISITOR; JsonSchemaService service = JsonSchemaService.Impl.get(file.getProject()); final URL url = ResourceUtil.getResource(getClass(), "schemas", schemaFileName); final VirtualFile virtualFile = VfsUtil.findFileByURL(url); final JsonSchemaObject schema = service.getSchemaObjectForSchemaFile(virtualFile); return new JsonElementVisitor() { @Override public void visitElement(PsiElement element) { if (element == root) { final JsonLikePsiWalker walker = JsonLikePsiWalker.getWalker(element, schema); if (walker == null) return; JsonComplianceCheckerOptions options = new JsonComplianceCheckerOptions(false); new JsonSchemaComplianceChecker(schema, holder, walker, session, options) .annotate(element); } } }; }
Example #7
Source File: JsonReferenceInspection.java From intellij-swagger with MIT License | 5 votes |
@NotNull @Override public PsiElementVisitor buildVisitor( @NotNull final ProblemsHolder holder, final boolean isOnTheFly, @NotNull final LocalInspectionToolSession session) { final PsiFile file = holder.getFile(); final VirtualFile virtualFile = file.getVirtualFile(); final Project project = holder.getProject(); boolean checkRefs = indexFacade.isMainSpecFile(virtualFile, project) || indexFacade.isPartialSpecFile(virtualFile, project); return new JsonElementVisitor() { @Override public void visitProperty(@NotNull JsonProperty o) { if (!checkRefs) { return; } if ("$ref".equals(o.getName())) { JsonValue value = o.getValue(); if (!(value instanceof JsonStringLiteral)) { return; } final String unquotedValue = StringUtil.unquoteString(value.getText()); if (!unquotedValue.startsWith("http")) { doCheck(holder, value, new CreateJsonReferenceIntentionAction(unquotedValue)); } } super.visitProperty(o); } }; }
Example #8
Source File: YamlReferenceInspection.java From intellij-swagger with MIT License | 5 votes |
@NotNull @Override public PsiElementVisitor buildVisitor( @NotNull final ProblemsHolder holder, final boolean isOnTheFly, @NotNull final LocalInspectionToolSession session) { final PsiFile file = holder.getFile(); final VirtualFile virtualFile = file.getVirtualFile(); final Project project = holder.getProject(); boolean checkRefs = indexFacade.isMainSpecFile(virtualFile, project) || indexFacade.isPartialSpecFile(virtualFile, project); return new YamlPsiElementVisitor() { @Override public void visitKeyValue(@NotNull YAMLKeyValue keyValue) { if (!checkRefs) { return; } if ("$ref".equals(keyValue.getKeyText())) { YAMLValue value = keyValue.getValue(); if (!(value instanceof YAMLScalar)) { return; } final String unquotedValue = StringUtil.unquoteString(value.getText()); if (!unquotedValue.startsWith("http")) { doCheck(holder, value, new CreateYamlReferenceIntentionAction(unquotedValue)); } } super.visitKeyValue(keyValue); } }; }
Example #9
Source File: CypherExplainWarningInspection.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 5 votes |
@NotNull @Override public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly, @NotNull LocalInspectionToolSession session) { return new PsiElementVisitor() { @Override public void visitElement(PsiElement element) { checkStatement(element, holder); } }; }
Example #10
Source File: MatchNamespaceInspection.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nonnull @Override @RequiredReadAction public PsiElementVisitor buildVisitor(@Nonnull ProblemsHolder holder, boolean isOnTheFly, @Nonnull LocalInspectionToolSession session) { PsiFile file = holder.getFile(); if(!(file instanceof CSharpFile)) { return PsiElementVisitor.EMPTY_VISITOR; } if(file instanceof PsiCodeFragment) { return PsiElementVisitor.EMPTY_VISITOR; } DotNetSimpleModuleExtension extension = ModuleUtilCore.getExtension(file, DotNetSimpleModuleExtension.class); if(extension == null) { return PsiElementVisitor.EMPTY_VISITOR; } MatchNamespaceVisitor visitor = session.getUserData(KEY); if(visitor == null) { session.putUserData(KEY, visitor = new MatchNamespaceVisitor(holder, extension)); } return visitor; }
Example #11
Source File: MatchNamespaceInspection.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Override public void inspectionFinished(@Nonnull LocalInspectionToolSession session, @Nonnull ProblemsHolder problemsHolder) { MatchNamespaceVisitor visitor = session.getUserData(KEY); if(visitor == null) { return; } visitor.report(); }
Example #12
Source File: PluginEnabledJsInspection.java From idea-php-typo3-plugin with MIT License | 4 votes |
@NotNull public abstract PsiElementVisitor buildRealVisitor(@NotNull ProblemsHolder problemsHolder, @NotNull LocalInspectionToolSession localInspectionToolSession);