From bb9be952d5be1d9f33ab0952cafd3f69054e9872 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Sat, 17 Mar 2012 06:39:04 -0400 Subject: [PATCH 1/9] bug 261976: Externalize strings --- .../src/org/eclipse/cdt/core/CommandLauncher.java | 8 +++++--- .../cdt/internal/core/CCorePluginResources.properties | 2 -- .../utils/org/eclipse/cdt/internal/core/Messages.java | 2 ++ .../org/eclipse/cdt/internal/core/messages.properties | 2 ++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java index dd7c0d68023..a8f38c8bef2 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java @@ -16,6 +16,7 @@ import java.io.OutputStream; import java.util.Properties; import org.eclipse.cdt.internal.core.Cygwin; +import org.eclipse.cdt.internal.core.Messages; import org.eclipse.cdt.internal.core.ProcessClosure; import org.eclipse.cdt.utils.PathUtil; import org.eclipse.cdt.utils.spawner.EnvironmentReader; @@ -25,6 +26,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Platform; +import org.eclipse.osgi.util.NLS; /** * @noextend This class is not intended to be subclassed by clients. @@ -201,8 +203,8 @@ public class CommandLauncher implements ICommandLauncher { envPathValue = System.getenv(PATH_ENV); } errorMessage = errorMessage + NEWLINE - + "Error: Program \"" + command + "\" not found in PATH" + NEWLINE - + "PATH=[" + envPathValue + "]" + NEWLINE; + + NLS.bind(Messages.CommandLauncher_ProgramNotFoundInPath, command) + NEWLINE + + "PATH=[" + envPathValue + "]" + NEWLINE; //$NON-NLS-1$ //$NON-NLS-2$ } setErrorMessage(errorMessage); fProcess = null; @@ -258,7 +260,7 @@ public class CommandLauncher implements ICommandLauncher { if (monitor.isCanceled()) { closure.terminate(); state = COMMAND_CANCELED; - setErrorMessage(CCorePlugin.getResourceString("CommandLauncher.error.commandCanceled")); //$NON-NLS-1$ + setErrorMessage(Messages.CommandLauncher_CommandCancelled); } try { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties index 44d8af158f9..cfcf1d84e09 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties @@ -26,8 +26,6 @@ CoreModel.PathEntry.DuplicateEntry= Duplicate path entries found ({0}), path: [{ CoreModel.PathEntry.NestedEntry= Nested path entries CoreModel.PathEntry.InvalidPathEntry= Invalid path -CommandLauncher.error.commandCanceled=Command canceled - CCProjectNature.exception.noNature=Project must have a cnature CCorePlugin.exception.noBinaryFormat=No Binary Format diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Messages.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Messages.java index a0894b911e6..56fead20b7e 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Messages.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Messages.java @@ -16,6 +16,8 @@ public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.messages"; //$NON-NLS-1$ public static String Util_unexpectedError; public static String Addr_valueOutOfRange; + public static String CommandLauncher_CommandCancelled; + public static String CommandLauncher_ProgramNotFoundInPath; public static String convention_illegalIdentifier; public static String convention_invalid; public static String convention_reservedKeyword; diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/messages.properties b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/messages.properties index 4e97e95a535..9c51cb755e7 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/messages.properties +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/messages.properties @@ -47,6 +47,8 @@ convention_enum_invalidName= Enum name is invalid Util_unexpectedError=Unexpected error Addr_valueOutOfRange=Address is outside valid range. +CommandLauncher_CommandCancelled=Command canceled +CommandLauncher_ProgramNotFoundInPath=Error: Program "{0}" not found in PATH XmlUtil_InternalErrorLoading=Internal error while trying to load XML document XmlUtil_InternalErrorSerializing=Internal error while trying to serialize XML Document. From bfb9dae292608eb2ff1de2ce9c4f0bc6739f401e Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sat, 17 Mar 2012 17:03:15 -0700 Subject: [PATCH 2/9] Added dependency on com.ibm.icu plug-in in an attempt to fix broken Hudson build. --- .../org.eclipse.cdt.core/META-INF/MANIFEST.MF | 14 ++++---- core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF | 32 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF index c81a487398c..b4582b3b0ab 100644 --- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF @@ -108,14 +108,14 @@ Export-Package: org.eclipse.cdt.core, org.eclipse.cdt.utils.spawner, org.eclipse.cdt.utils.xcoff, org.eclipse.cdt.utils.xcoff.parser -Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)", - org.eclipse.core.contenttype;bundle-version="[3.3.0,4.0.0)", - org.eclipse.text;bundle-version="[3.2.0,4.0.0)", - org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)", +Require-Bundle: org.eclipse.core.contenttype;bundle-version="[3.3.0,4.0.0)", org.eclipse.core.filebuffers;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.filesystem;bundle-version="[1.1.0,2.0.0)", - org.eclipse.ltk.core.refactoring;bundle-version="3.4.0" + org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)", + org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)", + org.eclipse.ltk.core.refactoring;bundle-version="3.4.0", + org.eclipse.text;bundle-version="[3.2.0,4.0.0)", + com.ibm.icu;bundle-version="4.4.2" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Import-Package: com.ibm.icu.text diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF index 993b6f1a79d..d5fbc3e8463 100644 --- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF @@ -95,26 +95,26 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true, org.eclipse.cdt.ui.wizards, org.eclipse.cdt.ui.wizards.conversion, org.eclipse.cdt.utils.ui.controls -Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.3.0,4.0.0)", - org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)", - org.eclipse.jface.text;bundle-version="[3.4.0,4.0.0)", - org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)", - org.eclipse.ui.editors;bundle-version="[3.3.0,4.0.0)", - org.eclipse.ui;bundle-version="[3.3.0,4.0.0)", - org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)", - org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", - org.eclipse.search;bundle-version="[3.2.0,4.0.0)", +Require-Bundle: org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)", org.eclipse.compare;bundle-version="[3.3.0,4.0.0)", - org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)", - org.eclipse.ui.console;bundle-version="[3.1.100,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)", - org.eclipse.help;bundle-version="[3.2.0,4.0.0)", - org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.filesystem;bundle-version="[1.1.0,2.0.0)", + org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)", org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)", + org.eclipse.help;bundle-version="[3.2.0,4.0.0)", + org.eclipse.jface.text;bundle-version="[3.4.0,4.0.0)", org.eclipse.ltk.core.refactoring;bundle-version="3.4.0", org.eclipse.ltk.ui.refactoring;bundle-version="3.4.0", - org.eclipse.ui.navigator.resources;bundle-version="3.3.100" + org.eclipse.search;bundle-version="[3.2.0,4.0.0)", + org.eclipse.ui;bundle-version="[3.3.0,4.0.0)", + org.eclipse.ui.console;bundle-version="[3.1.100,4.0.0)", + org.eclipse.ui.editors;bundle-version="[3.3.0,4.0.0)", + org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)", + org.eclipse.ui.ide;bundle-version="[3.3.0,4.0.0)", + org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)", + org.eclipse.ui.navigator.resources;bundle-version="3.3.100", + org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)", + org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)", + com.ibm.icu;bundle-version="4.4.2" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Import-Package: com.ibm.icu.text From 51fdcf8efdbaafc698d7f9ec657307f39d0bb54c Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sat, 17 Mar 2012 17:51:38 -0700 Subject: [PATCH 3/9] Fixed a typo. --- build/org.eclipse.cdt.autotools.ui/plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/org.eclipse.cdt.autotools.ui/plugin.xml b/build/org.eclipse.cdt.autotools.ui/plugin.xml index ae7e7e89b99..9413f67e7ee 100644 --- a/build/org.eclipse.cdt.autotools.ui/plugin.xml +++ b/build/org.eclipse.cdt.autotools.ui/plugin.xml @@ -248,7 +248,7 @@ category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage" class="org.eclipse.cdt.internal.autotools.ui.preferences.AutotoolsPreferencePage" id="org.eclipse.cdt.autotools.ui.preferences1" - name="%PreferencAutotools.name"> + name="%PreferenceAutotools.name"> Date: Sat, 17 Mar 2012 18:28:43 -0700 Subject: [PATCH 4/9] Fixed a typo. --- .../parser/org/eclipse/cdt/internal/core/pdom/PDOM.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 4c9bf0ef0e5..435a9249e97 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 @@ -208,7 +208,7 @@ public class PDOM extends PlatformObject implements IPDOM { * #114.0# - Partial specializations for class template specializations, bug 332884. * - Corrected signatures for function templates, bug 335062. <> * - * CDT 8.1 development (versions not supported on teh 8.0.x branch) + * CDT 8.1 development (versions not supported on the 8.0.x branch) * 120.0 - Enumerators in global index, bug 356235 * 120.1 - Specializations of using declarations, bug 357293. * 121.0 - Multiple variants of included header file, bug 197989. From 6f839b70112ea7cfc1da3e9aa52710bc80ad263f Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sat, 17 Mar 2012 19:43:24 -0700 Subject: [PATCH 5/9] Removed uses of a deprecated method. --- .../internal/pdom/tests/FilesOnReindexTests.java | 2 +- .../ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) 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 33d48658c23..c0a85089379 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 @@ -72,7 +72,7 @@ public class FilesOnReindexTests extends PDOMTestBase { void performAssertions(IFile file) throws CoreException { IIndex index = CCorePlugin.getIndexManager().getIndex(project); - assertNotNull(index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file))); + assertTrue(index.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)).length != 0); IBinding[] bs = index.findBindings(Pattern.compile("C"), true, IndexFilter.ALL, new NullProgressMonitor()); assertEquals(1, bs.length); 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 c0f5047458b..c8a9ef8cec8 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,7 +43,6 @@ import org.eclipse.ui.WorkbenchException; import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexFile; @@ -133,13 +132,11 @@ public class BaseUITestCase extends BaseTestCase { continue; index.acquireReadLock(); try { - IIndexFile pfile= index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); - if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) { - return; - } - pfile= index.getFile(ILinkage.C_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)); - if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) { - return; + IIndexFile[] indexFiles= index.getFiles(IndexLocationFactory.getWorkspaceIFL(file)); + for (IIndexFile indexFile : indexFiles) { + if (indexFile != null && indexFile.getTimestamp() >= file.getLocalTimeStamp()) { + return; + } } } finally { index.releaseReadLock(); From d3b2a6305b22ad712214052a8fd69c3f0c30884e Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sat, 17 Mar 2012 19:45:07 -0700 Subject: [PATCH 6/9] Cosmetics. --- .../eclipse/cdt/internal/pdom/tests/FilesOnReindexTests.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 c0a85089379..81c3824b6b2 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 @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Symbian - Initial implementation + * Symbian - Initial implementation *******************************************************************************/ package org.eclipse.cdt.internal.pdom.tests; @@ -33,7 +33,6 @@ import org.eclipse.core.runtime.NullProgressMonitor; * See bugzilla */ public class FilesOnReindexTests extends PDOMTestBase { - protected ICProject project; protected IIndex pdom; From 0496018fadfe80c0e53ccd393353d8e7e30ad235 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sat, 17 Mar 2012 21:53:29 -0700 Subject: [PATCH 7/9] Cosmetics. --- .../internal/core/model/TranslationUnit.java | 19 +- .../dom/parser/cpp/semantics/CPPVisitor.java | 2 +- .../cdt/internal/core/index/CIndex.java | 2 +- .../eclipse/cdt/internal/core/pdom/PDOM.java | 1 + .../cdt/internal/core/pdom/db/BTree.java | 184 +++++++++--------- 5 files changed, 101 insertions(+), 107 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java index 56921c2368c..3f74ba7243b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java @@ -447,14 +447,14 @@ public class TranslationUnit extends Openable implements ITranslationUnit { Map newElements, IResource underlyingResource) throws CModelException { TranslationUnitInfo unitInfo = (TranslationUnitInfo) info; - // generate structure + // Generate structure this.parse(newElements, pm); // ///////////////////////////////////////////////////////////// if (isWorkingCopy()) { ITranslationUnit original = ((IWorkingCopy)this).getOriginalElement(); - // might be IResource.NULL_STAMP if original does not exist + // Might be IResource.NULL_STAMP if original does not exist IResource r = original.getResource(); if (r != null && r instanceof IFile) { unitInfo.fTimestamp = ((IFile) r).getModificationStamp(); @@ -499,7 +499,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } else { workingCopy= new WorkingCopy(getParent(), getLocationURI(), getContentTypeId(), factory); } - // open the working copy now to ensure contents are that of the current state of this element + // Open the working copy now to ensure contents are that of the current state of this element workingCopy.open(monitor); return workingCopy; } @@ -541,7 +541,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { return null; } - // create a new info and make it the current info + // Create a new info and make it the current info // (this will remove the info and its children just before storing the new infos) CModelManager manager = CModelManager.getDefault(); boolean hadTemporaryCache = manager.hasTemporaryCache(); @@ -555,7 +555,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { Map newElements = manager.getTemporaryCache(); openWhenClosed(info, monitor); if (newElements.get(this) == null) { - // close any buffer that was opened for the new elements + // Close any buffer that was opened for the new elements Iterator iterator = newElements.keySet().iterator(); while (iterator.hasNext()) { ICElement element = iterator.next(); @@ -593,13 +593,13 @@ public class TranslationUnit extends Openable implements ITranslationUnit { @Override protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException { - // create buffer - translation units only use default buffer factory + // Create buffer - translation units only use default buffer factory BufferManager bufManager = getBufferManager(); IBuffer buffer = getBufferFactory().createBuffer(this); if (buffer == null) return null; - // set the buffer source + // Set the buffer source if (buffer.getCharacters() == null) { IResource resource = this.getResource(); if (resource != null && resource.getType() == IResource.FILE) { @@ -620,10 +620,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } } - // add buffer to buffer cache + // Add buffer to buffer cache bufManager.addBuffer(buffer); - // listen to buffer changes + // Listen to buffer changes buffer.addBufferChangedListener(this); return buffer; @@ -889,6 +889,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit { } private static final int[] CTX_LINKAGES= { ILinkage.CPP_LINKAGE_ID, ILinkage.C_LINKAGE_ID }; + public IIndexFile[] getContextToHeader(IIndex index, int style) { if (index != null && (style & AST_CONFIGURE_USING_SOURCE_CONTEXT) != 0) { try { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index 956fbad6d43..1975cd67965 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -2125,7 +2125,7 @@ public class CPPVisitor extends ASTQueries { } IType type = expr.getExpressionType(); if (spec.getType() == IASTSimpleDeclSpecifier.t_decltype) { - switch((expr).getValueCategory()) { + switch (expr.getValueCategory()) { case XVALUE: type= new CPPReferenceType(type, true); break; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java index 30fd9d70b74..7374440818d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java @@ -102,7 +102,7 @@ public class CIndex implements IIndex { public IIndexBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException { if (SPECIALCASE_SINGLES && fFragments.length == 1) { - return fFragments[0].findBindings(patterns, isFullyQualified, filter, monitor); + return fFragments[0].findBindings(patterns, isFullyQualified, filter, monitor); } else { List result = new ArrayList(); ILinkage[] linkages = Linkage.getIndexerLinkages(); 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 435a9249e97..3ea6248527f 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 @@ -469,6 +469,7 @@ public class PDOM extends PlatformObject implements IPDOM { public int compare(long record) throws CoreException { return 0; } + @Override public boolean visit(long record) throws CoreException { PDOMFile file = PDOMFile.recreateFile(PDOM.this, record); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/BTree.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/BTree.java index 4e88f118e6f..de9f0dd7871 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/BTree.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/BTree.java @@ -10,19 +10,17 @@ * Andrew Ferguson (Symbian) - Provide B-tree deletion routine * Markus Schorn (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.core.pdom.db; -import com.ibm.icu.text.MessageFormat; - import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import com.ibm.icu.text.MessageFormat; + /** * @author Doug Schaefer - * */ public class BTree { // Constants for internal deletion routine (see deleteImp doc) @@ -53,7 +51,7 @@ public class BTree { * @param rootPointer offset into database of the pointer to the root node */ public BTree(Database db, long rootPointer, int degree, IBTreeComparator cmp) { - if(degree<2) + if (degree < 2) throw new IllegalArgumentException(Messages.getString("BTree.IllegalDegree")); //$NON-NLS-1$ this.db = db; @@ -113,10 +111,10 @@ public class BTree { // if this node is full (last record isn't null), split it if (getRecord(chunk, node, MAX_RECORDS - 1) != 0) { long median = getRecord(chunk, node, MEDIAN_RECORD); - if (median == record) + if (median == record) { // found it, never mind return median; - else { + } else { // split it // create the new node and move the larger records over long newnode = allocateNode(); @@ -161,8 +159,8 @@ public class BTree { // binary search to find the insert point int lower= 0; - int upper= MAX_RECORDS-1; - while (lower < upper && getRecord(chunk, node, upper-1) == 0) { + int upper= MAX_RECORDS - 1; + while (lower < upper && getRecord(chunk, node, upper - 1) == 0) { upper--; } @@ -171,16 +169,13 @@ public class BTree { long checkRec= getRecord(chunk, node, middle); if (checkRec == 0) { upper= middle; - } - else { + } else { int compare= cmp.compare(checkRec, record); if (compare > 0) { upper= middle; - } - else if (compare < 0) { - lower= middle+1; - } - else { + } else if (compare < 0) { + lower= middle + 1; + } else { // found it, no insert, just return the record return record; } @@ -256,16 +251,16 @@ public class BTree { BTNode(long node) throws CoreException { this.node = node; this.chunk = db.getChunk(node); - int i=0; - while(i MIN_RECORDS) { + BTNode succ = node.getChild(keyIndexInNode + 1); + if (succ != null && succ.keyCount > MIN_RECORDS) { /* Case 2a: Delete key by overwriting it with its successor (which occurs in a leaf node) */ long subst = deleteImp(-1, succ.node, DELMODE_DELETE_MINIMUM); putRecord(node.chunk, node.node, keyIndexInNode, subst); @@ -334,7 +329,7 @@ public class BTree { } BTNode pred = node.getChild(keyIndexInNode); - if(pred!=null && pred.keyCount > MIN_RECORDS) { + if (pred != null && pred.keyCount > MIN_RECORDS) { /* Case 2b: Delete key by overwriting it with its predecessor (which occurs in a leaf node) */ long subst = deleteImp(-1, pred.node, DELMODE_DELETE_MAXIMUM); putRecord(node.chunk, node.node, keyIndexInNode, subst); @@ -342,7 +337,7 @@ public class BTree { } /* Case 2c: Merge successor and predecessor */ - // assert(pred!=null && succ!=null); + // assert(pred != null && succ != null); if (pred != null) { mergeNodes(succ, node, keyIndexInNode, pred); return deleteImp(key, pred.node, mode); @@ -356,8 +351,8 @@ public class BTree { switch(mode) { case DELMODE_NORMAL: subtreeIndex = node.keyCount; - for(int i=0; i0) { + for (int i= 0; i < node.keyCount; i++) + if (cmp.compare(getRecord(node.chunk, node.node, i), key)>0) { subtreeIndex = i; break; } @@ -368,15 +363,15 @@ public class BTree { } BTNode child = node.getChild(subtreeIndex); - if(child==null) { + if (child == null) { throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.OK, Messages.getString("BTree.IntegrityError"), null)); //$NON-NLS-1$ } - if(child.keyCount > MIN_RECORDS) { + if (child.keyCount > MIN_RECORDS) { return deleteImp(key, child.node, mode); } else { - BTNode sibR = node.getChild(subtreeIndex+1); - if(sibR!=null && sibR.keyCount > MIN_RECORDS) { + BTNode sibR = node.getChild(subtreeIndex + 1); + if (sibR != null && sibR.keyCount > MIN_RECORDS) { /* Case 3a (i): child will underflow upon deletion, take a key from rightSibling */ long rightKey = getRecord(node.chunk, node.node, subtreeIndex); long leftmostRightSiblingKey = getRecord(sibR.chunk, sibR.node, 0); @@ -386,26 +381,26 @@ public class BTree { return deleteImp(key, child.node, mode); } - BTNode sibL = node.getChild(subtreeIndex-1); - if(sibL!=null && sibL.keyCount > MIN_RECORDS) { + BTNode sibL = node.getChild(subtreeIndex - 1); + if (sibL != null && sibL.keyCount > MIN_RECORDS) { /* Case 3a (ii): child will underflow upon deletion, take a key from leftSibling */ - long leftKey = getRecord(node.chunk, node.node, subtreeIndex-1); + long leftKey = getRecord(node.chunk, node.node, subtreeIndex - 1); prepend(child, leftKey, getChild(sibL.chunk, sibL.node, sibL.keyCount)); - long rightmostLeftSiblingKey = getRecord(sibL.chunk, sibL.node, sibL.keyCount-1); - putRecord(sibL.chunk, sibL.node, sibL.keyCount-1, 0); + long rightmostLeftSiblingKey = getRecord(sibL.chunk, sibL.node, sibL.keyCount - 1); + putRecord(sibL.chunk, sibL.node, sibL.keyCount - 1, 0); putChild(sibL.chunk, sibL.node, sibL.keyCount, 0); - putRecord(node.chunk, node.node, subtreeIndex-1, rightmostLeftSiblingKey); + putRecord(node.chunk, node.node, subtreeIndex - 1, rightmostLeftSiblingKey); return deleteImp(key, child.node, mode); } /* Case 3b (i,ii): leftSibling, child, rightSibling all have minimum number of keys */ - if(sibL!=null) { // merge child into leftSibling - mergeNodes(child, node, subtreeIndex-1, sibL); + if (sibL != null) { // merge child into leftSibling + mergeNodes(child, node, subtreeIndex - 1, sibL); return deleteImp(key, sibL.node, mode); } - if(sibR!=null) { // merge rightSibling into child + if (sibR != null) { // merge rightSibling into child mergeNodes(sibR, node, subtreeIndex, child); return deleteImp(key, child.node, mode); } @@ -429,21 +424,21 @@ public class BTree { */ public void mergeNodes(BTNode src, BTNode keyProvider, int kIndex, BTNode dst) throws CoreException { - nodeContentCopy(src, 0, dst, dst.keyCount+1, src.keyCount+1); + nodeContentCopy(src, 0, dst, dst.keyCount + 1, src.keyCount + 1); long midKey = getRecord(keyProvider.chunk, keyProvider.node, kIndex); putRecord(dst.chunk, dst.node, dst.keyCount, midKey); - long keySucc = kIndex+1 == MAX_RECORDS ? 0 : getRecord(keyProvider.chunk, keyProvider.node, kIndex+1); - db.free(getChild(keyProvider.chunk, keyProvider.node, kIndex+1)); - nodeContentDelete(keyProvider, kIndex+1, 1); + long keySucc = kIndex + 1 == MAX_RECORDS ? 0 : getRecord(keyProvider.chunk, keyProvider.node, kIndex + 1); + db.free(getChild(keyProvider.chunk, keyProvider.node, kIndex + 1)); + nodeContentDelete(keyProvider, kIndex + 1, 1); putRecord(keyProvider.chunk, keyProvider.node, kIndex, keySucc); - if(kIndex == 0 && keySucc == 0) { + if (kIndex == 0 && keySucc == 0) { /* * The root node is excused from the property that a node must have a least MIN keys * This means we must special case it at the point when its had all of its keys deleted * entirely during merge operations (which push one of its keys down as a pivot) */ long rootNode = getRoot(); - if(rootNode == keyProvider.node) { + if (rootNode == keyProvider.node) { db.putRecPtr(rootPointer, dst.node); db.free(rootNode); } @@ -458,7 +453,7 @@ public class BTree { * @param child the new leftmost (least) subtree root */ private void prepend(BTNode node, long key, long child) { - nodeContentCopy(node, 0, node, 1, node.keyCount+1); + nodeContentCopy(node, 0, node, 1, node.keyCount + 1); putRecord(node.chunk, node.node, 0, key); putChild(node.chunk, node.node, 0, child); } @@ -487,15 +482,15 @@ public class BTree { * @param length the number of (key,(predecessor)child) nodes to write */ private void nodeContentCopy(BTNode src, int srcPos, BTNode dst, int dstPos, int length) { - for(int i=length-1; i>=0; i--) { // this order is important when src==dst! + for (int i=length - 1; i >= 0; i--) { // this order is important when src == dst! int srcIndex = srcPos + i; int dstIndex = dstPos + i; - if(srcIndex= 0) { upper= middle; - } - else { - lower= middle+1; + } else { + lower= middle + 1; } } } @@ -584,8 +577,7 @@ public class BTree { if (compare > 0) { // start point is to the left return accept(getChild(chunk, node, i), visitor); - } - else if (compare == 0) { + } else if (compare == 0) { if (!accept(getChild(chunk, node, i), visitor)) return false; if (!visitor.visit(record)) @@ -594,8 +586,8 @@ public class BTree { } return accept(getChild(chunk, node, i), visitor); } finally { - if(visitor instanceof IBTreeVisitor2) { - ((IBTreeVisitor2)visitor).postNode(node); + if (visitor instanceof IBTreeVisitor2) { + ((IBTreeVisitor2) visitor).postNode(node); } } } @@ -648,56 +640,56 @@ public class BTree { int keyCount = 0; int indexFirstBlankKey = MAX_RECORDS; int indexLastNonBlankKey = 0; - for(int i=0; i MAX_RECORDS) { + if (keyCount < MIN_RECORDS || keyCount > MAX_RECORDS) { valid = false; - msg += MessageFormat.format(Messages.getString("BTree.IntegrityErrorC"), new Object[]{new Long(node)}); //$NON-NLS-1$ + msg += MessageFormat.format(Messages.getString("BTree.IntegrityErrorC"), new Object[] { new Long(node) }); //$NON-NLS-1$ } // Check: All leaf nodes are at the same depth - if(childCount==0) { - if(leafDepth==null) { + if (childCount == 0) { + if (leafDepth == null) { leafDepth = new Integer(depth); } - if(depth!=leafDepth.intValue()) { + if (depth != leafDepth.intValue()) { valid = false; msg += Messages.getString("BTree.IntegrityErrorD"); //$NON-NLS-1$ } From 4b719a56c7e2dd6f4411a15161c5b973922fe1bd Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sat, 17 Mar 2012 21:57:57 -0700 Subject: [PATCH 8/9] Fixed compiler warnings. --- .../parser/cpp/semantics/CPPSemantics.java | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 8d1b457375b..b566bd01787 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -1671,9 +1671,8 @@ public class CPPSemantics { dtor.accept(visitor); } break; - case eEnumeration: - case eClassType: - case eTemplateDeclaration: + + default: break; } } @@ -1696,7 +1695,7 @@ public class CPPSemantics { IASTFunctionDeclarator declarator = functionDef.getDeclarator(); if (!((ICPPASTDeclSpecifier) declSpec).isFriend()) { - // check the function itself + // Check the function itself IASTName declName = ASTQueries.findInnermostDeclarator(declarator).getName(); ASTInternal.addName(scope, declName); } @@ -1710,21 +1709,22 @@ public class CPPSemantics { declSpec.accept(visitor); declarator.accept(visitor); break; - case eClassType: - case eTemplateDeclaration: - case eEnumeration: + + default: break; } } } /** - * Perform lookup in nominated namespaces that appear in the given scope. For unqualified lookups the method assumes - * that transitive directives have been stored in the lookup-data. For qualified lookups the transitive directives - * are considered if the lookup of the original directive returns empty. + * Perform lookup in nominated namespaces that appear in the given scope. For unqualified + * lookups the method assumes that transitive directives have been stored in the lookup-data. + * For qualified lookups the transitive directives are considered if the lookup of the original + * directive returns empty. * @param fileSet */ - private static void lookupInNominated(LookupData data, IIndexFileSet fileSet, ICPPNamespaceScope scope) throws DOMException { + private static void lookupInNominated(LookupData data, IIndexFileSet fileSet, + ICPPNamespaceScope scope) throws DOMException { List allNominated= data.usingDirectives.remove(scope); while (allNominated != null) { for (ICPPNamespaceScope nominated : allNominated) { @@ -1740,9 +1740,9 @@ public class CPPSemantics { found = true; } - // in the qualified lookup we have to nominate the transitive directives only when - // the lookup did not succeed. In the qualified case this is done earlier, when the directive - // is encountered. + // In the qualified lookup we have to nominate the transitive directives only when + // the lookup did not succeed. In the qualified case this is done earlier, when + // the directive is encountered. if (!found && data.qualified() && !data.contentAssist) { if (data.tu != null) { data.tu.handleAdditionalDirectives(nominated); @@ -1753,7 +1753,7 @@ public class CPPSemantics { } } } - // retry with transitive directives that may have been nominated in a qualified lookup + // Retry with transitive directives that may have been nominated in a qualified lookup allNominated= data.usingDirectives.remove(scope); } } @@ -1778,11 +1778,11 @@ public class CPPSemantics { return null; } - // bug 238180 + // Bug 238180 if (candidate instanceof ICPPClassTemplatePartialSpecialization) return null; - // specialization is selected during instantiation + // Specialization is selected during instantiation if (candidate instanceof ICPPTemplateInstance) candidate= ((ICPPTemplateInstance) candidate).getSpecializedBinding(); @@ -1829,7 +1829,7 @@ public class CPPSemantics { int pointOfDecl= -1; if (obj instanceof ICPPInternalBinding) { ICPPInternalBinding cpp = (ICPPInternalBinding) obj; - // for bindings in global or namespace scope we don't know whether there is a + // For bindings in global or namespace scope we don't know whether there is a // previous declaration in one of the skipped header files. For bindings that // are likely to be redeclared we need to assume that there is a declaration // in one of the headers. @@ -1865,7 +1865,8 @@ public class CPPSemantics { if (pointOfDecl < 0 && nd != null) { ASTNodeProperty prop = nd.getPropertyInParent(); if (prop == IASTDeclarator.DECLARATOR_NAME || nd instanceof IASTDeclarator) { - // point of declaration for a name is immediately after its complete declarator and before its initializer + // Point of declaration for a name is immediately after its complete declarator + // and before its initializer. IASTDeclarator dtor = (IASTDeclarator)((nd instanceof IASTDeclarator) ? nd : nd.getParent()); while (dtor.getParent() instanceof IASTDeclarator) dtor = (IASTDeclarator) dtor.getParent(); @@ -1875,7 +1876,8 @@ public class CPPSemantics { else pointOfDecl = ((ASTNode) dtor).getOffset() + ((ASTNode) dtor).getLength(); } else if (prop == IASTEnumerator.ENUMERATOR_NAME) { - // point of declaration for an enumerator is immediately after it enumerator-definition + // Point of declaration for an enumerator is immediately after it + // enumerator-definition IASTEnumerator enumtor = (IASTEnumerator) nd.getParent(); if (enumtor.getValue() != null) { ASTNode exp = (ASTNode) enumtor.getValue(); @@ -1906,7 +1908,7 @@ public class CPPSemantics { } else if (cpp instanceof ICompositeType || cpp instanceof IEnumeration) { IScope scope= cpp.getScope(); if (!(scope instanceof ICPPBlockScope) && scope instanceof ICPPNamespaceScope) { - // if this is not the definition, it may be found in a header. (bug 229571) + // If this is not the definition, it may be found in a header. (bug 229571) if (cpp.getDefinition() == null) { return true; } @@ -1956,7 +1958,7 @@ public class CPPSemantics { continue; } - // select among those bindings that have been created without problems. + // Select among those bindings that have been created without problems. if (temp instanceof IProblemBinding) continue; @@ -1984,7 +1986,7 @@ public class CPPSemantics { fns = new ObjectSet(2); fns.put((ICPPFunction) temp); } else if (temp instanceof IType) { - // specializations are selected during instantiation + // Specializations are selected during instantiation if (temp instanceof ICPPClassTemplatePartialSpecialization) continue; if (temp instanceof ICPPTemplateInstance) { @@ -2213,7 +2215,7 @@ public class CPPSemantics { return -1; // function from ast } } - // everything is from the index + // Everything is from the index if (!isReachableFromAst(data.tu, obj)) { return -1; // obj not reachable } From 13ab9fa3c4b556defbc3dbe4605a7828f664bb6e Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Sun, 18 Mar 2012 06:17:19 -0400 Subject: [PATCH 9/9] bug 364733: Fixed problem with not picking environment correctly --- .../org/eclipse/cdt/core/CommandLauncher.java | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java index a8f38c8bef2..fc4b097932c 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java @@ -127,18 +127,20 @@ public class CommandLauncher implements ICommandLauncher { /** * Parse array of "ENV=value" pairs to Properties. */ - private Properties parseEnv(String[] env) { - Properties envProperties = new Properties(); - for (String envStr : env) { - // Split "ENV=value" and put in Properties - int pos = envStr.indexOf('='); - if (pos < 0) - pos = envStr.length(); - String key = envStr.substring(0, pos); - String value = envStr.substring(pos + 1); - envProperties.put(key, value); + private void parseEnvironment(String[] env) { + fEnvironment = null; + if (env != null) { + fEnvironment = new Properties(); + for (String envStr : env) { + // Split "ENV=value" and put in Properties + int pos = envStr.indexOf('='); + if (pos < 0) + pos = envStr.length(); + String key = envStr.substring(0, pos); + String value = envStr.substring(pos + 1); + fEnvironment.put(key, value); + } } - return envProperties; } /** @@ -162,27 +164,28 @@ public class CommandLauncher implements ICommandLauncher { */ @Override public Process execute(IPath commandPath, String[] args, String[] env, IPath workingDirectory, IProgressMonitor monitor) throws CoreException { + parseEnvironment(env); + String envPathValue = (String) getEnvironment().get(PATH_ENV); + Boolean isFound = null; String command = commandPath.toOSString(); - String envPathValue = (String) getEnvironment().get(PATH_ENV); - try { - fCommandArgs = constructCommandArray(command, args); - if (Platform.getOS().equals(Platform.OS_WIN32)) { - // Handle cygwin link - IPath location = PathUtil.findProgramLocation(command, envPathValue); - isFound = location != null; - if (location != null) { - try { - fCommandArgs[0] = Cygwin.cygwinToWindowsPath(location.toString(), envPathValue); - } catch (Exception e) { - // if no cygwin nothing to worry about - } + fCommandArgs = constructCommandArray(command, args); + if (Platform.getOS().equals(Platform.OS_WIN32)) { + // Handle cygwin link + IPath location = PathUtil.findProgramLocation(command, envPathValue); + isFound = location != null; + if (location != null) { + try { + fCommandArgs[0] = Cygwin.cygwinToWindowsPath(location.toString(), envPathValue); + } catch (Exception e) { + // if no cygwin nothing to worry about } } + } - fEnvironment = parseEnv(env); - File dir = workingDirectory != null ? workingDirectory.toFile() : null; + File dir = workingDirectory != null ? workingDirectory.toFile() : null; + try { fProcess = ProcessFactory.getFactory().exec(fCommandArgs, env, dir); fCommandArgs[0] = command; // to print original command on the console fErrorMessage = ""; //$NON-NLS-1$