mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 278987 - Text Colors wrong in Makefile
This commit is contained in:
parent
dd438b6cee
commit
a2a8ff55a9
4 changed files with 47 additions and 83 deletions
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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()
|
* @see org.eclipse.cdt.make.internal.ui.text.makefile.AbstractMakefileCodeScanner#createRules()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected List createRules() {
|
protected List createRules() {
|
||||||
setDefaultReturnToken(getToken(fProperties[0]));
|
setDefaultReturnToken(getToken(fProperties[0]));
|
||||||
return null;
|
return null;
|
||||||
|
@ -69,6 +70,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration {
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.make.internal.ui.text.makefile.AbstractMakefileCodeScanner#getTokenProperties()
|
* @see org.eclipse.cdt.make.internal.ui.text.makefile.AbstractMakefileCodeScanner#getTokenProperties()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected String[] getTokenProperties() {
|
protected String[] getTokenProperties() {
|
||||||
return fProperties;
|
return fProperties;
|
||||||
}
|
}
|
||||||
|
@ -86,31 +88,22 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration {
|
||||||
/**
|
/**
|
||||||
* @see SourceViewerConfiguration#getConfiguredContentTypes(ISourceViewer)
|
* @see SourceViewerConfiguration#getConfiguredContentTypes(ISourceViewer)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String[] getConfiguredContentTypes(ISourceViewer v) {
|
public String[] getConfiguredContentTypes(ISourceViewer v) {
|
||||||
return new String[] {
|
return MakefilePartitionScanner.MAKE_PARTITIONS;
|
||||||
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,
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentAssistant(ISourceViewer)
|
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentAssistant(ISourceViewer)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
|
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
|
||||||
if (fEditor != null && fEditor.isEditable()) {
|
if (fEditor != null && fEditor.isEditable()) {
|
||||||
ContentAssistant assistant = new ContentAssistant();
|
ContentAssistant assistant = new ContentAssistant();
|
||||||
assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
|
assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
|
||||||
assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), IDocument.DEFAULT_CONTENT_TYPE);
|
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_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.enableAutoActivation(true);
|
||||||
assistant.setAutoActivationDelay(500);
|
assistant.setAutoActivationDelay(500);
|
||||||
|
@ -137,6 +130,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration {
|
||||||
return fCommentScanner;
|
return fCommentScanner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IPresentationReconciler getPresentationReconciler(ISourceViewer v) {
|
public IPresentationReconciler getPresentationReconciler(ISourceViewer v) {
|
||||||
|
|
||||||
PresentationReconciler reconciler = new PresentationReconciler();
|
PresentationReconciler reconciler = new PresentationReconciler();
|
||||||
|
@ -149,32 +143,13 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration {
|
||||||
dr = new DefaultDamagerRepairer(getCommentScanner());
|
dr = new DefaultDamagerRepairer(getCommentScanner());
|
||||||
reconciler.setDamager(dr, MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION);
|
reconciler.setDamager(dr, MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION);
|
||||||
reconciler.setRepairer(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;
|
return reconciler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
|
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
|
public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
|
||||||
return MakefileDocumentSetupParticipant.MAKEFILE_PARTITIONING;
|
return MakefileDocumentSetupParticipant.MAKEFILE_PARTITIONING;
|
||||||
}
|
}
|
||||||
|
@ -182,6 +157,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration {
|
||||||
/**
|
/**
|
||||||
* @see SourceViewerConfiguration#getReconciler(ISourceViewer)
|
* @see SourceViewerConfiguration#getReconciler(ISourceViewer)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public IReconciler getReconciler(ISourceViewer sourceViewer) {
|
public IReconciler getReconciler(ISourceViewer sourceViewer) {
|
||||||
if (fEditor != null && fEditor.isEditable()) {
|
if (fEditor != null && fEditor.isEditable()) {
|
||||||
MonoReconciler reconciler= new MonoReconciler(new MakefileReconcilingStrategy(fEditor), false);
|
MonoReconciler reconciler= new MonoReconciler(new MakefileReconcilingStrategy(fEditor), false);
|
||||||
|
@ -195,6 +171,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getDefaultPrefixes(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
|
* @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) {
|
public String[] getDefaultPrefixes(ISourceViewer sourceViewer, String contentType) {
|
||||||
return new String[]{"#"}; //$NON-NLS-1$
|
return new String[]{"#"}; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -202,6 +179,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getTextHover(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
|
* @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) {
|
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
|
||||||
if (fEditor != null) {
|
if (fEditor != null) {
|
||||||
return new MakefileTextHover(fEditor);
|
return new MakefileTextHover(fEditor);
|
||||||
|
@ -211,6 +189,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAnnotationHover(org.eclipse.jface.text.source.ISourceViewer)
|
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAnnotationHover(org.eclipse.jface.text.source.ISourceViewer)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
|
public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
|
||||||
if (fEditor != null) {
|
if (fEditor != null) {
|
||||||
return new MakefileAnnotationHover(fEditor);
|
return new MakefileAnnotationHover(fEditor);
|
||||||
|
@ -220,7 +199,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param event
|
* @param event
|
||||||
* @return
|
* @return <code>true</code> if the given property change event affects the code coloring
|
||||||
*/
|
*/
|
||||||
public boolean affectsBehavior(PropertyChangeEvent event) {
|
public boolean affectsBehavior(PropertyChangeEvent event) {
|
||||||
if (fCodeScanner != null && fCodeScanner.affectsBehavior(event)) {
|
if (fCodeScanner != null && fCodeScanner.affectsBehavior(event)) {
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.ICharacterScanner;
|
||||||
import org.eclipse.jface.text.rules.IPredicateRule;
|
import org.eclipse.jface.text.rules.IPredicateRule;
|
||||||
import org.eclipse.jface.text.rules.IToken;
|
import org.eclipse.jface.text.rules.IToken;
|
||||||
import org.eclipse.jface.text.rules.Token;
|
|
||||||
|
|
||||||
class MacroDefinitionRule implements IPredicateRule {
|
class MacroDefinitionRule implements IPredicateRule {
|
||||||
private static final int INIT_STATE = 0;
|
private static final int INIT_STATE = 0;
|
||||||
|
@ -60,6 +59,7 @@ class MacroDefinitionRule implements IPredicateRule {
|
||||||
if (isValidCharacter(c)) {
|
if (isValidCharacter(c)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
//$FALL-THROUGH$
|
||||||
case END_VAR_STATE :
|
case END_VAR_STATE :
|
||||||
if (c != '\n' && Character.isWhitespace((char) c)) {
|
if (c != '\n' && Character.isWhitespace((char) c)) {
|
||||||
state = END_VAR_STATE;
|
state = END_VAR_STATE;
|
||||||
|
@ -68,9 +68,6 @@ class MacroDefinitionRule implements IPredicateRule {
|
||||||
} else if (c == '=') {
|
} else if (c == '=') {
|
||||||
state = FINISH_STATE;
|
state = FINISH_STATE;
|
||||||
} else {
|
} else {
|
||||||
if (state == END_VAR_STATE) {
|
|
||||||
scanner.unread(); // Return back to the space
|
|
||||||
}
|
|
||||||
state = ERROR_STATE;
|
state = ERROR_STATE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -102,7 +99,7 @@ class MacroDefinitionRule implements IPredicateRule {
|
||||||
if (defaultToken.isUndefined())
|
if (defaultToken.isUndefined())
|
||||||
unreadBuffer(scanner);
|
unreadBuffer(scanner);
|
||||||
|
|
||||||
return Token.UNDEFINED;
|
return defaultToken;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +118,7 @@ class MacroDefinitionRule implements IPredicateRule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private void scanToEndOfLine(ICharacterScanner scanner) {
|
private void scanToEndOfLine(ICharacterScanner scanner) {
|
||||||
int c;
|
int c;
|
||||||
char[][] delimiters = scanner.getLegalLineDelimiters();
|
char[][] delimiters = scanner.getLegalLineDelimiters();
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -14,9 +14,12 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.make.internal.ui.text.ColorManager;
|
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.IToken;
|
||||||
import org.eclipse.jface.text.rules.IWhitespaceDetector;
|
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.MultiLineRule;
|
||||||
|
import org.eclipse.jface.text.rules.Token;
|
||||||
import org.eclipse.jface.text.rules.WhitespaceRule;
|
import org.eclipse.jface.text.rules.WhitespaceRule;
|
||||||
import org.eclipse.jface.text.rules.WordRule;
|
import org.eclipse.jface.text.rules.WordRule;
|
||||||
|
|
||||||
|
@ -52,39 +55,52 @@ public class MakefileCodeScanner extends AbstractMakefileCodeScanner {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List createRules() {
|
@Override
|
||||||
|
protected List<IRule> createRules() {
|
||||||
IToken keyword = getToken(ColorManager.MAKE_KEYWORD_COLOR);
|
IToken keyword = getToken(ColorManager.MAKE_KEYWORD_COLOR);
|
||||||
IToken function = getToken(ColorManager.MAKE_FUNCTION_COLOR);
|
IToken function = getToken(ColorManager.MAKE_FUNCTION_COLOR);
|
||||||
IToken macroRef = getToken(ColorManager.MAKE_MACRO_REF_COLOR);
|
IToken macroRef = getToken(ColorManager.MAKE_MACRO_REF_COLOR);
|
||||||
IToken macroDef = getToken(ColorManager.MAKE_MACRO_DEF_COLOR);
|
IToken macroDef = getToken(ColorManager.MAKE_MACRO_DEF_COLOR);
|
||||||
IToken other = getToken(ColorManager.MAKE_DEFAULT_COLOR);
|
IToken other = getToken(ColorManager.MAKE_DEFAULT_COLOR);
|
||||||
|
|
||||||
List rules = new ArrayList();
|
List<IRule> rules = new ArrayList<IRule>();
|
||||||
|
|
||||||
// Add generic whitespace rule.
|
// Add generic whitespace rule.
|
||||||
rules.add(new WhitespaceRule(new IWhitespaceDetector() {
|
rules.add(new WhitespaceRule(new IWhitespaceDetector() {
|
||||||
public boolean isWhitespace(char character) {
|
public boolean isWhitespace(char character) {
|
||||||
return Character.isWhitespace(character);
|
return Character.isWhitespace(character);
|
||||||
}
|
}
|
||||||
}));
|
}, other));
|
||||||
|
|
||||||
// Put before the the word rules
|
// 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", macroDef); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
defineRule.setColumnConstraint(0);
|
defineRule.setColumnConstraint(0);
|
||||||
rules.add(defineRule);
|
rules.add(defineRule);
|
||||||
|
|
||||||
// rules.add(new MacroDefinitionRule(macroDef, other));
|
rules.add(new MacroDefinitionRule(macroDef, Token.UNDEFINED));
|
||||||
|
|
||||||
// Add word rule for keywords, types, and constants.
|
// Add word rule for keywords, types, and constants.
|
||||||
// We restring the detection of the keywords to be the first column to be valid.
|
// We restrict the detection of the keywords to be the first column to be valid.
|
||||||
WordRule keyWordRule = new WordRule(new MakefileWordDetector(), other);
|
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++) {
|
for (int i = 0; i < keywords.length; i++) {
|
||||||
keyWordRule.addWord(keywords[i], keyword);
|
keyWordRule.addWord(keywords[i], keyword);
|
||||||
}
|
}
|
||||||
keyWordRule.setColumnConstraint(0);
|
keyWordRule.setColumnConstraint(0);
|
||||||
rules.add(keyWordRule);
|
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++)
|
for (int i = 0; i < functions.length; i++)
|
||||||
functionRule.addWord(functions[i], function);
|
functionRule.addWord(functions[i], function);
|
||||||
rules.add(functionRule);
|
rules.add(functionRule);
|
||||||
|
@ -100,6 +116,7 @@ public class MakefileCodeScanner extends AbstractMakefileCodeScanner {
|
||||||
/*
|
/*
|
||||||
* @see AbstractMakefileCodeScanner#getTokenProperties()
|
* @see AbstractMakefileCodeScanner#getTokenProperties()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected String[] getTokenProperties() {
|
protected String[] getTokenProperties() {
|
||||||
return fTokenProperties;
|
return fTokenProperties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.rules.EndOfLineRule;
|
import org.eclipse.jface.text.rules.EndOfLineRule;
|
||||||
import org.eclipse.jface.text.rules.IPredicateRule;
|
import org.eclipse.jface.text.rules.IPredicateRule;
|
||||||
import org.eclipse.jface.text.rules.IToken;
|
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.RuleBasedPartitionScanner;
|
||||||
import org.eclipse.jface.text.rules.Token;
|
import org.eclipse.jface.text.rules.Token;
|
||||||
|
|
||||||
public class MakefilePartitionScanner extends RuleBasedPartitionScanner {
|
public class MakefilePartitionScanner extends RuleBasedPartitionScanner {
|
||||||
// Partition types
|
// Partition types
|
||||||
public final static String MAKEFILE_COMMENT_PARTITION = "makefile_comment"; //$NON-NLS-1$
|
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_OTHER_PARTITION = IDocument.DEFAULT_CONTENT_TYPE;
|
||||||
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[] MAKE_PARTITIONS =
|
public final static String[] MAKE_PARTITIONS =
|
||||||
new String[] {
|
new String[] {
|
||||||
MAKEFILE_COMMENT_PARTITION,
|
MAKEFILE_COMMENT_PARTITION,
|
||||||
MAKEFILE_MACRO_ASSIGNEMENT_PARTITION,
|
|
||||||
MAKEFILE_INCLUDE_BLOCK_PARTITION,
|
|
||||||
MAKEFILE_IF_BLOCK_PARTITION,
|
|
||||||
MAKEFILE_DEF_BLOCK_PARTITION,
|
|
||||||
MAKEFILE_OTHER_PARTITION,
|
MAKEFILE_OTHER_PARTITION,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,36 +41,13 @@ public class MakefilePartitionScanner extends RuleBasedPartitionScanner {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
IToken tComment = new Token(MAKEFILE_COMMENT_PARTITION);
|
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<EndOfLineRule> rules = new ArrayList<EndOfLineRule>();
|
||||||
|
|
||||||
// Add rule for single line comments.
|
// Add rule for single line comments.
|
||||||
|
|
||||||
rules.add(new EndOfLineRule("#", tComment, '\\', true)); //$NON-NLS-1$
|
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()];
|
IPredicateRule[] result = new IPredicateRule[rules.size()];
|
||||||
rules.toArray(result);
|
rules.toArray(result);
|
||||||
setPredicateRules(result);
|
setPredicateRules(result);
|
||||||
|
@ -88,6 +57,7 @@ public class MakefilePartitionScanner extends RuleBasedPartitionScanner {
|
||||||
/*
|
/*
|
||||||
* @see ICharacterScanner#getLegalLineDelimiters
|
* @see ICharacterScanner#getLegalLineDelimiters
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public char[][] getLegalLineDelimiters() {
|
public char[][] getLegalLineDelimiters() {
|
||||||
return fModDelimiters;
|
return fModDelimiters;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue