From c1b15e81bcaceb0330b7b02a69d6312ddc2d772c Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Thu, 12 Mar 2009 10:32:14 +0000 Subject: [PATCH] Fixes content assist and refactoring testcases, bug 268306. --- .../eclipse/cdt/core/testplugin/util/BaseTestCase.java | 10 +++++++++- .../core/dom/parser/cpp/semantics/LookupData.java | 2 +- .../cdt/internal/ui/refactoring/NodeContainer.java | 2 +- .../extractfunction/ExtractFunctionRefactoring.java | 2 +- .../ExtractedFunctionConstructionHelper.java | 4 ++-- .../refactoring/gettersandsetters/FunctionFactory.java | 4 ++-- .../implementmethod/ImplementMethodRefactoring.java | 4 ++-- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java index 1a5bc3e7f40..73f1aed8ad1 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2009 Wind River Systems, Inc. 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,7 @@ import org.eclipse.cdt.core.model.ElementChangedEvent; import org.eclipse.cdt.core.model.IElementChangedListener; import org.eclipse.cdt.core.testplugin.TestScannerProvider; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase; +import org.eclipse.core.resources.IResourceStatus; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.ILogListener; import org.eclipse.core.runtime.IProgressMonitor; @@ -123,6 +124,13 @@ public class BaseTestCase extends TestCase { ILogListener logListener= new ILogListener() { public void logging(IStatus status, String plugin) { if(!status.isOK() && status.getSeverity() != IStatus.INFO) { + switch (status.getCode()) { + case IResourceStatus.NOT_FOUND_LOCAL: + case IResourceStatus.NO_LOCATION_LOCAL: + case IResourceStatus.FAILED_READ_LOCAL: + // logged by the resources plugin. + return; + } statusLog.add(status); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java index 87d28514db5..57e9dd23154 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java @@ -285,7 +285,7 @@ public class LookupData { } else if (p1 instanceof ICPPASTNamedTypeSpecifier && p2 instanceof IASTTypeId) { if (p2.getParent() instanceof ICPPASTNewExpression) { IASTDeclarator dtor = ((IASTTypeId) p2).getAbstractDeclarator(); - if (dtor.getPointerOperators().length == 0) + if (dtor != null && dtor.getPointerOperators().length == 0) return true; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java index 085dfc18f74..6dcea881798 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java @@ -160,7 +160,7 @@ public class NodeContainer { declarator.setName(new CPPASTName(getDeclaration().toCharArray())); for (IASTPointerOperator pointerOp : sourceDeclarator .getPointerOperators()) { - declarator.addPointerOperator(pointerOp); + declarator.addPointerOperator(pointerOp.copy()); } if (isReference && !hasReferenceOperartor(declarator)) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java index f317fa34a0a..0a4c744f1fb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java @@ -651,7 +651,7 @@ public class ExtractFunctionRefactoring extends CRefactoring { for (IASTPointerOperator pointer : orgDecl.getDeclarators()[0] .getPointerOperators()) { - declarator.addPointerOperator(pointer); + declarator.addPointerOperator(pointer.copy()); } IASTInitializerExpression initializer = new CPPASTInitializerExpression(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractedFunctionConstructionHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractedFunctionConstructionHelper.java index db6b5aac8de..d073d080844 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractedFunctionConstructionHelper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractedFunctionConstructionHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -71,7 +71,7 @@ public abstract class ExtractedFunctionConstructionHelper { IASTDeclarator decl = (IASTDeclarator) returnVariable.getDeclaration().getParent(); IASTPointerOperator[] pointers = decl.getPointerOperators(); for (IASTPointerOperator operator : pointers) { - declarator.addPointerOperator(operator); + declarator.addPointerOperator(operator.copy()); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java index 90493b80c89..e3bec0915cb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -48,7 +48,7 @@ public class FunctionFactory { declarator.setConst(true); declarator.setName(getterName); for(IASTPointerOperator pointer : fieldDeclaration.getDeclarators()[0].getPointerOperators()){ - declarator.addPointerOperator(pointer); + declarator.addPointerOperator(pointer.copy()); } getter.setDeclarator(declarator); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java index 5646d6c298b..e78eeb0972c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik * Rapperswil, University of applied sciences and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -217,7 +217,7 @@ public class ImplementMethodRefactoring extends CRefactoring { createdMethodDeclarator.setName(qname); createdMethodDeclarator.setConst(functionDeclarator.isConst()); for(IASTPointerOperator pop : functionDeclarator.getPointerOperators()) { - createdMethodDeclarator.addPointerOperator(pop); + createdMethodDeclarator.addPointerOperator(pop.copy()); } func.setDeclarator(createdMethodDeclarator);