mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Do the working copy.
This commit is contained in:
parent
37149bf71f
commit
644a631ca0
4 changed files with 134 additions and 8 deletions
|
@ -116,7 +116,11 @@ public class MakefileContentOutlinePage extends ContentOutlinePage implements IC
|
|||
} else if (inputElement instanceof IRule) {
|
||||
directives = ((IRule)inputElement).getCommands();
|
||||
} else if (inputElement instanceof IParent) {
|
||||
directives = ((IParent)inputElement).getDirectives();
|
||||
if (inputElement instanceof IInclude && !showIncludeChildren) {
|
||||
directives = new IDirective[0];
|
||||
} else {
|
||||
directives = ((IParent)inputElement).getDirectives();
|
||||
}
|
||||
} else {
|
||||
directives = new IDirective[0];
|
||||
}
|
||||
|
@ -277,15 +281,21 @@ public class MakefileContentOutlinePage extends ContentOutlinePage implements IC
|
|||
* Updates the outline page.
|
||||
*/
|
||||
public void update() {
|
||||
TreeViewer viewer = getTreeViewer();
|
||||
final TreeViewer viewer = getTreeViewer();
|
||||
|
||||
if (viewer != null) {
|
||||
Control control = viewer.getControl();
|
||||
final Control control = viewer.getControl();
|
||||
if (control != null && !control.isDisposed()) {
|
||||
control.setRedraw(false);
|
||||
viewer.setInput(fInput);
|
||||
//viewer.expandAll();
|
||||
control.setRedraw(true);
|
||||
control.getDisplay().asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
if (!control.isDisposed()) {
|
||||
control.setRedraw(false);
|
||||
viewer.setInput(fInput);
|
||||
viewer.expandAll();
|
||||
control.setRedraw(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe
|
|||
protected MakefileContentOutlinePage page;
|
||||
private IMakefile makefile;
|
||||
|
||||
private MakefileContentOutlinePage getOutlinePage() {
|
||||
public MakefileContentOutlinePage getOutlinePage() {
|
||||
if (page == null) {
|
||||
page = new MakefileContentOutlinePage(this);
|
||||
page.addSelectionChangedListener(this);
|
||||
|
|
|
@ -15,12 +15,16 @@ import org.eclipse.cdt.make.internal.ui.text.MakefileColorManager;
|
|||
import org.eclipse.cdt.make.internal.ui.text.makefile.MakefileCodeScanner;
|
||||
import org.eclipse.cdt.make.internal.ui.text.makefile.MakefileCompletionProcessor;
|
||||
import org.eclipse.cdt.make.internal.ui.text.makefile.MakefilePartitionScanner;
|
||||
import org.eclipse.cdt.make.internal.ui.text.makefile.MakefileReconcilingStrategy;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.TextAttribute;
|
||||
import org.eclipse.jface.text.contentassist.ContentAssistant;
|
||||
import org.eclipse.jface.text.contentassist.IContentAssistant;
|
||||
import org.eclipse.jface.text.presentation.IPresentationReconciler;
|
||||
import org.eclipse.jface.text.presentation.PresentationReconciler;
|
||||
import org.eclipse.jface.text.reconciler.IReconciler;
|
||||
import org.eclipse.jface.text.reconciler.MonoReconciler;
|
||||
import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
|
||||
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
|
||||
import org.eclipse.jface.text.rules.Token;
|
||||
|
@ -138,6 +142,19 @@ public class MakefileSourceConfiguration extends SourceViewerConfiguration {
|
|||
return reconciler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SourceViewerConfiguration#getReconciler(ISourceViewer)
|
||||
*/
|
||||
public IReconciler getReconciler(ISourceViewer sourceViewer) {
|
||||
if (fEditor != null && fEditor.isEditable()) {
|
||||
MonoReconciler reconciler= new MonoReconciler(new MakefileReconcilingStrategy(fEditor), false);
|
||||
reconciler.setDelay(1000);
|
||||
reconciler.setProgressMonitor(new NullProgressMonitor());
|
||||
return reconciler;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getDefaultPrefixes(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
/**********************************************************************
|
||||
* 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.text.makefile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
|
||||
import org.eclipse.cdt.make.core.makefile.IMakefile;
|
||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||
import org.eclipse.cdt.make.internal.ui.editor.MakefileContentOutlinePage;
|
||||
import org.eclipse.cdt.make.internal.ui.editor.MakefileEditor;
|
||||
import org.eclipse.cdt.make.ui.IWorkingCopyManager;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
import org.eclipse.jface.text.reconciler.DirtyRegion;
|
||||
import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
|
||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
|
||||
|
||||
public class MakefileReconcilingStrategy implements IReconcilingStrategy {
|
||||
|
||||
|
||||
private int fLastRegionOffset;
|
||||
private ITextEditor fEditor;
|
||||
private IWorkingCopyManager fManager;
|
||||
private IDocumentProvider fDocumentProvider;
|
||||
private IProgressMonitor fProgressMonitor;
|
||||
|
||||
private MakefileContentOutlinePage fOutliner;
|
||||
|
||||
public MakefileReconcilingStrategy(MakefileEditor editor) {
|
||||
fOutliner= editor.getOutlinePage();
|
||||
fLastRegionOffset = Integer.MAX_VALUE;
|
||||
fEditor= editor;
|
||||
fManager= MakeUIPlugin.getDefault().getWorkingCopyManager();
|
||||
fDocumentProvider= MakeUIPlugin.getDefault().getMakefileDocumentProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IReconcilingStrategy#reconcile(document)
|
||||
*/
|
||||
public void setDocument(IDocument document) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see IReconcilingStrategyExtension#setProgressMonitor(IProgressMonitor)
|
||||
*/
|
||||
public void setProgressMonitor(IProgressMonitor monitor) {
|
||||
fProgressMonitor= monitor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IReconcilingStrategy#reconcile(region)
|
||||
*/
|
||||
public void reconcile(IRegion region) {
|
||||
// We use a trick to avoid running the reconciler multiple times
|
||||
// on a file when it gets changed. This is because this gets called
|
||||
// multiple times with different regions of the file, we do a
|
||||
// complete parse on the first region.
|
||||
if(region.getOffset() <= fLastRegionOffset) {
|
||||
reconcile();
|
||||
}
|
||||
fLastRegionOffset = region.getOffset();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see IReconcilingStrategy#reconcile(dirtyRegion, region)
|
||||
*/
|
||||
public void reconcile(DirtyRegion dirtyRegion, IRegion region) {
|
||||
// FIXME: This seems to generate to much flashing in
|
||||
// the contentouline viewer.
|
||||
//reconcile();
|
||||
}
|
||||
|
||||
private void reconcile() {
|
||||
IMakefile makefile = fManager.getWorkingCopy(fEditor.getEditorInput());
|
||||
String content = fDocumentProvider.getDocument(fEditor.getEditorInput()).get();
|
||||
StringReader reader = new StringReader(content);
|
||||
try {
|
||||
makefile.parse(reader);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
|
||||
fOutliner.update();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue