use of org.jetbrains.lang.manifest.psi.Section in project intellij-community by JetBrains.
the class MissingFinalNewlineInspection method checkFile.
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (file instanceof ManifestFile) {
String text = file.getText();
if (text != null && text.length() > 0 && !StringUtil.endsWith(text, "\n")) {
List<Section> sections = ((ManifestFile) file).getSections();
assert sections.size() > 0 : text;
Section section = sections.get(sections.size() - 1);
ProblemDescriptor descriptor = manager.createProblemDescriptor(section.getLastChild(), ManifestBundle.message("inspection.newline.message"), new AddNewlineQuickFix(section), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
return new ProblemDescriptor[] { descriptor };
}
}
return null;
}
use of org.jetbrains.lang.manifest.psi.Section in project intellij-plugins by JetBrains.
the class OsgiPsiUtil method addHeader.
private static void addHeader(ManifestFile manifestFile, Header newHeader) {
Section section = manifestFile.getMainSection();
List<Header> headers = manifestFile.getHeaders();
if (section == null) {
manifestFile.add(newHeader.getParent());
} else if (headers.isEmpty()) {
section.addBefore(newHeader, section.getFirstChild());
} else {
section.addAfter(newHeader, headers.get(headers.size() - 1));
}
}
Aggregations