diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileSourceConfiguration.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileSourceConfiguration.java index 1c31d537ef8..a147c71a24d 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileSourceConfiguration.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/MakefileSourceConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 QNX Software Systems and others. + * Copyright (c) 2000, 2009 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -61,6 +61,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { /* * @see org.eclipse.cdt.make.internal.ui.text.makefile.AbstractMakefileCodeScanner#createRules() */ + @Override protected List createRules() { setDefaultReturnToken(getToken(fProperties[0])); return null; @@ -69,6 +70,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { /* * @see org.eclipse.cdt.make.internal.ui.text.makefile.AbstractMakefileCodeScanner#getTokenProperties() */ + @Override protected String[] getTokenProperties() { return fProperties; } @@ -86,31 +88,22 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { /** * @see SourceViewerConfiguration#getConfiguredContentTypes(ISourceViewer) */ + @Override public String[] getConfiguredContentTypes(ISourceViewer v) { - return new String[] { - IDocument.DEFAULT_CONTENT_TYPE, - MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION, - MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION, - MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION, - MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION, - MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION, - }; + return MakefilePartitionScanner.MAKE_PARTITIONS; } /** * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentAssistant(ISourceViewer) */ + @Override public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { if (fEditor != null && fEditor.isEditable()) { ContentAssistant assistant = new ContentAssistant(); assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), IDocument.DEFAULT_CONTENT_TYPE); assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION); assistant.enableAutoActivation(true); assistant.setAutoActivationDelay(500); @@ -137,6 +130,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { return fCommentScanner; } + @Override public IPresentationReconciler getPresentationReconciler(ISourceViewer v) { PresentationReconciler reconciler = new PresentationReconciler(); @@ -149,32 +143,13 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { dr = new DefaultDamagerRepairer(getCommentScanner()); reconciler.setDamager(dr, MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION); reconciler.setRepairer(dr, MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION); - - dr = new DefaultDamagerRepairer(getCodeScanner()); - reconciler.setDamager(dr, MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION); - reconciler.setRepairer(dr, MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION); - - dr = new DefaultDamagerRepairer(getCodeScanner()); - reconciler.setDamager(dr, MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION); - reconciler.setRepairer(dr, MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION); - - dr = new DefaultDamagerRepairer(getCodeScanner()); - reconciler.setDamager(dr, MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION); - reconciler.setRepairer(dr, MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION); - - dr = new DefaultDamagerRepairer(getCodeScanner()); - reconciler.setDamager(dr, MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION); - reconciler.setRepairer(dr, MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION); - - dr = new DefaultDamagerRepairer(getCodeScanner()); - reconciler.setDamager(dr, MakefilePartitionScanner.MAKEFILE_OTHER_PARTITION); - reconciler.setRepairer(dr, MakefilePartitionScanner.MAKEFILE_OTHER_PARTITION); return reconciler; } /* * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer) */ + @Override public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) { return MakefileDocumentSetupParticipant.MAKEFILE_PARTITIONING; } @@ -182,6 +157,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { /** * @see SourceViewerConfiguration#getReconciler(ISourceViewer) */ + @Override public IReconciler getReconciler(ISourceViewer sourceViewer) { if (fEditor != null && fEditor.isEditable()) { MonoReconciler reconciler= new MonoReconciler(new MakefileReconcilingStrategy(fEditor), false); @@ -195,6 +171,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { /* (non-Javadoc) * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getDefaultPrefixes(org.eclipse.jface.text.source.ISourceViewer, java.lang.String) */ + @Override public String[] getDefaultPrefixes(ISourceViewer sourceViewer, String contentType) { return new String[]{"#"}; //$NON-NLS-1$ } @@ -202,6 +179,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { /* (non-Javadoc) * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getTextHover(org.eclipse.jface.text.source.ISourceViewer, java.lang.String) */ + @Override public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { if (fEditor != null) { return new MakefileTextHover(fEditor); @@ -211,6 +189,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { /* (non-Javadoc) * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAnnotationHover(org.eclipse.jface.text.source.ISourceViewer) */ + @Override public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) { if (fEditor != null) { return new MakefileAnnotationHover(fEditor); @@ -220,7 +199,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { /** * @param event - * @return + * @return true if the given property change event affects the code coloring */ public boolean affectsBehavior(PropertyChangeEvent event) { if (fCodeScanner != null && fCodeScanner.affectsBehavior(event)) { diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MacroDefinitionRule.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MacroDefinitionRule.java index 928bae15b48..78df4142df3 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MacroDefinitionRule.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MacroDefinitionRule.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2008 QNX Software Systems and others. + * Copyright (c) 2002, 2009 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,7 +14,6 @@ package org.eclipse.cdt.make.internal.ui.text.makefile; import org.eclipse.jface.text.rules.ICharacterScanner; import org.eclipse.jface.text.rules.IPredicateRule; import org.eclipse.jface.text.rules.IToken; -import org.eclipse.jface.text.rules.Token; class MacroDefinitionRule implements IPredicateRule { private static final int INIT_STATE = 0; @@ -60,6 +59,7 @@ class MacroDefinitionRule implements IPredicateRule { if (isValidCharacter(c)) { break; } + //$FALL-THROUGH$ case END_VAR_STATE : if (c != '\n' && Character.isWhitespace((char) c)) { state = END_VAR_STATE; @@ -68,9 +68,6 @@ class MacroDefinitionRule implements IPredicateRule { } else if (c == '=') { state = FINISH_STATE; } else { - if (state == END_VAR_STATE) { - scanner.unread(); // Return back to the space - } state = ERROR_STATE; } break; @@ -102,7 +99,7 @@ class MacroDefinitionRule implements IPredicateRule { if (defaultToken.isUndefined()) unreadBuffer(scanner); - return Token.UNDEFINED; + return defaultToken; } @@ -121,6 +118,7 @@ class MacroDefinitionRule implements IPredicateRule { } } + @SuppressWarnings("unused") private void scanToEndOfLine(ICharacterScanner scanner) { int c; char[][] delimiters = scanner.getLegalLineDelimiters(); diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MakefileCodeScanner.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MakefileCodeScanner.java index 5f26759ee31..35d8052f9c9 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MakefileCodeScanner.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MakefileCodeScanner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 QNX Software Systems and others. + * Copyright (c) 2000, 2009 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,9 +14,12 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.cdt.make.internal.ui.text.ColorManager; +import org.eclipse.jface.text.rules.IRule; import org.eclipse.jface.text.rules.IToken; import org.eclipse.jface.text.rules.IWhitespaceDetector; +import org.eclipse.jface.text.rules.IWordDetector; import org.eclipse.jface.text.rules.MultiLineRule; +import org.eclipse.jface.text.rules.Token; import org.eclipse.jface.text.rules.WhitespaceRule; import org.eclipse.jface.text.rules.WordRule; @@ -52,39 +55,52 @@ public class MakefileCodeScanner extends AbstractMakefileCodeScanner { initialize(); } - protected List createRules() { + @Override + protected List 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); - List rules = new ArrayList(); + List rules = new ArrayList(); // Add generic whitespace rule. rules.add(new WhitespaceRule(new IWhitespaceDetector() { public boolean isWhitespace(char character) { return Character.isWhitespace(character); } - })); + }, other)); // Put before the the word rules MultiLineRule defineRule = new MultiLineRule("define", "endef", macroDef); //$NON-NLS-1$ //$NON-NLS-2$ defineRule.setColumnConstraint(0); rules.add(defineRule); -// rules.add(new MacroDefinitionRule(macroDef, other)); + rules.add(new MacroDefinitionRule(macroDef, Token.UNDEFINED)); // Add word rule for keywords, types, and constants. - // We restring the detection of the keywords to be the first column to be valid. - WordRule keyWordRule = new WordRule(new MakefileWordDetector(), other); + // We restrict the detection of the keywords to be the first column to be valid. + WordRule keyWordRule = new WordRule(new IWordDetector() { + public boolean isWordPart(char c) { + return Character.isLetterOrDigit(c) || c == '_'; + } + 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); } keyWordRule.setColumnConstraint(0); rules.add(keyWordRule); - WordRule functionRule = new WordRule(new MakefileWordDetector(), other); + WordRule functionRule = new WordRule(new IWordDetector() { + public boolean isWordPart(char c) { + return Character.isLetterOrDigit(c) || c == '_'; + } + public boolean isWordStart(char c) { + return Character.isLetterOrDigit(c) || c == '_'; + }}, other); for (int i = 0; i < functions.length; i++) functionRule.addWord(functions[i], function); rules.add(functionRule); @@ -100,6 +116,7 @@ public class MakefileCodeScanner extends AbstractMakefileCodeScanner { /* * @see AbstractMakefileCodeScanner#getTokenProperties() */ + @Override protected String[] getTokenProperties() { return fTokenProperties; } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MakefilePartitionScanner.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MakefilePartitionScanner.java index ee74e50209c..b5c2d45ca81 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MakefilePartitionScanner.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MakefilePartitionScanner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 QNX Software Systems and others. + * Copyright (c) 2000, 2009 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,29 +13,21 @@ package org.eclipse.cdt.make.internal.ui.text.makefile; import java.util.ArrayList; import java.util.List; +import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.rules.EndOfLineRule; import org.eclipse.jface.text.rules.IPredicateRule; import org.eclipse.jface.text.rules.IToken; -import org.eclipse.jface.text.rules.MultiLineRule; import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; import org.eclipse.jface.text.rules.Token; public class MakefilePartitionScanner extends RuleBasedPartitionScanner { // Partition types public final static String MAKEFILE_COMMENT_PARTITION = "makefile_comment"; //$NON-NLS-1$ - public final static String MAKEFILE_MACRO_ASSIGNEMENT_PARTITION = "makefile_macro_assignement"; //$NON-NLS-1$ - public final static String MAKEFILE_INCLUDE_BLOCK_PARTITION = "makefile_include_block"; //$NON-NLS-1$ - public final static String MAKEFILE_IF_BLOCK_PARTITION = "makefile_if_block"; //$NON-NLS-1$ - public final static String MAKEFILE_DEF_BLOCK_PARTITION = "makefile_def_block"; //$NON-NLS-1$ - public final static String MAKEFILE_OTHER_PARTITION = "makefile_other"; //$NON-NLS-1$ + public final static String MAKEFILE_OTHER_PARTITION = IDocument.DEFAULT_CONTENT_TYPE; public final static String[] MAKE_PARTITIONS = new String[] { MAKEFILE_COMMENT_PARTITION, - MAKEFILE_MACRO_ASSIGNEMENT_PARTITION, - MAKEFILE_INCLUDE_BLOCK_PARTITION, - MAKEFILE_IF_BLOCK_PARTITION, - MAKEFILE_DEF_BLOCK_PARTITION, MAKEFILE_OTHER_PARTITION, }; @@ -49,36 +41,13 @@ public class MakefilePartitionScanner extends RuleBasedPartitionScanner { super(); IToken tComment = new Token(MAKEFILE_COMMENT_PARTITION); - IToken tMacro = new Token(MAKEFILE_MACRO_ASSIGNEMENT_PARTITION); - IToken tInclude = new Token(MAKEFILE_INCLUDE_BLOCK_PARTITION); - IToken tIf = new Token(MAKEFILE_IF_BLOCK_PARTITION); - IToken tDef = new Token(MAKEFILE_DEF_BLOCK_PARTITION); - IToken tOther = new Token(MAKEFILE_OTHER_PARTITION); - List rules = new ArrayList(); + List rules = new ArrayList(); // Add rule for single line comments. rules.add(new EndOfLineRule("#", tComment, '\\', true)); //$NON-NLS-1$ - rules.add(new EndOfLineRule("include", tInclude)); //$NON-NLS-1$ - - rules.add(new EndOfLineRule("export", tDef)); //$NON-NLS-1$ - rules.add(new EndOfLineRule("unexport", tDef)); //$NON-NLS-1$ - rules.add(new EndOfLineRule("vpath", tDef)); //$NON-NLS-1$ - rules.add(new EndOfLineRule("override", tDef)); //$NON-NLS-1$ - rules.add(new MultiLineRule("define", "endef", tDef)); //$NON-NLS-1$ //$NON-NLS-2$ - rules.add(new MultiLineRule("override define", "endef", tDef)); //$NON-NLS-1$ //$NON-NLS-2$ - - // Add rules for conditionals - rules.add(new MultiLineRule("ifdef", "endif", tIf)); //$NON-NLS-1$ //$NON-NLS-2$ - rules.add(new MultiLineRule("ifndef", "endif", tIf)); //$NON-NLS-1$ //$NON-NLS-2$ - rules.add(new MultiLineRule("ifeq", "endif", tIf)); //$NON-NLS-1$ //$NON-NLS-2$ - rules.add(new MultiLineRule("ifnneq", "endif", tIf)); //$NON-NLS-1$ //$NON-NLS-2$ - - // Last rule must be supplied with default token! - rules.add(new MacroDefinitionRule(tMacro, tOther)); - IPredicateRule[] result = new IPredicateRule[rules.size()]; rules.toArray(result); setPredicateRules(result); @@ -88,6 +57,7 @@ public class MakefilePartitionScanner extends RuleBasedPartitionScanner { /* * @see ICharacterScanner#getLegalLineDelimiters */ + @Override public char[][] getLegalLineDelimiters() { return fModDelimiters; }