mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
bug 406911: Cosmetics
This commit is contained in:
parent
ac94a39422
commit
5f19186a60
1 changed files with 28 additions and 26 deletions
|
@ -24,19 +24,20 @@ import org.eclipse.jface.text.rules.WhitespaceRule;
|
|||
import org.eclipse.jface.text.rules.WordRule;
|
||||
|
||||
public class MakefileCodeScanner extends AbstractMakefileCodeScanner {
|
||||
|
||||
private final static String[] keywords = { "define", "endef", "ifdef", "ifndef", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
"ifeq", "ifneq", "else", "endif", "include", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
||||
"-include", "sinclude", "override", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
"export", "unexport", "vpath" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
@SuppressWarnings("nls")
|
||||
private final static String[] keywords = {
|
||||
"define", "endef", "ifdef", "ifndef",
|
||||
"ifeq", "ifneq", "else", "endif", "include",
|
||||
"-include", "sinclude", "override",
|
||||
"export", "unexport", "vpath"
|
||||
};
|
||||
|
||||
public static final String[] fTokenProperties = new String[] {
|
||||
ColorManager.MAKE_KEYWORD_COLOR,
|
||||
ColorManager.MAKE_FUNCTION_COLOR,
|
||||
ColorManager.MAKE_MACRO_REF_COLOR,
|
||||
ColorManager.MAKE_MACRO_DEF_COLOR,
|
||||
ColorManager.MAKE_DEFAULT_COLOR
|
||||
ColorManager.MAKE_KEYWORD_COLOR,
|
||||
ColorManager.MAKE_FUNCTION_COLOR,
|
||||
ColorManager.MAKE_MACRO_REF_COLOR,
|
||||
ColorManager.MAKE_MACRO_DEF_COLOR,
|
||||
ColorManager.MAKE_DEFAULT_COLOR
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -49,11 +50,11 @@ public class MakefileCodeScanner extends AbstractMakefileCodeScanner {
|
|||
|
||||
@Override
|
||||
protected List<IRule> createRules() {
|
||||
IToken keyword = getToken(ColorManager.MAKE_KEYWORD_COLOR);
|
||||
IToken function = getToken(ColorManager.MAKE_FUNCTION_COLOR);
|
||||
IToken macroRef = getToken(ColorManager.MAKE_MACRO_REF_COLOR);
|
||||
IToken macroDef = getToken(ColorManager.MAKE_MACRO_DEF_COLOR);
|
||||
IToken other = getToken(ColorManager.MAKE_DEFAULT_COLOR);
|
||||
IToken keywordToken = getToken(ColorManager.MAKE_KEYWORD_COLOR);
|
||||
IToken functionToken = getToken(ColorManager.MAKE_FUNCTION_COLOR);
|
||||
IToken macroRefToken = getToken(ColorManager.MAKE_MACRO_REF_COLOR);
|
||||
IToken macroDefToken = getToken(ColorManager.MAKE_MACRO_DEF_COLOR);
|
||||
IToken defaultToken = getToken(ColorManager.MAKE_DEFAULT_COLOR);
|
||||
|
||||
List<IRule> rules = new ArrayList<IRule>();
|
||||
|
||||
|
@ -63,14 +64,14 @@ public class MakefileCodeScanner extends AbstractMakefileCodeScanner {
|
|||
public boolean isWhitespace(char character) {
|
||||
return Character.isWhitespace(character);
|
||||
}
|
||||
}, other));
|
||||
}, defaultToken));
|
||||
|
||||
// Put before the the word rules
|
||||
MultiLineRule defineRule = new MultiLineRule("define", "endef", macroDef); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
MultiLineRule defineRule = new MultiLineRule("define", "endef", macroDefToken); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
defineRule.setColumnConstraint(0);
|
||||
rules.add(defineRule);
|
||||
|
||||
rules.add(new MacroDefinitionRule(macroDef, Token.UNDEFINED));
|
||||
rules.add(new MacroDefinitionRule(macroDefToken, Token.UNDEFINED));
|
||||
|
||||
// Add word rule for keywords, types, and constants.
|
||||
// We restrict the detection of the keywords to be the first column to be valid.
|
||||
|
@ -82,20 +83,21 @@ public class MakefileCodeScanner extends AbstractMakefileCodeScanner {
|
|||
@Override
|
||||
public boolean isWordStart(char c) {
|
||||
return Character.isLetterOrDigit(c) || c == '_' || c == '-';
|
||||
}}, other);
|
||||
for (int i = 0; i < keywords.length; i++) {
|
||||
keyWordRule.addWord(keywords[i], keyword);
|
||||
}
|
||||
});
|
||||
for (String keyword : keywords) {
|
||||
keyWordRule.addWord(keyword, keywordToken);
|
||||
}
|
||||
keyWordRule.setColumnConstraint(0);
|
||||
rules.add(keyWordRule);
|
||||
|
||||
rules.add(new FunctionReferenceRule(function));
|
||||
rules.add(new FunctionReferenceRule(functionToken));
|
||||
|
||||
rules.add(new AutomaticVariableReferenceRule(macroRef));
|
||||
rules.add(new MacroReferenceRule(macroRef, "$(", ")")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
rules.add(new MacroReferenceRule(macroRef, "${", "}")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
rules.add(new AutomaticVariableReferenceRule(macroRefToken));
|
||||
rules.add(new MacroReferenceRule(macroRefToken, "$(", ")")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
rules.add(new MacroReferenceRule(macroRefToken, "${", "}")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
setDefaultReturnToken(other);
|
||||
setDefaultReturnToken(defaultToken);
|
||||
|
||||
return rules;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue