diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java index 7adbb6d5391..4d93e393163 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseBaseTest.java @@ -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 ) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompletionParseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompletionParseTest.java index 23574190639..d29cf64eb7e 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompletionParseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompletionParseTest.java @@ -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.IASTNode.ILookupResult; import org.eclipse.cdt.core.parser.ast.IASTNode.LookupKind; +import org.eclipse.core.runtime.NullProgressMonitor; /** * @author jcamelon diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index 470afedbb48..e720ba5ba68 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -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 An implementation of IScannerInfoProvider on top diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java index 4f1828b6e3b..a37674d0a36 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java @@ -491,4 +491,11 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo public Reader createReader(String 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; + } } diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog-parser b/core/org.eclipse.cdt.core/parser/ChangeLog-parser index e02e5236154..a59919e6a78 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog-parser +++ b/core/org.eclipse.cdt.core/parser/ChangeLog-parser @@ -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 -fix recursive loop leading to StackOverFlowException during template instantiation -fix copy constructors for templated classes diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IParser.java index e01ea5339db..69eb18d632e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IParser.java @@ -14,7 +14,6 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode; import org.eclipse.cdt.core.parser.ast.IASTNode; - /** * This is the external interface that all C and C++ parsers in the CDT * must implement. @@ -35,7 +34,7 @@ public interface IParser { * @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 */ - public IASTCompletionNode parse( int offset ) throws ParseError; + public IASTCompletionNode parse( int offset) throws ParseError; /** * @@ -51,7 +50,7 @@ public interface IParser { * @return -1 for no error, otherwise the character offset where we encountered * our first unrecoverable error. */ - public int getLastErrorOffset(); + public int getLastErrorOffset(); } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java index 737bcd9cb40..f88ad4409a5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java @@ -112,4 +112,10 @@ public interface ISourceElementRequestor { * @return */ 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(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/NullSourceElementRequestor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/NullSourceElementRequestor.java index 0f6edad2a0c..b1ae5abd0ec 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/NullSourceElementRequestor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/NullSourceElementRequestor.java @@ -469,4 +469,11 @@ public class NullSourceElementRequestor implements ISourceElementRequestor // 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; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParseError.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParseError.java index 3f19f03bf52..c714a7ee6f2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParseError.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParseError.java @@ -29,6 +29,8 @@ public class ParseError extends Error { // offset range specified is not a valid identifier or qualified name // semantic context cannot be provided in this case public static final ParseErrorKind OFFSET_RANGE_NOT_NAME = new ParseErrorKind( 2 ); + + public static final ParseErrorKind TIMEOUT = new ParseErrorKind( 3 ); /** * @param enumValue diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionParser.java index 2ba7fa3ce46..cfe7b2871b8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionParser.java @@ -22,6 +22,7 @@ import org.eclipse.cdt.core.parser.IScanner; import org.eclipse.cdt.core.parser.IToken; import org.eclipse.cdt.core.parser.ITokenDuple; 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.ParserLanguage; 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 */ protected IToken LA(int i) throws EndOfFileException { + + if (parserTimeout()){ + throw new ParseError( ParseError.ParseErrorKind.TIMEOUT ); + } + if (i < 1) // can't go backwards return null; if (currToken == null) @@ -2524,6 +2530,7 @@ public class ExpressionParser implements IExpressionParser { * @throws EndOfFileException If there is no token to consume. */ protected IToken consume() throws EndOfFileException { + if (currToken == null) currToken = fetchToken(); if (currToken != null) @@ -2658,5 +2665,8 @@ public class ExpressionParser implements IExpressionParser { public char[] getCurrentFilename() { return scanner.getCurrentFilename(); } - + + protected boolean parserTimeout(){ + return false; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java index e36e4bc57ac..09c5f51ffcc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java @@ -72,7 +72,7 @@ public abstract class Parser extends ExpressionParser implements IParser { private static final List EMPTY_LIST = new ArrayList(); protected ISourceElementRequestor requestor = null; - + /** @@ -693,6 +693,7 @@ public abstract class Parser extends ExpressionParser implements IParser IASTTemplate ownerTemplate, CompletionKind overideKind) throws EndOfFileException, BacktrackException { + IASTCompletionNode.CompletionKind kind = getCompletionKindForDeclaration(scope, overideKind); 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 { + setCompletionValues(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.STATEMENT); switch (LT(1)) @@ -3010,4 +3012,11 @@ public abstract class Parser extends ExpressionParser implements IParser */ 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(); + } } diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java index 44008b6ba6a..12cd108cb12 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java @@ -608,4 +608,11 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants public Reader createReader(String 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; + } } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/TimeOut.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/TimeOut.java new file mode 100644 index 00000000000..2320ed80e65 --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/TimeOut.java @@ -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; + } +} diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 1faad12f2df..7b11447d88a 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -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 Modified CSearchResultCollector to create markers on external matches. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties index de7cbb9f39c..ef4b1be473e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties @@ -17,6 +17,7 @@ ExceptionDialog.seeErrorLogMessage=See error log for more details. # Content Assist ################ CEditor.contentassist.noCompletions=No completions available. +CEditor.contentassist.timeout=Content Assist parsing has timed out. CAnnotationHover.multipleMarkers=Multiple markers at this line diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/SourceElementRequestorAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/SourceElementRequestorAdapter.java index 2d744b3f40a..56006c142c1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/SourceElementRequestorAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/SourceElementRequestorAdapter.java @@ -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; + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java index f7a50c8fa85..773b75538dc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java @@ -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.INT, ContentAssistPreference.AUTOACTIVATION_DELAY)); 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_FOREGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND)); @@ -278,6 +279,8 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP store.setDefault(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, true); 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_ARROW, true); @@ -849,13 +852,16 @@ public class CEditorPreferencePage extends PreferencePage implements IWorkbenchP //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically"); //$NON-NLS-1$ addCheckBox(contentAssistComposite, label, ContentAssistPreference.AUTOINSERT, 0); label= PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.showProposalsInAlphabeticalOrder"); //$NON-NLS-1$ 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 label = PreferencesMessages.getString("CEditorPreferencePage.ContentAssistPage.autoActivationGroupTitle"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java index 8bd10c88d78..5a199fef207 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java @@ -115,6 +115,7 @@ public class EditTemplateDialog extends StatusDialog { assistant.enableAutoActivation(enabled); assistant.setAutoActivationDelay(store.getInt(ContentAssistPreference.AUTOACTIVATION_DELAY)); + assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY); assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE); //assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties index d603e4a644f..90a5009cc96 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties @@ -76,6 +76,7 @@ CEditorPreferencePage.ContentAssistPage.searchGroupCurrentProjectAndDependencies CEditorPreferencePage.ContentAssistPage.insertSingleProposalAutomatically=&Insert single proposals automatically CEditorPreferencePage.ContentAssistPage.showOnlyProposalsWithCorrectVisibility=Show only proposals visible in the invocation conte&xt 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.autoActivationEnableDot=Enable "." as trigger CEditorPreferencePage.ContentAssistPage.autoActivationEnableArrow=Enable "->" as trigger diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java index 543e35d3089..fdf9db278cc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist; import java.io.CharArrayReader; import java.io.Reader; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; import java.util.List; 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.internal.core.CharOperation; 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.Util; import org.eclipse.cdt.ui.CUIPlugin; @@ -79,8 +79,10 @@ public class CompletionEngine implements RelevanceConstants { int completionLength = 0; IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore(); private Map macroMap = null; + private ContentAssistElementRequestor elementRequestor = null; private static final String exceptionKeyword = "..."; //$NON-NLS-1$ +/* // scope relevance element counters private int numFields = 0; private int numVariables = 0; @@ -94,9 +96,10 @@ public class CompletionEngine implements RelevanceConstants { private int numEnumerators = 0; private int numNamespaces = 0; private int numTypedefs = 0; - +*/ public CompletionEngine(ICompletionRequestor completionRequestor){ requestor = completionRequestor; + elementRequestor = new ContentAssistElementRequestor(); } private int computeCaseMatchingRelevance(String prefix, String proposalName){ @@ -154,7 +157,6 @@ public class CompletionEngine implements RelevanceConstants { return relevance; } private IASTCompletionNode parse(IWorkingCopy sourceUnit, int completionOffset){ - ContentAssistElementRequestor requestor = new ContentAssistElementRequestor(); // Get resource info IResource currentResource = sourceUnit.getResource(); IPath realPath = currentResource.getLocation(); @@ -177,8 +179,8 @@ public class CompletionEngine implements RelevanceConstants { IScanner scanner = null; try { - scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETION_PARSE, language, requestor, ParserUtil.getScannerLogService() ); - parser = ParserFactory.createParser( scanner, requestor, ParserMode.COMPLETION_PARSE, language, ParserUtil.getParserLogService() ); + scanner = ParserFactory.createScanner( reader, realPath.toOSString(), scanInfo, ParserMode.COMPLETION_PARSE, language, elementRequestor, ParserUtil.getScannerLogService() ); + parser = ParserFactory.createParser( scanner, elementRequestor, ParserMode.COMPLETION_PARSE, language, ParserUtil.getParserLogService() ); } catch( ParserFactoryError pfe ) { @@ -187,10 +189,26 @@ public class CompletionEngine implements RelevanceConstants { if(parser != null){ IASTCompletionNode result = null; 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); + log("Time spent in Parser = "+ ( System.currentTimeMillis() - parserTime ) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$ + macroMap = scanner.getDefinitions(); } 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; } else { @@ -200,20 +218,20 @@ public class CompletionEngine implements RelevanceConstants { private void addNodeToCompletions(IASTNode node, String prefix, int totalNumberOfResults){ if(node instanceof IASTField){ - numFields++; +// numFields++; IASTField field = (IASTField)node; int relevance = computeRelevance(ICElement.C_FIELD, prefix, field.getName()); - relevance += totalNumberOfResults - numFields; + //relevance += totalNumberOfResults - numFields; requestor.acceptField(field.getName(), ASTUtil.getType(field.getAbstractDeclaration()), field.getVisiblity(), completionStart, completionLength, relevance); } else if (node instanceof IASTParameterDeclaration){ - numLocalVariables++; +// numLocalVariables++; IASTParameterDeclaration param = (IASTParameterDeclaration) node; int relevance = computeRelevance(ICElement.C_VARIABLE_LOCAL, prefix, param.getName()); - relevance += totalNumberOfResults - numLocalVariables; + //relevance += totalNumberOfResults - numLocalVariables; requestor.acceptLocalVariable(param.getName(), ASTUtil.getType(param), @@ -224,17 +242,17 @@ public class CompletionEngine implements RelevanceConstants { // get the container to check if it is a local variable IASTNode container = variable.getOwnerScope(); if(container instanceof IASTCodeScope){ - numLocalVariables++; +// numLocalVariables++; int relevance = computeRelevance(ICElement.C_VARIABLE_LOCAL, prefix, variable.getName()); - relevance += totalNumberOfResults - numLocalVariables; + //relevance += totalNumberOfResults - numLocalVariables; requestor.acceptLocalVariable(variable.getName(), ASTUtil.getType(variable.getAbstractDeclaration()), completionStart, completionLength, relevance); }else { - numVariables++; +// numVariables++; int relevance = computeRelevance(ICElement.C_VARIABLE, prefix, variable.getName()); - relevance += totalNumberOfResults - numVariables; + //relevance += totalNumberOfResults - numVariables; requestor.acceptVariable(variable.getName(), ASTUtil.getType(variable.getAbstractDeclaration()), @@ -242,10 +260,10 @@ public class CompletionEngine implements RelevanceConstants { } } else if(node instanceof IASTMethod) { - numMethods++; +// numMethods++; IASTMethod method = (IASTMethod)node; int relevance = computeRelevance(ICElement.C_METHOD, prefix, method.getName()); - relevance += totalNumberOfResults - numMethods; + //relevance += totalNumberOfResults - numMethods; String parameterString = ASTUtil.getParametersString(ASTUtil.getFunctionParameterTypes(method)); requestor.acceptMethod(method.getName(), @@ -254,10 +272,10 @@ public class CompletionEngine implements RelevanceConstants { method.getVisiblity(), completionStart, completionLength, relevance); } else if(node instanceof IASTFunction){ - numFunctions++; +// numFunctions++; IASTFunction function = (IASTFunction)node; int relevance = computeRelevance(ICElement.C_FUNCTION, prefix, function.getName()); - relevance += totalNumberOfResults - numFunctions; + //relevance += totalNumberOfResults - numFunctions; String parameterString = ASTUtil.getParametersString(ASTUtil.getFunctionParameterTypes(function)); requestor.acceptFunction(function.getName(), @@ -269,59 +287,59 @@ public class CompletionEngine implements RelevanceConstants { IASTClassSpecifier classSpecifier = (IASTClassSpecifier)node; ASTClassKind classkind = classSpecifier.getClassKind(); if(classkind == ASTClassKind.CLASS){ - numClasses++; +// numClasses++; int relevance = computeRelevance(ICElement.C_CLASS, prefix, classSpecifier.getName()); - relevance += totalNumberOfResults - numClasses; + //relevance += totalNumberOfResults - numClasses; requestor.acceptClass(classSpecifier.getName(), completionStart, completionLength, relevance); } if(classkind == ASTClassKind.STRUCT){ - numStructs++; +// numStructs++; int relevance = computeRelevance(ICElement.C_STRUCT, prefix, classSpecifier.getName()); - relevance += totalNumberOfResults - numStructs; + //relevance += totalNumberOfResults - numStructs; requestor.acceptStruct(classSpecifier.getName(), completionStart, completionLength, relevance); } if(classkind == ASTClassKind.UNION){ - numUnions++; +// numUnions++; int relevance = computeRelevance(ICElement.C_UNION, prefix, classSpecifier.getName()); - relevance += totalNumberOfResults - numUnions; + //relevance += totalNumberOfResults - numUnions; requestor.acceptUnion(classSpecifier.getName(), completionStart, completionLength, relevance); } } else if(node instanceof IASTNamespaceDefinition){ - numNamespaces++; +// numNamespaces++; IASTNamespaceDefinition namespace = (IASTNamespaceDefinition)node; int relevance = computeRelevance(ICElement.C_NAMESPACE, prefix, namespace.getName()); - relevance += totalNumberOfResults - numNamespaces; + //relevance += totalNumberOfResults - numNamespaces; requestor.acceptNamespace(namespace.getName(), completionStart, completionLength, relevance); } else if(node instanceof IASTEnumerationSpecifier){ - numEnumerations++; +// numEnumerations++; IASTEnumerationSpecifier enumeration = (IASTEnumerationSpecifier)node; int relevance = computeRelevance(ICElement.C_ENUMERATION, prefix, enumeration.getName()); - relevance += totalNumberOfResults - numEnumerations; + //relevance += totalNumberOfResults - numEnumerations; requestor.acceptEnumeration(enumeration.getName(), completionStart, completionLength, relevance); } else if(node instanceof IASTEnumerator){ - numEnumerators++; +// numEnumerators++; IASTEnumerator enumerator = (IASTEnumerator)node; int relevance = computeRelevance(ICElement.C_ENUMERATOR, prefix, enumerator.getName()); - relevance += totalNumberOfResults - numEnumerators; + //relevance += totalNumberOfResults - numEnumerators; requestor.acceptEnumerator(enumerator.getName(), completionStart, completionLength, relevance); } else if(node instanceof IASTTypedefDeclaration){ - numTypedefs++; +// numTypedefs++; IASTTypedefDeclaration typedef = (IASTTypedefDeclaration)node; int relevance = computeRelevance(ICElement.C_TYPEDEF, prefix, typedef.getName()); - relevance += totalNumberOfResults - numTypedefs; + //relevance += totalNumberOfResults - numTypedefs; requestor.acceptTypedef(typedef.getName(), completionStart, completionLength, relevance); } @@ -357,7 +375,7 @@ public class CompletionEngine implements RelevanceConstants { log("No of Macros = " + numOfMacros); //$NON-NLS-1$ } - +/* private void resetElementNumbers(){ numFields = 0; numVariables = 0; @@ -372,6 +390,7 @@ public class CompletionEngine implements RelevanceConstants { numNamespaces = 0; numTypedefs = 0; } +*/ private void addToCompletions (ILookupResult result){ if(result == null){ 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$ - resetElementNumbers(); +// resetElementNumbers(); while (nodes.hasNext()){ IASTNode node = (IASTNode) nodes.next(); addNodeToCompletions(node, result.getPrefix(), numberOfElements); @@ -461,7 +480,6 @@ public class CompletionEngine implements RelevanceConstants { // kinds[4] = IASTNode.LookupKind.TYPEDEFS; // ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext()); // addToCompletions(result); -// // TODO // // lookup static members (field / methods) in type // } private void completionOnTypeReference(IASTCompletionNode completionNode){ @@ -591,7 +609,7 @@ public class CompletionEngine implements RelevanceConstants { // basic completion on all types completionOnTypeReference(completionNode); } - // TODO: complete the lookups + private void completionOnConstructorReference(IASTCompletionNode completionNode){ // 1. Get the search scope node IASTScope searchNode = completionNode.getCompletionScope(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionRequestorAdaptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionRequestorAdaptor.java index 85e4e5471a4..6a6065cc9c5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionRequestorAdaptor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionRequestorAdaptor.java @@ -10,7 +10,6 @@ ***********************************************************************/ package org.eclipse.cdt.internal.ui.text.contentassist; -import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; public class CompletionRequestorAdaptor implements ICompletionRequestor { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistElementRequestor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistElementRequestor.java index d88b8f9b9c1..ac81f28c6d6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistElementRequestor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistElementRequestor.java @@ -1,17 +1,72 @@ -/* - * Created on Nov 19, 2003 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ +/********************************************************************** + * 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; 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. */ -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); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java index 06050b626cd..4821c5d4b35 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java @@ -26,6 +26,8 @@ public class ContentAssistPreference { //public final static String AUTOACTIVATION= "content_assist_autoactivation"; /** Preference key for content assist auto activation delay */ 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 */ public final static String PROPOSALS_FOREGROUND= "content_assist_proposals_foreground"; //$NON-NLS-1$ /** Preference key for content assist proposal color */ @@ -120,6 +122,7 @@ public class ContentAssistPreference { int delay= store.getInt(AUTOACTIVATION_DELAY); assistant.setAutoActivationDelay(delay); + delay= store.getInt(TIMEOUT_DELAY); Color c1= getColor(store, PROPOSALS_FOREGROUND, manager); assistant.setProposalSelectorForeground(c1); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ICompletionRequestor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ICompletionRequestor.java index bcbe837a3d7..6db43e03620 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ICompletionRequestor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ICompletionRequestor.java @@ -10,7 +10,6 @@ ***********************************************************************/ package org.eclipse.cdt.internal.ui.text.contentassist; -import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; public interface ICompletionRequestor { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/IProblem.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/IProblem.java new file mode 100644 index 00000000000..ee1b3c8d1dc --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/IProblem.java @@ -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(); +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ITimeoutThreadOwner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ITimeoutThreadOwner.java new file mode 100644 index 00000000000..f44b2022c14 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ITimeoutThreadOwner.java @@ -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(); +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/Problem.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/Problem.java new file mode 100644 index 00000000000..2205151dace --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/Problem.java @@ -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; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java index d28ce2fb3b1..2de8b710c64 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java @@ -11,22 +11,22 @@ package org.eclipse.cdt.internal.ui.text.contentassist; public interface RelevanceConstants { - final int CASE_MATCH_RELEVANCE = 1600; - final int EXACT_NAME_MATCH_RELEVANCE = 400; + final int CASE_MATCH_RELEVANCE = 160; + final int EXACT_NAME_MATCH_RELEVANCE = 40; - final int LOCAL_VARIABLE_TYPE_RELEVANCE = 1400; - final int FIELD_TYPE_RELEVANCE = 1300; - final int VARIABLE_TYPE_RELEVANCE = 1200; - final int METHOD_TYPE_RELEVANCE = 1100; - final int FUNCTION_TYPE_RELEVANCE = 1000; - final int CLASS_TYPE_RELEVANCE = 900; - final int STRUCT_TYPE_RELEVANCE = 800; - final int UNION_TYPE_RELEVANCE = 700; - final int TYPEDEF_TYPE_RELEVANCE = 600; - final int NAMESPACE_TYPE_RELEVANCE = 500; - final int MACRO_TYPE_RELEVANCE = 400; - final int ENUMERATION_TYPE_RELEVANCE = 300; - final int ENUMERATOR_TYPE_RELEVANCE = 200; - final int KEYWORD_TYPE_RELEVANCE = 100; + final int LOCAL_VARIABLE_TYPE_RELEVANCE = 140; + final int FIELD_TYPE_RELEVANCE = 130; + final int VARIABLE_TYPE_RELEVANCE = 120; + final int METHOD_TYPE_RELEVANCE = 110; + final int FUNCTION_TYPE_RELEVANCE = 100; + final int CLASS_TYPE_RELEVANCE = 90; + final int STRUCT_TYPE_RELEVANCE = 80; + final int UNION_TYPE_RELEVANCE = 70; + final int TYPEDEF_TYPE_RELEVANCE = 60; + final int NAMESPACE_TYPE_RELEVANCE = 50; + final int MACRO_TYPE_RELEVANCE = 40; + final int ENUMERATION_TYPE_RELEVANCE = 30; + final int ENUMERATOR_TYPE_RELEVANCE = 20; + final int KEYWORD_TYPE_RELEVANCE = 10; final int DEFAULT_TYPE_RELEVANCE = 0; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ResultCollector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ResultCollector.java index 4cec72db29f..c0a72492797 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ResultCollector.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ResultCollector.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist; import java.util.HashSet; import java.util.Set; -import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.internal.ui.CElementImageProvider; import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;