use of com.intellij.openapi.editor.DocumentFragment in project intellij-plugins by JetBrains.
the class JstdConfigFileAnnotator method annotateFileSequence.
private static void annotateFileSequence(@NotNull YAMLSequenceItem sequence, @NotNull final AnnotationHolder holder, @Nullable final VirtualFile basePath, @NotNull final String expectedIndent) {
checkSequenceIndent(sequence, holder, expectedIndent);
final YAMLValue value = sequence.getValue();
if (value == null) {
holder.createErrorAnnotation(sequence, "Sequence item is empty");
return;
}
if (value instanceof YAMLSequence) {
for (YAMLSequenceItem item : ((YAMLSequence) value).getItems()) {
annotateFileSequence(item, holder, basePath, expectedIndent);
}
}
if (value instanceof YAMLScalar && ((YAMLScalar) value).isMultiline()) {
holder.createErrorAnnotation(sequence, "Unexpected multiline path");
return;
}
PsiElementFragment<YAMLSequenceItem> sequenceTextFragment = JstdConfigFileUtils.buildSequenceTextFragment(sequence);
if (basePath != null && sequenceTextFragment != null) {
DocumentFragment documentFragment = sequenceTextFragment.toDocumentFragment();
if (documentFragment != null) {
annotatePath(basePath, documentFragment, holder, true, false);
}
}
}
use of com.intellij.openapi.editor.DocumentFragment in project intellij-plugins by JetBrains.
the class JstdConfigFileAnnotator method annotateBasePath.
private static void annotateBasePath(@NotNull BasePathInfo basePathInfo, @NotNull AnnotationHolder holder) {
YAMLKeyValue keyValue = basePathInfo.getKeyValue();
if (keyValue != null) {
DocumentFragment documentFragment = basePathInfo.getValueAsDocumentFragment();
if (documentFragment == null) {
int offset = keyValue.getTextRange().getEndOffset();
holder.createErrorAnnotation(TextRange.create(offset - 1, offset), "path is unspecified");
} else {
VirtualFile configDir = basePathInfo.getConfigDir();
if (configDir != null) {
annotatePath(configDir, documentFragment, holder, false, true);
}
}
}
}
Aggregations