mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 412346: Makefile Editor: F3 navigation to user defined functions from $(call user-fun)
This commit is contained in:
parent
01bfa48d40
commit
cb5b5c955a
3 changed files with 66 additions and 25 deletions
|
@ -14,29 +14,31 @@ import org.eclipse.cdt.make.internal.core.makefile.MakeFileConstants;
|
||||||
|
|
||||||
|
|
||||||
public class GNUMakefileConstants extends MakeFileConstants {
|
public class GNUMakefileConstants extends MakeFileConstants {
|
||||||
static final String CONDITIONAL_ELSE = "else"; //$NON-NLS-1$
|
public static final String CONDITIONAL_ELSE = "else"; //$NON-NLS-1$
|
||||||
static final String CONDITIONAL_IFNEQ = "ifneq"; //$NON-NLS-1$
|
public static final String CONDITIONAL_IFNEQ = "ifneq"; //$NON-NLS-1$
|
||||||
static final String CONDITIONAL_IFNDEF = "ifndef"; //$NON-NLS-1$
|
public static final String CONDITIONAL_IFNDEF = "ifndef"; //$NON-NLS-1$
|
||||||
static final String CONDITIONAL_IFEQ = "ifeq"; //$NON-NLS-1$
|
public static final String CONDITIONAL_IFEQ = "ifeq"; //$NON-NLS-1$
|
||||||
static final String CONDITIONAL_IFDEF = "ifdef"; //$NON-NLS-1$
|
public static final String CONDITIONAL_IFDEF = "ifdef"; //$NON-NLS-1$
|
||||||
|
|
||||||
static final String TERMINAL_ENDEF = "endef"; //$NON-NLS-1$
|
public static final String TERMINAL_ENDEF = "endef"; //$NON-NLS-1$
|
||||||
static final String TERMINAL_ENDIF = "endif"; //$NON-NLS-1$
|
public static final String TERMINAL_ENDIF = "endif"; //$NON-NLS-1$
|
||||||
|
|
||||||
static final String DIRECTIVE_VPATH = "vpath"; //$NON-NLS-1$
|
public static final String DIRECTIVE_VPATH = "vpath"; //$NON-NLS-1$
|
||||||
static final String DIRECTIVE_UNEXPORT = "unexport"; //$NON-NLS-1$
|
public static final String DIRECTIVE_UNEXPORT = "unexport"; //$NON-NLS-1$
|
||||||
|
|
||||||
static final String VARIABLE_DEFINE = "define"; //$NON-NLS-1$
|
public static final String VARIABLE_DEFINE = "define"; //$NON-NLS-1$
|
||||||
static final String VARIABLE_EXPORT = "export"; //$NON-NLS-1$
|
public static final String VARIABLE_EXPORT = "export"; //$NON-NLS-1$
|
||||||
static final String VARIABLE_OVERRIDE = "override"; //$NON-NLS-1$
|
public static final String VARIABLE_OVERRIDE = "override"; //$NON-NLS-1$
|
||||||
|
|
||||||
static final String DIRECTIVE_INCLUDE = "include"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
static final String RULE_DELETE_ON_ERROR = ".DELETE_ON_ERROR"; //$NON-NLS-1$
|
public static final String FUNCTION_CALL = "call"; //$NON-NLS-1$
|
||||||
static final String RULE_PHONY = ".PHONY"; //$NON-NLS-1$
|
|
||||||
static final String RULE_SECONDARY = ".SECONDARY"; //$NON-NLS-1$
|
public static final String DIRECTIVE_INCLUDE = "include"; //$NON-NLS-1$
|
||||||
static final String RULE_LOW_RESOLUTION_TIME = ".LOW_RESOLUTION_TIME"; //$NON-NLS-1$
|
|
||||||
static final String RULE_NOT_PARALLEL = ".NOTPARALLEL"; //$NON-NLS-1$
|
public static final String RULE_DELETE_ON_ERROR = ".DELETE_ON_ERROR"; //$NON-NLS-1$
|
||||||
static final String RULE_EXPORT_ALL_VARIABLES = ".EXPORT_ALL_VARIABLES"; //$NON-NLS-1$
|
public static final String RULE_PHONY = ".PHONY"; //$NON-NLS-1$
|
||||||
static final String RULE_INTERMEDIATE = ".INTERMEDIATE"; //$NON-NLS-1$
|
public static final String RULE_SECONDARY = ".SECONDARY"; //$NON-NLS-1$
|
||||||
|
public static final String RULE_LOW_RESOLUTION_TIME = ".LOW_RESOLUTION_TIME"; //$NON-NLS-1$
|
||||||
|
public static final String RULE_NOT_PARALLEL = ".NOTPARALLEL"; //$NON-NLS-1$
|
||||||
|
public static final String RULE_EXPORT_ALL_VARIABLES = ".EXPORT_ALL_VARIABLES"; //$NON-NLS-1$
|
||||||
|
public static final String RULE_INTERMEDIATE = ".INTERMEDIATE"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,8 @@ public class OpenDeclarationAction extends TextEditorAction {
|
||||||
String name = wordPart.getName();
|
String name = wordPart.getName();
|
||||||
if (wordPart.isMacro()) {
|
if (wordPart.isMacro()) {
|
||||||
directives = makefile.getMacroDefinitions(name);
|
directives = makefile.getMacroDefinitions(name);
|
||||||
if (directives.length == 0) {
|
} else if (wordPart.isFunctionCall()) {
|
||||||
directives = makefile.getBuiltinMacroDefinitions(name);
|
directives = makefile.getMacroDefinitions(wordPart.getName());
|
||||||
}
|
|
||||||
} else if (wordPart.isIncludeDirective()) {
|
} else if (wordPart.isIncludeDirective()) {
|
||||||
String incFile = wordPart.getName();
|
String incFile = wordPart.getName();
|
||||||
incFile = makefile.expandString(incFile, true);
|
incFile = makefile.expandString(incFile, true);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.make.internal.ui.text;
|
package org.eclipse.cdt.make.internal.ui.text;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.make.internal.core.makefile.gnu.GNUMakefileConstants;
|
||||||
import org.eclipse.cdt.make.internal.core.makefile.gnu.GNUMakefileUtil;
|
import org.eclipse.cdt.make.internal.core.makefile.gnu.GNUMakefileUtil;
|
||||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
|
@ -25,6 +26,7 @@ public class WordPartDetector {
|
||||||
private enum WORDPART_TYPE {
|
private enum WORDPART_TYPE {
|
||||||
MACRO,
|
MACRO,
|
||||||
INCLUDE,
|
INCLUDE,
|
||||||
|
FUNCTION_CALL,
|
||||||
UNDETERMINED,
|
UNDETERMINED,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +70,36 @@ public class WordPartDetector {
|
||||||
MakeUIPlugin.log(e);
|
MakeUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to figure out if we are in a user defined function call $(call user-fun)
|
||||||
|
try {
|
||||||
|
for (int index = offset - 1; index > 0; index--) {
|
||||||
|
char c = document.getChar(index);
|
||||||
|
if (!Character.isJavaIdentifierPart(c) && c != '-' && c != ' ') {
|
||||||
|
boolean isFunction = (c == '(' || c == '{') && document.getChar(index-1) == '$';
|
||||||
|
if (isFunction) {
|
||||||
|
String builtinFun = document.get(index + 1,4);
|
||||||
|
if (builtinFun.equals(GNUMakefileConstants.FUNCTION_CALL)) {
|
||||||
|
type = WORDPART_TYPE.FUNCTION_CALL;
|
||||||
|
int nameOffset = index + 2 + GNUMakefileConstants.FUNCTION_CALL.length();
|
||||||
|
int endIndex = offset;
|
||||||
|
for (endIndex = offset; endIndex < document.getLength(); endIndex++) {
|
||||||
|
// skip through function name
|
||||||
|
char c2 = document.getChar(endIndex);
|
||||||
|
if (!(Character.isJavaIdentifierPart(c2) || c2 == '-')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wordPart = document.get(nameOffset,endIndex-nameOffset);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
MakeUIPlugin.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
// Try to figure out if the cursor is on an include directive.
|
// Try to figure out if the cursor is on an include directive.
|
||||||
try {
|
try {
|
||||||
int lineNumber = document.getLineOfOffset(offset);
|
int lineNumber = document.getLineOfOffset(offset);
|
||||||
|
@ -91,7 +123,6 @@ public class WordPartDetector {
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
MakeUIPlugin.log(e);
|
MakeUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,6 +134,15 @@ public class WordPartDetector {
|
||||||
return type == WORDPART_TYPE.MACRO;
|
return type == WORDPART_TYPE.MACRO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the cursor is in function call $(call user-fun).
|
||||||
|
*
|
||||||
|
* @return {@code true} if the cursor is located in function call, {@code false} otherwise.
|
||||||
|
*/
|
||||||
|
public boolean isFunctionCall() {
|
||||||
|
return type == WORDPART_TYPE.FUNCTION_CALL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the cursor sits on an include directive line.
|
* Check if the cursor sits on an include directive line.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue