Java Code Examples for com.intellij.codeInspection.ProblemsHolder#getProject()
The following examples show how to use
com.intellij.codeInspection.ProblemsHolder#getProject() .
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: 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 2
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 3
Source File: InconsistentLineSeparatorsInspection.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public PsiElementVisitor buildVisitor(@Nonnull final ProblemsHolder holder, boolean isOnTheFly) { return new PsiElementVisitor() { @Override public void visitFile(PsiFile file) { if (!file.getLanguage().equals(file.getViewProvider().getBaseLanguage())) { // There is a possible case that more than a single virtual file/editor contains more than one language (e.g. php and html). // We want to process a virtual file once than, hence, ignore all non-base psi files. return; } final Project project = holder.getProject(); final String projectLineSeparator = CodeStyleFacade.getInstance(project).getLineSeparator(); if (projectLineSeparator == null) { return; } final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile == null || !AbstractConvertLineSeparatorsAction.shouldProcess(virtualFile, project)) { return; } final String curLineSeparator = LoadTextUtil.detectLineSeparator(virtualFile, true); if (curLineSeparator != null && !curLineSeparator.equals(projectLineSeparator)) { holder.registerProblem( file, "Line separators in the current file (" + StringUtil.escapeStringCharacters(curLineSeparator) + ") " + "differ from the project defaults (" + StringUtil.escapeStringCharacters(projectLineSeparator) + ")", SET_PROJECT_LINE_SEPARATORS); } } }; }