use of com.intellij.openapi.editor.LogicalPosition in project intellij-plugins by JetBrains.
the class FlexNavigationTest method doTestLibCss.
// we cannot use <caret> method, because lib css file is read-only
private void doTestLibCss(int line, int column) throws Exception {
myAfterCommitRunnable = () -> FlexTestUtils.addLibrary(myModule, "Lib", getTestDataPath() + BASE_PATH, "LibWithCssFile.swc", "LibWithCssFile_src.zip", null);
configureByFile(BASE_PATH + "CssEmptyFile.css");
final VirtualFile cssFile = getFile("LibWithCssFile.swc!/defaults.css");
configureByExistingFile(cssFile);
myEditor.getCaretModel().moveToLogicalPosition(new LogicalPosition(line, column));
final VirtualFile classFile = getFile("LibWithCssFile_src.zip!/p1/p2/MyClass.as");
doTest(classFile, null, null);
}
use of com.intellij.openapi.editor.LogicalPosition in project intellij-plugins by JetBrains.
the class ActionUtil method getCodePointer.
static CodePointer getCodePointer(Editor editor) {
CodePointer codePointer;
int selectionStart = editor.getSelectionModel().getSelectionStart();
int selectionEnd = editor.getSelectionModel().getSelectionEnd();
if (selectionStart != selectionEnd) {
LogicalPosition start = editor.offsetToLogicalPosition(selectionStart);
LogicalPosition end = editor.offsetToLogicalPosition(selectionEnd);
codePointer = new CodePointer(start.line, start.column, end.line, end.column);
} else {
LogicalPosition pos = editor.getCaretModel().getLogicalPosition();
codePointer = new CodePointer(pos.line, pos.column);
}
return codePointer;
}
use of com.intellij.openapi.editor.LogicalPosition 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.LogicalPosition 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.LogicalPosition in project intellij-community by JetBrains.
the class HintManagerImpl method showEditorHint.
/**
* In this method the point to show hint depends on current caret position.
* So, first of all, editor will be scrolled to make the caret position visible.
*/
public void showEditorHint(final LightweightHint hint, final Editor editor, @PositionFlags final short constraint, @HideFlags final int flags, final int timeout, final boolean reviveOnEditorChange) {
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
editor.getScrollingModel().runActionOnScrollingFinished(() -> {
LogicalPosition pos = editor.getCaretModel().getLogicalPosition();
Point p = getHintPosition(hint, editor, pos, constraint);
showEditorHint(hint, editor, p, flags, timeout, reviveOnEditorChange, createHintHint(editor, p, hint, constraint));
});
}
Aggregations