From 53b80f4d7e8f048e6de7c2dbf360e5c7ad1cfbea Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Mon, 10 Sep 2012 11:16:57 -0400 Subject: [PATCH 01/16] Bug 389070: Need to install disabled breakpoints Change-Id: Iedc6bcb29030f8e9d8e05355e53c2d3fddfac3de Reviewed-on: https://git.eclipse.org/r/7700 Reviewed-by: Mikhail Khodjaiants IP-Clean: Mikhail Khodjaiants Tested-by: Mikhail Khodjaiants Reviewed-by: Marc Khouzam IP-Clean: Marc Khouzam Tested-by: Marc Khouzam --- .../dsf/mi/service/MIBreakpointsManager.java | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java index 4a1208b9ebb..010b5d70bcc 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java @@ -431,8 +431,8 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo // Even if the breakpoint is disabled when we start, the target filter // can be accessed by the user through the breakpoint properties UI, so // we must set it right now. - // This is the reason we don't do this in 'installBreakpoint', which is not - // called right away if the breakpoint is disabled. + // This is the reason we don't do this in 'installBreakpoint', which used to not + // be called right away if the breakpoint was disabled (this is no longer the case). try { IContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IContainerDMContext.class); IDsfBreakpointExtension filterExt = getFilterExtension(breakpoint); @@ -444,14 +444,9 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo } catch (CoreException e) { } - // Install only if the breakpoint is enabled at startup (Bug261082) - // Note that Tracepoints are not affected by "skip-all" - boolean bpEnabled = attributes.get(ICBreakpoint.ENABLED).equals(true) && - (breakpoint instanceof ICTracepoint || fBreakpointManager.isEnabled()); - if (bpEnabled) - installBreakpoint(dmc, breakpoint, attributes, countingRm); - else - countingRm.done(); + // Must install breakpoints right away, even if disabled, so that + // we can find out if they apply to this target (Bug 389070) + installBreakpoint(dmc, breakpoint, attributes, countingRm); } }); } @@ -646,6 +641,8 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo // Convert the breakpoint attributes for the back-end attributes.put(ATTR_THREAD_ID, thread); Map targetAttributes = convertToTargetBreakpoint(breakpoint, attributes); + // Must install breakpoint right away, even if disabled, so that + // we can find out if it applies to this target (Bug 389070) fBreakpoints.insertBreakpoint(dmc, targetAttributes, drm); } } @@ -855,15 +852,11 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo return; } - // Check if the breakpoint is installed: it might not have been if it wasn't enabled at startup (Bug261082) - // Or the installation might have failed; in this case, we still try to install it again because + // Check if the breakpoint is installed: + // the installation might have failed; in this case, we try to install it again because // some attribute might have changed which will make the install succeed. if (!breakpointIDs.containsKey(breakpoint) && !targetBPs.containsValue(breakpoint)) { - // Install only if the breakpoint is enabled - // Note that Tracepoints are not affected by "skip-all" - boolean bpEnabled = attributes.get(ICBreakpoint.ENABLED).equals(true) && - (breakpoint instanceof ICTracepoint || fBreakpointManager.isEnabled()); - if (!filtered && bpEnabled) { + if (!filtered) { attributes.put(ATTR_DEBUGGER_PATH, NULL_STRING); attributes.put(ATTR_THREAD_FILTER, extractThreads(dmc, breakpoint)); attributes.put(ATTR_THREAD_ID, NULL_STRING); From 03a3b4109516dfc250092697939081ebfa0717de Mon Sep 17 00:00:00 2001 From: Vivian Kong Date: Mon, 10 Sep 2012 15:27:42 -0400 Subject: [PATCH 02/16] Bug 388243 - [LR parser] ICPPASTConstructorInitializer offsets did not include parentheses --- .../action/cpp/CPPBuildASTParserAction.java | 42 +++++++++++++++---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java index 35f58f474ba..19943bb3c5a 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/cpp/CPPBuildASTParserAction.java @@ -172,12 +172,17 @@ public class CPPBuildASTParserAction extends BuildASTParserAction { public void consumeNewInitializer() { + IASTExpression expr; if(astStack.peek() == null) { // if there is an empty set of parens astStack.pop(); - IASTExpression initializer = nodeFactory.newExpressionList(); - setOffsetAndLength(initializer); - astStack.push(initializer); + expr = nodeFactory.newExpressionList(); + setOffsetAndLength(expr); + } else { + expr = (IASTExpression) astStack.pop(); // may be null } + ICPPASTConstructorInitializer initializer = nodeFactory.newConstructorInitializer(expr); + setOffsetAndLength(initializer); + astStack.push(initializer); } @@ -189,13 +194,13 @@ public class CPPBuildASTParserAction extends BuildASTParserAction { * | dcolon_opt 'new' new_placement_opt '(' type_id ')' new_array_expressions_op new_initializer_opt */ public void consumeExpressionNew(boolean isNewTypeId) { - IASTExpression initializer = (IASTExpression) astStack.pop(); // may be null + ICPPASTConstructorInitializer initializer = (ICPPASTConstructorInitializer) astStack.pop(); // may be null List arrayExpressions = astStack.closeScope(); IASTTypeId typeId = (IASTTypeId) astStack.pop(); IASTExpression placement = (IASTExpression) astStack.pop(); // may be null boolean hasDoubleColon = astStack.pop() != null; - ICPPASTNewExpression newExpression = nodeFactory.newNewExpression(placement, initializer, typeId); + ICPPASTNewExpression newExpression = nodeFactory.newNewExpression(new IASTExpression[] {placement}, initializer, typeId); newExpression.setIsGlobal(hasDoubleColon); newExpression.setIsNewTypeId(isNewTypeId); setOffsetAndLength(newExpression); @@ -1635,9 +1640,30 @@ public class CPPBuildASTParserAction extends BuildASTParserAction { * ::= mem_initializer_id '(' expression_list_opt ')' */ public void consumeConstructorChainInitializer() { - IASTExpression expr = (IASTExpression) astStack.pop(); - IASTName name = (IASTName) astStack.pop(); - ICPPASTConstructorChainInitializer initializer = nodeFactory.newConstructorChainInitializer(name, expr); + Object o = astStack.pop(); + IASTName name = (IASTName) astStack.pop(); + IASTInitializerClause[] initClauseList =null; + if(o instanceof IASTExpressionList){ + initClauseList = ((IASTExpressionList) o).getExpressions(); + }else if(o instanceof IASTInitializerClause){ + initClauseList = new IASTInitializerClause[]{(IASTInitializerClause)o}; + } + ICPPASTConstructorInitializer init = nodeFactory.newConstructorInitializer(initClauseList); + int rule_start_offset = stream.getLeftIToken().getStartOffset(); + int initClauseList_offset = ParserUtil.offset(initClauseList[0]); + List ruleTokens = stream.getRuleTokens(); + int start_offset = -1; + + for (int i = initClauseList_offset, n = rule_start_offset; i >= n; i--){ + if(tokenMap.mapKind(ruleTokens.get(i).getKind()) == TK_LeftParen) { + start_offset = ruleTokens.get(i).getStartOffset(); + break; + } + } + int ruleLength = stream.getRightIToken().getEndOffset() - start_offset; + ParserUtil.setOffsetAndLength(init, start_offset, ruleLength < 0 ? 0 : ruleLength); + + ICPPASTConstructorChainInitializer initializer = nodeFactory.newConstructorChainInitializer(name, init); setOffsetAndLength(initializer); astStack.push(initializer); } From 5c0836124a7725ef41e91a6b340d19e0695f97f4 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Thu, 6 Sep 2012 14:54:06 -0700 Subject: [PATCH 03/16] Cosmetics. --- .../cdt/internal/core/UNCPathConverterImpl.java | 4 ++-- .../org/eclipse/cdt/utils/UNCPathConverter.java | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/UNCPathConverterImpl.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/UNCPathConverterImpl.java index be40ed0dbdb..fea302dd891 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/UNCPathConverterImpl.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/UNCPathConverterImpl.java @@ -53,8 +53,8 @@ public class UNCPathConverterImpl extends UNCPathConverter { for (IConfigurationElement ce : ext.getConfigurationElements()) { if (ce.getAttribute(CLASS_ATTRIBUTE) != null) { try { - UNCPathConverter converter = (UNCPathConverter) ce - .createExecutableExtension(CLASS_ATTRIBUTE); + UNCPathConverter converter = + (UNCPathConverter) ce.createExecutableExtension(CLASS_ATTRIBUTE); list.add(converter); } catch (Exception e) { CCorePlugin.log(e); diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/UNCPathConverter.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/UNCPathConverter.java index 91de1214d5e..783a82a0f9a 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/UNCPathConverter.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/UNCPathConverter.java @@ -19,16 +19,16 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; /** - * Base class for the UNC path conversion extension point. UNC paths are used to represent remote include - * locations, and this class is used to translate between UNC, IPath and URI representations. By default, - * paths are translated into the equivalent local file version to preserve existing behavior, but by providing - * an appropriate extension, these paths can be mapped into locations on a remote system. + * Base class for the UNC path conversion extension point. UNC paths are used to represent remote + * include locations, and this class is used to translate between UNC, IPath and URI + * representations. By default, paths are translated into the equivalent local file version to + * preserve existing behavior, but by providing an appropriate extension, these paths can be mapped + * into locations on a remote system. * * May be subclassed by clients. * @since 5.3 */ public abstract class UNCPathConverter { - /** * Get the instance of the class that combines the registered converters. * @return instance of UNCPathConverter @@ -37,7 +37,6 @@ public abstract class UNCPathConverter { return UNCPathConverterImpl.getInstance(); } - /** * Test if the string path is in UNC format. * @@ -56,7 +55,6 @@ public abstract class UNCPathConverter { return false; } - /** * Convert a URI to an IPath. * Resolves to local path if possible, including using EFS where required. From 59f33be72fcf07ad0fc87d771b72b6ff5d1ab878 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Thu, 6 Sep 2012 15:28:08 -0700 Subject: [PATCH 04/16] Fixed a race condition in setting up path canonicalization strategy. --- .../parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java index 13dbeb38268..1ca4bd01953 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java @@ -211,6 +211,9 @@ public class PDOMManager implements IWritableIndexManager, IListener { public Job startup() { fInShutDown= false; + // Set path canonicalization strategy early on to avoid a race condition. + updatePathCanonicalizationStrategy(); + Job postStartupJob= new Job(CCorePlugin.getResourceString("CCorePlugin.startupJob")) { //$NON-NLS-1$ @Override protected IStatus run(IProgressMonitor monitor) { From fc6b186ee6d5198fca335c3069efdd8d87a0d9ab Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Thu, 6 Sep 2012 15:31:46 -0700 Subject: [PATCH 05/16] Removed unnecessary synchronization. --- .../core/resources/PathCanonicalizationStrategy.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/PathCanonicalizationStrategy.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/PathCanonicalizationStrategy.java index 2ac47ca4ba9..e592fb95ab6 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/PathCanonicalizationStrategy.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/PathCanonicalizationStrategy.java @@ -20,14 +20,14 @@ import java.io.IOException; * symbolic links is undesirable. The default is to use File.getCanonicalPath. */ public abstract class PathCanonicalizationStrategy { - private static PathCanonicalizationStrategy instance; + private static volatile PathCanonicalizationStrategy instance; static { setPathCanonicalization(true); } public static String getCanonicalPath(File file) { - return getInstance().getCanonicalPathInternal(file); + return instance.getCanonicalPathInternal(file); } /** @@ -38,7 +38,7 @@ public abstract class PathCanonicalizationStrategy { * @param canonicalize true to use File.getCanonicalPath, false * to use File.getAbsolutePath. */ - public static synchronized void setPathCanonicalization(boolean canonicalize) { + public static void setPathCanonicalization(boolean canonicalize) { if (canonicalize) { instance = new PathCanonicalizationStrategy() { @Override @@ -60,9 +60,5 @@ public abstract class PathCanonicalizationStrategy { } } - private static synchronized PathCanonicalizationStrategy getInstance() { - return instance; - } - protected abstract String getCanonicalPathInternal(File file); } From 21bec6fcb402d23fd33743a43e7eee79a14b6e07 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Thu, 6 Sep 2012 16:00:06 -0700 Subject: [PATCH 06/16] Adjusted comments. --- .../org/eclipse/cdt/internal/core/pdom/PDOMManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java index 1ca4bd01953..715dbfb1f31 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java @@ -233,9 +233,8 @@ public class PDOMManager implements IWritableIndexManager, IListener { * Called from a job after plugin start. */ protected void postStartup() { - // the model listener is attached outside of the job in - // order to avoid a race condition where its not noticed - // that new projects are being created + // The model listener is attached outside of the job in order to avoid a race condition + // where it is not noticed that new projects are being created. InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).addPreferenceChangeListener(fPreferenceChangeListener); Job.getJobManager().addJobChangeListener(fJobChangeListener); adjustCacheSize(); From 044f754d101b9622ddc6c4872f90ae606adfa13b Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sat, 8 Sep 2012 15:14:09 -0700 Subject: [PATCH 07/16] Cosmetics. --- .../cdt/internal/core/index/IIndexFragmentInclude.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentInclude.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentInclude.java index e17e70ad6d4..f6c73bbc0fb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentInclude.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragmentInclude.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.internal.core.index; import org.eclipse.cdt.core.index.IIndexInclude; @@ -19,7 +18,7 @@ public interface IIndexFragmentInclude extends IIndexInclude { * Empty array constant * @since 4.0.1 */ - IIndexFragmentInclude[] EMPTY_FRAGMENT_INCLUDES_ARRAY = new IIndexFragmentInclude[0]; + IIndexFragmentInclude[] EMPTY_FRAGMENT_INCLUDES_ARRAY = {}; /** * Returns the fragment that owns this include. From bc11a19cbc32ade1bee22acc90c0d39edcecbbfd Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Wed, 12 Sep 2012 12:18:32 -0700 Subject: [PATCH 08/16] JavaDoc adjustments. --- .../org/eclipse/cdt/core/index/IIndex.java | 72 ++++++++++--------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java index bb4c413ac5c..50241604c1b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java @@ -69,7 +69,8 @@ public interface IIndex { */ final int FIND_DECLARATIONS_DEFINITIONS = FIND_DECLARATIONS | FIND_DEFINITIONS; /** - * Constant to search for all occurrences of a binding. This includes declarations, definitions and references. + * Constant to search for all occurrences of a binding. This includes declarations, definitions + * and references. */ final int FIND_ALL_OCCURRENCES = FIND_DECLARATIONS | FIND_DEFINITIONS | FIND_REFERENCES; @@ -95,7 +96,7 @@ public interface IIndex { public void releaseReadLock(); /** - * @return true if there are threads waiting for read locks. + * @return {@code true} if there are threads waiting for read locks. * @since 5.2 */ public boolean hasWaitingReaders(); @@ -131,13 +132,13 @@ public interface IIndex { public long getLastWriteAccess(); /** - * Returns the file object for the given location and linkage or null if the file + * Returns the file object for the given location and linkage or {@code null} if the file * was not indexed in this linkage. *

* When a header file is stored in the index in multiple variants for different sets of macro * definitions, this method will return an arbitrary one of these variants. * @param location an IIndexFileLocation representing the location of the file - * @return the file in the index or null + * @return the file in the index or {@code null} * @throws CoreException * @deprecated Use {@link #getFile(int, IIndexFileLocation, ISignificantMacros)} or * {@link #getFiles(int, IIndexFileLocation)}. @@ -147,13 +148,13 @@ public interface IIndex { /** * Returns the file for the given location, linkage, and significant macros - * May return null, if no such file exists. + * May return {@code null}, if no such file exists. * * @param linkageID the id of the linkage in which the file has been parsed. * @param location the IIndexFileLocation representing the location of the file * @param macroDictionary The names and definitions of the macros used to disambiguate between * variants of the file contents corresponding to different inclusion points. - * @return the file for the location, or null if the file is not present in + * @return the file for the location, or {@code null} if the file is not present in * the index * @throws CoreException * @since 5.4 @@ -223,13 +224,13 @@ public interface IIndex { public IIndexInclude[] findIncludedBy(IIndexFile file, int depth) throws CoreException; /** - * Resolves the file that is included by the given include directive. May return null + * Resolves the file that is included by the given include directive. May return {@code null} * in case the file cannot be found. This is usually more efficient than using: *

-	 * getFile(include.getIncludesLocation())
+	 * getFiles(include.getIncludesLocation())
 	 * 
* @param include - * @return the file included or null. + * @return the file included or {@code null}. * @throws CoreException * @since 4.0 */ @@ -240,7 +241,7 @@ public interface IIndex { * * @param name a name, that has to be matched by the macros. * @param filter a filter that allows for skipping parts of the index - * @param monitor a monitor to report progress, may be null. + * @param monitor a monitor to report progress, may be {@code null}. * @return an array of macros matching the name. * @throws CoreException * @since 4.0.2 @@ -252,7 +253,7 @@ public interface IIndex { * * @param prefix the prefix with which all returned macros must start * @param filter a filter that allows for skipping parts of the index - * @param monitor a monitor for progress reporting and cancellation, may be null + * @param monitor a monitor for progress reporting and cancellation, may be {@code null} * @return an array of bindings with the prefix * @throws CoreException * @since 4.0.2 @@ -261,16 +262,16 @@ public interface IIndex { /** * Searches for the binding of a name. The name may be originated by - * an AST or by a search in an index. May return null. + * an AST or by a search in an index. May return {@code null}. * @param name a name to find the binding for - * @return the binding or null + * @return the binding or {@code null} * @throws CoreException */ public IIndexBinding findBinding(IName name) throws CoreException; /** - * Searches for all bindings with simple names that match the given pattern. In case a binding exists - * in multiple projects, no duplicate bindings are returned. + * Searches for all bindings with simple names that match the given pattern. In case a binding + * exists in multiple projects, no duplicate bindings are returned. * This is fully equivalent to *
 	 * findBindings(new Pattern[]{pattern}, isFullyQualified, filter, monitor);
@@ -278,20 +279,23 @@ public interface IIndex {
 	 * @param pattern the pattern the name of the binding has to match.
 	 * @param isFullyQualified if true, binding must be in global scope
 	 * @param filter a filter that allows for skipping parts of the index
-	 * @param monitor a monitor to report progress, may be null.
+	 * @param monitor a monitor to report progress, may be {@code null}.
 	 * @return an array of bindings matching the pattern
 	 * @throws CoreException
 	 */
 	public IIndexBinding[] findBindings(Pattern pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
 
 	/**
-	 * Searches for all bindings with qualified names that seen as an array of simple names match the given array
-	 * of patterns. In case a binding exists in multiple projects, no duplicate bindings are returned.
-	 * You can search with an array of patterns that specifies a partial qualification only.
-	 * @param patterns an array of patterns the names of the qualified name of the bindings have to match.
-	 * @param isFullyQualified if true, the array of pattern specifies the fully qualified name
+	 * Searches for all bindings with qualified names that seen as an array of simple names match
+	 * the given array of patterns. In case a binding exists in multiple projects, no duplicate
+	 * bindings are returned. You can search with an array of patterns that specifies a partial
+	 * qualification only.
+	 * @param patterns an array of patterns the names of the qualified name of the bindings
+	 *     have to match.
+	 * @param isFullyQualified if true, the array of pattern specifies the fully
+	 *     qualified name
 	 * @param filter a filter that allows for skipping parts of the index
-	 * @param monitor a monitor to report progress, may be null.
+	 * @param monitor a monitor to report progress, may be {@code null}.
 	 * @return an array of bindings matching the pattern
 	 * @throws CoreException
 	 */
@@ -299,23 +303,25 @@ public interface IIndex {
 
 	/**
 	 * Searches for all macro containers (one for macros with the same name) with names that
-	 * match the given pattern. In case a binding exists in multiple projects, no duplicate bindings
-	 * are returned.
+	 * match the given pattern. In case a binding exists in multiple projects, no duplicate
+	 * bindings are returned.
 	 * @param pattern a pattern the name of the bindings have to match.
 	 * @param filter a filter that allows for skipping parts of the index
-	 * @param monitor a monitor to report progress, may be null
+	 * @param monitor a monitor to report progress, may be {@code null}
 	 * @return an array of bindings matching the pattern
 	 * @throws CoreException
 	 */
 	IIndexBinding[] findMacroContainers(Pattern pattern, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
 
 	/**
-	 * Searches for all bindings in global scope with a given name. In case a binding exists in multiple projects, no duplicate bindings are returned.
-	 * This method makes use of the BTree and is faster than the methods using patterns.
+	 * Searches for all bindings in global scope with a given name. In case a binding exists in
+	 * multiple projects, no duplicate bindings are returned. This method makes use of the BTree
+	 * and is faster than the methods using patterns.
 	 * 

- * @param names an array of names, which has to be matched by the qualified name of the bindings. + * @param names an array of names, which has to be matched by the qualified name of + * the bindings. * @param filter a filter that allows for skipping parts of the index - * @param monitor a monitor to report progress, may be null. + * @param monitor a monitor to report progress, may be {@code null}. * @return an array of bindings matching the pattern * @throws CoreException */ @@ -332,7 +338,7 @@ public interface IIndex { *

* @param name a name, which has to be matched by the qualified name of the bindings. * @param filter a filter that allows for skipping parts of the index - * @param monitor a monitor to report progress, may be null. + * @param monitor a monitor to report progress, may be {@code null}. * @return an array of bindings matching the pattern * @throws CoreException */ @@ -346,7 +352,7 @@ public interface IIndex { * @param name a name, which has to be matched by the qualified name of the bindings. * @param fileScopeOnly if true, only bindings at file scope are returned * @param filter a filter that allows for skipping parts of the index - * @param monitor a monitor to report progress, may be null. + * @param monitor a monitor to report progress, may be {@code null}. * @return an array of bindings matching the pattern * @throws CoreException */ @@ -357,7 +363,7 @@ public interface IIndex { * @param prefix the prefix with which all returned bindings must start * @param fileScopeOnly if true, only bindings at file scope are returned * @param filter a filter that allows for skipping parts of the index - * @param monitor a monitor for progress reporting and cancellation, may be null + * @param monitor a monitor for progress reporting and cancellation, may be {@code null} * @return an array of bindings with the prefix * @throws CoreException */ @@ -444,7 +450,7 @@ public interface IIndex { public IIndexFile[] getDefectiveFiles() throws CoreException; /** - * Returns an array of files containg unresolved includes. + * Returns an array of files containing unresolved includes. * @noreference This method is not intended to be referenced by clients. * @since 5.4 */ From eb8f1b49ea2322619f010324a2a47d26d55e2026 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Wed, 12 Sep 2012 18:48:21 -0700 Subject: [PATCH 09/16] Cosmetics. --- .../dom/ast/cpp/ICPPASTSimpleTypeTemplateParameter.java | 5 ++--- .../cdt/core/dom/ast/cpp/ICPPASTTemplateParameter.java | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeTemplateParameter.java index 34ccc93a17d..9a0eb46c548 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTSimpleTypeTemplateParameter.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * John Camelon (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTSimpleTypeTemplateParameter extends ICPPASTTemplateParameter, IASTNameOwner { - /** * Relation between template parameter and its name. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateParameter.java index d1e4a69d408..37ef185632f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateParameter.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * John Camelon (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTTemplateParameter extends IASTNode { - public static final ICPPASTTemplateParameter[] EMPTY_TEMPLATEPARAMETER_ARRAY = new ICPPASTTemplateParameter[0]; + public static final ICPPASTTemplateParameter[] EMPTY_TEMPLATEPARAMETER_ARRAY = {}; /** * Returns whether this template parameter is a parameter pack. From 857973df82596da3e365de6f17f45c365fa45eac Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Thu, 13 Sep 2012 16:22:47 +0200 Subject: [PATCH 10/16] Bug 372587: Argument deduction for function call. --- .../cdt/internal/core/model/BinaryRunner.java | 15 ++-- .../dom/ast/cpp/ICPPTemplateArgument.java | 9 +++ .../cdt/internal/core/dom/parser/Value.java | 2 +- .../CPPASTConstructorChainInitializer.java | 1 - .../cpp/CPPASTFunctionCallExpression.java | 2 +- .../cpp/CPPTemplateNonTypeArgument.java | 9 +-- .../parser/cpp/CPPTemplateTypeArgument.java | 5 ++ .../parser/cpp/semantics/CPPEvaluation.java | 5 +- .../parser/cpp/semantics/CPPTemplates.java | 72 ++++++++++++------- .../dom/parser/cpp/semantics/EvalBinding.java | 5 +- .../dom/parser/cpp/semantics/EvalUnary.java | 3 + .../parser/cpp/semantics/SemanticUtil.java | 3 + .../semantics/TemplateArgumentDeduction.java | 17 ++++- .../composite/cpp/TemplateInstanceUtil.java | 8 ++- .../core/pdom/db/TypeMarshalBuffer.java | 4 +- 15 files changed, 106 insertions(+), 54 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java index 30b68f9d52e..1b693dab40d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryRunner.java @@ -65,11 +65,10 @@ public class BinaryRunner { ICElement root = factory.getCModel(); CElementDelta cdelta = new CElementDelta(root); cdelta.changed(cproj, ICElementDelta.F_CONTENT); - for (int j = 0; j < containers.length; ++j) { + for (IParent container : containers) { if (fMonitor.isCanceled()) { return; } - IParent container = containers[j]; ICElement[] children = container.getChildren(); if (children.length > 0) { cdelta.added((ICElement)container); @@ -171,9 +170,9 @@ public class BinaryRunner { } private class Visitor implements IResourceProxyVisitor { - private IProgressMonitor vMonitor; - private IProject project; - private IContentType textContentType; + private final IProgressMonitor vMonitor; + private final IProject project; + private final IContentType textContentType; public Visitor(IProgressMonitor monitor) { vMonitor = monitor; @@ -200,7 +199,7 @@ public class BinaryRunner { // check against known content types // if the file has an extension String name = proxy.getName(); - if (name.contains(".")) { + if (name.contains(".")) { //$NON-NLS-1$ IContentType contentType = CCorePlugin.getContentType(project, name); if (contentType != null && textContentType != null) { if (contentType.isKindOf(textContentType)) { @@ -217,8 +216,8 @@ public class BinaryRunner { // we have a candidate IPath path = proxy.requestFullPath(); if (path != null) { - for (int i = 0; i < entries.length; ++i) { - if (isOnOutputEntry(entries[i], path)) { + for (IOutputEntry entrie : entries) { + if (isOnOutputEntry(entrie, path)) { IFile file = (IFile) proxy.requestResource(); CModelManager factory = CModelManager.getDefault(); IBinaryFile bin = factory.createBinaryFile(file); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateArgument.java index a4aa4fb9c77..98f32777a92 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateArgument.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateArgument.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.core.dom.ast.cpp; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; /** * Models the value of a template parameter or for the argument of a template-id. @@ -42,6 +43,14 @@ public interface ICPPTemplateArgument { */ IType getTypeValue(); + /** + * If this is a non-type value (suitable for a template non-type parameters), + * the evaluation object is returned. + * For type values, null is returned. + * @noreference This method is not intended to be referenced by clients. + */ + ICPPEvaluation getNonTypeEvaluation(); + /** * If this is a non-type value (suitable for a template non-type parameters), * the value is returned. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java index da4a20f4cdb..8fb39d3c2e7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java @@ -370,7 +370,7 @@ public class Value implements IValue { * Tests whether the value depends on a template parameter. */ public static boolean isDependentValue(IValue nonTypeValue) { - return nonTypeValue.getEvaluation() != null; + return nonTypeValue != null && nonTypeValue.getEvaluation() != null; } /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java index 60e3b2a1a4c..e99fbcd791a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConstructorChainInitializer.java @@ -35,7 +35,6 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.CharArraySet; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; -import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; /** * For example in the constructor definition
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java index cf551dd59ef..b4dbc11f2a5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java @@ -312,7 +312,7 @@ public class CPPASTFunctionCallExpression extends ASTNode IBinding b= name.resolvePreBinding(); if (b instanceof IType) { ICPPEvaluation[] args= new ICPPEvaluation[fArguments.length]; - for (int i = 1; i < args.length; i++) { + for (int i = 0; i < args.length; i++) { args[i]= ((ICPPASTExpression) fArguments[i]).getEvaluation(); } return new EvalTypeId((IType) b, args); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java index 3c095d5db00..fdc43248ec6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java @@ -51,6 +51,11 @@ public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument { return null; } + @Override + public ICPPEvaluation getNonTypeEvaluation() { + return fEvaluation; + } + @Override public IValue getNonTypeValue() { return fEvaluation.getValue(null); @@ -94,8 +99,4 @@ public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument { public String toString() { return getNonTypeValue().toString(); } - - public ICPPEvaluation getEvaluation() { - return fEvaluation; - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeArgument.java index 7ec0f62f798..c8c7bc02aca 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeArgument.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeArgument.java @@ -43,6 +43,11 @@ public class CPPTemplateTypeArgument implements ICPPTemplateArgument { return fType; } + @Override + public ICPPEvaluation getNonTypeEvaluation() { + return null; + } + @Override public IValue getNonTypeValue() { return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java index 8c2d30ed54c..9c87b033846 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java @@ -27,7 +27,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ISerializableType; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.Value; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.core.runtime.CoreException; @@ -112,9 +111,9 @@ public abstract class CPPEvaluation implements ICPPEvaluation { @Override public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException { - if (arg instanceof CPPTemplateNonTypeArgument) { + if (arg.isNonTypeValue()) { putByte(VALUE); - ((CPPTemplateNonTypeArgument) arg).getEvaluation().marshal(this, true); + arg.getNonTypeEvaluation().marshal(this, true); } else { marshalType(arg.getTypeValue()); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 122590d4731..662330216c1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -29,7 +29,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; -import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory; import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; @@ -44,6 +43,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunctionType; +import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IScope; @@ -56,6 +56,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBas import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; @@ -1074,13 +1075,11 @@ public class CPPTemplates { if (arg == null) return null; if (arg.isNonTypeValue()) { - final IValue origValue= arg.getNonTypeValue(); - final IType origType= arg.getTypeOfNonTypeValue(); - final IValue instValue= instantiateValue(origValue, tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point); - final IType instType= instantiateType(origType, tpMap, packOffset, within, point); - if (origType == instType && origValue == instValue) + final ICPPEvaluation eval = arg.getNonTypeEvaluation(); + final ICPPEvaluation newEval= eval.instantiate(tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point); + if (eval == newEval) return arg; - return new CPPTemplateNonTypeArgument(instValue, instType); + return new CPPTemplateNonTypeArgument(newEval); } final IType orig= arg.getTypeValue(); @@ -1676,11 +1675,9 @@ public class CPPTemplates { IASTNode arg= args[i]; if (arg instanceof IASTTypeId) { result[i]= new CPPTemplateTypeArgument(CPPVisitor.createType((IASTTypeId) arg)); - } else if (arg instanceof IASTExpression) { - IASTExpression expr= (IASTExpression) arg; - IType type= expr.getExpressionType(); - IValue value= Value.create((IASTExpression) arg, Value.MAX_RECURSION_DEPTH); - result[i]= new CPPTemplateNonTypeArgument(value, type); + } else if (arg instanceof ICPPASTExpression) { + ICPPASTExpression expr= (ICPPASTExpression) arg; + result[i]= new CPPTemplateNonTypeArgument(expr.getEvaluation()); } else { throw new IllegalArgumentException("Unexpected type: " + arg.getClass().getName()); //$NON-NLS-1$ } @@ -2190,11 +2187,11 @@ public class CPPTemplates { if (map != null && pType != null) { pType= instantiateType(pType, map, -1, null, point); } - if (argType instanceof ICPPUnknownType || argType instanceof ISemanticProblem || isNonTypeArgumentConvertible(pType, argType, point)) { + + if (argType instanceof ICPPUnknownType) { return new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), pType); } - return null; - + return convertNonTypeTemplateArgument(pType, arg, point); } catch (DOMException e) { return null; } @@ -2257,22 +2254,45 @@ public class CPPTemplates { } /** - * Returns whether the template argument arg can be converted to - * the same type as paramType using the rules specified in 14.3.2.5. - * @param paramType - * @param arg - * @return + * Converts the template argument arg to match the parameter type + * paramType or returns null, if this violates the rules + * specified in 14.3.2 - 5. * @throws DOMException */ - private static boolean isNonTypeArgumentConvertible(IType paramType, IType arg, IASTNode point) throws DOMException { + private static ICPPTemplateArgument convertNonTypeTemplateArgument(final IType paramType, ICPPTemplateArgument arg, IASTNode point) throws DOMException { //14.1s8 function to pointer and array to pointer conversions + IType a= arg.getTypeOfNonTypeValue(); + IType p; if (paramType instanceof IFunctionType) { - paramType = new CPPPointerType(paramType); + p = new CPPPointerType(paramType); } else if (paramType instanceof IArrayType) { - paramType = new CPPPointerType(((IArrayType) paramType).getType()); + p = new CPPPointerType(((IArrayType) paramType).getType()); + } else { + p= paramType; + if (p.isSameType(a)) + return arg; } - Cost cost = Conversions.checkImplicitConversionSequence(paramType, arg, LVALUE, UDCMode.FORBIDDEN, Context.ORDINARY, point); - return cost != null && cost.converts(); + + if (a instanceof FunctionSetType) { + if (p instanceof IPointerType) { + p= ((IPointerType) p).getType(); + } + if (p instanceof IFunctionType) { + final CPPFunctionSet functionSet = ((FunctionSetType) a).getFunctionSet(); + for (ICPPFunction f : functionSet.getBindings()) { + if (p.isSameType(f.getType())) { + functionSet.applySelectedFunction(f); + return new CPPTemplateNonTypeArgument(new EvalBinding(f, null)); + } + } + } + return null; + } + Cost cost = Conversions.checkImplicitConversionSequence(p, a, LVALUE, UDCMode.FORBIDDEN, Context.ORDINARY, point); + if (cost == null || !cost.converts()) + return null; + + return new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), paramType); } static boolean argsAreTrivial(ICPPTemplateParameter[] pars, ICPPTemplateArgument[] args) { @@ -2320,7 +2340,7 @@ public class CPPTemplates { if (arg.isTypeValue()) return isDependentType(arg.getTypeValue()); - return Value.isDependentValue(arg.getNonTypeValue()); + return arg.getNonTypeEvaluation().isValueDependent(); } public static boolean containsDependentType(List ts) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java index fbb50500da8..dbd8c1296a8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java @@ -223,9 +223,8 @@ public class EvalBinding extends CPPEvaluation { return new EvalFixed(type, ValueCategory.PRVALUE, value); } else if (fBinding instanceof ICPPTemplateNonTypeParameter) { ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) fBinding); - if (argument != null) { - IValue value = argument.getNonTypeValue(); - return new EvalFixed(null, ValueCategory.PRVALUE, value); + if (argument != null && argument.isNonTypeValue()) { + return argument.getNonTypeEvaluation(); } // TODO(sprigogin): Do we need something similar for pack expansion? } else if (fBinding instanceof ICPPUnknownBinding) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java index 97632357044..6b287f62b1f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java @@ -238,6 +238,9 @@ public class EvalUnary extends CPPEvaluation { } IValue val = fArgument.getValue(point); + if (val == null) + return Value.UNKNOWN; + Long num = val.numericalValue(); if (num != null) { return Value.evaluateUnaryExpression(fOperator, num); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java index 3d9dadf4b01..9de29a630bb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SemanticUtil.java @@ -437,6 +437,9 @@ public class SemanticUtil { } public static IType mapToAST(IType type, IASTNode node) { + if (node == null) + return type; + if (type instanceof IFunctionType) { final ICPPFunctionType ft = (ICPPFunctionType) type; final IType r = ft.getReturnType(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java index 14d895b84ae..e921895e1fb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java @@ -54,6 +54,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter; import org.eclipse.cdt.internal.core.dom.parser.Value; @@ -185,6 +186,20 @@ public class TemplateArgumentDeduction { if (!map.addDeducedArgs(deduct.fDeducedArgs)) return false; + // 14.8.2.5 - 17 + for (ICPPTemplateParameter tpar : tmplPars) { + if (tpar instanceof ICPPTemplateNonTypeParameter) { + ICPPTemplateArgument arg = deduct.fDeducedArgs.getArgument(tpar); + if (arg != null) { + IType type1 = ((ICPPTemplateNonTypeParameter) tpar).getType(); + type1= CPPTemplates.instantiateType(type1, map, -1, null, point); + IType type2= arg.getTypeOfNonTypeValue(); + if (!type1.isSameType(type2)) + return false; + } + } + } + return verifyDeduction(tmplPars, map, true, point); } catch (DOMException e) { } @@ -649,8 +664,6 @@ public class TemplateArgumentDeduction { if (Value.referencesTemplateParameter(tval)) { int parId= Value.isTemplateParameter(tval); if (parId >= 0) { - if (!p.getTypeOfNonTypeValue().isSameType(a.getTypeOfNonTypeValue())) - return false; ICPPTemplateArgument old= fDeducedArgs.getArgument(parId, fPackOffset); if (old == null) { return deduce(parId, a); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java index 06cc8f1fc69..caae733da88 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java @@ -93,14 +93,16 @@ public class TemplateInstanceUtil { } static ICPPTemplateArgument convert(ICompositesFactory cf, ICPPTemplateArgument arg) throws DOMException { - if (arg instanceof CPPTemplateTypeArgument) { + if (arg == null) + return null; + if (arg.isTypeValue()) { final IType typeValue = arg.getTypeValue(); IType t= cf.getCompositeType(typeValue); if (t != typeValue) { return new CPPTemplateTypeArgument(t); } - } else if (arg instanceof CPPTemplateNonTypeArgument) { - ICPPEvaluation eval = ((CPPTemplateNonTypeArgument) arg).getEvaluation(); + } else { + ICPPEvaluation eval = arg.getNonTypeEvaluation(); ICPPEvaluation eval2 = ((CPPCompositesFactory) cf).getCompositeEvaluation(eval); if (eval2 != eval) { return new CPPTemplateNonTypeArgument(eval2); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java index b3e7656fca4..4abb48cee0c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java @@ -189,9 +189,9 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { @Override public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException { - if (arg instanceof CPPTemplateNonTypeArgument) { + if (arg.isNonTypeValue()) { putByte(VALUE); - ((CPPTemplateNonTypeArgument) arg).getEvaluation().marshal(this, true); + arg.getNonTypeEvaluation().marshal(this, true); } else { marshalType(arg.getTypeValue()); } From 0a9773666e337ac2e04ac52303a7671259a6253a Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Thu, 13 Sep 2012 16:39:12 +0200 Subject: [PATCH 11/16] Bug 372587: Testcase. --- .../parser/tests/ast2/AST2TemplateTests.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 2f54ed2d440..0bc7d6659da 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -6011,4 +6011,27 @@ public class AST2TemplateTests extends AST2BaseTest { public void testIsPOD_367993() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, true); } + + // template class A { + // public: + // static void Delegate(void* thiz) { ((T*)thiz->*M)(); } + // }; + // class B { + // public: + // void Method() {} + // }; + // class C { + // public: + // template + // void callDelegate(A& thiz) { A::Delegate(&thiz); } + // }; + // void Run() { + // C c; + // B b; + // A a; /* no error this line */ + // c.callDelegate(a); /* Invalid arguments 'Candidates are: void callDelegate(A<#0,#1> &)' */ + // } + public void testDeductionOfNonTypeTemplateArg_372587() throws Exception { + parseAndCheckBindings(getAboveComment(), CPP, true); + } } From c35d8851b950033154960a3ae16d3fba99f65611 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 13 Sep 2012 11:14:41 -0400 Subject: [PATCH 12/16] Bug 389518: Simplify GDB traces preference Change-Id: If767cbf1b54b4820cf5d5e6ff06c58b10f72e598 Reviewed-on: https://git.eclipse.org/r/7746 Reviewed-by: Mikhail Khodjaiants IP-Clean: Mikhail Khodjaiants Tested-by: Mikhail Khodjaiants Reviewed-by: Marc Khouzam IP-Clean: Marc Khouzam Tested-by: Marc Khouzam --- .../preferences/GdbDebugPreferencePage.java | 41 +++---------------- .../preferences/MessagesForPreferences.java | 2 - .../MessagesForPreferences.properties | 3 +- 3 files changed, 6 insertions(+), 40 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java index 5addf84a8c3..fdc136c9ac6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java @@ -580,20 +580,6 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements enableStopAtMain.fillIntoGrid(group1, 3); addField(enableStopAtMain); -// final StringFieldEditor stopAtMainSymbol = new StringFieldEditor( -// IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL, -// "", group1); //$NON-NLS-1$ -// stopAtMainSymbol.fillIntoGrid(group1, 2); -// addField(stopAtMainSymbol); -// -// enableStopAtMain.getChangeControl(group1).addSelectionListener(new SelectionAdapter() { -// @Override -// public void widgetSelected(SelectionEvent e) { -// boolean enabled = enableStopAtMain.getBooleanValue(); -// stopAtMainSymbol.setEnabled(enabled, group1); -// } -// }); - fCommandTimeoutField = new IntegerWithBooleanFieldEditor( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, @@ -659,33 +645,16 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements // Need to set layout again. group2.setLayout(groupLayout); - final ListenableBooleanFieldEditor enableGdbTracesField = new ListenableBooleanFieldEditor( + final IntegerWithBooleanFieldEditor enableGdbTracesField = new IntegerWithBooleanFieldEditor( IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE, - MessagesForPreferences.GdbDebugPreferencePage_enableTraces_label, - SWT.NONE, group2); - - enableGdbTracesField.fillIntoGrid(group2, 3); - addField(enableGdbTracesField); - - final IntegerFieldEditor maxCharactersField = new IntegerFieldEditor( IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES, - MessagesForPreferences.GdbDebugPreferencePage_maxGdbTraces_label, + MessagesForPreferences.GdbDebugPreferencePage_enableTraces_label, group2); // Instead of using Integer.MAX_VALUE which is some obscure number, // using 2 billion is nice and readable. - maxCharactersField.setValidRange(10000, 2000000000); - - maxCharactersField.fillIntoGrid(group2, 3); - addField(maxCharactersField); - - enableGdbTracesField.getChangeControl(group2).addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - boolean enabled = enableGdbTracesField.getBooleanValue(); - maxCharactersField.setEnabled(enabled, group2); - } - }); - + enableGdbTracesField.setValidRange(10000, 2000000000); + enableGdbTracesField.fillIntoGrid(group2, 2); + addField(enableGdbTracesField); // Need to set layout again. group2.setLayout(groupLayout); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java index 39f8c012e09..105a25caded 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java @@ -29,8 +29,6 @@ class MessagesForPreferences extends NLS { /** @since 2.3 */ public static String GdbDebugPreferencePage_general_behavior_label; public static String GdbDebugPreferencePage_enableTraces_label; - /** @since 2.2 */ - public static String GdbDebugPreferencePage_maxGdbTraces_label; public static String GdbDebugPreferencePage_autoTerminateGdb_label; public static String GdbDebugPreferencePage_Browse_button; public static String GdbDebugPreferencePage_Command_column_name; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties index b9d448bab57..9b22d8b9e9c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties @@ -16,8 +16,7 @@ GdbDebugPreferencePage_Add_button=Add GdbDebugPreferencePage_description=General settings for GDB Debugging GdbDebugPreferencePage_general_behavior_label=General Behavior -GdbDebugPreferencePage_enableTraces_label=Enable GDB traces -GdbDebugPreferencePage_maxGdbTraces_label=Limit GDB traces output (number of characters): +GdbDebugPreferencePage_enableTraces_label=Enable GDB traces with character limit: GdbDebugPreferencePage_autoTerminateGdb_label=Terminate GDB when last process exits GdbDebugPreferencePage_Command_column_name=GDB/MI Command GdbDebugPreferencePage_Command_field_can_not_be_empty='Command' field can not be empty From 983d057df183d80ce83264b1025531ae08e9bfd4 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 13 Sep 2012 13:21:13 -0400 Subject: [PATCH 13/16] Bug 389518: Simplify DSF-GDB preferences page Change-Id: Iaafc2acaaeb36a825584db7bea08dd179e4ab9a6 Reviewed-on: https://git.eclipse.org/r/7750 Reviewed-by: Mikhail Khodjaiants IP-Clean: Mikhail Khodjaiants Tested-by: Mikhail Khodjaiants Reviewed-by: Marc Khouzam IP-Clean: Marc Khouzam Tested-by: Marc Khouzam --- .../preferences/GdbDebugPreferencePage.java | 28 ++++++++----------- .../preferences/MessagesForPreferences.java | 2 -- .../MessagesForPreferences.properties | 5 ++-- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java index fdc136c9ac6..0f2dbc62618 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java @@ -658,6 +658,17 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements // Need to set layout again. group2.setLayout(groupLayout); + boolField= new BooleanFieldEditor( + IGdbDebugPreferenceConstants.PREF_USE_RTTI, + MessagesForPreferences.GdbDebugPreferencePage_use_rtti_label1 + "\n" //$NON-NLS-1$ + + MessagesForPreferences.GdbDebugPreferencePage_use_rtti_label2, + group2); + + boolField.fillIntoGrid(group2, 3); + addField(boolField); + // need to set layout again + group2.setLayout(groupLayout); + Group group = new Group(parent, SWT.NONE); group.setText(MessagesForPreferences.GdbDebugPreferencePage_prettyPrinting_label); groupLayout = new GridLayout(3, false); @@ -702,23 +713,6 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements } }); - group= new Group(parent, SWT.NONE); - group.setText(MessagesForPreferences.GdbDebugPreferencePage_rtti_label); - groupLayout= new GridLayout(3, false); - group.setLayout(groupLayout); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - boolField= new BooleanFieldEditor( - IGdbDebugPreferenceConstants.PREF_USE_RTTI, - MessagesForPreferences.GdbDebugPreferencePage_use_rtti_label1 + "\n" //$NON-NLS-1$ - + MessagesForPreferences.GdbDebugPreferencePage_use_rtti_label2, - group); - - boolField.fillIntoGrid(group, 3); - addField(boolField); - // need to set layout again - group.setLayout(groupLayout); - // need to set layouts again indentHelper.setLayout(helperLayout); group.setLayout(groupLayout); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java index 105a25caded..fe43d6cf09c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java @@ -56,8 +56,6 @@ class MessagesForPreferences extends NLS { public static String GdbDebugPreferencePage_Non_stop_mode; public static String GdbDebugPreferencePage_Timeout_column_name; public static String GdbDebugPreferencePage_Timeout_value_can_not_be_negative; - /** @since 2.3 */ - public static String GdbDebugPreferencePage_rtti_label; public static String GdbDebugPreferencePage_Stop_on_startup_at; /** @since 2.3 */ public static String GdbDebugPreferencePage_use_rtti_label1; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties index 9b22d8b9e9c..85c62111b46 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties @@ -28,12 +28,11 @@ GdbDebugPreferencePage_hideRunningThreads=Show only suspended threads in the Deb GdbDebugPreferencePage_prettyPrinting_label=Pretty Printing GdbDebugPreferencePage_enablePrettyPrinting_label1=Enable pretty printers in variable/expression tree -GdbDebugPreferencePage_enablePrettyPrinting_label2=(requires python-enabled GDB) +GdbDebugPreferencePage_enablePrettyPrinting_label2=(Note: requires python-enabled GDB) GdbDebugPreferencePage_initialChildCountLimitForCollections_label=For collections, initially limit child count to -GdbDebugPreferencePage_rtti_label=Run-time type information GdbDebugPreferencePage_use_rtti_label1=Display run-time type of variables -GdbDebugPreferencePage_use_rtti_label2=(requires GDB 7.5 or higher) +GdbDebugPreferencePage_use_rtti_label2=(Note: requires GDB 7.5 or higher) GdbDebugPreferencePage_defaults_label=Debug Configurations Defaults GdbDebugPreferencePage_Delete_button=Delete From 9cdef8c443cdfc90ab09795cfaff9d0e43ac3242 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Fri, 14 Sep 2012 07:18:06 +0200 Subject: [PATCH 14/16] Bug 299911: Directly marshall template arguments rather than their type and value. --- .../cpp/CPPTemplateNonTypeArgument.java | 13 +++- .../parser/cpp/semantics/CPPTemplates.java | 6 +- .../composite/cpp/TemplateInstanceUtil.java | 2 +- .../eclipse/cdt/internal/core/pdom/PDOM.java | 7 ++- .../cdt/internal/core/pdom/db/Database.java | 1 + .../core/pdom/db/TypeMarshalBuffer.java | 2 +- .../internal/core/pdom/dom/PDOMLinkage.java | 63 +++++++++++++++++++ .../pdom/dom/cpp/PDOMCPPArgumentList.java | 30 +++------ .../cpp/PDOMCPPTemplateNonTypeParameter.java | 4 +- .../dom/cpp/PDOMCPPTemplateParameterMap.java | 30 ++------- 10 files changed, 98 insertions(+), 60 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java index fdc43248ec6..b81b6eb4eab 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType; @@ -27,9 +28,15 @@ import org.eclipse.core.runtime.Assert; public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument { private final ICPPEvaluation fEvaluation; - public CPPTemplateNonTypeArgument(ICPPEvaluation evaluation) { + public CPPTemplateNonTypeArgument(ICPPEvaluation evaluation, IASTNode point) { Assert.isNotNull(evaluation); - fEvaluation= evaluation; + if (evaluation instanceof EvalFixed || point == null || + evaluation.isTypeDependent() || evaluation.isValueDependent()) { + fEvaluation= evaluation; + } else { + fEvaluation= new EvalFixed(evaluation.getTypeOrFunctionSet(point), + evaluation.getValueCategory(point), evaluation.getValue(point)); + } } public CPPTemplateNonTypeArgument(IValue value, IType type) { @@ -84,7 +91,7 @@ public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument { } else { evaluation = new EvalTypeId(t, fEvaluation); } - return new CPPTemplateNonTypeArgument(evaluation); + return new CPPTemplateNonTypeArgument(evaluation, null); } } return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 662330216c1..37f1bc4c148 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -1079,7 +1079,7 @@ public class CPPTemplates { final ICPPEvaluation newEval= eval.instantiate(tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point); if (eval == newEval) return arg; - return new CPPTemplateNonTypeArgument(newEval); + return new CPPTemplateNonTypeArgument(newEval, point); } final IType orig= arg.getTypeValue(); @@ -1677,7 +1677,7 @@ public class CPPTemplates { result[i]= new CPPTemplateTypeArgument(CPPVisitor.createType((IASTTypeId) arg)); } else if (arg instanceof ICPPASTExpression) { ICPPASTExpression expr= (ICPPASTExpression) arg; - result[i]= new CPPTemplateNonTypeArgument(expr.getEvaluation()); + result[i]= new CPPTemplateNonTypeArgument(expr.getEvaluation(), expr); } else { throw new IllegalArgumentException("Unexpected type: " + arg.getClass().getName()); //$NON-NLS-1$ } @@ -2282,7 +2282,7 @@ public class CPPTemplates { for (ICPPFunction f : functionSet.getBindings()) { if (p.isSameType(f.getType())) { functionSet.applySelectedFunction(f); - return new CPPTemplateNonTypeArgument(new EvalBinding(f, null)); + return new CPPTemplateNonTypeArgument(new EvalBinding(f, null), point); } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java index caae733da88..b58cde9455f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java @@ -105,7 +105,7 @@ public class TemplateInstanceUtil { ICPPEvaluation eval = arg.getNonTypeEvaluation(); ICPPEvaluation eval2 = ((CPPCompositesFactory) cf).getCompositeEvaluation(eval); if (eval2 != eval) { - return new CPPTemplateNonTypeArgument(eval2); + return new CPPTemplateNonTypeArgument(eval2, null); } } return arg; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java index dce5d02d643..77a02465976 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java @@ -222,10 +222,11 @@ public class PDOM extends PlatformObject implements IPDOM { * 130.0 - Dependent expressions, bug 299911. * 131.0 - Dependent expressions part 2, bug 299911. * 132.0 - Explicit virtual overrides, bug 380623. + * 133.0 - Storing template arguments via direct marshalling, bug 299911. */ - private static final int MIN_SUPPORTED_VERSION= version(132, 0); - private static final int MAX_SUPPORTED_VERSION= version(132, Short.MAX_VALUE); - private static final int DEFAULT_VERSION = version(132, 0); + private static final int MIN_SUPPORTED_VERSION= version(133, 0); + private static final int MAX_SUPPORTED_VERSION= version(133, Short.MAX_VALUE); + private static final int DEFAULT_VERSION = version(133, 0); private static int version(int major, int minor) { return (major << 16) + minor; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java index 6e5bdc27242..3f7274ce4bb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java @@ -77,6 +77,7 @@ public class Database { public static final int PTR_SIZE = 4; // size of a pointer in the database in bytes public static final int TYPE_SIZE = 2+PTR_SIZE; // size of a type in the database in bytes public static final int VALUE_SIZE = TYPE_SIZE; // size of a value in the database in bytes + public static final int ARGUMENT_SIZE = TYPE_SIZE; // size of a template argument in the database in bytes public static final long MAX_DB_SIZE= ((long) 1 << (Integer.SIZE + BLOCK_SIZE_DELTA_BITS)); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java index 4abb48cee0c..2fc3456dc6d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java @@ -201,7 +201,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { public ICPPTemplateArgument unmarshalTemplateArgument() throws CoreException { int firstByte= getByte(); if (firstByte == VALUE) { - return new CPPTemplateNonTypeArgument((ICPPEvaluation) unmarshalEvaluation()); + return new CPPTemplateNonTypeArgument((ICPPEvaluation) unmarshalEvaluation(), null); } else { fPos--; return new CPPTemplateTypeArgument(unmarshalType()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java index 40a3ac04027..9a03c49a423 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java @@ -32,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.IVariable; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective; import org.eclipse.cdt.core.index.IIndexLinkage; import org.eclipse.cdt.core.parser.util.CharArrayMap; @@ -496,6 +497,68 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage return new TypeMarshalBuffer(this, data).unmarshalType(); } + public void storeTemplateArgument(long offset, ICPPTemplateArgument arg) throws CoreException { + final Database db= getDB(); + deleteArgument(db, offset); + storeArgument(db, offset, arg); + } + + private void storeArgument(Database db, long offset, ICPPTemplateArgument arg) throws CoreException { + if (arg != null) { + TypeMarshalBuffer bc= new TypeMarshalBuffer(this); + bc.marshalTemplateArgument(arg); + int len= bc.getPosition(); + if (len > 0) { + if (len <= Database.ARGUMENT_SIZE) { + db.putBytes(offset, bc.getBuffer(), len); + } else if (len <= Database.MAX_MALLOC_SIZE-2){ + long ptr= db.malloc(len+2); + db.putShort(ptr, (short) len); + db.putBytes(ptr+2, bc.getBuffer(), len); + db.putByte(offset, TypeMarshalBuffer.INDIRECT_TYPE); + db.putRecPtr(offset+2, ptr); + } + } + } + } + + private void deleteArgument(Database db, long offset) throws CoreException { + byte firstByte= db.getByte(offset); + if (firstByte == TypeMarshalBuffer.INDIRECT_TYPE) { + long ptr= db.getRecPtr(offset+2); + clearArgument(db, offset); + db.free(ptr); + } else { + clearArgument(db, offset); + } + } + + private void clearArgument(Database db, long offset) throws CoreException { + db.clearBytes(offset, Database.ARGUMENT_SIZE); + } + + public ICPPTemplateArgument loadTemplateArgument(long offset) throws CoreException { + final Database db= getDB(); + final byte firstByte= db.getByte(offset); + byte[] data= null; + switch(firstByte) { + case TypeMarshalBuffer.INDIRECT_TYPE: + long ptr= db.getRecPtr(offset+2); + int len= db.getShort(ptr) & 0xffff; + data= new byte[len]; + db.getBytes(ptr+2, data); + break; + case TypeMarshalBuffer.UNSTORABLE_TYPE: + case TypeMarshalBuffer.NULL_TYPE: + return null; + default: + data= new byte[Database.TYPE_SIZE]; + db.getBytes(offset, data); + break; + } + return new TypeMarshalBuffer(this, data).unmarshalTemplateArgument(); + } + public void storeValue(long offset, IValue type) throws CoreException { final Database db= getDB(); deleteValue(db, offset); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPArgumentList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPArgumentList.java index 0fc6df2b276..7fd8ea57df1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPArgumentList.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPArgumentList.java @@ -11,11 +11,8 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp; import org.eclipse.cdt.core.dom.ast.ISemanticProblem; -import org.eclipse.cdt.core.dom.ast.IType; -import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument; import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; @@ -27,8 +24,7 @@ import org.eclipse.core.runtime.CoreException; * Collects methods to store an argument list in the database */ public class PDOMCPPArgumentList { - private static final int VALUE_OFFSET= Database.TYPE_SIZE; - private static final int NODE_SIZE = VALUE_OFFSET + Database.VALUE_SIZE; + private static final int NODE_SIZE = Database.ARGUMENT_SIZE; /** * Stores the given template arguments in the database. @@ -45,13 +41,7 @@ public class PDOMCPPArgumentList { p += 2; for (int i= 0; i < len; i++, p += NODE_SIZE) { final ICPPTemplateArgument arg = templateArguments[i]; - final boolean isNonType= arg.isNonTypeValue(); - if (isNonType) { - linkage.storeType(p, arg.getTypeOfNonTypeValue()); - linkage.storeValue(p + VALUE_OFFSET, arg.getNonTypeValue()); - } else { - linkage.storeType(p, arg.getTypeValue()); - } + linkage.storeTemplateArgument(p, arg); } return block; } @@ -67,8 +57,7 @@ public class PDOMCPPArgumentList { Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE - 2) / NODE_SIZE); long p= record + 2; for (int i= 0; i < len; i++) { - linkage.storeType(p, null); - linkage.storeValue(p + VALUE_OFFSET, null); + linkage.storeTemplateArgument(p, null); p+= NODE_SIZE; } db.free(record); @@ -90,16 +79,11 @@ public class PDOMCPPArgumentList { rec += 2; ICPPTemplateArgument[] result= new ICPPTemplateArgument[len]; for (int i= 0; i < len; i++) { - IType type= linkage.loadType(rec); - if (type == null) { - type= new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED); - } - IValue val= linkage.loadValue(rec + VALUE_OFFSET); - if (val != null) { - result[i]= new CPPTemplateNonTypeArgument(val, type); - } else { - result[i]= new CPPTemplateTypeArgument(type); + ICPPTemplateArgument arg= linkage.loadTemplateArgument(rec); + if (arg == null) { + arg= new CPPTemplateTypeArgument(new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED)); } + result[i]= arg; rec += NODE_SIZE; } return result; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateNonTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateNonTypeParameter.java index 5b5988ebfad..38b316d6725 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateNonTypeParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateNonTypeParameter.java @@ -39,9 +39,9 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMemberOwner, ICPPTemplateNonTypeParameter, IPDOMCPPTemplateParameter { private static final int TYPE_OFFSET= PDOMCPPBinding.RECORD_SIZE; private static final int PARAMETERID= TYPE_OFFSET + Database.TYPE_SIZE; - private static final int DEFAULTVAL= PARAMETERID + Database.VALUE_SIZE; + private static final int DEFAULTVAL= PARAMETERID + 4; @SuppressWarnings("hiding") - protected static final int RECORD_SIZE = DEFAULTVAL + Database.PTR_SIZE; + protected static final int RECORD_SIZE = DEFAULTVAL + Database.VALUE_SIZE; private int fCachedParamID= -1; private volatile IType fType; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateParameterMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateParameterMap.java index 74b2e6ef453..80cbd7c9f69 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateParameterMap.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTemplateParameterMap.java @@ -11,12 +11,9 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp; import org.eclipse.cdt.core.dom.ast.ISemanticProblem; -import org.eclipse.cdt.core.dom.ast.IType; -import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument; import org.eclipse.cdt.internal.core.pdom.db.Database; @@ -28,9 +25,7 @@ import org.eclipse.core.runtime.CoreException; * Collects methods to store an argument list in the database */ public class PDOMCPPTemplateParameterMap { - private static final int TYPE_OFFSET= 0; - private static final int VALUE_OFFSET= TYPE_OFFSET + Database.TYPE_SIZE; - private static final int NODE_SIZE = VALUE_OFFSET + Database.VALUE_SIZE; + private static final int NODE_SIZE = Database.ARGUMENT_SIZE; /** * Stores the given template parameter map in the database. @@ -78,12 +73,7 @@ public class PDOMCPPTemplateParameterMap { private static void storeArgument(final Database db, final PDOMLinkage linkage, long p, final ICPPTemplateArgument arg) throws CoreException { - if (arg.isNonTypeValue()) { - linkage.storeType(p + TYPE_OFFSET, arg.getTypeOfNonTypeValue()); - linkage.storeValue(p + VALUE_OFFSET, arg.getNonTypeValue()); - } else { - linkage.storeType(p + TYPE_OFFSET, arg.getTypeValue()); - } + linkage.storeTemplateArgument(p, arg); } /** @@ -102,8 +92,7 @@ public class PDOMCPPTemplateParameterMap { if (packSize == -1) packSize= 1; for (int j = 0; j < packSize; j++) { - linkage.storeType(p + TYPE_OFFSET, null); - linkage.storeValue(p + VALUE_OFFSET, null); + linkage.storeTemplateArgument(p, null); p+= NODE_SIZE; } } @@ -143,16 +132,9 @@ public class PDOMCPPTemplateParameterMap { private static ICPPTemplateArgument readArgument(long rec, final PDOMLinkage linkage, final Database db) throws CoreException { - IType type= linkage.loadType(rec + TYPE_OFFSET); - if (type == null) { - type= new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED); - } - IValue val= linkage.loadValue(rec + VALUE_OFFSET); - ICPPTemplateArgument arg; - if (val != null) { - arg= new CPPTemplateNonTypeArgument(val, type); - } else { - arg= new CPPTemplateTypeArgument(type); + ICPPTemplateArgument arg = linkage.loadTemplateArgument(rec); + if (arg == null) { + arg= new CPPTemplateTypeArgument(new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED)); } return arg; } From d643e121a097ff44f84c36da5c72a704999df3c8 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Fri, 14 Sep 2012 09:31:39 +0200 Subject: [PATCH 15/16] Fix intermittent test failures. --- .../cdt/codan/core/test/CheckerTestCase.java | 2 +- .../cdt/codan/core/test/CodanTestCase.java | 6 +-- .../cdt/core/model/tests/ASTCacheTests.java | 2 +- .../core/model/tests/CModelElementsTests.java | 7 ++-- .../model/tests/CModelIdentifierTests.java | 3 +- .../model/tests/IntegratedCModelTest.java | 7 ++-- .../tests/StructuralCModelElementsTests.java | 6 +-- .../changegenerator/ChangeGeneratorTest.java | 3 +- .../cdt/internal/index/tests/Bug246129.java | 2 +- .../tests/IndexBindingResolutionTestBase.java | 16 ++++---- .../internal/index/tests/IndexBugsTests.java | 11 +---- .../index/tests/IndexIncludeTest.java | 8 ++-- .../index/tests/IndexListenerTest.java | 10 +++-- .../index/tests/IndexLocationTest.java | 3 +- .../internal/index/tests/IndexNamesTests.java | 4 +- .../index/tests/IndexProviderManagerTest.java | 37 ++++++++--------- .../internal/index/tests/IndexTestBase.java | 5 +-- .../index/tests/IndexUpdateTests.java | 20 ++++----- .../index/tests/TeamSharedIndexTest.java | 26 ++++++------ .../index/tests/TrilogyPerformanceTest.java | 6 +-- .../pdom/tests/CPPClassTemplateTests.java | 8 +--- .../pdom/tests/ChangeConfigurationTests.java | 10 ++--- .../pdom/tests/FilesOnReindexTests.java | 2 +- .../internal/pdom/tests/PDOMCBugsTest.java | 2 +- .../internal/pdom/tests/PDOMCPPBugsTest.java | 6 +-- .../pdom/tests/PDOMProviderTests.java | 14 +++---- .../cdt/core/tests/BaseTestFramework.java | 13 +++--- .../core/testplugin/util/BaseTestCase.java | 13 +++++- .../testplugin/util/TestSourceReader.java | 2 + .../eclipse/cdt/ui/tests/BaseUITestCase.java | 41 ------------------- .../callhierarchy/BasicCallHierarchyTest.java | 32 +++++++-------- .../BasicCppCallHierarchyTest.java | 18 ++++---- .../CallHierarchyAcrossProjectsTest.java | 14 +++---- .../callhierarchy/CallHierarchyBaseTest.java | 2 +- .../callhierarchy/CallHierarchyBugs.java | 24 +++++------ .../callhierarchy/CppCallHierarchyTest.java | 22 ++++------ .../InitializersInCallHierarchyTest.java | 2 +- .../BasicIncludeBrowserTest.java | 4 +- .../ui/tests/outline/BasicOutlineTest.java | 2 +- .../refactoring/RefactoringTestBase.java | 3 +- .../tests/refactoring/rename/RenameTests.java | 13 +----- .../cdt/ui/tests/search/BasicSearchTest.java | 21 ++++------ .../cdt/ui/tests/text/AddIncludeTest.java | 7 ++-- .../contentassist/ContentAssistTests.java | 16 ++++---- .../AbstractContentAssistTest.java | 30 ++++++-------- .../text/contentassist2/CompletionTests.java | 5 +-- .../CompletionTests_PlainC.java | 7 ++-- .../selection/BaseSelectionTestsIndexer.java | 13 +----- .../CPPSelectionTestsAnyIndexer.java | 2 +- .../text/selection/ResolveBindingTests.java | 6 +-- .../typehierarchy/CTypeHierarchyTest.java | 24 +++++------ .../typehierarchy/CppTypeHierarchyTest.java | 18 ++++---- .../typehierarchy/QuickTypeHierarchyTest.java | 16 ++++---- .../TypeHierarchyAcrossProjectsTest.java | 2 +- .../typehierarchy/TypeHierarchyBaseTest.java | 2 +- 55 files changed, 252 insertions(+), 348 deletions(-) diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java index bf6736bb690..3aac43569a8 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java @@ -148,7 +148,7 @@ public class CheckerTestCase extends CodanTestCase { public void runOnProject() { try { indexFiles(); - } catch (CoreException e) { + } catch (Exception e) { fail(e.getMessage()); } runCodan(); diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java index 5ce5343e19d..fb73bbe18eb 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java @@ -127,7 +127,7 @@ public class CodanTestCase extends BaseTestCase { return cprojects[0]; } - protected void indexFiles() throws CoreException { + protected void indexFiles() throws CoreException, InterruptedException { final IWorkspace workspace = ResourcesPlugin.getWorkspace(); workspace.run(new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { @@ -138,9 +138,7 @@ public class CodanTestCase extends BaseTestCase { CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); CCorePlugin.getIndexManager().reindex(cproject); // wait until the indexer is done - assertTrue(CCorePlugin.getIndexManager().joinIndexer(1000 * 60, // 1 min - new NullProgressMonitor())); - return; + waitForIndexer(cproject); } /** diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ASTCacheTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ASTCacheTests.java index 386ae9e6857..82fd57fa59a 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ASTCacheTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ASTCacheTests.java @@ -113,7 +113,7 @@ public class ASTCacheTests extends BaseTestCase { assertNotNull(fTU1); fTU2= (ITranslationUnit) CoreModel.getDefault().create(file2); assertNotNull(fTU2); - CCorePlugin.getIndexManager().joinIndexer(5000, npm); + waitForIndexer(fProject); fIndex= CCorePlugin.getIndexManager().getIndex(fProject); fIndex.acquireReadLock(); } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java index 7cdf2374137..9bc8a6373cc 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java @@ -15,10 +15,8 @@ import java.io.FileNotFoundException; import java.util.List; import junit.framework.Test; -import junit.framework.TestCase; import junit.framework.TestSuite; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; @@ -48,12 +46,13 @@ import org.eclipse.cdt.core.model.IVariableDeclaration; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; -public class CModelElementsTests extends TestCase { +public class CModelElementsTests extends BaseTestCase { private ICProject fCProject; private IFile headerFile; private IFile includedFile; @@ -90,7 +89,7 @@ public class CModelElementsTests extends TestCase { } } // make sure the index is up-to-date - assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor())); + waitForIndexer(fCProject); } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelIdentifierTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelIdentifierTests.java index b088b350c38..40770938ff5 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelIdentifierTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelIdentifierTests.java @@ -18,7 +18,6 @@ import java.util.List; import junit.framework.Test; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; @@ -67,7 +66,7 @@ public class CModelIdentifierTests extends BaseTestCase { e.printStackTrace(); } } - CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor()); + waitForIndexer(fCProject); } @Override diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java index 338069dc751..8bee6fd544a 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java @@ -17,8 +17,6 @@ package org.eclipse.cdt.core.model.tests; import java.io.FileInputStream; import java.io.FileNotFoundException; -import junit.framework.TestCase; - import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.CModelException; @@ -27,6 +25,7 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; @@ -36,7 +35,7 @@ import org.eclipse.core.runtime.Path; * @author bnicolle * */ -public abstract class IntegratedCModelTest extends TestCase { +public abstract class IntegratedCModelTest extends BaseTestCase { private ICProject fCProject; private IFile sourceFile; @@ -84,7 +83,7 @@ public abstract class IntegratedCModelTest extends TestCase { e.printStackTrace(); } } - CCorePlugin.getIndexManager().joinIndexer(2000, new NullProgressMonitor()); + waitForIndexer(fCProject); } @Override diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java index 592e9d4739e..7de3dd87c12 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java @@ -15,7 +15,6 @@ import java.io.FileNotFoundException; import java.util.List; import junit.framework.Test; -import junit.framework.TestCase; import junit.framework.TestSuite; import org.eclipse.cdt.core.CCorePlugin; @@ -48,12 +47,13 @@ import org.eclipse.cdt.core.model.IVariableDeclaration; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; -public class StructuralCModelElementsTests extends TestCase { +public class StructuralCModelElementsTests extends BaseTestCase { private ICProject fCProject; private IFile headerFile; private IFile includedFile; @@ -89,7 +89,7 @@ public class StructuralCModelElementsTests extends TestCase { e.printStackTrace(); } } - CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor()); + waitForIndexer(fCProject); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTest.java index 33bfc7c7f16..8ba6bef41fb 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/changegenerator/ChangeGeneratorTest.java @@ -59,8 +59,7 @@ public abstract class ChangeGeneratorTest extends BaseTestFramework { ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); - boolean joined = CCorePlugin.getIndexManager().joinIndexer(20000, new NullProgressMonitor()); - assertTrue("The indexing operation of the test CProject has not finished jet. This should not happen...", joined); + waitForIndexer(cproject); IASTTranslationUnit unit = CoreModelUtil.findTranslationUnit(testFile).getAST(); final ChangeGenerator changeGenerator = diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/Bug246129.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/Bug246129.java index 76c3121f5a2..d3d6044e7d2 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/Bug246129.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/Bug246129.java @@ -151,7 +151,7 @@ public class Bug246129 extends IndexTestBase { fFalseFriendsAccepted = falseFriendDirectory.exists(); CCorePlugin.getIndexManager().reindex(fProject); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, npm())); + waitForIndexer(fProject); fIndex = CCorePlugin.getIndexManager().getIndex(fProject); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java index 3a0308f3be5..37b10fbad55 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java @@ -50,7 +50,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.osgi.framework.Bundle; @@ -66,7 +65,6 @@ import org.osgi.framework.Bundle; */ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { private static final boolean DEBUG= false; - private static final int INDEXER_TIMEOUT_SEC = 300; protected ITestStrategy strategy; public void setStrategy(ITestStrategy strategy) { @@ -339,7 +337,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { return; IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString()); CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, new NullProgressMonitor())); + waitForIndexer(cproject); if (DEBUG) { System.out.println("Project PDOM: " + getName()); @@ -424,10 +422,10 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString()); CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, new NullProgressMonitor())); + waitForIndexer(cproject); IFile cppfile= TestSourceReader.createFile(cproject.getProject(), new Path("references.c" + (cpp ? "pp" : "")), testData[1].toString()); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, new NullProgressMonitor())); + waitForIndexer(cproject); if (DEBUG) { System.out.println("Project PDOM: " + getName()); @@ -537,7 +535,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { } } CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, new NullProgressMonitor())); + waitForIndexer(cproject); if (DEBUG) { System.out.println("Project PDOM: " + getName()); @@ -621,7 +619,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER); CCorePlugin.getIndexManager().reindex(cproject); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, new NullProgressMonitor())); + waitForIndexer(cproject); if (DEBUG) { System.out.println("Online: "+getName()); @@ -633,7 +631,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { ast= TestSourceReader.createIndexBasedAST(index, cproject, references); } - protected ICProject createReferencedContent() throws CoreException { + private ICProject createReferencedContent() throws Exception { ICProject referenced = cpp ? CProjectHelper.createCCProject("ReferencedContent" + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER) : CProjectHelper.createCProject("ReferencedContent" + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER); @@ -643,7 +641,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { IndexerPreferences.set(referenced.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER); CCorePlugin.getIndexManager().reindex(referenced); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, new NullProgressMonitor())); + waitForIndexer(referenced); if (DEBUG) { System.out.println("Referenced: "+getName()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java index e4558287e40..785a110ed0b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java @@ -303,14 +303,7 @@ public class IndexBugsTests extends BaseTestCase { } private void waitForIndexer() throws InterruptedException { - final IIndexManager indexManager = CCorePlugin.getIndexManager(); - assertTrue(indexManager.joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm())); - long waitms= 1; - while (waitms < 2000 && indexManager.isIndexerSetupPostponed(fCProject)) { - Thread.sleep(waitms); - waitms *= 2; - } - assertTrue(indexManager.joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm())); + waitForIndexer(fCProject); } protected Pattern[] getPattern(String qname) { @@ -424,7 +417,7 @@ public class IndexBugsTests extends BaseTestCase { content.append("unsigned int arrayDataSize = sizeof(arrayData);\n"); int indexOfDecl = content.indexOf(varName); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm())); + waitForIndexer(); IFile file= createFile(getProject(), fileName, content.toString()); // must be done in a reasonable amount of time waitUntilFileIsIndexed(file, INDEXER_TIMEOUT_SEC * 1000); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java index 080e8a99f1b..4e58eb978f7 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java @@ -94,8 +94,8 @@ public class IndexIncludeTest extends IndexTestBase { checkContext(); } - private void waitForIndexer() { - assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, npm())); + private void waitForIndexer() throws InterruptedException { + waitForIndexer(fProject); } private void checkHeader(boolean all) throws Exception { @@ -564,9 +564,9 @@ public class IndexIncludeTest extends IndexTestBase { final IFile h1= TestSourceReader.createFile(fProject.getProject(), "h1.h", h1Contents.toString()); IFile h2= TestSourceReader.createFile(fProject.getProject(), "h2.h", contents[1].toString()); IFile s1= TestSourceReader.createFile(fProject.getProject(), "s1.cpp", contents[2].toString()); + waitUntilFileIsIndexed(fIndex, s1); IFile s2= TestSourceReader.createFile(fProject.getProject(), "s2.cpp", contents[3].toString()); - TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_WAIT_TIME); - TestSourceReader.waitUntilFileIsIndexed(fIndex, s2, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, s2); fIndex.acquireReadLock(); try { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexListenerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexListenerTest.java index f1a9e63b3aa..8b4aa2a7545 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexListenerTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexListenerTest.java @@ -28,7 +28,6 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.NullProgressMonitor; public class IndexListenerTest extends BaseTestCase { private ICProject fProject1; @@ -42,7 +41,8 @@ public class IndexListenerTest extends BaseTestCase { protected void setUp() throws Exception { fProject1 = CProjectHelper.createCCProject("testIndexListener1", null, IPDOMManager.ID_FAST_INDEXER); fProject2 = CProjectHelper.createCCProject("testIndexListener2", null, IPDOMManager.ID_FAST_INDEXER); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(2000, new NullProgressMonitor())); + waitForIndexer(fProject1); + waitForIndexer(fProject2); } @Override @@ -55,7 +55,8 @@ public class IndexListenerTest extends BaseTestCase { final Object mutex= new Object(); final int[] state= new int[] {0, 0, 0}; IIndexManager im= CCorePlugin.getIndexManager(); - assertTrue(im.joinIndexer(10000, npm())); + waitForIndexer(fProject1); + waitForIndexer(fProject2); IIndexerStateListener listener = new IIndexerStateListener() { @Override @@ -99,7 +100,8 @@ public class IndexListenerTest extends BaseTestCase { final List projects= new ArrayList(); IIndexManager im= CCorePlugin.getIndexManager(); - assertTrue(im.joinIndexer(10000, npm())); + waitForIndexer(fProject1); + waitForIndexer(fProject2); IIndexChangeListener listener = new IIndexChangeListener() { @Override public void indexChanged(IIndexChangeEvent event) { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexLocationTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexLocationTest.java index ac54b275678..ae1d7fbfe6c 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexLocationTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexLocationTest.java @@ -98,7 +98,7 @@ public class IndexLocationTest extends BaseTestCase { IFile file3 = TestSourceReader.createFile(cproject.getProject(), "source.cpp", content); CCorePlugin.getIndexManager().reindex(cproject); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor())); + waitForIndexer(cproject); IIndex index = CCorePlugin.getIndexManager().getIndex(cproject); index.acquireReadLock(); @@ -166,7 +166,6 @@ public class IndexLocationTest extends BaseTestCase { IIndex index = CCorePlugin.getIndexManager().getIndex(cproject); TestSourceReader.waitUntilFileIsIndexed(index, content.getFile("external2.h"), 4000); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor())); index.acquireReadLock(); try { IBinding[] bs= index.findBindings("External".toCharArray(), IndexFilter.ALL, npm()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexNamesTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexNamesTests.java index ca8e197a13c..919070159a5 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexNamesTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexNamesTests.java @@ -76,8 +76,8 @@ public class IndexNamesTests extends BaseTestCase { return TestSourceReader.createFile(container, new Path(fileName), contents); } - protected void waitForIndexer() { - assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, npm())); + protected void waitForIndexer() throws InterruptedException { + waitForIndexer(fCProject); } protected Pattern[] getPattern(String qname) { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java index 1e963510c0e..d048477f94c 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexProviderManagerTest.java @@ -238,8 +238,7 @@ public class IndexProviderManagerTest extends IndexTestBase { return true; } }; - - CCorePlugin.getIndexManager().joinIndexer(8000, npm()); // ensure IPM is called only once under test conditions + waitForIndexer(cproject); setExpectedNumberOfLoggedNonOKStatusObjects(3); // foo, bar and baz have no compatible fragments available ipm.reset(VERSION_405); ipm.startup(); @@ -298,7 +297,7 @@ public class IndexProviderManagerTest extends IndexTestBase { } }; - CCorePlugin.getIndexManager().joinIndexer(8000, npm()); // ensure IPM is called only once under test conditions + waitForIndexer(cproject); setExpectedNumberOfLoggedNonOKStatusObjects(1); // contentA has no compatible fragments available ipm.reset(VERSION_502); ipm.startup(); @@ -348,21 +347,21 @@ public class IndexProviderManagerTest extends IndexTestBase { core.setProjectDescription(project, pd); index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION); - CCorePlugin.getIndexManager().joinIndexer(8000, npm()); + waitForIndexer(cproject); DPT.reset(DP1); - changeConfigRelations(project, ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE); + changeConfigRelations(cproject, ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE); assertEquals(0, DPT.getProjectsTrace(DP1).size()); assertEquals(0, DPT.getCfgsTrace(DP1).size()); - changeActiveConfiguration(project, cfg1); + changeActiveConfiguration(cproject, cfg1); DPT.reset(DP1); index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION); assertEquals(0, DPT.getProjectsTrace(DP1).size()); assertEquals(1, DPT.getCfgsTrace(DP1).size()); assertEquals("project.config1", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId()); - changeActiveConfiguration(project, cfg2); + changeActiveConfiguration(cproject, cfg2); DPT.reset(DP1); index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION); assertEquals(0, DPT.getProjectsTrace(DP1).size()); @@ -370,11 +369,11 @@ public class IndexProviderManagerTest extends IndexTestBase { assertEquals("project.config2", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId()); DPT.reset(DP1); - changeConfigRelations(project, ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT); + changeConfigRelations(cproject, ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT); assertEquals(0, DPT.getProjectsTrace(DP1).size()); assertEquals(0, DPT.getCfgsTrace(DP1).size()); - changeActiveConfiguration(project, cfg1); + changeActiveConfiguration(cproject, cfg1); DPT.reset(DP1); index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION); assertEquals(0, DPT.getProjectsTrace(DP1).size()); @@ -382,7 +381,7 @@ public class IndexProviderManagerTest extends IndexTestBase { // should still be config2, as the change in active configuration does not matter assertEquals("project.config2", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId()); - changeActiveConfiguration(project, cfg2); + changeActiveConfiguration(cproject, cfg2); DPT.reset(DP1); index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION); assertEquals(0, DPT.getProjectsTrace(DP1).size()); @@ -556,18 +555,18 @@ public class IndexProviderManagerTest extends IndexTestBase { return des.createConfiguration(CCorePlugin.DEFAULT_PROVIDER_ID, data); } - private void changeActiveConfiguration(IProject project, ICConfigurationDescription cfg) throws CoreException { - ICProjectDescription pd= core.getProjectDescription(project); + private void changeActiveConfiguration(ICProject cproject, ICConfigurationDescription cfg) throws CoreException, InterruptedException { + ICProjectDescription pd= core.getProjectDescription(cproject.getProject()); pd.setActiveConfiguration(pd.getConfigurationById(cfg.getId())); - core.setProjectDescription(project, pd); - CCorePlugin.getIndexManager().joinIndexer(8000, npm()); + core.setProjectDescription(cproject.getProject(), pd); + waitForIndexer(cproject); } - private void changeConfigRelations(IProject project, int option) throws CoreException { - ICProjectDescription pd= core.getProjectDescription(project); + private void changeConfigRelations(ICProject cproject, int option) throws CoreException, InterruptedException { + ICProjectDescription pd= core.getProjectDescription(cproject.getProject()); pd.setConfigurationRelations(option); - core.setProjectDescription(project, pd); - CCorePlugin.getIndexManager().joinIndexer(8000, npm()); + core.setProjectDescription(cproject.getProject(), pd); + waitForIndexer(cproject); } } @@ -830,7 +829,7 @@ class MockState { public static final String DBG_V2_ID = "dbg_v2"; public static final List states = new ArrayList(Arrays.asList(new String[]{REL_V1_ID, REL_V2_ID, DBG_V1_ID, DBG_V2_ID})); - private IProject project; + private final IProject project; private String currentConfig; public MockState(ICProject cproject) { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestBase.java index cbddce3c418..59cab0fd370 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestBase.java @@ -25,7 +25,6 @@ import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; public class IndexTestBase extends BaseTestCase { protected static int INDEXER_WAIT_TIME= 8000; @@ -34,7 +33,7 @@ public class IndexTestBase extends BaseTestCase { super(name); } - protected ICProject createProject(final boolean useCpp, final String importSource) throws CoreException { + protected ICProject createProject(final boolean useCpp, final String importSource) throws CoreException, InterruptedException { // Create the project final ICProject[] result= new ICProject[] {null}; final IWorkspace workspace = ResourcesPlugin.getWorkspace(); @@ -52,7 +51,7 @@ public class IndexTestBase extends BaseTestCase { }, null); CCorePlugin.getIndexManager().setIndexerId(result[0], IPDOMManager.ID_FAST_INDEXER); // wait until the indexer is done - assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor())); + waitForIndexer(result[0]); return result[0]; } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java index 6a8e8da0adc..c25c43b7e29 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java @@ -102,7 +102,8 @@ public class IndexUpdateTests extends IndexTestBase { if (fCProject == null) { fCProject= CProjectHelper.createCProject("indexUpdateTestsC", null, IPDOMManager.ID_FAST_INDEXER); } - CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm()); + waitForIndexer(fCppProject); + waitForIndexer(fCProject); fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {fCProject, fCppProject}); } @@ -113,7 +114,8 @@ public class IndexUpdateTests extends IndexTestBase { } IProject project= cpp ? fCppProject.getProject() : fCProject.getProject(); fHeader= TestSourceReader.createFile(project, "header.h", fContents[++fContentUsed].toString()); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm())); + waitForIndexer(fCppProject); + waitForIndexer(fCProject); } private void updateHeader() throws Exception { @@ -122,7 +124,7 @@ public class IndexUpdateTests extends IndexTestBase { IProject project= fHeader.getProject(); fHeader= TestSourceReader.createFile(project, "header.h", fContents[++fContentUsed].toString() + "\n// " + fContentUsed); - TestSourceReader.waitUntilFileIsIndexed(fIndex, fHeader, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, fHeader); } private void setupFile(int totalFileVersions, boolean cpp) throws Exception { @@ -130,10 +132,10 @@ public class IndexUpdateTests extends IndexTestBase { fContents= getContentsForTest(totalFileVersions); fContentUsed= -1; } - IProject project= cpp ? fCppProject.getProject() : fCProject.getProject(); - fFile= TestSourceReader.createFile(project, "file" + (cpp ? ".cpp" : ".c"), fContents[++fContentUsed].toString()); + ICProject cproject= cpp ? fCppProject : fCProject; + fFile= TestSourceReader.createFile(cproject.getProject(), "file" + (cpp ? ".cpp" : ".c"), fContents[++fContentUsed].toString()); TestSourceReader.waitUntilFileIsIndexed(fIndex, fFile, INDEXER_WAIT_TIME); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm())); + waitForIndexer(cproject); } private void updateFile() throws Exception { @@ -141,7 +143,7 @@ public class IndexUpdateTests extends IndexTestBase { // Indexer would not reindex the file if its contents remain the same. fFile= TestSourceReader.createFile(fFile.getParent(), fFile.getName(), fContents[++fContentUsed].toString() + "\n// " + fContentUsed); - TestSourceReader.waitUntilFileIsIndexed(fIndex, fFile, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, fFile); } @Override @@ -153,7 +155,6 @@ public class IndexUpdateTests extends IndexTestBase { if (fHeader != null) { fHeader.delete(true, npm()); } - CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm()); super.tearDown(); } @@ -945,8 +946,7 @@ public class IndexUpdateTests extends IndexTestBase { } fHeader= TestSourceReader.createFile(fHeader.getParent(), fHeader.getName(), fContents[0].toString().replaceAll("globalVar", "newVar")); - TestSourceReader.waitUntilFileIsIndexed(fIndex, fHeader, INDEXER_WAIT_TIME); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm())); + waitUntilFileIsIndexed(fIndex, fHeader); fIndex.acquireReadLock(); try { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TeamSharedIndexTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TeamSharedIndexTest.java index aa802674ae6..b0386d97f02 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TeamSharedIndexTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TeamSharedIndexTest.java @@ -48,7 +48,7 @@ public class TeamSharedIndexTest extends IndexTestBase { return suite(TeamSharedIndexTest.class); } - private Collection fProjects= new LinkedList(); + private final Collection fProjects= new LinkedList(); private static final IIndexManager fPDOMManager = CCorePlugin.getIndexManager(); public TeamSharedIndexTest(String name) { @@ -77,7 +77,7 @@ public class TeamSharedIndexTest extends IndexTestBase { fProjects.remove(prj); } - private ICProject createProject(String name) throws CoreException { + private ICProject createProject(String name) throws CoreException, InterruptedException { ModelJoiner mj= new ModelJoiner(); try { ICProject project= CProjectHelper.createCCProject(name, null, IPDOMManager.ID_NO_INDEXER); @@ -88,7 +88,7 @@ public class TeamSharedIndexTest extends IndexTestBase { mj.join(); // in order we are sure the indexer task has been scheduled before joining the indexer fPDOMManager.setIndexerId(project, IPDOMManager.ID_FAST_INDEXER); - assertTrue(fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm())); + waitForIndexer(project); return project; } finally { mj.dispose(); @@ -151,7 +151,7 @@ public class TeamSharedIndexTest extends IndexTestBase { fPDOMManager.setIndexerId(prj, FakeIndexer.ID); IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED); new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush(); - fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm()); + waitForIndexer(prj); checkVariable(prj, "a", 0); checkVariable(prj, "b", 0); checkVariable(prj, "c", 0); @@ -182,7 +182,7 @@ public class TeamSharedIndexTest extends IndexTestBase { IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED); new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush(); fPDOMManager.export(prj, loc, 0, npm()); - fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm()); + waitForIndexer(prj); // change file changeFile(prj); @@ -228,13 +228,13 @@ public class TeamSharedIndexTest extends IndexTestBase { // export the project. fPDOMManager.export(prj, loc, 0, npm()); - fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm()); + waitForIndexer(prj); // set indexer to the fake one. fPDOMManager.setIndexerId(prj, FakeIndexer.ID); IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED); new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush(); - fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm()); + waitForIndexer(prj); checkVariable(prj, "a", 0); checkVariable(prj, "b", 0); checkVariable(prj, "c", 0); @@ -264,7 +264,7 @@ public class TeamSharedIndexTest extends IndexTestBase { IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED); new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush(); fPDOMManager.export(prj, loc, 0, npm()); - fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm()); + waitForIndexer(prj); // add file TestSourceReader.createFile(prj.getProject(), "d.cpp", "int d;"); @@ -290,13 +290,13 @@ public class TeamSharedIndexTest extends IndexTestBase { // export the project. fPDOMManager.export(prj, loc, 0, npm()); - fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm()); + waitForIndexer(prj); // set indexer to the fake one. fPDOMManager.setIndexerId(prj, FakeIndexer.ID); IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED); new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush(); - fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm()); + waitForIndexer(prj); checkVariable(prj, "a", 0); checkVariable(prj, "b", 0); checkVariable(prj, "c", 0); @@ -327,7 +327,7 @@ public class TeamSharedIndexTest extends IndexTestBase { IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED); new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush(); fPDOMManager.export(prj, loc, 0, npm()); - fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm()); + waitForIndexer(prj); // delete file prj.getProject().getFile("a.cpp").delete(true, npm()); @@ -352,13 +352,13 @@ public class TeamSharedIndexTest extends IndexTestBase { // export the project. fPDOMManager.export(prj, loc, 0, npm()); - fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm()); + waitForIndexer(prj); // set indexer to the fake one. fPDOMManager.setIndexerId(prj, FakeIndexer.ID); IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED); new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush(); - fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm()); + waitForIndexer(prj); checkVariable(prj, "a", 0); checkVariable(prj, "b", 0); checkVariable(prj, "c", 0); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TrilogyPerformanceTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TrilogyPerformanceTest.java index 8ddcced2c9c..f53caf0cdcb 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TrilogyPerformanceTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TrilogyPerformanceTest.java @@ -55,14 +55,14 @@ public class TrilogyPerformanceTest extends IndexTestBase { } // you must have the Windows SDK installed and the INETSDK env var setup - public void testIndexTrilogyPerformanceTimes() throws CoreException { + public void testIndexTrilogyPerformanceTimes() throws CoreException, InterruptedException { if(Platform.getOS().equals(Platform.OS_WIN32)) { - assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); + waitForIndexer(cproject); TestScannerProvider.sIncludes = new String[]{EnvironmentReader.getEnvVar("INETSDK")+"\\Include"}; IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "true"); long start = System.currentTimeMillis(); CCorePlugin.getIndexManager().reindex(cproject); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); + waitForIndexer(cproject); System.out.println("Took: "+(System.currentTimeMillis() - start)); IIndex index= CCorePlugin.getIndexManager().getIndex(cproject); IBinding[] binding = index.findBindings(Pattern.compile("IXMLElementCollection"), false, IndexFilter.ALL, new NullProgressMonitor()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java index e06d3cb350b..52c117f25ba 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java @@ -14,7 +14,6 @@ import java.util.Arrays; import junit.framework.Test; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -40,7 +39,6 @@ import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences; import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; /** @@ -67,11 +65,7 @@ public class CPPClassTemplateTests extends PDOMTestBase { IFile file= TestSourceReader.createFile(cproject.getProject(), new Path("refs.cpp"), content.toString()); } IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER); - for(int i=0; i<5 && !CCoreInternals.getPDOMManager().isProjectRegistered(cproject); i++) { - Thread.sleep(200); - } - assertTrue(CCoreInternals.getPDOMManager().isProjectRegistered(cproject)); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); + waitForIndexer(cproject); pdom= (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject); pdom.acquireReadLock(); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ChangeConfigurationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ChangeConfigurationTests.java index a8235dc64ee..d0b3a4375a8 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ChangeConfigurationTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/ChangeConfigurationTests.java @@ -43,11 +43,11 @@ public class ChangeConfigurationTests extends PDOMTestBase { return suite(ChangeConfigurationTests.class); } - private void changeConfigRelations(IProject project, int option) throws CoreException { - ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(project); + private void changeConfigRelations(ICProject project, int option) throws CoreException, InterruptedException { + ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(project.getProject()); pd.setConfigurationRelations(option); - CCorePlugin.getDefault().setProjectDescription(project, pd); - CCorePlugin.getIndexManager().joinIndexer(8000, npm()); + CCorePlugin.getDefault().setProjectDescription(project.getProject(), pd); + waitForIndexer(project); } // Emulates ChangeConfigAction @@ -79,7 +79,7 @@ public class ChangeConfigurationTests extends PDOMTestBase { IFile file= TestSourceReader.createFile(cProject.getProject(), new Path("test.c"), contents[0].toString()); mj.join(); mj.dispose(); - changeConfigRelations(cProject.getProject(), ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE); + changeConfigRelations(cProject, ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE); ICProjectDescription prjd = CCorePlugin.getDefault().getProjectDescriptionManager().getProjectDescription(project); ICConfigurationDescription configuration1 = prjd.getConfigurations()[0]; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/FilesOnReindexTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/FilesOnReindexTests.java index 81c3824b6b2..ddc6e63b818 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/FilesOnReindexTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/FilesOnReindexTests.java @@ -64,7 +64,7 @@ public class FilesOnReindexTests extends PDOMTestBase { CCoreInternals.getPDOMManager().reindex(project); // wait until the indexer is done - assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); + waitForIndexer(project); pdom.acquireReadLock(); performAssertions(file); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java index 2b082fa568e..616b1ca98a3 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java @@ -58,7 +58,7 @@ public class PDOMCBugsTest extends BaseTestCase { IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString()); CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); + waitForIndexer(cproject); pdom= (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject); super.setUp(); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCPPBugsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCPPBugsTest.java index c4aa6f02157..6248a4fb90c 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCPPBugsTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCPPBugsTest.java @@ -58,7 +58,7 @@ public class PDOMCPPBugsTest extends BaseTestCase { protected void setUp() throws Exception { super.setUp(); cproject= CProjectHelper.createCCProject("PDOMBugsTest"+System.currentTimeMillis(), "bin", IPDOMManager.ID_FAST_INDEXER); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(8000, npm())); + waitForIndexer(cproject); } @Override @@ -122,7 +122,7 @@ public class PDOMCPPBugsTest extends BaseTestCase { assertFalse("Project pdom ID equals export PDOM id", id2.equals(id)); pdomManager.reindex(cproject); - assertTrue(pdomManager.joinIndexer(4000, new NullProgressMonitor())); + waitForIndexer(cproject); String id3= pdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID); assertNotNull("Exported pdom ID is null after project reindex", id3); @@ -217,7 +217,7 @@ public class PDOMCPPBugsTest extends BaseTestCase { IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER); CCorePlugin.getIndexManager().reindex(cproject); - CCorePlugin.getIndexManager().joinIndexer(10000, npm()); + waitForIndexer(cproject); final PDOM pdom= (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject); pdom.acquireReadLock(); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMProviderTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMProviderTests.java index f5a8ce9598b..8e52106f071 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMProviderTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMProviderTests.java @@ -57,7 +57,7 @@ public class PDOMProviderTests extends PDOMTestBase { { ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER); TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n"); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()); + waitForIndexer(cproject); IIndex index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTIONS); index.acquireReadLock(); @@ -78,7 +78,7 @@ public class PDOMProviderTests extends PDOMTestBase { final URI baseURI= new File("c:/ExternalSDK/").toURI(); final ICProject cproject2= CProjectHelper.createCCProject("bar" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER); TestSourceReader.createFile(cproject2.getProject(), new Path("/source.cpp"), "namespace X { class A {}; }\n\n"); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()); + waitForIndexer(cproject2); IndexProviderManager ipm= CCoreInternals.getPDOMManager().getIndexProviderManager(); ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge( @@ -129,7 +129,7 @@ public class PDOMProviderTests extends PDOMTestBase { { ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER); TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n"); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()); + waitForIndexer(cproject); IIndex index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTIONS); index.acquireReadLock(); @@ -149,12 +149,12 @@ public class PDOMProviderTests extends PDOMTestBase { final ICProject cproject3= CProjectHelper.createCCProject("bar" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER); TestSourceReader.createFile(cproject3.getProject(), new Path("/source.cpp"), "namespace Y { class A {}; }\n\n"); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()); + waitForIndexer(cproject3); final URI baseURI= new File("c:/ExternalSDK/").toURI(); final ICProject cproject2= CProjectHelper.createCCProject("baz" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER); TestSourceReader.createFile(cproject2.getProject(), new Path("/source.cpp"), "namespace X { class A {}; }\n\n"); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()); + waitForIndexer(cproject2); IndexProviderManager ipm= CCoreInternals.getPDOMManager().getIndexProviderManager(); ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge( @@ -247,7 +247,7 @@ public class PDOMProviderTests extends PDOMTestBase { { ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER); TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n"); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()); + waitForIndexer(cproject); ResourceContainerRelativeLocationConverter cvr= new ResourceContainerRelativeLocationConverter(cproject.getProject()); CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, tempPDOM, cvr); CProjectHelper.delete(cproject); @@ -266,7 +266,7 @@ public class PDOMProviderTests extends PDOMTestBase { final URI baseURI= new File("c:/ExternalSDK/").toURI(); final ICProject cproject2= CProjectHelper.createCCProject("baz" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER); TestSourceReader.createFile(cproject2.getProject(), new Path("/source.cpp"), "namespace X { class A {}; }\n\n"); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()); + waitForIndexer(cproject2); IndexProviderManager ipm= CCoreInternals.getPDOMManager().getIndexProviderManager(); ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge( diff --git a/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/BaseTestFramework.java b/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/BaseTestFramework.java index 7df855cce1c..6d9b3e54e51 100644 --- a/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/BaseTestFramework.java +++ b/core/org.eclipse.cdt.core.tests/regression/org/eclipse/cdt/core/tests/BaseTestFramework.java @@ -18,13 +18,12 @@ package org.eclipse.cdt.core.tests; import java.io.ByteArrayInputStream; import java.io.InputStream; -import junit.framework.TestCase; - import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.FileManager; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; @@ -38,7 +37,7 @@ import org.eclipse.core.runtime.NullProgressMonitor; /** * @author aniefer */ -abstract public class BaseTestFramework extends TestCase { +abstract public class BaseTestFramework extends BaseTestCase { static protected NullProgressMonitor monitor; static protected IWorkspace workspace; static protected IProject project; @@ -109,13 +108,13 @@ abstract public class BaseTestFramework extends TestCase { return; IResource [] members = project.members(); - for (int i = 0; i < members.length; i++) { - if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$ + for (IResource member : members) { + if (member.getName().equals(".project") || member.getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$ continue; - if (members[i].getName().equals(".settings")) + if (member.getName().equals(".settings")) continue; try { - members[i].delete(false, monitor); + member.delete(false, monitor); } catch (Throwable e) { /*boo*/ } diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java index 3053135b962..6d23969e328 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java @@ -27,6 +27,7 @@ import junit.framework.TestResult; import junit.framework.TestSuite; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ElementChangedEvent; import org.eclipse.cdt.core.model.ICProject; @@ -37,12 +38,15 @@ import org.eclipse.cdt.internal.core.CCoreInternals; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase; import org.eclipse.cdt.internal.core.pdom.CModelListener; import org.eclipse.cdt.internal.core.pdom.PDOMManager; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.ILogListener; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.jobs.Job; public class BaseTestCase extends TestCase { protected static final int INDEXER_TIMEOUT_SEC = 10; @@ -247,7 +251,7 @@ public class BaseTestCase extends TestCase { * is a very basic means of doing that. */ static protected class ModelJoiner implements IElementChangedListener { - private boolean[] changed= new boolean[1]; + private final boolean[] changed= new boolean[1]; public ModelJoiner() { CoreModel.getDefault().addElementChangedListener(this); @@ -290,6 +294,8 @@ public class BaseTestCase extends TestCase { } public static void waitForIndexer(ICProject project) throws InterruptedException { + Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null); + final PDOMManager indexManager = CCoreInternals.getPDOMManager(); assertTrue(indexManager.joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm())); long waitms= 1; @@ -297,6 +303,11 @@ public class BaseTestCase extends TestCase { Thread.sleep(waitms); waitms *= 2; } + assertTrue(indexManager.isProjectRegistered(project)); assertTrue(indexManager.joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm())); } + + public static void waitUntilFileIsIndexed(IIndex index, IFile file) throws Exception { + TestSourceReader.waitUntilFileIsIndexed(index, file, INDEXER_TIMEOUT_SEC * 1000); + } } diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java index 26debd1fd69..c27a7e263f6 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java @@ -327,10 +327,12 @@ public class TestSourceReader { try { IIndexFile[] files= index.getFiles(ILinkage.CPP_LINKAGE_ID, indexFileLocation); if (files.length > 0 && areAllFilesNotOlderThan(files, fileTimestamp)) { + Assert.assertTrue(CCorePlugin.getIndexManager().joinIndexer(timeLeft, new NullProgressMonitor())); return; } files= index.getFiles(ILinkage.C_LINKAGE_ID, indexFileLocation); if (files.length > 0 && areAllFilesNotOlderThan(files, fileTimestamp)) { + Assert.assertTrue(CCorePlugin.getIndexManager().joinIndexer(timeLeft, new NullProgressMonitor())); return; } } finally { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java index 04e6abcb899..6979a04788c 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java @@ -43,13 +43,9 @@ import org.eclipse.ui.WorkbenchException; import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.ui.internal.WorkbenchPartReference; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.index.IIndex; -import org.eclipse.cdt.core.index.IIndexFile; -import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.model.CModelException; -import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; @@ -112,43 +108,6 @@ public class BaseUITestCase extends BaseTestCase { return TestSourceReader.createIndexBasedAST(index, project, file); } - protected void waitForIndexer(IIndex index, IFile file, int maxmillis) throws Exception { - boolean firstTime= true; - long endTime= System.currentTimeMillis() + maxmillis; - long sleep= 1; - while (firstTime || System.currentTimeMillis() < endTime) { - if (!firstTime) { - Thread.sleep(sleep); - sleep= Math.min(250, sleep * 2); - } - firstTime= false; - - if (CCorePlugin.getIndexManager().isIndexerSetupPostponed(CoreModel.getDefault().create(file.getProject()))) - continue; - try { - index.acquireReadLock(); - try { - IIndexFile[] indexFiles= index.getFiles(IndexLocationFactory.getWorkspaceIFL(file)); - for (IIndexFile indexFile : indexFiles) { - if (indexFile != null && indexFile.getTimestamp() >= file.getLocalTimeStamp()) { - return; - } - } - } finally { - index.releaseReadLock(); - int time= (int) (endTime - System.currentTimeMillis()); - if (time > 0) { - CCorePlugin.getIndexManager().joinIndexer(time, npm()); - } - } - } - catch (InterruptedException e) { - // index.acquireReadLock() can be interrupted - } - } - throw new Exception("Indexer did not complete in time!"); - } - protected void runEventQueue(int time) { final long endTime= System.currentTimeMillis() + time; while (true) { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java index 63e62bd3661..0b21feceff3 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java @@ -59,7 +59,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { private void doTestFunctions(String filename) throws IOException, Exception, PartInitException { String content = readTaggedComment("testFunctions"); IFile file= createFile(getProject(), filename, content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("proto"), 5); @@ -103,7 +103,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { private void doTestVariables(String filename) throws Exception { String content = readTaggedComment("testVariables"); IFile file= createFile(getProject(), filename, content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("extern_var"), 0); @@ -158,7 +158,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { private void doTestEnumerator(String filename, String contentTag) throws Exception { String content = readTaggedComment(contentTag); IFile file= createFile(getProject(), filename, content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("enumerator"), 0); @@ -213,7 +213,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { public void testStructMembersC() throws Exception { String content = readTaggedComment("testStructMembers"); IFile file= createFile(getProject(), "struct_member.c", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("mem1"), 0); @@ -259,7 +259,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { public void testStructMembersCpp() throws Exception { String content = readTaggedComment("testStructMembers"); IFile file= createFile(getProject(), "struct_member.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("mem1"), 0); @@ -305,7 +305,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { public void testAnonymousStructMembersC_156671() throws Exception { String content = readTaggedComment("testStructMembers"); IFile file= createFile(getProject(), "anon_struct_member.c", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("mem3"), 0); @@ -333,7 +333,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { public void testAnonymousStructMembersCpp_156671() throws Exception { String content = readTaggedComment("testStructMembers"); IFile file= createFile(getProject(), "anon_struct_member.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("mem3"), 0); @@ -395,7 +395,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { public void testUnionMembersC() throws Exception { String content = readTaggedComment("testUnionMembers"); IFile file= createFile(getProject(), "union_member.c", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("mem1"), 0); @@ -441,7 +441,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { public void testUnionMembersCpp() throws Exception { String content = readTaggedComment("testUnionMembers"); IFile file= createFile(getProject(), "union_member.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("mem1"), 0); @@ -487,7 +487,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { public void testAnonymousUnionMembersC_156671() throws Exception { String content = readTaggedComment("testUnionMembers"); IFile file= createFile(getProject(), "anon_union_member.c", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("mem3"), 0); @@ -515,7 +515,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { public void testAnonymousUnionMembersCpp_156671() throws Exception { String content = readTaggedComment("testUnionMembers"); IFile file= createFile(getProject(), "anon_union_member.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("mem3"), 0); @@ -556,8 +556,8 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { String content1= content2 + sbs[1].toString(); IFile file1= createFile(getProject(), "staticFunc1.c", content1); IFile file2= createFile(getProject(), "staticFunc2.c", content2); - waitForIndexer(fIndex, file1, INDEXER_WAIT_TIME); - waitForIndexer(fIndex, file2, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file1); + waitUntilFileIsIndexed(fIndex, file2); TreeItem i1, i2, i3, i4, i5, i6; Tree tree; @@ -625,8 +625,8 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { String content1= content2 + sbs[1].toString(); IFile file1= createFile(getProject(), "staticFunc1.cpp", content1); IFile file2= createFile(getProject(), "staticFunc2.cpp", content2); - waitForIndexer(fIndex, file1, INDEXER_WAIT_TIME); - waitForIndexer(fIndex, file2, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file1); + waitUntilFileIsIndexed(fIndex, file2); TreeItem i0, i1, i2, i3, i4, i5, i6; Tree tree; @@ -701,7 +701,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { try { String content = readTaggedComment("testFunctionsWithParams"); IFile file= createFile(getProject(), filename, content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("proto"), 5); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java index e302bab3f05..9fe45ef3778 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java @@ -51,7 +51,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void testMethods() throws Exception { String content = readTaggedComment("testMethods"); IFile file= createFile(getProject(), "testMethods.cpp", content); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("method"), 2); @@ -134,7 +134,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void testStaticMethods() throws Exception { String content = readTaggedComment("testStaticMethods"); IFile file= createFile(getProject(), "testStaticMethods.cpp", content); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("method"), 2); @@ -222,7 +222,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void testFields() throws Exception { String content = readTaggedComment("testFields"); IFile file= createFile(getProject(), "testFields.cpp", content); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("field"), 2); @@ -296,7 +296,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void testAutomaticConstructor_156668() throws Exception { String content = readTaggedComment("testAutomaticConstructor"); IFile file= createFile(getProject(), "testConstructor.cpp", content); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("MyClass()"), 2); @@ -309,7 +309,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void _testAutomaticDestructor_156668() throws Exception { String content = readTaggedComment("testAutomaticConstructor"); IFile file= createFile(getProject(), "testConstructor.cpp", content); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); openCallHierarchy(editor); Tree tree = getCHTreeViewer().getTree(); @@ -334,7 +334,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void testConstructor() throws Exception { String content = readTaggedComment("testConstructor"); IFile file= createFile(getProject(), "testConstructor.cpp", content); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("MyClass()"), 2); @@ -347,7 +347,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void testDestructor_156669() throws Exception { String content = readTaggedComment("testConstructor"); IFile file= createFile(getProject(), "testConstructor.cpp", content); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("~MyClass()"), 2); @@ -382,7 +382,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void testNamespace() throws Exception { String content = readTaggedComment("testNamespace"); IFile file= createFile(getProject(), "testNamespace.cpp", content); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("var"), 2); @@ -439,7 +439,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void testNamespacePart2_156519() throws Exception { String content = readTaggedComment("testNamespace"); IFile file= createFile(getProject(), "testNamespace.cpp", content); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("var; // r1"), 2); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java index fc4e9f8c776..e208ec0d490 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java @@ -46,7 +46,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { fCProject2= CProjectHelper.createCCProject("__chTest_2__", "bin", IPDOMManager.ID_NO_INDEXER); CCorePlugin.getIndexManager().setIndexerId(fCProject2, IPDOMManager.ID_FAST_INDEXER); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm()); + waitForIndexer(fCProject2); fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {fCProject, fCProject2}); TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()}; } @@ -86,9 +86,9 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { String header= content[0].toString(); String source = content[1].toString(); IFile headerFile= createFile(fCProject.getProject(), "testMethods.h", header); - waitForIndexer(fIndex, headerFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, headerFile); IFile sourceFile= createFile(fCProject2.getProject(), "testMethods.cpp", source); - waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, sourceFile); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); CEditor editor= openEditor(sourceFile); @@ -164,7 +164,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { IFile sourceFile2= createFile(fCProject2.getProject(), "testMethods2.cpp", source2); CEditor editor= openEditor(sourceFile1); - waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, sourceFile2); editor.selectAndReveal(source1.indexOf("method3"), 2); openCallHierarchy(editor); @@ -214,8 +214,8 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2); CEditor editor= openEditor(sourceFile1); - waitForIndexer(fIndex, sourceFile1, CallHierarchyBaseTest.INDEXER_WAIT_TIME); - waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, sourceFile1); + waitUntilFileIsIndexed(fIndex, sourceFile2); editor.selectAndReveal(source1.indexOf("method3"), 2); openCallHierarchy(editor); @@ -275,7 +275,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2); CEditor editor= openEditor(sourceFile2); - waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, sourceFile2); editor.selectAndReveal(source2.indexOf("main"), 2); openCallHierarchy(editor, false); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java index 7e8fc911de7..395255941b8 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java @@ -53,7 +53,7 @@ public class CallHierarchyBaseTest extends BaseUITestCase { CallHierarchyUI.setIsJUnitTest(true); String prjName= "chTest"+sProjectCounter++; fCProject= CProjectHelper.createCCProject(prjName, "bin", IPDOMManager.ID_FAST_INDEXER); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm()); + waitForIndexer(fCProject); fIndex= CCorePlugin.getIndexManager().getIndex(fCProject); IWorkbenchPage page= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewReference[] refs= page.getViewReferences(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java index 448259b6cd3..676f8940fbf 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java @@ -57,7 +57,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { StringBuilder[] contents = getContentsForTest(2); IFile file1= createFile(getProject(), "SomeClass.h", contents[0].toString()); IFile file2= createFile(getProject(), "SomeClass.cpp", contents[1].toString()); - waitForIndexer(fIndex, file2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file2); final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY); final IViewPart outline= activateView(IPageLayout.ID_OUTLINE); @@ -98,7 +98,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { StringBuilder[] contents = getContentsForTest(2); IFile file1= createFile(getProject(), "SomeClass.h", contents[0].toString()); IFile file2= createFile(getProject(), "SomeClass.cpp", contents[1].toString()); - waitForIndexer(fIndex, file2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file2); final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY); final IViewPart outline= activateView(IPageLayout.ID_OUTLINE); @@ -161,7 +161,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { public void testPolyMorphicMethodCalls_156689() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "SomeClass.cpp", content); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY); final IWorkbenchWindow workbenchWindow = ch.getSite().getWorkbenchWindow(); @@ -217,7 +217,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { public void testReversePolyMorphicMethodCalls_156689() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "SomeClass.cpp", content); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY); final IWorkbenchWindow workbenchWindow = ch.getSite().getWorkbenchWindow(); @@ -253,7 +253,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { public void testMethodInstance_Bug240599() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "CSome.cpp", content); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY); final IWorkbenchWindow workbenchWindow = ch.getSite().getWorkbenchWindow(); @@ -293,7 +293,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { public void testMultiplePolyMorphicMethodCalls_244987() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "SomeClass244987.cpp", content); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY); final IWorkbenchWindow workbenchWindow = ch.getSite().getWorkbenchWindow(); @@ -335,7 +335,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { public void testMacrosHidingCall_249801() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "file249801.cpp", content); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY); @@ -370,7 +370,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { IFile header= createFile(getProject(), "260262.h", hcontent); IFile f1= createFile(getProject(), "260262.c", content_full); IFile f2= createFile(getProject(), "260262.cpp", content_inc); - waitForIndexer(fIndex, f2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, f2); final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY); @@ -400,7 +400,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { IFile header= createFile(getProject(), "260262.h", hcontent); IFile f1= createFile(getProject(), "260262.c", content_full); IFile f2= createFile(getProject(), "260262.cpp", content_inc); - waitForIndexer(fIndex, f2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, f2); final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY); @@ -428,7 +428,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { final StringBuilder[] contents = getContentsForTest(1); final String content = contents[0].toString(); IFile f2= createFile(getProject(), "testUnnamedNamespace_283679.cpp", content); - waitForIndexer(fIndex, f2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, f2); final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY); @@ -463,7 +463,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { final StringBuilder[] contents = getContentsForTest(1); final String content = contents[0].toString(); IFile f2= createFile(getProject(), "testCallsToFromVirtualMethod_246064.cpp", content); - waitForIndexer(fIndex, f2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, f2); final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY); @@ -491,7 +491,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { public void testCallsToInstanceofSpecializedTemplate_361999() throws Exception { final String content = getAboveComment(); IFile f2= createFile(getProject(), "testCallsToInstanceofSpecializedTemplate_361999.cpp", content); - waitForIndexer(fIndex, f2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, f2); final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java index f97fe728d90..913a5669fad 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java @@ -19,8 +19,6 @@ import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PlatformUI; -import org.eclipse.cdt.core.CCorePlugin; - import org.eclipse.cdt.internal.ui.editor.CEditor; @@ -62,7 +60,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { String source = content[1].toString(); IFile headerFile= createFile(getProject(), "testMethods.h", header); IFile sourceFile= createFile(getProject(), "testMethods.cpp", source); - waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, sourceFile); CEditor editor= openEditor(sourceFile); editor.selectAndReveal(source.indexOf("method"), 2); @@ -136,7 +134,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2); CEditor editor= openEditor(sourceFile1); - waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, sourceFile2); editor.selectAndReveal(source1.indexOf("method3"), 2); openCallHierarchy(editor); @@ -185,7 +183,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1); IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2); - waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, sourceFile2); CEditor editor= openEditor(sourceFile1); editor.selectAndReveal(source1.indexOf("method3"), 2); @@ -246,7 +244,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2); CEditor editor= openEditor(sourceFile2); - waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, sourceFile2); editor.selectAndReveal(source2.indexOf("main"), 2); openCallHierarchy(editor, false); @@ -300,8 +298,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { IFile cFile= createFile(getProject(), "s.c", cSource); IFile cppFile= createFile(getProject(), "s.cpp", cppSource); CEditor editor= openEditor(cFile); - waitForIndexer(fIndex, cppFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm()); + waitUntilFileIsIndexed(fIndex, cppFile); editor.selectAndReveal(cSource.indexOf("cfunc"), 2); openCallHierarchy(editor); @@ -346,8 +343,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { IFile cppFile= createFile(getProject(), "s.cpp", cppSource); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); CEditor editor= openEditor(cFile); - waitForIndexer(fIndex, cppFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm()); + waitUntilFileIsIndexed(fIndex, cppFile); editor.selectAndReveal(cSource.indexOf("cfunc"), 2); openCallHierarchy(editor, false); @@ -415,8 +411,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { String source = content[0].toString(); IFile file= createFile(getProject(), "testTemplates.cpp", source); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm()); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); int pos= source.indexOf("f("); @@ -479,8 +474,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { String source = content[0].toString(); IFile file= createFile(getProject(), "testClosures.cpp", source); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm()); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); int pos= source.indexOf("a("); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java index 3df7c8de99f..981449f1f4c 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java @@ -33,7 +33,7 @@ public class InitializersInCallHierarchyTest extends CallHierarchyBaseTest { public void testCIntVarInitializer() throws Exception { String content = readTaggedComment("intvar"); IFile file= createFile(getProject(), "intvar.c", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor = openEditor(file); editor.selectAndReveal(content.indexOf("a"), 1); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java index f5174157a6a..a4e92ad7d20 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java @@ -48,7 +48,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest { IFile user= createFile(project, "user.h", ""); IFile system= createFile(project, "system.h", ""); IFile source= createFile(project, "source.cpp", contents[0].toString()); - waitForIndexer(fIndex, source, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, source); openIncludeBrowser(source); Tree tree = getIBTree(); @@ -83,7 +83,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest { IFile system= createFile(op.getProject(), "system.h", ""); IFile source= createFile(getProject().getProject(), "source.cpp", contents[0].toString()); CCorePlugin.getIndexManager().reindex(op); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM); + waitForIndexer(op); openIncludeBrowser(source); Tree tree = getIBTree(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java index 234a9bdec95..491633b4fc5 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java @@ -78,7 +78,7 @@ public class BasicOutlineTest extends BaseUITestCase { } private void waitForIndexer(IProject project, IFile source) throws Exception, CoreException { - waitForIndexer(CCorePlugin.getIndexManager().getIndex(fCProject), source, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(CCorePlugin.getIndexManager().getIndex(fCProject), source); } private void checkTreeItems(TreeItem[] items, String... labels) { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java index a461896c7df..e1836964b4f 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java @@ -130,8 +130,7 @@ public abstract class RefactoringTestBase extends BaseTestCase { selectedFile = testFiles.iterator().next(); } CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, - NULL_PROGRESS_MONITOR)); + waitForIndexer(cproject); } @Override diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java index 93c3c673ff7..4292c598f10 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java @@ -18,9 +18,6 @@ import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.index.IIndexManager; - import org.eclipse.cdt.internal.ui.refactoring.rename.CRefactoringArgument; import org.eclipse.cdt.internal.ui.refactoring.rename.CRefactory; import org.eclipse.cdt.internal.ui.refactoring.rename.CRenameProcessor; @@ -140,15 +137,7 @@ public class RenameTests extends RefactoringTests { } protected void waitForIndexer() throws InterruptedException { - final IIndexManager im = CCorePlugin.getIndexManager(); - assertTrue(im.joinIndexer(10000, NPM)); - int sleep= 1; - while (im.isIndexerSetupPostponed(cproject)) { - Thread.sleep(sleep); - sleep *= 2; - assertTrue(sleep < 2000); - } - assertTrue(im.joinIndexer(10000, NPM)); + waitForIndexer(cproject); } @Override diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java index 1502948a487..3eb1119f6fd 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java @@ -22,11 +22,8 @@ import junit.framework.TestSuite; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.ILabelProvider; @@ -74,10 +71,10 @@ public class BasicSearchTest extends BaseUITestCase { IFile file = TestSourceReader.createFile(fCProject.getProject(), new Path("header.h"), testData[0].toString()); CCorePlugin.getIndexManager().setIndexerId(fCProject, IPDOMManager.ID_FAST_INDEXER); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); + waitForIndexer(fCProject); IFile cppfile= TestSourceReader.createFile(fCProject.getProject(), new Path("references.cpp"), testData[1].toString()); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); + waitForIndexer(fCProject); } @Override @@ -106,7 +103,7 @@ public class BasicSearchTest extends BaseUITestCase { // rebuild the index TestScannerProvider.sIncludes= new String[] {dir.getAbsolutePath()}; CCorePlugin.getIndexManager().reindex(fCProject); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); + waitForIndexer(fCProject); // open a query CSearchQuery query= makeProjectQuery("foo"); @@ -149,7 +146,7 @@ public class BasicSearchTest extends BaseUITestCase { // rebuild the index with no indexer CCorePlugin.getIndexManager().setIndexerId(fCProject, IPDOMManager.ID_NO_INDEXER); CCorePlugin.getIndexManager().reindex(fCProject); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); + waitForIndexer(fCProject); // open a query CSearchQuery query= makeProjectQuery("x"); @@ -220,7 +217,7 @@ public class BasicSearchTest extends BaseUITestCase { coreTestIndexerInProgress(false); // now join and test again to get the full results - assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); + waitForIndexer(fCProject); coreTestIndexerInProgress(true); } @@ -322,8 +319,7 @@ public class BasicSearchTest extends BaseUITestCase { String newContent= "void bar() {}"; IFile file = fCProject.getProject().getFile(new Path("references.cpp")); file.setContents(new ByteArrayInputStream(newContent.getBytes()), IResource.FORCE, npm()); - Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); + waitForIndexer(fCProject); assertOccurrences(query, 1); } @@ -343,14 +339,13 @@ public class BasicSearchTest extends BaseUITestCase { runEventQueue(1000); IIndexManager indexManager = CCorePlugin.getIndexManager(); indexManager.update(new ICElement[] {fCProject}, IIndexManager.UPDATE_ALL); - assertTrue(indexManager.joinIndexer(360000, new NullProgressMonitor())); + waitForIndexer(fCProject); assertOccurrences(query, 2); String newContent2= "void bar() {foo(); foo();}"; file.setContents(new ByteArrayInputStream(newContent2.getBytes()), IResource.FORCE, npm()); - Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null); - assertTrue(indexManager.joinIndexer(360000, new NullProgressMonitor())); + waitForIndexer(fCProject); assertOccurrences(query, 3); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddIncludeTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddIncludeTest.java index 79ae7ebc54c..6e10ccf182a 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddIncludeTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddIncludeTest.java @@ -15,7 +15,6 @@ import java.util.ListResourceBundle; import junit.extensions.TestSetup; import junit.framework.Test; -import junit.framework.TestCase; import junit.framework.TestSuite; import org.eclipse.core.runtime.NullProgressMonitor; @@ -27,6 +26,7 @@ import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.ui.testplugin.ResourceTestHelper; @@ -37,7 +37,7 @@ import org.eclipse.cdt.internal.ui.editor.CEditor; /** * Tests the AddIncludeOnSelectionAction. */ -public class AddIncludeTest extends TestCase { +public class AddIncludeTest extends BaseTestCase { private static final String PROJECT= "AddIncludeTests"; private static final class EmptyBundle extends ListResourceBundle { @@ -59,8 +59,7 @@ public class AddIncludeTest extends TestCase { super.setUp(); fCProject= EditorTestHelper.createCProject(PROJECT, "resources/addInclude"); CCorePlugin.getIndexManager().setIndexerId(fCProject, IPDOMManager.ID_FAST_INDEXER); - // Wait until the indexer is done - assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor())); + waitForIndexer(fCProject); } @Override diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java index 822b57ee29e..b67a838ec67 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java @@ -31,7 +31,6 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; @@ -51,26 +50,25 @@ import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistProcessor; * @author aniefer */ public class ContentAssistTests extends BaseUITestCase { - private NullProgressMonitor monitor= new NullProgressMonitor(); + private final NullProgressMonitor monitor= new NullProgressMonitor(); static IProject project; + static ICProject cproject; static boolean disabledHelpContributions = false; @Override - public void setUp() { + public void setUp() throws InterruptedException { //(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset(); if (project == null) { - ICProject cPrj; try { - cPrj = CProjectHelper.createCCProject("ContentAssistTestProject", "bin", IPDOMManager.ID_FAST_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$ - - project = cPrj.getProject(); + cproject = CProjectHelper.createCCProject("ContentAssistTestProject", "bin", IPDOMManager.ID_FAST_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$ + project = cproject.getProject(); + waitForIndexer(cproject); } catch ( CoreException e ) { /*boo*/ } if (project == null) fail("Unable to create project"); //$NON-NLS-1$ - assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, monitor)); } } public ContentAssistTests() @@ -125,7 +123,7 @@ public class ContentAssistTests extends BaseUITestCase { closeAllEditors(); // wait for indexer before deleting project to avoid errors in the log - CCorePlugin.getIndexManager().joinIndexer(10000, monitor); + waitForIndexer(cproject); IResource [] members = project.members(); for (IResource member : members) { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java index ffdf98e0212..e39e48b2b2a 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java @@ -19,7 +19,6 @@ import java.util.List; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.TextUtilities; import org.eclipse.jface.text.contentassist.ContentAssistant; @@ -30,7 +29,6 @@ import org.eclipse.jface.text.templates.TemplateProposal; import org.eclipse.ui.texteditor.AbstractTextEditor; import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; @@ -55,7 +53,7 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase { protected ICProject fCProject; private IFile fCFile; protected ITextEditor fEditor; - private boolean fIsCpp; + private final boolean fIsCpp; public AbstractContentAssistTest(String name, boolean isCpp) { super(name); @@ -73,7 +71,7 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase { } fCFile= setUpProjectContent(fCProject.getProject()); assertNotNull(fCFile); - CCorePlugin.getIndexManager().joinIndexer(8000, new NullProgressMonitor()); + waitForIndexer(fCProject); fEditor= (ITextEditor)EditorTestHelper.openInEditor(fCFile, true); assertNotNull(fEditor); CPPASTNameBase.sAllowNameComputation= true; @@ -129,22 +127,20 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase { if (CTestPlugin.getDefault().isDebugging()) { System.out.println("Time (ms): " + (endTime-startTime)); - for (int i = 0; i < resultStrings.length; i++) { - String proposal = resultStrings[i]; + for (String proposal : resultStrings) { System.out.println("Result: " + proposal); } } boolean allFound = true ; // for the time being, let's be optimistic - for (int i = 0; i< expected.length; i++){ + for (String element : expected) { boolean found = false; - for(int j = 0; j< resultStrings.length; j++){ - String proposal = resultStrings[j]; - if(expected[i].equals(proposal)){ + for (String proposal : resultStrings) { + if(element.equals(proposal)){ found = true; if (CTestPlugin.getDefault().isDebugging()) { - System.out.println("Lookup success for " + expected[i]); + System.out.println("Lookup success for " + element); } break; } @@ -152,7 +148,7 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase { if (!found) { allFound = false ; if (CTestPlugin.getDefault().isDebugging()) { - System.out.println( "Lookup failed for " + expected[i]); //$NON-NLS-1$ + System.out.println( "Lookup failed for " + element); //$NON-NLS-1$ } } } @@ -177,8 +173,7 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase { */ private Object[] filterResults(Object[] results, boolean isCodeCompletion) { List filtered= new ArrayList(); - for (int i = 0; i < results.length; i++) { - Object result = results[i]; + for (Object result : results) { if (result instanceof TemplateProposal) { continue; } @@ -206,8 +201,7 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase { */ private Object[] filterResultsKeepTemplates(Object[] results) { List filtered= new ArrayList(); - for (int i = 0; i < results.length; i++) { - Object result = results[i]; + for (Object result : results) { if (result instanceof TemplateProposal) { filtered.add(result); } @@ -248,8 +242,8 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase { private String toString(String[] strings) { StringBuffer buf= new StringBuffer(); - for(int i=0; i< strings.length; i++){ - buf.append(strings[i]).append('\n'); + for (String string : strings) { + buf.append(string).append('\n'); } return buf.toString(); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java index bc27e46dee4..0bcba3b64f0 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java @@ -26,7 +26,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.jface.text.IDocument; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.testplugin.TestScannerProvider; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; @@ -862,11 +861,11 @@ public class CompletionTests extends AbstractContentAssistTest { }; String disturbContent= readTaggedComment(DISTURB_FILE_NAME); IFile dfile= createFile(fProject, DISTURB_FILE_NAME, disturbContent); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(8000, npm())); + waitForIndexer(fCProject); assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_REP_STRINGS); dfile.delete(true, npm()); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(8000, npm())); + waitForIndexer(fCProject); assertCompletionResults(fCursorOffset, expected2, AbstractContentAssistTest.COMPARE_REP_STRINGS); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java index b5da4972d4c..d6583096a79 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java @@ -17,7 +17,6 @@ import junit.framework.Test; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.text.IDocument; import org.eclipse.cdt.core.CCorePlugin; @@ -182,7 +181,7 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest { IFile sourceFile= createFile(project, SOURCE_FILE_NAME, sourceContent.toString()); // re-indexing is necessary to parse the header in context of the source. CCorePlugin.getIndexManager().reindex(fCProject); - CCorePlugin.getIndexManager().joinIndexer(4000, new NullProgressMonitor()); + waitForIndexer(fCProject); return sourceFile; } @@ -232,11 +231,11 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest { }; String disturbContent= readTaggedComment(DISTURB_FILE_NAME); IFile dfile= createFile(fProject, DISTURB_FILE_NAME, disturbContent); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(8000, npm())); + waitForIndexer(fCProject); assertCompletionResults(expected); dfile.delete(true, npm()); - assertTrue(CCorePlugin.getIndexManager().joinIndexer(8000, npm())); + waitForIndexer(fCProject); assertCompletionResults(expected2); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java index d38ec492a87..75fc638be06 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java @@ -43,16 +43,13 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.AbstractTextEditor; -import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.FileManager; -import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; @@ -89,14 +86,6 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase { } } - public void waitForIndex(int maxSec) throws Exception { - assertTrue(CCorePlugin.getIndexManager().joinIndexer(maxSec * 1000, new NullProgressMonitor())); - } - - protected void waitUntilFileIsIndexed(IIndex index, IFile file) throws Exception { - TestSourceReader.waitUntilFileIsIndexed(index, file, INDEXER_TIMEOUT_SEC * 1000); - } - protected String getMessage(IStatus status) { StringBuffer message = new StringBuffer("["); //$NON-NLS-1$ message.append(status.getMessage()); @@ -123,7 +112,7 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase { fileManager.addFile(file); - waitForIndex(20); // only wait 20 seconds max. + waitForIndexer(fCProject); return file; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java index 436afbe29c1..c56a72f0917 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java @@ -834,7 +834,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde IFile hcppfile = importFile("cpp.h", hcppcode); IFile cppfile = importFile("cpp.cpp", cppcode); CCorePlugin.getIndexManager().reindex(fCProject); - waitForIndex(INDEXER_TIMEOUT_SEC * 1000); + waitForIndexer(fCProject); IASTNode decl; int offset0, offset1; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/ResolveBindingTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/ResolveBindingTests.java index 743799c60d3..28481417fc2 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/ResolveBindingTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/ResolveBindingTests.java @@ -108,7 +108,7 @@ public class ResolveBindingTests extends BaseUITestCase { public void testNamespaceVarBinding() throws Exception { String content = readTaggedComment("namespace-var-test"); IFile file= createFile(fCProject.getProject(), "nsvar.cpp", content); - waitForIndexer(fIndex, file, WAIT_FOR_INDEXER); + waitUntilFileIsIndexed(fIndex, file); IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject); index.acquireReadLock(); @@ -132,7 +132,7 @@ public class ResolveBindingTests extends BaseUITestCase { public void testNamespaceVarBinding_156519() throws Exception { String content = readTaggedComment("namespace-var-test"); IFile file= createFile(fCProject.getProject(), "nsvar.cpp", content); - waitForIndexer(fIndex, file, WAIT_FOR_INDEXER); + waitUntilFileIsIndexed(fIndex, file); IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject); index.acquireReadLock(); @@ -173,7 +173,7 @@ public class ResolveBindingTests extends BaseUITestCase { IFile hfile= createFile(fCProject.getProject(), "testMethods.h", content); content = readTaggedComment("testMethods.cpp"); IFile cppfile= createFile(fCProject.getProject(), "testMethods.cpp", content); - waitForIndexer(fIndex, hfile, WAIT_FOR_INDEXER); + waitUntilFileIsIndexed(fIndex, hfile); IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject); index.acquireReadLock(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java index 4d06bddb2e2..456438fb018 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java @@ -36,7 +36,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { public void testEnumC() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "enum.c", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; TreeItem item; @@ -72,7 +72,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { public void testEnumCFromMember() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "enummem.c", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; TreeItem item; @@ -108,7 +108,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { public void testEnumCPP() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "enum.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; TreeItem item; @@ -144,7 +144,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { public void testEnumCPPFromMember() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "enummem.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; TreeItem item; @@ -188,7 +188,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { public void testStructC() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "struct.c", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); editor.selectAndReveal(content.indexOf("S1"), 1); @@ -242,7 +242,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { public void testStructCFromMember() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "structmem.c", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); editor.selectAndReveal(content.indexOf("a1"), 1); @@ -276,7 +276,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { public void testStructCPP() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "struct.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); editor.selectAndReveal(content.indexOf("S1"), 1); @@ -331,7 +331,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { public void testStructCPPFromMember() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "structmem.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); editor.selectAndReveal(content.indexOf("a1"), 1); @@ -365,7 +365,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { public void testUnionC() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "union.c", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); editor.selectAndReveal(content.indexOf("U1"), 1); @@ -415,7 +415,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { public void testUnionCFromMember() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "unionmem.c", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); editor.selectAndReveal(content.indexOf("a1"), 1); @@ -441,7 +441,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { public void testUnionCPP() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "union.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); editor.selectAndReveal(content.indexOf("U1"), 1); @@ -500,7 +500,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest { public void testUnionCPPFromMember() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "unionmem.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); editor.selectAndReveal(content.indexOf("a1"), 1); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java index 0f0f96fad04..fbdbc0281b2 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java @@ -52,7 +52,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { public void testSimpleInheritance() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "class.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; TreeItem item1, item2, item3, item4; @@ -145,7 +145,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { public void testSimpleInheritanceFromMember() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "classmem.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; TreeItem item1, item2, item3, item4; @@ -238,7 +238,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { public void testMultipleInheritance() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "multi.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; @@ -349,7 +349,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { public void testMultipleInheritanceFromMember() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "multimem.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; @@ -460,7 +460,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { public void testDiamondInheritance() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "diamond.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; @@ -571,7 +571,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { public void testDiamondInheritanceFromMember() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "diamondmem.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; @@ -679,7 +679,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { public void testViaTypedefInheritance() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "viaTypedef.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; @@ -770,7 +770,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { public void testViaTypedefInheritanceFromMember() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "viaTypedefmem.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; @@ -849,7 +849,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest { public void testTemplatesNoInheritance() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "simpleTemplate.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java index f6631f137f1..2c6ce79c394 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java @@ -53,7 +53,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { public void testSimpleInheritance() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "class.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; @@ -149,7 +149,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { public void testSimpleInheritanceFromMember() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "classmem.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; @@ -231,7 +231,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { public void testMultipleInheritance() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "multi.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; @@ -342,7 +342,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { public void testMultipleInheritanceFromMember() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "multimem.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; @@ -434,7 +434,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { public void testDiamondInheritance() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "diamond.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; @@ -545,7 +545,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { public void testDiamondInheritanceFromMember() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "diamondmem.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; @@ -632,7 +632,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { public void testViaTypedefInheritance() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "viaTypedef.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; @@ -726,7 +726,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest { public void testViaTypedefInheritanceFromMember() throws Exception { String content= getContentsForTest(1)[0].toString(); IFile file= createFile(getProject(), "viaTypedefmem.cpp", content); - waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, file); CEditor editor= openEditor(file); Tree tree; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java index 3b490ffa356..24979d81737 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java @@ -90,7 +90,7 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest { String source = content[1].toString(); IFile headerFile= createFile(fCProject.getProject(), "simpleHeader.h", header); IFile sourceFile= createFile(fCProject2.getProject(), "simple.cpp", source); - waitForIndexer(fIndex, sourceFile, TypeHierarchyBaseTest.INDEXER_WAIT_TIME); + waitUntilFileIsIndexed(fIndex, sourceFile); CEditor editor= openEditor(sourceFile); Tree tree; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java index 1f94c84f23b..ad87db587d3 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java @@ -56,7 +56,7 @@ public class TypeHierarchyBaseTest extends BaseUITestCase { protected void setUp() throws Exception { super.setUp(); fCProject= CProjectHelper.createCCProject("__thTest__", "bin", IPDOMManager.ID_FAST_INDEXER); - CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm()); + waitForIndexer(fCProject); fIndex= CCorePlugin.getIndexManager().getIndex(fCProject); } From b1fc6f69bef0788f34d8c0f6eb4f173b8e62bfb9 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Sun, 16 Sep 2012 07:22:50 -0400 Subject: [PATCH 16/16] bug 357442: User-friendlier message about missing toolchain --- ...figurationEnvironmentVariableSupplier.java | 68 +++++++++---------- .../dataprovider/BuildConfigurationData.java | 20 +++--- .../DataProviderMessages.properties | 2 +- 3 files changed, 44 insertions(+), 46 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IConfigurationEnvironmentVariableSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IConfigurationEnvironmentVariableSupplier.java index a52d4a873d5..2ad85459956 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IConfigurationEnvironmentVariableSupplier.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/envvar/IConfigurationEnvironmentVariableSupplier.java @@ -13,49 +13,45 @@ package org.eclipse.cdt.managedbuilder.envvar; import org.eclipse.cdt.managedbuilder.core.IConfiguration; /** - * - * this interface is to be implemented by the tool-integrator - * for supplying the configuration-specific environment - * + * This interface is to be implemented by the tool-integrator for supplying the configuration-specific + * environment. + * * @since 3.0 */ -public interface IConfigurationEnvironmentVariableSupplier{ +public interface IConfigurationEnvironmentVariableSupplier { /** - * - * @param variableName the variable name - * @param configuration configuration + * @param variableName - the variable name. + * @param configuration - configuration. * @param provider the instance of the environment variable provider to be used for querying the - * environment variables from within the supplier. The supplier should use this provider to obtain - * the already defined environment instead of using the "default" provider returned by the - * ManagedBuildManager.getEnvironmentVariableProvider(). - * The provider passed to a supplier will ignore searching the variables for the levels - * higher than the current supplier level, will query only the lower-precedence suppliers - * for the current level and will query all suppliers for the lower levels. - * This is done to avoid infinite loops that could be caused if the supplier calls the provider - * and the provider in turn calls that supplier again. Also the supplier should not know anything - * about the environment variables defined for the higher levels. - * @return the reference to the IBuildEnvironmentVariable interface representing - * the variable of a given name + * environment variables from within the supplier. The supplier should use this provider to obtain + * the already defined environment instead of using the "default" provider returned by the + * ManagedBuildManager.getEnvironmentVariableProvider(). + * The provider passed to a supplier will ignore searching the variables for the levels + * higher than the current supplier level, will query only the lower-precedence suppliers + * for the current level and will query all suppliers for the lower levels. + * This is done to avoid infinite loops that could be caused if the supplier calls the provider + * and the provider in turn calls that supplier again. Also the supplier should not know anything + * about the environment variables defined for the higher levels. + * @return The reference to the IBuildEnvironmentVariable interface representing + * the variable of a given name or {@code null} if the variable is not defined. */ - IBuildEnvironmentVariable getVariable(String variableName, - IConfiguration configuration, - IEnvironmentVariableProvider provider); + IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration, IEnvironmentVariableProvider provider); /** - * @param configuration configuration - * @param provider the instance of the environment variable provider to be used for querying the - * environment variables from within the supplier. The supplier should use this provider to obtain - * the already defined environment instead of using the "default" provider returned by the - * ManagedBuildManager.getEnvironmentVariableProvider(). - * The provider passed to a supplier will ignore searching the variables for the levels - * higher than the current supplier level, will query only the lower-precedence suppliers - * for the current level and will query all suppliers for the lower levels. - * This is done to avoid infinite loops that could be caused if the supplier calls the provider - * and the provider in turn calls that supplier again. Also the supplier should not know anything - * about the environment variables defined for the higher levels. - * @return the array of IBuildEnvironmentVariable that represents the environment variables + * @param configuration - configuration. + * @param provider - the instance of the environment variable provider to be used for querying the + * environment variables from within the supplier. The supplier should use this provider to obtain + * the already defined environment instead of using the "default" provider returned by the + * ManagedBuildManager.getEnvironmentVariableProvider(). + * The provider passed to a supplier will ignore searching the variables for the levels + * higher than the current supplier level, will query only the lower-precedence suppliers + * for the current level and will query all suppliers for the lower levels. + * This is done to avoid infinite loops that could be caused if the supplier calls the provider + * and the provider in turn calls that supplier again. Also the supplier should not know anything + * about the environment variables defined for the higher levels. + * @return The array of IBuildEnvironmentVariable that represents the environment variables. + * If the array contains any {@code null} it will be ignored. */ - IBuildEnvironmentVariable[] getVariables (IConfiguration configuration, - IEnvironmentVariableProvider provider); + IBuildEnvironmentVariable[] getVariables(IConfiguration configuration, IEnvironmentVariableProvider provider); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildConfigurationData.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildConfigurationData.java index 4886881035a..1a88d7fd75f 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildConfigurationData.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildConfigurationData.java @@ -26,6 +26,7 @@ import org.eclipse.cdt.managedbuilder.core.IFileInfo; import org.eclipse.cdt.managedbuilder.core.IFolderInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.ITool; +import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.managedbuilder.internal.core.Configuration; @@ -39,7 +40,7 @@ public class BuildConfigurationData extends CConfigurationData { public BuildConfigurationData(IConfiguration cfg){ fCfg = (Configuration)cfg; } - + public IConfiguration getConfiguration(){ return fCfg; } @@ -51,7 +52,7 @@ public class BuildConfigurationData extends CConfigurationData { IFileInfo info = fCfg.createFileInfo(path, ((BuildFileData)base).getFileInfo(), id, path.lastSegment()); return info.getFileData(); } - + @Override public CFileData createFileData(IPath path, CFolderData base, CLanguageData baseLangData) throws CoreException { @@ -67,7 +68,7 @@ public class BuildConfigurationData extends CConfigurationData { } - + @Override public CFolderData createFolderData(IPath path, CFolderData base) throws CoreException { @@ -153,7 +154,7 @@ public class BuildConfigurationData extends CConfigurationData { // return fCdtVars; return new BuildVariablesContributor(this); } - + void clearCachedData(){ fCfg.clearCachedData(); CResourceData[] datas = getResourceDatas(); @@ -161,7 +162,7 @@ public class BuildConfigurationData extends CConfigurationData { // BuildLanguageData lData; // BuildLanguageData[] lDatas; - + for(int i = 0; i < datas.length; i++){ data = datas[i]; if(data.getType() == ICSettingBase.SETTING_FOLDER){ @@ -178,16 +179,17 @@ public class BuildConfigurationData extends CConfigurationData { String msg = null; if(!fCfg.isSupported()){ flags |= CConfigurationStatus.TOOLCHAIN_NOT_SUPPORTED; - msg = DataProviderMessages.getString("BuildConfigurationData.NoConfigurationSupport"); //$NON-NLS-1$ - + IToolChain toolChain = fCfg.getToolChain(); + String tname = toolChain != null ? toolChain.getName() : ""; //$NON-NLS-1$ + msg = NLS.bind(DataProviderMessages.getString("BuildConfigurationData.NoToolchainSupport"), tname); //$NON-NLS-1$ } else if (ManagedBuildManager.getExtensionConfiguration(fCfg)==null){ flags |= CConfigurationStatus.SETTINGS_INVALID; msg = NLS.bind(DataProviderMessages.getString("BuildConfigurationData.OrphanedConfiguration"), fCfg.getId()); //$NON-NLS-1$ } - + if(flags != 0) return new CConfigurationStatus(ManagedBuilderCorePlugin.getUniqueIdentifier(), flags, msg, null); - + return CConfigurationStatus.CFG_STATUS_OK; } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/DataProviderMessages.properties b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/DataProviderMessages.properties index 0d61f21330a..1127a644861 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/DataProviderMessages.properties +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/DataProviderMessages.properties @@ -21,5 +21,5 @@ ProjectConverter.6=the project conversion failed ProjectConverter.7=targets conversion ProjectConverter.8=the project conversion failed due to unknown reason ProjectConverter.9=the given project is not a valid CDT project -BuildConfigurationData.NoConfigurationSupport=The configuration support is not installed on the system +BuildConfigurationData.NoToolchainSupport=Toolchain "{0}" is not detected. Refer to "C/C++ Development User Guide", "Before you begin" about installing toolchains. BuildConfigurationData.OrphanedConfiguration=Orphaned configuration. No base extension cfg exists for {0}