mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
FIXED - bug 246062: [Refactoring] NPE extracting a constant from an inlined method
https://bugs.eclipse.org/bugs/show_bug.cgi?id=246062
This commit is contained in:
parent
21c07ecee5
commit
4cdb7e40c9
2 changed files with 30 additions and 1 deletions
|
@ -449,3 +449,25 @@ int A::foo()
|
|||
return theAnswer;
|
||||
}
|
||||
|
||||
//!Bug 246062 [Refactoring] NPE extracting a constant from an inlined method
|
||||
//#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest
|
||||
//@.config
|
||||
filename=A.h
|
||||
//@A.h
|
||||
class X {
|
||||
void method() {
|
||||
int a= /*$*/1/*$$*/;
|
||||
}
|
||||
};
|
||||
|
||||
//=
|
||||
namespace
|
||||
{
|
||||
const int theAnswer = 1;
|
||||
}
|
||||
class X {
|
||||
void method() {
|
||||
int a= theAnswer;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -170,7 +170,14 @@ public class ExtractConstantRefactoring extends CRefactoring {
|
|||
if (binding instanceof CPPMethod) {
|
||||
|
||||
CPPMethod methode = (CPPMethod) binding;
|
||||
IASTNode decl = methode.getDeclarations()[0];
|
||||
IASTNode[] declarations = methode.getDeclarations();
|
||||
|
||||
IASTNode decl;
|
||||
if(declarations != null) {
|
||||
decl = declarations[0];
|
||||
}else {
|
||||
decl = methode.getDefinition();
|
||||
}
|
||||
|
||||
IASTNode spec = decl.getParent().getParent();
|
||||
if (spec instanceof ICPPASTCompositeTypeSpecifier) {
|
||||
|
|
Loading…
Add table
Reference in a new issue