Search in sources :

Example 1 with BuildoutPartReference

use of com.jetbrains.python.buildout.config.ref.BuildoutPartReference in project intellij-community by JetBrains.

the class BuildoutUnresolvedPartInspection method checkFile.

@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
    List<ProblemDescriptor> problems = Lists.newArrayList();
    if (file.getFileType().equals(BuildoutCfgFileType.INSTANCE)) {
        Visitor visitor = new Visitor();
        file.accept(visitor);
        for (BuildoutPartReference ref : visitor.getUnresolvedParts()) {
            ProblemDescriptor d = manager.createProblemDescriptor(ref.getElement(), ref.getRangeInElement(), PyBundle.message("buildout.unresolved.part.inspection.msg"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
            problems.add(d);
        }
    }
    return problems.toArray(new ProblemDescriptor[problems.size()]);
}
Also used : PsiRecursiveElementVisitor(com.intellij.psi.PsiRecursiveElementVisitor) ProblemDescriptor(com.intellij.codeInspection.ProblemDescriptor) BuildoutPartReference(com.jetbrains.python.buildout.config.ref.BuildoutPartReference)

Example 2 with BuildoutPartReference

use of com.jetbrains.python.buildout.config.ref.BuildoutPartReference in project intellij-community by JetBrains.

the class BuildoutCfgValueLine method getReferences.

@NotNull
@Override
public PsiReference[] getReferences() {
    if (BuildoutPsiUtil.isInBuildoutSection(this) && BuildoutPsiUtil.isAssignedTo(this, "parts")) {
        List<BuildoutPartReference> refs = Lists.newArrayList();
        List<Pair<String, Integer>> names = StringUtil.getWordsWithOffset(getText());
        for (Pair<String, Integer> name : names) {
            refs.add(new BuildoutPartReference(this, name.getFirst(), name.getSecond()));
        }
        return refs.toArray(new BuildoutPartReference[refs.size()]);
    }
    return PsiReference.EMPTY_ARRAY;
}
Also used : BuildoutPartReference(com.jetbrains.python.buildout.config.ref.BuildoutPartReference) Pair(com.intellij.openapi.util.Pair) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

BuildoutPartReference (com.jetbrains.python.buildout.config.ref.BuildoutPartReference)2 ProblemDescriptor (com.intellij.codeInspection.ProblemDescriptor)1 Pair (com.intellij.openapi.util.Pair)1 PsiRecursiveElementVisitor (com.intellij.psi.PsiRecursiveElementVisitor)1 NotNull (org.jetbrains.annotations.NotNull)1