1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Joined effort with Bogdan, Added parser timeout capability that is used by Content Assist

This commit is contained in:
Hoda Amer 2004-03-25 18:48:27 +00:00
parent 18b0c0e692
commit f2dba87e93
29 changed files with 428 additions and 68 deletions

View file

@ -690,6 +690,13 @@ public class CompleteParseBaseTest extends TestCase
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#parserTimeout()
*/
public boolean parserTimeout() {
// TODO Auto-generated method stub
return false;
}
} }
protected Iterator getNestedScopes( IASTCodeScope scope ) protected Iterator getNestedScopes( IASTCodeScope scope )

View file

@ -30,6 +30,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTVariable; import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.parser.ast.IASTNode.ILookupResult; import org.eclipse.cdt.core.parser.ast.IASTNode.ILookupResult;
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind; import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
import org.eclipse.core.runtime.NullProgressMonitor;
/** /**
* @author jcamelon * @author jcamelon

View file

@ -1,3 +1,7 @@
2004-03-25 Hoda Amer
Joined effort with Bogdan: Added a TimeOut class to core.utils
that implements a thread to control parser timeout.
2004-03-23 Alain Magloire 2004-03-23 Alain Magloire
An implementation of IScannerInfoProvider on top An implementation of IScannerInfoProvider on top

View file

@ -491,4 +491,11 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
public Reader createReader(String finalPath) { public Reader createReader(String finalPath) {
return ParserUtil.createReader(finalPath); return ParserUtil.createReader(finalPath);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#parserTimeout()
*/
public boolean parserTimeout() {
// TODO Auto-generated method stub
return false;
}
} }

View file

@ -1,3 +1,7 @@
2004-03-25 Hoda Amer
Joined effort with Bogdan: Added a parserTimeout() method to ISourceElementRequestor
and the ability for the parser to timeout.
2004-03-23 Andrew Niefer 2004-03-23 Andrew Niefer
-fix recursive loop leading to StackOverFlowException during template instantiation -fix recursive loop leading to StackOverFlowException during template instantiation
-fix copy constructors for templated classes -fix copy constructors for templated classes

View file

@ -14,7 +14,6 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
import org.eclipse.cdt.core.parser.ast.IASTNode; import org.eclipse.cdt.core.parser.ast.IASTNode;
/** /**
* This is the external interface that all C and C++ parsers in the CDT * This is the external interface that all C and C++ parsers in the CDT
* must implement. * must implement.
@ -35,7 +34,7 @@ public interface IParser {
* @param offset offset in the input file where code completion is being requested for * @param offset offset in the input file where code completion is being requested for
* @return an IASTCompletionConstruct that provides a mechanism for determining C/C++ code completion contributions * @return an IASTCompletionConstruct that provides a mechanism for determining C/C++ code completion contributions
*/ */
public IASTCompletionNode parse( int offset ) throws ParseError; public IASTCompletionNode parse( int offset) throws ParseError;
/** /**
* *

View file

@ -112,4 +112,10 @@ public interface ISourceElementRequestor {
* @return * @return
*/ */
public Reader createReader(String finalPath); public Reader createReader(String finalPath);
/**
* The parser asks the client if it wishes to time out
* in case it is taking more than the expected time.
* @return
*/
public boolean parserTimeout();
} }

View file

@ -469,4 +469,11 @@ public class NullSourceElementRequestor implements ISourceElementRequestor
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#parserTimeout()
*/
public boolean parserTimeout() {
// TODO Auto-generated method stub
return false;
}
} }

View file

@ -30,6 +30,8 @@ public class ParseError extends Error {
// semantic context cannot be provided in this case // semantic context cannot be provided in this case
public static final ParseErrorKind OFFSET_RANGE_NOT_NAME = new ParseErrorKind( 2 ); public static final ParseErrorKind OFFSET_RANGE_NOT_NAME = new ParseErrorKind( 2 );
public static final ParseErrorKind TIMEOUT = new ParseErrorKind( 3 );
/** /**
* @param enumValue * @param enumValue
*/ */

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.ITokenDuple; import org.eclipse.cdt.core.parser.ITokenDuple;
import org.eclipse.cdt.core.parser.OffsetLimitReachedException; import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
import org.eclipse.cdt.core.parser.ParseError;
import org.eclipse.cdt.core.parser.ParserFactory; import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ParserMode;
@ -2492,6 +2493,11 @@ public class ExpressionParser implements IExpressionParser {
* @throws EndOfFileException if looking ahead encounters EOF, throw EndOfFile * @throws EndOfFileException if looking ahead encounters EOF, throw EndOfFile
*/ */
protected IToken LA(int i) throws EndOfFileException { protected IToken LA(int i) throws EndOfFileException {
if (parserTimeout()){
throw new ParseError( ParseError.ParseErrorKind.TIMEOUT );
}
if (i < 1) // can't go backwards if (i < 1) // can't go backwards
return null; return null;
if (currToken == null) if (currToken == null)
@ -2524,6 +2530,7 @@ public class ExpressionParser implements IExpressionParser {
* @throws EndOfFileException If there is no token to consume. * @throws EndOfFileException If there is no token to consume.
*/ */
protected IToken consume() throws EndOfFileException { protected IToken consume() throws EndOfFileException {
if (currToken == null) if (currToken == null)
currToken = fetchToken(); currToken = fetchToken();
if (currToken != null) if (currToken != null)
@ -2659,4 +2666,7 @@ public class ExpressionParser implements IExpressionParser {
return scanner.getCurrentFilename(); return scanner.getCurrentFilename();
} }
protected boolean parserTimeout(){
return false;
}
} }

View file

@ -693,6 +693,7 @@ public abstract class Parser extends ExpressionParser implements IParser
IASTTemplate ownerTemplate, CompletionKind overideKind) IASTTemplate ownerTemplate, CompletionKind overideKind)
throws EndOfFileException, BacktrackException throws EndOfFileException, BacktrackException
{ {
IASTCompletionNode.CompletionKind kind = getCompletionKindForDeclaration(scope, overideKind); IASTCompletionNode.CompletionKind kind = getCompletionKindForDeclaration(scope, overideKind);
setCompletionValues(scope, kind, Key.DECLARATION ); setCompletionValues(scope, kind, Key.DECLARATION );
@ -2631,6 +2632,7 @@ public abstract class Parser extends ExpressionParser implements IParser
*/ */
protected void statement(IASTCodeScope scope) throws EndOfFileException, BacktrackException protected void statement(IASTCodeScope scope) throws EndOfFileException, BacktrackException
{ {
setCompletionValues(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.STATEMENT); setCompletionValues(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.STATEMENT);
switch (LT(1)) switch (LT(1))
@ -3010,4 +3012,11 @@ public abstract class Parser extends ExpressionParser implements IParser
*/ */
protected void setupASTFactory(IScanner scanner, ParserLanguage language) { protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#parserTimeout()
*/
protected boolean parserTimeout() {
// TODO Auto-generated method stub
return requestor.parserTimeout();
}
} }

View file

@ -608,4 +608,11 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
public Reader createReader(String finalPath) { public Reader createReader(String finalPath) {
return ParserUtil.createReader(finalPath); return ParserUtil.createReader(finalPath);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#parserTimeout()
*/
public boolean parserTimeout() {
// TODO Auto-generated method stub
return false;
}
} }

View file

@ -0,0 +1,131 @@
/**********************************************************************
* Copyright (c) 2004 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.utils;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* @author bgheorgh
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class TimeOut implements Runnable {
protected Thread thread;
protected boolean enabled;
protected IProgressMonitor pm = null;
private int timeout = 0;
// long timerTime=0;
private int threadPriority = Thread.MIN_PRIORITY + 1;
boolean debug = false;
public TimeOut(){
reset();
}
public void run() {
while (this.thread != null) {
try {
// System.out.println("Main loop: TOP time: " + (System.currentTimeMillis() - timerTime));
if (enabled){
// System.out.println("Main loop: ENABLED");
synchronized (this){
// System.out.println("Main loop: TIMEOUT START : waiting " + timeout + " ms");
wait(timeout);
// System.out.println("Main loop: TIMEOUT END");
}
if (enabled){
// System.out.println("Main loop: ABOUT TO CANCEL");
if(pm != null)
pm.setCanceled(true);
enabled = false;
}
}
else{
// System.out.println("Main loop: NOT ENABLED");
synchronized(this){
while(!enabled){
// System.out.println("SLEEP NOT ENABLED LOOP");
wait();
// timerTime = System.currentTimeMillis();
// System.out.println("WOKE UP: enabled = " + enabled);
}
}
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public synchronized void startTimer(){
// System.out.println("START TIMER");
enabled = true;
notify();
}
public synchronized void stopTimer(){
// System.out.println("STOP TIMER");
enabled= false;
notify();
}
public void reset() {
System.out.println("TimeOut reset");
enabled=false;
thread = new Thread(this, "Time Out Thread");
thread.setDaemon(true);
thread.setPriority(threadPriority);
thread.start();
}
/**
* @return Returns the threadPriority.
*/
public int getThreadPriority() {
return threadPriority;
}
/**
* @param threadPriority The threadPriority to set.
*/
public void setThreadPriority(int threadPriority) {
this.threadPriority = threadPriority;
}
/**
* @return Returns the pm.
*/
public IProgressMonitor getProgressMonitor() {
return pm;
}
/**
* @param pm The pm to set.
*/
public void setProgressMonitor(IProgressMonitor pm) {
this.pm = pm;
}
/**
* @return Returns the timeout.
*/
public int getTimeout() {
return timeout;
}
/**
* @param timeout The timeout to set.
*/
public void setTimeout(int timeout) {
this.timeout = timeout;
}
}

View file

@ -1,3 +1,7 @@
2004-03-25 Hoda Amer
Added the timeout capability for content assist.
Added a preference for the user to set up the timeout limit for content assist
2004-03-24 Bogdan Gheorghe 2004-03-24 Bogdan Gheorghe
Modified CSearchResultCollector to create markers on external matches. Modified CSearchResultCollector to create markers on external matches.

View file

@ -17,6 +17,7 @@ ExceptionDialog.seeErrorLogMessage=See error log for more details.
# Content Assist # Content Assist
################ ################
CEditor.contentassist.noCompletions=No completions available. CEditor.contentassist.noCompletions=No completions available.
CEditor.contentassist.timeout=Content Assist parsing has timed out.
CAnnotationHover.multipleMarkers=Multiple markers at this line CAnnotationHover.multipleMarkers=Multiple markers at this line

View file

@ -350,4 +350,11 @@ public class SourceElementRequestorAdapter implements ISourceElementRequestor {
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#parserTimeout()
*/
public boolean parserTimeout() {
// TODO Auto-generated method stub
return false;
}
} }

View file

@ -189,6 +189,7 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.TIMEOUT_DELAY));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_BACKGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_BACKGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FOREGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FOREGROUND));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND));
@ -279,6 +280,8 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
store.setDefault(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, true); store.setDefault(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, true);
store.setDefault(ContentAssistPreference.PROJECT_SEARCH_SCOPE, false); store.setDefault(ContentAssistPreference.PROJECT_SEARCH_SCOPE, false);
store.setDefault(ContentAssistPreference.TIMEOUT_DELAY, 3000);
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, true); store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, true);
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, true); store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, true);
store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, true); store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, true);
@ -849,13 +852,16 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically"); //$NON-NLS-1$ label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically"); //$NON-NLS-1$
addCheckBox(contentAssistComposite, label, ContentAssistPreference.AUTOINSERT, 0); addCheckBox(contentAssistComposite, label, ContentAssistPreference.AUTOINSERT, 0);
label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.showProposalsInAlphabeticalOrder"); //$NON-NLS-1$ label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.showProposalsInAlphabeticalOrder"); //$NON-NLS-1$
addCheckBox(contentAssistComposite, label, ContentAssistPreference.ORDER_PROPOSALS, 0); addCheckBox(contentAssistComposite, label, ContentAssistPreference.ORDER_PROPOSALS, 0);
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.timeoutDelay"); //$NON-NLS-1$
addTextField(contentAssistComposite, label, ContentAssistPreference.TIMEOUT_DELAY, 6, 0, true);
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
// The following items are grouped for Auto Activation // The following items are grouped for Auto Activation
label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationGroupTitle"); //$NON-NLS-1$ label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationGroupTitle"); //$NON-NLS-1$

View file

@ -115,6 +115,7 @@ public class EditTemplateDialog extends StatusDialog {
assistant.enableAutoActivation(enabled); assistant.enableAutoActivation(enabled);
assistant.setAutoActivationDelay(store.getInt(ContentAssistPreference.AUTOACTIVATION_DELAY)); assistant.setAutoActivationDelay(store.getInt(ContentAssistPreference.AUTOACTIVATION_DELAY));
assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY); assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
//assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); //assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));

View file

@ -76,6 +76,7 @@ CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectAndDependencies
CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically=&Insert single proposals automatically CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically=&Insert single proposals automatically
CEditorPreferencePage.ContentAssistPage.showOnlyProposalsWithCorrectVisibility=Show only proposals visible in the invocation conte&xt CEditorPreferencePage.ContentAssistPage.showOnlyProposalsWithCorrectVisibility=Show only proposals visible in the invocation conte&xt
CEditorPreferencePage.ContentAssistPage.showProposalsInAlphabeticalOrder=Present proposals in a&lphabetical order CEditorPreferencePage.ContentAssistPage.showProposalsInAlphabeticalOrder=Present proposals in a&lphabetical order
CEditorPreferencePage.ContentAssistPage.timeoutDelay=Content Assist parsing &timeout (in milli seconds)
CEditorPreferencePage.ContentAssistPage.autoActivationGroupTitle=Auto activation: CEditorPreferencePage.ContentAssistPage.autoActivationGroupTitle=Auto activation:
CEditorPreferencePage.ContentAssistPage.autoActivationEnableDot=Enable "." as trigger CEditorPreferencePage.ContentAssistPage.autoActivationEnableDot=Enable "." as trigger
CEditorPreferencePage.ContentAssistPage.autoActivationEnableArrow=Enable "->" as trigger CEditorPreferencePage.ContentAssistPage.autoActivationEnableArrow=Enable "->" as trigger

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
import java.io.CharArrayReader; import java.io.CharArrayReader;
import java.io.Reader; import java.io.Reader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -58,6 +57,7 @@ import org.eclipse.cdt.core.parser.ast.IASTNode.ILookupResult;
import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind; import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind;
import org.eclipse.cdt.internal.core.CharOperation; import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.cdt.internal.core.parser.util.ASTUtil; import org.eclipse.cdt.internal.core.parser.util.ASTUtil;
import org.eclipse.cdt.internal.ui.CUIMessages;
import org.eclipse.cdt.internal.ui.util.IDebugLogConstants; import org.eclipse.cdt.internal.ui.util.IDebugLogConstants;
import org.eclipse.cdt.internal.ui.util.Util; import org.eclipse.cdt.internal.ui.util.Util;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
@ -79,8 +79,10 @@ public class CompletionEngine implements RelevanceConstants {
int completionLength = 0; int completionLength = 0;
IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore(); IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
private Map macroMap = null; private Map macroMap = null;
private ContentAssistElementRequestor elementRequestor = null;
private static final String exceptionKeyword = "..."; //$NON-NLS-1$ private static final String exceptionKeyword = "..."; //$NON-NLS-1$
/*
// scope relevance element counters // scope relevance element counters
private int numFields = 0; private int numFields = 0;
private int numVariables = 0; private int numVariables = 0;
@ -94,9 +96,10 @@ public class CompletionEngine implements RelevanceConstants {
private int numEnumerators = 0; private int numEnumerators = 0;
private int numNamespaces = 0; private int numNamespaces = 0;
private int numTypedefs = 0; private int numTypedefs = 0;
*/
public CompletionEngine(ICompletionRequestor completionRequestor){ public CompletionEngine(ICompletionRequestor completionRequestor){
requestor = completionRequestor; requestor = completionRequestor;
elementRequestor = new ContentAssistElementRequestor();
} }
private int computeCaseMatchingRelevance(String prefix, String proposalName){ private int computeCaseMatchingRelevance(String prefix, String proposalName){
@ -154,7 +157,6 @@ public class CompletionEngine implements RelevanceConstants {
return relevance; return relevance;
} }
private IASTCompletionNode parse(IWorkingCopy sourceUnit, int completionOffset){ private IASTCompletionNode parse(IWorkingCopy sourceUnit, int completionOffset){
ContentAssistElementRequestor requestor = new ContentAssistElementRequestor();
// Get resource info // Get resource info
IResource currentResource = sourceUnit.getResource(); IResource currentResource = sourceUnit.getResource();
IPath realPath = currentResource.getLocation(); IPath realPath = currentResource.getLocation();
@ -177,8 +179,8 @@ public class CompletionEngine implements RelevanceConstants {
IScanner scanner = null; IScanner scanner = null;
try try
{ {
scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETION_PARSE, language, requestor, ParserUtil.getScannerLogService() ); scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETION_PARSE, language, elementRequestor, ParserUtil.getScannerLogService() );
parser = ParserFactory.createParser( scanner, requestor, ParserMode.COMPLETION_PARSE, language, ParserUtil.getParserLogService() ); parser = ParserFactory.createParser( scanner, elementRequestor, ParserMode.COMPLETION_PARSE, language, ParserUtil.getParserLogService() );
} }
catch( ParserFactoryError pfe ) catch( ParserFactoryError pfe )
{ {
@ -187,10 +189,26 @@ public class CompletionEngine implements RelevanceConstants {
if(parser != null){ if(parser != null){
IASTCompletionNode result = null; IASTCompletionNode result = null;
try { try {
// set timeout
IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
int timeout = store.getInt(ContentAssistPreference.TIMEOUT_DELAY);
elementRequestor.setTimeout(timeout);
// start timer
elementRequestor.startTimer();
long parserTime = System.currentTimeMillis();
result = parser.parse(completionOffset); result = parser.parse(completionOffset);
log("Time spent in Parser = "+ ( System.currentTimeMillis() - parserTime ) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$
macroMap = scanner.getDefinitions(); macroMap = scanner.getDefinitions();
} catch (ParseError e ) { } catch (ParseError e ) {
//TODO - this can be more than just a Not Implemented exception if(e.getErrorKind() == ParseError.ParseErrorKind.TIMEOUT){
log("Timeout received !!!!!! "); //$NON-NLS-1$;
requestor.acceptError(new Problem(CUIMessages.getString("CEditor.contentassist.timeout"))); //$NON-NLS-1$;
}
} finally {
// stop timer
elementRequestor.stopTimer();
} }
return result; return result;
} else { } else {
@ -200,20 +218,20 @@ public class CompletionEngine implements RelevanceConstants {
private void addNodeToCompletions(IASTNode node, String prefix, int totalNumberOfResults){ private void addNodeToCompletions(IASTNode node, String prefix, int totalNumberOfResults){
if(node instanceof IASTField){ if(node instanceof IASTField){
numFields++; // numFields++;
IASTField field = (IASTField)node; IASTField field = (IASTField)node;
int relevance = computeRelevance(ICElement.C_FIELD, prefix, field.getName()); int relevance = computeRelevance(ICElement.C_FIELD, prefix, field.getName());
relevance += totalNumberOfResults - numFields; //relevance += totalNumberOfResults - numFields;
requestor.acceptField(field.getName(), requestor.acceptField(field.getName(),
ASTUtil.getType(field.getAbstractDeclaration()), ASTUtil.getType(field.getAbstractDeclaration()),
field.getVisiblity(), completionStart, completionLength, relevance); field.getVisiblity(), completionStart, completionLength, relevance);
} }
else if (node instanceof IASTParameterDeclaration){ else if (node instanceof IASTParameterDeclaration){
numLocalVariables++; // numLocalVariables++;
IASTParameterDeclaration param = (IASTParameterDeclaration) node; IASTParameterDeclaration param = (IASTParameterDeclaration) node;
int relevance = computeRelevance(ICElement.C_VARIABLE_LOCAL, prefix, param.getName()); int relevance = computeRelevance(ICElement.C_VARIABLE_LOCAL, prefix, param.getName());
relevance += totalNumberOfResults - numLocalVariables; //relevance += totalNumberOfResults - numLocalVariables;
requestor.acceptLocalVariable(param.getName(), requestor.acceptLocalVariable(param.getName(),
ASTUtil.getType(param), ASTUtil.getType(param),
@ -224,17 +242,17 @@ public class CompletionEngine implements RelevanceConstants {
// get the container to check if it is a local variable // get the container to check if it is a local variable
IASTNode container = variable.getOwnerScope(); IASTNode container = variable.getOwnerScope();
if(container instanceof IASTCodeScope){ if(container instanceof IASTCodeScope){
numLocalVariables++; // numLocalVariables++;
int relevance = computeRelevance(ICElement.C_VARIABLE_LOCAL, prefix, variable.getName()); int relevance = computeRelevance(ICElement.C_VARIABLE_LOCAL, prefix, variable.getName());
relevance += totalNumberOfResults - numLocalVariables; //relevance += totalNumberOfResults - numLocalVariables;
requestor.acceptLocalVariable(variable.getName(), requestor.acceptLocalVariable(variable.getName(),
ASTUtil.getType(variable.getAbstractDeclaration()), ASTUtil.getType(variable.getAbstractDeclaration()),
completionStart, completionLength, relevance); completionStart, completionLength, relevance);
}else { }else {
numVariables++; // numVariables++;
int relevance = computeRelevance(ICElement.C_VARIABLE, prefix, variable.getName()); int relevance = computeRelevance(ICElement.C_VARIABLE, prefix, variable.getName());
relevance += totalNumberOfResults - numVariables; //relevance += totalNumberOfResults - numVariables;
requestor.acceptVariable(variable.getName(), requestor.acceptVariable(variable.getName(),
ASTUtil.getType(variable.getAbstractDeclaration()), ASTUtil.getType(variable.getAbstractDeclaration()),
@ -242,10 +260,10 @@ public class CompletionEngine implements RelevanceConstants {
} }
} }
else if(node instanceof IASTMethod) { else if(node instanceof IASTMethod) {
numMethods++; // numMethods++;
IASTMethod method = (IASTMethod)node; IASTMethod method = (IASTMethod)node;
int relevance = computeRelevance(ICElement.C_METHOD, prefix, method.getName()); int relevance = computeRelevance(ICElement.C_METHOD, prefix, method.getName());
relevance += totalNumberOfResults - numMethods; //relevance += totalNumberOfResults - numMethods;
String parameterString = ASTUtil.getParametersString(ASTUtil.getFunctionParameterTypes(method)); String parameterString = ASTUtil.getParametersString(ASTUtil.getFunctionParameterTypes(method));
requestor.acceptMethod(method.getName(), requestor.acceptMethod(method.getName(),
@ -254,10 +272,10 @@ public class CompletionEngine implements RelevanceConstants {
method.getVisiblity(), completionStart, completionLength, relevance); method.getVisiblity(), completionStart, completionLength, relevance);
} }
else if(node instanceof IASTFunction){ else if(node instanceof IASTFunction){
numFunctions++; // numFunctions++;
IASTFunction function = (IASTFunction)node; IASTFunction function = (IASTFunction)node;
int relevance = computeRelevance(ICElement.C_FUNCTION, prefix, function.getName()); int relevance = computeRelevance(ICElement.C_FUNCTION, prefix, function.getName());
relevance += totalNumberOfResults - numFunctions; //relevance += totalNumberOfResults - numFunctions;
String parameterString = ASTUtil.getParametersString(ASTUtil.getFunctionParameterTypes(function)); String parameterString = ASTUtil.getParametersString(ASTUtil.getFunctionParameterTypes(function));
requestor.acceptFunction(function.getName(), requestor.acceptFunction(function.getName(),
@ -269,59 +287,59 @@ public class CompletionEngine implements RelevanceConstants {
IASTClassSpecifier classSpecifier = (IASTClassSpecifier)node; IASTClassSpecifier classSpecifier = (IASTClassSpecifier)node;
ASTClassKind classkind = classSpecifier.getClassKind(); ASTClassKind classkind = classSpecifier.getClassKind();
if(classkind == ASTClassKind.CLASS){ if(classkind == ASTClassKind.CLASS){
numClasses++; // numClasses++;
int relevance = computeRelevance(ICElement.C_CLASS, prefix, classSpecifier.getName()); int relevance = computeRelevance(ICElement.C_CLASS, prefix, classSpecifier.getName());
relevance += totalNumberOfResults - numClasses; //relevance += totalNumberOfResults - numClasses;
requestor.acceptClass(classSpecifier.getName(), requestor.acceptClass(classSpecifier.getName(),
completionStart, completionLength, relevance); completionStart, completionLength, relevance);
} }
if(classkind == ASTClassKind.STRUCT){ if(classkind == ASTClassKind.STRUCT){
numStructs++; // numStructs++;
int relevance = computeRelevance(ICElement.C_STRUCT, prefix, classSpecifier.getName()); int relevance = computeRelevance(ICElement.C_STRUCT, prefix, classSpecifier.getName());
relevance += totalNumberOfResults - numStructs; //relevance += totalNumberOfResults - numStructs;
requestor.acceptStruct(classSpecifier.getName(), requestor.acceptStruct(classSpecifier.getName(),
completionStart, completionLength, relevance); completionStart, completionLength, relevance);
} }
if(classkind == ASTClassKind.UNION){ if(classkind == ASTClassKind.UNION){
numUnions++; // numUnions++;
int relevance = computeRelevance(ICElement.C_UNION, prefix, classSpecifier.getName()); int relevance = computeRelevance(ICElement.C_UNION, prefix, classSpecifier.getName());
relevance += totalNumberOfResults - numUnions; //relevance += totalNumberOfResults - numUnions;
requestor.acceptUnion(classSpecifier.getName(), requestor.acceptUnion(classSpecifier.getName(),
completionStart, completionLength, relevance); completionStart, completionLength, relevance);
} }
} }
else if(node instanceof IASTNamespaceDefinition){ else if(node instanceof IASTNamespaceDefinition){
numNamespaces++; // numNamespaces++;
IASTNamespaceDefinition namespace = (IASTNamespaceDefinition)node; IASTNamespaceDefinition namespace = (IASTNamespaceDefinition)node;
int relevance = computeRelevance(ICElement.C_NAMESPACE, prefix, namespace.getName()); int relevance = computeRelevance(ICElement.C_NAMESPACE, prefix, namespace.getName());
relevance += totalNumberOfResults - numNamespaces; //relevance += totalNumberOfResults - numNamespaces;
requestor.acceptNamespace(namespace.getName(), completionStart, completionLength, relevance); requestor.acceptNamespace(namespace.getName(), completionStart, completionLength, relevance);
} }
else if(node instanceof IASTEnumerationSpecifier){ else if(node instanceof IASTEnumerationSpecifier){
numEnumerations++; // numEnumerations++;
IASTEnumerationSpecifier enumeration = (IASTEnumerationSpecifier)node; IASTEnumerationSpecifier enumeration = (IASTEnumerationSpecifier)node;
int relevance = computeRelevance(ICElement.C_ENUMERATION, prefix, enumeration.getName()); int relevance = computeRelevance(ICElement.C_ENUMERATION, prefix, enumeration.getName());
relevance += totalNumberOfResults - numEnumerations; //relevance += totalNumberOfResults - numEnumerations;
requestor.acceptEnumeration(enumeration.getName(), completionStart, completionLength, relevance); requestor.acceptEnumeration(enumeration.getName(), completionStart, completionLength, relevance);
} }
else if(node instanceof IASTEnumerator){ else if(node instanceof IASTEnumerator){
numEnumerators++; // numEnumerators++;
IASTEnumerator enumerator = (IASTEnumerator)node; IASTEnumerator enumerator = (IASTEnumerator)node;
int relevance = computeRelevance(ICElement.C_ENUMERATOR, prefix, enumerator.getName()); int relevance = computeRelevance(ICElement.C_ENUMERATOR, prefix, enumerator.getName());
relevance += totalNumberOfResults - numEnumerators; //relevance += totalNumberOfResults - numEnumerators;
requestor.acceptEnumerator(enumerator.getName(), completionStart, completionLength, relevance); requestor.acceptEnumerator(enumerator.getName(), completionStart, completionLength, relevance);
} }
else if(node instanceof IASTTypedefDeclaration){ else if(node instanceof IASTTypedefDeclaration){
numTypedefs++; // numTypedefs++;
IASTTypedefDeclaration typedef = (IASTTypedefDeclaration)node; IASTTypedefDeclaration typedef = (IASTTypedefDeclaration)node;
int relevance = computeRelevance(ICElement.C_TYPEDEF, prefix, typedef.getName()); int relevance = computeRelevance(ICElement.C_TYPEDEF, prefix, typedef.getName());
relevance += totalNumberOfResults - numTypedefs; //relevance += totalNumberOfResults - numTypedefs;
requestor.acceptTypedef(typedef.getName(), completionStart, completionLength, relevance); requestor.acceptTypedef(typedef.getName(), completionStart, completionLength, relevance);
} }
@ -357,7 +375,7 @@ public class CompletionEngine implements RelevanceConstants {
log("No of Macros = " + numOfMacros); //$NON-NLS-1$ log("No of Macros = " + numOfMacros); //$NON-NLS-1$
} }
/*
private void resetElementNumbers(){ private void resetElementNumbers(){
numFields = 0; numFields = 0;
numVariables = 0; numVariables = 0;
@ -372,6 +390,7 @@ public class CompletionEngine implements RelevanceConstants {
numNamespaces = 0; numNamespaces = 0;
numTypedefs = 0; numTypedefs = 0;
} }
*/
private void addToCompletions (ILookupResult result){ private void addToCompletions (ILookupResult result){
if(result == null){ if(result == null){
log("Lookup Results = null ................. !!! No Lookup Results found !!! "); //$NON-NLS-1$ log("Lookup Results = null ................. !!! No Lookup Results found !!! "); //$NON-NLS-1$
@ -382,7 +401,7 @@ public class CompletionEngine implements RelevanceConstants {
log("No of Lookup Results = " + numberOfElements); //$NON-NLS-1$ log("No of Lookup Results = " + numberOfElements); //$NON-NLS-1$
resetElementNumbers(); // resetElementNumbers();
while (nodes.hasNext()){ while (nodes.hasNext()){
IASTNode node = (IASTNode) nodes.next(); IASTNode node = (IASTNode) nodes.next();
addNodeToCompletions(node, result.getPrefix(), numberOfElements); addNodeToCompletions(node, result.getPrefix(), numberOfElements);
@ -461,7 +480,6 @@ public class CompletionEngine implements RelevanceConstants {
// kinds[4] = IASTNode.LookupKind.TYPEDEFS; // kinds[4] = IASTNode.LookupKind.TYPEDEFS;
// ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext()); // ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext());
// addToCompletions(result); // addToCompletions(result);
// // TODO
// // lookup static members (field / methods) in type // // lookup static members (field / methods) in type
// } // }
private void completionOnTypeReference(IASTCompletionNode completionNode){ private void completionOnTypeReference(IASTCompletionNode completionNode){
@ -591,7 +609,7 @@ public class CompletionEngine implements RelevanceConstants {
// basic completion on all types // basic completion on all types
completionOnTypeReference(completionNode); completionOnTypeReference(completionNode);
} }
// TODO: complete the lookups
private void completionOnConstructorReference(IASTCompletionNode completionNode){ private void completionOnConstructorReference(IASTCompletionNode completionNode){
// 1. Get the search scope node // 1. Get the search scope node
IASTScope searchNode = completionNode.getCompletionScope(); IASTScope searchNode = completionNode.getCompletionScope();

View file

@ -10,7 +10,6 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.internal.ui.text.contentassist; package org.eclipse.cdt.internal.ui.text.contentassist;
import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public class CompletionRequestorAdaptor implements ICompletionRequestor { public class CompletionRequestorAdaptor implements ICompletionRequestor {

View file

@ -1,17 +1,72 @@
/* /**********************************************************************
* Created on Nov 19, 2003 * Copyright (c) 2004 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
* *
* To change the template for this generated file go to * Contributors:
* Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments * IBM Rational Software - Initial API and implementation
*/ ***********************************************************************/
package org.eclipse.cdt.internal.ui.text.contentassist; package org.eclipse.cdt.internal.ui.text.contentassist;
import org.eclipse.cdt.core.parser.NullSourceElementRequestor; import org.eclipse.cdt.core.parser.NullSourceElementRequestor;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.cdt.utils.TimeOut;
/** /**
* *
* This class is the source element requestor used by the completion engine. * This class is the source element requestor used by the completion engine.
*/ */
public class ContentAssistElementRequestor extends NullSourceElementRequestor { public class ContentAssistElementRequestor extends NullSourceElementRequestor implements ITimeoutThreadOwner{
// a static timer thread
private static TimeOut timeoutThread = new TimeOut();
private IProgressMonitor pm = new NullProgressMonitor();
/**
*
*/
public ContentAssistElementRequestor() {
super();
// set the timer thread to max priority for best performance
timeoutThread.setThreadPriority(Thread.MAX_PRIORITY);
}
/* (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();
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() {
pm.setCanceled(false);
timeoutThread.setProgressMonitor(pm);
}
} }

View file

@ -26,6 +26,8 @@ public class ContentAssistPreference {
//public final static String AUTOACTIVATION= "content_assist_autoactivation"; //public final static String AUTOACTIVATION= "content_assist_autoactivation";
/** Preference key for content assist auto activation delay */ /** Preference key for content assist auto activation delay */
public final static String AUTOACTIVATION_DELAY= "content_assist_autoactivation_delay"; //$NON-NLS-1$ public final static String AUTOACTIVATION_DELAY= "content_assist_autoactivation_delay"; //$NON-NLS-1$
/** Preference key for content assist timeout delay */
public final static String TIMEOUT_DELAY= "content_assist_timeout_delay"; //$NON-NLS-1$
/** Preference key for content assist proposal color */ /** Preference key for content assist proposal color */
public final static String PROPOSALS_FOREGROUND= "content_assist_proposals_foreground"; //$NON-NLS-1$ public final static String PROPOSALS_FOREGROUND= "content_assist_proposals_foreground"; //$NON-NLS-1$
/** Preference key for content assist proposal color */ /** Preference key for content assist proposal color */
@ -120,6 +122,7 @@ public class ContentAssistPreference {
int delay= store.getInt(AUTOACTIVATION_DELAY); int delay= store.getInt(AUTOACTIVATION_DELAY);
assistant.setAutoActivationDelay(delay); assistant.setAutoActivationDelay(delay);
delay= store.getInt(TIMEOUT_DELAY);
Color c1= getColor(store, PROPOSALS_FOREGROUND, manager); Color c1= getColor(store, PROPOSALS_FOREGROUND, manager);
assistant.setProposalSelectorForeground(c1); assistant.setProposalSelectorForeground(c1);

View file

@ -10,7 +10,6 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.internal.ui.text.contentassist; package org.eclipse.cdt.internal.ui.text.contentassist;
import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public interface ICompletionRequestor { public interface ICompletionRequestor {

View file

@ -0,0 +1,15 @@
/**********************************************************************
* Copyright (c) 2004 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.internal.ui.text.contentassist;
public interface IProblem {
String getMessage();
}

View file

@ -0,0 +1,33 @@
/**********************************************************************
* Copyright (c) 2004 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.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();
}

View file

@ -0,0 +1,25 @@
/**********************************************************************
* Copyright (c) 2004 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.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;
}
}

View file

@ -11,22 +11,22 @@
package org.eclipse.cdt.internal.ui.text.contentassist; package org.eclipse.cdt.internal.ui.text.contentassist;
public interface RelevanceConstants { public interface RelevanceConstants {
final int CASE_MATCH_RELEVANCE = 1600; final int CASE_MATCH_RELEVANCE = 160;
final int EXACT_NAME_MATCH_RELEVANCE = 400; final int EXACT_NAME_MATCH_RELEVANCE = 40;
final int LOCAL_VARIABLE_TYPE_RELEVANCE = 1400; final int LOCAL_VARIABLE_TYPE_RELEVANCE = 140;
final int FIELD_TYPE_RELEVANCE = 1300; final int FIELD_TYPE_RELEVANCE = 130;
final int VARIABLE_TYPE_RELEVANCE = 1200; final int VARIABLE_TYPE_RELEVANCE = 120;
final int METHOD_TYPE_RELEVANCE = 1100; final int METHOD_TYPE_RELEVANCE = 110;
final int FUNCTION_TYPE_RELEVANCE = 1000; final int FUNCTION_TYPE_RELEVANCE = 100;
final int CLASS_TYPE_RELEVANCE = 900; final int CLASS_TYPE_RELEVANCE = 90;
final int STRUCT_TYPE_RELEVANCE = 800; final int STRUCT_TYPE_RELEVANCE = 80;
final int UNION_TYPE_RELEVANCE = 700; final int UNION_TYPE_RELEVANCE = 70;
final int TYPEDEF_TYPE_RELEVANCE = 600; final int TYPEDEF_TYPE_RELEVANCE = 60;
final int NAMESPACE_TYPE_RELEVANCE = 500; final int NAMESPACE_TYPE_RELEVANCE = 50;
final int MACRO_TYPE_RELEVANCE = 400; final int MACRO_TYPE_RELEVANCE = 40;
final int ENUMERATION_TYPE_RELEVANCE = 300; final int ENUMERATION_TYPE_RELEVANCE = 30;
final int ENUMERATOR_TYPE_RELEVANCE = 200; final int ENUMERATOR_TYPE_RELEVANCE = 20;
final int KEYWORD_TYPE_RELEVANCE = 100; final int KEYWORD_TYPE_RELEVANCE = 10;
final int DEFAULT_TYPE_RELEVANCE = 0; final int DEFAULT_TYPE_RELEVANCE = 0;
} }

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.internal.ui.CElementImageProvider; import org.eclipse.cdt.internal.ui.CElementImageProvider;
import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry; import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;