mirror of
https://github.com/processing/processing4.git
synced 2026-02-04 06:09:17 +01:00
ASTGen: ctrl click on declaration shows usage
This commit is contained in:
@@ -2509,13 +2509,11 @@ public class ASTGenerator {
|
||||
|
||||
|
||||
// Thread: EDT
|
||||
public void scrollToDeclaration(int tabIndex, int offset) {
|
||||
public void handleCtrlClick(int tabIndex, int offset) {
|
||||
Messages.log("* scrollToDeclaration");
|
||||
|
||||
// TODO: don't run the heavy lifting on EDT
|
||||
|
||||
// TODO: handle comments
|
||||
|
||||
PreprocessedSketch ps = errorCheckerService.latestResult;
|
||||
|
||||
int javaOffset = ps.tabOffsetToJavaOffset(tabIndex, offset);
|
||||
@@ -2536,7 +2534,8 @@ public class ASTGenerator {
|
||||
String key = binding.getKey();
|
||||
ASTNode decl = ps.compilationUnit.findDeclaringNode(key);
|
||||
if (decl == null) {
|
||||
Messages.log("decl not found");
|
||||
Messages.log("decl not found, showing usage instead");
|
||||
handleShowUsage(binding);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2551,8 +2550,12 @@ public class ASTGenerator {
|
||||
return;
|
||||
}
|
||||
|
||||
Messages.log("found declaration, offset " + decl.getStartPosition() + ", name: " + declName);
|
||||
errorCheckerService.highlightJavaRange(declName.getStartPosition(), declName.getLength());
|
||||
if (declName.equals(simpleName)) {
|
||||
handleShowUsage(binding);
|
||||
} else {
|
||||
Messages.log("found declaration, offset " + decl.getStartPosition() + ", name: " + declName);
|
||||
errorCheckerService.highlightJavaRange(declName.getStartPosition(), declName.getLength());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public class JavaTextAreaPainter extends TextAreaPainter
|
||||
super(textArea, defaults);
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent evt) {
|
||||
public void mouseReleased(MouseEvent evt) {
|
||||
if (!getJavaEditor().hasJavaTabs()) { // Ctrl + Click disabled for java tabs
|
||||
if (evt.getButton() == MouseEvent.BUTTON1) {
|
||||
if ((evt.isControlDown() && !Platform.isMacOS()) || evt.isMetaDown()) {
|
||||
@@ -130,7 +130,7 @@ public class JavaTextAreaPainter extends TextAreaPainter
|
||||
|
||||
ASTGenerator astGenerator = getJavaEditor().getErrorChecker().getASTGenerator();
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.scrollToDeclaration(tabIndex, off);
|
||||
astGenerator.handleCtrlClick(tabIndex, off);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user