use of org.jetbrains.annotations.NotNull in project intellij-community by JetBrains.
the class YAMLBreadcrumbsInfoProvider method getElementInfo.
@NotNull
@Override
public String getElementInfo(@NotNull PsiElement e) {
if (e instanceof YAMLDocument) {
final YAMLFile file = (YAMLFile) e.getContainingFile();
if (file == null) {
return "Document";
}
final List<YAMLDocument> documents = file.getDocuments();
return "Document " + getIndexOf(documents, e);
}
if (e instanceof YAMLKeyValue) {
return ((YAMLKeyValue) e).getKeyText() + ':';
}
if (e instanceof YAMLSequenceItem) {
final PsiElement parent = e.getParent();
if (!(parent instanceof YAMLSequence)) {
return "Item";
}
final List<YAMLSequenceItem> items = ((YAMLSequence) parent).getItems();
return "Item " + getIndexOf(items, e);
}
if (e instanceof YAMLScalar) {
return StringUtil.first(((YAMLScalar) e).getTextValue(), SCALAR_MAX_LENGTH, true);
}
throw new IllegalArgumentException("This element should not pass #acceptElement");
}
use of org.jetbrains.annotations.NotNull in project intellij-community by JetBrains.
the class YAMLKeyValueImpl method getKeyText.
@NotNull
public String getKeyText() {
final PsiElement keyElement = getKey();
if (keyElement == null) {
return "";
}
if (keyElement instanceof YAMLCompoundValue) {
return ((YAMLCompoundValue) keyElement).getTextValue();
}
final String text = keyElement.getText();
return StringUtil.unquoteString(text.substring(0, text.length() - 1));
}
use of org.jetbrains.annotations.NotNull in project intellij-community by JetBrains.
the class YAMLQuotedTextImpl method getContentRanges.
@NotNull
@Override
public List<TextRange> getContentRanges() {
final ASTNode firstContentNode = getFirstContentNode();
if (firstContentNode == null) {
return Collections.emptyList();
}
List<TextRange> result = new ArrayList<>();
TextRange contentRange = TextRange.create(firstContentNode.getStartOffset(), getTextRange().getEndOffset()).shiftRight(-getTextRange().getStartOffset());
final List<String> lines = StringUtil.split(contentRange.substring(getText()), "\n", true, false);
// First line has opening quote
int cumulativeOffset = contentRange.getStartOffset();
for (int i = 0; i < lines.size(); ++i) {
final String line = lines.get(i);
int lineStart = 0;
int lineEnd = line.length();
if (i == 0) {
lineStart++;
} else {
while (lineStart < line.length() && YAMLGrammarCharUtil.isSpaceLike(line.charAt(lineStart))) {
lineStart++;
}
}
if (i == lines.size() - 1) {
// Last line has closing quote
lineEnd--;
} else {
while (lineEnd > lineStart && YAMLGrammarCharUtil.isSpaceLike(line.charAt(lineEnd - 1))) {
lineEnd--;
}
}
result.add(TextRange.create(lineStart, lineEnd).shiftRight(cumulativeOffset));
cumulativeOffset += line.length() + 1;
}
return result;
}
use of org.jetbrains.annotations.NotNull in project intellij-community by JetBrains.
the class XsltDebuggerEditorsProvider method createDocument.
@NotNull
@Override
public Document createDocument(@NotNull Project project, @NotNull String text, @Nullable XSourcePosition sourcePosition, @NotNull EvaluationMode mode) {
final PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText("XPathExpr." + myFileType.getDefaultExtension(), myFileType, text, LocalTimeCounter.currentTime(), true);
if (sourcePosition instanceof XsltSourcePosition && ((XsltSourcePosition) sourcePosition).getLocation() instanceof Debugger.StyleFrame) {
final Debugger.Locatable location = ((XsltSourcePosition) sourcePosition).getLocation();
final EvalContextProvider context = new EvalContextProvider(((Debugger.StyleFrame) location).getVariables());
context.attachTo(psiFile);
} else {
final PsiElement contextElement = XsltBreakpointHandler.findContextElement(project, sourcePosition);
if (contextElement != null) {
final BreakpointContext context = new BreakpointContext(contextElement);
context.attachTo(psiFile);
}
}
final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
assert document != null;
return document;
}
use of org.jetbrains.annotations.NotNull in project intellij-community by JetBrains.
the class YAMLCodeStyleSettingsProvider method createSettingsPage.
@NotNull
@Override
public Configurable createSettingsPage(final CodeStyleSettings settings, final CodeStyleSettings originalSettings) {
return new CodeStyleAbstractConfigurable(settings, originalSettings, YAMLLanguage.INSTANCE.getDisplayName()) {
@Override
protected CodeStyleAbstractPanel createPanel(final CodeStyleSettings settings) {
final CodeStyleSettings currentSettings = getCurrentSettings();
final CodeStyleSettings settings1 = settings;
return new TabbedLanguageCodeStylePanel(YAMLLanguage.INSTANCE, currentSettings, settings1) {
@Override
protected void initTabs(final CodeStyleSettings settings) {
addIndentOptionsTab(settings);
}
};
}
@Override
public String getHelpTopic() {
return "reference.settingsdialog.codestyle.yaml";
}
};
}
Aggregations