mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 562896 - Fix qualified name in return type for implement method
Change-Id: Ie1ff2e401091655c6ecc2a7393dac19cea872a0e
(cherry picked from commit 1d38d997dc
)
This commit is contained in:
parent
59d53ab880
commit
35384d6adf
2 changed files with 32 additions and 3 deletions
|
@ -936,4 +936,21 @@ public class ImplementMethodRefactoringTest extends RefactoringTestBase {
|
||||||
public void testNoexpect_Bug562722() throws Exception {
|
public void testNoexpect_Bug562722() throws Exception {
|
||||||
assertRefactoringSuccess();
|
assertRefactoringSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//A.h
|
||||||
|
//
|
||||||
|
//struct Test {};
|
||||||
|
//class TestClass {
|
||||||
|
//public:
|
||||||
|
// /*$*/Test foo();/*$$*/
|
||||||
|
//};
|
||||||
|
//
|
||||||
|
|
||||||
|
//A.cpp
|
||||||
|
//====================
|
||||||
|
//Test TestClass::foo() {
|
||||||
|
//}
|
||||||
|
public void testWithClassAsReturnType_Bug562896() throws Exception {
|
||||||
|
assertRefactoringSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTNodeFactoryFactory;
|
import org.eclipse.cdt.core.dom.ast.ASTNodeFactoryFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
@ -321,9 +323,19 @@ public class ImplementMethodRefactoring extends CRefactoring {
|
||||||
* we could miss the fully qualified name.
|
* we could miss the fully qualified name.
|
||||||
*/
|
*/
|
||||||
if (declSpecifier instanceof ICPPASTNamedTypeSpecifier) {
|
if (declSpecifier instanceof ICPPASTNamedTypeSpecifier) {
|
||||||
ICPPASTQualifiedName qName = createQualifiedNameFor((IASTNamedTypeSpecifier) declSpecifier,
|
IBinding binding = ((ICPPASTNamedTypeSpecifier) methodDeclaration.getDeclSpecifier()).getName()
|
||||||
functionDeclarator, declarationParent, insertLocation, functionOffset);
|
.resolveBinding();
|
||||||
((IASTNamedTypeSpecifier) declSpecifier).setName(qName);
|
try {
|
||||||
|
if (binding.getScope().getKind() == EScopeKind.eClassType) {
|
||||||
|
if (!(((ICPPASTNamedTypeSpecifier) declSpecifier).getName() instanceof ICPPASTQualifiedName)) {
|
||||||
|
ICPPASTQualifiedName qName = createQualifiedNameFor((IASTNamedTypeSpecifier) declSpecifier,
|
||||||
|
functionDeclarator, declarationParent, insertLocation, functionOffset);
|
||||||
|
((IASTNamedTypeSpecifier) declSpecifier).setName(qName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DOMException | CoreException e) {
|
||||||
|
CUIPlugin.log(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (declSpecifier instanceof ICPPASTDeclSpecifier) {
|
if (declSpecifier instanceof ICPPASTDeclSpecifier) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue