|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2008 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 51-56
Link Here
|
| 51 |
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser; |
51 |
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser; |
| 52 |
import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType; |
52 |
import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType; |
| 53 |
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; |
53 |
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; |
|
|
54 |
import org.eclipse.jdt.internal.corext.util.Strings; |
| 54 |
|
55 |
|
| 55 |
import org.eclipse.jdt.ui.JavaUI; |
56 |
import org.eclipse.jdt.ui.JavaUI; |
| 56 |
import org.eclipse.jdt.ui.PreferenceConstants; |
57 |
import org.eclipse.jdt.ui.PreferenceConstants; |
|
Lines 236-247
Link Here
|
| 236 |
testHelper(testClass); |
237 |
testHelper(testClass); |
| 237 |
|
238 |
|
| 238 |
IMethod[] methods= testClass.getMethods(); |
239 |
IMethod[] methods= testClass.getMethods(); |
| 239 |
checkMethods(new String[] { "b", "foo", "equals", "clone", "toString", "finalize", "hashCode" }, methods); |
240 |
checkMethodsInOrder(new String[] { "foo", "b", "clone", "equals", "finalize", "hashCode", "toString"}, methods); |
| 240 |
|
241 |
|
| 241 |
IImportDeclaration[] imports= cu.getImports(); |
242 |
IImportDeclaration[] imports= cu.getImports(); |
| 242 |
checkImports(new String[0], imports); |
243 |
checkImports(new String[0], imports); |
| 243 |
} |
244 |
} |
| 244 |
|
245 |
|
|
|
246 |
public void testBug297183() throws Exception { |
| 247 |
StringBuffer buf= new StringBuffer(); |
| 248 |
buf.append("package ibm.util;\n"); |
| 249 |
buf.append("interface Shape {\r\n"); |
| 250 |
buf.append(" int getX();\r\n"); |
| 251 |
buf.append(" int getY();\r\n"); |
| 252 |
buf.append(" int getEdges();\r\n"); |
| 253 |
buf.append(" int getArea();\r\n"); |
| 254 |
buf.append("}\r\n"); |
| 255 |
fPackage.createCompilationUnit("Shape.java", buf.toString(), false, null); |
| 256 |
|
| 257 |
buf= new StringBuffer(); |
| 258 |
buf.append("package ibm.util;\n"); |
| 259 |
buf.append("interface Circle extends Shape {\r\n"); |
| 260 |
buf.append(" int getR();\r\n"); |
| 261 |
buf.append("}\r\n"); |
| 262 |
buf.append("\r\n"); |
| 263 |
fPackage.createCompilationUnit("Circle.java", buf.toString(), false, null); |
| 264 |
|
| 265 |
buf= new StringBuffer(); |
| 266 |
buf.append("package ibm.util;\n"); |
| 267 |
buf.append("public class DefaultCircle implements Circle {\n"); |
| 268 |
buf.append("}\n"); |
| 269 |
ICompilationUnit cu= fPackage.getCompilationUnit("DefaultCircle.java"); |
| 270 |
IType testClass= cu.createType(buf.toString(), null, true, null); |
| 271 |
|
| 272 |
testHelper(testClass, -1, false); |
| 273 |
|
| 274 |
IMethod[] methods= testClass.getMethods(); |
| 275 |
checkMethodsInOrder(new String[] { "getX", "getY", "getEdges", "getArea", "getR"}, methods); |
| 276 |
|
| 277 |
IImportDeclaration[] imports= cu.getImports(); |
| 278 |
checkImports(new String[0], imports); |
| 279 |
} |
| 280 |
|
| 245 |
public void testInsertAt() throws Exception { |
281 |
public void testInsertAt() throws Exception { |
| 246 |
fJavaProject= JavaProjectHelper.createJavaProject("DummyProject", "bin"); |
282 |
fJavaProject= JavaProjectHelper.createJavaProject("DummyProject", "bin"); |
| 247 |
assertNotNull(JavaProjectHelper.addRTJar(fJavaProject)); |
283 |
assertNotNull(JavaProjectHelper.addRTJar(fJavaProject)); |
|
Lines 336-341
Link Here
|
| 336 |
JavaModelUtil.reconcile(testClass.getCompilationUnit()); |
372 |
JavaModelUtil.reconcile(testClass.getCompilationUnit()); |
| 337 |
} |
373 |
} |
| 338 |
|
374 |
|
|
|
375 |
private void checkMethodsInOrder(String[] expected, IMethod[] methods) { |
| 376 |
String[] actualNames= new String[methods.length]; |
| 377 |
for (int i= 0; i < actualNames.length; i++) { |
| 378 |
actualNames[i]= methods[i].getElementName(); |
| 379 |
} |
| 380 |
assertEquals(Strings.concatenate(expected, ", "), Strings.concatenate(actualNames, ", ")); |
| 381 |
} |
| 382 |
|
| 339 |
private void checkMethods(String[] expected, IMethod[] methods) { |
383 |
private void checkMethods(String[] expected, IMethod[] methods) { |
| 340 |
int nMethods= methods.length; |
384 |
int nMethods= methods.length; |
| 341 |
int nExpected= expected.length; |
385 |
int nExpected= expected.length; |