Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmanuel Graf2009-07-29 09:19:16 +0000
committerEmanuel Graf2009-07-29 09:19:16 +0000
commit9d35fca4a44b174dfb124c35b8daf2bed2c2fcc5 (patch)
tree28559617ec0b83c23d7faabe0afd11f7fbb6a413 /core/org.eclipse.cdt.ui
parentec02c7525d87b2271331d43ff08b667e37276842 (diff)
downloadorg.eclipse.cdt-9d35fca4a44b174dfb124c35b8daf2bed2c2fcc5.tar.gz
org.eclipse.cdt-9d35fca4a44b174dfb124c35b8daf2bed2c2fcc5.tar.xz
org.eclipse.cdt-9d35fca4a44b174dfb124c35b8daf2bed2c2fcc5.zip
FIXED - bug 280432: Refactoring removes comments in class header file and reformats file.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=280432
Diffstat (limited to 'core/org.eclipse.cdt.ui')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractFunctionAction.java2
3 files changed, 21 insertions, 5 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 0a4c744f1fb..9788291f86e 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
@@ -33,6 +33,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.text.edits.TextEditGroup;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
@@ -71,6 +72,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.core.dom.parser.c.CASTBinaryExpression;
@@ -122,6 +125,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
private final Container<Integer> returnNumber;
protected boolean hasNameResolvingForSimilarError = false;
+ protected ICProject project;
HashMap<String, Integer> nameTrail;
@@ -129,9 +133,10 @@ public class ExtractFunctionRefactoring extends CRefactoring {
private INodeFactory factory = CPPNodeFactory.getDefault();
public ExtractFunctionRefactoring(IFile file, ISelection selection,
- ExtractFunctionInformation info) {
+ ExtractFunctionInformation info, ICProject project) {
super(file, selection, null);
this.info = info;
+ this.project = project;
name = Messages.ExtractFunctionRefactoring_ExtractFunction;
names = new HashMap<String, Integer>();
namesCounter = new Container<Integer>(NULL_INTEGER);
@@ -190,6 +195,12 @@ public class ExtractFunctionRefactoring extends CRefactoring {
info.setDeclarator(getDeclaration(container.getNodesToWrite().get(0)));
MethodContext context = NodeHelper.findMethodContext(container.getNodesToWrite().get(0), getIndex());
info.setMethodContext(context);
+
+ if(unit != null) {
+ IIndex index = CCorePlugin.getIndexManager().getIndex(project);
+ unit.setIndex(index);
+ }
+
sm.done();
return status;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java
index 5e453713bf7..2511a71d678 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.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
@@ -16,6 +16,8 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
+import org.eclipse.cdt.core.model.ICProject;
+
import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner;
@@ -24,16 +26,19 @@ import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner;
*
*/
public class ExtractFunctionRefactoringRunner extends RefactoringRunner {
+
+ private ICProject project;
- public ExtractFunctionRefactoringRunner(IFile file, ISelection selection, IShellProvider shellProvider) {
+ public ExtractFunctionRefactoringRunner(IFile file, ISelection selection, IShellProvider shellProvider, ICProject project) {
super(file, selection, null, shellProvider);
+ this.project = project;
}
@Override
public void run() {
ExtractFunctionInformation info = new ExtractFunctionInformation();
- CRefactoring refactoring = new ExtractFunctionRefactoring(file,selection,info);
+ CRefactoring refactoring = new ExtractFunctionRefactoring(file,selection,info, project);
ExtractFunctionRefactoringWizard wizard = new ExtractFunctionRefactoringWizard(refactoring,info);
RefactoringWizardOpenOperation operator = new RefactoringWizardOpenOperation(wizard);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractFunctionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractFunctionAction.java
index 96cd385eaaa..2d7d38e0d29 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractFunctionAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractFunctionAction.java
@@ -45,7 +45,7 @@ public class ExtractFunctionAction extends RefactoringAction {
IResource res = wc.getResource();
if (res instanceof IFile) {
final ISelection selection = fEditor.getSelectionProvider().getSelection();
- new ExtractFunctionRefactoringRunner((IFile) res, selection, fEditor.getSite()).run();
+ new ExtractFunctionRefactoringRunner((IFile) res, selection, fEditor.getSite(), wc.getCProject()).run();
}
}

Back to the top