Search in sources :

Example 1 with HeaderValuePart

use of org.jetbrains.lang.manifest.psi.HeaderValuePart in project intellij-community by JetBrains.

the class ClassReferenceParser method annotate.

@Override
public boolean annotate(@NotNull Header header, @NotNull AnnotationHolder holder) {
    HeaderValue value = header.getHeaderValue();
    if (!(value instanceof HeaderValuePart))
        return false;
    HeaderValuePart valuePart = (HeaderValuePart) value;
    String className = valuePart.getUnwrappedText();
    if (StringUtil.isEmptyOrSpaces(className)) {
        holder.createErrorAnnotation(valuePart.getHighlightingRange(), ManifestBundle.message("header.reference.invalid"));
        return true;
    }
    Project project = header.getProject();
    Module module = ModuleUtilCore.findModuleForPsiElement(header);
    GlobalSearchScope scope = module != null ? module.getModuleWithDependenciesAndLibrariesScope(false) : ProjectScope.getAllScope(project);
    PsiClass aClass = JavaPsiFacade.getInstance(project).findClass(className, scope);
    if (aClass == null) {
        String message = JavaErrorMessages.message("error.cannot.resolve.class", className);
        Annotation anno = holder.createErrorAnnotation(valuePart.getHighlightingRange(), message);
        anno.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
        return true;
    }
    return checkClass(valuePart, aClass, holder);
}
Also used : Project(com.intellij.openapi.project.Project) HeaderValue(org.jetbrains.lang.manifest.psi.HeaderValue) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) HeaderValuePart(org.jetbrains.lang.manifest.psi.HeaderValuePart) Module(com.intellij.openapi.module.Module) Annotation(com.intellij.lang.annotation.Annotation)

Example 2 with HeaderValuePart

use of org.jetbrains.lang.manifest.psi.HeaderValuePart in project intellij-community by JetBrains.

the class HeaderValuePartManipulator method handleContentChange.

@Override
public HeaderValuePart handleContentChange(@NotNull HeaderValuePart element, @NotNull TextRange range, String newContent) throws IncorrectOperationException {
    String text = "HeaderValuePartManipulator: " + range.replace(element.getText(), newContent);
    PsiFile file = PsiFileFactory.getInstance(element.getProject()).createFileFromText("DUMMY.MF", ManifestFileTypeFactory.MANIFEST, text);
    HeaderValue value = ((ManifestFile) file).getHeaders().get(0).getHeaderValue();
    assert value != null : text;
    return (HeaderValuePart) element.replace(value);
}
Also used : HeaderValue(org.jetbrains.lang.manifest.psi.HeaderValue) PsiFile(com.intellij.psi.PsiFile) HeaderValuePart(org.jetbrains.lang.manifest.psi.HeaderValuePart) ManifestFile(org.jetbrains.lang.manifest.psi.ManifestFile)

Example 3 with HeaderValuePart

use of org.jetbrains.lang.manifest.psi.HeaderValuePart in project intellij-plugins by JetBrains.

the class BasePackageParser method annotate.

@Override
public boolean annotate(@NotNull Header header, @NotNull AnnotationHolder holder) {
    boolean annotated = false;
    for (HeaderValue value : header.getHeaderValues()) {
        if (value instanceof Clause) {
            HeaderValuePart valuePart = ((Clause) value).getValue();
            if (valuePart != null) {
                String packageName = valuePart.getUnwrappedText();
                packageName = StringUtil.trimEnd(packageName, ".*");
                if (StringUtil.isEmptyOrSpaces(packageName)) {
                    holder.createErrorAnnotation(valuePart.getHighlightingRange(), ManifestBundle.message("header.reference.invalid"));
                    annotated = true;
                    continue;
                }
                PsiDirectory[] directories = OsgiPsiUtil.resolvePackage(header, packageName);
                if (directories.length == 0) {
                    holder.createErrorAnnotation(valuePart.getHighlightingRange(), JavaErrorMessages.message("cannot.resolve.package", packageName));
                    annotated = true;
                }
            }
        }
    }
    return annotated;
}
Also used : HeaderValue(org.jetbrains.lang.manifest.psi.HeaderValue) PsiDirectory(com.intellij.psi.PsiDirectory) Clause(org.osmorc.manifest.lang.psi.Clause) HeaderValuePart(org.jetbrains.lang.manifest.psi.HeaderValuePart)

Example 4 with HeaderValuePart

use of org.jetbrains.lang.manifest.psi.HeaderValuePart in project intellij-plugins by JetBrains.

the class AbstractAssignmentExpression method getName.

@Override
public String getName() {
    HeaderValuePart namePsi = getNameElement();
    String result = namePsi != null ? namePsi.getUnwrappedText() : null;
    return result != null ? result : "<unnamed>";
}
Also used : HeaderValuePart(org.jetbrains.lang.manifest.psi.HeaderValuePart)

Example 5 with HeaderValuePart

use of org.jetbrains.lang.manifest.psi.HeaderValuePart in project intellij-plugins by JetBrains.

the class AbstractAssignmentExpression method getValue.

@Override
public String getValue() {
    HeaderValuePart valuePsi = getValueElement();
    String result = valuePsi != null ? valuePsi.getUnwrappedText() : null;
    return result != null ? result : "";
}
Also used : HeaderValuePart(org.jetbrains.lang.manifest.psi.HeaderValuePart)

Aggregations

HeaderValuePart (org.jetbrains.lang.manifest.psi.HeaderValuePart)5 HeaderValue (org.jetbrains.lang.manifest.psi.HeaderValue)3 Annotation (com.intellij.lang.annotation.Annotation)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 PsiDirectory (com.intellij.psi.PsiDirectory)1 PsiFile (com.intellij.psi.PsiFile)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 ManifestFile (org.jetbrains.lang.manifest.psi.ManifestFile)1 Clause (org.osmorc.manifest.lang.psi.Clause)1