1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 14:25:37 +02:00

Rename to Makefile*.java instead of Make*.java

Files are for managing Makefile related things.
This commit is contained in:
Alain Magloire 2003-09-07 19:44:27 +00:00
parent 9147013836
commit 11fbc47cb2
14 changed files with 415 additions and 187 deletions

View file

@ -15,7 +15,7 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
public interface IMakeColorManager {
public interface IMakefileColorManager {
public static final RGB MAKE_COMMENT = new RGB(128, 0, 0);
public static final RGB MAKE_KEYWORD = new RGB(128, 128, 0);
public static final RGB MAKE_FUNCTION = new RGB(128, 0, 128);

View file

@ -1,89 +0,0 @@
/**********************************************************************
* Copyright (c) 2002,2003 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.make.internal.ui.editor;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.ui.texteditor.DefaultRangeIndicator;
import org.eclipse.ui.texteditor.StatusTextEditor;
public class MakeTextEditor extends StatusTextEditor {
public final static String MAKE_COMMENT = "make_comment"; //$NON-NLS-1$
public final static String MAKE_KEYWORD = "make_keyword"; //$NON-NLS-1$
public final static String MAKE_MACRO_VAR = "macro_var"; //$NON-NLS-1$
public final static String MAKE_META_DATA = "meta_data"; //$NON-NLS-1$
private boolean presentationState;
public MakeTextEditor() {
super();
initializeEditor();
}
/**
* @see AbstractTextEditor#init(IEditorSite, IEditorInput)
*/
protected void initializeEditor() {
setSourceViewerConfiguration(new MakeEditorConfiguration(new MakeColorManager()));
setRangeIndicator(new DefaultRangeIndicator());
setEditorContextMenuId("#MakeEditorContext"); //$NON-NLS-1$
setRulerContextMenuId("#MakeRulerContext"); //$NON-NLS-1$
}
public boolean getPresentationState() {
return presentationState;
}
public void setPresentationState(boolean newState) {
ISourceViewer srcViewer = getSourceViewer();
if (null == srcViewer)
return;
presentationState = newState;
if (newState)
srcViewer.resetVisibleRegion();
else {
IDocument document = getDocumentProvider().getDocument(getEditorInput());
int nVisibleRegionLength;
// Collect old information
for (int offset = 0; offset < document.getLength();) {
try {
ITypedRegion region = document.getPartition(offset);
if (region.getType().equals(MakePartitionScanner.MAKE_INTERNAL)) {
nVisibleRegionLength = region.getOffset();
srcViewer = getSourceViewer();
if (null != srcViewer)
srcViewer.setVisibleRegion(0, nVisibleRegionLength);
break;
}
offset += Math.max(region.getLength(), 1);
} catch (BadLocationException e) {
break;
}
}
}
}
/**
* @see org.eclipse.ui.texteditor.ITextEditor#selectAndReveal(int, int)
*/
public void selectAndReveal(int offset, int length) {
super.selectAndReveal(offset, length);
// Update visible region because text could be updated
// This is not the best place for that, at least not very
// straightforward. However keep it there for a meantime.
setPresentationState(getPresentationState());
}
}

View file

@ -25,7 +25,7 @@ import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.rules.WhitespaceRule;
import org.eclipse.jface.text.rules.WordRule;
public class MakeCodeScanner extends RuleBasedScanner {
public class MakefileCodeScanner extends RuleBasedScanner {
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$
@ -38,16 +38,16 @@ public class MakeCodeScanner extends RuleBasedScanner {
"firstword", "wildcard", "error", "warning", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"shell", "origin", "foreach", "call" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
/**
* Constructor for MakeCodeScanner
* Constructor for MakefileCodeScanner
*/
public MakeCodeScanner(IMakeColorManager provider) {
public MakefileCodeScanner(IMakefileColorManager provider) {
super();
IToken keyword = new Token(new TextAttribute(provider.getColor(IMakeColorManager.MAKE_KEYWORD)));
IToken function = new Token(new TextAttribute(provider.getColor(IMakeColorManager.MAKE_FUNCTION)));
IToken comment = new Token(new TextAttribute(provider.getColor(IMakeColorManager.MAKE_COMMENT)));
IToken macro = new Token(new TextAttribute(provider.getColor(IMakeColorManager.MAKE_MACRO_VAR)));
IToken other = new Token(new TextAttribute(provider.getColor(IMakeColorManager.MAKE_DEFAULT)));
IToken keyword = new Token(new TextAttribute(provider.getColor(IMakefileColorManager.MAKE_KEYWORD)));
IToken function = new Token(new TextAttribute(provider.getColor(IMakefileColorManager.MAKE_FUNCTION)));
IToken comment = new Token(new TextAttribute(provider.getColor(IMakefileColorManager.MAKE_COMMENT)));
IToken macro = new Token(new TextAttribute(provider.getColor(IMakefileColorManager.MAKE_MACRO_VAR)));
IToken other = new Token(new TextAttribute(provider.getColor(IMakefileColorManager.MAKE_DEFAULT)));
List rules = new ArrayList();
@ -62,7 +62,7 @@ public class MakeCodeScanner extends RuleBasedScanner {
}));
// Add word rule for keywords, types, and constants.
WordRule wordRule = new WordRule(new MakeWordDetector(), Token.UNDEFINED);
WordRule wordRule = new WordRule(new MakefileWordDetector(), Token.UNDEFINED);
for (int i = 0; i < keywords.length; i++)
wordRule.addWord(keywords[i], keyword);
for (int i = 0; i < functions.length; i++)

View file

@ -18,12 +18,12 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
public class MakeColorManager implements IMakeColorManager {
public class MakefileColorManager implements IMakefileColorManager {
protected Map fColorTable = new HashMap(10);
/**
* @see IMakeColorManager#dispose()
* @see IMakefileColorManager#dispose()
*/
public void dispose() {
Iterator e = fColorTable.values().iterator();
@ -32,7 +32,7 @@ public class MakeColorManager implements IMakeColorManager {
}
/**
* @see IMakeColorManager#getColor(RGB)
* @see IMakefileColorManager#getColor(RGB)
*/
public Color getColor(RGB rgb) {
Color color = (Color) fColorTable.get(rgb);

View file

@ -0,0 +1,252 @@
/**********************************************************************
* Copyright (c) 2002,2003 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.make.internal.ui.editor;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.cdt.make.core.makefile.IInferenceRule;
import org.eclipse.cdt.make.core.makefile.IMacroDefinition;
import org.eclipse.cdt.make.core.makefile.IMakefile;
import org.eclipse.cdt.make.core.makefile.IRule;
import org.eclipse.cdt.make.core.makefile.IStatement;
import org.eclipse.cdt.make.core.makefile.ITargetRule;
import org.eclipse.cdt.make.internal.core.makefile.posix.PosixMakefile;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
/**
* MakefileContentOutlinePage
*/
public class MakefileContentOutlinePage extends ContentOutlinePage implements IContentOutlinePage {
private class MakefileContentProvider implements ITreeContentProvider {
protected boolean showMacroDefinition = true;
protected boolean showTargetRule = true;
protected boolean showInferenceRule = true;
protected IMakefile makefile;
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
*/
public Object[] getChildren(Object element) {
if (element == fInput) {
return getElements(element);
}
return new Object[0];
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
*/
public Object getParent(Object element) {
if (element instanceof IStatement)
return fInput;
return fInput;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
*/
public boolean hasChildren(Object element) {
return element == fInput;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
public Object[] getElements(Object inputElement) {
List list = new ArrayList();
if (showMacroDefinition) {
list.addAll(Arrays.asList(makefile.getMacroDefinitions()));
}
if (showInferenceRule) {
list.addAll(Arrays.asList(makefile.getInferenceRules()));
}
if (showTargetRule) {
list.addAll(Arrays.asList(makefile.getTargetRules()));
}
return list.toArray();
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (oldInput != null) {
//IDocument document= fDocumentProvider.getDocument(oldInput);
//if (document != null) {
//}
}
if (newInput != null) {
IDocument document = fDocumentProvider.getDocument(newInput);
if (document != null) {
try {
String content = document.get();
Reader r = new StringReader(content);
makefile = new PosixMakefile(r);
} catch (IOException e) {
}
}
}
}
}
private class MakefileLabelProvider extends LabelProvider implements ILabelProvider {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
*/
public Image getImage(Object element) {
if (element instanceof ITargetRule) {
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_TARGET_RULE);
} else if (element instanceof IInferenceRule) {
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_INFERENCE_RULE);
} else if (element instanceof IMacroDefinition) {
return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_MACRO);
}
return super.getImage(element);
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
public String getText(Object element) {
if (element instanceof IRule) {
return ((IRule) element).getTarget().toString();
} else if (element instanceof IMacroDefinition) {
return ((IMacroDefinition) element).getName();
}
return super.getText(element);
}
}
protected IDocumentProvider fDocumentProvider;
protected MakefileEditor fEditor;
protected Object fInput;
public MakefileContentOutlinePage(IDocumentProvider provider, MakefileEditor editor) {
super();
fDocumentProvider = provider;
fEditor = editor;
}
/* (non-Javadoc)
* @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
super.createControl(parent);
TreeViewer viewer = getTreeViewer();
/*
* We might want to implement our own content provider.
* This content provider should be able to work on a dom like tree
* structure that resembles the file contents.
*/
viewer.setContentProvider(new MakefileContentProvider());
/*
* We probably also need our own label provider.
*/
viewer.setLabelProvider(new MakefileLabelProvider());
if (fInput != null) {
viewer.setInput(fInput);
}
}
/**
* Sets the input of the outline page
*/
public void setInput(Object input) {
fInput = input;
update();
}
/* (non-Javadoc)
* Method declared on ContentOutlinePage
*/
public void selectionChanged(SelectionChangedEvent event) {
super.selectionChanged(event);
ISelection selection = event.getSelection();
if (selection.isEmpty()) {
fEditor.resetHighlightRange();
} else if (selection instanceof IStructuredSelection){
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof IStatement) {
IStatement statement = (IStatement)element;
int startLine = statement.getStartLine() - 1;
int endLine = statement.getEndLine() - 1;
try {
IDocument doc = fEditor.getDocumentProvider().getDocument(fInput);
int start = doc.getLineOffset(startLine);
int len = doc.getLineLength(endLine) - 1;
int length = (doc.getLineOffset(endLine) + len) - start;
fEditor.setHighlightRange(start, length, true);
} catch (IllegalArgumentException x) {
fEditor.resetHighlightRange();
} catch (BadLocationException e) {
fEditor.resetHighlightRange();
}
}
}
}
/**
* Updates the outline page.
*/
public void update() {
TreeViewer viewer = getTreeViewer();
if (viewer != null) {
Control control = viewer.getControl();
if (control != null && !control.isDisposed()) {
control.setRedraw(false);
viewer.setInput(fInput);
viewer.expandAll();
control.setRedraw(true);
}
}
}
}

View file

@ -18,14 +18,14 @@ import org.eclipse.ui.editors.text.FileDocumentProvider;
/**
*/
public class MakeDocumentProvider extends FileDocumentProvider {
public class MakefileDocumentProvider extends FileDocumentProvider {
private static MakePartitionScanner scanner = null;
private static MakefilePartitionScanner scanner = null;
/**
* Constructor for MakeDocumentProvider.
* Constructor for MakefileDocumentProvider.
*/
public MakeDocumentProvider() {
public MakefileDocumentProvider() {
super();
}
@ -36,19 +36,19 @@ public class MakeDocumentProvider extends FileDocumentProvider {
IDocument document = super.createDocument(element);
if (document != null) {
IDocumentPartitioner partitioner = createPartitioner();
document.setDocumentPartitioner(partitioner);
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
}
return document;
}
private IDocumentPartitioner createPartitioner() {
return new DefaultPartitioner(getPartitionScanner(), MakePartitionScanner.TYPES);
return new DefaultPartitioner(getPartitionScanner(), MakefilePartitionScanner.TYPES);
}
private MakePartitionScanner getPartitionScanner() {
private MakefilePartitionScanner getPartitionScanner() {
if (scanner == null)
scanner = new MakePartitionScanner();
scanner = new MakefilePartitionScanner();
return scanner;
}

View file

@ -0,0 +1,77 @@
/**********************************************************************
* Copyright (c) 2002,2003 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.make.internal.ui.editor;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.texteditor.DefaultRangeIndicator;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
public class MakefileEditor extends TextEditor {
public final static String MAKE_COMMENT = "make_comment"; //$NON-NLS-1$
public final static String MAKE_KEYWORD = "make_keyword"; //$NON-NLS-1$
public final static String MAKE_MACRO_VAR = "macro_var"; //$NON-NLS-1$
public final static String MAKE_META_DATA = "meta_data"; //$NON-NLS-1$
/**
* The page that shows the outline.
*/
protected MakefileContentOutlinePage page;
public MakefileEditor() {
super();
initializeEditor();
}
/**
* @see AbstractTextEditor#init(IEditorSite, IEditorInput)
*/
protected void initializeEditor() {
setSourceViewerConfiguration(new MakefileEditorConfiguration(new MakefileColorManager()));
setRangeIndicator(new DefaultRangeIndicator());
setEditorContextMenuId("#MakefileEditorContext"); //$NON-NLS-1$
setRulerContextMenuId("#MakefileRulerContext"); //$NON-NLS-1$
setDocumentProvider(new MakefileDocumentProvider());
}
/* (non-Javadoc)
* Method declared on IAdaptable
*/
public Object getAdapter(Class key) {
if (key.equals(IContentOutlinePage.class)) {
return getOutlinePage();
}
return super.getAdapter(key);
}
private MakefileContentOutlinePage getOutlinePage() {
if (page == null) {
page= new MakefileContentOutlinePage(getDocumentProvider(), this);
//page.addPostSelectionChangedListener(selectionChangedListener);
page.setInput(getEditorInput());
}
return page;
}
/* (non-Javadoc)
* @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor)
*/
public void doSave(IProgressMonitor monitor) {
super.doSave(monitor);
if (page != null) {
page.update();
}
}
}

View file

@ -18,16 +18,16 @@ import org.eclipse.ui.texteditor.ITextEditor;
/**
*/
public class MakeEditorActionContributor extends BasicTextEditorActionContributor {
private MakeEditorTogglePresentationAction togglePresentationAction;
private static final String TOGGLE_PRESENTATION = "make_toggle_presentation"; //$NON-NLS-1$
public class MakefileEditorActionContributor extends BasicTextEditorActionContributor {
private MakefileEditorTogglePresentationAction togglePresentationAction;
private static final String TOGGLE_PRESENTATION = "makefile_toggle_presentation"; //$NON-NLS-1$
/**
* Constructor for MakeEditorActionContributor.
* Constructor for MakefileEditorActionContributor.
*/
public MakeEditorActionContributor() {
public MakefileEditorActionContributor() {
super();
togglePresentationAction = new MakeEditorTogglePresentationAction();
togglePresentationAction = new MakefileEditorTogglePresentationAction();
}
/**

View file

@ -20,10 +20,10 @@ import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
public class MakeEditorConfiguration extends SourceViewerConfiguration {
public class MakefileEditorConfiguration extends SourceViewerConfiguration {
private IMakeColorManager colorManager = null;
private MakeCodeScanner codeScanner = null;
private IMakefileColorManager colorManager = null;
private MakefileCodeScanner codeScanner = null;
/**
* Single token scanner.
@ -37,7 +37,7 @@ public class MakeEditorConfiguration extends SourceViewerConfiguration {
/**
* Constructor for MakeConfiguration
*/
public MakeEditorConfiguration(IMakeColorManager colorManager) {
public MakefileEditorConfiguration(IMakefileColorManager colorManager) {
super();
this.colorManager = colorManager;
}
@ -48,22 +48,22 @@ public class MakeEditorConfiguration extends SourceViewerConfiguration {
public String[] getConfiguredContentTypes(ISourceViewer v) {
return new String[] {
IDocument.DEFAULT_CONTENT_TYPE,
MakeTextEditor.MAKE_COMMENT,
MakeTextEditor.MAKE_KEYWORD,
MakeTextEditor.MAKE_MACRO_VAR,
MakeTextEditor.MAKE_META_DATA };
MakefileEditor.MAKE_COMMENT,
MakefileEditor.MAKE_KEYWORD,
MakefileEditor.MAKE_MACRO_VAR,
MakefileEditor.MAKE_META_DATA };
}
protected IMakeColorManager getColorManager() {
protected IMakefileColorManager getColorManager() {
if (null == colorManager)
colorManager = new MakeColorManager();
colorManager = new MakefileColorManager();
return colorManager;
}
protected MakeCodeScanner getCodeScanner() {
protected MakefileCodeScanner getCodeScanner() {
if (null == codeScanner)
codeScanner = new MakeCodeScanner(getColorManager());
codeScanner = new MakefileCodeScanner(getColorManager());
return codeScanner;
}
@ -77,32 +77,29 @@ public class MakeEditorConfiguration extends SourceViewerConfiguration {
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
dr = new DefaultDamagerRepairer(getCodeScanner());
reconciler.setDamager(dr, MakePartitionScanner.MAKE_INTERNAL);
reconciler.setRepairer(dr, MakePartitionScanner.MAKE_INTERNAL);
dr = new DefaultDamagerRepairer(getCodeScanner());
reconciler.setDamager(dr, MakefilePartitionScanner.MAKE_COMMENT);
reconciler.setRepairer(dr, MakefilePartitionScanner.MAKE_COMMENT);
dr = new DefaultDamagerRepairer(getCodeScanner());
reconciler.setDamager(dr, MakePartitionScanner.MAKE_COMMENT);
reconciler.setRepairer(dr, MakePartitionScanner.MAKE_COMMENT);
reconciler.setDamager(dr, MakefilePartitionScanner.MAKE_MACRO_ASSIGNEMENT);
reconciler.setRepairer(dr, MakefilePartitionScanner.MAKE_MACRO_ASSIGNEMENT);
dr = new DefaultDamagerRepairer(getCodeScanner());
reconciler.setDamager(dr, MakePartitionScanner.MAKE_MACRO_ASSIGNEMENT);
reconciler.setRepairer(dr, MakePartitionScanner.MAKE_MACRO_ASSIGNEMENT);
reconciler.setDamager(dr, MakefilePartitionScanner.MAKE_INCLUDE_BLOCK);
reconciler.setRepairer(dr, MakefilePartitionScanner.MAKE_INCLUDE_BLOCK);
dr = new DefaultDamagerRepairer(getCodeScanner());
reconciler.setDamager(dr, MakePartitionScanner.MAKE_INCLUDE_BLOCK);
reconciler.setRepairer(dr, MakePartitionScanner.MAKE_INCLUDE_BLOCK);
reconciler.setDamager(dr, MakefilePartitionScanner.MAKE_IF_BLOCK);
reconciler.setRepairer(dr, MakefilePartitionScanner.MAKE_IF_BLOCK);
dr = new DefaultDamagerRepairer(getCodeScanner());
reconciler.setDamager(dr, MakePartitionScanner.MAKE_IF_BLOCK);
reconciler.setRepairer(dr, MakePartitionScanner.MAKE_IF_BLOCK);
reconciler.setDamager(dr, MakefilePartitionScanner.MAKE_DEF_BLOCK);
reconciler.setRepairer(dr, MakefilePartitionScanner.MAKE_DEF_BLOCK);
dr = new DefaultDamagerRepairer(getCodeScanner());
reconciler.setDamager(dr, MakePartitionScanner.MAKE_DEF_BLOCK);
reconciler.setRepairer(dr, MakePartitionScanner.MAKE_DEF_BLOCK);
dr = new DefaultDamagerRepairer(getCodeScanner());
reconciler.setDamager(dr, MakePartitionScanner.MAKE_OTHER);
reconciler.setRepairer(dr, MakePartitionScanner.MAKE_OTHER);
reconciler.setDamager(dr, MakefilePartitionScanner.MAKE_OTHER);
reconciler.setRepairer(dr, MakefilePartitionScanner.MAKE_OTHER);
return reconciler;
}

View file

@ -10,42 +10,40 @@
***********************************************************************/
package org.eclipse.cdt.make.internal.ui.editor;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextEditorAction;
/**
*/
public class MakeEditorTogglePresentationAction extends TextEditorAction {
public class MakefileEditorTogglePresentationAction extends TextEditorAction {
private final static String ACTION_ID = "org.eclipse.cdt.make.ui.MakeEditorTogglePresentationAction"; //$NON-NLS-1$
private final static String ACTION_ID = "org.eclipse.cdt.make.ui.MakefileEditorTogglePresentationAction"; //$NON-NLS-1$
/**
* Constructor for MakeEditorTogglePresentationAction.
* Constructor for MakefileEditorTogglePresentationAction.
* @param bundle
* @param prefix
* @param editor
*/
public MakeEditorTogglePresentationAction() {
super(MakeUIPlugin.getDefault().getResourceBundle(), "MakeEditorTogglePresentationAction.", null); //$NON-NLS-1$
public MakefileEditorTogglePresentationAction() {
super(MakeUIPlugin.getDefault().getResourceBundle(), "MakefileEditorTogglePresentationAction.", null); //$NON-NLS-1$
setToolTipText("MakeEditorTogglePresentationAction.tooltip"); //$NON-NLS-1$
setToolTipText("MakefileEditorTogglePresentationAction.tooltip"); //$NON-NLS-1$
setActionDefinitionId(ACTION_ID);
MakeUIImages.setImageDescriptors(this, MakeUIImages.T_TOOL, MakeUIImages.IMG_TOOLS_MAKEFILE_SEGMENT_EDIT);
update();
}
/**
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
super.run();
ITextEditor editor = getTextEditor();
if (editor == null)
return;
if (!(editor instanceof MakeTextEditor))
return;
((MakeTextEditor) editor).setPresentationState(!((MakeTextEditor) editor).getPresentationState());
// update();
ITextEditor editor= getTextEditor();
editor.resetHighlightRange();
boolean show = editor.showsHighlightRangeOnly();
setChecked(!show);
editor.showHighlightRangeOnly(!show);
}
/**
@ -61,9 +59,6 @@ public class MakeEditorTogglePresentationAction extends TextEditorAction {
*/
public void setEditor(ITextEditor editor) {
super.setEditor(editor);
if (editor instanceof MakeTextEditor) {
((MakeTextEditor) editor).setPresentationState(isChecked());
}
update();
}

View file

@ -24,7 +24,7 @@ import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.rules.WhitespaceRule;
import org.eclipse.jface.text.rules.WordRule;
public class MakeMacroScanner extends RuleBasedScanner {
public class MakefileMacroScanner extends RuleBasedScanner {
private String buffer;
private final static String[] DELIMITERS = { "\r", "\n", "\r\n" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@ -33,9 +33,9 @@ public class MakeMacroScanner extends RuleBasedScanner {
public final static String tokenOther = "other"; //$NON-NLS-1$
/**
* Constructor for MakeMacroScanner
* Constructor for MakefileMacroScanner
*/
public MakeMacroScanner(String buffer) {
public MakefileMacroScanner(String buffer) {
super();
this.buffer = buffer;
fOffset = 0;
@ -49,7 +49,7 @@ public class MakeMacroScanner extends RuleBasedScanner {
rules.add(new PatternRule("\"", "\"", tText, '\\', true)); //$NON-NLS-1$ //$NON-NLS-2$
rules.add(new PatternRule("\'", "\'", tText, '\\', true)); //$NON-NLS-1$ //$NON-NLS-2$
rules.add(new MakeSimpleMacroRule(tMacro));
rules.add(new MakefileSimpleMacroRule(tMacro));
// Add generic whitespace rule.
rules.add(new WhitespaceRule(new IWhitespaceDetector() {

View file

@ -21,19 +21,17 @@ import org.eclipse.jface.text.rules.MultiLineRule;
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
import org.eclipse.jface.text.rules.Token;
public class MakePartitionScanner extends RuleBasedPartitionScanner {
public class MakefilePartitionScanner extends RuleBasedPartitionScanner {
// Partition types
public final static String MAKE_INTERNAL = "make_internal"; //$NON-NLS-1$
public final static String MAKE_COMMENT = "make_comment"; //$NON-NLS-1$
public final static String MAKE_MACRO_ASSIGNEMENT = "make_macro_assig"; //$NON-NLS-1$
public final static String MAKE_INCLUDE_BLOCK = "make_include_block"; //$NON-NLS-1$
public final static String MAKE_IF_BLOCK = "make_if_block"; //$NON-NLS-1$
public final static String MAKE_DEF_BLOCK = "make_def_block"; //$NON-NLS-1$
public final static String MAKE_OTHER = "make_other"; //$NON-NLS-1$
public final static String MAKE_COMMENT = "makefile_comment"; //$NON-NLS-1$
public final static String MAKE_MACRO_ASSIGNEMENT = "makefile_macro_assignement"; //$NON-NLS-1$
public final static String MAKE_INCLUDE_BLOCK = "makefile_include_block"; //$NON-NLS-1$
public final static String MAKE_IF_BLOCK = "makefile_if_block"; //$NON-NLS-1$
public final static String MAKE_DEF_BLOCK = "makefile_def_block"; //$NON-NLS-1$
public final static String MAKE_OTHER = "makefile_other"; //$NON-NLS-1$
public final static String[] TYPES =
new String[] {
MAKE_INTERNAL,
MAKE_COMMENT,
MAKE_MACRO_ASSIGNEMENT,
MAKE_INCLUDE_BLOCK,
@ -50,12 +48,11 @@ public class MakePartitionScanner extends RuleBasedPartitionScanner {
};
/**
* Constructor for MakePartitionScanner
* Constructor for MakefilePartitionScanner
*/
public MakePartitionScanner() {
public MakefilePartitionScanner() {
super();
// IToken tInternal = new Token(MAKE_INTERNAL);
IToken tComment = new Token(MAKE_COMMENT);
IToken tMacro = new Token(MAKE_MACRO_ASSIGNEMENT);
IToken tInclude = new Token(MAKE_INCLUDE_BLOCK);
@ -66,19 +63,18 @@ public class MakePartitionScanner extends RuleBasedPartitionScanner {
List rules = new ArrayList();
// Add rule for single line comments.
//rules.add(new MultiLineRule("#QNX internal start", "#QNX internal end", tInternal)); //$NON-NLS-1$ //$NON-NLS-2$
rules.add(new EndOfLineRule("#", tComment)); //$NON-NLS-1$
rules.add(new EndOfLineRule("include", tInclude)); //$NON-NLS-1$
// Add rules for multi-line comments and javadoc.
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$
rules.add(new MultiLineRule("ifdef", "endif", tIf)); //$NON-NLS-1$
rules.add(new MultiLineRule("ifndef", "endif", tIf)); //$NON-NLS-1$
rules.add(new MultiLineRule("ifeq", "endif", tIf)); //$NON-NLS-1$
rules.add(new MultiLineRule("ifnneq", "endif", tIf)); //$NON-NLS-1$
rules.add(new MultiLineRule("define", "endef", tDef)); //$NON-NLS-1$ //$NON-NLS-2$
rules.add(new MultiLineRule("define", "endef", tDef)); //$NON-NLS-1$
// Last rule must be supplied with default token!
rules.add(new MacroRule(tMacro, tOther)); //$NON-NLS-1$

View file

@ -14,11 +14,11 @@ import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.PatternRule;
public class MakeSimpleMacroRule extends PatternRule {
public class MakefileSimpleMacroRule extends PatternRule {
private int nOfBrackets;
public MakeSimpleMacroRule(IToken token) {
public MakefileSimpleMacroRule(IToken token) {
super("$(", ")", token, (char) 0, true); //$NON-NLS-1$ //$NON-NLS-2$
}

View file

@ -12,7 +12,7 @@ package org.eclipse.cdt.make.internal.ui.editor;
import org.eclipse.jface.text.rules.IWordDetector;
public class MakeWordDetector implements IWordDetector {
public class MakefileWordDetector implements IWordDetector {
private static final String correctStartSpecChars = "%*().><"; //$NON-NLS-1$
private static final String correctSpecChars = "@$/\\"; //$NON-NLS-1$