mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-01 12:43:26 +02:00
Code streamlining.
This commit is contained in:
parent
0ece103fb9
commit
46695ac68b
2 changed files with 8 additions and 16 deletions
|
@ -18,6 +18,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
import org.eclipse.core.filesystem.URIUtil;
|
import org.eclipse.core.filesystem.URIUtil;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
import org.eclipse.ltk.core.refactoring.Refactoring;
|
||||||
import org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy;
|
import org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy;
|
||||||
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
||||||
import org.eclipse.ltk.core.refactoring.history.RefactoringHistory;
|
import org.eclipse.ltk.core.refactoring.history.RefactoringHistory;
|
||||||
|
@ -25,8 +26,6 @@ import org.eclipse.ltk.internal.core.refactoring.history.RefactoringHistoryServi
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest;
|
import org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emanuel Graf IFS
|
* @author Emanuel Graf IFS
|
||||||
*/
|
*/
|
||||||
|
@ -41,7 +40,6 @@ public class RefactoringHistoryTest extends ExtractFunctionRefactoringTest {
|
||||||
protected void configureRefactoring(Properties refactoringProperties) {
|
protected void configureRefactoring(Properties refactoringProperties) {
|
||||||
scriptFile = fileMap.get(refactoringProperties.getProperty(
|
scriptFile = fileMap.get(refactoringProperties.getProperty(
|
||||||
"scriptFile", "refScript.xml"));
|
"scriptFile", "refScript.xml"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,27 +47,21 @@ public class RefactoringHistoryTest extends ExtractFunctionRefactoringTest {
|
||||||
String xmlSource = scriptFile.getSource();
|
String xmlSource = scriptFile.getSource();
|
||||||
URI uri= URIUtil.toURI(project.getLocation());
|
URI uri= URIUtil.toURI(project.getLocation());
|
||||||
xmlSource = xmlSource.replaceAll("\\$\\$projectPath\\$\\$", uri.getPath());
|
xmlSource = xmlSource.replaceAll("\\$\\$projectPath\\$\\$", uri.getPath());
|
||||||
RefactoringHistory refHist = RefactoringHistoryService.getInstance()
|
RefactoringHistory refHist = RefactoringHistoryService.getInstance().readRefactoringHistory(
|
||||||
.readRefactoringHistory(
|
new ByteArrayInputStream(xmlSource.getBytes()), 0);
|
||||||
new ByteArrayInputStream(xmlSource
|
|
||||||
.getBytes()), 0);
|
|
||||||
for (RefactoringDescriptorProxy proxy : refHist.getDescriptors()) {
|
for (RefactoringDescriptorProxy proxy : refHist.getDescriptors()) {
|
||||||
RefactoringStatus status = new RefactoringStatus();
|
RefactoringStatus status = new RefactoringStatus();
|
||||||
CRefactoring ref = (CRefactoring) proxy
|
Refactoring ref = proxy.requestDescriptor(new NullProgressMonitor()).createRefactoring(status);
|
||||||
.requestDescriptor(new NullProgressMonitor())
|
|
||||||
.createRefactoring(status);
|
|
||||||
assertTrue(status.isOK());
|
assertTrue(status.isOK());
|
||||||
RefactoringStatus checkInitialConditions = ref.checkInitialConditions(NULL_PROGRESS_MONITOR);
|
RefactoringStatus checkInitialConditions = ref.checkInitialConditions(NULL_PROGRESS_MONITOR);
|
||||||
|
|
||||||
if(fatalError){
|
if (fatalError) {
|
||||||
assertConditionsFatalError(checkInitialConditions);
|
assertConditionsFatalError(checkInitialConditions);
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
assertConditionsOk(checkInitialConditions);
|
assertConditionsOk(checkInitialConditions);
|
||||||
executeRefactoring(ref);
|
executeRefactoring(ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ import java.util.Collection;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.ltk.core.refactoring.Change;
|
import org.eclipse.ltk.core.refactoring.Change;
|
||||||
|
import org.eclipse.ltk.core.refactoring.Refactoring;
|
||||||
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.tests.refactoring.RefactoringTest;
|
import org.eclipse.cdt.ui.tests.refactoring.RefactoringTest;
|
||||||
|
@ -66,7 +66,7 @@ public class ExtractFunctionRefactoringTest extends RefactoringTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void executeRefactoring(CRefactoring refactoring) throws CoreException, Exception {
|
protected void executeRefactoring(Refactoring refactoring) throws Exception {
|
||||||
RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR);
|
RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR);
|
||||||
assertConditionsOk(finalConditions);
|
assertConditionsOk(finalConditions);
|
||||||
Change createChange = refactoring.createChange(NULL_PROGRESS_MONITOR);
|
Change createChange = refactoring.createChange(NULL_PROGRESS_MONITOR);
|
||||||
|
|
Loading…
Add table
Reference in a new issue