use of com.intellij.openapi.editor.Document in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoRecursiveCallMarkerProvider method collectSlowLineMarkers.
@Override
public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) {
Set<Integer> lines = ContainerUtil.newHashSet();
for (PsiElement element : elements) {
if (element instanceof GoCallExpr) {
PsiElement resolve = GoPsiImplUtil.resolveCall((GoCallExpr) element);
if (resolve instanceof GoFunctionOrMethodDeclaration) {
if (isRecursiveCall(element, (GoFunctionOrMethodDeclaration) resolve)) {
PsiDocumentManager instance = PsiDocumentManager.getInstance(element.getProject());
Document document = instance.getDocument(element.getContainingFile());
int textOffset = element.getTextOffset();
if (document == null)
continue;
int lineNumber = document.getLineNumber(textOffset);
if (!lines.contains(lineNumber)) {
result.add(new RecursiveMethodCallMarkerInfo(element));
}
lines.add(lineNumber);
}
}
}
}
}
use of com.intellij.openapi.editor.Document in project go-lang-idea-plugin by go-lang-plugin-org.
the class DlvBreakpointType method isLineBreakpointAvailable.
private static boolean isLineBreakpointAvailable(@NotNull VirtualFile file, int line, @NotNull Project project) {
Document document = FileDocumentManager.getInstance().getDocument(file);
if (document == null || document.getLineEndOffset(line) == document.getLineStartOffset(line))
return false;
Checker canPutAtChecker = new Checker();
XDebuggerUtil.getInstance().iterateLine(project, document, line, canPutAtChecker);
return canPutAtChecker.isLineBreakpointAvailable();
}
use of com.intellij.openapi.editor.Document in project intellij-elixir by KronicDeth.
the class Logger method excerpt.
@NotNull
private static String excerpt(@NotNull PsiFile containingFile, @NotNull PsiElement element) {
StringBuilder excerptBuilder = new StringBuilder();
excerptBuilder.append('\n');
excerptBuilder.append("### Excerpt\n");
excerptBuilder.append('\n');
excerptBuilder.append("```\n");
excerptBuilder.append(element.getText());
excerptBuilder.append('\n');
excerptBuilder.append("```\n");
FileViewProvider fileViewProvider = containingFile.getViewProvider();
Document document = fileViewProvider.getDocument();
if (document != null) {
TextRange textRange = element.getTextRange();
int startingLine = document.getLineNumber(textRange.getStartOffset());
int endingLine = document.getLineNumber(textRange.getEndOffset());
excerptBuilder.append(" Line(s) ");
excerptBuilder.append(startingLine);
excerptBuilder.append('-');
excerptBuilder.append(endingLine);
VirtualFile virtualFile = containingFile.getVirtualFile();
if (virtualFile != null) {
excerptBuilder.append(" in ");
excerptBuilder.append(virtualFile.getPath());
}
excerptBuilder.append("\n");
}
return excerptBuilder.toString();
}
use of com.intellij.openapi.editor.Document in project intellij-elixir by KronicDeth.
the class QuoteHandler method getClosingQuote.
/*
* Instance Methods
*/
@Nullable
@Override
public CharSequence getClosingQuote(HighlighterIterator highlighterIterator, int offset) {
Document document = highlighterIterator.getDocument();
CharSequence closingQuote = null;
if (document != null) {
if (offset >= 3) {
String openingQuote = document.getText(new TextRange(offset - 3, offset));
closingQuote = StackFrame.TERMINATOR_BY_PROMOTER.get(openingQuote);
if (closingQuote != null) {
closingQuote = "\n" + closingQuote;
}
}
if (closingQuote == null && offset >= 1) {
String openingQuote = document.getText(new TextRange(offset - 1, offset));
closingQuote = StackFrame.TERMINATOR_BY_PROMOTER.get(openingQuote);
}
}
return closingQuote;
}
use of com.intellij.openapi.editor.Document in project intellij-plugins by StepicOrg.
the class ProgrammingLanguageUtils method closeStepNodeFile.
private static ArrayList<VirtualFile> closeStepNodeFile(@NotNull Project project, @NotNull StepNode targetStepNode) {
FileDocumentManager documentManager = FileDocumentManager.getInstance();
ArrayList<VirtualFile> needClose = new ArrayList<>();
for (VirtualFile file : FileEditorManager.getInstance(project).getOpenFiles()) {
if (StudyUtils.getStudyNode(project, file) != targetStepNode) {
continue;
}
final Document document = ApplicationManager.getApplication().runReadAction((Computable<Document>) () -> documentManager.getDocument(file));
if (document == null) {
continue;
}
ApplicationManager.getApplication().invokeAndWait(() -> documentManager.saveDocument(document));
needClose.add(file);
}
return needClose;
}
Aggregations