com.intellij.openapi.editor.Editor Java Examples
The following examples show how to use
com.intellij.openapi.editor.Editor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: consulo Author: consulo File: XBreakpointUtil.java License: Apache License 2.0 | 6 votes |
@Nonnull public static Pair<GutterIconRenderer, Object> findSelectedBreakpoint(@Nonnull final Project project, @Nonnull final Editor editor) { int offset = editor.getCaretModel().getOffset(); Document editorDocument = editor.getDocument(); List<DebuggerSupport> debuggerSupports = DebuggerSupport.getDebuggerSupports(); for (DebuggerSupport debuggerSupport : debuggerSupports) { final BreakpointPanelProvider<?> provider = debuggerSupport.getBreakpointPanelProvider(); final int textLength = editor.getDocument().getTextLength(); if (offset > textLength) { offset = textLength; } Object breakpoint = provider.findBreakpoint(project, editorDocument, offset); if (breakpoint != null) { final GutterIconRenderer iconRenderer = provider.getBreakpointGutterIconRenderer(breakpoint); return Pair.create(iconRenderer, breakpoint); } } return Pair.create(null, null); }
Example #2
Source Project: consulo Author: consulo File: RunIdeConsoleAction.java License: Apache License 2.0 | 6 votes |
@Override public void actionPerformed(AnActionEvent e) { Project project = e.getProject(); Editor editor = e.getDataContext().getData(CommonDataKeys.EDITOR); VirtualFile virtualFile = e.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE); if (project == null || editor == null || virtualFile == null) return; PsiDocumentManager.getInstance(project).commitAllDocuments(); String extension = virtualFile.getExtension(); if (extension != null && (engine == null || !engine.getFileExtensions().contains(extension))) { engine = IdeScriptEngineManager.getInstance().getEngineForFileExtension(extension, null); } if (engine == null) { LOG.warn("Script engine not found for: " + virtualFile.getName()); } else { executeQuery(project, virtualFile, editor, engine); } }
Example #3
Source Project: EclipseCodeFormatter Author: krasa File: EclipseCodeStyleManager.java License: Apache License 2.0 | 6 votes |
protected boolean shouldSkipFormatting(PsiFile psiFile, Collection<TextRange> textRanges) { VirtualFile virtualFile = psiFile.getVirtualFile(); if (settings.isFormatSeletedTextInAllFileTypes()) { // when file is being edited, it is important to load text from editor, i think final Editor editor = PsiUtilBase.findEditor(psiFile); if (editor != null) { Document document = editor.getDocument(); String text = document.getText(); if (!FileUtils.isWholeFile(textRanges, text)) { return false; } } } //not else if (settings.isFormatOtherFileTypesWithIntelliJ()) { return isDisabledFileType(virtualFile); } return true; }
Example #4
Source Project: bamboo-soy Author: google File: EnterHandler.java License: Apache License 2.0 | 6 votes |
@Override public Result postProcessEnter( @NotNull PsiFile file, @NotNull Editor editor, @NotNull DataContext dataContext) { if (file.getFileType() != SoyFileType.INSTANCE) { return Result.Continue; } int caretOffset = editor.getCaretModel().getOffset(); PsiElement element = file.findElementAt(caretOffset); Document document = editor.getDocument(); int lineNumber = document.getLineNumber(caretOffset) - 1; int lineStartOffset = document.getLineStartOffset(lineNumber); String lineTextBeforeCaret = document.getText(new TextRange(lineStartOffset, caretOffset)); if (element instanceof PsiComment && element.getTextOffset() < caretOffset) { handleEnterInComment(element, file, editor); } else if (lineTextBeforeCaret.startsWith("/*")) { insertText(file, editor, " * \n ", 3); } return Result.Continue; }
Example #5
Source Project: BashSupport Author: BashSupport File: BashPerformanceTest.java License: Apache License 2.0 | 6 votes |
private void doTest(final int iterations) { myFixture.configureByFile("functions_issue96.bash"); enableInspections(); long start = System.currentTimeMillis(); PlatformTestUtil.startPerformanceTest(getTestName(true), iterations * 2000, () -> { for (int i = 0; i < iterations; i++) { long innerStart = System.currentTimeMillis(); Editor editor = myFixture.getEditor(); editor.getCaretModel().moveToOffset(editor.getDocument().getTextLength()); myFixture.type("\n"); myFixture.type("echo \"hello world\"\n"); myFixture.type("pri"); myFixture.complete(CompletionType.BASIC); System.out.println("Cycle duration: " + (System.currentTimeMillis() - innerStart)); } }).usesAllCPUCores().attempts(1).assertTiming(); System.out.println("Complete duration: " + (System.currentTimeMillis() - start)); }
Example #6
Source Project: lombok-intellij-plugin Author: mplushnikov File: LombokElementRenameHandler.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) { PsiElement element = PsiElementRenameHandler.getElement(dataContext); if (null == element) { element = BaseRefactoringAction.getElementAtCaret(editor, file); } if (null != element) { RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(element); element = processor.substituteElementToRename(element, editor); } if (null != element) { editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); PsiElement nameSuggestionContext = file.getViewProvider().findElementAt(editor.getCaretModel().getOffset()); PsiElementRenameHandler.invoke(element, project, nameSuggestionContext, editor); } }
Example #7
Source Project: consulo Author: consulo File: TargetElementUtil.java License: Apache License 2.0 | 6 votes |
@Nullable @RequiredReadAction public static PsiReference findReference(Editor editor, int offset) { Project project = editor.getProject(); if (project == null) return null; Document document = editor.getDocument(); PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document); if (file == null) return null; offset = adjustOffset(file, document, offset); if (file instanceof PsiCompiledFile) { return ((PsiCompiledFile)file).getDecompiledPsiFile().findReferenceAt(offset); } return file.findReferenceAt(offset); }
Example #8
Source Project: consulo-csharp Author: consulo File: AddXModifierFix.java License: Apache License 2.0 | 6 votes |
@Override public void invoke(@Nonnull Project project, Editor editor, @Nonnull PsiElement element) throws IncorrectOperationException { DotNetModifierListOwner owner = CSharpIntentionUtil.findOwner(element); if(owner == null || !owner.isWritable()) { return; } DotNetModifierList modifierList = owner.getModifierList(); if(modifierList == null) { return; } beforeAdd(modifierList); for(CSharpModifier modifier : ArrayUtil.reverseArray(myModifiers)) { modifierList.addModifier(modifier); } }
Example #9
Source Project: saros Author: saros-project File: ContributionAnnotation.java License: GNU General Public License v2.0 | 6 votes |
@Override void addLocalRepresentation(@NotNull Editor editor) { User user = getUser(); TextAttributes textAttributes = getContributionTextAttributes(editor, user); addEditor(editor); IFile file = getFile(); for (AnnotationRange annotationRange : getAnnotationRanges()) { int start = annotationRange.getStart(); int end = annotationRange.getEnd(); RangeHighlighter rangeHighlighter = AbstractEditorAnnotation.addRangeHighlighter(start, end, editor, textAttributes, file); if (rangeHighlighter != null) { annotationRange.addRangeHighlighter(rangeHighlighter); } else { log.warn( "Could not create range highlighter for range " + annotationRange + " for " + this); } } }
Example #10
Source Project: consulo Author: consulo File: DiffDrawUtil.java License: Apache License 2.0 | 6 votes |
@Nonnull private static LineSeparatorRenderer createDiffLineRenderer(@Nonnull final Editor editor, @Nonnull final TextDiffType type, @Nonnull SeparatorPlacement placement, final boolean doubleLine, final boolean resolved) { return new LineSeparatorRenderer() { @Override public void drawLine(Graphics g, int x1, int x2, int y) { // TODO: change LineSeparatorRenderer interface ? Rectangle clip = g.getClipBounds(); x2 = clip.x + clip.width; if (placement == SeparatorPlacement.TOP) y++; drawChunkBorderLine((Graphics2D)g, x1, x2, y, type.getColor(editor), doubleLine, resolved); } }; }
Example #11
Source Project: consulo-csharp Author: consulo File: CSharpDocHighlightUsagesHandlerFactory.java License: Apache License 2.0 | 6 votes |
@Nullable @Override @RequiredReadAction public HighlightUsagesHandlerBase createHighlightUsagesHandler(Editor editor, PsiFile file) { int offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset()); PsiElement target = file.findElementAt(offset); if(target != null && target.getNode().getElementType() == CSharpDocTokenType.XML_NAME) { CSharpDocTagImpl docTag = PsiTreeUtil.getParentOfType(target, CSharpDocTagImpl.class); if(docTag == null) { return null; } return new CSharpDocTagHighlightUsagesHandler(editor, file, docTag); } return null; }
Example #12
Source Project: consulo Author: consulo File: MultiCaretCodeInsightAction.java License: Apache License 2.0 | 6 votes |
private static void iterateOverCarets(@Nonnull final Project project, @Nonnull final Editor hostEditor, @Nonnull final MultiCaretCodeInsightActionHandler handler) { PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); final PsiFile psiFile = documentManager.getCachedPsiFile(hostEditor.getDocument()); documentManager.commitAllDocuments(); hostEditor.getCaretModel().runForEachCaret(new CaretAction() { @Override public void perform(Caret caret) { Editor editor = hostEditor; if (psiFile != null) { Caret injectedCaret = InjectedLanguageUtil.getCaretForInjectedLanguageNoCommit(caret, psiFile); if (injectedCaret != null) { caret = injectedCaret; editor = caret.getEditor(); } } final PsiFile file = PsiUtilBase.getPsiFileInEditor(caret, project); if (file != null) { handler.invoke(project, editor, caret, file); } } }); }
Example #13
Source Project: intellij Author: bazelbuild File: ArgumentCompletionContributorTest.java License: Apache License 2.0 | 6 votes |
@Test public void testExistingKeywordArg() { completionTester.runWithAutoPopupEnabled( () -> { BuildFile file = createBuildFile( new WorkspacePath("BUILD"), "def function(name, deps, srcs):", " # empty function", "function(name = \"lib\")"); Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); editorTest.setCaretPosition(editor, 2, "function(".length()); completionTester.joinAutopopup(); completionTester.joinCompletion(); String[] completionItems = editorTest.getCompletionItemsAsStrings(); assertThat(completionItems).asList().containsAllOf("name", "deps", "srcs", "function"); }); }
Example #14
Source Project: consulo Author: consulo File: CompletionPhase.java License: Apache License 2.0 | 6 votes |
private static boolean shouldSkipAutoPopup(Editor editor, PsiFile psiFile) { int offset = editor.getCaretModel().getOffset(); int psiOffset = Math.max(0, offset - 1); PsiElement elementAt = psiFile.findElementAt(psiOffset); if (elementAt == null) return true; Language language = PsiUtilCore.findLanguageFromElement(elementAt); for (CompletionConfidence confidence : CompletionConfidenceEP.forLanguage(language)) { final ThreeState result = confidence.shouldSkipAutopopup(elementAt, psiFile, offset); if (result != ThreeState.UNSURE) { LOG.debug(confidence + " has returned shouldSkipAutopopup=" + result); return result == ThreeState.YES; } } return false; }
Example #15
Source Project: consulo Author: consulo File: TemplateLineStartEndHandler.java License: Apache License 2.0 | 6 votes |
@Override protected void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) { final TemplateState templateState = TemplateManagerImpl.getTemplateState(editor); if (templateState != null && !templateState.isFinished()) { final TextRange range = templateState.getCurrentVariableRange(); final int caretOffset = editor.getCaretModel().getOffset(); if (range != null && shouldStayInsideVariable(range, caretOffset)) { int selectionOffset = editor.getSelectionModel().getLeadSelectionOffset(); int offsetToMove = myIsHomeHandler ? range.getStartOffset() : range.getEndOffset(); LogicalPosition logicalPosition = editor.offsetToLogicalPosition(offsetToMove).leanForward(myIsHomeHandler); editor.getCaretModel().moveToLogicalPosition(logicalPosition); EditorModificationUtil.scrollToCaret(editor); if (myWithSelection) { editor.getSelectionModel().setSelection(selectionOffset, offsetToMove); } else { editor.getSelectionModel().removeSelection(); } return; } } myOriginalHandler.execute(editor, caret, dataContext); }
Example #16
Source Project: GoogleTranslation Author: a483210 File: GoogleTranslation.java License: Apache License 2.0 | 6 votes |
private void getTranslation(AnActionEvent event) { Editor editor = event.getData(PlatformDataKeys.EDITOR); if (editor == null) { return; } SelectionModel model = editor.getSelectionModel(); String selectedText = model.getSelectedText(); if (TextUtils.isEmpty(selectedText)) { selectedText = getCurrentWords(editor); if (TextUtils.isEmpty(selectedText)) { return; } } String queryText = strip(addBlanks(selectedText)); new Thread(new RequestRunnable(mTranslator, editor, queryText)).start(); }
Example #17
Source Project: IDEA-GitLab-Integration Author: bsideup File: GitLabOpenInBrowserAction.java License: MIT License | 6 votes |
@Nullable static String makeUrlToOpen(@Nullable Editor editor, @NotNull String relativePath, @NotNull String branch, @NotNull String remoteUrl) { final StringBuilder builder = new StringBuilder(); final String repoUrl = GitlabUrlUtil.makeRepoUrlFromRemoteUrl(remoteUrl); if (repoUrl == null) { return null; } builder.append(repoUrl).append("/blob/").append(branch).append(relativePath); if (editor != null && editor.getDocument().getLineCount() >= 1) { // lines are counted internally from 0, but from 1 on gitlab SelectionModel selectionModel = editor.getSelectionModel(); final int begin = editor.getDocument().getLineNumber(selectionModel.getSelectionStart()) + 1; final int selectionEnd = selectionModel.getSelectionEnd(); int end = editor.getDocument().getLineNumber(selectionEnd) + 1; if (editor.getDocument().getLineStartOffset(end - 1) == selectionEnd) { end -= 1; } builder.append("#L").append(begin).append('-').append(end); } return builder.toString(); }
Example #18
Source Project: intellij-plugin-v4 Author: antlr File: CreateRuleFix.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
private int findInsertionPoint(Editor editor, PsiFile file) { PsiElement atRange = file.findElementAt(textRange.getEndOffset()); if ( atRange!=null ) { RuleSpecNode parentRule = PsiTreeUtil.getParentOfType(atRange, RuleSpecNode.class); if ( parentRule!=null ) { PsiElement semi = MyPsiUtils.findFirstChildOfType(parentRule, getTokenElementType(SEMI)); if ( semi!=null ) { return semi.getTextOffset() + 1; } return parentRule.getTextRange().getEndOffset(); } } return editor.getDocument().getLineEndOffset(editor.getDocument().getLineCount() - 1); }
Example #19
Source Project: consulo Author: consulo File: ShowIntentionActionsHandler.java License: Apache License 2.0 | 5 votes |
public static boolean availableFor(@Nonnull PsiFile psiFile, @Nonnull Editor editor, @Nonnull IntentionAction action) { if (!psiFile.isValid()) return false; try { Project project = psiFile.getProject(); action = IntentionActionDelegate.unwrap(action); if (action instanceof SuppressIntentionActionFromFix) { final ThreeState shouldBeAppliedToInjectionHost = ((SuppressIntentionActionFromFix)action).isShouldBeAppliedToInjectionHost(); if (editor instanceof EditorWindow && shouldBeAppliedToInjectionHost == ThreeState.YES) { return false; } if (!(editor instanceof EditorWindow) && shouldBeAppliedToInjectionHost == ThreeState.NO) { return false; } } if (action instanceof PsiElementBaseIntentionAction) { PsiElementBaseIntentionAction psiAction = (PsiElementBaseIntentionAction)action; if (!psiAction.checkFile(psiFile)) { return false; } PsiElement leaf = psiFile.findElementAt(editor.getCaretModel().getOffset()); if (leaf == null || !psiAction.isAvailable(project, editor, leaf)) { return false; } } else if (!action.isAvailable(project, editor, psiFile)) { return false; } } catch (IndexNotReadyException e) { return false; } return true; }
Example #20
Source Project: CppTools Author: nicity File: CppOverrideImplementMethodHandler.java License: Apache License 2.0 | 5 votes |
private void proceedWithChoosingMethods(Project project, PsiFile file, final Editor editor, List<CppMethodElementNode> candidates, boolean override) { final MemberChooser<CppMethodElementNode> chooser = new MemberChooser<CppMethodElementNode>( candidates.toArray(new CppMethodElementNode[candidates.size()]), false, true, project, false ) { }; chooser.setTitle("Choose Methods to " + (override ? "Override":"Implement")); chooser.setCopyJavadocVisible(false); chooser.show(); if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE) return; final List<CppMethodElementNode> selectedElements = chooser.getSelectedElements(); if (selectedElements == null || selectedElements.size() == 0) return; CommandProcessor.getInstance().executeCommand(project, new Runnable() { public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { Document document = editor.getDocument(); int offset = editor.getCaretModel().getOffset(); for(CppMethodElementNode c:selectedElements) { String cType = c.getType(); String methodText = "virtual " + cType + " " + c.getText() + " {\n" + (!"void".equals(cType) ? "return ":"") + (c.myIsAbstract ? "": c.getParentName() + "::" + c.myName + "(" + c.myParamNames + ");") + "\n" + "}\n"; document.insertString(offset, methodText); offset += methodText.length(); } } }); } }, override ? "Override Methods":"Implement Methods", this); }
Example #21
Source Project: react-templates-plugin Author: idok File: RTExternalAnnotator.java License: MIT License | 5 votes |
@Nullable private static ExternalLintAnnotationInput collectInformation(@NotNull PsiFile psiFile, @Nullable Editor editor) { if (psiFile.getContext() != null || !RTFileUtil.isRTFile(psiFile)) { return null; } VirtualFile virtualFile = psiFile.getVirtualFile(); if (virtualFile == null || !virtualFile.isInLocalFileSystem()) { return null; } if (psiFile.getViewProvider() instanceof MultiplePsiFilesPerDocumentFileViewProvider) { return null; } Project project = psiFile.getProject(); RTProjectComponent component = project.getComponent(RTProjectComponent.class); if (component == null || !component.isValidAndEnabled()) { return null; } Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile); if (document == null) { return null; } String fileContent = document.getText(); if (StringUtil.isEmptyOrSpaces(fileContent)) { return null; } EditorColorsScheme colorsScheme = editor == null ? null : editor.getColorsScheme(); // tabSize = getTabSize(editor); // tabSize = 4; return new ExternalLintAnnotationInput(project, psiFile, fileContent, colorsScheme); }
Example #22
Source Project: idea-php-symfony2-plugin Author: Haehnchen File: AssetGoToDeclarationHandler.java License: MIT License | 5 votes |
@Nullable @Override public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int i, Editor editor) { if(!Symfony2ProjectComponent.isEnabled(psiElement)) { return null; } String[] fileExtensionFilterIfValidTag = findValidAssetFilter(psiElement); if (fileExtensionFilterIfValidTag == null) { return null; } Collection<PsiElement> psiElements = new HashSet<>(); for (VirtualFile virtualFile : TwigUtil.resolveAssetsFiles(psiElement.getProject(), psiElement.getText(), fileExtensionFilterIfValidTag)) { PsiElement target; if(virtualFile.isDirectory()) { target = PsiManager.getInstance(psiElement.getProject()).findDirectory(virtualFile); } else { target = PsiManager.getInstance(psiElement.getProject()).findFile(virtualFile); } if(target != null) { psiElements.add(target); } } return psiElements.toArray(new PsiElement[psiElements.size()]); }
Example #23
Source Project: consulo Author: consulo File: RearrangeCodeAction.java License: Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { final Project project = e.getProject(); if (project == null) { return; } final Editor editor = e.getData(CommonDataKeys.EDITOR); if (editor == null) { return; } PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); Document document = editor.getDocument(); documentManager.commitDocument(document); final PsiFile file = documentManager.getPsiFile(document); if (file == null) { return; } SelectionModel model = editor.getSelectionModel(); if (model.hasSelection()) { new RearrangeCodeProcessor(file, model).run(); } else { new RearrangeCodeProcessor(file).run(); } }
Example #24
Source Project: consulo Author: consulo File: ShowContainerInfoHandler.java License: Apache License 2.0 | 5 votes |
private static boolean isDeclarationVisible(PsiElement container, Editor editor) { Rectangle viewRect = editor.getScrollingModel().getVisibleArea(); final TextRange range = DeclarationRangeUtil.getPossibleDeclarationAtRange(container); if (range == null) { return false; } LogicalPosition pos = editor.offsetToLogicalPosition(range.getStartOffset()); Point loc = editor.logicalPositionToXY(pos); return loc.y >= viewRect.y; }
Example #25
Source Project: flutter-intellij Author: flutter File: PropertyEditorPanel.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
static boolean insideVisibleArea(Editor e, TextRange r) { final int textLength = e.getDocument().getTextLength(); if (r.getStartOffset() > textLength) return false; if (r.getEndOffset() > textLength) return false; final Rectangle visibleArea = e.getScrollingModel().getVisibleArea(); final Point point = e.logicalPositionToXY(e.offsetToLogicalPosition(r.getStartOffset())); return visibleArea.contains(point); }
Example #26
Source Project: consulo Author: consulo File: CompletionParameters.java License: Apache License 2.0 | 5 votes |
CompletionParameters(@Nonnull final PsiElement position, @Nonnull final PsiFile originalFile, @Nonnull CompletionType completionType, int offset, int invocationCount, @Nonnull Editor editor, @Nonnull CompletionProcess process) { PsiUtilCore.ensureValid(position); assert position.getTextRange().containsOffset(offset) : position; myPosition = position; myOriginalFile = originalFile; myCompletionType = completionType; myOffset = offset; myInvocationCount = invocationCount; myEditor = editor; myProcess = process; }
Example #27
Source Project: intellij Author: bazelbuild File: TargetExpressionListUi.java License: Apache License 2.0 | 5 votes |
@Override public Component getTableCellEditorComponent( JTable table, Object value, boolean isSelected, int row, int column) { textField = new TextFieldWithAutoCompletion<String>( project, new TargetCompletionProvider(project), /* showCompletionHint= */ true, /* text= */ (String) value) { @Override public void addNotify() { // base class ignores 'enter' keypress events, causing entire dialog to close without // committing changes... fix copied from upstream PsiClassTableCellEditor super.addNotify(); Editor editor = getEditor(); if (editor == null) { return; } JComponent c = editor.getContentComponent(); c.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ENTER"); c.getActionMap() .put( "ENTER", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { stopCellEditing(); } }); } }; textField.setBorder(BorderFactory.createLineBorder(JBColor.BLACK)); return textField; }
Example #28
Source Project: intellij-haxe Author: HaxeFoundation File: HaxeTypeAddImportIntentionAction.java License: Apache License 2.0 | 5 votes |
@Override public boolean showHint(@NotNull Editor editor) { myEditor = editor; TextRange range = InjectedLanguageManager.getInstance(myType.getProject()).injectedToHost(myType, myType.getTextRange()); HintManager.getInstance().showQuestionHint(editor, getText(), range.getStartOffset(), range.getEndOffset(), this); return true; }
Example #29
Source Project: consulo Author: consulo File: InitialScrollPositionSupport.java License: Apache License 2.0 | 5 votes |
@Nonnull public static LogicalPosition[] doGetCaretPositions(@Nonnull List<? extends Editor> editors) { LogicalPosition[] carets = new LogicalPosition[editors.size()]; for (int i = 0; i < editors.size(); i++) { carets[i] = DiffUtil.getCaretPosition(editors.get(i)); } return carets; }
Example #30
Source Project: consulo Author: consulo File: MergePanel2.java License: Apache License 2.0 | 5 votes |
private void tryInitView() { if (!hasAllEditors()) return; if (myMergeList != null) return; myMergeList = MergeList.create(myData); myMergeList.addListener(myDividersRepainter); myStatusUpdater = StatusUpdater.install(myMergeList, myPanel); Editor left = getEditor(0); Editor base = getEditor(1); Editor right = getEditor(2); setupHighlighterSettings(left, base, right); myMergeList.setMarkups(left, base, right); EditingSides[] sides = {getFirstEditingSide(), getSecondEditingSide()}; EditingSides[] sidesWithApplied = {getFirstEditingSide(true), getSecondEditingSide(true)}; myScrollSupport.install(sides); for (int i = 0; i < myDividers.length; i++) { myDividers[i].listenEditors(sidesWithApplied[i]); } if (myScrollToFirstDiff) { myPanel.requestScrollEditors(); } if (myMergeList.getErrorMessage() != null) { myPanel.insertTopComponent(new EditorNotificationPanel() { { myLabel.setText(myMergeList.getErrorMessage()); } }); } }