mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Code streamlining.
This commit is contained in:
parent
97b21f3397
commit
a5c4ac9c10
13 changed files with 86 additions and 170 deletions
|
@ -1,33 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2008 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
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* Institute for Software - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.ui.tests.refactoring;
|
|
||||||
|
|
||||||
import java.util.MissingResourceException;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
public class Messages {
|
|
||||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.tests.refactoring.messages"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
|
|
||||||
.getBundle(BUNDLE_NAME);
|
|
||||||
|
|
||||||
private Messages() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getString(String key) {
|
|
||||||
try {
|
|
||||||
return RESOURCE_BUNDLE.getString(key);
|
|
||||||
} catch (MissingResourceException e) {
|
|
||||||
return '!' + key + '!';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,15 +7,15 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.tests.refactoring;
|
package org.eclipse.cdt.ui.tests.refactoring;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.tests.BaseTestFramework;
|
import org.eclipse.cdt.core.tests.BaseTestFramework;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -27,7 +27,6 @@ import org.eclipse.jface.text.TextSelection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Guido Zgraggen IFS
|
* @author Guido Zgraggen IFS
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class RefactoringBaseTest extends BaseTestFramework implements ILogListener{
|
public abstract class RefactoringBaseTest extends BaseTestFramework implements ILogListener{
|
||||||
protected static final NullProgressMonitor NULL_PROGRESS_MONITOR = new NullProgressMonitor();
|
protected static final NullProgressMonitor NULL_PROGRESS_MONITOR = new NullProgressMonitor();
|
||||||
|
@ -40,7 +39,7 @@ public abstract class RefactoringBaseTest extends BaseTestFramework implements I
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RefactoringBaseTest(String name, Vector<TestSourceFile> files) {
|
public RefactoringBaseTest(String name, Collection<TestSourceFile> files) {
|
||||||
super(name);
|
super(name);
|
||||||
for (TestSourceFile file : files) {
|
for (TestSourceFile file : files) {
|
||||||
fileMap.put(file.getName(), file);
|
fileMap.put(file.getName(), file);
|
||||||
|
@ -79,7 +78,7 @@ public abstract class RefactoringBaseTest extends BaseTestFramework implements I
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(file.getContents()));
|
BufferedReader br = new BufferedReader(new InputStreamReader(file.getContents()));
|
||||||
StringBuilder code = new StringBuilder();
|
StringBuilder code = new StringBuilder();
|
||||||
String line;
|
String line;
|
||||||
while((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
code.append(line);
|
code.append(line);
|
||||||
code.append('\n');
|
code.append('\n');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2010 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2009, 2011 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others.
|
* Rapperswil, University of applied sciences and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -7,14 +7,14 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software (IFS)- initial API and implementation
|
* Institute for Software (IFS)- initial API and implementation
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.tests.refactoring;
|
package org.eclipse.cdt.ui.tests.refactoring;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.eclipse.core.filesystem.URIUtil;
|
import org.eclipse.core.filesystem.URIUtil;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
@ -29,15 +29,11 @@ import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emanuel Graf IFS
|
* @author Emanuel Graf IFS
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RefactoringHistoryTest extends
|
public class RefactoringHistoryTest extends ExtractFunctionRefactoringTest {
|
||||||
ExtractFunctionRefactoringTest {
|
|
||||||
|
|
||||||
private TestSourceFile scriptFile;
|
private TestSourceFile scriptFile;
|
||||||
|
|
||||||
public RefactoringHistoryTest(String name,
|
public RefactoringHistoryTest(String name, Collection<TestSourceFile> files) {
|
||||||
Vector<TestSourceFile> files) {
|
|
||||||
super(name, files);
|
super(name, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ package org.eclipse.cdt.ui.tests.refactoring;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
||||||
import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry;
|
import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry;
|
||||||
|
@ -36,12 +36,9 @@ public abstract class RefactoringTest extends RefactoringBaseTest {
|
||||||
protected String fileName;
|
protected String fileName;
|
||||||
protected RefactoringASTCache astCache;
|
protected RefactoringASTCache astCache;
|
||||||
|
|
||||||
public RefactoringTest(String name, Vector<TestSourceFile> files) {
|
public RefactoringTest(String name, Collection<TestSourceFile> files) {
|
||||||
super(name, files);
|
super(name, files);
|
||||||
initializeConfiguration(files);
|
initializeConfiguration(files);
|
||||||
for (TestSourceFile file : files) {
|
|
||||||
fileMap.put(file.getName(), file);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void configureRefactoring(Properties refactoringProperties);
|
protected abstract void configureRefactoring(Properties refactoringProperties);
|
||||||
|
@ -63,7 +60,7 @@ public abstract class RefactoringTest extends RefactoringBaseTest {
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeConfiguration(Vector<TestSourceFile> files) {
|
private void initializeConfiguration(Collection<TestSourceFile> files) {
|
||||||
TestSourceFile configFile = null;
|
TestSourceFile configFile = null;
|
||||||
|
|
||||||
for (TestSourceFile currentFile : files) {
|
for (TestSourceFile currentFile : files) {
|
||||||
|
@ -75,7 +72,7 @@ public abstract class RefactoringTest extends RefactoringBaseTest {
|
||||||
Properties refactoringProperties = new Properties();
|
Properties refactoringProperties = new Properties();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(configFile != null) {
|
if (configFile != null) {
|
||||||
refactoringProperties.load(new ByteArrayInputStream(configFile.getSource().getBytes()));
|
refactoringProperties.load(new ByteArrayInputStream(configFile.getSource().getBytes()));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.tests.refactoring;
|
package org.eclipse.cdt.ui.tests.refactoring;
|
||||||
|
|
||||||
|
@ -15,10 +15,9 @@ import java.io.BufferedReader;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -34,10 +33,8 @@ import org.eclipse.cdt.ui.testplugin.CTestPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emanuel Graf
|
* @author Emanuel Graf
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RefactoringTester extends TestSuite{
|
public class RefactoringTester extends TestSuite{
|
||||||
|
|
||||||
enum MatcherState{skip, inTest, inSource, inExpectedResult}
|
enum MatcherState{skip, inTest, inSource, inExpectedResult}
|
||||||
|
|
||||||
private static final String classRegexp = "//#(.*)\\s*(\\w*)*$"; //$NON-NLS-1$
|
private static final String classRegexp = "//#(.*)\\s*(\\w*)*$"; //$NON-NLS-1$
|
||||||
|
@ -61,9 +58,8 @@ public class RefactoringTester extends TestSuite{
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<RefactoringBaseTest> createTests(BufferedReader inputReader) throws Exception {
|
private static ArrayList<RefactoringBaseTest> createTests(BufferedReader inputReader) throws Exception {
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
Vector<TestSourceFile> files = new Vector<TestSourceFile>();
|
Collection<TestSourceFile> files = new ArrayList<TestSourceFile>();
|
||||||
TestSourceFile actFile = null;
|
TestSourceFile actFile = null;
|
||||||
MatcherState matcherState = MatcherState.skip;
|
MatcherState matcherState = MatcherState.skip;
|
||||||
ArrayList<RefactoringBaseTest> testCases = new ArrayList<RefactoringBaseTest>();
|
ArrayList<RefactoringBaseTest> testCases = new ArrayList<RefactoringBaseTest>();
|
||||||
|
@ -71,13 +67,12 @@ public class RefactoringTester extends TestSuite{
|
||||||
String className = null;
|
String className = null;
|
||||||
boolean bevorFirstTest = true;
|
boolean bevorFirstTest = true;
|
||||||
|
|
||||||
while ((line = inputReader.readLine()) != null){
|
while ((line = inputReader.readLine()) != null) {
|
||||||
|
if (lineMatchesBeginOfTest(line)) {
|
||||||
if(lineMatchesBeginOfTest(line)) {
|
if (!bevorFirstTest) {
|
||||||
if(!bevorFirstTest) {
|
|
||||||
RefactoringBaseTest test = createTestClass(className, testName, files);
|
RefactoringBaseTest test = createTestClass(className, testName, files);
|
||||||
testCases.add(test);
|
testCases.add(test);
|
||||||
files = new Vector<TestSourceFile>();
|
files = new ArrayList<TestSourceFile>();
|
||||||
className = null;
|
className = null;
|
||||||
testName = null;
|
testName = null;
|
||||||
}
|
}
|
||||||
|
@ -85,27 +80,27 @@ public class RefactoringTester extends TestSuite{
|
||||||
testName = getNameOfTest(line);
|
testName = getNameOfTest(line);
|
||||||
bevorFirstTest = false;
|
bevorFirstTest = false;
|
||||||
continue;
|
continue;
|
||||||
} else if (lineMatchesBeginOfResult(line)) {
|
} else if (lineMatchesBeginOfResult(line)) {
|
||||||
matcherState = MatcherState.inExpectedResult;
|
matcherState = MatcherState.inExpectedResult;
|
||||||
continue;
|
continue;
|
||||||
}else if (lineMatchesFileName(line)) {
|
} else if (lineMatchesFileName(line)) {
|
||||||
matcherState = MatcherState.inSource;
|
matcherState = MatcherState.inSource;
|
||||||
actFile = new TestSourceFile(getFileName(line));
|
actFile = new TestSourceFile(getFileName(line));
|
||||||
files.add(actFile);
|
files.add(actFile);
|
||||||
continue;
|
continue;
|
||||||
}else if(lineMatchesClassName(line)) {
|
} else if (lineMatchesClassName(line)) {
|
||||||
className = getNameOfClass(line);
|
className = getNameOfClass(line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(matcherState) {
|
switch (matcherState) {
|
||||||
case inSource:
|
case inSource:
|
||||||
if(actFile != null) {
|
if (actFile != null) {
|
||||||
actFile.addLineToSource(line);
|
actFile.addLineToSource(line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case inExpectedResult:
|
case inExpectedResult:
|
||||||
if(actFile != null) {
|
if (actFile != null) {
|
||||||
actFile.addLineToExpectedSource(line);
|
actFile.addLineToExpectedSource(line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -118,50 +113,44 @@ public class RefactoringTester extends TestSuite{
|
||||||
return testCases;
|
return testCases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static RefactoringBaseTest createTestClass(String className, String testName, Collection<TestSourceFile> files) throws Exception {
|
||||||
|
|
||||||
private static RefactoringBaseTest createTestClass(String className, String testName, Vector<TestSourceFile> files) throws Exception {
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class<?> refClass = Class.forName(className);
|
Class<?> refClass = Class.forName(className);
|
||||||
Class<?> paratypes[] = new Class[2];
|
if (testName == null) {
|
||||||
paratypes[0] = testName.getClass();
|
testName = refClass.getSimpleName();
|
||||||
paratypes[1] = files.getClass();
|
}
|
||||||
Constructor<?> ct = refClass.getConstructor(paratypes);
|
Constructor<?>[] constructors = refClass.getConstructors();
|
||||||
Object arglist[] = new Object[2];
|
for (Constructor<?> ctor : constructors) {
|
||||||
arglist[0] = testName;
|
Object arglist[] = new Object[] { testName, files };
|
||||||
arglist[1] = files;
|
if (ctor.getParameterTypes().length == arglist.length) {
|
||||||
RefactoringBaseTest test = (RefactoringBaseTest) ct.newInstance(arglist);
|
RefactoringBaseTest test = null;
|
||||||
for (TestSourceFile file : files) {
|
try {
|
||||||
TextSelection sel = file.getSelection();
|
test = (RefactoringBaseTest) ctor.newInstance(arglist);
|
||||||
if(sel != null) {
|
} catch (IllegalArgumentException e) {
|
||||||
test.setFileWithSelection(file.getName());
|
continue;
|
||||||
test.setSelection(sel);
|
}
|
||||||
break;
|
for (TestSourceFile file : files) {
|
||||||
|
TextSelection sel = file.getSelection();
|
||||||
|
if (sel != null) {
|
||||||
|
test.setFileWithSelection(file.getName());
|
||||||
|
test.setSelection(sel);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return test;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return test;
|
throw new Exception(className + " class does not provide required constructor"); //$NON-NLS-1$
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new Exception(Messages.getString("RefactoringTester.UnknownTestClass")); //$NON-NLS-1$
|
throw new Exception("Unknown test class " + className); //$NON-NLS-1$
|
||||||
} catch (SecurityException e) {
|
} catch (Exception e) {
|
||||||
throw new Exception(Messages.getString("RefactoringTester.SecurityException"), e); //$NON-NLS-1$
|
throw new Exception(e.getClass().getSimpleName() + " diring creation of test " + className, e); //$NON-NLS-1$
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
throw new Exception(Messages.getString("RefactoringTester.ConstructorError")); //$NON-NLS-1$
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
throw new Exception(Messages.getString("RefactoringTester.IllegalArgument"), e); //$NON-NLS-1$
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
throw new Exception(Messages.getString("RefactoringTester.InstantiationException"), e); //$NON-NLS-1$
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new Exception(Messages.getString("RefactoringTester.IllegalAccessException"), e); //$NON-NLS-1$
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
throw new Exception(Messages.getString("RefactoringTester.InvocationTargetException"), e); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getFileName(String line) {
|
private static String getFileName(String line) {
|
||||||
Matcher matcherBeginOfTest = createMatcherFromString(fileRegexp, line);
|
Matcher matcherBeginOfTest = createMatcherFromString(fileRegexp, line);
|
||||||
if(matcherBeginOfTest.find())
|
if (matcherBeginOfTest.find())
|
||||||
return matcherBeginOfTest.group(1);
|
return matcherBeginOfTest.group(1);
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
|
@ -169,7 +158,7 @@ public class RefactoringTester extends TestSuite{
|
||||||
|
|
||||||
private static String getNameOfClass(String line) {
|
private static String getNameOfClass(String line) {
|
||||||
Matcher matcherBeginOfTest = createMatcherFromString(classRegexp, line);
|
Matcher matcherBeginOfTest = createMatcherFromString(classRegexp, line);
|
||||||
if(matcherBeginOfTest.find())
|
if (matcherBeginOfTest.find())
|
||||||
return matcherBeginOfTest.group(1);
|
return matcherBeginOfTest.group(1);
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
|
@ -193,10 +182,9 @@ public class RefactoringTester extends TestSuite{
|
||||||
|
|
||||||
private static String getNameOfTest(String line) {
|
private static String getNameOfTest(String line) {
|
||||||
Matcher matcherBeginOfTest = createMatcherFromString(testRegexp, line);
|
Matcher matcherBeginOfTest = createMatcherFromString(testRegexp, line);
|
||||||
if(matcherBeginOfTest.find())
|
if (matcherBeginOfTest.find())
|
||||||
return matcherBeginOfTest.group(1);
|
return matcherBeginOfTest.group(1);
|
||||||
else
|
return null;
|
||||||
return Messages.getString("RefactoringTester.NotNamed"); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean lineMatchesBeginOfResult(String line) {
|
private static boolean lineMatchesBeginOfResult(String line) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -7,12 +7,12 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.tests.refactoring.extractconstant;
|
package org.eclipse.cdt.ui.tests.refactoring.extractconstant;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.ltk.core.refactoring.Change;
|
import org.eclipse.ltk.core.refactoring.Change;
|
||||||
|
@ -30,11 +30,9 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
|
||||||
* @author Emanuel Graf
|
* @author Emanuel Graf
|
||||||
*/
|
*/
|
||||||
public class ExtractConstantRefactoringTest extends RefactoringTest {
|
public class ExtractConstantRefactoringTest extends RefactoringTest {
|
||||||
|
|
||||||
|
|
||||||
protected VisibilityEnum visibility;
|
protected VisibilityEnum visibility;
|
||||||
|
|
||||||
public ExtractConstantRefactoringTest(String name, Vector<TestSourceFile> files) {
|
public ExtractConstantRefactoringTest(String name, Collection<TestSourceFile> files) {
|
||||||
super(name, files);
|
super(name, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +55,5 @@ public class ExtractConstantRefactoringTest extends RefactoringTest {
|
||||||
@Override
|
@Override
|
||||||
protected void configureRefactoring(Properties refactoringProperties) {
|
protected void configureRefactoring(Properties refactoringProperties) {
|
||||||
visibility = VisibilityEnum.getEnumForStringRepresentation(refactoringProperties.getProperty("visibility", VisibilityEnum.v_public.toString())); //$NON-NLS-1$
|
visibility = VisibilityEnum.getEnumForStringRepresentation(refactoringProperties.getProperty("visibility", VisibilityEnum.v_public.toString())); //$NON-NLS-1$
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -7,12 +7,12 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.tests.refactoring.extractfunction;
|
package org.eclipse.cdt.ui.tests.refactoring.extractfunction;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -30,10 +30,8 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emanuel Graf
|
* @author Emanuel Graf
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ExtractFunctionRefactoringTest extends RefactoringTest {
|
public class ExtractFunctionRefactoringTest extends RefactoringTest {
|
||||||
|
|
||||||
protected String methodName;
|
protected String methodName;
|
||||||
protected boolean replaceDuplicates;
|
protected boolean replaceDuplicates;
|
||||||
protected boolean returnValue;
|
protected boolean returnValue;
|
||||||
|
@ -47,7 +45,7 @@ public class ExtractFunctionRefactoringTest extends RefactoringTest {
|
||||||
* @param name
|
* @param name
|
||||||
* @param files
|
* @param files
|
||||||
*/
|
*/
|
||||||
public ExtractFunctionRefactoringTest(String name, Vector<TestSourceFile> files) {
|
public ExtractFunctionRefactoringTest(String name, Collection<TestSourceFile> files) {
|
||||||
super(name, files);
|
super(name, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -7,12 +7,12 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable;
|
package org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.ltk.core.refactoring.Change;
|
import org.eclipse.ltk.core.refactoring.Change;
|
||||||
|
@ -34,7 +34,7 @@ public class ExtractLocalVariableRefactoringTest extends RefactoringTest {
|
||||||
protected String variableName;
|
protected String variableName;
|
||||||
protected boolean fatalError;
|
protected boolean fatalError;
|
||||||
|
|
||||||
public ExtractLocalVariableRefactoringTest(String name, Vector<TestSourceFile> files) {
|
public ExtractLocalVariableRefactoringTest(String name, Collection<TestSourceFile> files) {
|
||||||
super(name, files);
|
super(name, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public class ExtractLocalVariableRefactoringTest extends RefactoringTest {
|
||||||
CRefactoring refactoring = new ExtractLocalVariableRefactoring( refFile, selection, info, cproject);
|
CRefactoring refactoring = new ExtractLocalVariableRefactoring( refFile, selection, info, cproject);
|
||||||
RefactoringStatus checkInitialConditions = refactoring.checkInitialConditions(NULL_PROGRESS_MONITOR);
|
RefactoringStatus checkInitialConditions = refactoring.checkInitialConditions(NULL_PROGRESS_MONITOR);
|
||||||
|
|
||||||
if(fatalError){
|
if (fatalError){
|
||||||
assertConditionsFatalError(checkInitialConditions);
|
assertConditionsFatalError(checkInitialConditions);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
package org.eclipse.cdt.ui.tests.refactoring.gettersandsetters;
|
package org.eclipse.cdt.ui.tests.refactoring.gettersandsetters;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -48,7 +48,7 @@ public class GenerateGettersAndSettersTest extends RefactoringTest {
|
||||||
* @param name
|
* @param name
|
||||||
* @param files
|
* @param files
|
||||||
*/
|
*/
|
||||||
public GenerateGettersAndSettersTest(String name, Vector<TestSourceFile> files) {
|
public GenerateGettersAndSettersTest(String name, Collection<TestSourceFile> files) {
|
||||||
super(name, files);
|
super(name, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -7,12 +7,12 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.tests.refactoring.hidemethod;
|
package org.eclipse.cdt.ui.tests.refactoring.hidemethod;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.ltk.core.refactoring.Change;
|
import org.eclipse.ltk.core.refactoring.Change;
|
||||||
|
@ -32,7 +32,7 @@ public class HideMethodRefactoringTest extends RefactoringTest {
|
||||||
private int errors;
|
private int errors;
|
||||||
private int fatalerrors;
|
private int fatalerrors;
|
||||||
|
|
||||||
public HideMethodRefactoringTest(String name, Vector<TestSourceFile> files) {
|
public HideMethodRefactoringTest(String name, Collection<TestSourceFile> files) {
|
||||||
super(name, files);
|
super(name, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -7,12 +7,12 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.tests.refactoring.implementmethod;
|
package org.eclipse.cdt.ui.tests.refactoring.implementmethod;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.ltk.core.refactoring.Change;
|
import org.eclipse.ltk.core.refactoring.Change;
|
||||||
|
@ -26,22 +26,18 @@ import org.eclipse.cdt.internal.ui.refactoring.implementmethod.ImplementMethodRe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mirko Stocker
|
* @author Mirko Stocker
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ImplementMethodRefactoringTest extends RefactoringTest {
|
public class ImplementMethodRefactoringTest extends RefactoringTest {
|
||||||
|
|
||||||
protected int finalWarnings;
|
protected int finalWarnings;
|
||||||
private int initialWarnings;
|
private int initialWarnings;
|
||||||
|
|
||||||
public ImplementMethodRefactoringTest(String name,Vector<TestSourceFile> files) {
|
public ImplementMethodRefactoringTest(String name, Collection<TestSourceFile> files) {
|
||||||
super(name, files);
|
super(name, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void runTest() throws Throwable {
|
protected void runTest() throws Throwable {
|
||||||
|
|
||||||
IFile refFile = project.getFile(fileName);
|
IFile refFile = project.getFile(fileName);
|
||||||
|
|
||||||
CRefactoring refactoring = new ImplementMethodRefactoring(refFile, selection, null, cproject);
|
CRefactoring refactoring = new ImplementMethodRefactoring(refFile, selection, null, cproject);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -65,8 +61,7 @@ public class ImplementMethodRefactoringTest extends RefactoringTest {
|
||||||
assertConditionsWarning(finalConditions, finalWarnings);
|
assertConditionsWarning(finalConditions, finalWarnings);
|
||||||
}
|
}
|
||||||
compareFiles(fileMap);
|
compareFiles(fileMap);
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
refactoring.unlockIndex();
|
refactoring.unlockIndex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
###############################################################################
|
|
||||||
# Copyright (c) 2008 Wind River Systems and others.
|
|
||||||
# All rights reserved. This program and the accompanying materials
|
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
# which accompanies this distribution, and is available at
|
|
||||||
# http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
#
|
|
||||||
# Contributors:
|
|
||||||
# Wind River Systems - initial API and implementation
|
|
||||||
###############################################################################
|
|
||||||
RefactoringTester.UnknownTestClass=Unknown TestClass. Make sure the test's sourcefile specifies a valid test class.
|
|
||||||
RefactoringTester.SecurityException=Security Exception during Test creation
|
|
||||||
RefactoringTester.ConstructorError=Test class does not provied required constructor.
|
|
||||||
RefactoringTester.IllegalArgument=IllegalArgumentException during Test creation
|
|
||||||
RefactoringTester.InstantiationException=InstantiationException during Test creation
|
|
||||||
RefactoringTester.IllegalAccessException=IllegalAccessException during Test creation
|
|
||||||
RefactoringTester.InvocationTargetException=InvocationTargetException during Test creation
|
|
||||||
RefactoringTester.NotNamed=Not Named
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -7,12 +7,12 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.tests.refactoring.utils;
|
package org.eclipse.cdt.ui.tests.refactoring.utils;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
|
||||||
|
@ -25,13 +25,11 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.TranslationUnitHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mirko Stocker
|
* @author Mirko Stocker
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class TranslationUnitHelperTest extends RefactoringTest {
|
public class TranslationUnitHelperTest extends RefactoringTest {
|
||||||
|
|
||||||
private int offset;
|
private int offset;
|
||||||
|
|
||||||
public TranslationUnitHelperTest(String name,Vector<TestSourceFile> files) {
|
public TranslationUnitHelperTest(String name, Collection<TestSourceFile> files) {
|
||||||
super(name, files);
|
super(name, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue