From ff15847cbe669f0a30ebbd3c2a0f2f909fee9bc8 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Thu, 12 Jul 2012 12:01:24 -0400 Subject: [PATCH 01/11] bug 375859 - update junit tests --- .../resources/tests/RefreshScopeTests.java | 103 +++++++++++++++++- 1 file changed, 99 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java index a8ef6802ed6..4bc8323db72 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java @@ -22,6 +22,7 @@ import junit.framework.TestSuite; 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.ICProject; import org.eclipse.cdt.core.resources.ExclusionInstance; import org.eclipse.cdt.core.resources.ExclusionType; @@ -29,6 +30,7 @@ import org.eclipse.cdt.core.resources.RefreshExclusion; import org.eclipse.cdt.core.resources.RefreshScopeManager; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.WriteAccessException; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.internal.core.resources.ResourceExclusion; @@ -408,10 +410,8 @@ public class RefreshScopeTests extends TestCase { IResource config1_resource = fProject; - CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance(); - ICProjectDescription projectDescription = descriptionManager.getProjectDescription(fProject, false); - ICConfigurationDescription conf = projectDescription.getActiveConfiguration(); - String conf_name = conf.getName(); + + String conf_name = getCurrentConfigName(); manager.addResourceToRefresh(fProject, conf_name, config1_resource); @@ -567,6 +567,101 @@ public class RefreshScopeTests extends TestCase { } + public void closeProject(ICProjectDescription projDesc) { + + try { + // save the project description + CCorePlugin.getDefault().setProjectDescription(fProject, projDesc); + fProject.close(null); + } catch (CoreException e1) { + fail(); + } + } + + public void openProject() { + try { + fProject.open(null); + } catch (CoreException e) { + fail(); + } + } + + public String getCurrentConfigName() { + CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance(); + ICProjectDescription projectDescription = descriptionManager.getProjectDescription(fProject, false); + ICConfigurationDescription conf = projectDescription.getActiveConfiguration(); + return conf.getName(); + } + + public void testEmptyRefreshScopeCloseAndReopen() { + + RefreshScopeManager manager = RefreshScopeManager.getInstance(); + manager.clearAllData(); + + String config_name = getCurrentConfigName(); + + // get the resources. since we are not loading ... the project should auto-magically be added by default. + List config_resources = manager.getResourcesToRefresh(fProject, config_name); + assertEquals(1,config_resources.size()); + assertEquals(true, config_resources.contains(fProject)); + + // now delete it. + manager.deleteResourceToRefresh(fProject, config_name, fProject); + + // and make sure it is empty. + config_resources = manager.getResourcesToRefresh(fProject, config_name); + assertEquals(0,config_resources.size()); + + // write the persistent data. + ICProjectDescription projectDescription = CCorePlugin.getDefault().getProjectDescription(fProject); + try { + manager.persistSettings(projectDescription); + } catch (CoreException e) { + fail(); + } + + // close and reopen + closeProject(projectDescription); + openProject(); + + // now verify that there are no resources. + HashMap>> config_map = manager.getConfigurationToResourcesMap(fProject); + assertEquals(1,config_map.size()); + config_resources = manager.getResourcesToRefresh(fProject, config_name); + assertEquals(0,config_resources.size()); + } + + public void testAddEmptyConfiguration() { + final String CFG_NAME="empty_config"; + + CoreModel model = CoreModel.getDefault(); + RefreshScopeManager manager = RefreshScopeManager.getInstance(); + manager.clearAllData(); + + CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance(); + ICProjectDescription projectDescription = descriptionManager.getProjectDescription(fProject, false); + ICConfigurationDescription base = projectDescription.getActiveConfiguration(); + + ICProjectDescription propertyProjectDescription = CoreModel.getDefault().getProjectDescription(fProject); + ICConfigurationDescription propertyDefaultConfigurationDescription = propertyProjectDescription.getConfigurations()[0]; + try { + projectDescription.setReadOnly(false, true); + ICConfigurationDescription newCfg = projectDescription.createConfiguration(CFG_NAME + ".id", CFG_NAME, propertyDefaultConfigurationDescription); + } catch (WriteAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + List empty_config_resources = manager.getResourcesToRefresh(fProject, CFG_NAME); + assertEquals(1,empty_config_resources.size()); + assertEquals(true,empty_config_resources.contains(fProject)); + + } + public static Test suite() { return new TestSuite(RefreshScopeTests.class); } From 8114a24402160f78ebd73d0910a40b898feeaa68 Mon Sep 17 00:00:00 2001 From: Vivian Kong Date: Thu, 12 Jul 2012 15:05:40 -0400 Subject: [PATCH 02/11] Bug 382426 - [Accessibility] Some UI elements do not provide a label --- .../ui/properties/BuildBehaviourTab.java | 9 ++++++++- .../cdt/internal/ui/filters/CustomFiltersDialog.java | 12 +++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildBehaviourTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildBehaviourTab.java index 46cf3e813f5..f7bc7f82ccf 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildBehaviourTab.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildBehaviourTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Intel Corporation and others. + * Copyright (c) 2007, 2012 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -163,6 +163,13 @@ public class BuildBehaviourTab extends AbstractCBuildPropertyTab { updateButtons(); } }); + s_parallelNumber.getAccessible().addAccessibleListener(new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = Messages.BuilderSettingsTab_UseParallelJobs; + } + }); + s_parallelNumber.setToolTipText(Messages.BuilderSettingsTab_UseParallelJobs); b_parallelUnlimited= new Button(c3, SWT.RADIO); b_parallelUnlimited.setText(Messages.BuilderSettingsTab_UseUnlimitedJobs); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java index 2afb5902155..e83ea702b5b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,6 +32,8 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.swt.SWT; +import org.eclipse.swt.accessibility.AccessibleAdapter; +import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; @@ -183,6 +185,14 @@ public class CustomFiltersDialog extends SelectionDialog { List initialSelection= getInitialElementSelections(); if (initialSelection != null && !initialSelection.isEmpty()) checkInitialSelections(); + + fCheckBoxList.getTable().getAccessible().addAccessibleListener(new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = FilterMessages.CustomFiltersDialog_filterList_label; + } + }); + fCheckBoxList.getTable().setToolTipText(FilterMessages.CustomFiltersDialog_filterList_label); // Description info= new Label(parent, SWT.LEFT); From e477f03d08dce38b39b14c26403c4e220fb6d536 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Thu, 12 Jul 2012 18:41:16 -0400 Subject: [PATCH 03/11] bug 378590: Fixed error message in the log --- .../org/eclipse/cdt/internal/core/model/CModelManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java index 21cbf20cf06..16deb2d5f4e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelManager.java @@ -982,8 +982,10 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang try { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(event.getProjectName()); - // Recalculate cached settings - CoreModel.getDefault().updateProjectDescriptions(new IProject[] {project}, null); + // Recalculate cached settings unless already inside CProjectDescriptionManager.setProjectDescription() + if (!CProjectDescriptionManager.getInstance().isCurrentThreadSetProjectDescription()) { + CoreModel.getDefault().updateProjectDescriptions(new IProject[] {project}, null); + } // Notify listeners ICProject cproject = CModelManager.getDefault().getCModel().getCProject(project); From 45e67ddcf2c1750ff42d723c04f76d04626d54fd Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Fri, 13 Jul 2012 22:02:40 -0700 Subject: [PATCH 04/11] Cosmetics. --- .../eclipse/cdt/core/dom/ast/IASTTypeId.java | 9 +++----- .../core/dom/ast/IASTTypeIdExpression.java | 7 +++--- .../cdt/core/dom/ast/IASTWhileStatement.java | 3 +-- .../dom/ast/ICPPASTCompletionContext.java | 3 +-- .../cdt/core/dom/ast/ICompositeType.java | 9 ++++---- .../cdt/core/dom/ast/cpp/ICPPConstructor.java | 3 +-- .../ast/cpp/ICPPDeferredTemplateInstance.java | 4 ++-- .../cdt/core/dom/ast/cpp/ICPPEnumeration.java | 3 +-- .../cdt/core/dom/ast/cpp/ICPPField.java | 5 ++--- .../cdt/core/dom/ast/cpp/ICPPFunction.java | 16 +++++++------- .../core/dom/ast/cpp/ICPPFunctionScope.java | 1 - .../dom/ast/cpp/ICPPFunctionTemplate.java | 15 ++++++------- .../AbstractCPPClassSpecializationScope.java | 11 +++++----- .../parser/cpp/CPPASTAmbiguityResolver.java | 2 +- ...CPPASTAmbiguousBinaryVsCastExpression.java | 2 +- ...AmbiguousCastVsFunctionCallExpression.java | 6 ++--- .../parser/cpp/CPPASTAmbiguousCondition.java | 2 +- .../parser/cpp/CPPASTAmbiguousExpression.java | 14 +++++------- .../CPPASTAmbiguousParameterDeclaration.java | 12 +++++----- .../parser/cpp/CPPASTAmbiguousStatement.java | 3 ++- .../cpp/CPPASTAmbiguousTemplateArgument.java | 22 ++++++++----------- .../core/dom/parser/cpp/CPPArrayType.java | 12 +++++----- .../parser/cpp/semantics/CPPSemantics.java | 16 +++++++++++--- .../GenerateGettersAndSettersWizard.java | 2 +- 24 files changed, 88 insertions(+), 94 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeId.java index 13fc8a000c9..5e0f5546596 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeId.java @@ -15,10 +15,7 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTTypeId extends IASTNode { - /** - * Constant. - */ - public static final IASTTypeId[] EMPTY_TYPEID_ARRAY = new IASTTypeId[0]; + public static final IASTTypeId[] EMPTY_TYPEID_ARRAY = {}; /** * DECL_SPECIFIER represents the relationship between an IASTTypeId @@ -35,7 +32,7 @@ public interface IASTTypeId extends IASTNode { "IASTTypeId.ABSTRACT_DECLARATOR - IASTDeclarator for IASTTypeId"); //$NON-NLS-1$ /** - * Get the decl specifier. + * Returns the decl specifier. * @return IASTDeclSpecifier */ public IASTDeclSpecifier getDeclSpecifier(); @@ -54,7 +51,7 @@ public interface IASTTypeId extends IASTNode { public IASTDeclarator getAbstractDeclarator(); /** - * Set the abstract declarator. + * Sets the abstract declarator. * @param abstractDeclarator IASTDeclarator */ public void setAbstractDeclarator(IASTDeclarator abstractDeclarator); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeIdExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeIdExpression.java index f62f4313551..af81f5d4580 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeIdExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTypeIdExpression.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM Rational Software) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * John Camelon (IBM Rational Software) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -16,9 +16,8 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTTypeIdExpression extends IASTExpression { - /** - * op_sizeof sizeof( typeId ) expression + * op_sizeof sizeof (typeId) expression */ public static final int op_sizeof = 0; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTWhileStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTWhileStatement.java index 77dbe1ed089..180b2eb8a78 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTWhileStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTWhileStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTWhileStatement extends IASTStatement { - /** * CONDITIONEXPRESSION represents the relationship between an IASTWhileStatement and * it's nested IASTExpression. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICPPASTCompletionContext.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICPPASTCompletionContext.java index 2bc8aed0b39..e502a24930b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICPPASTCompletionContext.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICPPASTCompletionContext.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Tomasz Wesolowski - initial API and implementation + * Tomasz Wesolowski - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -19,7 +19,6 @@ package org.eclipse.cdt.core.dom.ast; * @since 5.3 */ public interface ICPPASTCompletionContext extends IASTCompletionContext { - /** * Returns bindings that start with the given name or prefix, only considering those that are valid for * this context, including those in the requested set of namespaces. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICompositeType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICompositeType.java index 439bf8f9613..6775e42c92a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICompositeType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ICompositeType.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -21,15 +21,16 @@ public interface ICompositeType extends IBinding, IType { public static final int k_union = IASTCompositeTypeSpecifier.k_union; /** - * Returns the type of the composite, {@link #k_struct}, {@link #k_union}, or - * {@link org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#k_class}. + * Returns the type of the composite, {@link #k_struct}, {@link #k_union}, + * or {@link org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#k_class}. */ public int getKey(); /** * Returns whether the type is anonymous or not. A type for which objects or * pointers are declared is not considered an anonymous type. - *
 struct Outer {
+	 * 
+	 * struct Outer {
 	 *    struct {int a;}; // anonymous
 	 *    struct {int b;} c; // not anonymous
 	 * }
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPConstructor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPConstructor.java
index 7ccdc403f85..0220f5c7deb 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPConstructor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPConstructor.java
@@ -10,11 +10,10 @@
  *******************************************************************************/
 package org.eclipse.cdt.core.dom.ast.cpp;
 
-
 /**
  * @noextend This interface is not intended to be extended by clients.
  * @noimplement This interface is not intended to be implemented by clients.
  */
 public interface ICPPConstructor extends ICPPMethod {
-	public static final ICPPConstructor [] EMPTY_CONSTRUCTOR_ARRAY = new ICPPConstructor[0];
+	public static final ICPPConstructor[] EMPTY_CONSTRUCTOR_ARRAY = {};
 }
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPDeferredTemplateInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPDeferredTemplateInstance.java
index 14f643f2d28..bbf8ab55f7d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPDeferredTemplateInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPDeferredTemplateInstance.java
@@ -6,8 +6,8 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *    Bryan Wilkinson (QNX) - Initial API and implementation
- *    Markus Schorn (Wind River Systems)
+ *     Bryan Wilkinson (QNX) - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
  *******************************************************************************/
 package org.eclipse.cdt.core.dom.ast.cpp;
 
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPEnumeration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPEnumeration.java
index 7cd598500e0..22225a116aa 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPEnumeration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPEnumeration.java
@@ -6,7 +6,7 @@
  * 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.core.dom.ast.cpp;
 
@@ -21,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
  * @noimplement This interface is not intended to be implemented by clients.
  */
 public interface ICPPEnumeration extends IEnumeration, ICPPBinding {
-    
     /**
      * Returns whether this enumeration is scoped.
      * An enumeration can only be scoped in C++.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPField.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPField.java
index b0b0e7dbb31..196f0a5817f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPField.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPField.java
@@ -6,7 +6,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *    Doug Schaefer (IBM) - Initial API and implementation
+ *     Doug Schaefer (IBM) - Initial API and implementation
  *******************************************************************************/
 package org.eclipse.cdt.core.dom.ast.cpp;
 
@@ -17,6 +17,5 @@ import org.eclipse.cdt.core.dom.ast.IField;
  * @noimplement This interface is not intended to be implemented by clients.
  */
 public interface ICPPField extends IField, ICPPMember, ICPPVariable {
-    public static final ICPPField [] EMPTY_CPPFIELD_ARRAY = new ICPPField[0];
-
+    public static final ICPPField[] EMPTY_CPPFIELD_ARRAY = {};
 }
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java
index b1af1daf8a0..17248714040 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java
@@ -1,13 +1,13 @@
 /*******************************************************************************
- *  Copyright (c) 2005, 2010 IBM Corporation and others.
- *  All rights reserved. This program and the accompanying materials
- *  are made available under the terms of the Eclipse Public License v1.0
- *  which accompanies this distribution, and is available at
- *  http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
  * 
- *  Contributors:
- *      Andrew Niefer (IBM Corporation) - initial API and implementation
- *      Markus Schorn (Wind River Systems)
+ * Contributors:
+ *     Andrew Niefer (IBM Corporation) - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
  *******************************************************************************/
 package org.eclipse.cdt.core.dom.ast.cpp;
 
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionScope.java
index b6be37f5c51..e78ad625b74 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionScope.java
@@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IScope;
  * @noimplement This interface is not intended to be implemented by clients.
  */
 public interface ICPPFunctionScope extends ICPPScope {
-
 	/**
 	 * Get the scope representing the function body. returns null if there is no
 	 * function definition
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionTemplate.java
index cdd9808211f..ea247dbb0d1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionTemplate.java
@@ -1,12 +1,12 @@
 /*******************************************************************************
- *  Copyright (c) 2005, 2009 IBM Corporation and others.
- *  All rights reserved. This program and the accompanying materials
- *  are made available under the terms of the Eclipse Public License v1.0
- *  which accompanies this distribution, and is available at
- *  http://www.eclipse.org/legal/epl-v10.html
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
  * 
- *  Contributors:
- *    Andrew Niefer (IBM) - Initial API and implementation
+ * Contributors:
+ *     Andrew Niefer (IBM) - Initial API and implementation
  *******************************************************************************/
 package org.eclipse.cdt.core.dom.ast.cpp;
 
@@ -17,5 +17,4 @@ package org.eclipse.cdt.core.dom.ast.cpp;
  * @noextend This interface is not intended to be extended by clients.
  */
 public interface ICPPFunctionTemplate extends ICPPFunction, ICPPTemplateDefinition {
-
 }
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java
index 62ff6bc9ca8..560c545e08e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java
@@ -6,10 +6,10 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *    IBM - Initial API and implementation
- *    Markus Schorn (Wind River Systems)
- *    Bryan Wilkinson (QNX)
- *    Andrew Ferguson (Symbian)
+ *     IBM - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Bryan Wilkinson (QNX)
+ *     Andrew Ferguson (Symbian)
  *******************************************************************************/
 package org.eclipse.cdt.internal.core.dom.parser.cpp;
 
@@ -91,7 +91,8 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
     	return CPPSemantics.resolveAmbiguities(name, specs);
 	}
 
-	@Deprecated	@Override
+	@Deprecated
+	@Override
 	final public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup,
 			IIndexFileSet fileSet) {
 		return getBindings(new ScopeLookupData(name, resolve, prefixLookup));
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguityResolver.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguityResolver.java
index 3a7043e32cd..198478bcb44 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguityResolver.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguityResolver.java
@@ -6,7 +6,7 @@
  * 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.dom.parser.cpp;
 
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousBinaryVsCastExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousBinaryVsCastExpression.java
index 33e3534b2b3..a7967717781 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousBinaryVsCastExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousBinaryVsCastExpression.java
@@ -6,7 +6,7 @@
  * 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.dom.parser.cpp;
 
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCastVsFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCastVsFunctionCallExpression.java
index 4c08dbe087d..c9254d33de8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCastVsFunctionCallExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCastVsFunctionCallExpression.java
@@ -6,7 +6,7 @@
  * 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.dom.parser.cpp;
 
@@ -15,8 +15,8 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
 import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
 import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousCastVsFunctionCallExpression;
 
-public class CPPASTAmbiguousCastVsFunctionCallExpression extends
-		ASTAmbiguousCastVsFunctionCallExpression implements ICPPASTExpression {
+public class CPPASTAmbiguousCastVsFunctionCallExpression
+		extends	ASTAmbiguousCastVsFunctionCallExpression implements ICPPASTExpression {
 
     public CPPASTAmbiguousCastVsFunctionCallExpression(IASTCastExpression castExpr, IASTFunctionCallExpression funcCall) {
     	super(castExpr, funcCall);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCondition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCondition.java
index f47bcda4a3a..5839aa7d636 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCondition.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCondition.java
@@ -6,7 +6,7 @@
  * 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.dom.parser.cpp;
 
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousExpression.java
index c45715f43aa..1612a28c1f9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousExpression.java
@@ -18,17 +18,15 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
 import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
 import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
 
-public class CPPASTAmbiguousExpression extends ASTAmbiguousNode implements
-        IASTAmbiguousExpression, ICPPASTExpression {
-
-    private IASTExpression [] exp = new IASTExpression[2];
-    private int expPos=-1;
+public class CPPASTAmbiguousExpression extends ASTAmbiguousNode
+		implements IASTAmbiguousExpression, ICPPASTExpression {
+    private IASTExpression[] exp = new IASTExpression[2];
+    private int expPos= -1;
     
     public CPPASTAmbiguousExpression(IASTExpression... expressions) {
 		for(IASTExpression e : expressions)
 			addExpression(e);
 	}
-
     
     @Override
 	public IASTExpression copy() {
@@ -44,7 +42,7 @@ public class CPPASTAmbiguousExpression extends ASTAmbiguousNode implements
 	public void addExpression(IASTExpression e) {
         assertNotFrozen();
     	if (e != null) {
-    		exp = ArrayUtil.appendAt( IASTExpression.class, exp, ++expPos, e );
+    		exp = ArrayUtil.appendAt(IASTExpression.class, exp, ++expPos, e);
     		e.setParent(this);
 			e.setPropertyInParent(SUBEXPRESSION);
     	}
@@ -52,7 +50,7 @@ public class CPPASTAmbiguousExpression extends ASTAmbiguousNode implements
 
     @Override
 	public IASTExpression[] getExpressions() {
-        exp = ArrayUtil.trimAt( IASTExpression.class, exp, expPos );
+        exp = ArrayUtil.trimAt(IASTExpression.class, exp, expPos);
     	return exp;
     }
 
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java
index 81b864a9bfc..5984d0efe9d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousParameterDeclaration.java
@@ -6,7 +6,7 @@
  * 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.dom.parser.cpp;
 
@@ -34,9 +34,8 @@ import org.eclipse.core.runtime.Assert;
  * 
* template void function(T ...); // is T a parameter pack? */ -public class CPPASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implements - IASTAmbiguousParameterDeclaration, ICPPASTParameterDeclaration { - +public class CPPASTAmbiguousParameterDeclaration extends ASTAmbiguousNode + implements IASTAmbiguousParameterDeclaration, ICPPASTParameterDeclaration { private ICPPASTParameterDeclaration fParameterDecl; public CPPASTAmbiguousParameterDeclaration(ICPPASTParameterDeclaration decl) { @@ -47,7 +46,6 @@ public class CPPASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implem public void addParameterDeclaration(IASTParameterDeclaration d) { assert false; } - @Override protected final IASTNode doResolveAmbiguity(ASTVisitor resolver) { @@ -73,7 +71,7 @@ public class CPPASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implem final ASTNode asNode = (ASTNode) dtor; if (ptrOps.length > 0) { final ASTNode first = (ASTNode)ptrOps[0]; - final ASTNode last = (ASTNode)ptrOps[ptrOps.length-1]; + final ASTNode last = (ASTNode)ptrOps[ptrOps.length - 1]; asNode.setOffsetAndLength(first.getOffset(), last.getOffset() + last.getLength()); } else { asNode.setOffsetAndLength(0, 0); @@ -82,7 +80,7 @@ public class CPPASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implem @Override public IASTParameterDeclaration[] getParameterDeclarations() { - return new IASTParameterDeclaration[] {fParameterDecl}; + return new IASTParameterDeclaration[] { fParameterDecl }; } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java index 53b624a78f9..6d898528ee8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousStatement.java @@ -32,8 +32,9 @@ public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAm private IASTDeclaration fDeclaration; public CPPASTAmbiguousStatement(IASTStatement... statements) { - for (IASTStatement s : statements) + for (IASTStatement s : statements) { addStatement(s); + } } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java index f6deabd115f..bd2101e22f1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial Implementation - * Markus Schorn (Wind River Systems) - * IBM Corporation + * Andrew Ferguson (Symbian) - Initial Implementation + * Markus Schorn (Wind River Systems) + * IBM Corporation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -33,11 +33,11 @@ import org.eclipse.core.runtime.Assert; * Ambiguity node for deciding between type-id and id-expression in a template argument. */ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements ICPPASTAmbiguousTemplateArgument { - private List fNodes; /** - * @param nodes nodes of type {@link IASTTypeId}, {@link IASTIdExpression} or {@link ICPPASTPackExpansionExpression}. + * @param nodes nodes of type {@link IASTTypeId}, {@link IASTIdExpression} + * or {@link ICPPASTPackExpansionExpression}. */ public CPPASTAmbiguousTemplateArgument(IASTNode... nodes) { fNodes= new ArrayList(2); @@ -56,7 +56,6 @@ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements } } } - @Override protected void beforeAlternative(IASTNode node) { @@ -77,13 +76,11 @@ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements } } - @Override protected void afterResolution(ASTVisitor resolver, IASTNode best) { beforeAlternative(best); } - @Override public IASTNode copy() { return copy(CopyStyle.withoutLocations); @@ -91,15 +88,14 @@ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements @Override public IASTNode copy(CopyStyle style) { - int sizeOfNodes = fNodes.size(); IASTNode[] copyNodes = new IASTNode[sizeOfNodes]; int arrayIndex = 0; - for(IASTNode node : fNodes) { - if(node!=null){ + for (IASTNode node : fNodes) { + if (node != null){ copyNodes[arrayIndex] = node.copy(style); - }else{ - copyNodes[arrayIndex]=null; + } else { + copyNodes[arrayIndex]= null; } arrayIndex++; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java index f38210cc2fb..a832a347973 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java @@ -1,11 +1,11 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2004, 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * Andrew Niefer (IBM Corporation) - initial API and implementation * Markus Schorn (Wind River Systems) *******************************************************************************/ 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 358e30115fd..ed466a91df0 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 @@ -16,7 +16,17 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE; -import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ALLCVQ; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ARRAY; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.MPTR; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.PTR; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.calculateInheritanceDepth; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.isConversionOperator; import java.util.ArrayList; import java.util.Arrays; @@ -3261,7 +3271,7 @@ public class CPPSemantics { if (tu != null && funcData.foundItems instanceof Object[]) { final IIndexFileSet fileSet = tu.getIndexFileSet(); if (fileSet != null) { - int j=0; + int j= 0; final Object[] items= (Object[]) funcData.foundItems; for (int i = 0; i < items.length; i++) { Object item = items[i]; @@ -3292,7 +3302,7 @@ public class CPPSemantics { items[j++]= func; } } - if (j>0) { + if (j > 0) { while (j < items.length) items[j++]= null; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersWizard.java index 8e48c62e61a..d89e479d21b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersWizard.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersWizard.java @@ -17,7 +17,7 @@ import org.eclipse.ltk.ui.refactoring.UserInputWizardPage; /** * @author Thomas Corbat */ -public class GenerateGettersAndSettersWizard extends RefactoringWizard { +public class GenerateGettersAndSettersWizard extends RefactoringWizard { public GenerateGettersAndSettersWizard( GenerateGettersAndSettersRefactoring refactoring) { super(refactoring, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE); From 12cca1e9b283bd71973c339811a7d6ada8456b57 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 15 Jul 2012 14:53:02 -0700 Subject: [PATCH 05/11] Cosmetics. --- .../parser/cpp/semantics/CPPTemplates.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) 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 bfd903dc69e..8fbb1cb8149 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 @@ -224,7 +224,7 @@ public class CPPTemplates { } if (isPack) { - int packOffset= numParams-1; + int packOffset= numParams - 1; int packSize= numArgs - packOffset; ICPPTemplateArgument[] pack= new ICPPTemplateArgument[packSize]; System.arraycopy(arguments, packOffset, pack, 0, packSize); @@ -401,7 +401,7 @@ public class CPPTemplates { for (int i = 0; i < arguments.length; i++) { ICPPTemplateArgument arg = arguments[i]; if (arg.isPackExpansion()) { - if (i != arguments.length-1) { + if (i != arguments.length - 1) { return arguments; } havePackExpansion= true; @@ -420,10 +420,10 @@ public class CPPTemplates { // More arguments allowed if we have a parameter pack. if (tparCount < argCount) { - if (tpars[tparCount-1].isParameterPack()) + if (tpars[tparCount - 1].isParameterPack()) return arguments; - if (havePackExpansion && tparCount+1 == argCount) + if (havePackExpansion && tparCount + 1 == argCount) return arguments; return null; } @@ -433,7 +433,7 @@ public class CPPTemplates { return arguments; // Fewer arguments are allowed with default arguments - if (tpars[tparCount-1].isParameterPack()) + if (tpars[tparCount - 1].isParameterPack()) tparCount--; if (tparCount == argCount) @@ -1024,7 +1024,7 @@ public class CPPTemplates { } else if (packSize == PACK_SIZE_DEFER) { newType= origType; } else { - IType[] newResult= new IType[result.length+packSize-1]; + IType[] newResult= new IType[result.length + packSize - 1]; System.arraycopy(result, 0, newResult, 0, j); result= newResult; for (int k= 0; k < packSize; k++) { @@ -1167,7 +1167,7 @@ public class CPPTemplates { return type; } // The parameter types need to be adjusted. - for (int i=0; i 0 || usesTemplateParameter((ICPPASTTemplateId) n, tparnames)) { @@ -1438,17 +1438,17 @@ public class CPPTemplates { b= b.getOwner(); } if (depIDCount > 0) { - nestingLevel+= depIDCount; + nestingLevel += depIDCount; } else if (consumesTDecl < tdeclCount && !lastIsTemplate) { nestingLevel++; lastIsTemplate= true; } } else { - nestingLevel+= depIDCount; + nestingLevel += depIDCount; node= outerMostTDecl.getParent(); while (node != null) { if (node instanceof ICPPASTInternalTemplateDeclaration) { - nestingLevel+= ((ICPPASTInternalTemplateDeclaration) node).getNestingLevel() + 1; + nestingLevel += ((ICPPASTInternalTemplateDeclaration) node).getNestingLevel() + 1; break; } node= node.getParent(); @@ -1461,7 +1461,7 @@ public class CPPTemplates { node= outerMostTDecl.getParent(); while (node != null) { if (node instanceof ICPPASTInternalTemplateDeclaration) { - nestingLevel+= ((ICPPASTInternalTemplateDeclaration) node).getNestingLevel() + 1; + nestingLevel += ((ICPPASTInternalTemplateDeclaration) node).getNestingLevel() + 1; break; } node= node.getParent(); @@ -1470,7 +1470,7 @@ public class CPPTemplates { } node= innerMostTDecl; - while(node instanceof ICPPASTInternalTemplateDeclaration) { + while (node instanceof ICPPASTInternalTemplateDeclaration) { if (--nestingLevel < 0) nestingLevel= 0; tdecl= (ICPPASTInternalTemplateDeclaration) node; @@ -1500,7 +1500,7 @@ public class CPPTemplates { private static CharArraySet collectTemplateParameterNames(ICPPASTTemplateDeclaration tdecl) { CharArraySet set= new CharArraySet(4); - while(true) { + while (true) { ICPPASTTemplateParameter[] pars = tdecl.getTemplateParameters(); for (ICPPASTTemplateParameter par : pars) { IASTName name= CPPTemplates.getTemplateParameterName(par); @@ -1520,7 +1520,7 @@ public class CPPTemplates { private static boolean usesTemplateParameter(final ICPPASTTemplateId id, final CharArraySet names) { final boolean[] result= {false}; ASTVisitor v= new ASTVisitor(false) { - { shouldVisitNames= true; shouldVisitAmbiguousNodes=true;} + { shouldVisitNames= true; shouldVisitAmbiguousNodes= true; } @Override public int visit(IASTName name) { if (name instanceof ICPPASTTemplateId) @@ -1612,7 +1612,7 @@ public class CPPTemplates { } private static ICPPASTInternalTemplateDeclaration getDirectlyEnclosingTemplateDeclaration( - ICPPASTInternalTemplateDeclaration tdecl ) { + ICPPASTInternalTemplateDeclaration tdecl) { final IASTNode parent= tdecl.getParent(); if (parent instanceof ICPPASTInternalTemplateDeclaration) return (ICPPASTInternalTemplateDeclaration) parent; @@ -1680,7 +1680,7 @@ public class CPPTemplates { if (args.length != specArgs.length) { return false; } - for (int i=0; i < args.length; i++) { + for (int i= 0; i < args.length; i++) { if (!specArgs[i].isSameValue(args[i])) return false; } @@ -1792,7 +1792,7 @@ public class CPPTemplates { static ICPPFunction[] instantiateConversionTemplates(ICPPFunction[] functions, IType conversionType, IASTNode point) { boolean checkedForDependentType= false; ICPPFunction[] result= functions; - int i=0; + int i= 0; boolean done= false; for (ICPPFunction f : functions) { ICPPFunction inst = f; @@ -1993,7 +1993,7 @@ public class CPPTemplates { } private static IType[] concat(final IType t, IType[] types) { - IType[] result= new IType[types.length+1]; + IType[] result= new IType[types.length + 1]; result[0]= t; System.arraycopy(types, 0, result, 1, types.length); return result; @@ -2216,8 +2216,8 @@ public class CPPTemplates { private static boolean matchTemplateTemplateParameters(ICPPTemplateParameter[] pParams, ICPPTemplateParameter[] aParams) throws DOMException { - int pi=0; - int ai=0; + int pi= 0; + int ai= 0; while (pi < pParams.length && ai < aParams.length) { final ICPPTemplateParameter pp = pParams[pi]; final ICPPTemplateParameter ap = aParams[ai]; @@ -2250,8 +2250,9 @@ public class CPPTemplates { } if (!matchTemplateTemplateParameters(((ICPPTemplateTemplateParameter) pp).getTemplateParameters(), - ((ICPPTemplateTemplateParameter) ap).getTemplateParameters()) ) + ((ICPPTemplateTemplateParameter) ap).getTemplateParameters())) { return false; + } } } if (!pp.isParameterPack()) From df4921b1bc72e9a82c553b042b191e79aca719c4 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 17 Jul 2012 09:23:33 -0400 Subject: [PATCH 06/11] Missing @since tag --- .../managedbuilder/ui/properties/BuildOptionSettingsUI.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java index 80f927fc86e..eb5f833f8d6 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java @@ -1302,6 +1302,9 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { return selected; } + /** + * @since 8.2 + */ public void setSelection(ITreeOption option) { if (treeRoot == getRoot(option)) { // only work in the same tree selected = option; From 9aa20f2270b6e8618327fded6276eb012cae3c70 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Wed, 18 Jul 2012 13:24:02 -0700 Subject: [PATCH 07/11] Cosmetics. --- .../dom/ast/cpp/ICPPASTAmbiguousTemplateArgument.java | 7 +++---- .../cdt/internal/core/dom/parser/ASTAmbiguousNode.java | 4 ++-- .../dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java | 8 ++++---- .../internal/core/dom/parser/cpp/CPPTemplateArgument.java | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAmbiguousTemplateArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAmbiguousTemplateArgument.java index 54038f30d43..a11c134330e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAmbiguousTemplateArgument.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTAmbiguousTemplateArgument.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial Implementation - * Markus Schorn (Wind River Systems) + * Andrew Ferguson (Symbian) - Initial Implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -17,8 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTypeId; /** - * Place-holder in the AST for template arguments that are not yet - * understood. + * Place-holder in the AST for template arguments that are not yet understood. * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousNode.java index 566ff3a9c0e..0a234b35410 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTAmbiguousNode.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java index bd2101e22f1..7b702c2bcf5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousTemplateArgument.java @@ -34,14 +34,14 @@ import org.eclipse.core.runtime.Assert; */ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements ICPPASTAmbiguousTemplateArgument { private List fNodes; - + /** * @param nodes nodes of type {@link IASTTypeId}, {@link IASTIdExpression} * or {@link ICPPASTPackExpansionExpression}. */ public CPPASTAmbiguousTemplateArgument(IASTNode... nodes) { fNodes= new ArrayList(2); - for(IASTNode node : nodes) { + for (IASTNode node : nodes) { if (node instanceof IASTTypeId || node instanceof IASTIdExpression) { fNodes.add(node); } else if (node instanceof ICPPASTPackExpansionExpression) { @@ -92,10 +92,10 @@ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements IASTNode[] copyNodes = new IASTNode[sizeOfNodes]; int arrayIndex = 0; for (IASTNode node : fNodes) { - if (node != null){ + if (node != null) { copyNodes[arrayIndex] = node.copy(style); } else { - copyNodes[arrayIndex]= null; + copyNodes[arrayIndex] = null; } arrayIndex++; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateArgument.java index 77956c14b9f..a7a33a6a73e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateArgument.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateArgument.java @@ -6,7 +6,7 @@ * 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.dom.parser.cpp; From 0d4b048d1594b701d194b6bd91e40825934ed67f Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Wed, 18 Jul 2012 12:19:37 -0700 Subject: [PATCH 08/11] More detailed exception message. --- .../internal/core/dom/parser/cpp/semantics/CPPTemplates.java | 5 +++++ 1 file changed, 5 insertions(+) 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 8fbb1cb8149..acec6713497 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 @@ -51,6 +51,7 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem; 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.cpp.ICPPASTAmbiguousTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; @@ -1706,6 +1707,10 @@ public class CPPTemplates { IType type= expr.getExpressionType(); IValue value= Value.create((IASTExpression) arg, Value.MAX_RECURSION_DEPTH); result[i]= new CPPTemplateArgument(value, type); + } else if (arg instanceof ICPPASTAmbiguousTemplateArgument) { + throw new IllegalArgumentException(id.getRawSignature() + + " contains an ambiguous template argument at position " + i + " in " //$NON-NLS-1$ //$NON-NLS-2$ + + id.getContainingFilename()); } else { throw new IllegalArgumentException("Unexpected type: " + arg.getClass().getName()); //$NON-NLS-1$ } From a8f38bba36430ed456383d26001f30b6896b641c Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 19 Jul 2012 08:04:06 -0400 Subject: [PATCH 09/11] Update pom.xml Change-Id: I84294b30fa0863ab0e7b388969308adeb7196dfd --- cross/org.eclipse.cdt.launch.remote/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross/org.eclipse.cdt.launch.remote/pom.xml b/cross/org.eclipse.cdt.launch.remote/pom.xml index 05c23752a6f..53c688df2c2 100644 --- a/cross/org.eclipse.cdt.launch.remote/pom.xml +++ b/cross/org.eclipse.cdt.launch.remote/pom.xml @@ -7,7 +7,7 @@ org.eclipse.cdt cdt-parent - 8.1.0-SNAPSHOT + 8.2.0-SNAPSHOT ../../pom.xml From 4c0af173c9f790f3b50aaa79a6ab14657edf539e Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Wed, 18 Jul 2012 17:08:10 -0400 Subject: [PATCH 10/11] bug 357442: avoid adding default drive letter to unresolved paths by language settings providers --- .../tests/GCCBuildCommandParserTest.java | 536 ++++++------------ ...AbstractLanguageSettingsOutputScanner.java | 77 ++- 2 files changed, 222 insertions(+), 391 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java index b719fbf4312..bd56882895e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java @@ -417,8 +417,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); { - IPath path = new Path("/path0").setDevice(project.getLocation().getDevice()); - CIncludePathEntry expected = new CIncludePathEntry(path, 0); + CIncludePathEntry expected = new CIncludePathEntry("/path0", 0); CIncludePathEntry entry = (CIncludePathEntry)entries.get(0); assertEquals(expected.getName(), entry.getName()); assertEquals(expected.getValue(), entry.getValue()); @@ -469,46 +468,45 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - IPath path0 = new Path("/path0").setDevice(project.getLocation().getDevice()); { List entries = parser.getSettingEntries(cfgDescription, file1, languageId); - assertEquals(new CIncludePathEntry(path0, 0), entries.get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { List entries = parser.getSettingEntries(cfgDescription, file2, languageId); - assertEquals(new CIncludePathEntry(path0, 0), entries.get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { List entries = parser.getSettingEntries(cfgDescription, file3, languageId); - assertEquals(new CIncludePathEntry(path0, 0), entries.get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { List entries = parser.getSettingEntries(cfgDescription, file4, languageId); - assertEquals(new CIncludePathEntry(path0, 0), entries.get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { List entries = parser.getSettingEntries(cfgDescription, file5, languageId); - assertEquals(new CIncludePathEntry(path0, 0), entries.get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { List entries = parser.getSettingEntries(cfgDescription, file6, languageId); - assertEquals(new CIncludePathEntry(path0, 0), entries.get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { List entries = parser.getSettingEntries(cfgDescription, file7, languageId); - assertEquals(new CIncludePathEntry(path0, 0), entries.get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { List entries = parser.getSettingEntries(cfgDescription, file8, languageId); - assertEquals(new CIncludePathEntry(path0, 0), entries.get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { List entries = parser.getSettingEntries(cfgDescription, file9, languageId); - assertEquals(new CIncludePathEntry(path0, 0), entries.get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { List entries = parser.getSettingEntries(cfgDescription, file10, languageId); - assertEquals(new CIncludePathEntry(path0, 0), entries.get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } } @@ -549,40 +547,18 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - IPath path = new Path("/path0").setDevice(project.getLocation().getDevice()); - CIncludePathEntry expected = new CIncludePathEntry(path, 0); - CIncludePathEntry entry = (CIncludePathEntry)entries.get(0); - assertEquals(expected.getName(), entry.getName()); - assertEquals(expected.getValue(), entry.getValue()); - assertEquals(expected.getKind(), entry.getKind()); - assertEquals(expected.getFlags(), entry.getFlags()); - assertEquals(expected, entry); - } - { - IPath path = new Path("/path1").setDevice(project.getLocation().getDevice()); - CIncludePathEntry expected = new CIncludePathEntry(path, 0); - CIncludePathEntry entry = (CIncludePathEntry)entries.get(1); - assertEquals(expected, entry); - } - { - IPath path = new Path("/path with spaces").setDevice(project.getLocation().getDevice()); - CIncludePathEntry expected = new CIncludePathEntry(path, 0); - CIncludePathEntry entry = (CIncludePathEntry)entries.get(2); - assertEquals(expected, entry); - } - { - IPath path = new Path("/path with spaces2").setDevice(project.getLocation().getDevice()); - CIncludePathEntry expected = new CIncludePathEntry(path, 0); - CIncludePathEntry entry = (CIncludePathEntry)entries.get(3); - assertEquals(expected, entry); - } - { - IPath path = new Path("/path with spaces3").setDevice(project.getLocation().getDevice()); - CIncludePathEntry expected = new CIncludePathEntry(path, 0); - CIncludePathEntry entry = (CIncludePathEntry)entries.get(4); - assertEquals(expected, entry); - } + CIncludePathEntry expected = new CIncludePathEntry("/path0", 0); + CIncludePathEntry entry = (CIncludePathEntry)entries.get(0); + assertEquals(expected.getName(), entry.getName()); + assertEquals(expected.getValue(), entry.getValue()); + assertEquals(expected.getKind(), entry.getKind()); + assertEquals(expected.getFlags(), entry.getFlags()); + assertEquals(expected, entry); + + assertEquals(new CIncludePathEntry("/path1", 0), entries.get(1)); + assertEquals(new CIncludePathEntry("/path with spaces", 0), entries.get(2)); + assertEquals(new CIncludePathEntry("/path with spaces2", 0), entries.get(3)); + assertEquals(new CIncludePathEntry("/path with spaces3", 0), entries.get(4)); } /** @@ -616,18 +592,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - IPath path = new Path("/Framework").setDevice(project.getLocation().getDevice()); - assertEquals(new CIncludePathEntry(path, ICSettingEntry.FRAMEWORKS_MAC), entries.get(0)); - } - { - IPath path = new Path("/framework/system").setDevice(project.getLocation().getDevice()); - assertEquals(new CIncludePathEntry(path, ICSettingEntry.FRAMEWORKS_MAC), entries.get(1)); - } - { - IPath path = new Path("/Framework with spaces").setDevice(project.getLocation().getDevice()); - assertEquals(new CIncludePathEntry(path, ICSettingEntry.FRAMEWORKS_MAC), entries.get(2)); - } + assertEquals(new CIncludePathEntry("/Framework", ICSettingEntry.FRAMEWORKS_MAC), entries.get(0)); + assertEquals(new CIncludePathEntry("/framework/system", ICSettingEntry.FRAMEWORKS_MAC), entries.get(1)); + assertEquals(new CIncludePathEntry("/Framework with spaces", ICSettingEntry.FRAMEWORKS_MAC), entries.get(2)); } /** @@ -663,50 +630,21 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - CMacroEntry expected = new CMacroEntry("MACRO0", "", 0); - CMacroEntry entry = (CMacroEntry)entries.get(0); - assertEquals(expected.getName(), entry.getName()); - assertEquals(expected.getValue(), entry.getValue()); - assertEquals(expected.getKind(), entry.getKind()); - assertEquals(expected.getFlags(), entry.getFlags()); - assertEquals(expected, entry); - } - { - CMacroEntry expected = new CMacroEntry("MACRO1", "value", 0); - CMacroEntry entry = (CMacroEntry)entries.get(1); - assertEquals(expected, entry); - } - { - CMacroEntry expected = new CMacroEntry("MACRO2", "value with spaces", 0); - CMacroEntry entry = (CMacroEntry)entries.get(2); - assertEquals(expected, entry); - } - { - CMacroEntry expected = new CMacroEntry("MACRO3", "value with spaces", 0); - CMacroEntry entry = (CMacroEntry)entries.get(3); - assertEquals(expected, entry); - } - { - CMacroEntry expected = new CMacroEntry("MACRO4", "\"quoted value\"", 0); - CMacroEntry entry = (CMacroEntry)entries.get(4); - assertEquals(expected, entry); - } - { - CMacroEntry expected = new CMacroEntry("MACRO5", "\"quoted value\"", 0); - CMacroEntry entry = (CMacroEntry)entries.get(5); - assertEquals(expected, entry); - } - { - CMacroEntry expected = new CMacroEntry("MACRO6", "\"escape-quoted value\"", 0); - CMacroEntry entry = (CMacroEntry)entries.get(6); - assertEquals(expected, entry); - } - { - CMacroEntry expected = new CMacroEntry("MACRO7", "'single-quoted value'", 0); - CMacroEntry entry = (CMacroEntry)entries.get(7); - assertEquals(expected, entry); - } + CMacroEntry expected = new CMacroEntry("MACRO0", "", 0); + CMacroEntry entry = (CMacroEntry)entries.get(0); + assertEquals(expected.getName(), entry.getName()); + assertEquals(expected.getValue(), entry.getValue()); + assertEquals(expected.getKind(), entry.getKind()); + assertEquals(expected.getFlags(), entry.getFlags()); + assertEquals(expected, entry); + + assertEquals(new CMacroEntry("MACRO1", "value", 0), entries.get(1)); + assertEquals(new CMacroEntry("MACRO2", "value with spaces", 0), entries.get(2)); + assertEquals(new CMacroEntry("MACRO3", "value with spaces", 0), entries.get(3)); + assertEquals(new CMacroEntry("MACRO4", "\"quoted value\"", 0), entries.get(4)); + assertEquals(new CMacroEntry("MACRO5", "\"quoted value\"", 0), entries.get(5)); + assertEquals(new CMacroEntry("MACRO6", "\"escape-quoted value\"", 0), entries.get(6)); + assertEquals(new CMacroEntry("MACRO7", "'single-quoted value'", 0), entries.get(7)); } /** @@ -735,9 +673,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - assertEquals(new CMacroEntry("MACRO", null, ICSettingEntry.UNDEFINED), entries.get(0)); - } + assertEquals(new CMacroEntry("MACRO", null, ICSettingEntry.UNDEFINED), entries.get(0)); } /** @@ -770,26 +706,18 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - IPath incFile = new Path("/include.file1").setDevice(project.getLocation().getDevice()); - CIncludeFileEntry expected = new CIncludeFileEntry(incFile, 0); - CIncludeFileEntry entry = (CIncludeFileEntry)entries.get(0); - assertEquals(expected.getName(), entry.getName()); - assertEquals(expected.getValue(), entry.getValue()); - assertEquals(expected.getKind(), entry.getKind()); - assertEquals(expected.getFlags(), entry.getFlags()); - assertEquals(expected, entry); - } + CIncludeFileEntry expected = new CIncludeFileEntry("/include.file1", 0); + CIncludeFileEntry entry = (CIncludeFileEntry)entries.get(0); + assertEquals(expected.getName(), entry.getName()); + assertEquals(expected.getValue(), entry.getValue()); + assertEquals(expected.getKind(), entry.getKind()); + assertEquals(expected.getFlags(), entry.getFlags()); + assertEquals(expected, entry); - { - IPath incFile = new Path("/include.file with spaces").setDevice(project.getLocation().getDevice()); - assertEquals(new CIncludeFileEntry(incFile, 0), entries.get(1)); - } - { - assertEquals(new CIncludeFileEntry(project.getLocation().removeLastSegments(2).append("include.file2"), 0), entries.get(2)); - assertEquals(new CIncludeFileEntry(project.getFullPath().append("include.file3"), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(3)); - assertEquals(new CIncludeFileEntry(project.getLocation().removeLastSegments(2).append("include-file-with-dashes"), 0), entries.get(4)); - } + assertEquals(new CIncludeFileEntry("/include.file with spaces", 0), entries.get(1)); + assertEquals(new CIncludeFileEntry(project.getLocation().removeLastSegments(2).append("include.file2"), 0), entries.get(2)); + assertEquals(new CIncludeFileEntry(project.getFullPath().append("include.file3"), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(3)); + assertEquals(new CIncludeFileEntry(project.getLocation().removeLastSegments(2).append("include-file-with-dashes"), 0), entries.get(4)); } /** @@ -820,22 +748,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - IPath path = new Path("/macro.file").setDevice(project.getLocation().getDevice()); - CMacroFileEntry expected = new CMacroFileEntry(path, 0); - CMacroFileEntry entry = (CMacroFileEntry)entries.get(0); - assertEquals(expected.getName(), entry.getName()); - assertEquals(expected.getValue(), entry.getValue()); - assertEquals(expected.getKind(), entry.getKind()); - assertEquals(expected.getFlags(), entry.getFlags()); - assertEquals(expected, entry); - } - { - IPath path = new Path("/macro.file with spaces").setDevice(project.getLocation().getDevice()); - CMacroFileEntry expected = new CMacroFileEntry(path, 0); - CMacroFileEntry entry = (CMacroFileEntry)entries.get(1); - assertEquals(expected, entry); - } + CMacroFileEntry expected = new CMacroFileEntry("/macro.file", 0); + CMacroFileEntry entry = (CMacroFileEntry)entries.get(0); + assertEquals(expected.getName(), entry.getName()); + assertEquals(expected.getValue(), entry.getValue()); + assertEquals(expected.getKind(), entry.getKind()); + assertEquals(expected.getFlags(), entry.getFlags()); + assertEquals(expected, entry); + + assertEquals(new CMacroFileEntry("/macro.file with spaces", 0), entries.get(1)); + } /** @@ -865,22 +787,15 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - IPath path = new Path("/path0").setDevice(project.getLocation().getDevice()); - CLibraryPathEntry expected = new CLibraryPathEntry(path, 0); - CLibraryPathEntry entry = (CLibraryPathEntry)entries.get(0); - assertEquals(expected.getName(), entry.getName()); - assertEquals(expected.getValue(), entry.getValue()); - assertEquals(expected.getKind(), entry.getKind()); - assertEquals(expected.getFlags(), entry.getFlags()); - assertEquals(expected, entry); - } - { - IPath path = new Path("/path with spaces").setDevice(project.getLocation().getDevice()); - CLibraryPathEntry expected = new CLibraryPathEntry(path, 0); - CLibraryPathEntry entry = (CLibraryPathEntry)entries.get(1); - assertEquals(expected, entry); - } + CLibraryPathEntry expected = new CLibraryPathEntry("/path0", 0); + CLibraryPathEntry entry = (CLibraryPathEntry)entries.get(0); + assertEquals(expected.getName(), entry.getName()); + assertEquals(expected.getValue(), entry.getValue()); + assertEquals(expected.getKind(), entry.getKind()); + assertEquals(expected.getFlags(), entry.getFlags()); + assertEquals(expected, entry); + + assertEquals(new CLibraryPathEntry("/path with spaces", 0), entries.get(1)); } /** @@ -953,20 +868,12 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - String device = project.getLocation().getDevice(); -// + " -I/path0 " - assertEquals(new CIncludePathEntry(new Path("/path0").setDevice(device), 0), entries.get(0)); -// + " -I /path1 " - assertEquals(new CIncludePathEntry(new Path("/path1").setDevice(device), 0), entries.get(1)); -// + " -I\"/path with spaces\"" - assertEquals(new CIncludePathEntry(new Path("/path with spaces").setDevice(device), 0), entries.get(2)); -// + " -DMACRO1=value" + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); + assertEquals(new CIncludePathEntry("/path1", 0), entries.get(1)); + assertEquals(new CIncludePathEntry("/path with spaces", 0), entries.get(2)); assertEquals(new CMacroEntry("MACRO1", "value", 0), entries.get(3)); -// + " -DMACRO2=\"value with spaces\"" assertEquals(new CMacroEntry("MACRO2", "value with spaces", 0), entries.get(4)); -// + " -L/usr/lib" - assertEquals(new CLibraryPathEntry(new Path("/usr/lib").setDevice(device), 0), entries.get(5)); -// + " -ldomain" + assertEquals(new CLibraryPathEntry("/usr/lib", 0), entries.get(5)); assertEquals(new CLibraryFileEntry("libdomain.a", 0), entries.get(6)); assertEquals(7, entries.size()); } @@ -1019,12 +926,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check entries - IPath path0 = new Path("/path0").setDevice(project.getLocation().getDevice()); - { - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(new CIncludePathEntry(path0, 0), entries.get(0)); - assertEquals(new CIncludePathEntry(project.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); - } + List entries = parser.getSettingEntries(cfgDescription, file, languageId); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); + assertEquals(new CIncludePathEntry(project.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); } /** @@ -1053,12 +957,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check entries - IPath path0 = new Path("/path0").setDevice(project.getLocation().getDevice()); - { - List entries = parser.getSettingEntries(null, file, languageId); - assertEquals(new CIncludePathEntry(path0, 0), entries.get(0)); - assertEquals(new CIncludePathEntry(file.getParent().getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); - } + assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(null, file, languageId).get(0)); + assertEquals(new CIncludePathEntry(file.getParent().getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), parser.getSettingEntries(null, file, languageId).get(1)); } /** @@ -1090,31 +990,14 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - IPath path0 = new Path("/path0").setDevice(project.getLocation().getDevice()); - { - // in single quotes - List entries = parser.getSettingEntries(cfgDescription, file1, languageId); - CIncludePathEntry expected = new CIncludePathEntry(path0, 0); - assertEquals(expected, entries.get(0)); - } - { - // in double quotes - List entries = parser.getSettingEntries(cfgDescription, file2, languageId); - CIncludePathEntry expected = new CIncludePathEntry(path0, 0); - assertEquals(expected, entries.get(0)); - } - { - // Unix EOL - List entries = parser.getSettingEntries(cfgDescription, file3, languageId); - CIncludePathEntry expected = new CIncludePathEntry(path0, 0); - assertEquals(expected, entries.get(0)); - } - { - // Windows EOL - List entries = parser.getSettingEntries(cfgDescription, file4, languageId); - CIncludePathEntry expected = new CIncludePathEntry(path0, 0); - assertEquals(expected, entries.get(0)); - } + // in single quotes + assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(cfgDescription, file1, languageId).get(0)); + // in double quotes + assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(cfgDescription, file2, languageId).get(0)); + // Unix EOL + assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(cfgDescription, file3, languageId).get(0)); + // Windows EOL + assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(cfgDescription, file4, languageId).get(0)); } /** @@ -1150,13 +1033,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check entries - IPath path0 = new Path("/path0").setDevice(project.getLocation().getDevice()); - { - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(new CIncludePathEntry(path0, 0), entries.get(0)); - // Information from build output should take precedence over build dir - assertEquals(new CIncludePathEntry(project.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); - } + assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(cfgDescription, file, languageId).get(0)); + // Information from build output should take precedence over build dir + assertEquals(new CIncludePathEntry(project.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), parser.getSettingEntries(cfgDescription, file, languageId).get(1)); } /** @@ -1186,24 +1065,17 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - IPath path0 = new Path("/path0").setDevice(project.getLocation().getDevice()); { List entries = parser.getSettingEntries(cfgDescription, file0, languageId); - CIncludePathEntry expected = new CIncludePathEntry(path0, 0); - CIncludePathEntry entry = (CIncludePathEntry)entries.get(0); - assertEquals(expected, entry); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { List entries = parser.getSettingEntries(cfgDescription, file1, languageId); - CIncludePathEntry expected = new CIncludePathEntry(path0, 0); - CIncludePathEntry entry = (CIncludePathEntry)entries.get(0); - assertEquals(expected, entry); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { List entries = parser.getSettingEntries(cfgDescription, file2, languageId); - CIncludePathEntry expected = new CIncludePathEntry(path0, 0); - CIncludePathEntry entry = (CIncludePathEntry)entries.get(0); - assertEquals(expected, entry); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } } @@ -1273,13 +1145,11 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - // check that relative paths are relative to CWD which is the location of the project - assertEquals(new CIncludePathEntry(project.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); - assertEquals(new CIncludePathEntry(project.getLocation().removeLastSegments(1), 0), entries.get(1)); - assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(2)); - assertEquals(new CIncludePathEntry(folderComposite.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(3)); - } + // check that relative paths are relative to CWD which is the location of the project + assertEquals(new CIncludePathEntry(project.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); + assertEquals(new CIncludePathEntry(project.getLocation().removeLastSegments(1), 0), entries.get(1)); + assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(2)); + assertEquals(new CIncludePathEntry(folderComposite.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(3)); } /** @@ -1313,11 +1183,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - assertEquals(new CIncludePathEntry(".", 0), entries.get(0)); - assertEquals(new CIncludePathEntry("..", 0), entries.get(1)); - assertEquals(new CIncludePathEntry("Folder", 0), entries.get(2)); - } + assertEquals(new CIncludePathEntry(".", 0), entries.get(0)); + assertEquals(new CIncludePathEntry("..", 0), entries.get(1)); + assertEquals(new CIncludePathEntry("Folder", 0), entries.get(2)); } /** @@ -1349,10 +1217,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); - assertEquals(1, entries.size()); - } + assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); + assertEquals(1, entries.size()); } /** @@ -1392,13 +1258,11 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - assertEquals(new CIncludePathEntry(buildDir.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); - assertEquals(new CIncludePathEntry(buildDir.getFullPath().removeLastSegments(1), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); - assertEquals(new CIncludePathEntry(buildDir.getLocation().removeLastSegments(3), 0), entries.get(2)); - assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(3)); - assertEquals(new CIncludePathEntry(buildDir.getFullPath().append("MissingFolder"), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(4)); - } + assertEquals(new CIncludePathEntry(buildDir.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); + assertEquals(new CIncludePathEntry(buildDir.getFullPath().removeLastSegments(1), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); + assertEquals(new CIncludePathEntry(buildDir.getLocation().removeLastSegments(3), 0), entries.get(2)); + assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(3)); + assertEquals(new CIncludePathEntry(buildDir.getFullPath().append("MissingFolder"), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(4)); } /** @@ -1467,11 +1331,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - assertEquals(new CIncludePathEntry(buildDir.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); - assertEquals(new CIncludePathEntry(buildDir.getFullPath().removeLastSegments(1), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); - assertEquals(new CIncludePathEntry(buildDir.getFullPath().append("Folder"), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(2)); - } + assertEquals(new CIncludePathEntry(buildDir.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); + assertEquals(new CIncludePathEntry(buildDir.getFullPath().removeLastSegments(1), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); + assertEquals(new CIncludePathEntry(buildDir.getFullPath().append("Folder"), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(2)); } /** @@ -1509,12 +1371,10 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - IPath buildPath = new Path(uriBuildDir.getPath()).setDevice(project.getLocation().getDevice()); - assertEquals(new CIncludePathEntry(buildPath, 0), entries.get(0)); - assertEquals(new CIncludePathEntry(buildPath.removeLastSegments(1), 0), entries.get(1)); - assertEquals(new CIncludePathEntry(buildPath.append("Folder"), 0), entries.get(2)); - } + IPath buildPath = new Path(uriBuildDir.getPath()).setDevice(project.getLocation().getDevice()); + assertEquals(new CIncludePathEntry(buildPath, 0), entries.get(0)); + assertEquals(new CIncludePathEntry(buildPath.removeLastSegments(1), 0), entries.get(1)); + assertEquals(new CIncludePathEntry(buildPath.append("Folder"), 0), entries.get(2)); } /** @@ -1555,13 +1415,11 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - assertEquals(new CIncludePathEntry(buildDir.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); - assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); - assertEquals(new CIncludePathEntry(folder2.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(2)); - assertEquals(new CIncludePathEntry(buildDir.getFullPath().append("MissingFolder"), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(3)); - assertEquals(new CIncludePathEntry(buildDir.getFullPath().append("MissingFolder2"), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(4)); - } + assertEquals(new CIncludePathEntry(buildDir.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); + assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); + assertEquals(new CIncludePathEntry(folder2.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(2)); + assertEquals(new CIncludePathEntry("/BuildDir/MissingFolder", 0), entries.get(3)); + assertEquals(new CIncludePathEntry(buildDir.getFullPath().append("MissingFolder2"), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(4)); } /** @@ -1601,18 +1459,10 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); - assertEquals(new CIncludePathEntry(mappedFolder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); - } - { - IPath path = new Path("/Ambiguous/Folder").setDevice(file.getLocation().getDevice()); - assertEquals(new CIncludePathEntry(path, 0), entries.get(2)); - } - { - IPath path = new Path("/Missing/Folder").setDevice(file.getLocation().getDevice()); - assertEquals(new CIncludePathEntry(path, 0), entries.get(3)); - } + assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); + assertEquals(new CIncludePathEntry(mappedFolder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); + assertEquals(new CIncludePathEntry("/Ambiguous/Folder", 0), entries.get(2)); + assertEquals(new CIncludePathEntry("/Missing/Folder", 0), entries.get(3)); } /** @@ -1654,17 +1504,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); - } - { - IPath path = new Path("/Ambiguous/Folder").setDevice(file.getLocation().getDevice()); - assertEquals(new CIncludePathEntry(path, 0), entries.get(1)); - } - { - IPath path = new Path("/Missing/Folder").setDevice(file.getLocation().getDevice()); - assertEquals(new CIncludePathEntry(path, 0), entries.get(2)); - } + assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); + assertEquals(new CIncludePathEntry("/Ambiguous/Folder", 0), entries.get(1)); + assertEquals(new CIncludePathEntry("/Missing/Folder", 0), entries.get(2)); } /** @@ -1713,12 +1555,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - assertEquals(new CIncludePathEntry(folderInReferencedProject.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); - - IPath path = new Path("/Ambiguous/Folder").setDevice(file.getLocation().getDevice()); - assertEquals(new CIncludePathEntry(path, 0), entries.get(1)); - } + assertEquals(new CIncludePathEntry(folderInReferencedProject.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); + assertEquals(new CIncludePathEntry("/Ambiguous/Folder", 0), entries.get(1)); } /** @@ -1755,11 +1593,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - { - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - CIncludePathEntry expected = new CIncludePathEntry(dir2.removeLastSegments(1), 0); - assertEquals(expected, entries.get(0)); - } + List entries = parser.getSettingEntries(cfgDescription, file, languageId); + CIncludePathEntry expected = new CIncludePathEntry(dir2.removeLastSegments(1), 0); + assertEquals(expected, entries.get(0)); } /** @@ -1796,11 +1632,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - { - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - CIncludePathEntry expected = new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED); - assertEquals(expected, entries.get(0)); - } + List entries = parser.getSettingEntries(cfgDescription, file, languageId); + CIncludePathEntry expected = new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED); + assertEquals(expected, entries.get(0)); } /** @@ -1841,10 +1675,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - assertEquals(new CIncludePathEntry(buildDir.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); - assertEquals(new CIncludePathEntry(includeDir.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); - } + assertEquals(new CIncludePathEntry(buildDir.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); + assertEquals(new CIncludePathEntry(includeDir.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); } /** @@ -1886,11 +1718,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - assertEquals(new CIncludePathEntry(buildDir.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); - assertEquals(new CIncludePathEntry(includeDir.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); - } - + assertEquals(new CIncludePathEntry(buildDir.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); + assertEquals(new CIncludePathEntry(includeDir.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(1)); } /** @@ -1964,12 +1793,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - IPath path0 = new Path("/path0").setDevice(project.getLocation().getDevice()); - { - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - CIncludePathEntry expected = new CIncludePathEntry(path0, 0); - assertEquals(expected, entries.get(0)); - } + assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(cfgDescription, file, languageId).get(0)); // cleanup contentType.removeFileSpec("x++", IContentTypeSettings.FILE_EXTENSION_SPEC); @@ -1999,12 +1823,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - IPath path0 = new Path("/path0").setDevice(project.getLocation().getDevice()); - { - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - CIncludePathEntry expected = new CIncludePathEntry(path0, 0); - assertEquals(expected, entries.get(0)); - } + assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(cfgDescription, file, languageId).get(0)); } /** @@ -2039,15 +1858,15 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - { - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(new CIncludePathEntry(project.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); - assertEquals(new CIncludePathEntry(new Path("/Python1025/Include").setDevice(project.getLocation().getDevice()), 0), entries.get(1)); - assertEquals(new CMacroEntry("BOOST_ALL_NO_LIB", "1", 0), entries.get(2)); - assertEquals(new CMacroEntry("BOOST_PYTHON_SOURCE", "", 0), entries.get(3)); - assertEquals(new CMacroEntry("BOOST_PYTHON_STATIC_LIB", "", 0), entries.get(4)); - assertEquals(5, entries.size()); - } + List entries = parser.getSettingEntries(cfgDescription, file, languageId); + assertEquals(new CIncludePathEntry(project.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); + // "/Python1025/Include" not expected to be there + assertFalse(new java.io.File("/Python1025/Include").exists()); + assertEquals(new CIncludePathEntry("/Python1025/Include", 0), entries.get(1)); + assertEquals(new CMacroEntry("BOOST_ALL_NO_LIB", "1", 0), entries.get(2)); + assertEquals(new CMacroEntry("BOOST_PYTHON_SOURCE", "", 0), entries.get(3)); + assertEquals(new CMacroEntry("BOOST_PYTHON_STATIC_LIB", "", 0), entries.get(4)); + assertEquals(5, entries.size()); } /** @@ -2082,11 +1901,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - String device = project.getLocation().getDevice(); - assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); - assertEquals(new CIncludePathEntry(new Path("/Absolute/Folder").setDevice(device), 0), entries.get(1)); - } + String device = project.getLocation().getDevice(); + assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); + assertEquals(new CIncludePathEntry(new Path("/Absolute/Folder").setDevice(device), 0), entries.get(1)); } /** @@ -2121,10 +1938,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List entries = parser.getSettingEntries(cfgDescription, file, languageId); - { - String device = project.getLocation().getDevice(); - assertEquals(new CIncludePathEntry(new Path("/LocallyMappedTo/Folder").setDevice(device), 0), entries.get(0)); - } + String device = project.getLocation().getDevice(); + assertEquals(new CIncludePathEntry(new Path("/LocallyMappedTo/Folder").setDevice(device), 0), entries.get(0)); } /** @@ -2153,14 +1968,10 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List expected = new ArrayList(); - expected.add(new CIncludePathEntry(new Path("/path0").setDevice(project.getLocation().getDevice()), 0)); - - List entriesFile = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(expected, entriesFile); - List entriesFolder = parser.getSettingEntries(cfgDescription, folder, languageId); - assertEquals(null, entriesFolder); - List entriesProject = parser.getSettingEntries(cfgDescription, project, languageId); - assertEquals(null, entriesProject); + expected.add(new CIncludePathEntry("/path0", 0)); + assertEquals(expected, parser.getSettingEntries(cfgDescription, file, languageId)); + assertEquals(null, parser.getSettingEntries(cfgDescription, folder, languageId)); + assertEquals(null, parser.getSettingEntries(cfgDescription, project, languageId)); } /** @@ -2189,14 +2000,10 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List expected = new ArrayList(); - expected.add(new CIncludePathEntry(new Path("/path0").setDevice(project.getLocation().getDevice()), 0)); - - List entriesFile = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(null, entriesFile); - List entriesFolder = parser.getSettingEntries(cfgDescription, folder, languageId); - assertEquals(expected, entriesFolder); - List entriesProject = parser.getSettingEntries(cfgDescription, project, languageId); - assertEquals(null, entriesProject); + expected.add(new CIncludePathEntry("/path0", 0)); + assertEquals(null, parser.getSettingEntries(cfgDescription, file, languageId)); + assertEquals(expected, parser.getSettingEntries(cfgDescription, folder, languageId)); + assertEquals(null, parser.getSettingEntries(cfgDescription, project, languageId)); } /** @@ -2225,14 +2032,11 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List expected = new ArrayList(); - expected.add(new CIncludePathEntry(new Path("/path0").setDevice(project.getLocation().getDevice()), 0)); + expected.add(new CIncludePathEntry("/path0", 0)); - List entriesFile = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(null, entriesFile); - List entriesFolder = parser.getSettingEntries(cfgDescription, folder, languageId); - assertEquals(null, entriesFolder); - List entriesProject = parser.getSettingEntries(cfgDescription, project, languageId); - assertEquals(expected, entriesProject); + assertEquals(null, parser.getSettingEntries(cfgDescription, file, languageId)); + assertEquals(null, parser.getSettingEntries(cfgDescription, folder, languageId)); + assertEquals(expected, parser.getSettingEntries(cfgDescription, project, languageId)); } /** @@ -2261,7 +2065,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List expected = new ArrayList(); - expected.add(new CIncludePathEntry(new Path("/path0").setDevice(project.getLocation().getDevice()), 0)); + expected.add(new CIncludePathEntry("/path0", 0)); assertEquals(expected, parser.getSettingEntries(null, project, languageId)); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java index b6c51da59f0..9d8d5347644 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.managedbuilder.language.settings.providers; import java.io.File; -import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; @@ -741,38 +740,61 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * The manipulations here are done to resolve "../" navigation for symbolic links where "link/.." cannot - * be collapsed as it must follow the real file-system path. {@link java.io.File#getCanonicalPath()} deals - * with that correctly but {@link Path} or {@link URI} try to normalize the path which would be incorrect - * here. + * The manipulations here are done to resolve problems such as "../" navigation for symbolic links where + * "link/.." cannot be collapsed as it must follow the real file-system path. {@link java.io.File#getCanonicalPath()} + * deals with that correctly but {@link Path} or {@link URI} try to normalize the path which would be incorrect here. + * Another issue being resolved here is fixing drive letters in URI syntax. */ - private static URI resolvePathFromBaseLocation(String name, IPath baseLocation) { - String pathName = name; + private static URI resolvePathFromBaseLocation(String pathStr0, IPath baseLocation) { + String pathStr = pathStr0; if (baseLocation != null && !baseLocation.isEmpty()) { - pathName = pathName.replace(File.separatorChar, '/'); - String device = new Path(pathName).getDevice(); - if (device==null || device.equals(baseLocation.getDevice())) { + pathStr = pathStr.replace(File.separatorChar, '/'); + String device = new Path(pathStr).getDevice(); + if (device == null || device.equals(baseLocation.getDevice())) { if (device != null && device.length() > 0) { - pathName = pathName.substring(device.length()); + pathStr = pathStr.substring(device.length()); } baseLocation = baseLocation.addTrailingSeparator(); - if (pathName.startsWith("/")) { //$NON-NLS-1$ - pathName = pathName.substring(1); + if (pathStr.startsWith("/")) { //$NON-NLS-1$ + pathStr = pathStr.substring(1); } - pathName = baseLocation.toString() + pathName; + pathStr = baseLocation.toString() + pathStr; } } try { - File file = new File(pathName); + File file = new File(pathStr); file = file.getCanonicalFile(); - return file.toURI(); - } catch (IOException e) { - // if error just leave it as is + URI uri = file.toURI(); + if (file.exists()) { + return uri; + } + + IPath path0 = new Path(pathStr0); + if (!path0.isAbsolute()) { + return uri; + } + + String device = path0.getDevice(); + if (device == null || device.isEmpty()) { + // Avoid spurious adding of drive letters on Windows + pathStr = path0.setDevice(null).toString(); + } else { + // On Windows "C:/folder/" -> "/C:/folder/" + if (pathStr.charAt(0) != IPath.SEPARATOR) { + pathStr = IPath.SEPARATOR + pathStr; + } + } + + return new URI(uri.getScheme(), uri.getAuthority(), pathStr, uri.getQuery(), uri.getFragment()); + + } catch (Exception e) { + // if error will leave it as is + ManagedBuilderCorePlugin.log(e); } - return org.eclipse.core.filesystem.URIUtil.toURI(pathName); + return org.eclipse.core.filesystem.URIUtil.toURI(pathStr); } /** @@ -916,12 +938,17 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett String pathStr = EFSExtensionManager.getDefault().getMappedPath(uri); uri = org.eclipse.core.filesystem.URIUtil.toURI(pathStr); - try { - File file = new java.io.File(uri); - String canonicalPathStr = file.getCanonicalPath(); - return new Path(canonicalPathStr); - } catch (Exception e) { - ManagedBuilderCorePlugin.log(e); + if (uri != null && uri.isAbsolute()) { + try { + File file = new java.io.File(uri); + String canonicalPathStr = file.getCanonicalPath(); + if (new Path(pathStr).getDevice() == null) { + return new Path(canonicalPathStr).setDevice(null); + } + return new Path(canonicalPathStr); + } catch (Exception e) { + ManagedBuilderCorePlugin.log(e); + } } return null; } From 45d2d9400dea5ac9b620469037d1f9514c5ce89a Mon Sep 17 00:00:00 2001 From: Pawel Piech Date: Thu, 19 Jul 2012 14:10:19 -0700 Subject: [PATCH 11/11] Bug 385553 - [hover] Expression view hover in editor can show value for incorrect expression Change-Id: If149e80bbd8e1fcfa064ad5d5055cd88ea15900b Reviewed-on: https://git.eclipse.org/r/6876 Reviewed-by: Pawel Piech IP-Clean: Pawel Piech Tested-by: Pawel Piech --- .../expression/ExpressionVMProvider.java | 1 - .../expression/SingleExpressionVMNode.java | 194 +++++++----------- 2 files changed, 79 insertions(+), 116 deletions(-) diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/ExpressionVMProvider.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/ExpressionVMProvider.java index ba3b733c1f1..33ee22a6df5 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/ExpressionVMProvider.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/ExpressionVMProvider.java @@ -430,7 +430,6 @@ public class ExpressionVMProvider extends AbstractDMVMProvider if (input instanceof IExpressionDMContext) { IExpressionDMContext dmc = (IExpressionDMContext) input; SingleExpressionVMNode vmNode = (SingleExpressionVMNode) getChildVMNodes(getRootVMNode())[0]; - vmNode.setExpression(dmc); final IDMVMContext viewerInput= vmNode.createVMContext(dmc); // provide access to viewer (needed by details pane) diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/SingleExpressionVMNode.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/SingleExpressionVMNode.java index a511fbeb7ab..e9e6acc2334 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/SingleExpressionVMNode.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/SingleExpressionVMNode.java @@ -15,14 +15,10 @@ import java.util.LinkedList; import java.util.List; import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; -import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext; -import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider; -import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionsChangedEvent; -import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.InvalidExpressionVMContext; -import org.eclipse.cdt.dsf.ui.concurrent.ViewerCountingRequestMonitor; +import org.eclipse.cdt.dsf.ui.concurrent.ViewerDataRequestMonitor; import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMContext; import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMNode; import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode; @@ -38,6 +34,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProv import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; import org.eclipse.jface.viewers.TreePath; /** @@ -90,6 +87,10 @@ public class SingleExpressionVMNode extends AbstractVMNode implements IElementLa return getVMNode().hashCode() + fDmc.hashCode(); } + @Override + public String toString() { + return fDmc.toString(); + } } private static class SimpleExpression implements IExpression { @@ -141,27 +142,8 @@ public class SingleExpressionVMNode extends AbstractVMNode implements IElementLa } } - private static class SingleExpressionManager { - private static final IExpression[] NO_EXPRESSIONS = {}; - IExpression fExpression; - public IExpression[] getExpressions() { - if (fExpression != null) { - return new IExpression[] { fExpression }; - } - return NO_EXPRESSIONS; - } - public void setExpression(IExpression expression) { - fExpression = expression; - } - - } - - /** Local reference to the expression manager */ - private final SingleExpressionManager fManager; - public SingleExpressionVMNode(ExpressionVMProvider provider) { super(provider); - fManager = new SingleExpressionManager(); } @Override @@ -173,14 +155,21 @@ public class SingleExpressionVMNode extends AbstractVMNode implements IElementLa return (ExpressionVMProvider)getVMProvider(); } + private IExpressionDMContext getUpdateExpressionDMC(IViewerUpdate update) { + if (update.getElement() instanceof IDMVMContext) { + IDMContext dmc = ((IDMVMContext)update.getElement()).getDMContext(); + if (dmc instanceof IExpressionDMContext) { + return (IExpressionDMContext)dmc; + } + } + return null; + } + + @Override public void update(IHasChildrenUpdate[] updates) { - // Test availability of children based on whether there are any expressions - // in the manager. We assume that the getExpressions() will just read - // local state data, so we don't bother using a job to perform this - // operation. for (int i = 0; i < updates.length; i++) { - updates[i].setHasChilren(fManager.getExpressions().length != 0); + updates[i].setHasChilren(getUpdateExpressionDMC(updates[i]) != null); updates[i].done(); } } @@ -192,7 +181,7 @@ public class SingleExpressionVMNode extends AbstractVMNode implements IElementLa // We assume that the getExpressions() will just read local state data, // so we don't bother using a job to perform this operation. - update.setChildCount(fManager.getExpressions().length); + update.setChildCount(getUpdateExpressionDMC(update) != null ? 1 : 0); update.done(); } } @@ -200,62 +189,38 @@ public class SingleExpressionVMNode extends AbstractVMNode implements IElementLa @Override public void update(final IChildrenUpdate[] updates) { for (IChildrenUpdate update : updates) { - doUpdateChildren(update); + IExpressionDMContext dmc = getUpdateExpressionDMC(update); + if (dmc != null) { + doUpdateChildren(update, new SimpleExpression(dmc.getExpression())); + } + else { + handleFailedUpdate(update); + } } } - public void doUpdateChildren(final IChildrenUpdate update) { - final IExpression[] expressions = fManager.getExpressions(); - - // For each (expression) element in update, find the layout node that can - // parse it. And for each expression that has a corresponding layout node, - // call IExpressionLayoutNode#getElementForExpression to generate a VMC. - // Since the last is an async call, we need to create a multi-RM to wait - // for all the calls to complete. - final CountingRequestMonitor multiRm = new ViewerCountingRequestMonitor(getVMProvider().getExecutor(), update); - int multiRmCount = 0; - - int lowOffset= update.getOffset(); - if (lowOffset < 0) { - lowOffset = 0; - } - int length= update.getLength(); - if (length <= 0) { - length = expressions.length; - } - final int highOffset= lowOffset + length; - for (int i = lowOffset; i < highOffset && i < expressions.length + 1; i++) { - if (i < expressions.length) { - multiRmCount++; - final int childIndex = i; - final IExpression expression = expressions[i]; - // getElementForExpression() accepts a IElementsUpdate as an argument. - // Construct an instance of VMElementsUpdate which will call a - // the request monitor when it is finished. The request monitor - // will in turn set the element in the update argument in this method. - ((ExpressionVMProvider)getVMProvider()).update( - new VMExpressionUpdate( - update, expression, - new DataRequestMonitor(getVMProvider().getExecutor(), multiRm) { - @Override - protected void handleSuccess() { - update.setChild(getData(), childIndex); - multiRm.done(); - } - - @Override - protected void handleError() { - update.setChild(new InvalidExpressionVMContext(SingleExpressionVMNode.this, expression), childIndex); - multiRm.done(); - } - }) - ); - } - } - - // If no expressions were parsed, we're finished. - // Set the count to the counting RM. - multiRm.setDoneCount(multiRmCount); + public void doUpdateChildren(final IChildrenUpdate update, final IExpression expression) { + // getElementForExpression() accepts a IElementsUpdate as an argument. + // Construct an instance of VMElementsUpdate which will call a + // the request monitor when it is finished. The request monitor + // will in turn set the element in the update argument in this method. + ((ExpressionVMProvider)getVMProvider()).update( + new VMExpressionUpdate( + update, expression, + new ViewerDataRequestMonitor(getVMProvider().getExecutor(), update) { + @Override + protected void handleSuccess() { + update.setChild(getData(), 0); + update.done(); + } + + @Override + protected void handleError() { + update.setChild(new InvalidExpressionVMContext(SingleExpressionVMNode.this, expression), 0); + update.done(); + } + }) + ); } @Override @@ -267,7 +232,7 @@ public class SingleExpressionVMNode extends AbstractVMNode implements IElementLa update.done(); } } - + @Override public int getDeltaFlags(Object event) { int retVal = 0; @@ -277,41 +242,48 @@ public class SingleExpressionVMNode extends AbstractVMNode implements IElementLa retVal |= IModelDelta.ADDED | IModelDelta.REMOVED | IModelDelta.INSERTED | IModelDelta.CONTENT ; } - for (IExpression expression : fManager.getExpressions()) { - retVal |= getExpressionVMProvider().getDeltaFlagsForExpression(expression, event); + // The expression in the hover is not known here, so assume that all + // expression nodes need to provide delta flags for event. Iterate + // through them here and collect the flags. + for (IExpressionVMNode node : getExpressionVMProvider().getExpressionNodes()) { + retVal |= getDeltaFlagsForNode(node, event); } return retVal; } + private int getDeltaFlagsForNode(IVMNode node, Object event) { + int retVal = node.getDeltaFlags(event); + for (IVMNode child : getVMProvider().getChildVMNodes(node)) { + if (!node.equals(child)) { + retVal |= getDeltaFlagsForNode(child, event); + } + } + return retVal; + } + @Override public void buildDelta(final Object event, final VMDelta parentDelta, final int nodeOffset, final RequestMonitor requestMonitor) { if (event instanceof ExpressionsChangedEvent) { buildDeltaForExpressionsChangedEvent((ExpressionsChangedEvent)event, parentDelta, nodeOffset, requestMonitor); } else { - - // For each expression, find its corresponding node and ask that - // layout node for its delta flags for given event. If there are delta flags to be - // generated, call the asynchronous method to do so. - CountingRequestMonitor multiRm = new CountingRequestMonitor(getExecutor(), requestMonitor); - - int buildDeltaForExpressionCallCount = 0; - - IExpression[] expressions = fManager.getExpressions(); - for (int i = 0; i < expressions.length; i++ ) { - int flags = getExpressionVMProvider().getDeltaFlagsForExpression(expressions[i], event); - // If the given expression has no delta flags, skip it. - if (flags == IModelDelta.NO_CHANGE) continue; - - int elementOffset = nodeOffset >= 0 ? nodeOffset + i : -1; - getExpressionVMProvider().buildDeltaForExpression( - expressions[i], elementOffset, event, parentDelta, getTreePathFromDelta(parentDelta), - new RequestMonitor(getExecutor(), multiRm)); - buildDeltaForExpressionCallCount++; + Object parent = parentDelta.getElement(); + if (parent instanceof IDMVMContext) { + IDMContext dmc = ((IDMVMContext)parent).getDMContext(); + if (dmc instanceof IExpressionDMContext) { + IExpression expression = new SimpleExpression( ((IExpressionDMContext)dmc).getExpression() ); + int flags = getExpressionVMProvider().getDeltaFlagsForExpression(expression, event); + // If the given expression has no delta flags, skip it. + if (flags != IModelDelta.NO_CHANGE) { + getExpressionVMProvider().buildDeltaForExpression( + expression, nodeOffset, event, parentDelta, getTreePathFromDelta(parentDelta), + requestMonitor); + return; + } + } } - - multiRm.setDoneCount(buildDeltaForExpressionCallCount); } + requestMonitor.done(); } private void buildDeltaForExpressionsChangedEvent(ExpressionsChangedEvent event, VMDelta parentDelta, @@ -340,16 +312,8 @@ public class SingleExpressionVMNode extends AbstractVMNode implements IElementLa return new TreePath(elementList.toArray()); } - protected void updateElementsInSessionThread(IChildrenUpdate update) { - doUpdateChildren(update); - } - public IDMVMContext createVMContext(IDMContext dmc) { return new RootDMVMContext(getVMProvider().getRootVMNode(), dmc); } - public void setExpression(IExpressionDMContext dmc) { - String text = dmc.getExpression(); - fManager.setExpression(new SimpleExpression(text)); - } }