Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java7
1 files changed, 6 insertions, 1 deletions
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 7b1b8a0e8e9..e3e44f5c3b0 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
@@ -215,6 +215,10 @@ public class ExtractFunctionRefactoring extends CRefactoring {
info.setDeclarator(getDeclaration(container.getNodesToWrite().get(0)));
MethodContext context = NodeHelper.findMethodContext(container.getNodesToWrite().get(0),
refactoringContext, sm.newChild(1));
+ if (context.getType() == ContextType.METHOD && context.getMethodDeclarationName() == null) {
+ initStatus.addFatalError(Messages.ExtractFunctionRefactoring_no_declaration_of_surrounding_method);
+ return initStatus;
+ }
info.setMethodContext(context);
return initStatus;
} finally {
@@ -290,8 +294,9 @@ public class ExtractFunctionRefactoring extends CRefactoring {
MethodContext context = info.getMethodContext();
if (context.getType() == ContextType.METHOD && !context.isInline()) {
+ IASTDeclaration contextDeclaration = context.getMethodDeclaration();
ICPPASTCompositeTypeSpecifier classDeclaration =
- (ICPPASTCompositeTypeSpecifier) context.getMethodDeclaration().getParent();
+ (ICPPASTCompositeTypeSpecifier) contextDeclaration.getParent();
IASTSimpleDeclaration methodDeclaration = getDeclaration(methodName);
if (isMethodAllreadyDefined(methodDeclaration, classDeclaration, getIndex())) {

Back to the top