Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorEmanuel Graf2009-08-18 04:29:42 -0400
committerEmanuel Graf2009-08-18 04:29:42 -0400
commit061f23bca617671e820514a3546a063c03cff6f3 (patch)
tree0ac4cffb0593ee2fb7ea2ab57eba0299f6b4d1db /core
parentebd406ce915fc8c4936be69b38890bd4e3e3dc97 (diff)
downloadorg.eclipse.cdt-061f23bca617671e820514a3546a063c03cff6f3.tar.gz
org.eclipse.cdt-061f23bca617671e820514a3546a063c03cff6f3.tar.xz
org.eclipse.cdt-061f23bca617671e820514a3546a063c03cff6f3.zip
FIXED - bug 284973: "Internal Error" while using "Source -> Generate getters/setters"
https://bugs.eclipse.org/bugs/show_bug.cgi?id=284973
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/messages.properties1
5 files changed, 31 insertions, 15 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java
index 18a1c55b4a..47b4c87e16 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java
@@ -24,6 +24,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.Refactoring;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
@@ -179,6 +180,7 @@ public abstract class CRefactoring extends Refactoring {
}
if(!loadTranslationUnit(initStatus, sm.newChild(8))){
initStatus.addError(Messages.Refactoring_CantLoadTU);
+ return initStatus;
}
if(isProgressMonitorCanceld(sm, initStatus)) {
return initStatus;
@@ -225,6 +227,10 @@ public abstract class CRefactoring extends Refactoring {
try {
subMonitor.subTask(Messages.Refactoring_PM_ParseTU);
unit = loadTranslationUnit(file);
+ if(unit == null) {
+ subMonitor.done();
+ return false;
+ }
subMonitor.worked(2);
if(isProgressMonitorCanceld(subMonitor, initStatus)) {
return true;
@@ -249,6 +255,10 @@ public abstract class CRefactoring extends Refactoring {
protected IASTTranslationUnit loadTranslationUnit(IFile file) throws CoreException {
ITranslationUnit tu = (ITranslationUnit) CCorePlugin.getDefault().getCoreModel().create(file);
+ if(tu == null){
+ initStatus.addFatalError(NLS.bind(Messages.CRefactoring_FileNotFound, file.getName()));
+ return null;
+ }
return tu.getAST(fIndex, AST_STYLE);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java
index c589442222..34b943711d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java
@@ -35,6 +35,7 @@ public final class Messages extends NLS {
public static String CreateFileChange_CreateFile;
public static String CreateFileChange_UnknownLoc;
public static String CreateFileChange_FileExists;
+ public static String CRefactoring_FileNotFound;
public static String Refactoring_SelectionNotValid;
public static String Refactoring_CantLoadTU;
public static String Refactoring_Ambiguity;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java
index 908de7bee8..54e8ad5e66 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java
@@ -91,12 +91,14 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
super.checkInitialConditions(sm.newChild(6));
- initRefactoring(pm);
-
- if(context.existingFields.size() == 0) {
- initStatus.addFatalError(Messages.GenerateGettersAndSettersRefactoring_NoFields);
- }
-
+ if(!initStatus.hasFatalError()) {
+
+ initRefactoring(pm);
+
+ if(context.existingFields.size() == 0) {
+ initStatus.addFatalError(Messages.GenerateGettersAndSettersRefactoring_NoFields);
+ }
+ }
return initStatus;
}
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 e78eeb0972..34a5504b18 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
@@ -76,19 +76,21 @@ public class ImplementMethodRefactoring extends CRefactoring {
SubMonitor sm = SubMonitor.convert(pm, 10);
super.checkInitialConditions(sm.newChild(6));
- data.setMethodDeclarations(findUnimplementedMethodDeclarations(unit));
-
- if(region.getLength()>0) {
- IASTSimpleDeclaration methodDeclaration = SelectionHelper.findFirstSelectedDeclaration(region, unit);
- if (NodeHelper.isMethodDeclaration(methodDeclaration)) {
- for (MethodToImplementConfig config : data.getMethodDeclarations()) {
- if(config.getDeclaration() == methodDeclaration) {
- config.setChecked(true);
+ if(!initStatus.hasFatalError()) {
+
+ data.setMethodDeclarations(findUnimplementedMethodDeclarations(unit));
+
+ if(region.getLength()>0) {
+ IASTSimpleDeclaration methodDeclaration = SelectionHelper.findFirstSelectedDeclaration(region, unit);
+ if (NodeHelper.isMethodDeclaration(methodDeclaration)) {
+ for (MethodToImplementConfig config : data.getMethodDeclarations()) {
+ if(config.getDeclaration() == methodDeclaration) {
+ config.setChecked(true);
+ }
}
}
}
}
-
sm.done();
return initStatus;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/messages.properties
index 5a1bb230af..a9c8e839f0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/messages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/messages.properties
@@ -23,6 +23,7 @@ AddDeclarationNodeToClassChange_AddDeclaration=Add Declaration to Class {0}.
CreateFileChange_CreateFile=Create file: {0}
CreateFileChange_UnknownLoc=Unknown Location: {0}
CreateFileChange_FileExists=File already exists: {0}
+CRefactoring_FileNotFound=File {0} not found in the Project Source Path.
Refactoring_SelectionNotValid=Selection is not valid.
Refactoring_CantLoadTU=Can not load translation unit.
Refactoring_Ambiguity=Translation unit is ambiguous.

Back to the top