mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Code cleanup
This commit is contained in:
parent
eceefeeea0
commit
9fb29e5239
20 changed files with 90 additions and 2114 deletions
|
@ -48,7 +48,8 @@ public class ReconcileWorkingCopyOperation extends CModelOperation {
|
|||
}
|
||||
|
||||
WorkingCopy workingCopy = getWorkingCopy();
|
||||
boolean wasConsistent = workingCopy.isConsistent();
|
||||
boolean wasOpen= workingCopy.isOpen();
|
||||
boolean wasConsistent = wasOpen && workingCopy.isConsistent();
|
||||
CElementDeltaBuilder deltaBuilder = null;
|
||||
|
||||
try {
|
||||
|
@ -63,7 +64,9 @@ public class ReconcileWorkingCopyOperation extends CModelOperation {
|
|||
|
||||
// register the deltas
|
||||
if (deltaBuilder.delta != null) {
|
||||
addReconcileDelta(workingCopy, deltaBuilder.delta);
|
||||
if (!wasOpen || deltaBuilder.delta.getAffectedChildren().length > 0) {
|
||||
addReconcileDelta(workingCopy, deltaBuilder.delta);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,33 +1,42 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 IBM Corporation 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.tests.DOMAST;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
||||
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.text.TextSelection;
|
||||
import org.eclipse.jface.viewers.IContentProvider;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.ui.IEditorActionDelegate;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IPathEditorInput;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.actions.ActionDelegate;
|
||||
import org.eclipse.ui.editors.text.ILocationProvider;
|
||||
import org.eclipse.ui.ide.ResourceUtil;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
|
||||
/**
|
||||
* @author dsteffle
|
||||
|
@ -73,13 +82,7 @@ public class ShowInDOMViewAction extends ActionDelegate implements
|
|||
}
|
||||
|
||||
private boolean isFileInView() {
|
||||
if( editor.getInputFile() != null )
|
||||
file = editor.getInputFile().getLocation().toOSString();
|
||||
else
|
||||
{
|
||||
if( editor.getEditorInput() instanceof ExternalEditorInput )
|
||||
file = ((ExternalEditorInput)editor.getEditorInput()).getStorage().getFullPath().toOSString();
|
||||
}
|
||||
file= getInputFile(editor);
|
||||
|
||||
if (file == null) return false;
|
||||
|
||||
|
@ -122,6 +125,36 @@ public class ShowInDOMViewAction extends ActionDelegate implements
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the absolute file system location of the file open in the given editor.
|
||||
* @param editor
|
||||
* @return the absolute file system location or <code>null</code>
|
||||
*/
|
||||
private String getInputFile(ITextEditor editor) {
|
||||
IEditorInput input= editor.getEditorInput();
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
IFile file= ResourceUtil.getFile(input);
|
||||
if (file != null) {
|
||||
return file.getLocation().toOSString();
|
||||
}
|
||||
if (input instanceof IPathEditorInput) {
|
||||
IPath location= ((IPathEditorInput)input).getPath();
|
||||
if (location != null) {
|
||||
return location.toOSString();
|
||||
}
|
||||
}
|
||||
ILocationProvider locationProvider= (ILocationProvider)input.getAdapter(ILocationProvider.class);
|
||||
if (locationProvider != null) {
|
||||
IPath location= locationProvider.getPath(input);
|
||||
if (location != null) {
|
||||
return location.toOSString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private class FindDisplayNode implements Runnable {
|
||||
private static final String IAST_NODE_NOT_FOUND = "IASTNode not found for the selection. "; //$NON-NLS-1$
|
||||
private static final String IASTNode_NOT_FOUND = IAST_NODE_NOT_FOUND;
|
||||
|
@ -141,13 +174,7 @@ public class ShowInDOMViewAction extends ActionDelegate implements
|
|||
IContentProvider provider = ((DOMAST)view).getContentProvider();
|
||||
if (provider != null && provider instanceof DOMAST.ViewContentProvider) {
|
||||
tu = ((DOMAST.ViewContentProvider)provider).getTU();
|
||||
if( editor.getInputFile() != null )
|
||||
file = editor.getInputFile().getLocation().toOSString();
|
||||
else
|
||||
{
|
||||
if( editor.getEditorInput() instanceof ExternalEditorInput )
|
||||
file = ((ExternalEditorInput)editor.getEditorInput()).getStorage().getFullPath().toOSString();
|
||||
}
|
||||
file = getInputFile(editor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.ui.IWorkbenchPartReference;
|
|||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import org.eclipse.cdt.core.IPositionConverter;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
@ -320,7 +319,7 @@ public final class ASTProvider {
|
|||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled()
|
||||
*/
|
||||
void reconciled(IASTTranslationUnit ast, IPositionConverter converter, ICElement cElement, IProgressMonitor progressMonitor) {
|
||||
void reconciled(IASTTranslationUnit ast, ICElement cElement, IProgressMonitor progressMonitor) {
|
||||
if (cElement == null)
|
||||
return;
|
||||
Assert.isTrue(cElement instanceof ITranslationUnit);
|
||||
|
|
|
@ -290,8 +290,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
|
||||
String markerType= MarkerUtilities.getMarkerType(marker);
|
||||
if (markerType != null && markerType.startsWith(CMarkerAnnotation.C_MARKER_TYPE_PREFIX)) {
|
||||
// TODO: Fix this we need the document
|
||||
return new CMarkerAnnotation(marker, null);
|
||||
return new CMarkerAnnotation(marker);
|
||||
}
|
||||
return super.createMarkerAnnotation(marker);
|
||||
}
|
||||
|
|
|
@ -137,7 +137,6 @@ import com.ibm.icu.text.BreakIterator;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CCorePreferenceConstants;
|
||||
import org.eclipse.cdt.core.IPositionConverter;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
||||
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
|
||||
|
@ -1099,12 +1098,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
*/
|
||||
private ListenerList fReconcilingListeners= new ListenerList(ListenerList.IDENTITY);
|
||||
|
||||
/**
|
||||
* Flag indicating whether the reconciler is currently running.
|
||||
* @since 4.0
|
||||
*/
|
||||
private volatile boolean fIsReconciling;
|
||||
|
||||
/**
|
||||
* Semantic highlighting manager
|
||||
* @since 4.0
|
||||
|
@ -1209,24 +1202,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(getEditorInput());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current IFile input.
|
||||
* This method will be remove after cdt-3.0.
|
||||
* We can not guaranty that the input is an IFile, it may
|
||||
* an external file. Clients should test for <code>null<code> or use getInputCElement()
|
||||
* @deprecated use <code>CEditor.getInputCElement()</code>.
|
||||
* @return IFile Input file or null if input is not and IFileEditorInput.
|
||||
*/
|
||||
public IFile getInputFile() {
|
||||
IEditorInput editorInput = getEditorInput();
|
||||
if (editorInput != null) {
|
||||
if ((editorInput instanceof IFileEditorInput)) {
|
||||
return ((IFileEditorInput) editorInput).getFile();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
|
||||
*/
|
||||
|
@ -1534,7 +1509,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
* @since 4.0
|
||||
*/
|
||||
protected void synchronizeOutlinePage() {
|
||||
if(fOutlinePage != null && fOutlinePage.isLinkingEnabled() && !fIsReconciling) {
|
||||
if(fOutlinePage != null && fOutlinePage.isLinkingEnabled()) {
|
||||
fOutlinePage.removeSelectionChangedListener(this);
|
||||
fOutlinePage.synchronizeSelectionWithEditor();
|
||||
fOutlinePage.addSelectionChangedListener(this);
|
||||
|
@ -1938,6 +1913,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
menu.add(new GroupMarker(ICommonMenuConstants.GROUP_TOP));
|
||||
// separator for debug related actions (similar to ruler context menu)
|
||||
menu.add(new Separator(IContextMenuConstants.GROUP_DEBUG));
|
||||
menu.add(new Separator(IContextMenuConstants.GROUP_DEBUG+".end")); //$NON-NLS-1$
|
||||
|
||||
super.editorContextMenuAboutToShow(menu);
|
||||
|
||||
|
@ -2524,8 +2500,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
* @since 4.0
|
||||
*/
|
||||
public void aboutToBeReconciled() {
|
||||
fIsReconciling= true;
|
||||
|
||||
// Notify AST provider
|
||||
CUIPlugin.getDefault().getASTProvider().aboutToBeReconciled(getInputCElement());
|
||||
|
||||
|
@ -2537,23 +2511,21 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, IPositionConverter, IProgressMonitor)
|
||||
* @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, boolean, IProgressMonitor)
|
||||
* @since 4.0
|
||||
*/
|
||||
public void reconciled(IASTTranslationUnit ast, IPositionConverter positionTracker, IProgressMonitor progressMonitor) {
|
||||
fIsReconciling= false;
|
||||
|
||||
public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
|
||||
CUIPlugin cuiPlugin= CUIPlugin.getDefault();
|
||||
if (cuiPlugin == null)
|
||||
return;
|
||||
|
||||
// Always notify AST provider
|
||||
cuiPlugin.getASTProvider().reconciled(ast, positionTracker, getInputCElement(), progressMonitor);
|
||||
cuiPlugin.getASTProvider().reconciled(ast, getInputCElement(), progressMonitor);
|
||||
|
||||
// Notify listeners
|
||||
Object[] listeners = fReconcilingListeners.getListeners();
|
||||
for (int i = 0, length= listeners.length; i < length; ++i) {
|
||||
((ICReconcilingListener)listeners[i]).reconciled(ast, positionTracker, progressMonitor);
|
||||
((ICReconcilingListener)listeners[i]).reconciled(ast, force, progressMonitor);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 IBM Corporation 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
|
||||
|
@ -15,7 +15,6 @@ package org.eclipse.cdt.internal.ui.editor;
|
|||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.ui.texteditor.MarkerAnnotation;
|
||||
import org.eclipse.ui.texteditor.MarkerUtilities;
|
||||
|
||||
|
@ -37,7 +36,7 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
|
|||
|
||||
private ICAnnotation fOverlay;
|
||||
|
||||
public CMarkerAnnotation(IMarker marker, IDocument document) {
|
||||
public CMarkerAnnotation(IMarker marker) {
|
||||
super(marker);
|
||||
fIsProblemMarker = MarkerUtilities.isMarkerType(getMarker(), ICModelMarker.C_MODEL_PROBLEM_MARKER);
|
||||
}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2007 IBM Corporation 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Interface of an object participating in reconciling.
|
||||
* @deprecated in favour of {@link org.eclipse.cdt.internal.ui.text.ICReconcilingListener}
|
||||
*/
|
||||
public interface IReconcilingParticipant {
|
||||
|
||||
/**
|
||||
* Called after reconciling has been finished.
|
||||
*/
|
||||
void reconciled(boolean SomethingHasChanged);
|
||||
}
|
|
@ -26,11 +26,9 @@ import org.eclipse.jface.text.BadLocationException;
|
|||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
import org.eclipse.jface.text.ITextInputListener;
|
||||
import org.eclipse.jface.text.Region;
|
||||
import org.eclipse.jface.text.TypedPosition;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import org.eclipse.cdt.core.IPositionConverter;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElseStatement;
|
||||
|
@ -109,7 +107,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
|
|||
final ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
|
||||
result= astProvider.runOnAST(fTranslationUnit, ASTProvider.WAIT_YES, monitor, new ASTCache.ASTRunnable() {
|
||||
public IStatus runOnAST(IASTTranslationUnit ast) {
|
||||
reconciled(ast, null, monitor);
|
||||
reconciled(ast, true, monitor);
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
});
|
||||
|
@ -189,13 +187,13 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
|
|||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, IPositionConverter, IProgressMonitor)
|
||||
* @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, boolean, IProgressMonitor)
|
||||
*/
|
||||
public void reconciled(IASTTranslationUnit ast, final IPositionConverter positionTracker, IProgressMonitor progressMonitor) {
|
||||
public void reconciled(IASTTranslationUnit ast, final boolean force, IProgressMonitor progressMonitor) {
|
||||
if (progressMonitor != null && progressMonitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
final List newInactiveCodePositions= collectInactiveCodePositions(ast, positionTracker);
|
||||
final List newInactiveCodePositions= collectInactiveCodePositions(ast);
|
||||
Runnable updater = new Runnable() {
|
||||
public void run() {
|
||||
if (fEditor != null && fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
|
||||
|
@ -214,10 +212,9 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
|
|||
* in the given translation unit.
|
||||
*
|
||||
* @param translationUnit the {@link IASTTranslationUnit}, may be <code>null</code>
|
||||
* @param positionTracker map historic positions to actual
|
||||
* @return a {@link List} of {@link IRegion}s
|
||||
*/
|
||||
private List collectInactiveCodePositions(IASTTranslationUnit translationUnit, IPositionConverter positionTracker) {
|
||||
private List collectInactiveCodePositions(IASTTranslationUnit translationUnit) {
|
||||
if (translationUnit == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
@ -277,7 +274,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
|
|||
inInactiveCode = true;
|
||||
} else if (elseStmt.taken() && inInactiveCode) {
|
||||
int inactiveCodeEnd = stmtLocation.getNodeOffset();
|
||||
positions.add(createHighlightPosition(inactiveCodeStart, inactiveCodeEnd, positionTracker, false, fHighlightKey));
|
||||
positions.add(createHighlightPosition(inactiveCodeStart, inactiveCodeEnd, false, fHighlightKey));
|
||||
inInactiveCode = false;
|
||||
}
|
||||
} else if (statement instanceof IASTPreprocessorElifStatement) {
|
||||
|
@ -287,7 +284,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
|
|||
inInactiveCode = true;
|
||||
} else if (elifStmt.taken() && inInactiveCode) {
|
||||
int inactiveCodeEnd = stmtLocation.getNodeOffset();
|
||||
positions.add(createHighlightPosition(inactiveCodeStart, inactiveCodeEnd, positionTracker, false, fHighlightKey));
|
||||
positions.add(createHighlightPosition(inactiveCodeStart, inactiveCodeEnd, false, fHighlightKey));
|
||||
inInactiveCode = false;
|
||||
}
|
||||
} else if (statement instanceof IASTPreprocessorEndifStatement) {
|
||||
|
@ -295,7 +292,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
|
|||
boolean wasInInactiveCode = ((Boolean)inactiveCodeStack.pop()).booleanValue();
|
||||
if (inInactiveCode && !wasInInactiveCode) {
|
||||
int inactiveCodeEnd = stmtLocation.getNodeOffset() + stmtLocation.getNodeLength();
|
||||
positions.add(createHighlightPosition(inactiveCodeStart, inactiveCodeEnd, positionTracker, true, fHighlightKey));
|
||||
positions.add(createHighlightPosition(inactiveCodeStart, inactiveCodeEnd, true, fHighlightKey));
|
||||
}
|
||||
inInactiveCode = wasInInactiveCode;
|
||||
}
|
||||
|
@ -315,17 +312,11 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
|
|||
*
|
||||
* @param startOffset the start offset of the region to align
|
||||
* @param endOffset the (exclusive) end offset of the region to align
|
||||
* @param positionTracker map historic position to actual
|
||||
* @param inclusive whether the last line should be included or not
|
||||
* @param key the highlight key
|
||||
* @return a position aligned for background highlighting
|
||||
*/
|
||||
private HighlightPosition createHighlightPosition(int startOffset, int endOffset, IPositionConverter positionTracker, boolean inclusive, String key) {
|
||||
if (positionTracker != null) {
|
||||
IRegion original= positionTracker.historicToActual(new Region(startOffset, endOffset - startOffset));
|
||||
startOffset= original.getOffset();
|
||||
endOffset= startOffset + original.getLength();
|
||||
}
|
||||
private HighlightPosition createHighlightPosition(int startOffset, int endOffset, boolean inclusive, String key) {
|
||||
final IDocument document= fDocument;
|
||||
try {
|
||||
if (document != null) {
|
||||
|
|
|
@ -22,16 +22,13 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
import org.eclipse.jface.text.Position;
|
||||
import org.eclipse.jface.text.Region;
|
||||
import org.eclipse.jface.text.TextPresentation;
|
||||
import org.eclipse.jface.text.source.ISourceViewer;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkbenchPartSite;
|
||||
|
||||
import org.eclipse.cdt.core.IPositionConverter;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
|
@ -82,16 +79,13 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
/** The semantic token */
|
||||
private SemanticToken fToken= new SemanticToken();
|
||||
private String fFilePath;
|
||||
private IPositionConverter fPositionTracker;
|
||||
private int fMinLocation;
|
||||
|
||||
/**
|
||||
* @param filePath
|
||||
* @param positionTracker
|
||||
*/
|
||||
public PositionCollector(String filePath, IPositionConverter positionTracker) {
|
||||
public PositionCollector(String filePath) {
|
||||
fFilePath= filePath;
|
||||
fPositionTracker= positionTracker;
|
||||
fMinLocation= -1;
|
||||
}
|
||||
|
||||
|
@ -267,11 +261,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
}
|
||||
int offset= nodeLocation.getNodeOffset();
|
||||
int length= nodeLocation.getNodeLength();
|
||||
if (fPositionTracker != null) {
|
||||
IRegion actualPos= fPositionTracker.historicToActual(new Region(offset, length));
|
||||
offset= actualPos.getOffset();
|
||||
length= actualPos.getLength();
|
||||
}
|
||||
if (offset > -1 && length > 0) {
|
||||
addPosition(offset, length, highlighting);
|
||||
}
|
||||
|
@ -290,11 +279,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
}
|
||||
int offset= macroUseLocation.getNodeOffset();
|
||||
int length= macroLength;
|
||||
if (fPositionTracker != null) {
|
||||
IRegion actualPos= fPositionTracker.historicToActual(new Region(offset, length));
|
||||
offset= actualPos.getOffset();
|
||||
length= actualPos.getLength();
|
||||
}
|
||||
if (offset > -1 && length > 0) {
|
||||
addPosition(offset, length, highlighting);
|
||||
}
|
||||
|
@ -387,9 +371,9 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, IPositionConverter, IProgressMonitor)
|
||||
* @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, boolean, IProgressMonitor)
|
||||
*/
|
||||
public void reconciled(IASTTranslationUnit ast, IPositionConverter positionTracker, IProgressMonitor progressMonitor) {
|
||||
public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
|
||||
// ensure at most one thread can be reconciling at any time
|
||||
synchronized (fReconcileLock) {
|
||||
if (fIsReconciling)
|
||||
|
@ -410,7 +394,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
if (ast == null || fJobPresenter.isCanceled())
|
||||
return;
|
||||
|
||||
PositionCollector collector= new PositionCollector(ast.getFilePath(), positionTracker);
|
||||
PositionCollector collector= new PositionCollector(ast.getFilePath());
|
||||
|
||||
startReconcilingPositions();
|
||||
|
||||
|
@ -576,7 +560,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
|
||||
IStatus status= astProvider.runOnAST(element, ASTProvider.WAIT_YES, monitor, new ASTCache.ASTRunnable() {
|
||||
public IStatus runOnAST(IASTTranslationUnit ast) {
|
||||
reconciled(ast, null, monitor);
|
||||
reconciled(ast, true, monitor);
|
||||
synchronized (fJobLock) {
|
||||
// allow the job to be gc'ed
|
||||
if (fJob == me)
|
||||
|
|
|
@ -119,9 +119,11 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
|
|||
if (workingCopy == null) {
|
||||
return;
|
||||
}
|
||||
boolean forced= false;
|
||||
try {
|
||||
// reconcile
|
||||
synchronized (workingCopy) {
|
||||
forced= workingCopy.isConsistent();
|
||||
ast= workingCopy.reconcile(computeAST, true, fProgressMonitor);
|
||||
}
|
||||
} catch(OperationCanceledException oce) {
|
||||
|
@ -136,7 +138,7 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
|
|||
index= ast.getIndex();
|
||||
}
|
||||
try {
|
||||
((ICReconcilingListener)fEditor).reconciled(ast, null, fProgressMonitor);
|
||||
((ICReconcilingListener)fEditor).reconciled(ast, forced, fProgressMonitor);
|
||||
} finally {
|
||||
if (index != null) {
|
||||
index.releaseReadLock();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2007 IBM Corporation 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,7 +13,6 @@ package org.eclipse.cdt.internal.ui.text;
|
|||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.eclipse.cdt.core.IPositionConverter;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
|
||||
|
||||
|
@ -35,13 +34,11 @@ public interface ICReconcilingListener {
|
|||
*
|
||||
* @param ast
|
||||
* the translation unit AST or <code>null</code> if the working
|
||||
* copy was consistent or reconciliation has been cancelled
|
||||
* @param positionTracker
|
||||
* the position tracker to map AST positions to current document
|
||||
* positions; may be <code>null</code> which means positions
|
||||
* can be considered up-to-date
|
||||
* copy was consistent or reconcilation has been cancelled
|
||||
* @param force
|
||||
* flag indicating whether the reconciler was invoked forcefully
|
||||
* @param progressMonitor
|
||||
* the progress monitor
|
||||
*/
|
||||
void reconciled(IASTTranslationUnit ast, IPositionConverter positionTracker, IProgressMonitor progressMonitor);
|
||||
void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,148 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
|
||||
public class CompletionRequestorAdaptor implements ICompletionRequestor {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptField(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void acceptField(String name, String returnType, ASTAccessVisibility visibility, int completionStart, int completionLength, int relevance) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptClass(java.lang.String)
|
||||
*/
|
||||
public void acceptClass(String name, int completionStart, int completionLength, int relevance) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptEnumeration(java.lang.String)
|
||||
*/
|
||||
public void acceptEnumeration(String name, int completionStart, int completionLength, int relevance) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptFunction(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void acceptFunction(
|
||||
String name,
|
||||
String parameterString,
|
||||
String returnType, int completionStart, int completionLength, int relevance, boolean insertFunctionName, int contextInfoOffset) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptMacro(java.lang.String)
|
||||
*/
|
||||
public void acceptMacro(String name, int completionStart, int completionLength, int relevance, int contextInfoOffset) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptMethod(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void acceptMethod(
|
||||
String name,
|
||||
String parameterString,
|
||||
String returnType, ASTAccessVisibility visibility, int completionStart, int completionLength, int relevance, boolean insertFunctionName, int contextInfoOffset) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptStruct(java.lang.String)
|
||||
*/
|
||||
public void acceptStruct(String name, int completionStart, int completionLength, int relevance) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptUnion(java.lang.String)
|
||||
*/
|
||||
public void acceptUnion(String name, int completionStart, int completionLength, int relevance) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptVariable(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void acceptVariable(String name, String returnType, int completionStart, int completionLength, int relevance) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptLocalVariable(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void acceptLocalVariable(String name, String returnType, int completionStart, int completionLength, int relevance) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptNamespace(java.lang.String)
|
||||
*/
|
||||
public void acceptNamespace(String name, int completionStart, int completionLength, int relevance) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptEnumerator(java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptEnumerator(
|
||||
String name,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptKeyword(java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptKeyword(
|
||||
String name,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptError(org.eclipse.cdt.core.parser.IProblem)
|
||||
*/
|
||||
public void acceptError(IProblem error) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.text.contentassist.ICompletionRequestor#acceptTypedef(java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptTypedef(String name, int completionStart,
|
||||
int completionLength, int relevance) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserTimeOut;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is the source element requestor used by the completion engine.
|
||||
*/
|
||||
public class ContentAssistElementRequestor extends NullSourceElementRequestor implements ITimeoutThreadOwner{
|
||||
// a static timer thread
|
||||
private static ParserTimeOut timeoutThread = new ParserTimeOut();
|
||||
private IProgressMonitor pm = new NullProgressMonitor();
|
||||
private IParser parser;
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#createReader(java.lang.String)
|
||||
*/
|
||||
public CodeReader createReader(String finalPath, Iterator workingCopies) {
|
||||
return ParserUtil.createReader(finalPath, workingCopies );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ContentAssistElementRequestor() {
|
||||
super();
|
||||
// set the timer thread to max priority for best performance
|
||||
timeoutThread.setThreadPriority(Thread.MAX_PRIORITY);
|
||||
}
|
||||
|
||||
|
||||
public void setParser( IParser parser )
|
||||
{
|
||||
this.parser = parser;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.text.contentassist.ITimeoutThreadOwner#setTimeout(int)
|
||||
*/
|
||||
public void setTimeout(int timeout) {
|
||||
timeoutThread.setTimeout(timeout);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.text.contentassist.ITimeoutThreadOwner#startTimer()
|
||||
*/
|
||||
public void startTimer() {
|
||||
createProgressMonitor(parser);
|
||||
timeoutThread.startTimer();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.text.contentassist.ITimeoutThreadOwner#stopTimer()
|
||||
*/
|
||||
public void stopTimer() {
|
||||
timeoutThread.stopTimer();
|
||||
pm.setCanceled(false);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#parserTimeout()
|
||||
*/
|
||||
public boolean parserTimeout() {
|
||||
if ((pm != null) && (pm.isCanceled()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* Creates a new progress monitor with each start timer
|
||||
*/
|
||||
private void createProgressMonitor(IParser parser) {
|
||||
pm.setCanceled(false);
|
||||
timeoutThread.setParser(parser);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
|
||||
public interface ICompletionRequestor {
|
||||
void acceptField(String name, String returnType, ASTAccessVisibility visibility, int completionStart, int completionLength, int relevance);
|
||||
void acceptVariable(String name, String returnType, int completionStart, int completionLength, int relevance);
|
||||
void acceptLocalVariable(String name, String returnType, int completionStart, int completionLength, int relevance);
|
||||
void acceptMethod(String name, String parameterString, String returnType, ASTAccessVisibility visibility, int completionStart, int completionLength, int relevance, boolean insertFunctionName, int contextInfoOffset);
|
||||
void acceptFunction(String name, String parameterString, String returnType, int completionStart, int completionLength, int relevance, boolean insertFunctionName, int contextInfoOffset);
|
||||
void acceptClass(String name, int completionStart, int completionLength, int relevance);
|
||||
void acceptStruct(String name, int completionStart, int completionLength, int relevance);
|
||||
void acceptUnion(String name, int completionStart, int completionLength, int relevance);
|
||||
void acceptTypedef(String name, int completionStart, int completionLength, int relevance);
|
||||
void acceptNamespace(String name, int completionStart, int completionLength, int relevance);
|
||||
void acceptMacro(String name, int completionStart, int completionLength, int relevance, int contextInfoOffset);
|
||||
void acceptEnumeration(String name, int completionStart, int completionLength, int relevance);
|
||||
void acceptEnumerator(String name, int completionStart, int completionLength, int relevance);
|
||||
void acceptKeyword(String name, int completionStart, int completionLength, int relevance);
|
||||
void acceptError(IProblem error);
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
public interface IProblem {
|
||||
String getMessage();
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
/**
|
||||
* @author hamer
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
public interface ITimeoutThreadOwner {
|
||||
/**
|
||||
* Sets the timeout limit for the timer
|
||||
* @param timeout
|
||||
*/
|
||||
public void setTimeout(int timeout);
|
||||
/**
|
||||
* Starts the timer
|
||||
*/
|
||||
public void startTimer();
|
||||
/**
|
||||
* Stops the timer
|
||||
*/
|
||||
public void stopTimer();
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
public class Problem implements IProblem {
|
||||
String message = null;
|
||||
Problem(String message){
|
||||
this.message = message;
|
||||
}
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.text.contentassist.IProblem#getMessage()
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
|
@ -1,600 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.FunctionPrototypeSummary;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.text.ITextViewer;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
/**
|
||||
*
|
||||
* The Result Collector class receives information from the completion engine
|
||||
* as a completion requestor. It might also receive information from others
|
||||
* such as the results of a search operation to generate completion proposals.
|
||||
*
|
||||
*/
|
||||
public class ResultCollector extends CompletionRequestorAdaptor {
|
||||
|
||||
private final static char[] METHOD_WITH_ARGUMENTS_TRIGGERS= new char[] { '(', '-', ' ' };
|
||||
private final static char[] METHOD_TRIGGERS= new char[] { ';', ',', '.', '\t', '[', ' ' };
|
||||
private final static char[] TYPE_TRIGGERS= new char[] { '.', '\t', '[', '(', ' ' };
|
||||
private final static char[] VAR_TRIGGERS= new char[] { '\t', ' ', '[', '(', '=', '-', ';', ',', '.' };
|
||||
|
||||
private final String DEFINE ="#define "; //$NON-NLS-1$
|
||||
|
||||
private Set completions = new HashSet();
|
||||
private ImageDescriptorRegistry registry = CUIPlugin.getImageDescriptorRegistry();
|
||||
private IProblem fLastProblem;
|
||||
private ITextViewer fTextViewer;
|
||||
|
||||
public ResultCollector(){
|
||||
completions.clear();
|
||||
fTextViewer = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the completion list
|
||||
*/
|
||||
public Set getCompletions() {
|
||||
return completions;
|
||||
}
|
||||
public void reset(ITextViewer viewer) {
|
||||
completions.clear();
|
||||
fTextViewer = viewer;
|
||||
fLastProblem = null;
|
||||
}
|
||||
/*
|
||||
* Create a proposal
|
||||
*/
|
||||
public CCompletionProposal createProposal(String replaceString, String displayString, String infoString, String arguments, int contextInfoOffset, Image image, int offset, int length, int relevance){
|
||||
CCompletionProposal proposal;
|
||||
|
||||
proposal = new CCompletionProposal(
|
||||
replaceString, // Replacement string
|
||||
offset,
|
||||
length,
|
||||
image,
|
||||
displayString, // Display string
|
||||
relevance,
|
||||
fTextViewer);
|
||||
|
||||
if(arguments != null && arguments.length() > 0) {
|
||||
CProposalContextInformation info = new CProposalContextInformation(replaceString, arguments);
|
||||
info.setContextInformationPosition(contextInfoOffset - 1);
|
||||
proposal.setContextInformation( info );
|
||||
}
|
||||
|
||||
// The info string could be populated with documentation info.
|
||||
// For now, it has the name and the parent's name if available.
|
||||
if((infoString != null)&& (!displayString.equals(infoString)))
|
||||
proposal.setAdditionalProposalInfo(infoString);
|
||||
|
||||
return proposal;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptField(java.lang.String, java.lang.String, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, int, int, int)
|
||||
*/
|
||||
public void acceptField(String name, String returnType, ASTAccessVisibility visibility,
|
||||
int completionStart, int completionLength, int relevance) {
|
||||
String replaceString = ""; //$NON-NLS-1$
|
||||
String displayString = ""; //$NON-NLS-1$
|
||||
Image image = null;
|
||||
StringBuffer infoString = new StringBuffer();
|
||||
|
||||
// fill the replace, display and info strings
|
||||
replaceString = name;
|
||||
displayString = name;
|
||||
if(returnType != null)
|
||||
displayString+= " : " + returnType; //$NON-NLS-1$
|
||||
|
||||
// get the image
|
||||
ImageDescriptor imageDescriptor = CElementImageProvider.getFieldImageDescriptor(visibility);
|
||||
image = registry.get( imageDescriptor );
|
||||
|
||||
// create proposal and add it to completions list
|
||||
CCompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
|
||||
null, 0, image, completionStart, completionLength, relevance);
|
||||
proposal.setTriggerCharacters(VAR_TRIGGERS);
|
||||
completions.add(proposal);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptClass(java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptClass(
|
||||
String name,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance) {
|
||||
String replaceString = ""; //$NON-NLS-1$
|
||||
String displayString = ""; //$NON-NLS-1$
|
||||
Image image = null;
|
||||
StringBuffer infoString = new StringBuffer();
|
||||
|
||||
// fill the replace, display and info strings
|
||||
replaceString = name;
|
||||
displayString = name;
|
||||
|
||||
// get the image
|
||||
ImageDescriptor imageDescriptor = CElementImageProvider.getClassImageDescriptor();
|
||||
image = registry.get( imageDescriptor );
|
||||
|
||||
// create proposal and add it to completions list
|
||||
CCompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
|
||||
null, 0, image, completionStart, completionLength, relevance);
|
||||
proposal.setTriggerCharacters(TYPE_TRIGGERS);
|
||||
completions.add(proposal);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptFunction(java.lang.String, java.lang.String, java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptFunction(
|
||||
String name,
|
||||
String parameterString,
|
||||
String returnType,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance, boolean insertFunctionName, int contextInfoOffset ) {
|
||||
String replaceString = ""; //$NON-NLS-1$
|
||||
String displayString = ""; //$NON-NLS-1$
|
||||
String arguments = ""; //$NON-NLS-1$
|
||||
|
||||
Image image = null;
|
||||
StringBuffer infoString = new StringBuffer();
|
||||
|
||||
// fill the replace, display and info strings
|
||||
replaceString = name;
|
||||
displayString = name;
|
||||
String functionPrototype = returnType + " " + name; //$NON-NLS-1$
|
||||
if(parameterString != null){
|
||||
if ((parameterString.indexOf("(") == -1) && (parameterString.indexOf(")") == -1)) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
{
|
||||
functionPrototype += "(" + parameterString + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
else {
|
||||
functionPrototype += parameterString;
|
||||
}
|
||||
}
|
||||
|
||||
FunctionPrototypeSummary fproto = new FunctionPrototypeSummary(functionPrototype);
|
||||
if(fproto != null) {
|
||||
replaceString = fproto.getName() + "()"; //$NON-NLS-1$
|
||||
displayString = fproto.getPrototypeString(true);
|
||||
infoString.append(displayString);
|
||||
arguments = fproto.getArguments();
|
||||
}
|
||||
|
||||
// get the image
|
||||
ImageDescriptor imageDescriptor = CElementImageProvider.getFunctionImageDescriptor();
|
||||
image = registry.get( imageDescriptor );
|
||||
|
||||
if( !insertFunctionName ){
|
||||
replaceString = ""; //$NON-NLS-1$
|
||||
}
|
||||
// create proposal and add it to completions list
|
||||
CCompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
|
||||
arguments, contextInfoOffset, image, completionStart, completionLength, relevance);
|
||||
|
||||
boolean userMustCompleteParameters= (arguments != null && arguments.length() > 0) && insertFunctionName;
|
||||
|
||||
char[] triggers= userMustCompleteParameters ? METHOD_WITH_ARGUMENTS_TRIGGERS : METHOD_TRIGGERS;
|
||||
proposal.setTriggerCharacters(triggers);
|
||||
|
||||
if (userMustCompleteParameters) {
|
||||
// set the cursor before the closing bracket
|
||||
proposal.setCursorPosition(replaceString.length() - 1);
|
||||
}
|
||||
|
||||
completions.add(proposal);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptLocalVariable(java.lang.String, java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptLocalVariable(
|
||||
String name,
|
||||
String returnType,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance) {
|
||||
|
||||
String replaceString = ""; //$NON-NLS-1$
|
||||
String displayString = ""; //$NON-NLS-1$
|
||||
Image image = null;
|
||||
StringBuffer infoString = new StringBuffer();
|
||||
|
||||
// fill the replace, display and info strings
|
||||
replaceString = name;
|
||||
displayString = name;
|
||||
if(returnType != null)
|
||||
displayString+= " : " + returnType; //$NON-NLS-1$
|
||||
|
||||
// get the image
|
||||
ImageDescriptor imageDescriptor = CElementImageProvider.getLocalVariableImageDescriptor();
|
||||
image = registry.get( imageDescriptor );
|
||||
|
||||
// create proposal and add it to completions list
|
||||
CCompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(), null, 0, image, completionStart, completionLength, relevance);
|
||||
proposal.setTriggerCharacters(VAR_TRIGGERS);
|
||||
completions.add(proposal);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptMacro(java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptMacro(
|
||||
String name,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance, int contextInfoOffset) {
|
||||
|
||||
String replaceString = ""; //$NON-NLS-1$
|
||||
String displayString = ""; //$NON-NLS-1$
|
||||
String arguments = ""; //$NON-NLS-1$
|
||||
Image image = null;
|
||||
StringBuffer infoString = new StringBuffer();
|
||||
String prototype = ""; //$NON-NLS-1$
|
||||
|
||||
// fill the replace, display and info strings
|
||||
int bracket = name.indexOf('{');
|
||||
if(name.startsWith(DEFINE)){
|
||||
prototype = name.substring(DEFINE.length(), bracket == -1? name.length() : bracket);
|
||||
}else {
|
||||
prototype = name;
|
||||
}
|
||||
int leftbracket = prototype.indexOf('(');
|
||||
int rightbracket = prototype.lastIndexOf(')');
|
||||
if(( leftbracket == -1 ) && (rightbracket == -1)) {
|
||||
replaceString = prototype;
|
||||
displayString = prototype;
|
||||
}else {
|
||||
FunctionPrototypeSummary fproto = new FunctionPrototypeSummary(prototype);
|
||||
if(fproto != null) {
|
||||
replaceString = fproto.getName() + "()"; //$NON-NLS-1$
|
||||
displayString = fproto.getPrototypeString(true, false);
|
||||
infoString.append(displayString);
|
||||
arguments = fproto.getArguments();
|
||||
} else {
|
||||
replaceString = prototype;
|
||||
displayString = prototype;
|
||||
}
|
||||
}
|
||||
// get the image
|
||||
ImageDescriptor imageDescriptor = CElementImageProvider.getMacroImageDescriptor();
|
||||
image = registry.get( imageDescriptor );
|
||||
|
||||
// create proposal and add it to completions list
|
||||
CCompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
|
||||
arguments, contextInfoOffset, image, completionStart, completionLength, relevance);
|
||||
|
||||
proposal.setTriggerCharacters(VAR_TRIGGERS);
|
||||
|
||||
boolean userMustCompleteParameters= (arguments != null && arguments.length() > 0);
|
||||
if (userMustCompleteParameters) {
|
||||
// set the cursor before the closing bracket
|
||||
proposal.setCursorPosition(replaceString.length() - 1);
|
||||
}
|
||||
|
||||
completions.add(proposal);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptMethod(java.lang.String, java.lang.String, java.lang.String, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, int, int, int)
|
||||
*/
|
||||
public void acceptMethod(
|
||||
String name,
|
||||
String parameterString,
|
||||
String returnType,
|
||||
ASTAccessVisibility visibility,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance, boolean insertFunctionName, int contextInfoOffset) {
|
||||
|
||||
String replaceString = ""; //$NON-NLS-1$
|
||||
String displayString = ""; //$NON-NLS-1$
|
||||
String arguments = ""; //$NON-NLS-1$
|
||||
Image image = null;
|
||||
StringBuffer infoString = new StringBuffer();
|
||||
|
||||
// fill the replace, display and info strings
|
||||
replaceString = name;
|
||||
displayString = name;
|
||||
String functionPrototype = returnType + " " + name; //$NON-NLS-1$
|
||||
if(parameterString != null){
|
||||
if ((parameterString.indexOf("(") == -1) && (parameterString.indexOf(")") == -1)) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
{
|
||||
functionPrototype += "(" + parameterString + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
else {
|
||||
functionPrototype += parameterString;
|
||||
}
|
||||
}
|
||||
|
||||
FunctionPrototypeSummary fproto = new FunctionPrototypeSummary(functionPrototype);
|
||||
if(fproto != null) {
|
||||
replaceString = fproto.getName() + "()"; //$NON-NLS-1$
|
||||
displayString = fproto.getPrototypeString(true);
|
||||
infoString.append(displayString);
|
||||
arguments = fproto.getArguments();
|
||||
}
|
||||
|
||||
// get the image
|
||||
ImageDescriptor imageDescriptor = CElementImageProvider.getMethodImageDescriptor(visibility);
|
||||
image = registry.get( imageDescriptor );
|
||||
|
||||
if( !insertFunctionName ){
|
||||
//completion only to display the infoString, don't actually insert text
|
||||
replaceString = ""; //$NON-NLS-1$
|
||||
}
|
||||
// create proposal and add it to completions list
|
||||
CCompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
|
||||
arguments, contextInfoOffset, image, completionStart, completionLength, relevance );
|
||||
|
||||
boolean userMustCompleteParameters= (arguments != null && arguments.length() > 0) && insertFunctionName;
|
||||
|
||||
char[] triggers= userMustCompleteParameters ? METHOD_WITH_ARGUMENTS_TRIGGERS : METHOD_TRIGGERS;
|
||||
proposal.setTriggerCharacters(triggers);
|
||||
|
||||
if (userMustCompleteParameters) {
|
||||
// set the cursor before the closing bracket
|
||||
proposal.setCursorPosition(replaceString.length() - 1);
|
||||
}
|
||||
|
||||
completions.add(proposal);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptNamespace(java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptNamespace(
|
||||
String name,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance) {
|
||||
String replaceString = ""; //$NON-NLS-1$
|
||||
String displayString = ""; //$NON-NLS-1$
|
||||
Image image = null;
|
||||
StringBuffer infoString = new StringBuffer();
|
||||
|
||||
// fill the replace, display and info strings
|
||||
replaceString = name;
|
||||
displayString = name;
|
||||
|
||||
// get the image
|
||||
ImageDescriptor imageDescriptor = CElementImageProvider.getNamespaceImageDescriptor();
|
||||
image = registry.get( imageDescriptor );
|
||||
|
||||
// create proposal and add it to completions list
|
||||
CCompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
|
||||
null, 0, image, completionStart, completionLength, relevance);
|
||||
proposal.setTriggerCharacters(TYPE_TRIGGERS);
|
||||
completions.add(proposal);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptStruct(java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptStruct(
|
||||
String name,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance) {
|
||||
String replaceString = ""; //$NON-NLS-1$
|
||||
String displayString = ""; //$NON-NLS-1$
|
||||
Image image = null;
|
||||
StringBuffer infoString = new StringBuffer();
|
||||
|
||||
// fill the replace, display and info strings
|
||||
replaceString = name;
|
||||
displayString = name;
|
||||
|
||||
// get the image
|
||||
ImageDescriptor imageDescriptor = CElementImageProvider.getStructImageDescriptor();
|
||||
image = registry.get( imageDescriptor );
|
||||
|
||||
// create proposal and add it to completions list
|
||||
CCompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(), null, 0, image, completionStart, completionLength, relevance);
|
||||
proposal.setTriggerCharacters(TYPE_TRIGGERS);
|
||||
completions.add(proposal);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptUnion(java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptUnion(
|
||||
String name,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance) {
|
||||
String replaceString = ""; //$NON-NLS-1$
|
||||
String displayString = ""; //$NON-NLS-1$
|
||||
Image image = null;
|
||||
StringBuffer infoString = new StringBuffer();
|
||||
|
||||
// fill the replace, display and info strings
|
||||
replaceString = name;
|
||||
displayString = name;
|
||||
|
||||
// get the image
|
||||
ImageDescriptor imageDescriptor = CElementImageProvider.getUnionImageDescriptor();
|
||||
image = registry.get( imageDescriptor );
|
||||
|
||||
// create proposal and add it to completions list
|
||||
CCompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(), null, 0, image, completionStart, completionLength, relevance);
|
||||
proposal.setTriggerCharacters(TYPE_TRIGGERS);
|
||||
completions.add(proposal);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptVariable(java.lang.String, java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptVariable(
|
||||
String name,
|
||||
String returnType,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance) {
|
||||
String replaceString = ""; //$NON-NLS-1$
|
||||
String displayString = ""; //$NON-NLS-1$
|
||||
Image image = null;
|
||||
StringBuffer infoString = new StringBuffer();
|
||||
|
||||
// fill the replace, display and info strings
|
||||
replaceString = name;
|
||||
displayString = name;
|
||||
if(returnType != null)
|
||||
displayString+= " : " + returnType; //$NON-NLS-1$
|
||||
|
||||
// get the image
|
||||
ImageDescriptor imageDescriptor = CElementImageProvider.getVariableImageDescriptor();
|
||||
image = registry.get( imageDescriptor );
|
||||
|
||||
// create proposal and add it to completions list
|
||||
CCompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(), null, 0, image, completionStart, completionLength, relevance);
|
||||
proposal.setTriggerCharacters(VAR_TRIGGERS);
|
||||
completions.add(proposal);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptEnumeration(java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptEnumeration(
|
||||
String name,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance) {
|
||||
String replaceString = ""; //$NON-NLS-1$
|
||||
String displayString = ""; //$NON-NLS-1$
|
||||
Image image = null;
|
||||
StringBuffer infoString = new StringBuffer();
|
||||
|
||||
// fill the replace, display and info strings
|
||||
replaceString = name;
|
||||
displayString = name;
|
||||
|
||||
// get the image
|
||||
ImageDescriptor imageDescriptor = CElementImageProvider.getEnumerationImageDescriptor();
|
||||
image = registry.get( imageDescriptor );
|
||||
|
||||
// create proposal and add it to completions list
|
||||
CCompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
|
||||
null, 0, image, completionStart, completionLength, relevance);
|
||||
proposal.setTriggerCharacters(TYPE_TRIGGERS);
|
||||
completions.add(proposal);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptEnumerator(java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptEnumerator(
|
||||
String name,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance) {
|
||||
String replaceString = ""; //$NON-NLS-1$
|
||||
String displayString = ""; //$NON-NLS-1$
|
||||
Image image = null;
|
||||
StringBuffer infoString = new StringBuffer();
|
||||
|
||||
// fill the replace, display and info strings
|
||||
replaceString = name;
|
||||
displayString = name;
|
||||
|
||||
// get the image
|
||||
ImageDescriptor imageDescriptor = CElementImageProvider.getEnumeratorImageDescriptor();
|
||||
image = registry.get( imageDescriptor );
|
||||
|
||||
// create proposal and add it to completions list
|
||||
CCompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
|
||||
null, 0, image, completionStart, completionLength, relevance);
|
||||
proposal.setTriggerCharacters(VAR_TRIGGERS);
|
||||
completions.add(proposal);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.text.contentassist.ICompletionRequestor#acceptTypedef(java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptTypedef(String name,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance) {
|
||||
String replaceString = ""; //$NON-NLS-1$
|
||||
String displayString = ""; //$NON-NLS-1$
|
||||
Image image = null;
|
||||
StringBuffer infoString = new StringBuffer();
|
||||
|
||||
// fill the replace, display and info strings
|
||||
replaceString = name;
|
||||
displayString = name;
|
||||
|
||||
// get the image
|
||||
ImageDescriptor imageDescriptor = CElementImageProvider.getTypedefImageDescriptor();
|
||||
image = registry.get( imageDescriptor );
|
||||
|
||||
// create proposal and add it to completions list
|
||||
CCompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
|
||||
null, 0, image, completionStart, completionLength, relevance);
|
||||
proposal.setTriggerCharacters(TYPE_TRIGGERS);
|
||||
completions.add(proposal);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptKeyword(java.lang.String, int, int, int)
|
||||
*/
|
||||
public void acceptKeyword(
|
||||
String name,
|
||||
int completionStart,
|
||||
int completionLength,
|
||||
int relevance) {
|
||||
String replaceString = ""; //$NON-NLS-1$
|
||||
String displayString = ""; //$NON-NLS-1$
|
||||
Image image = null;
|
||||
StringBuffer infoString = new StringBuffer();
|
||||
|
||||
// fill the replace, display and info strings
|
||||
replaceString = name;
|
||||
displayString = name;
|
||||
|
||||
ImageDescriptor imageDescriptor = CElementImageProvider.getKeywordImageDescriptor();
|
||||
image = registry.get( imageDescriptor );
|
||||
|
||||
// no image for keywords
|
||||
// create proposal and add it to completions list
|
||||
CCompletionProposal proposal = createProposal(replaceString, displayString, infoString.toString(),
|
||||
null, 0, image, completionStart, completionLength, relevance);
|
||||
proposal.setTriggerCharacters(VAR_TRIGGERS);
|
||||
completions.add(proposal);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.ICompletionRequestor#acceptError(org.eclipse.cdt.core.parser.IProblem)
|
||||
*/
|
||||
public void acceptError(IProblem error) {
|
||||
fLastProblem = error;
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
if (fLastProblem != null)
|
||||
return fLastProblem.getMessage();
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
|
@ -46,7 +46,6 @@ import org.eclipse.jface.text.source.projection.ProjectionViewer;
|
|||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
|
||||
import org.eclipse.cdt.core.IPositionConverter;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElseStatement;
|
||||
|
@ -99,9 +98,9 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
|||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit, org.eclipse.cdt.core.IPositionConverter, org.eclipse.core.runtime.IProgressMonitor)
|
||||
* @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, boolean, IProgressMonitor)
|
||||
*/
|
||||
public void reconciled(IASTTranslationUnit ast, IPositionConverter positionTracker, IProgressMonitor progressMonitor) {
|
||||
public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
|
||||
if (fInput == null || fReconciling) {
|
||||
return;
|
||||
}
|
||||
|
@ -113,7 +112,6 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
|||
FoldingStructureComputationContext ctx= createContext(fInitialReconcilePending);
|
||||
fInitialReconcilePending= false;
|
||||
ctx.fAST= ast;
|
||||
ctx.fASTPositionConverter= positionTracker;
|
||||
update(ctx);
|
||||
} finally {
|
||||
fReconciling= false;
|
||||
|
@ -137,7 +135,6 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
|||
private boolean fHasHeaderComment;
|
||||
private LinkedHashMap fMap= new LinkedHashMap();
|
||||
private IASTTranslationUnit fAST;
|
||||
private IPositionConverter fASTPositionConverter;
|
||||
|
||||
FoldingStructureComputationContext(IDocument document, ProjectionAnnotationModel model, boolean allowCollapsing) {
|
||||
Assert.isNotNull(document);
|
||||
|
@ -270,13 +267,6 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
|||
return fAllowCollapsing && fCollapseInactiveCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the converter for the current AST or <code>null</code>
|
||||
*/
|
||||
public IPositionConverter getASTPositionConverter() {
|
||||
return fASTPositionConverter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current AST or <code>null</code>
|
||||
*/
|
||||
|
@ -1051,7 +1041,6 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
|||
public IStatus runOnAST(IASTTranslationUnit ast) {
|
||||
if (ast != null) {
|
||||
ctx.fAST= ast;
|
||||
ctx.fASTPositionConverter= null;
|
||||
fInitialReconcilePending= false;
|
||||
computeFoldingStructure(ast, ctx);
|
||||
}
|
||||
|
@ -1098,7 +1087,6 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
|||
if (fileName == null) {
|
||||
return;
|
||||
}
|
||||
IPositionConverter converter= ctx.getASTPositionConverter();
|
||||
List branches= new ArrayList();
|
||||
Stack branchStack = new Stack();
|
||||
|
||||
|
@ -1133,10 +1121,6 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
|||
IASTPreprocessorElseStatement elseStmt = (IASTPreprocessorElseStatement)statement;
|
||||
branchStack.push(new Branch(stmtLocation.getNodeOffset(), elseStmt.taken()));
|
||||
branch.setEndOffset(stmtLocation.getNodeOffset());
|
||||
if (converter != null) {
|
||||
IRegion converted= converter.historicToActual(branch);
|
||||
branch= new Branch(converted.getOffset(), converted.getLength(), branch.taken());
|
||||
}
|
||||
branches.add(branch);
|
||||
} else if (statement instanceof IASTPreprocessorElifStatement) {
|
||||
if (branchStack.isEmpty()) {
|
||||
|
@ -1147,10 +1131,6 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
|||
IASTPreprocessorElifStatement elifStmt = (IASTPreprocessorElifStatement) statement;
|
||||
branchStack.push(new Branch(stmtLocation.getNodeOffset(), elifStmt.taken()));
|
||||
branch.setEndOffset(stmtLocation.getNodeOffset());
|
||||
if (converter != null) {
|
||||
IRegion converted= converter.historicToActual(branch);
|
||||
branch= new Branch(converted.getOffset(), converted.getLength(), branch.taken());
|
||||
}
|
||||
branches.add(branch);
|
||||
} else if (statement instanceof IASTPreprocessorEndifStatement) {
|
||||
if (branchStack.isEmpty()) {
|
||||
|
@ -1159,10 +1139,6 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
|||
}
|
||||
Branch branch= (Branch)branchStack.pop();
|
||||
branch.setEndOffset(stmtLocation.getNodeOffset() + stmtLocation.getNodeLength());
|
||||
if (converter != null) {
|
||||
IRegion converted= converter.historicToActual(branch);
|
||||
branch= new Branch(converted.getOffset(), converted.getLength(), branch.taken());
|
||||
}
|
||||
branch.setInclusive(true);
|
||||
branches.add(branch);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue