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);
}
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);
}
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;
}
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>";
}
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 : "";
}
Aggregations