mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-27 16:57:49 +08:00
Added diagnostics.
This commit is contained in:
parent
318c5bb15c
commit
4bcbc02a23
@ -7,6 +7,8 @@ import com.intellij.openapi.editor.*;
|
|||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.ui.Messages;
|
import com.intellij.openapi.ui.Messages;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Anna Bulenkova
|
* @author Anna Bulenkova
|
||||||
*/
|
*/
|
||||||
@ -15,14 +17,19 @@ public class EditorAreaIllustration extends AnAction {
|
|||||||
public void actionPerformed(AnActionEvent anActionEvent) {
|
public void actionPerformed(AnActionEvent anActionEvent) {
|
||||||
final Editor editor = anActionEvent.getRequiredData(CommonDataKeys.EDITOR);
|
final Editor editor = anActionEvent.getRequiredData(CommonDataKeys.EDITOR);
|
||||||
CaretModel caretModel = editor.getCaretModel();
|
CaretModel caretModel = editor.getCaretModel();
|
||||||
|
|
||||||
|
System.out.println("\n");
|
||||||
|
System.out.print("caretModel.isUpToDate: " + caretModel.isUpToDate() + ", ");
|
||||||
|
System.out.println("Number of carets: " + caretModel.getAllCarets().size());
|
||||||
|
Caret primary = caretModel.getPrimaryCaret();
|
||||||
|
System.out.println("Primary caret is valid? " + primary.isValid() + ", has: " + primary.getLogicalPosition().toString() + ", Offset: " + primary.getOffset());
|
||||||
|
|
||||||
LogicalPosition logicalPosition = caretModel.getLogicalPosition();
|
LogicalPosition logicalPosition = caretModel.getLogicalPosition();
|
||||||
VisualPosition visualPosition = caretModel.getVisualPosition();
|
VisualPosition visualPosition = caretModel.getVisualPosition();
|
||||||
int offset = caretModel.getOffset();
|
int offset = caretModel.getOffset();
|
||||||
Messages.showInfoMessage(logicalPosition.toString() + "\n" +
|
Messages.showInfoMessage(logicalPosition.toString() + "\n" +
|
||||||
visualPosition.toString() + "\n" +
|
visualPosition.toString() + "\n" +
|
||||||
"Offset: " + offset
|
"Offset: " + offset,
|
||||||
// TODO: Remove the next line of diagnostic code
|
|
||||||
+ "\n" + "LogicalPosition.leansForward = " + String.valueOf(logicalPosition.leansForward),
|
|
||||||
"Caret Parameters Inside The Editor");
|
"Caret Parameters Inside The Editor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
text="Caret Position"
|
text="Caret Position"
|
||||||
description="Reports information about the caret position."
|
description="Reports information about the caret position."
|
||||||
icon="EditorBasicsIcons.Sdk_default_icon">
|
icon="EditorBasicsIcons.Sdk_default_icon">
|
||||||
|
<keyboard-shortcut keymap="$default" first-keystroke="control alt G"/>
|
||||||
<add-to-group group-id="EditorPopupMenu" anchor="first"/>
|
<add-to-group group-id="EditorPopupMenu" anchor="first"/>
|
||||||
</action>
|
</action>
|
||||||
</actions>
|
</actions>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user