use of com.intellij.openapi.editor.ex.EditorEx in project intellij-plugins by JetBrains.
the class CfmlMatcherTest method doTest.
private void doTest() throws Throwable {
final int pairOffset = configureByTestFile(getTestName(false));
int offset = myFixture.getEditor().getCaretModel().getOffset();
EditorHighlighter editorHighlighter = ((EditorEx) myFixture.getEditor()).getHighlighter();
HighlighterIterator iterator = editorHighlighter.createIterator(offset);
boolean forward = offset < pairOffset;
boolean matched = BraceMatchingUtil.matchBrace(myFixture.getEditor().getDocument().getCharsSequence(), myFixture.getFile().getFileType(), iterator, forward);
assertTrue(matched);
assertEquals(pairOffset, iterator.getStart());
}
use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.
the class DiffPreviewPanel method getChange.
@Nullable
private SimpleThreesideDiffChange getChange(ThreeSide side, EditorMouseEvent e) {
EditorEx editor = myViewer.getEditor(side);
LogicalPosition logicalPosition = editor.xyToLogicalPosition(e.getMouseEvent().getPoint());
int offset = editor.logicalPositionToOffset(logicalPosition);
int line = editor.getDocument().getLineNumber(offset);
return getChange(side, line);
}
use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.
the class MethodSignatureComponent method createEditor.
@Override
protected EditorEx createEditor() {
EditorEx editor = super.createEditor();
final String fileName = getFileName();
if (fileName != null) {
editor.setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(getProject(), fileName));
}
editor.getSettings().setWhitespacesShown(false);
editor.setHorizontalScrollbarVisible(true);
editor.setVerticalScrollbarVisible(true);
return editor;
}
use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.
the class HintManagerImpl method getHintPosition.
/**
* @return coordinates in layered pane coordinate system.
*/
public Point getHintPosition(@NotNull LightweightHint hint, @NotNull Editor editor, @PositionFlags short constraint) {
LogicalPosition pos = editor.getCaretModel().getLogicalPosition();
final DataContext dataContext = ((EditorEx) editor).getDataContext();
final Rectangle dominantArea = PlatformDataKeys.DOMINANT_HINT_AREA_RECTANGLE.getData(dataContext);
LOG.assertTrue(SwingUtilities.isEventDispatchThread());
if (dominantArea != null) {
return getHintPositionRelativeTo(hint, editor, constraint, dominantArea, pos);
}
JRootPane rootPane = editor.getComponent().getRootPane();
if (rootPane != null) {
JLayeredPane lp = rootPane.getLayeredPane();
for (HintInfo info : getHintsStackArray()) {
if (!info.hint.isSelectingHint())
continue;
IdeTooltip tooltip = info.hint.getCurrentIdeTooltip();
if (tooltip != null) {
Point p = tooltip.getShowingPoint().getPoint(lp);
if (info.hint != hint) {
switch(constraint) {
case ABOVE:
if (tooltip.getPreferredPosition() == Balloon.Position.below) {
p.y -= tooltip.getPositionChangeY();
}
break;
case UNDER:
case RIGHT_UNDER:
if (tooltip.getPreferredPosition() == Balloon.Position.above) {
p.y += tooltip.getPositionChangeY();
}
break;
case RIGHT:
if (tooltip.getPreferredPosition() == Balloon.Position.atLeft) {
p.x += tooltip.getPositionChangeX();
}
break;
case LEFT:
if (tooltip.getPreferredPosition() == Balloon.Position.atRight) {
p.x -= tooltip.getPositionChangeX();
}
break;
}
}
return p;
}
Rectangle rectangle = info.hint.getBounds();
JComponent c = info.hint.getComponent();
rectangle = SwingUtilities.convertRectangle(c.getParent(), rectangle, lp);
return getHintPositionRelativeTo(hint, editor, constraint, rectangle, pos);
}
}
return getHintPosition(hint, editor, pos, constraint);
}
use of com.intellij.openapi.editor.ex.EditorEx in project intellij-community by JetBrains.
the class DocumentFragmentTooltipRenderer method show.
@Override
public LightweightHint show(@NotNull final Editor editor, @NotNull Point p, boolean alignToRight, @NotNull TooltipGroup group, @NotNull HintHint intInfo) {
LightweightHint hint;
final JComponent editorComponent = editor.getComponent();
TextRange range = myDocumentFragment.getTextRange();
int startOffset = range.getStartOffset();
int endOffset = range.getEndOffset();
Document doc = myDocumentFragment.getDocument();
int endLine = doc.getLineNumber(endOffset);
int startLine = doc.getLineNumber(startOffset);
JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane();
// There is a possible case that collapsed folding region is soft wrapped, hence, we need to anchor
// not logical but visual line start.
VisualPosition visual = editor.offsetToVisualPosition(startOffset);
p = editor.visualPositionToXY(visual);
p = SwingUtilities.convertPoint(((EditorEx) editor).getGutterComponentEx(), p, layeredPane);
p.x -= 3;
p.y += editor.getLineHeight();
Point screenPoint = new Point(p);
SwingUtilities.convertPointToScreen(screenPoint, layeredPane);
int maxLineCount = (ScreenUtil.getScreenRectangle(screenPoint).height - screenPoint.y) / editor.getLineHeight();
if (endLine - startLine > maxLineCount) {
endOffset = doc.getLineEndOffset(Math.max(0, Math.min(startLine + maxLineCount, doc.getLineCount() - 1)));
}
if (endOffset < startOffset)
return null;
FoldingModelEx foldingModel = (FoldingModelEx) editor.getFoldingModel();
foldingModel.setFoldingEnabled(false);
TextRange textRange = new TextRange(startOffset, endOffset);
hint = EditorFragmentComponent.showEditorFragmentHintAt(editor, textRange, p.y, false, false, true, true, true);
foldingModel.setFoldingEnabled(true);
return hint;
}
Aggregations