This commit was manufactured by cvs2svn to create tag 'v_273a'.
Sprout from master 2002-09-16 14:23:05 UTC Jerome lanneluc <jlanneluc> '*** empty log message ***'
Cherrypick from master 2002-09-18 15:27:40 UTC Jerome lanneluc <jlanneluc> '*** empty log message ***':
org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java
Cherrypick from master 2002-09-19 12:07:47 UTC Philipe Mulet <pmulet> '*** empty log message ***':
org.eclipse.jdt.core/buildnotes_jdt-core.html
Delete:
org.eclipse.jdt.core.tests.builder/.classpath
org.eclipse.jdt.core.tests.builder/.cvsignore
org.eclipse.jdt.core.tests.builder/.project
org.eclipse.jdt.core.tests.builder/about.html
org.eclipse.jdt.core.tests.builder/build.properties
org.eclipse.jdt.core.tests.builder/plugin.xml
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractMethodTests.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Assert.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AssertionFailedException.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ClasspathTests.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/CompilationUnitLocationTests.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyCompilerRequestor.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyTests.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ErrorsTests.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ExecutionTests.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/FilteredTestSuite.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/JCLTests.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/OutputFolderTests.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageTests.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Problem.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java
org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Tests.java
org.eclipse.jdt.core.tests.builder/test.xml
org.eclipse.jdt.core.tests.compiler/.classpath
org.eclipse.jdt.core.tests.compiler/.cvsignore
org.eclipse.jdt.core.tests.compiler/.project
org.eclipse.jdt.core.tests.compiler/about.html
org.eclipse.jdt.core.tests.compiler/build.properties
org.eclipse.jdt.core.tests.compiler/plugin.xml
org.eclipse.jdt.core.tests.compiler/src/EvalTestsTarget.zip
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractCompletionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSelectionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AllocationExpressionCompletionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ClassLiteralAccessCompletionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionRecoveryTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietCompletionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ExplicitConstructorInvocationCompletionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ExplicitConstructorInvocationSelectionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/FieldAccessCompletionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/InnerTypeCompletionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LabelStatementCompletionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/MethodInvocationCompletionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/NameReferenceCompletionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceTypeCompletionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SingleCompletionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceField.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceImport.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceInitializer.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceMethod.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourcePackage.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceType.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileComparatorTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExpectedProblem.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InMemoryNameEnvironment.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LogRequestor.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RegressionTestSetup.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Requestor.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UtilTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/CodeSnippetTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationSetup.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationSetup.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/JDIStackFrame.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeCodeSnippetTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeVariableTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SanityTestEvaluationContext.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SanityTestEvaluationResult.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SimpleCodeSnippetTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SimpleTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SimpleVariableTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/TestAll.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/VariableTest.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetClassLoader.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetRunner.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/IDEInterface.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/ExcludedTestSuite.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/StopableTestCase.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestListener.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestResult.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/AbstractReader.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VMLauncher.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VirtualMachine.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVirtualMachine.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/NullConsoleReader.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/ProxyConsoleReader.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/RuntimeConstants.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/TargetException.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/TargetInterface.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/VMInputStream.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/SocketHelper.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/VerifyTests.java
org.eclipse.jdt.core.tests.compiler/test.xml
org.eclipse.jdt.core.tests.model/.classpath
org.eclipse.jdt.core.tests.model/.cvsignore
org.eclipse.jdt.core.tests.model/.project
org.eclipse.jdt.core.tests.model/JCL/converterJclMin.jar
org.eclipse.jdt.core.tests.model/JCL/converterJclMinsrc.zip
org.eclipse.jdt.core.tests.model/JCL/jclMin.jar
org.eclipse.jdt.core.tests.model/JCL/jclMinsrc.zip
org.eclipse.jdt.core.tests.model/about.html
org.eclipse.jdt.core.tests.model/build.properties
org.eclipse.jdt.core.tests.model/plugin.xml
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTMatcherTest.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTPosterChild.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTVisitorTest.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/RunAllTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/BufferTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassNameTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateMethodSourceExamplesTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateTypeSourceExamplesTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/EncodingTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExistenceTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/HierarchyOnWorkingCopiesTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaConventionTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaModelTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NameLookupTests2.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SuiteOfTestCases.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyNotInClasspathTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopySearchTests.java
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java
org.eclipse.jdt.core.tests.model/test.xml
org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/.classpath
org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/.project
org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attach.jar
org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attach2.jar
org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attach2src.zip
org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attachsrc.new.zip
org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attachsrc.zip
org.eclipse.jdt.core.tests.model/workspace/Converter/.classpath
org.eclipse.jdt.core.tests.model/workspace/Converter/.project
org.eclipse.jdt.core.tests.model/workspace/Converter/Hello.java
org.eclipse.jdt.core.tests.model/workspace/Converter/Test0157.java
org.eclipse.jdt.core.tests.model/workspace/Converter/Test0158.java
org.eclipse.jdt.core.tests.model/workspace/Converter/Test0170.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/AboutDialog.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/Logo.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/ProgressBar.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/TestRunner.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/ActiveTestSuite.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/ExceptionTestCase.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/RepeatedTest.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/TestDecorator.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/TestSetup.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/Assert.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/AssertionFailedError.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/Protectable.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestCase.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestFailure.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestListener.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestResult.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestSuite.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/BaseTestRunner.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/ClassPathTestCollector.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/FailureDetailView.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/LoadingTestCollector.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/ReloadingTestSuiteLoader.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/SimpleTestCollector.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/Sorter.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/StandardTestSuiteLoader.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/TestCaseClassLoader.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/TestCollector.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/TestSuiteLoader.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/Version.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/AboutDialog.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/CounterPanel.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/DefaultFailureDetailView.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/FailureRunView.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/ProgressBar.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/StatusLine.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestHierarchyRunView.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestRunContext.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestRunView.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestRunner.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestSelector.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestSuitePanel.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestTreeModel.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/textui/TestRunner.java
org.eclipse.jdt.core.tests.model/workspace/Converter/junit/ui/TestRunner.java
org.eclipse.jdt.core.tests.model/workspace/Converter/p1/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/p2/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/p3/B.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0001/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0002/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0003/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0004/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0005/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0006/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0007/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0008/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0009/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0010/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0011/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0012/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0013/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0014/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0015/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0016/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0017/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0018/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0019/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0020/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0021/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0022/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0023/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0024/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0025/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0026/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0027/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0028/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0029/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0030/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0031/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0032/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0033/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0034/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0035/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0036/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0037/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0038/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0039/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0040/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0041/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0042/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0043/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0044/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0045/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0046/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0047/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0048/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0049/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0050/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0051/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0052/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0053/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0054/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0055/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0056/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0057/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0058/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0059/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0060/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0061/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0062/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0063/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0064/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0065/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0066/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0067/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0068/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0069/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0070/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0071/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0072/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0073/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0074/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0075/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0076/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0077/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0078/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0079/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0080/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0081/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0082/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0083/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0084/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0085/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0086/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0087/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0088/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0089/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0090/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0091/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0092/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0093/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0094/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0095/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0096/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0097/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0098/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0099/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0100/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0101/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0102/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0103/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0104/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0105/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0106/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0107/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0108/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0109/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0110/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0111/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0112/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0113/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0114/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0115/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0116/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0117/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0118/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0119/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0120/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0121/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0122/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0123/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0124/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0125/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0126/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0127/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0128/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0129/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0130/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0131/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0132/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0133/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0134/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0135/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0136/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0137/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0138/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0139/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0140/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0141/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0142/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0143/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0144/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0145/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0146/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0147/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0148/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0149/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0150/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0151/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0152/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0153/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0154/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0155/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0156/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0159/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0160/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0161/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0162/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0163/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0164/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0165/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0166/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0167/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0168/test1/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0169/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0171/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0172/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0173/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0174/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0175/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0176/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0177/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0178/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0179/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0180/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0181/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0182/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0183/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0184/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0185/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0186/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0187/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0188/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0189/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0190/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0191/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0192/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0193/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0194/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0195/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0196/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0197/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0198/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0199/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0200/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0201/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0202/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0203/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0204/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0205/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0206/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0207/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0208/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0209/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0210/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0211/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0212/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0213/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0214/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0215/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0216/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0217/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0218/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0219/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0220/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0221/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0222/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0223/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0224/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0225/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0226/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0227/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0228/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0229/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0230/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0231/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0232/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0233/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0234/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0235/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0236/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0238/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0239/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0240/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0241/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0242/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0243/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0244/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0245/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0246/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0247/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0248/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0249/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0250/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0251/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0252/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0253/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0254/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0255/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0256/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0257/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0258/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0259/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0260/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0261/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0262/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0263/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0264/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0265/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0266/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0267/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0268/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0269/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0270/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0271/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0272/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0273/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0274/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0275/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0276/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0277/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0278/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0279/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0280/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0281/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0282/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0283/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0284/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0285/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0286/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0287/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0288/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0289/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0290/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0291/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0292/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0293/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0294/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0295/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0296/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0297/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0298/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0299/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0300/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0301/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0302/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0303/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0304/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0307/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0308/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0309/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0310/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0311/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0312/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0313/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0314/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0315/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0317/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0318/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0319/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0320/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0321/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0322/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0323/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0324/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0325/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0326/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0327/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0328/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0329/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0330/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0331/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0332/LocalSelectionTransfer.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0333/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0334/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0335/ExceptionTestCaseTest.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0336/SorterTest.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0337/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0338/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0339/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0341/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0342/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0343/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0344/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0345/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0346/Test2.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0347/Test2.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0348/Test2.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0349/Test2.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0350/Test2.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0351/Test2.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0352/Test2.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0353/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0354/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0355/Foo.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0356/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0356/X.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0357/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0358/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0359/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0360/X.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0361/X.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0362/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0363/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0364/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0365/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0366/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0367/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0368/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0369/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0370/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0371/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0372/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0373/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0374/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0375/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0376/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0377/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0378/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0379/Test.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0380/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0381/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0382/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0383/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0384/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0385/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0386/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0387/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0388/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0389/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0390/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0391/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0392/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0393/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0394/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0395/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0396/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0397/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0398/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0399/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0400/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0401/A.java
org.eclipse.jdt.core.tests.model/workspace/Converter/test0402/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaProjectSrcTests/.classpath
org.eclipse.jdt.core.tests.model/workspace/JavaProjectSrcTests/.project
org.eclipse.jdt.core.tests.model/workspace/JavaProjectSrcTests/src/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/.classpath
org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/.project
org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/B.java
org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/bin/dummy
org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/lib.jar
org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/p/Y.class
org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/q/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/q/readme.txt
org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/x/readme.txt
org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/x/readme2.txt
org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/x/y/Main.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/.classpath
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/.project
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/AbortCompilation.jar
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/MyJar.jar
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/NotInClasspath/p/Y.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/B.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/CA.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/D.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/E.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/InterfaceImplementors.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/MemberTypeReference/Azz.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/MemberTypeReference/B.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/NoReference/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/O.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/ObjectMemberTypeReference/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PR_1GGNOTF.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/B.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/C.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/D.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/E.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/F.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/G.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/H.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/I.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/J.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/K.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceA.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceB.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceC.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceD.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceE.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceF.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceG.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceH.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceI.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceJ.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/Test.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/TypeReferenceAsSingleNameReference.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/TypeReferenceInArray/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/TypeReferenceInImport/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/B.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/C.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/D.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/W.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a2/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/References.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/Y.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/Z.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/b/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/b/B.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a4/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a5/B.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a6/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a7/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a8/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a9/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b1/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b1/B.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b2/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b2/Y.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b2/Z.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b3/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b4/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b5/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b6/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b7/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b8/Test.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b9/Foo.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c1/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c1/B.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c1/I.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c2/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c2/B.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c3/C.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c4/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/I.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/Y.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/Z.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p2/Z.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p3/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p3/p2/p/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p4/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p5/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p6/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p7/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p8/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p9/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q1/B.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q2/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q3/A$B.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q4/C.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q5/AQ.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q6/CD.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q7/AQ.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q8/EclipseTest.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q9/I.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r2/I.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r2/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r3/A21485.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r4/B21485.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r5/XYZ.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r6/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r6/B.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s1/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s1/Y.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s2/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s2/Z.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s3/A.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/sd/AQ.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/wc/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/wc1/X.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/wc2/Y.java
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/test20631.jar
org.eclipse.jdt.core.tests.model/workspace/JavaSearch/test20631.zip
org.eclipse.jdt.core.tests.model/workspace/Resolve/.classpath
org.eclipse.jdt.core.tests.model/workspace/Resolve/.project
org.eclipse.jdt.core.tests.model/workspace/Resolve/class-folder/ResolveConstructorCallOfMemberType$Inner.class
org.eclipse.jdt.core.tests.model/workspace/Resolve/class-folder/ResolveConstructorCallOfMemberType.class
org.eclipse.jdt.core.tests.model/workspace/Resolve/class-folder/ResolveConstructorCallOfMemberType.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/p3.jar
org.eclipse.jdt.core.tests.model/workspace/Resolve/p3src.zip
org.eclipse.jdt.core.tests.model/workspace/Resolve/p4.jar
org.eclipse.jdt.core.tests.model/workspace/Resolve/p4src.zip
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveArgumentName.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveArrayLength.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveCatchArgumentName.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass1.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass2.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass3.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass4.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass5.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass6.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveConstructor.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveConstructorDeclaration.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveEmptySelectionOnMethod.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveExplicitSuperConstructorCall.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveExplicitThisConstructorCall.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveField.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveFieldDeclaration.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveImport.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveInterface.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveLocalName.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMemberTypeDeclaration1.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMemberTypeDeclaration2.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMessageSendOnBaseType.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMethod.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMethodDeclaration.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMethodWithIncorrectParameter.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolvePackage.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolvePartiallyQualifiedType.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveQualifiedType.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeDeclaration.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeEmptySelection.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeEmptySelection2.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeInComment.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveUnicode.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/SuperClass.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/a/b/ImportedClass.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/p1/X.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/p1/Y.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/src/p2/X.java
org.eclipse.jdt.core.tests.model/workspace/Resolve/zzz.jar
org.eclipse.jdt.core.tests.model/workspace/Resolve/zzzsrc.zip
diff --git a/org.eclipse.jdt.core.tests.builder/.classpath b/org.eclipse.jdt.core.tests.builder/.classpath
deleted file mode 100644
index b7132bc..0000000
--- a/org.eclipse.jdt.core.tests.builder/.classpath
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="/org.junit"/>
- <classpathentry kind="src" path="/org.eclipse.jdt.core"/>
- <classpathentry kind="src" path="/org.eclipse.jdt.core.tests.compiler"/>
- <classpathentry kind="src" path="/org.eclipse.core.resources"/>
- <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
- <classpathentry kind="src" path="/org.eclipse.core.boot"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jdt.core.tests.builder/.cvsignore b/org.eclipse.jdt.core.tests.builder/.cvsignore
deleted file mode 100644
index c5e82d7..0000000
--- a/org.eclipse.jdt.core.tests.builder/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/.project b/org.eclipse.jdt.core.tests.builder/.project
deleted file mode 100644
index 571c831..0000000
--- a/org.eclipse.jdt.core.tests.builder/.project
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.core.tests.builder</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.core.boot</project>
- <project>org.eclipse.core.resources</project>
- <project>org.eclipse.core.runtime</project>
- <project>org.eclipse.jdt.core</project>
- <project>org.eclipse.jdt.core.tests.compiler</project>
- <project>org.junit</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.jdt.core.tests.builder/about.html b/org.eclipse.jdt.core.tests.builder/about.html
deleted file mode 100644
index 21aa90c..0000000
--- a/org.eclipse.jdt.core.tests.builder/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>20th June, 2002</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
-For purposes of the CPL, "Program" will mean the Content.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.</p>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/build.properties b/org.eclipse.jdt.core.tests.builder/build.properties
deleted file mode 100644
index c5def11..0000000
--- a/org.eclipse.jdt.core.tests.builder/build.properties
+++ /dev/null
@@ -1 +0,0 @@
-source.jdtcoretestsbuilder.jar = src
diff --git a/org.eclipse.jdt.core.tests.builder/plugin.xml b/org.eclipse.jdt.core.tests.builder/plugin.xml
deleted file mode 100644
index ecff8fa..0000000
--- a/org.eclipse.jdt.core.tests.builder/plugin.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<plugin
- id="org.eclipse.jdt.core.tests.builder"
- name="Java Builder Tests"
- version="2.1.0">
-
- <runtime>
- <library name="jdtcoretestsbuilder.jar"/>
- </runtime>
- <requires>
- <import plugin="org.junit"/>
- <import plugin="org.eclipse.jdt.core"/>
- <import plugin="org.eclipse.jdt.core.tests.compiler"/>
- <import plugin="org.eclipse.core.resources"/>
- </requires>
-
-
-</plugin>
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractMethodTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractMethodTests.java
deleted file mode 100644
index 4487ae3..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractMethodTests.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import junit.framework.*;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.tests.util.Util;
-
-public class AbstractMethodTests extends Tests {
- private static String[] EXCLUDED_TESTS = {};
-
- public AbstractMethodTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new FilteredTestSuite(EXCLUDED_TESTS);
- suite.addTestSuite(AbstractMethodTests.class);
- return suite;
- }
-
- public void test001() {
- //----------------------------
- // Step 1
- //----------------------------
- //----------------------------
- // Project1
- //----------------------------
- IPath project1Path = env.addProject("Project1");
- env.addExternalJar(project1Path, Util.getJavaClassLib());
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(project1Path, "");
-
- IPath root1 = env.addPackageFragmentRoot(project1Path, "src");
- env.setOutputFolder(project1Path, "bin");
-
- env.addClass(root1, "p1", "IX",
- "package p1;\n" +
- "public interface IX {\n" +
- " public abstract void foo(IX x);\n" +
- "}\n"
- );
-
- IPath classX = env.addClass(root1, "p2", "X",
- "package p2;\n" +
- "import p1.*;\n" +
- "public abstract class X implements IX {\n" +
- " public void foo(IX x){}\n" +
- "}\n"
- );
-
- //----------------------------
- // Project2
- //----------------------------
- IPath project2Path = env.addProject("Project2");
- env.addExternalJar(project2Path, Util.getJavaClassLib());
- env.addRequiredProject(project2Path, project1Path);
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(project2Path, "");
-
- IPath root2 = env.addPackageFragmentRoot(project2Path, "src");
- env.setOutputFolder(project2Path, "bin");
-
- IPath classY =env.addClass(root2, "p3", "Y",
- "package p3;\n" +
- "import p2.*;\n" +
- "public class Y extends X{\n" +
- "}\n"
- );
-
- fullBuild();
- expectingNoProblems();
-
- //----------------------------
- // Step 2
- //----------------------------
- env.addClass(root1, "p2", "X",
- "package p2;\n" +
- "import p1.*;\n" +
- "public abstract class X implements IX {\n" +
- " public void foo(I__X x){}\n" +
- "}\n"
- );
-
- incrementalBuild();
- expectingOnlySpecificProblemFor(classX, new Problem("X.foo(I__X)", "I__X cannot be resolved (or is not a valid type) for the argument x of the method foo", classX));
- expectingOnlySpecificProblemFor(classY, new Problem("Y", "Class must implement the inherited abstract method X.foo(IX)", classY));
-
- //----------------------------
- // Step 3
- //----------------------------
- env.addClass(root1, "p2", "X",
- "package p2;\n" +
- "import p1.*;\n" +
- "public abstract class X implements IX {\n" +
- " public void foo(IX x){}\n" +
- "}\n"
- );
-
- incrementalBuild();
- expectingNoProblems();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Assert.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Assert.java
deleted file mode 100644
index bf32a5a..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Assert.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-/**
- * <code>Assert</code> is useful for for embedding runtime sanity checks
- * in code.
- * The predicate methods all test a condition and throw some
- * type of unchecked exception if the condition does not hold.
- * <p>
- * Assertion failure exceptions, like most runtime exceptions, are
- * thrown when something is misbehaving. Assertion failures are invariably
- * unspecified behavior; consequently, clients should never rely on
- * these being thrown (and certainly should not being catching them
- * specifically).
- * </p>
- */
-public final class Assert {
-/* This class is not intended to be instantiated. */
-private Assert() {
-}
-/** Asserts that an argument is legal. If the given boolean is
- * not <code>true</code>, an <code>IllegalArgumentException</code>
- * is thrown.
- *
- * @param expression the outcode of the check
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- * @exception IllegalArgumentException if the legality test failed
- */
-public static boolean isLegal(boolean expression) {
- return isLegal(expression, "");
-}
-/** Asserts that an argument is legal. If the given boolean is
- * not <code>true</code>, an <code>IllegalArgumentException</code>
- * is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param expression the outcode of the check
- * @param message the message to include in the exception
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- * @exception IllegalArgumentException if the legality test failed
- */
-public static boolean isLegal(boolean expression, String message) {
- if (!expression)
- throw new IllegalArgumentException(message);
- return expression;
-}
-/** Asserts that the given object is not <code>null</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- *
- * @param object the value to test
- * @exception IllegalArgumentException if the object is <code>null</code>
- */
-public static void isNotNull(Object object) {
- isNotNull(object, "");
-}
-/** Asserts that the given object is not <code>null</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param object the value to test
- * @param message the message to include in the exception
- * @exception IllegalArgumentException if the object is <code>null</code>
- */
-public static void isNotNull(Object object, String message) {
- if (object == null)
- throw new AssertionFailedException("null argument;" + message);
-}
-/** Asserts that the given boolean is <code>true</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- *
- * @param expression the outcode of the check
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- */
-public static boolean isTrue(boolean expression) {
- return isTrue(expression, "");
-}
-/** Asserts that the given boolean is <code>true</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param expression the outcode of the check
- * @param message the message to include in the exception
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- */
-public static boolean isTrue(boolean expression, String message) {
- if (!expression)
- throw new AssertionFailedException("assertion failed; "+message);
- return expression;
-}
-}
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AssertionFailedException.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AssertionFailedException.java
deleted file mode 100644
index 8a35cbd..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AssertionFailedException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-/**
- * <code>AssertionFailedException</code> is a runtime exception thrown
- * by some of the methods in <code>Assert</code>.
- * <p>
- * This class is not declared public to prevent some misuses; programs that catch
- * or otherwise depend on assertion failures are susceptible to unexpected
- * breakage when assertions in the code are added or removed.
- * </p>
- */
-/* package */
-class AssertionFailedException extends RuntimeException {
-/** Constructs a new exception.
- */
-public AssertionFailedException() {
-}
-/** Constructs a new exception with the given message.
- */
-public AssertionFailedException(String detail) {
- super(detail);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java
deleted file mode 100644
index a117cbd..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BasicBuildTests.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import junit.framework.*;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.tests.util.Util;
-
-/**
- * Basic tests of the image builder.
- */
-public class BasicBuildTests extends Tests {
- public BasicBuildTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(BasicBuildTests.class);
- }
-
- public void testBuild() {
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
- fullBuild(projectPath);
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- env.addClass(root, "p1", "Hello",
- "package p1;\n"+
- "public class Hello {\n"+
- " public static void main(String args[]) {\n"+
- " System.out.println(\"Hello world\");\n"+
- " }\n"+
- "}\n"
- );
-
- incrementalBuild(projectPath);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ClasspathTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ClasspathTests.java
deleted file mode 100644
index bb9a07f..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ClasspathTests.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import junit.framework.*;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.tests.util.Util;
-
-import java.util.*;
-
-public class ClasspathTests extends Tests {
- private static String[] EXCLUDED_TESTS = {};
-
- public ClasspathTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new FilteredTestSuite(EXCLUDED_TESTS);
- suite.addTestSuite(ClasspathTests.class);
- return suite;
- }
-
- public void testClosedProject() {
- IPath project1Path = env.addProject("CP1");
- env.addExternalJar(project1Path, Util.getJavaClassLib());
- IPath jarPath = env.addInternalJar(project1Path, "temp.jar", new byte[] {0});
-
- IPath project2Path = env.addProject("CP2");
- env.addExternalJar(project2Path, Util.getJavaClassLib());
- env.addRequiredProject(project2Path, project1Path);
-
- IPath project3Path = env.addProject("CP3");
- env.addExternalJar(project3Path, Util.getJavaClassLib());
- env.addExternalJar(project3Path, jarPath.toString());
-
- fullBuild();
- expectingNoProblems();
-
- //----------------------------
- // Step 2
- //----------------------------
- env.closeProject(project1Path);
-
- incrementalBuild();
- expectingOnlyProblemsFor(new IPath[] {project2Path, project3Path});
- expectingOnlySpecificProblemsFor(project2Path,
- new Problem[] {
- new Problem("", "The project was not built due to classpath errors (incomplete or involved in cycle).", project2Path),
- new Problem("Build path", "Missing required Java project: CP1.", project2Path)
- }
- );
- expectingOnlySpecificProblemsFor(project3Path,
- new Problem[] {
- new Problem("", "The project was not built due to classpath errors (incomplete or involved in cycle).", project3Path),
- new Problem("Build path", "Missing required library: /CP1/temp.jar.", project3Path)
- }
- );
-
- env.openProject(project1Path);
- incrementalBuild();
- expectingNoProblems();
-
- //----------------------------
- // Step 3
- //----------------------------
- Hashtable options = JavaCore.getOptions();
- options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.IGNORE);
- JavaCore.setOptions(options);
- env.closeProject(project1Path);
-
- incrementalBuild();
- expectingOnlyProblemsFor(new IPath[] {project2Path, project3Path});
- expectingOnlySpecificProblemFor(project2Path,
- new Problem("Build path", "Missing required Java project: CP1.", project2Path)
- );
- expectingOnlySpecificProblemFor(project3Path,
- new Problem("Build path", "Missing required library: /CP1/temp.jar.", project3Path)
- );
-
- env.openProject(project1Path);
- incrementalBuild();
- expectingNoProblems();
-
- options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.ABORT);
- JavaCore.setOptions(options);
- }
-
- public void testMissingProject() {
- IPath project1Path = env.addProject("MP1");
- env.addExternalJar(project1Path, Util.getJavaClassLib());
-
- IPath project2Path = env.addProject("MP2");
- env.addExternalJar(project2Path, Util.getJavaClassLib());
- env.addRequiredProject(project2Path, project1Path);
-
- fullBuild();
- expectingNoProblems();
-
- //----------------------------
- // Step 2
- //----------------------------
- env.removeProject(project1Path);
-
- incrementalBuild();
- expectingOnlyProblemsFor(project2Path);
- expectingOnlySpecificProblemsFor(project2Path,
- new Problem[] {
- new Problem("", "The project was not built due to classpath errors (incomplete or involved in cycle).", project2Path),
- new Problem("Build path", "Missing required Java project: MP1.", project2Path)
- }
- );
-
- project1Path = env.addProject("MP1");
- env.addExternalJar(project1Path, Util.getJavaClassLib());
-
- incrementalBuild();
- expectingNoProblems();
-
- //----------------------------
- // Step 3
- //----------------------------
- Hashtable options = JavaCore.getOptions();
- options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.IGNORE);
- JavaCore.setOptions(options);
- env.removeProject(project1Path);
-
- incrementalBuild();
- expectingOnlyProblemsFor(project2Path);
- expectingOnlySpecificProblemFor(project2Path,
- new Problem("Build path", "Missing required Java project: MP1.", project2Path)
- );
-
- project1Path = env.addProject("MP1");
- env.addExternalJar(project1Path, Util.getJavaClassLib());
-
- incrementalBuild();
- expectingNoProblems();
-
- options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.ABORT);
- JavaCore.setOptions(options);
- }
-
- public void testMissingLibrary() {
- IPath projectPath = env.addProject("Project");
- env.removePackageFragmentRoot(projectPath, "");
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- IPath bin = env.setOutputFolder(projectPath, "bin");
- IPath classTest1 = env.addClass(root, "p1", "Test1",
- "package p1;\n"+
- "public class Test1 {}"
- );
- env.addClass(root, "p2", "Test2",
- "package p2;\n"+
- "public class Test2 {}"
- );
- env.addClass(root, "p2", "Test3",
- "package p2;\n"+
- "public class Test3 {}"
- );
-
- fullBuild();
- expectingOnlyProblemsFor(new IPath[] {projectPath, classTest1});
- expectingOnlySpecificProblemsFor(projectPath,
- new Problem[] {
- new Problem("", "The project was not built since its classpath is incomplete. Can not find the class file for java.lang.Object. Fix the classpath then try rebuilding this project", projectPath),
- new Problem("p1", "This compilation unit indirectly references the missing type java.lang.Object (typically some required class file is referencing a type outside the classpath)", classTest1)
- }
- );
-
- //----------------------------
- // Step 2
- //----------------------------
- env.addExternalJar(projectPath, Util.getJavaClassLib());
-
- incrementalBuild();
- expectingNoProblems();
- expectingPresenceOf(new IPath[]{
- bin.append("p1").append("Test1.class"),
- bin.append("p2").append("Test2.class"),
- bin.append("p2").append("Test3.class")
- });
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/CompilationUnitLocationTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/CompilationUnitLocationTests.java
deleted file mode 100644
index e061453..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/CompilationUnitLocationTests.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import junit.framework.*;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.tests.util.Util;
-
-public class CompilationUnitLocationTests extends Tests {
- private static String[] EXCLUDED_TESTS = {
- "CompilationUnitLocationTests", "testWrongCompilationUnitLocation"
- };
-
- public CompilationUnitLocationTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new FilteredTestSuite(EXCLUDED_TESTS);
- suite.addTestSuite(CompilationUnitLocationTests.class);
- return suite;
- }
-
- /**
- * Bugs 6461
- */
- public void testWrongCompilationUnitLocation() {
- //----------------------------
- // Step 1
- //----------------------------
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
- env.removePackageFragmentRoot(projectPath, "");
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- IPath bin = env.setOutputFolder(projectPath, "bin");
- IPath x = env.addClass(root, "", "X",
- "public class X {\n"+
- "}\n"
- );
-
-
- fullBuild();
- expectingNoProblems();
- expectingPresenceOf(bin.append("X.class"));
-
- //----------------------------
- // Step 2
- //----------------------------
- env.addClass(root, "", "X",
- "package p1;\n"+
- "public class X {\n"+
- "}\n"
- );
-
- incrementalBuild();
- expectingProblemsFor(x);
- expectingNoPresenceOf(bin.append("X.class"));
- }
-}
-
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyCompilerRequestor.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyCompilerRequestor.java
deleted file mode 100644
index 2f261fb..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyCompilerRequestor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import java.util.Vector;
-import org.eclipse.jdt.internal.compiler.ClassFile;
-import org.eclipse.jdt.internal.compiler.CompilationResult;
-import org.eclipse.jdt.internal.compiler.IDebugRequestor;
-import org.eclipse.jdt.internal.core.Util;
-
-public class EfficiencyCompilerRequestor implements IDebugRequestor {
- private boolean isActive = false;
-
- private Vector compiledClasses = new Vector(10);
-
- public void acceptDebugResult(CompilationResult result){
- ClassFile[] classFiles = result.getClassFiles();
- Util.sort(classFiles, new Util.Comparer() {
- public int compare(Object a, Object b) {
- String aName = new String(((ClassFile)a).fileName());
- String bName = new String(((ClassFile)b).fileName());
- return aName.compareTo(bName);
- }
- });
- for (int i = 0; i < classFiles.length; i++) {
- String className = new String(classFiles[i].fileName());
- compiledClasses.addElement(className.replace('/', '.'));
- }
- }
-
- String[] getCompiledClasses(){
- return (String [])compiledClasses.toArray(new String[0]);
- }
-
- public void clearResult(){
- compiledClasses.clear();
- }
-
- public void reset() {
- }
-
- public void activate() {
- isActive = true;
- }
-
- public void deactivate() {
- isActive = false;
- }
-
- public boolean isActive() {
- return isActive;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyTests.java
deleted file mode 100644
index 1583ed5..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/EfficiencyTests.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import junit.framework.*;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.tests.util.Util;
-
-/**
- * Basic efficiency tests of the image builder.
- */
-public class EfficiencyTests extends Tests {
- public EfficiencyTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(EfficiencyTests.class);
- }
-
- public void testEfficiency() {
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
- fullBuild(projectPath);
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- env.addClass(root, "p1", "Indicted",
- "package p1;\n"+
- "public abstract class Indicted {\n"+
- "}\n"
- );
-
- env.addClass(root, "p2", "Collaborator",
- "package p2;\n"+
- "import p1.*;\n"+
- "public class Collaborator extends Indicted{\n"+
- "}\n"
- );
-
- fullBuild(projectPath);
-
- env.addClass(root, "p1", "Indicted",
- "package p1;\n"+
- "public abstract class Indicted {\n"+
- " public abstract void foo();\n"+
- "}\n"
- );
-
- incrementalBuild(projectPath);
-
- expectingCompiledClasses(new String[]{"p2.Collaborator", "p1.Indicted"});
- expectingCompilingOrder(new String[]{"p1.Indicted", "p2.Collaborator"});
- }
-
- public void testMethodAddition() {
-
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
- fullBuild(projectPath);
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- env.addClass(root, "p1", "X",
- "package p1;\n"+
- "public class X {\n"+
- " void foo() { \n" +
- " }\n" +
- "}\n"
- );
-
- env.addClass(root, "p2", "Y",
- "package p2;\n"+
- "import p1.*;\n"+
- "public class Y extends X{\n"+
- "}\n"
- );
-
- env.addClass(root, "p3", "Z",
- "package p2;\n"+
- "import p1.*;\n"+
- "public class Z{\n"+
- "}\n"
- );
-
- fullBuild(projectPath);
-
- env.addClass(root, "p1", "X",
- "package p1;\n"+
- "public class X {\n"+
- " void bar(){} \n" +
- " void foo() { \n" +
- " }; \n" +
- " }\n" +
- "}\n"
- );
-
- incrementalBuild(projectPath);
-
- expectingCompiledClasses(new String[]{"p1.X", "p2.Y"});
- expectingCompilingOrder(new String[]{"p1.X", "p2.Y" });
- }
-
- public void testLocalTypeAddition() {
-
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
- fullBuild(projectPath);
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- env.addClass(root, "p1", "X",
- "package p1;\n"+
- "public class X {\n"+
- " void foo() { \n" +
- " }\n" +
- "}\n"
- );
-
- env.addClass(root, "p2", "Y",
- "package p2;\n"+
- "import p1.*;\n"+
- "public class Y extends X{\n"+
- "}\n"
- );
-
- env.addClass(root, "p3", "Z",
- "package p2;\n"+
- "import p1.*;\n"+
- "public class Z{\n"+
- "}\n"
- );
-
- fullBuild(projectPath);
-
- env.addClass(root, "p1", "X",
- "package p1;\n"+
- "public class X {\n"+
- " void foo() { \n" +
- " new Object(){ \n" +
- " }; \n" +
- " }\n" +
- "}\n"
- );
-
- incrementalBuild(projectPath);
-
- expectingCompiledClasses(new String[]{"p1.X", "p1.X$1"});
- expectingCompilingOrder(new String[]{"p1.X", "p1.X$1" });
- }
-
- public void testLocalTypeAddition2() {
-
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
- fullBuild(projectPath);
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- env.addClass(root, "p1", "X",
- "package p1;\n"+
- "public class X {\n"+
- " void foo() { \n" +
- " new X(){ \n" +
- " void bar(){} \n" +
- " }; \n" +
- " }\n" +
- "}\n"
- );
-
- env.addClass(root, "p2", "Y",
- "package p2;\n"+
- "import p1.*;\n"+
- "public class Y extends X{\n"+
- "}\n"
- );
-
- env.addClass(root, "p3", "Z",
- "package p2;\n"+
- "import p1.*;\n"+
- "public class Z{\n"+
- "}\n"
- );
-
- fullBuild(projectPath);
-
- env.addClass(root, "p1", "X",
- "package p1;\n"+
- "public class X {\n"+
- " void foo() { \n" +
- " new Object(){ \n" +
- " }; \n" +
- " new X(){ \n" +
- " void bar(){} \n" +
- " }; \n" +
- " }\n" +
- "}\n"
- );
-
- incrementalBuild(projectPath);
-
- expectingCompiledClasses(new String[]{"p1.X", "p1.X$1", "p1.X$2"});
- expectingCompilingOrder(new String[]{"p1.X", "p1.X$1", "p1.X$2" });
- }
-
- public void testLocalTypeRemoval() {
-
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
- fullBuild(projectPath);
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- env.addClass(root, "p1", "X",
- "package p1;\n"+
- "public class X {\n"+
- " void foo() { \n" +
- " new Object(){ \n" +
- " }; \n" +
- " }\n" +
- "}\n"
- );
-
- env.addClass(root, "p2", "Y",
- "package p2;\n"+
- "import p1.*;\n"+
- "public class Y extends X{\n"+
- "}\n"
- );
-
- env.addClass(root, "p3", "Z",
- "package p2;\n"+
- "import p1.*;\n"+
- "public class Z{\n"+
- "}\n"
- );
-
- fullBuild(projectPath);
-
- env.addClass(root, "p1", "X",
- "package p1;\n"+
- "public class X {\n"+
- " void foo() { \n" +
- " }\n" +
- "}\n"
- );
-
- incrementalBuild(projectPath);
-
- expectingCompiledClasses(new String[]{"p1.X"});
- expectingCompilingOrder(new String[]{"p1.X" });
- }
-
- public void testLocalTypeRemoval2() {
-
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
- fullBuild(projectPath);
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- env.addClass(root, "p1", "X",
- "package p1;\n"+
- "public class X {\n"+
- " void foo() { \n" +
- " new Object(){ \n" +
- " }; \n" +
- " new X(){ \n" +
- " void bar(){} \n" +
- " }; \n" +
- " }\n" +
- "}\n"
- );
-
- env.addClass(root, "p2", "Y",
- "package p2;\n"+
- "import p1.*;\n"+
- "public class Y extends X{\n"+
- "}\n"
- );
-
- env.addClass(root, "p3", "Z",
- "package p2;\n"+
- "import p1.*;\n"+
- "public class Z{\n"+
- "}\n"
- );
-
- fullBuild(projectPath);
-
- env.addClass(root, "p1", "X",
- "package p1;\n"+
- "public class X {\n"+
- " void foo() { \n" +
- " new X(){ \n" +
- " void bar(){} \n" +
- " }; \n" +
- " }\n" +
- "}\n"
- );
-
- incrementalBuild(projectPath);
-
- expectingCompiledClasses(new String[]{"p1.X", "p1.X$1"});
- expectingCompilingOrder(new String[]{"p1.X", "p1.X$1" });
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ErrorsTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ErrorsTests.java
deleted file mode 100644
index 47a7dfa..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ErrorsTests.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import junit.framework.*;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.tests.util.Util;
-
-
-/**
- * Basic errors tests of the image builder.
- */
-public class ErrorsTests extends Tests {
- public ErrorsTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(ErrorsTests.class);
- }
-
- public void testErrors() {
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
- fullBuild(projectPath);
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath,"");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- env.addClass(root, "p1", "Indicted",
- "package p1;\n"+
- "public abstract class Indicted {\n"+
- "}\n"
- );
-
- IPath collaboratorPath = env.addClass(root, "p2", "Collaborator",
- "package p2;\n"+
- "import p1.*;\n"+
- "public class Collaborator extends Indicted{\n"+
- "}\n"
- );
-
- fullBuild(projectPath);
- expectingNoProblems();
-
- env.addClass(root, "p1", "Indicted",
- "package p1;\n"+
- "public abstract class Indicted {\n"+
- " public abstract void foo();\n"+
- "}\n"
- );
-
- incrementalBuild(projectPath);
-
- expectingOnlyProblemsFor(collaboratorPath);
- expectingOnlySpecificProblemFor(collaboratorPath, new Problem("Collaborator", "Class must implement the inherited abstract method Indicted.foo()", collaboratorPath));
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ExecutionTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ExecutionTests.java
deleted file mode 100644
index cbb62a1..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/ExecutionTests.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import junit.framework.*;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.tests.util.Util;
-
-/**
- * Basic execution tests of the image builder.
- */
-public class ExecutionTests extends Tests {
- public ExecutionTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(ExecutionTests.class);
- }
-
- public void testSuccess() {
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
- fullBuild(projectPath);
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- env.addClass(root, "p1", "Hello",
- "package p1;\n"+
- "public class Hello {\n"+
- " public static void main(String args[]) {\n"+
- " System.out.println(\"Hello world\");\n"+
- " }\n"+
- "}\n"
- );
-
- incrementalBuild(projectPath);
- expectingNoProblems();
- executeClass(projectPath, "p1.Hello", "Hello world\r\n", "");
- }
-
- public void testFailure() {
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
- fullBuild(projectPath);
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- IPath helloPath = env.addClass(root, "p1", "Hello",
- "package p1;\n"+
- "public class Hello {\n"+
- " public static void main(String args[]) {\n"+
- " System.out.println(\"Hello world\")\n"+
- " }\n"+
- "}\n"
- );
- // public static void main(String args[]) {
- // System.out.println("Hello world") <-- missing ";"
- // }
-
- incrementalBuild(projectPath);
- expectingOnlyProblemsFor(helloPath);
- executeClass(projectPath, "p1.Hello", "",
- "java.lang.Error: Unresolved compilation problem: \n" +
- " Syntax error on token \"}\", \"++\", \"--\" expected\n"
- );
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/FilteredTestSuite.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/FilteredTestSuite.java
deleted file mode 100644
index 6a88948..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/FilteredTestSuite.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import junit.framework.*;
-public class FilteredTestSuite extends TestSuite {
- public static boolean EXPERT = false;
- String[] excludedTests = null;
-/**
- * Creates a new test suite by excluding the given tests
- * from the given test suite if Tests.EXPERT is false.
- */
-public FilteredTestSuite(String[] excludedTests) {
- this.excludedTests = excludedTests;
- if(!EXPERT) {
- for (int i = 0; i < excludedTests.length; i+=2) {
- System.out.println("excluded : "+excludedTests[i]+"#"+excludedTests[i+1]);
- }
- }
-}
-/**
- * Adds a test to the suite.
- */
-public void addTest(Test test) {
- if(EXPERT){
- super.addTest(test);
- } else {
- if (test instanceof TestCase) {
- if (!isExcluded((TestCase)test)) {
- super.addTest(test);
- }
- } else if (test instanceof TestSuite) {
- java.util.Enumeration enum = ((TestSuite)test).tests();
- while (enum.hasMoreElements()) {
- this.addTest((Test)enum.nextElement());
- }
- }
- }
-}
-/**
- * Returns whether the test is excluded.
- */
-public boolean isExcluded(TestCase test) {
- if (this.excludedTests == null) {
- return false;
- }
- for (int i = 0; i < this.excludedTests.length; i += 2) {
- String className = this.excludedTests[i];
- String methodName = this.excludedTests[i+1];
- if (test.getName().equals(methodName) &&
- test.getClass().getName().endsWith(className)) {
- return true;
- }
- }
- return false;
-}
-}
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java
deleted file mode 100644
index 6cb60ab..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/IncrementalTests.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.tests.util.Util;
-
-public class IncrementalTests extends Tests {
-
- public IncrementalTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(IncrementalTests.class);
- }
-
- /*
- * http://bugs.eclipse.org/bugs/show_bug.cgi?id=17329
- */
- public void testRenameMainType() {
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- /* A.java */
- IPath pathToA = env.addClass(root, "p", "A",
- "package p; \n"+
- "public class A {}");
-
- /* B.java */
- IPath pathToB = env.addClass(root, "p", "B",
- "package p; \n"+
- "public class B extends A {}");
-
- /* C.java */
- IPath pathToC = env.addClass(root, "p", "C",
- "package p; \n"+
- "public class C extends B {}");
-
- fullBuild(projectPath);
- expectingNoProblems();
-
- /* Touch both A and C, removing A main type */
- pathToA = env.addClass(root, "p", "A",
- "package p; \n"+
- "public class _A {}");
-
- pathToC = env.addClass(root, "p", "C",
- "package p; \n"+
- "public class C extends B { }");
-
- incrementalBuild(projectPath);
- expectingProblemsFor(new IPath[]{ pathToA, pathToB, pathToC });
- expectingSpecificProblemFor(pathToA, new Problem("_A", "The public type _A must be defined in its own file", pathToA));
- expectingSpecificProblemFor(pathToB, new Problem("B", "A cannot be resolved or is not a valid superclass", pathToB));
- expectingSpecificProblemFor(pathToC, new Problem("C", "The hierarchy of the type C is inconsistent", pathToC));
-
- /* Touch both A and C, removing A main type */
- pathToA = env.addClass(root, "p", "A",
- "package p; \n"+
- "public class A {}");
-
- incrementalBuild(projectPath);
- expectingNoProblems();
- }
-
- /*
- * http://bugs.eclipse.org/bugs/show_bug.cgi?id=17807
- * case 1
- */
- public void testRemoveSecondaryType() {
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- IPath pathToAA = env.addClass(root, "p", "AA",
- "package p; \n"+
- "public class AA {} \n"+
- "class AZ {}");
-
- IPath pathToAB = env.addClass(root, "p", "AB",
- "package p; \n"+
- "public class AB extends AZ {}");
-
- IPath pathToBB = env.addClass(root, "p", "BB",
- "package p; \n"+
- "public class BB { \n"+
- " void foo(){ \n" +
- " System.out.println(new AB()); \n" +
- " System.out.println(new ZA()); \n" +
- " } \n" +
- "}");
-
- IPath pathToZZ = env.addClass(root, "p", "ZZ",
- "package p; \n"+
- "public class ZZ {} \n"+
- "class ZA {}");
-
- fullBuild(projectPath);
- expectingNoProblems();
-
- /* Remove AZ and touch BB */
- pathToAA = env.addClass(root, "p", "AA",
- "package p; \n"+
- "public class AA {}");
-
- pathToBB = env.addClass(root, "p", "BB",
- "package p; \n"+
- "public class BB { \n"+
- " void foo() { \n" +
- " System.out.println(new AB()); \n" +
- " System.out.println(new ZA()); \n" +
- " } \n" +
- "}");
-
- incrementalBuild(projectPath);
- expectingProblemsFor(new IPath[]{ pathToAB });
- expectingSpecificProblemFor(pathToAB, new Problem("AB", "AZ cannot be resolved or is not a valid superclass", pathToAB));
-
- pathToAA = env.addClass(root, "p", "AA",
- "package p; \n"+
- "public class AA {} \n"+
- "class AZ {}");
-
- incrementalBuild(projectPath);
- expectingNoProblems();
- }
-
- /*
- * http://bugs.eclipse.org/bugs/show_bug.cgi?id=17807
- * case 2
- */
- public void testRemoveSecondaryType2() {
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- IPath pathToAA = env.addClass(root, "p", "AA",
- "package p; \n"+
- "public class AA {} \n"+
- "class AZ {}");
-
- IPath pathToAB = env.addClass(root, "p", "AB",
- "package p; \n"+
- "public class AB extends AZ {}");
-
- IPath pathToBB = env.addClass(root, "p", "BB",
- "package p; \n"+
- "public class BB { \n"+
- " void foo(){ \n" +
- " System.out.println(new AB()); \n" +
- " System.out.println(new ZA()); \n" +
- " } \n" +
- "}");
-
- IPath pathToZZ = env.addClass(root, "p", "ZZ",
- "package p; \n"+
- "public class ZZ {} \n"+
- "class ZA {}");
-
- fullBuild(projectPath);
- expectingNoProblems();
-
- /* Remove ZA and touch BB */
- pathToZZ = env.addClass(root, "p", "ZZ",
- "package p; \n"+
- "public class ZZ {}");
-
- pathToBB = env.addClass(root, "p", "BB",
- "package p; \n"+
- "public class BB { \n"+
- " void foo() { \n" +
- " System.out.println(new AB()); \n" +
- " System.out.println(new ZA()); \n" +
- " } \n" +
- "}");
-
- incrementalBuild(projectPath);
- expectingProblemsFor(new IPath[]{ pathToBB });
- expectingSpecificProblemFor(pathToBB, new Problem("BB.foo()", "ZA cannot be resolved or is not a type", pathToBB));
-
- pathToZZ = env.addClass(root, "p", "ZZ",
- "package p; \n"+
- "public class ZZ {} \n"+
- "class ZA {}");
-
- incrementalBuild(projectPath);
- expectingNoProblems();
- }
-
- public void testMoveSecondaryType() {
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- env.addClass(root, "p", "AA",
- "package p; \n"+
- "public class AA {} \n"+
- "class AZ {}");
-
- env.addClass(root, "p", "AB",
- "package p; \n"+
- "public class AB extends AZ {}");
-
- env.addClass(root, "p", "ZZ",
- "package p; \n"+
- "public class ZZ {}");
-
- fullBuild(projectPath);
- expectingNoProblems();
-
- /* Move AZ from AA to ZZ */
- env.addClass(root, "p", "AA",
- "package p; \n"+
- "public class AA {}");
-
- env.addClass(root, "p", "ZZ",
- "package p; \n"+
- "public class ZZ {} \n"+
- "class AZ {}");
-
- incrementalBuild(projectPath);
- expectingNoProblems();
-
- /* Move AZ from ZZ to AA */
- env.addClass(root, "p", "AA",
- "package p; \n"+
- "public class AA {} \n"+
- "class AZ {}");
-
- env.addClass(root, "p", "ZZ",
- "package p; \n"+
- "public class ZZ {}");
-
- incrementalBuild(projectPath);
- expectingNoProblems();
- }
-
- public void testMoveMemberType() {
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- IPath pathToAA = env.addClass(root, "p", "AA",
- "package p; \n"+
- "public class AA {} \n"+
- "class AZ {static class M{}}");
-
- IPath pathToAB = env.addClass(root, "p", "AB",
- "package p; \n"+
- "import p.AZ.*; \n"+
- "import p.ZA.*; \n"+
- "public class AB extends M {}");
-
- IPath pathToZZ = env.addClass(root, "p", "ZZ",
- "package p; \n"+
- "public class ZZ {} \n"+
- "class ZA {}");
-
- fullBuild(projectPath);
- expectingNoProblems();
-
- /* Move M from AA to ZZ */
- pathToAA = env.addClass(root, "p", "AA",
- "package p; \n"+
- "public class AA {} \n"+
- "class AZ {}");
-
- pathToZZ = env.addClass(root, "p", "ZZ",
- "package p; \n"+
- "public class ZZ {} \n"+
- "class ZA {static class M{}}");
-
- incrementalBuild(projectPath);
- expectingNoProblems();
-
- /* Move M from ZZ to AA */
- pathToAA = env.addClass(root, "p", "AA",
- "package p; \n"+
- "public class AA {} \n"+
- "class AZ {static class M{}}");
-
- pathToZZ = env.addClass(root, "p", "ZZ",
- "package p; \n"+
- "public class ZZ {} \n"+
- "class ZA {}");
-
- incrementalBuild(projectPath);
- expectingNoProblems();
- }
-
- public void testMemberTypeFromClassFile() {
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- env.setOutputFolder(projectPath, "bin");
-
- env.addClass(root, "p", "A",
- "package p; \n"+
- "public class A extends Z {M[] m;}");
-
- env.addClass(root, "p", "B",
- "package p; \n"+
- "public class B {A a; E e; \n"+
- "void foo() { System.out.println(a.m); }}");
-
- env.addClass(root, "p", "E",
- "package p; \n"+
- "public class E extends Z { \n"+
- "void foo() { System.out.println(new M()); }}");
-
- env.addClass(root, "p", "Z",
- "package p; \n"+
- "public class Z {static class M {}}");
-
- fullBuild(projectPath);
- expectingNoProblems();
-
- env.addClass(root, "p", "B",
- "package p; \n"+
- "public class B {A a; E e; \n"+
- "void foo( ) { System.out.println(a.m); }}");
-
- env.addClass(root, "p", "E",
- "package p; \n"+
- "public class E extends Z { \n"+
- "void foo( ) { System.out.println(new M()); }}");
-
- env.addClass(root, "p", "Z",
- "package p; \n"+
- "public class Z { static class M {} }");
-
- int previous = org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE;
- org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE = 1; // reduce the lot size
- incrementalBuild(projectPath);
- org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE = previous;
- expectingNoProblems();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/JCLTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/JCLTests.java
deleted file mode 100644
index 093e712..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/JCLTests.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import junit.framework.*;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Basic tests of the image builder.
- */
-public class JCLTests extends Tests {
- private static String[] EXCLUDED_TESTS = {
- "JCLTests", "testNewJCL"
- };
-
- public JCLTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new FilteredTestSuite(EXCLUDED_TESTS);
- suite.addTestSuite(JCLTests.class);
- return suite;
- }
-
-
- public void testNewJCL() {
- //----------------------------
- // Step 1
- //----------------------------
- IPath projectPath = env.addProject("Project");
-
- IPath root = env.getPackageFragmentRootPath(projectPath, "");
- fullBuild();
- expectingNoProblems();
-
- //----------------------------
- // Step 2
- //----------------------------
- IPath object = env.addClass(root, "java.lang", "Object",
- "package java.lang;\n" +
- "public class Object {\n"+
- "}\n"
- );
-
-
- incrementalBuild();
- expectingSpecificProblemFor(object, new Problem("java.lang", "This compilation unit indirectly references the missing type java.lang.Throwable (typically some required class file is referencing a type outside the classpath)", object));
-
- //----------------------------
- // Step 3
- //----------------------------
- IPath throwable = env.addClass(root, "java.lang", "Throwable",
- "package java.lang;\n" +
- "public class Throwable {\n"+
- "}\n"
- );
-
-
- incrementalBuild();
- expectingSpecificProblemFor(object, new Problem("java.lang", "This compilation unit indirectly references the missing type java.lang.RuntimeException (typically some required class file is referencing a type outside the classpath)", object));
- expectingSpecificProblemFor(throwable, new Problem("java.lang", "This compilation unit indirectly references the missing type java.lang.RuntimeException (typically some required class file is referencing a type outside the classpath)", throwable));
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java
deleted file mode 100644
index 26b096e..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiProjectTests.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import junit.framework.*;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.tests.util.Util;
-
-
-public class MultiProjectTests extends Tests {
- private static String[] EXCLUDED_TESTS = {};
-
- public MultiProjectTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new FilteredTestSuite(EXCLUDED_TESTS);
- suite.addTestSuite(MultiProjectTests.class);
- return suite;
- }
-
- public void testCompileOnlyDependent() {
- //----------------------------
- // Step 1
- //----------------------------
- //----------------------------
- // Project1
- //----------------------------
- IPath project1Path = env.addProject("Project1");
- env.addExternalJar(project1Path, Util.getJavaClassLib());
- IPath root1 = env.getPackageFragmentRootPath(project1Path, "");
- env.addClass(root1, "", "A",
- "public class A {\n"+
- "}\n"
- );
-
- //----------------------------
- // Project2
- //----------------------------
- IPath project2Path = env.addProject("Project2");
- env.addExternalJar(project2Path, Util.getJavaClassLib());
- env.addRequiredProject(project2Path, project1Path);
- IPath root2 = env.getPackageFragmentRootPath(project2Path, "");
- env.addClass(root2, "", "B",
- "public class B extends A {\n"+
- "}\n"
- );
-
- //----------------------------
- // Project3
- //----------------------------
- IPath project3Path = env.addProject("Project3");
- env.addExternalJar(project3Path, Util.getJavaClassLib());
- IPath root3 = env.getPackageFragmentRootPath(project3Path, "");
- env.addClass(root3, "", "C",
- "public class C {\n"+
- "}\n"
- );
-
- fullBuild();
- expectingNoProblems();
-
- //----------------------------
- // Step 2
- //----------------------------
- env.addClass(root1, "", "A",
- "public class A {\n"+
- " int x;\n"+
- "}\n"
- );
-
- incrementalBuild();
- expectingCompiledClasses(new String[]{"A", "B"});
- }
-
- public void testRemoveField() {
- //----------------------------
- // Step 1
- //----------------------------
- //----------------------------
- // Project1
- //----------------------------
- IPath project1Path = env.addProject("Project1");
- env.addExternalJar(project1Path, Util.getJavaClassLib());
- IPath root1 = env.getPackageFragmentRootPath(project1Path, "");
- env.addClass(root1, "", "A",
- "public class A {\n"+
- " public int x;\n"+
- "}\n"
- );
-
- //----------------------------
- // Project2
- //----------------------------
- IPath project2Path = env.addProject("Project2");
- env.addExternalJar(project2Path, Util.getJavaClassLib());
- env.addRequiredProject(project2Path, project1Path);
- IPath root2 = env.getPackageFragmentRootPath(project2Path, "");
- IPath b = env.addClass(root2, "", "B",
- "public class B {\n"+
- " public void foo(){\n"+
- " int x = new A().x;\n"+
- " }\n"+
- "}\n"
- );
-
- fullBuild();
- expectingNoProblems();
-
- //----------------------------
- // Step 2
- //----------------------------
- env.addClass(root1, "", "A",
- "public class A {\n"+
- "}\n"
- );
-
- incrementalBuild();
- expectingSpecificProblemFor(b, new Problem("B.foo()", "x cannot be resolved or is not a field", b));
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/OutputFolderTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/OutputFolderTests.java
deleted file mode 100644
index dadc3ae..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/OutputFolderTests.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import junit.framework.*;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.tests.util.Util;
-
-/**
- * Basic tests of the image builder.
- */
-public class OutputFolderTests extends Tests {
- private static String[] EXCLUDED_TESTS = {
- "OutputFolderTests", "testDeleteOutputFolder",
- "OutputFolderTests", "testChangeOutputFolder"
- };
-
- public OutputFolderTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new FilteredTestSuite(EXCLUDED_TESTS);
- suite.addTestSuite(OutputFolderTests.class);
- return suite;
- }
-
- public void testDeleteOutputFolder() {
- //----------------------------
- // Step 1
- //----------------------------
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
-
- IPath root = env.getPackageFragmentRootPath(projectPath, "");
- IPath bin = env.setOutputFolder(projectPath, "bin");
-
- env.addClass(root, "", "Test",
- "public class Test {\n"+
- "}\n"
- );
-
- env.addFile(root, "Test.txt", "");
-
-
- fullBuild();
- expectingNoProblems();
- expectingPresenceOf(new IPath[]{
- bin,
- bin.append("Test.class"),
- bin.append("Test.txt")
- });
-
- //----------------------------
- // Step 2
- //----------------------------
- env.removeFolder(bin);
-
- incrementalBuild();
- expectingPresenceOf(new IPath[]{
- bin,
- bin.append("Test.class"),
- bin.append("Test.txt")
- });
- }
-
- public void testChangeOutputFolder() {
- //----------------------------
- // Step 1
- //----------------------------
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
-
- // remove old package fragment root so that names don't collide
- env.removePackageFragmentRoot(projectPath, "");
-
- IPath root = env.addPackageFragmentRoot(projectPath, "src");
- IPath bin1 = env.setOutputFolder(projectPath, "bin1");
-
- env.addClass(root, "p", "Test",
- "package p;\n" +
- "public class Test {\n"+
- "}\n"
- );
-
-
- fullBuild();
- expectingNoProblems();
- expectingPresenceOf(new IPath[]{
- bin1,
- bin1.append("p").append("Test.class"),
- });
-
- //----------------------------
- // Step 2
- //----------------------------
- IPath bin2 = env.setOutputFolder(projectPath, "bin2");
-
- incrementalBuild();
-
- expectingNoProblems();
- expectingPresenceOf(new IPath[]{
- bin2,
- bin2.append("p").append("Test.class"),
- });
- expectingNoPresenceOf(new IPath[]{
- bin1,
- bin1.append("p").append("Test.class"),
- });
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageTests.java
deleted file mode 100644
index 9ccb4ed..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/PackageTests.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import junit.framework.*;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.tests.util.Util;
-
-public class PackageTests extends Tests {
- private static String[] EXCLUDED_TESTS = {
- };
-
- public PackageTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new FilteredTestSuite(EXCLUDED_TESTS);
- suite.addTestSuite(PackageTests.class);
- return suite;
- }
-
- /**
- * Bugs 6564
- */
- public void testPackageProblem(){
- //----------------------------
- // Step 1
- //----------------------------
- IPath projectPath = env.addProject("Project");
- env.addExternalJar(projectPath, Util.getJavaClassLib());
- env.removePackageFragmentRoot(projectPath, "");
- IPath src = env.addPackageFragmentRoot(projectPath, "src");
- IPath src2 = env.addPackageFragmentRoot(projectPath, "src2");
- IPath bin = env.setOutputFolder(projectPath, "bin");
-
- IPath x = env.addClass(src, "pack", "X",
- "package pack;\n"+
- "public class X {\n"+
- "}\n"
- );
-
- env.addClass(src2, "p1", "X",
- "package p1;\n"+
- "public class X {\n"+
- "}\n"
- );
-
- env.addClass(src2, "p2", "Y",
- "package p2;\n"+
- "public class Y extends p1.X {\n"+
- "}\n"
- );
-
- env.addClass(src2, "p3", "Z",
- "package p3;\n"+
- "public class Z extends p2.Y {\n"+
- "}\n"
- );
-
-
- fullBuild();
- expectingNoProblems();
-
- //----------------------------
- // Step 2
- //----------------------------
- env.removeClass(env.getPackagePath(src, "pack"), "X");
- env.removePackage(src2, "p3");
-
- incrementalBuild();
- expectingNoProblems();
- }
-}
-
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Problem.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Problem.java
deleted file mode 100644
index 335767b..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Problem.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.IPath;
-
-public class Problem {
- private String location;
- private String message;
- private IPath resourcePath;
-
- public Problem(String location, String message, IPath resourcePath){
- this.location = location;
- this.message = message;
- this.resourcePath = resourcePath;
- }
-
- public Problem(IMarker marker){
- this.location = marker.getAttribute(IMarker.LOCATION, "");
- this.message = marker.getAttribute(IMarker.MESSAGE, "");
- this.resourcePath = marker.getResource().getFullPath();
- }
- /**
- * Gets the location.
- * @return Returns a String
- */
- public String getLocation() {
- return location;
- }
- /**
- * Gets the message.
- * @return Returns a String
- */
- public String getMessage() {
- return message;
- }
- /**
- * Gets the resourcePath.
- * @return Returns a IPath
- */
- public IPath getResourcePath() {
- return resourcePath;
- }
-
- public String toString(){
- return "Problem : " + message + " [ resource : <" + resourcePath + "> location <"+ location + "> ]";
- }
-
- public boolean equals(Object o){
- if(o instanceof Problem){
- return this.toString().equals(o.toString());
- }
- return false;
- }
-}
-
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java
deleted file mode 100644
index dab5586..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java
+++ /dev/null
@@ -1,831 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
-
-import org.eclipse.jdt.core.*;
-
-import org.eclipse.jdt.internal.core.JavaProject;
-import java.io.*;
-import java.util.*;
-
-public class TestingEnvironment {
- private static final String testJarName = "buildertests.jar";
- private static final String testProjectName = "org.eclipse.jdt.core.tests.builder";
-
- private boolean fIsOpen = false;
- private boolean fWasBuilt = false;
-
- private IWorkspace fWorkspace = null;
- private Hashtable fProjects = null;
-
- private void addBuilderSpecs(String projectName) {
- try {
- IProject project = getProject(projectName);
- IProjectDescription description = project.getDescription();
- description.setNatureIds(new String[] { JavaCore.NATURE_ID });
- project.setDescription(description, null);
- } catch (CoreException e) {
- handleCoreException(e);
- }
- }
-
- /** Adds a binary class with the given contents to the
- * given package in the workspace. The package is created
- * if necessary. If a class with the same name already
- * exists, it is replaced. A workspace must be open,
- * and the given class name must not end with ".class".
- * Returns the path of the added class.
- */
- public IPath addBinaryClass(IPath packagePath, String className, byte[] contents) {
- checkAssertion("a workspace must be open", fIsOpen);
- IPath classPath = packagePath.append(className + ".class");
- createFile(classPath, contents);
- return classPath;
- }
-
- /** Adds a binary class with the given contents to the
- * given package in the workspace. The package is created
- * if necessary. If a class with the same name already
- * exists, it is replaced. A workspace must be open,
- * and the given class name must not end with ".class".
- * Returns the path of the added class.
- */
- public IPath addBinaryClass(IPath packageFragmentRootPath, String packageName, String className, byte[] contents) {
- /* make sure the package exists */
- if(packageName != null && packageName.length() >0){
- IPath packagePath = addPackage(packageFragmentRootPath, packageName);
-
- return addBinaryClass(packagePath, className, contents);
- } else {
- return addBinaryClass(packageFragmentRootPath, className, contents);
- }
-
- }
-
- /** Adds a class with the given contents to the given
- * package in the workspace. The package is created
- * if necessary. If a class with the same name already
- * exists, it is replaced. A workspace must be open,
- * and the given class name must not end with ".java".
- * Returns the path of the added class.
- */
- public IPath addClass(IPath packagePath, String className, String contents) {
- checkAssertion("a workspace must be open", fIsOpen);
- IPath classPath = packagePath.append(className + ".java");
- try {
- createFile(classPath, contents.getBytes("UTF8"));
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- checkAssertion("e1", false);
- }
- return classPath;
- }
-
- /** Adds a class with the given contents to the given
- * package in the workspace. The package is created
- * if necessary. If a class with the same name already
- * exists, it is replaced. A workspace must be open,
- * and the given class name must not end with ".java".
- * Returns the path of the added class.
- */
- public IPath addClass(IPath packageFragmentRootPath, String packageName, String className, String contents) {
- /* make sure the package exists */
- if(packageName != null && packageName.length() >0){
- IPath packagePath = addPackage(packageFragmentRootPath, packageName);
-
- return addClass(packagePath, className, contents);
- } else {
- return addClass(packageFragmentRootPath, className, contents);
- }
- }
-
- /** Adds a package to the given package fragment root
- * in the workspace. The package fragment root is created
- * if necessary. If a package with the same name already
- * exists, it is not replaced. A workspace must be open.
- * Returns the path of the added package.
- */
- public IPath addPackage(IPath packageFragmentRootPath, String packageName) {
- checkAssertion("a workspace must be open", fIsOpen);
- IPath path =
- packageFragmentRootPath.append(packageName.replace('.', IPath.SEPARATOR));
- createFolder(path);
- return path;
- }
-
- /** Adds a package fragment root to the workspace. If
- * a package fragment root with the same name already
- * exists, it is not replaced. A workspace must be open.
- * Returns the path of the added package fragment root.
- */
- public IPath addPackageFragmentRoot(IPath projectPath, String packageFragmentRootName) {
- checkAssertion("a workspace must be open", fIsOpen);
- IPath packageFragmentRootPath =
- projectPath.append(packageFragmentRootName);
- if (!packageFragmentRootName.toLowerCase().endsWith(".zip")
- && !packageFragmentRootName.toLowerCase().endsWith(".jar")) {
- createFolder(packageFragmentRootPath);
- }
- IPath[] oldRootsPath = getClasspath(projectPath);
- IPath[] newRootsPath = new IPath[oldRootsPath.length + 1];
- System.arraycopy(oldRootsPath, 0, newRootsPath, 0, oldRootsPath.length);
- IPath rootPath = getPackageFragmentRootPath(projectPath, packageFragmentRootName);
- newRootsPath[newRootsPath.length - 1] = rootPath;
- setClasspath(projectPath, newRootsPath);
- return rootPath;
- }
-
- public IPath addProject(String projectName){
- checkAssertion("a workspace must be open", fIsOpen);
- IProject project = createProject(projectName);
- return project.getFullPath();
- }
-
- /** Adds a project to the classpath of a project.
- */
- public void addRequiredProject(IPath projectPath, IPath requiredProjectPath){
- checkAssertion("required project must not be in project", !projectPath.isPrefixOf(requiredProjectPath));
- addEntry(projectPath, requiredProjectPath);
-
- }
-
- /** Adds an external jar to the classpath of a project.
- */
- public void addExternalJar(IPath projectPath, String jar) {
- checkAssertion("file name must end with .zip or .jar", jar.endsWith(".zip") || jar.endsWith(".jar"));
- addEntry(projectPath, new Path(jar));
- }
-
- private void addEntry(IPath projectPath, IPath entryPath) {
- IPath[] classpath = getClasspath(projectPath);
- IPath[] newClaspath = new IPath[classpath.length + 1];
- System.arraycopy(classpath, 0, newClaspath, 1, classpath.length);
- newClaspath[0] = entryPath;
- setClasspath(projectPath, newClaspath);
- }
-
- /** Adds a file.
- */
- public IPath addFile(IPath root, String fileName, String contents){
- checkAssertion("a workspace must be open", fIsOpen);
- IPath filePath = root.append(fileName);
- try {
- createFile(filePath, contents.getBytes("UTF8"));
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- checkAssertion("e1", false);
- }
- return filePath;
- }
-
- /** Adds a folder.
- */
- public IPath addFolder(IPath root, String folderName, String contents){
- checkAssertion("a workspace must be open", fIsOpen);
- IPath folderPath = root.append(folderName);
- createFolder(folderPath);
- return folderPath;
- }
-
- /** Adds a jar with the given contents to the the workspace.
- * If a jar with the same name already exists, it is
- * replaced. A workspace must be open, and the given
- * zip name must end with ".zip" or ".jar". Returns the path of
- * the added jar.
- */
- public IPath addInternalJar(IPath projectPath, String zipName, byte[] contents) {
- checkAssertion("a workspace must be open", fIsOpen);
- checkAssertion("zipName must end with .zip or .jar", zipName.endsWith(".zip") || zipName.endsWith(".jar"));
- IPath path = projectPath.append(zipName);
-
- /* remove any existing zip from the java model */
- removeInternalJar(projectPath, zipName);
-
- IFile file = fWorkspace.getRoot().getFile(path);
- createFile(path, contents);
- addPackageFragmentRoot(projectPath, zipName);
- return path;
- }
-
- private void checkAssertion(String message, boolean b) {
- Assert.isTrue(b, message);
- }
-
- /** Closes the testing environment and frees up any
- * resources. Once the testing environment is closed,
- * it shouldn't be used any more.
- */
- public void close() {
- try {
- if (fProjects != null) {
- Enumeration projectNames = fProjects.keys();
- while (projectNames.hasMoreElements()) {
- String projectName = (String) projectNames.nextElement();
- getJavaProject(projectName).getJavaModel().close();
- }
- }
- closeWorkspace();
- } catch (JavaModelException e) {
- e.printStackTrace();
- } catch (RuntimeException e) {
- e.printStackTrace();
- }
- }
-
- /** Close a project from the workspace.
- */
- public void closeProject(IPath projectPath){
- checkAssertion("a workspace must be open", fIsOpen);
- try {
- getJavaProject(projectPath).getProject().close(null);
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
-
- private void closeWorkspace() {
- fIsOpen = false;
- fWasBuilt = false;
- }
-
- private IFile createFile(IPath path, byte[] contents) {
- try {
- IFile file = fWorkspace.getRoot().getFile(path);
-
- ByteArrayInputStream is = new ByteArrayInputStream(contents);
- if (file.exists()) {
- file.delete(true, null);
- }
- file.create(is, true, null);
- return file;
- } catch (CoreException e) {
- handle(e);
- }
- return null;
- }
-
- private IFolder createFolder(IPath path) {
- checkAssertion("root", !path.isRoot());
-
- /* don't create folders for projects */
- if (path.segmentCount() <= 1) {
- return null;
- }
-
- IFolder folder = fWorkspace.getRoot().getFolder(path);
- if (!folder.exists()) {
- /* create the parent folder if necessary */
- createFolder(path.removeLastSegments(1));
-
- try {
- folder.create(true, true, null);
- } catch (CoreException e) {
- handle(e);
- }
- }
- return folder;
- }
-
- private IProject createProject(String projectName) {
- IProject project = null;
- try {
- project = fWorkspace.getRoot().getProject(projectName);
- project.create(null, null);
- project.open(null);
- fProjects.put(projectName, project);
- addBuilderSpecs(projectName);
- } catch (CoreException e) {
- handle(e);
- }
-
- return project;
- }
-
- private void deleteFile(File file) {
- file = file.getAbsoluteFile();
- if (!file.exists())
- return;
- if (file.isDirectory()) {
- String[] files = file.list();
- //file.list() can return null
- if (files != null) {
- for (int i = 0; i < files.length; ++i) {
- deleteFile(new File(file, files[i]));
- }
- }
- }
- if (!file.delete()) {
- System.out.println(
- "WARNING: deleteFile(File) could not delete: " + file.getPath());
- }
- }
-
- /** Batch builds the workspace. A workspace must be
- * open.
- */
- public void fullBuild() {
- checkAssertion("a workspace must be open", fIsOpen);
- try {
- getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);
- } catch (CoreException e) {
- handle(e);
- }
- fWasBuilt = true;
- }
-
- /** Batch builds a project. A workspace must be
- * open.
- */
- public void fullBuild(IPath projectPath) {
- checkAssertion("a workspace must be open", fIsOpen);
- try {
- getProject(projectPath).build(IncrementalProjectBuilder.FULL_BUILD, null);
- } catch (CoreException e) {
- handle(e);
- }
- fWasBuilt = true;
- }
-
- /**
- * Returns the class path.
- */
- public IPath[] getClasspath(IPath projectPath) {
- try {
- checkAssertion("a workspace must be open", fIsOpen);
- IJavaProject javaProject =
- (IJavaProject) getProject(projectPath).getNature(JavaCore.NATURE_ID);
- IClasspathEntry[] entries =
- ((JavaProject) javaProject).getExpandedClasspath(true);
- IPath[] packageFragmentRootsPath = new IPath[entries.length];
- for (int i = 0; i < entries.length; ++i) {
- packageFragmentRootsPath[i] = entries[i].getPath();
- }
- return packageFragmentRootsPath;
- } catch (JavaModelException e) {
- e.printStackTrace();
- checkAssertion("JavaModelException", false);
- return null; // not reachable
- } catch (CoreException e) {
- e.printStackTrace();
- checkAssertion("CoreException", false);
- return null; // not reachable
- }
- }
-
- /**
- * Returns the Java Model element for the project.
- */
- public IJavaProject getJavaProject(IPath projectPath) {
- IJavaProject javaProject = JavaCore.create(getProject(projectPath));
- Assert.isNotNull(javaProject);
- return javaProject;
- }
-
- /**
- * Returns the Java Model element for the project.
- */
- public IJavaProject getJavaProject(String projectName) {
- IJavaProject javaProject = JavaCore.create(getProject(projectName));
- Assert.isNotNull(javaProject);
- return javaProject;
- }
-
- /**
- * Return output location for a project.
- */
- public IPath getOutputLocation(IPath projectPath){
- try {
- IJavaProject javaProject = (IJavaProject) getProject(projectPath).getNature(JavaCore.NATURE_ID);
- return javaProject.getOutputLocation();
- } catch(CoreException e){
-
- }
- return null;
- }
-
- /**
- * Return all problems with workspace.
- */
- public Problem[] getProblems(){
- return getProblemsFor(getWorkspaceRootPath());
- }
-
- /**
- * Return all problems with the specified element.
- */
- public Problem[] getProblemsFor(IPath path){
- IResource resource;
- if(path.equals(getWorkspaceRootPath())){
- resource = getWorkspace().getRoot();
- } else {
- IProject p = getProject(path);
- if(p != null && path.equals(p.getFullPath())) {
- resource = getProject(path.lastSegment());
- } else if(path.getFileExtension() == null) {
- resource = getWorkspace().getRoot().getFolder(path);
- } else {
- resource = getWorkspace().getRoot().getFile(path);
- }
- }
- try {
- ArrayList problems = new ArrayList();
- IMarker[] markers = resource.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
- for (int i = 0; i < markers.length; i++)
- problems.add(new Problem(markers[i]));
-
- markers = resource.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
- for (int i = 0; i < markers.length; i++)
- problems.add(new Problem(markers[i]));
-
- Problem[] result = new Problem[problems.size()];
- problems.toArray(result);
- return result;
- } catch(CoreException e){
- }
- return new Problem[0];
- }
-
- /**
- * Returns the path of a class. Class name must not end with .java
- */
- public IPath getClazzPath(IPath packagePath, String clazzName) {
- checkAssertion("a workspace must be open", fIsOpen);
- checkAssertion("type a name must not be empty", clazzName.length() != 0);
-
- return packagePath.append(clazzName + ".java");
- }
-
- /** Return the path of the package
- * with the given name. A workspace must be open, and
- * the package must exist.
- */
- public IPath getPackagePath(IPath root, String packageName) {
- checkAssertion("a workspace must be open", fIsOpen);
- if (packageName.length() == 0)
- return root;
- else
- return root.append(packageName.replace('.', IPath.SEPARATOR));
- }
-
- /** Return the path of the package fragment root
- * with the given name. A workspace must be open, and
- * the package fragment root must exist.
- */
- public IPath getPackageFragmentRootPath(IPath projectPath, String name) {
- checkAssertion("a workspace must be open", fIsOpen);
- if (name.length() == 0)
- return projectPath;
- else
- return projectPath.append(name);
- }
-
- /**
- * Returns the core project.
- */
- public IProject getProject(String projectName) {
- return (IProject)fProjects.get(projectName);
- }
-
- /**
- * Returns the core project.
- */
- public IProject getProject(IPath projectPath) {
- return (IProject)fProjects.get(projectPath.lastSegment());
- }
-
- /**
- * Returns the workspace.
- */
- public IWorkspace getWorkspace() {
- return fWorkspace;
- }
-
- /**
- * Returns the path of workspace root.
- */
- public IPath getWorkspaceRootPath(){
- return getWorkspace().getRoot().getLocation();
- }
-
- private IPath getJarRootPath(IPath projectPath) {
- checkAssertion("a workspace must be open", fIsOpen);
- return getProject(projectPath).getFullPath();
- }
-
- void handle(Exception e) {
- if (e instanceof CoreException) {
- handleCoreException((CoreException) e);
- } else {
- e.printStackTrace();
- Assert.isTrue(false);
- }
- }
-
- /**
- * Handles a core exception thrown during a testing environment operation
- */
- private void handleCoreException(CoreException e) {
- e.printStackTrace();
- Assert.isTrue(
- false,
- "Core exception in testing environment: " + e.getMessage());
- }
-
- /** Incrementally builds the workspace. A workspace must be
- * open.
- */
- public void incrementalBuild() {
- checkAssertion("a workspace must be open", fIsOpen);
- checkAssertion("the workspace must have been built", fWasBuilt);
- try {
- getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
- } catch (CoreException e) {
- handle(e);
- }
- }
-
- /** Incrementally builds a project. A workspace must be
- * open.
- */
- public void incrementalBuild(IPath projectPath) {
- checkAssertion("a workspace must be open", fIsOpen);
- checkAssertion("the workspace must have been built", fWasBuilt);
- try {
- getProject(projectPath).build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
- } catch (CoreException e) {
- handle(e);
- }
- }
-
- /** Open an empty workspace.
- */
- public void openEmptyWorkspace() {
- close();
- openWorkspace();
- fProjects = new Hashtable(10);
- setup();
- }
-
- /** Close a project from the workspace.
- */
- public void openProject(IPath projectPath){
- checkAssertion("a workspace must be open", fIsOpen);
- try {
- getJavaProject(projectPath).getProject().open(null);
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
-
- private void openWorkspace() {
- try {
- closeWorkspace();
-
- fWorkspace = ResourcesPlugin.getWorkspace();
-
- // turn off auto-build -- the tests determine when builds occur
- IWorkspaceDescription description = fWorkspace.getDescription();
- description.setAutoBuilding(false);
- fWorkspace.setDescription(description);
- } catch (Exception e) {
- handle(e);
- }
- }
-
- /** Removes a binary class from the given package in
- * the workspace. A workspace must be open, and the
- * given class name must not end with ".class".
- */
- public void removeBinaryClass(IPath packagePath, String className) {
- checkAssertion("a workspace must be open", fIsOpen);
- className += ".class";
- IFolder packageFolder = fWorkspace.getRoot().getFolder(packagePath);
- try {
- packageFolder.getFile(className).delete(true, null);
- } catch (CoreException e) {
- handle(e);
- }
- }
-
- /** Removes a class from the given package in the workspace.
- * A workspace must be open, and the given class name must
- * not end with ".java".
- */
- public void removeClass(IPath packagePath, String className) {
- checkAssertion("a workspace must be open", fIsOpen);
- className += ".java";
- IFolder packageFolder = fWorkspace.getRoot().getFolder(packagePath);
- try {
- packageFolder.getFile(className).delete(true, null);
- } catch (CoreException e) {
- handle(e);
- }
- }
-
- /** Removes a package from the given package fragment root
- * in the workspace. A workspace must be open.
- */
- public void removePackage(IPath packageFragmentRootPath, String packageName) {
- checkAssertion("a workspace must be open", fIsOpen);
- IPath path =
- packageFragmentRootPath.append(packageName.replace('.', IPath.SEPARATOR));
- IFolder folder = fWorkspace.getRoot().getFolder(path);
- try {
- folder.delete(false, null);
- } catch (CoreException e) {
- handle(e);
- }
- }
-
- /** Removes the given package fragment root from the
- * the workspace. A workspace must be open.
- */
- public void removePackageFragmentRoot(IPath projectPath, String packageFragmentRootName) {
- checkAssertion("a workspace must be open", fIsOpen);
- if (packageFragmentRootName.length() > 0) {
- IFolder folder = getProject(projectPath).getFolder(packageFragmentRootName);
- if (folder.exists()) {
- try {
- folder.delete(false, null);
- } catch (CoreException e) {
- handle(e);
- }
- }
- }
- IPath rootPath = getPackageFragmentRootPath(projectPath, packageFragmentRootName);
- IPath[] oldEntries = getClasspath(projectPath);
- removeEntry(projectPath, rootPath);
- }
-
- /** Remove a project from the workspace.
- */
- public void removeProject(IPath projectPath){
- checkAssertion("a workspace must be open", fIsOpen);
- try {
- getJavaProject(projectPath).close();
- } catch (JavaModelException e) {
- e.printStackTrace();
- }
- IProject project = getProject(projectPath);
- try {
- project.delete(true, null);
- } catch (CoreException e) {
- handle(e);
- }
-
- }
-
- /** Remove a required project from the classpath
- */
- public void removeRequiredProject(IPath projectPath, IPath requiredProject){
- removeEntry(projectPath, requiredProject);
- }
-
- /** Remove all elements in the workspace.
- */
- public void resetWorkspace(){
- if (fProjects != null) {
- Enumeration projectNames = fProjects.keys();
- while (projectNames.hasMoreElements()) {
- String projectName = (String) projectNames.nextElement();
- removeProject(getProject(projectName).getFullPath());
- }
- }
- }
-
- /** Removes the given internal jar from the workspace.
- * A workspace must be open.
- */
- public void removeInternalJar(IPath projectPath, String zipName) {
- checkAssertion("a workspace must be open", fIsOpen);
- checkAssertion("zipName must end with .zip or .jar", zipName.endsWith(".zip") || zipName.endsWith(".jar"));
-
- /* remove zip from the java model (it caches open zip files) */
- IPath zipPath = getJarRootPath(projectPath).append(zipName);
- try {
- getJavaProject(projectPath)
- .getPackageFragmentRoot(getWorkspace().getRoot().getFile(zipPath))
- .close();
- } catch (JavaModelException e) {
- e.printStackTrace();
- }
- removePackageFragmentRoot(projectPath, zipName);
-
- IFile file = getProject(projectPath).getFile(zipName);
- try {
- file.delete(false, null);
- } catch (CoreException e) {
- handle(e);
- }
- }
-
- /**
- * Remove an external jar from the classpath.
- */
- public void removeExternalJar(IPath projectPath, IPath jarPath) {
- checkAssertion("a workspace must be open", fIsOpen);
- removeEntry(projectPath, jarPath);
- }
-
- private void removeEntry(IPath projectPath, IPath entryPath) {
- checkAssertion("a workspace must be open", fIsOpen);
- IPath[] oldEntries = getClasspath(projectPath);
- for (int i = 0; i < oldEntries.length; ++i) {
- if (oldEntries[i].equals(entryPath)) {
- IPath[] newEntries = new IPath[oldEntries.length - 1];
- System.arraycopy(oldEntries, 0, newEntries, 0, i);
- System.arraycopy(oldEntries, i + 1, newEntries, i, oldEntries.length - i - 1);
- setClasspath(projectPath, newEntries);
- }
- }
- }
-
- /** Remove a file
- */
- public void removeFile(IPath filePath) {
- checkAssertion("a workspace must be open", fIsOpen);
- IFolder folder = fWorkspace.getRoot().getFolder(filePath.removeLastSegments(1));
- try {
- folder.getFile(filePath.lastSegment()).delete(true, null);
- } catch (CoreException e) {
- handle(e);
- }
- }
-
- /** Remove a folder
- */
- public void removeFolder(IPath folderPath) {
- checkAssertion("a workspace must be open", fIsOpen);
- IFolder folder = fWorkspace.getRoot().getFolder(folderPath);
- try {
- folder.delete(true, null);
- } catch (CoreException e) {
- handle(e);
- }
- }
-
- /** Sets the classpath to the given package fragment
- * roots. The builder searches the classpath to
- * find the java files it needs during a build.
- */
- public void setClasspath(IPath projectPath, IPath[] packageFragmentRootsPath) {
- try {
- checkAssertion("a workspace must be open", fIsOpen);
- IJavaProject javaProject =
- (IJavaProject) getProject(projectPath).getNature(JavaCore.NATURE_ID);
- IClasspathEntry[] entries =
- new IClasspathEntry[packageFragmentRootsPath.length];
- for (int i = 0; i < packageFragmentRootsPath.length; ++i) {
- IPath path = packageFragmentRootsPath[i];
- if ("jar".equals(path.getFileExtension())
- || "zip".equals(path.getFileExtension())) {
- entries[i] = JavaCore.newLibraryEntry(path, null, null, false);
- } else if (projectPath.isPrefixOf(packageFragmentRootsPath[i])) {
- entries[i] = JavaCore.newSourceEntry(path);
- } else {
- entries[i] = JavaCore.newProjectEntry(path);
- }
- }
- javaProject.setRawClasspath(entries, null);
- } catch (JavaModelException e) {
- e.printStackTrace();
- checkAssertion("JavaModelException", false);
- } catch (CoreException e) {
- e.printStackTrace();
- checkAssertion("CoreException", false);
- }
- }
-
- public IPath setOutputFolder(IPath projectPath, String outputFolder){
- IPath outputPath = null;
- try {
- checkAssertion("a workspace must be open", fIsOpen);
- IJavaProject javaProject =
- (IJavaProject) getProject(projectPath).getNature(JavaCore.NATURE_ID);
- outputPath = projectPath.append(outputFolder);
- javaProject.setOutputLocation(outputPath, null);
- } catch (JavaModelException e) {
- e.printStackTrace();
- checkAssertion("JavaModelException", false);
- } catch (CoreException e) {
- e.printStackTrace();
- checkAssertion("CoreException", false);
- }
- return outputPath;
- }
-
- private void setup() {
- fIsOpen = true;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Tests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Tests.java
deleted file mode 100644
index 229125e..0000000
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/Tests.java
+++ /dev/null
@@ -1,415 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.builder;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-import junit.framework.*;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.tests.util.TestVerifier;
-import org.eclipse.jdt.core.tests.util.Util;
-import org.eclipse.jdt.internal.compiler.Compiler;
-
-/**
- * Base class for Java image builder tests
- */
-public class Tests extends TestCase {
- protected static boolean DEBUG = false;
- protected static TestingEnvironment env = null;
- protected EfficiencyCompilerRequestor debugRequestor = null;
-
- private static String[] EXCLUDED_TESTS = {
- };
-
- public Tests(String name) {
- super(name);
- }
-
- /** Execute the given class. Expecting output and error must be specified.
- */
- protected void executeClass(IPath projectPath, String className, String expectingOutput, String expectedError){
- TestVerifier verifier = new TestVerifier(false);
- Vector classpath = new Vector(5);
-
- IPath workspacePath = env.getWorkspaceRootPath();
-
- classpath.addElement(workspacePath.append(env.getOutputLocation(projectPath)).toOSString());
- IPath[] cp = env.getClasspath(projectPath);
- for (int i = 0; i < cp.length; i++) {
- IPath c = cp[i];
- String ext = c.getFileExtension();
- if(ext != null && (ext.equals("zip") || ext.equals("jar"))){
- if(c.getDevice() == null) {
- classpath.addElement(workspacePath.append(c).toOSString());
- } else {
- classpath.addElement(c.toOSString());
- }
- }
- }
-
- verifier.execute(className, (String[])classpath.toArray(new String[0]));
-
- if(DEBUG){
- System.out.println("ERRORS\n");
- System.out.println(Util.displayString(verifier.getExecutionError()));
-
- System.out.println("OUTPUT\n");
- System.out.println(Util.displayString(verifier.getExecutionOutput()));
- }
- String actualError = verifier.getExecutionError();
- if (!expectedError.equals(actualError)){
- System.out.println("ERRORS\n");
- System.out.println(Util.displayString(actualError));
- }
- assertTrue("unexpected error", actualError.indexOf(expectedError) != -1);
-
- String actualOutput = verifier.getExecutionOutput();
- if (!expectingOutput.equals(actualOutput)){
- System.out.println("OUTPUT\n");
- System.out.println(Util.displayString(actualOutput));
- }
- assertTrue("unexpected output", actualOutput.indexOf(expectingOutput) != -1);
-
- }
-
- /** Verifies that given element is not present.
- */
- protected void expectingPresenceOf(IPath path) {
- expectingPresenceOf(new IPath[]{path});
- }
-
- /** Verifies that given elements are not present.
- */
- protected void expectingPresenceOf(IPath[] paths) {
- IPath wRoot = env.getWorkspaceRootPath();
-
- for (int i = 0; i < paths.length; i++){
- assertTrue(paths[i] +" is not present", wRoot.append(paths[i]).toFile().exists());
- }
- }
-
- /** Verifies that given element is not present.
- */
- protected void expectingNoPresenceOf(IPath path) {
- expectingNoPresenceOf(new IPath[]{path});
- }
-
- /** Verifies that given elements are not present.
- */
- protected void expectingNoPresenceOf(IPath[] paths) {
- IPath wRoot = env.getWorkspaceRootPath();
-
- for (int i = 0; i < paths.length; i++){
- assertTrue(paths[i] +" is present", !wRoot.append(paths[i]).toFile().exists());
- }
- }
-
- /** Verifies that given classes have been compiled.
- */
- protected void expectingCompiledClasses(String[] expected){
- String[] actual = debugRequestor.getCompiledClasses();
- org.eclipse.jdt.internal.core.Util.sort(actual);
- org.eclipse.jdt.internal.core.Util.sort(expected);
- expectingCompiling(actual, expected, "unexpected recompiled units");
- }
-
- /** Verifies that given classes have been compiled in the specified order.
- */
- protected void expectingCompilingOrder(String[] expected){
- expectingCompiling(debugRequestor.getCompiledClasses(), expected, "unexpected compiling order");
- }
-
- private void expectingCompiling(String[] actual, String[] expected, String message){
- if(DEBUG) {
- for (int i = 0; i < actual.length; i++) {
- System.out.println(actual[i]);
- }
- }
-
- StringBuffer actualBuffer = new StringBuffer("{");
- for (int i = 0; i < actual.length; i++){
- if (i > 0) actualBuffer.append(",");
- actualBuffer.append(actual[i]);
- }
- actualBuffer.append('}');
- StringBuffer expectedBuffer = new StringBuffer("{");
- for (int i = 0; i < expected.length; i++){
- if (i > 0) expectedBuffer.append(",");
- expectedBuffer.append(expected[i]);
- }
- expectedBuffer.append('}');
- assertEquals(message, expectedBuffer.toString(), actualBuffer.toString());
- }
-
- /** Verifies that the workspace has no problems.
- */
- protected void expectingNoProblems() {
- expectingNoProblemsFor(env.getWorkspaceRootPath());
- }
-
- /** Verifies that the given element has no problems.
- */
- protected void expectingNoProblemsFor(IPath root) {
- expectingNoProblemsFor(new IPath[]{root});
- }
-
- /** Verifies that the given elements have no problems.
- */
- protected void expectingNoProblemsFor(IPath[] roots) {
- if(DEBUG)
- printProblemsFor(roots);
-
- for (int i = 0; i < roots.length; i++) {
- IPath root = roots[i];
- Problem[] problems = env.getProblemsFor(root);
-
- if(problems.length != 0) {
- assertTrue("unexpected problem(s) : " + problems[0], false);
- }
- }
- }
-
- /** Verifies that the given element has problems and
- * only the given element.
- */
- protected void expectingOnlyProblemsFor(IPath expected) {
- expectingOnlyProblemsFor(new IPath[]{expected});
- }
-
- /** Verifies that the given elements have problems and
- * only the given elements.
- */
- protected void expectingOnlyProblemsFor(IPath[] expected) {
- if(DEBUG)
- printProblems();
-
- Problem[] rootProblems = env.getProblems();
-
- Hashtable actual = new Hashtable(rootProblems.length*2+1);
- for (int i = 0; i < rootProblems.length; i++) {
- IPath culprit = rootProblems[i].getResourcePath();
- actual.put(culprit, culprit);
- }
-
- for (int i = 0; i < expected.length; i++) {
- if (!actual.containsKey(expected[i])) {
- assertTrue("missing expected problem with " + expected[i].toString(), false);
- }
- }
-
- if (actual.size() > expected.length) {
- for (Enumeration e = actual.elements(); e.hasMoreElements();) {
- IPath path = (IPath)e.nextElement();
- boolean found = false;
- for (int i = 0; i < expected.length; ++i) {
- if (path.equals(expected[i])) {
- found = true;
- break;
- }
- }
- if (!found) {
- assertTrue("unexpected problem(s) with " + path.toString(), false);
- }
- }
- }
- }
-
- /** Verifies that the given element has a specific problem and
- * only the given problem.
- */
- protected void expectingOnlySpecificProblemFor(IPath root, Problem problem){
- expectingOnlySpecificProblemsFor(root, new Problem[]{problem});
- }
-
- /** Verifies that the given element has specifics problems and
- * only the given problems.
- */
- protected void expectingOnlySpecificProblemsFor(IPath root, Problem[] problems){
- if(DEBUG)
- printProblemsFor(root);
-
- Problem[] rootProblems = env.getProblemsFor(root);
-
- next : for (int i = 0; i < problems.length; i++) {
- Problem problem = problems[i];
- for (int j = 0; j < rootProblems.length; j++) {
- Problem rootProblem = rootProblems[j];
- if(rootProblem != null){
- if(problem.equals(rootProblem)){
- rootProblems[j] = null;
- continue next;
- }
- }
- }
- assertTrue("missing expected problem : "+ problem, false);
- }
-
- for (int i = 0; i < rootProblems.length; i++) {
- if(rootProblems[i] != null) {
- assertTrue("unexpected problem : "+ rootProblems[i], false);
- }
- }
- }
-
- /** Verifies that the given element has problems.
- */
- protected void expectingProblemsFor(IPath expected) {
- expectingProblemsFor(new IPath[]{expected});
- }
-
- /** Verifies that the given elements have problems.
- */
- protected void expectingProblemsFor(IPath[] expected) {
- if(DEBUG)
- printProblemsFor(expected);
-
- for (int i = 0; i < expected.length; i++) {
- IPath path = expected[i];
-
- /* get the leaf problems for this type */
- Problem[] problems = env.getProblemsFor(path);
- assertTrue("missing expected problem with " + expected[i].toString(), problems.length > 0);
- }
- }
-
- /** Verifies that the given element has a specific problem.
- */
- protected void expectingSpecificProblemFor(IPath root, Problem problem){
- expectingSpecificProblemsFor(root, new Problem[]{problem});
- }
-
- /** Verifies that the given element has specific problems.
- */
- protected void expectingSpecificProblemsFor(IPath root, Problem[] problems){
- if(DEBUG)
- printProblemsFor(root);
-
- Problem[] rootProblems = env.getProblemsFor(root);
-
- next : for (int i = 0; i < problems.length; i++) {
- Problem problem = problems[i];
- for (int j = 0; j < rootProblems.length; j++) {
- Problem rootProblem = rootProblems[j];
- if(rootProblem != null){
- if(problem.equals(rootProblem)){
- rootProblems[j] = null;
- continue next;
- }
- }
- }
- for (int j = 0; j < rootProblems.length; j++) {
- Problem pb = rootProblems[j];
- System.out.println("got pb: new Problem(\""+pb.getLocation()+"\", \""+pb.getMessage()+"\", \""+pb.getResourcePath()+"\")");
- }
- assertTrue("missing expected problem : "+ problem, false);
- }
- }
-
- /** Batch builds the workspace.
- */
- protected void fullBuild(){
- debugRequestor.clearResult();
- debugRequestor.activate();
- env.fullBuild();
- debugRequestor.deactivate();
- }
-
- /** Batch builds the given project.
- */
- protected void fullBuild(IPath projectPath){
- debugRequestor.clearResult();
- debugRequestor.activate();
- env.fullBuild(projectPath);
- debugRequestor.deactivate();
- }
-
- /** Incrementally builds the given project.
- */
- protected void incrementalBuild(IPath projectPath){
- debugRequestor.clearResult();
- debugRequestor.activate();
- env.incrementalBuild(projectPath);
- debugRequestor.deactivate();
- }
-
- /** Incrementally builds the workspace.
- */
- protected void incrementalBuild(){
- debugRequestor.clearResult();
- debugRequestor.activate();
- env.incrementalBuild();
- debugRequestor.deactivate();
- }
-
- protected void printProblems(){
- printProblemsFor(env.getWorkspaceRootPath());
- }
-
- protected void printProblemsFor(IPath root){
- printProblemsFor(new IPath[]{root});
- }
-
- protected void printProblemsFor(IPath[] roots){
- for (int i = 0; i < roots.length; i++) {
- IPath path = roots[i];
-
- /* get the leaf problems for this type */
- Problem[] problems = env.getProblemsFor(path);
- for (int j = 0; j < problems.length; j++) {
- System.out.println(problems[j].toString());
- }
- }
- }
-
- /** Sets up this test.
- */
- protected void setUp() {
- debugRequestor = new EfficiencyCompilerRequestor();
- Compiler.DebugRequestor = debugRequestor;
- if(env == null) {
- env = new TestingEnvironment();
- env.openEmptyWorkspace();
- }
- env.resetWorkspace();
-
- }
- /**
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- env.resetWorkspace();
- }
-
-
- public static Test suite() {
- TestSuite suite = new FilteredTestSuite(EXCLUDED_TESTS);
-
- /* basic tests */
- suite.addTest(BasicBuildTests.suite());
- suite.addTest(ErrorsTests.suite());
- suite.addTest(EfficiencyTests.suite());
- suite.addTest(ExecutionTests.suite());
-
-
- /* tests */
- suite.addTest(ClasspathTests.suite());
- suite.addTest(AbstractMethodTests.suite());
- suite.addTest(OutputFolderTests.suite());
- suite.addTest(MultiProjectTests.suite());
- suite.addTest(JCLTests.suite());
- suite.addTest(CompilationUnitLocationTests.suite());
- suite.addTest(PackageTests.suite());
- suite.addTest(IncrementalTests.suite());
-
- return suite;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/test.xml b/org.eclipse.jdt.core.tests.builder/test.xml
deleted file mode 100644
index 41cb3b6..0000000
--- a/org.eclipse.jdt.core.tests.builder/test.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0"?>
-
-<project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <property name="eclipse-home" value="${basedir}\..\.."/>
-
- <!-- sets the properties eclipse-home, and library-file -->
- <property name="plugin-name" value="org.eclipse.jdt.core.tests.builder"/>
- <property name="library-file"
- value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/>
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- <delete>
- <fileset dir="${eclipse-home}" includes="org*.xml"/>
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <property name="jdt-builder-folder"
- value="${eclipse-home}/jdt_builder_folder"/>
- <delete dir="${jdt-builder-folder}" quiet="true"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${jdt-builder-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.jdt.core.tests.builder.Tests"/>
- </ant>
- </target>
-
- <!-- This target holds code to cleanup the testing environment after -->
- <!-- after all of the tests have been run. You can use this target to -->
- <!-- delete temporary files that have been created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen -->
- <!-- after all the tests have been run should go here. -->
- <target name="run" depends="init,suite,cleanup">
- <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
- <property name="includes" value="org*.xml"/>
- <property name="output-file" value="${plugin-name}.xml"/>
- </ant>
- </target>
-
-</project>
diff --git a/org.eclipse.jdt.core.tests.compiler/.classpath b/org.eclipse.jdt.core.tests.compiler/.classpath
deleted file mode 100644
index 48572db..0000000
--- a/org.eclipse.jdt.core.tests.compiler/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="/org.junit"/>
- <classpathentry kind="src" path="/org.eclipse.jdt.debug"/>
- <classpathentry kind="src" path="/org.eclipse.jdt.core"/>
- <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
- <classpathentry kind="src" path="/org.eclipse.core.boot"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jdt.core.tests.compiler/.cvsignore b/org.eclipse.jdt.core.tests.compiler/.cvsignore
deleted file mode 100644
index c5e82d7..0000000
--- a/org.eclipse.jdt.core.tests.compiler/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/.project b/org.eclipse.jdt.core.tests.compiler/.project
deleted file mode 100644
index 7d98a6c..0000000
--- a/org.eclipse.jdt.core.tests.compiler/.project
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.core.tests.compiler</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.core.boot</project>
- <project>org.eclipse.core.runtime</project>
- <project>org.eclipse.jdt.core</project>
- <project>org.eclipse.jdt.debug</project>
- <project>org.junit</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.jdt.core.tests.compiler/about.html b/org.eclipse.jdt.core.tests.compiler/about.html
deleted file mode 100644
index 2c7906e..0000000
--- a/org.eclipse.jdt.core.tests.compiler/about.html
+++ /dev/null
@@ -1,44 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>20th June, 2002</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
-For purposes of the CPL, "Program" will mean the Content.</p>
-
-<h3>Third Party Content</h3>
-
-<p>The Content includes items that may be have been sourced from third parties as follows:</p>
-
-<p><b>JUnit 3.7</b></p>
-<p>The plug-in is based on software developed by JUnit.org. Your use of JUnit 3.7 in both source and binary code
-form contained in the plug-in is subject to the terms and conditions of the IBM Public License 1.0 which is available at
-<a href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</a>.
-The source code is located in src/org/eclipse/jdt/core/tests/junit/extension.</p>
-
-<p>i) IBM effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;</p>
-<p>ii) IBM effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;</p>
-<p>iii) IBM states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.</p>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/build.properties b/org.eclipse.jdt.core.tests.compiler/build.properties
deleted file mode 100644
index d8cb610..0000000
--- a/org.eclipse.jdt.core.tests.compiler/build.properties
+++ /dev/null
@@ -1 +0,0 @@
-source.jdtcoretestscompiler.jar = src
diff --git a/org.eclipse.jdt.core.tests.compiler/plugin.xml b/org.eclipse.jdt.core.tests.compiler/plugin.xml
deleted file mode 100644
index 39336b1..0000000
--- a/org.eclipse.jdt.core.tests.compiler/plugin.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<plugin
- id="org.eclipse.jdt.core.tests.compiler"
- name="Java Compiler Tests"
- version="2.1.0">
-
- <runtime>
- <library name="jdtcoretestscompiler.jar"/>
- </runtime>
- <requires>
- <import plugin="org.junit"/>
- <import plugin="org.eclipse.jdt.debug"/>
- <import plugin="org.eclipse.jdt.core"/>
- </requires>
-
-
-</plugin>
diff --git a/org.eclipse.jdt.core.tests.compiler/src/EvalTestsTarget.zip b/org.eclipse.jdt.core.tests.compiler/src/EvalTestsTarget.zip
deleted file mode 100644
index 19bb2e9..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/EvalTestsTarget.zip
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractCompletionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractCompletionTest.java
deleted file mode 100644
index 2afccce..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractCompletionTest.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-import java.util.Locale;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
-import org.eclipse.jdt.internal.codeassist.complete.CompletionScanner;
-import org.eclipse.jdt.internal.compiler.CompilationResult;
-import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.AstNode;
-import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Initializer;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
-import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
-
-public abstract class AbstractCompletionTest extends TestCase {
-
- public final static String NONE = "<NONE>";
-public AbstractCompletionTest(String testName){
- super(testName);
-}
-/*
- * DietParse with completionNode check
- */
-public void checkDietParse(
- char[] source,
- int cursorLocation,
- String expectedCompletion,
- String expectedUnitToString,
- String expectedCompletionIdentifier,
- String expectedReplacedSource,
- String testName) {
-
- CompilerOptions options = new CompilerOptions();
- CompletionParser parser =
- new CompletionParser(
- new ProblemReporter(
- DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- options,
- new DefaultProblemFactory(Locale.getDefault())),
- options.sourceLevel >= CompilerOptions.JDK1_4);
-
- ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null);
- CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
-
- CompilationUnitDeclaration unit = parser.dietParse(sourceUnit, compilationResult, cursorLocation);
-
- String computedCompletion = parser.assistNode == null
- ? NONE
- : parser.assistNode.toString(0);
- String computedUnitToString = unit.toString();
- //System.out.println(computedUnitToString);
- //System.out.println(Util.displayString(computedUnitToString));
- //System.out.println(expectedUnitToString);
-
- assertEquals(
- "invalid completion node-" + testName,
- expectedCompletion,
- computedCompletion);
-
- assertEquals(
- "invalid completion tree-" + testName,
- expectedUnitToString,
- computedUnitToString);
-
- if (expectedCompletionIdentifier != null){
- char[] chars = ((CompletionScanner)parser.scanner).completionIdentifier;
- String computedCompletionIdentifier = chars == null ? NONE : new String(chars);
- assertEquals(
- "invalid completion identifier-" + testName,
- expectedCompletionIdentifier,
- computedCompletionIdentifier);
- }
- if (expectedReplacedSource != null){
- char[] chars = null;
- if (parser.assistNode != null){
- chars = CharOperation.subarray(
- parser.scanner.source,
- parser.assistNode.sourceStart,
- parser.assistNode.sourceEnd + 1);
- } else {
- if (parser.assistIdentifier() != null){
- if (((CompletionScanner)parser.scanner).completedIdentifierEnd
- >= ((CompletionScanner)parser.scanner).completedIdentifierStart){
- chars = CharOperation.subarray(
- parser.scanner.source,
- ((CompletionScanner)parser.scanner).completedIdentifierStart,
- ((CompletionScanner)parser.scanner).completedIdentifierEnd + 1);
- }
- }
- }
- String computedReplacedSource = chars == null ? NONE : new String(chars);
- assertEquals(
- "invalid replaced source-" + testName,
- expectedReplacedSource,
- computedReplacedSource);
- }
-}
-/*
- * Parse a method with completionNode check
- */
-public void checkMethodParse(
- char[] source,
- int cursorLocation,
- String expectedCompletion,
- String expectedUnitToString,
- String expectedCompletionIdentifier,
- String expectedReplacedSource,
- String[] expectedLabels,
- String testName) {
-
- CompilerOptions options = new CompilerOptions();
- CompletionParser parser =
- new CompletionParser(
- new ProblemReporter(
- DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- options,
- new DefaultProblemFactory(Locale.getDefault())),
- options.sourceLevel >= CompilerOptions.JDK1_4);
-
- ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null);
- CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
-
- CompilationUnitDeclaration unit = parser.dietParse(sourceUnit, compilationResult, cursorLocation);
-
- AstNode foundMethod = null;
- if (unit.types != null) {
- for (int i = 0; i < unit.types.length; i++) {
- TypeDeclaration type = unit.types[i];
- AstNode method = findMethod(type, cursorLocation);
- if (method != null) {
- foundMethod = method;
- break;
- }
- }
- }
- assertTrue("no method found at cursor location", foundMethod != null);
- if (foundMethod instanceof AbstractMethodDeclaration) {
- parser.parseBlockStatements((AbstractMethodDeclaration)foundMethod, unit);
- } else {
- TypeDeclaration type = (TypeDeclaration)foundMethod;
- if (type.fields != null) {
- for (int i = 0; i < type.fields.length; i++) {
- FieldDeclaration field = type.fields[i];
- if (field.declarationSourceStart <= cursorLocation && (cursorLocation <= field.declarationSourceEnd || field.declarationSourceEnd == 0)) {
- if (field instanceof Initializer) {
- parser.parseBlockStatements((Initializer)field, type, unit);
- break;
- } else {
- assertTrue("TBD", false); // field initializer
- }
- }
- }
- }
- }
-
- String computedCompletion = parser.assistNode == null
- ? NONE
- : parser.assistNode.toString(0);
- String computedUnitToString = unit.toString();
- //System.out.println(computedUnitToString);
- //System.out.println(Util.displayString(computedUnitToString));
- //System.out.println(expectedUnitToString);
-
- assertEquals(
- "invalid completion node-" + testName,
- expectedCompletion,
- computedCompletion);
-
- assertEquals(
- "invalid completion location-"+testName,
- expectedUnitToString,
- computedUnitToString);
-
- if (expectedCompletionIdentifier != null){
- char[] chars = ((CompletionScanner)parser.scanner).completionIdentifier;
- String computedCompletionIdentifier = chars == null ? NONE : new String(chars);
- assertEquals(
- "invalid completion identifier-" + testName,
- expectedCompletionIdentifier,
- computedCompletionIdentifier);
- }
- if (expectedReplacedSource != null){
- char[] chars = null;
- if (parser.assistNode != null){
- chars = CharOperation.subarray(
- parser.scanner.source,
- parser.assistNode.sourceStart,
- parser.assistNode.sourceEnd + 1);
- } else {
- if (parser.assistIdentifier() != null){
- if (((CompletionScanner)parser.scanner).completedIdentifierEnd
- >= ((CompletionScanner)parser.scanner).completedIdentifierStart){
- chars = CharOperation.subarray(
- parser.scanner.source,
- ((CompletionScanner)parser.scanner).completedIdentifierStart,
- ((CompletionScanner)parser.scanner).completedIdentifierEnd + 1);
- }
- }
- }
- String computedReplacedSource = chars == null ? NONE : new String(chars);
- assertEquals(
- "invalid replaced source-" + testName,
- expectedReplacedSource,
- computedReplacedSource);
- if (expectedReplacedSource.length() == 0) {
- assertEquals(
- "invalid insertion point-" + testName,
- cursorLocation + 1,
- parser.assistNode.sourceStart);
- }
- }
-// if (expectedLabels != null) {
-// int length = (parser.labels == null) ? 0 : parser.labels.length;
-// assertEquals("invalid number of labels-" + testName, expectedLabels.length, length);
-// for (int i = 0; i < length; i++) {
-// String label = new String(parser.labels[i]);
-// assertEquals("invalid label-" + testName, expectedLabels[i], label);
-// }
-// }
-}
-/*
- * Parse a method with completionNode check
- */
-public void checkMethodParse(
- char[] source,
- int cursorLocation,
- String expectedCompletion,
- String expectedUnitToString,
- String expectedCompletionIdentifier,
- String expectedReplacedSource,
- String testName) {
-
- this.checkMethodParse(
- source,
- cursorLocation,
- expectedCompletion,
- expectedUnitToString,
- expectedCompletionIdentifier,
- expectedReplacedSource,
- null,
- testName);
-}
-/*
- * Returns the method, the constructor or the type declaring the initializer
- * at the cursor location in the given type.
- * Returns null if not found.
- */
-private AstNode findMethod(TypeDeclaration type, int cursorLocation) {
- if (type.methods != null) {
- for (int i = 0; i < type.methods.length; i++) {
- AbstractMethodDeclaration method = type.methods[i];
- if (method.declarationSourceStart <= cursorLocation && (cursorLocation <= method.declarationSourceEnd || method.declarationSourceEnd == 0)) {
- return method;
- }
- }
- }
- if (type.memberTypes != null) {
- for (int i = 0; i < type.memberTypes.length; i++) {
- TypeDeclaration memberType = type.memberTypes[i];
- AstNode method = findMethod(memberType, cursorLocation);
- if (method != null) {
- return method;
- }
- }
- }
- if (type.fields != null) {
- for (int i = 0; i < type.fields.length; i++) {
- FieldDeclaration field = type.fields[i];
- if (field instanceof Initializer && field.declarationSourceStart <= cursorLocation && (cursorLocation <= field.declarationSourceEnd || field.declarationSourceEnd == 0)) {
- return type;
- }
- }
- }
- return null;
-}
-/**
- * Runs the given test that checks that diet completion parsing returns the given completion.
- */
-protected void runTestCheckDietParse(
- String compilationUnit,
- String completeBehind,
- String expectedCompletionNodeToString,
- String expectedUnitDisplayString,
- String expectedCompletionIdentifier,
- String expectedReplacedSource,
- String testName) {
-
- int cursorLocation = compilationUnit.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- compilationUnit.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- expectedCompletionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/**
- * Runs the given test that checks that method completion parsing returns the given completion.
- */
-protected void runTestCheckMethodParse(
- String compilationUnit,
- String completeBehind,
- String expectedCompletionNodeToString,
- String expectedUnitDisplayString,
- String expectedCompletionIdentifier,
- String expectedReplacedSource,
- String[] expectedLabels,
- String testName) {
-
- int completeBehindStart = compilationUnit.indexOf(completeBehind);
- assertTrue("completeBehind string not found", completeBehindStart >= 0);
- int cursorLocation = completeBehindStart + completeBehind.length() - 1;
- this.checkMethodParse(
- compilationUnit.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- expectedCompletionIdentifier,
- expectedReplacedSource,
- expectedLabels,
- testName);
-}
-/**
- * Runs the given test that checks that method completion parsing returns the given completion.
- */
-protected void runTestCheckMethodParse(
- String compilationUnit,
- String completeBehind,
- String expectedCompletionNodeToString,
- String expectedUnitDisplayString,
- String expectedCompletionIdentifier,
- String expectedReplacedSource,
- String testName) {
-
- this.runTestCheckMethodParse(
- compilationUnit,
- completeBehind,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- expectedCompletionIdentifier,
- expectedReplacedSource,
- null,
- testName);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSelectionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSelectionTest.java
deleted file mode 100644
index 3a53369..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSelectionTest.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-import java.util.Locale;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jdt.internal.codeassist.select.SelectionParser;
-import org.eclipse.jdt.internal.codeassist.select.SelectionScanner;
-import org.eclipse.jdt.internal.compiler.CompilationResult;
-import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.AstNode;
-import org.eclipse.jdt.internal.compiler.ast.Block;
-import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Initializer;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
-import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
-
-public abstract class AbstractSelectionTest extends TestCase {
-
- public final static String NONE = "<NONE>";
-public AbstractSelectionTest(String testName){
- super(testName);
-}
-/*
- * DietParse with selectionNode check
- */
-public void checkDietParse(
- char[] source,
- int selectionStart,
- int selectionEnd,
- String expectedSelection,
- String expectedUnitToString,
- String expectedSelectionIdentifier,
- String expectedSelectedSource,
- String testName) {
-
- CompilerOptions options = new CompilerOptions();
- SelectionParser parser =
- new SelectionParser(
- new ProblemReporter(
- DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- options,
- new DefaultProblemFactory(Locale.getDefault())),
- options.sourceLevel >= CompilerOptions.JDK1_4);
-
- ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null);
- CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
-
- CompilationUnitDeclaration unit = parser.dietParse(sourceUnit, compilationResult, selectionStart, selectionEnd);
-
- String computedUnitToString = unit.toString();
- //System.out.println(computedUnitToString);
- //System.out.println(Util.displayString(computedUnitToString));
- //System.out.println(expectedUnitToString);
-
- String computedSelection = parser.assistNode == null
- ? NONE
- : parser.assistNode.toString(0);
- assertEquals(
- "invalid selection node-" + testName,
- expectedSelection,
- computedSelection);
-
- assertEquals(
- "invalid selection tree-" + testName,
- expectedUnitToString,
- computedUnitToString);
-
- if (expectedSelectionIdentifier != null){
- char[] chars = ((SelectionScanner)parser.scanner).selectionIdentifier;
- String computedSelectionIdentifier = chars == null ? NONE : new String(chars);
- assertEquals(
- "invalid selection identifier-" + testName,
- expectedSelectionIdentifier,
- computedSelectionIdentifier);
- }
- if (expectedSelectedSource != null){
- char[] chars = null;
- if (parser.assistNode != null){
- chars = CharOperation.subarray(
- parser.scanner.source,
- parser.assistNode.sourceStart,
- parser.assistNode.sourceEnd + 1);
- } else {
- if (parser.assistIdentifier() != null){
- if (((SelectionScanner)parser.scanner).selectionEnd
- >= ((SelectionScanner)parser.scanner).selectionStart){
- chars = CharOperation.subarray(
- parser.scanner.source,
- ((SelectionScanner)parser.scanner).selectionStart,
- ((SelectionScanner)parser.scanner).selectionEnd + 1);
- }
- }
- }
- String computedSelectedSource = chars == null ? NONE : new String(chars);
- assertEquals(
- "invalid replaced source-" + testName,
- expectedSelectedSource,
- computedSelectedSource);
- }
-}
-/*
- * Parse a method with selectionNode check
- */
-public void checkMethodParse(
- char[] source,
- int selectionStart,
- int selectionEnd,
- String expectedSelection,
- String expectedUnitToString,
- String expectedSelectionIdentifier,
- String expectedSelectedSource,
- String[] expectedLabels,
- String testName) {
-
- CompilerOptions options = new CompilerOptions();
- SelectionParser parser =
- new SelectionParser(
- new ProblemReporter(
- DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- options,
- new DefaultProblemFactory(Locale.getDefault())),
- options.sourceLevel >= CompilerOptions.JDK1_4);
-
- ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null);
- CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
-
- CompilationUnitDeclaration unit = parser.dietParse(sourceUnit, compilationResult, selectionStart, selectionEnd);
-
- AstNode foundMethod = null;
- if (unit.types != null) {
- for (int i = 0; i < unit.types.length; i++) {
- TypeDeclaration type = unit.types[i];
- AstNode method = findMethod(type, selectionStart);
- if (method != null) {
- foundMethod = method;
- break;
- }
- }
- }
- assertTrue("no method found at cursor location", foundMethod != null);
- if (foundMethod instanceof AbstractMethodDeclaration) {
- parser.parseBlockStatements((AbstractMethodDeclaration)foundMethod, unit);
- } else {
- TypeDeclaration type = (TypeDeclaration)foundMethod;
- if (type.fields != null) {
- for (int i = 0; i < type.fields.length; i++) {
- FieldDeclaration field = type.fields[i];
- if (field instanceof Initializer && field.sourceStart <= selectionStart && selectionStart <= field.sourceEnd) {
- parser.parseBlockStatements((Initializer)field, type, unit);
- break;
- }
- }
- }
- }
-
- String computedUnitToString = unit.toString();
- //System.out.println(computedUnitToString);
- //System.out.println(Util.displayString(computedUnitToString));
- //System.out.println(expectedUnitToString);
-
- String computedCompletion = parser.assistNode == null
- ? NONE
- : parser.assistNode.toString(0);
- assertEquals(
- "invalid selection node-" + testName,
- expectedSelection,
- computedCompletion);
-
- assertEquals(
- "invalid selection location-"+testName,
- expectedUnitToString,
- computedUnitToString);
-
- if (expectedSelectionIdentifier != null){
- char[] chars = ((SelectionScanner)parser.scanner).selectionIdentifier;
- String computedSelectionIdentifier = chars == null ? NONE : new String(chars);
- assertEquals(
- "invalid selection identifier-" + testName,
- expectedSelectionIdentifier,
- computedSelectionIdentifier);
- }
- if (expectedSelectedSource != null){
- char[] chars = null;
- if (parser.assistNode != null){
- chars = CharOperation.subarray(
- parser.scanner.source,
- parser.assistNode.sourceStart,
- parser.assistNode.sourceEnd + 1);
- } else {
- if (parser.assistIdentifier() != null){
- if (((SelectionScanner)parser.scanner).selectionEnd
- >= ((SelectionScanner)parser.scanner).selectionStart){
- chars = CharOperation.subarray(
- parser.scanner.source,
- ((SelectionScanner)parser.scanner).selectionStart,
- ((SelectionScanner)parser.scanner).selectionEnd + 1);
- }
- }
- }
- String computedReplacedSource = chars == null ? NONE : new String(chars);
- assertEquals(
- "invalid replaced source-" + testName,
- expectedSelectedSource,
- computedReplacedSource);
- }
-/*
- if (expectedLabels != null) {
- assert("no labels-" + testName, parser.labels != null);
- int length = parser.labels.length;
- assertEquals("invalid number of labels-" + testName, expectedLabels.length, length);
- for (int i = 0; i < length; i++) {
- String label = new String(parser.labels[i]);
- assertEquals("invalid label-" + testName, expectedLabels[i], label);
- }
- }
-*/
-}
-/*
- * Parse a method with selectionNode check
- */
-public void checkMethodParse(
- char[] source,
- int selectionStart,
- int selectionEnd,
- String expectedSelection,
- String expectedUnitToString,
- String expectedSelectionIdentifier,
- String expectedSelectedSource,
- String testName) {
-
- this.checkMethodParse(
- source,
- selectionStart,
- selectionEnd,
- expectedSelection,
- expectedUnitToString,
- expectedSelectionIdentifier,
- expectedSelectedSource,
- null,
- testName);
-}
-/*
- * Returns the method, the constructor or the type declaring the initializer
- * at the cursor location in the given type.
- * Returns null if not found.
- */
-private AstNode findMethod(TypeDeclaration type, int cursorLocation) {
- if (type.methods != null) {
- for (int i = 0; i < type.methods.length; i++) {
- AbstractMethodDeclaration method = type.methods[i];
- if (method.declarationSourceStart <= cursorLocation && (cursorLocation <= method.declarationSourceEnd || method.declarationSourceEnd == 0)) {
- return method;
- }
- }
- }
- if (type.memberTypes != null) {
- for (int i = 0; i < type.memberTypes.length; i++) {
- TypeDeclaration memberType = type.memberTypes[i];
- AstNode method = findMethod(memberType, cursorLocation);
- if (method != null) {
- return method;
- }
- }
- }
- if (type.fields != null) {
- for (int i = 0; i < type.fields.length; i++) {
- FieldDeclaration field = type.fields[i];
- if (field instanceof Initializer) {
- Initializer initializer = (Initializer)field;
- Block block = initializer.block;
- if (block != null && block.sourceStart <= cursorLocation && (cursorLocation <= block.sourceEnd || block.sourceEnd == 0)) {
- return type;
- }
- }
- }
- }
- return null;
-}
-/**
- * Runs the given test that checks that method completion parsing returns the given completion.
- */
-protected void runTestCheckMethodParse(
- String compilationUnit,
- String selectionStartBehind,
- String selectionEndBehind,
- String expectedSelectionNodeToString,
- String expectedUnitDisplayString,
- String expectedSelectionIdentifier,
- String expectedReplacedSource,
- String testName) {
-
- int selectionStartBehindStart = compilationUnit.indexOf(selectionStartBehind);
- assertTrue("selectionStartBehind string not found", selectionStartBehindStart != -1);
- int selectionStart = selectionStartBehindStart + selectionStartBehind.length();
- int selectionEndBehindStart = compilationUnit.indexOf(selectionEndBehind);
- assertTrue("selectionEndBehind string not found", selectionEndBehindStart != -1);
- int selectionEnd = selectionEndBehindStart + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- compilationUnit.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedSelectionNodeToString,
- expectedUnitDisplayString,
- expectedSelectionIdentifier,
- expectedReplacedSource,
- testName);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AllocationExpressionCompletionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AllocationExpressionCompletionTest.java
deleted file mode 100644
index caad1f0..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AllocationExpressionCompletionTest.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-/**
- * Completion is expected to be an AllocationExpression.
- */
-public class AllocationExpressionCompletionTest extends AbstractCompletionTest {
-public AllocationExpressionCompletionTest(String testName) {
- super(testName);
-}
-
-/*
- * Completion inside an if statement.
- */
-public void testInIfStatement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " if (true) { \n" +
- " new z.y.X(1, 2, i); \n" +
- " } \n" +
- " } \n" +
- "}\n",
- // completeBehind:
- "X(1, 2,",
- // expectedCompletionNodeToString:
- "<CompleteOnAllocationExpression:new z.y.X(1, 2)>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " <CompleteOnAllocationExpression:new z.y.X(1, 2)>;\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete inside an if statement>"
- );
-}
-/*
- * Completion on a constructor invocation with no qualification and using a qualified type name.
- *
- * ie. ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
- * where ClassType is a qualified type name
- */
-public void testNoQualificationQualifiedTypeName() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " new z.y.X(1, 2, i); \n" +
- " } \n" +
- "}\n",
- // completeBehind:
- "X(1, 2,",
- // expectedCompletionNodeToString:
- "<CompleteOnAllocationExpression:new z.y.X(1, 2)>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnAllocationExpression:new z.y.X(1, 2)>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete on non qualified instance creation with qualified type name>"
- );
-}
-/*
- * Completion on a constructor invocation with no qualification and using a simple type name.
- *
- * ie. ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
- * where ClassType is a simple type name
- */
-public void testNoQualificationSimpleTypeName() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " new X(1, 2, i); \n" +
- " } \n" +
- "}\n",
- // completeBehind:
- "X(1, 2,",
- // expectedCompletionNodeToString:
- "<CompleteOnAllocationExpression:new X(1, 2)>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnAllocationExpression:new X(1, 2)>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete on non qualified instance creation with simple type name>"
- );
-}
-/*
- * Completion on a constructor invocation qualified with a name.
- *
- * ie. ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testQualifiedWithName() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar {\n" +
- " void foo() { \n" +
- " Buz.x.new X(1, 2, i); \n" +
- " } \n" +
- "}\n",
- // completeBehind:
- "X(1, 2,",
- // expectedCompletionNodeToString:
- "<CompleteOnQualifiedAllocationExpression:Buz.x.new X(1, 2)>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnQualifiedAllocationExpression:Buz.x.new X(1, 2)>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete on name qualified instance creation>"
- );
-}
-/*
- * Completion on a constructor invocation qualified with a primary.
- *
- * ie. ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testQualifiedWithPrimary() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " primary().new X(1, 2, i); \n" +
- " } \n" +
- "}\n",
- // completeBehind:
- "X(1, 2,",
- // expectedCompletionNodeToString:
- "<CompleteOnQualifiedAllocationExpression:primary().new X(1, 2)>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnQualifiedAllocationExpression:primary().new X(1, 2)>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete on primary qualified instance creation>"
- );
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ClassLiteralAccessCompletionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ClassLiteralAccessCompletionTest.java
deleted file mode 100644
index 96be787..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ClassLiteralAccessCompletionTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-/**
- * Completion is expected to be a ClassLiteralAccess.
- */
-public class ClassLiteralAccessCompletionTest extends AbstractCompletionTest {
-public ClassLiteralAccessCompletionTest(String testName) {
- super(testName);
-}
-/*
- * Completion on the keyword 'class' on an array type
- */
-public void testArrayType() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " String[].; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "String[].",
- // expectedCompletionNodeToString:
- "<CompleteOnClassLiteralAccess:String[].>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnClassLiteralAccess:String[].>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "String[].",
- // test name
- "<complete on array type member>"
- );
-}
-/*
- * Test access to the keyword 'class' on an array type
- * where the keyword is non empty.
- */
-public void testArrayTypeWithNonEmptyIdentifier() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " String[].class; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "String[].cl",
- // expectedCompletionNodeToString:
- "<CompleteOnClassLiteralAccess:String[].cl>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnClassLiteralAccess:String[].cl>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "cl",
- // expectedReplacedSource:
- "String[].class",
- // test name
- "<complete on array type member with non empty identifier>"
- );
-}
-/*
- * Completion on the keyword 'class' on a primitive array type
- */
-public void testPrimitiveArrayType() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int[].; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "int[].",
- // expectedCompletionNodeToString:
- "<CompleteOnClassLiteralAccess:int[].>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnClassLiteralAccess:int[].>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "int[].",
- // test name
- "<complete on primitive array type member>"
- );
-}
-/*
- * Completion on the keyword 'class' on a primitive array type where the
- * keyword is non empty
- */
-public void testPrimitiveArrayTypeWithNonEmptyIdentifier() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int[].class; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "int[].cl",
- // expectedCompletionNodeToString:
- "<CompleteOnClassLiteralAccess:int[].cl>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnClassLiteralAccess:int[].cl>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "cl",
- // expectedReplacedSource:
- "int[].class",
- // test name
- "<complete on primitive array type member with non empty identifier>"
- );
-}
-/*
- * Completion on the keyword 'class' on a primitive type
- */
-public void testPrimitiveType() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int.; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "int.",
- // expectedCompletionNodeToString:
- "<CompleteOnClassLiteralAccess:int.>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnClassLiteralAccess:int.>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "int.",
- // test name
- "<complete on primitive type member>"
- );
-}
-/*
- * Completion on the keyword 'class' on a primitive type where the
- * keyword is non empty
- */
-public void testPrimitiveTypeWithNonEmptyIdentifier() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int.class; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "int.cl",
- // expectedCompletionNodeToString:
- "<CompleteOnClassLiteralAccess:int.cl>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnClassLiteralAccess:int.cl>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "cl",
- // expectedReplacedSource:
- "int.class",
- // test name
- "<complete on primitive type member with non empty identifier>"
- );
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java
deleted file mode 100644
index 774fb82..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest.java
+++ /dev/null
@@ -1,8387 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-import org.eclipse.jdt.core.tests.compiler.parser.*;
-import org.eclipse.jdt.internal.codeassist.complete.*;
-
-public class CompletionParserTest extends AbstractCompletionTest {
-public CompletionParserTest(String testName) {
- super(testName);
-}
-public void testA() {
- String str =
- "package p; \n" +
- "public class A {\n" +
- " public void foo(\n" +
- " java.util.Locale, \n" +
- " java.util.Vector) {\n" +
- " int i;\n" +
- " if (i instanceof O) {\n" +
- " }\n" +
- " String s = \"hello\";\n" +
- " s.}\n" +
- "}\n";
-
- String testName = "<complete on methods/fields>";
- String completeBehind = "s.";
- String expectedCompletionNodeToString = "<CompleteOnName:s.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "s.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class A {\n" +
- " public A() {\n" +
- " }\n" +
- " public void foo() {\n" +
- " {\n" +
- " int i;\n" +
- " String s;\n" +
- " <CompleteOnName:s.>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testAA_1() {
- String str =
- "package p; \n" +
- "import something; \n" +
- "import p2.; \n" +
- "public class AA {\n" +
- " void foo() {\n" +
- " int maxUnits = 0;\n" +
- " for (int i = 0; \n" +
- " i < maxUnits; \n" +
- " i++) {\n" +
- " CompilationUnitResult unitResult = \n" +
- " new CompilationUnitResult(\n" +
- " null, \n" +
- " i, \n" +
- " maxUnits); \n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String completeBehind = "n";
- String expectedCompletionNodeToString = "<CompleteOnName:n>";
- String completionIdentifier = "n";
- String expectedUnitDisplayString =
- "package p;\n" +
- "import something;\n" +
- "public class AA {\n" +
- " public AA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int maxUnits;\n" +
- " int i;\n" +
- " {\n" +
- " CompilationUnitResult unitResult = <CompleteOnName:n>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "new";
- String testName = "<complete on initializer (new)>";
-
- int cursorLocation = str.indexOf("new CompilationUnitResult(") + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testAA_2() {
- String str =
- "package p; \n" +
- "import something; \n" +
- "import p2.; \n" +
- "public class AA {\n" +
- " void foo() {\n" +
- " int maxUnits = 0;\n" +
- " for (int i = 0; \n" +
- " i < maxUnits; \n" +
- " i++) {\n" +
- " CompilationUnitResult unitResult = \n" +
- " new CompilationUnitResult(\n" +
- " null, \n" +
- " i, \n" +
- " maxUnits); \n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method call argument>";
- String completeBehind = "n";
- String expectedCompletionNodeToString = "<CompleteOnName:n>";
- String completionIdentifier = "n";
- String expectedReplacedSource = "null";
- int cursorLocation = str.indexOf("null, ") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import something;\n" +
- "public class AA {\n" +
- " public AA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int maxUnits;\n" +
- " int i;\n" +
- " {\n" +
- " CompilationUnitResult unitResult;\n" +
- " <CompleteOnName:n>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testAA_3() {
- String str =
- "package p; \n" +
- "import something; \n" +
- "import p2.; \n" +
- "public class AA {\n" +
- " void foo() {\n" +
- " int maxUnits = 0;\n" +
- " for (int i = 0; \n" +
- " i < maxUnits; \n" +
- " i++) {\n" +
- " CompilationUnitResult unitResult = \n" +
- " new CompilationUnitResult(\n" +
- " null, \n" +
- " i, \n" +
- " maxUnits); \n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on call to constructor argument>";
- String completeBehind = "i";
- String expectedCompletionNodeToString = "<CompleteOnName:i>";
- String completionIdentifier = "i";
- String expectedReplacedSource = "i";
- int cursorLocation = str.indexOf("i, ") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import something;\n" +
- "public class AA {\n" +
- " public AA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int maxUnits;\n" +
- " int i;\n" +
- " {\n" +
- " CompilationUnitResult unitResult;\n" +
- " <CompleteOnName:i>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testAA_4() {
- String str =
- "package p; \n" +
- "import something; \n" +
- "import p2.; \n" +
- "public class AA {\n" +
- " void foo() {\n" +
- " int maxUnits = 0;\n" +
- " for (int i = 0; \n" +
- " i < maxUnits; \n" +
- " i++) {\n" +
- " CompilationUnitResult unitResult = \n" +
- " new CompilationUnitResult(\n" +
- " null, \n" +
- " i, \n" +
- " maxUnits); \n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on constructor call argument>";
- String completeBehind = "max";
- String expectedCompletionNodeToString = "<CompleteOnName:max>";
- String completionIdentifier = "max";
- String expectedReplacedSource = "maxUnits";
- int cursorLocation = str.indexOf("maxUnits); ") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import something;\n" +
- "public class AA {\n" +
- " public AA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int maxUnits;\n" +
- " int i;\n" +
- " {\n" +
- " CompilationUnitResult unitResult;\n" +
- " <CompleteOnName:max>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testAB_1FHU9LU() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHU9LU\n" +
- " */\n" +
- "class SuperClass {\n" +
- " static void eFooStatic() {\n" +
- " }\n" +
- " void eFoo() {\n" +
- " }\n" +
- "}\n" +
- "public class AB\n" +
- " extends SuperClass {\n" +
- " void eBar() {\n" +
- " super.eFoo();\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on methods/fields from super class>";
- String completeBehind = "super.";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:super.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "super.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class SuperClass {\n" +
- " SuperClass() {\n" +
- " }\n" +
- " static void eFooStatic() {\n" +
- " }\n" +
- " void eFoo() {\n" +
- " }\n" +
- "}\n" +
- "public class AB extends SuperClass {\n" +
- " public AB() {\n" +
- " }\n" +
- " void eBar() {\n" +
- " <CompleteOnMemberAccess:super.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testAC_1FJ8D9Z_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FJ8D9Z\n" +
- " */\n" +
- "import java.io.*;\n" +
- "public class AC {\n" +
- " AC() {\n" +
- " }\n" +
- " AC(int i) {\n" +
- " }\n" +
- " AC(int i, String s) {\n" +
- " }\n" +
- " void foo() {\n" +
- " new AC(new File(\n" +
- " new java\n" +
- " .util\n" +
- " .Vector(}\n" +
- "}\n";
-
- String testName = "<complete on constructor argument>";
- String completeBehind = "new AC(";
- String expectedCompletionNodeToString = "<CompleteOnAllocationExpression:new AC()>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import java.io.*;\n" +
- "public class AC {\n" +
- " AC() {\n" +
- " }\n" +
- " AC(int i) {\n" +
- " }\n" +
- " AC(int i, String s) {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnAllocationExpression:new AC()>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testAC_1FJ8D9Z_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FJ8D9Z\n" +
- " */\n" +
- "import java.io.*;\n" +
- "public class AC {\n" +
- " AC() {\n" +
- " }\n" +
- " AC(int i) {\n" +
- " }\n" +
- " AC(int i, String s) {\n" +
- " }\n" +
- " void foo() {\n" +
- " new AC(new File(\n" +
- " new java\n" +
- " .util\n" +
- " .Vector(}\n" +
- "}\n";
-
- String testName = "<complete on constructor argument>";
- String completeBehind = "new File(";
- String expectedCompletionNodeToString = "<CompleteOnAllocationExpression:new File()>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import java.io.*;\n" +
- "public class AC {\n" +
- " AC() {\n" +
- " }\n" +
- " AC(int i) {\n" +
- " }\n" +
- " AC(int i, String s) {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnAllocationExpression:new File()>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testAC_1FJ8D9Z_3() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FJ8D9Z\n" +
- " */\n" +
- "import java.io.*;\n" +
- "public class AC {\n" +
- " AC() {\n" +
- " }\n" +
- " AC(int i) {\n" +
- " }\n" +
- " AC(int i, String s) {\n" +
- " }\n" +
- " void foo() {\n" +
- " new AC(new File(\n" +
- " new java.util.Vector(}\n" +
- "}\n";
-
- String testName = "<complete on constructor argument>";
- String completeBehind = "new java.util.Vector(";
- String expectedCompletionNodeToString = "<CompleteOnAllocationExpression:new java.util.Vector()>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import java.io.*;\n" +
- "public class AC {\n" +
- " AC() {\n" +
- " }\n" +
- " AC(int i) {\n" +
- " }\n" +
- " AC(int i, String s) {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnAllocationExpression:new java.util.Vector()>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testB() {
- String str =
- "package p; \n" +
- "public class B {\n" +
- " Object o = new Object }\n";
-
- String testName = "<complete on type into type creation>";
- String completeBehind = "new Object";
- String expectedCompletionNodeToString = "<CompleteOnType:Object>";
- String completionIdentifier = "Object";
- String expectedReplacedSource = "Object";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class B {\n" +
- " Object o = new <CompleteOnType:Object>();\n" +
- " public B() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testBA_1() {
- String str =
- "package p; \n" +
- "public class BA {\n" +
- " void foo() {\n" +
- " java.util.Vector v2;\n" +
- " java.util.Vector v1;\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on package name>";
- String completeBehind = "java.";
- String expectedCompletionNodeToString = "<CompleteOnName:java.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "java.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class BA {\n" +
- " public BA() {\n" +
-
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:java.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testBA_2() {
- String str =
- "package p; \n" +
- "public class BA {\n" +
- " void foo() {\n" +
- " java.util.Vector v2;\n" +
- " java.util.Vector v1;\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on package contents>";
- String completeBehind = "java.util.";
- String expectedCompletionNodeToString = "<CompleteOnName:java.util.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "java.util.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class BA {\n" +
- " public BA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:java.util.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testBB_1FHJ8H9() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHJ8H9\n" +
- " */\n" +
- "public class BB {\n" +
- " void bar() {\n" +
- " f }\n" +
- "}\n";
-
- String testName = "<complete on method/field from implicit method call>";
- String completeBehind = "f";
- String expectedCompletionNodeToString = "<CompleteOnName:f>";
- String completionIdentifier = "f";
- String expectedReplacedSource = "f";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class BB {\n" +
- " public BB() {\n" +
- " }\n" +
- " void bar() {\n" +
- " <CompleteOnName:f>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testBC_1FJ4GSG_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FJ4GSG\n" +
- " */\n" +
- "import java.util.Vector;\n" +
- "public class BC {\n" +
- " int Value1 = 0;\n" +
- " interface Constants {\n" +
- " int OK = 1;\n" +
- " int CANCEL = 2;\n" +
- " }\n" +
- " void foo() {\n" +
- " Vector v = \n" +
- " new Vector(\n" +
- " Value1, \n" +
- " BC.Constants.OK\n" +
- " | BC.Constants.CANCEL); \n" +
- " Object ans = v.elementAt(1);\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on member type>";
- String completeBehind = "BC.";
- String expectedCompletionNodeToString = "<CompleteOnName:BC.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "BC.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import java.util.Vector;\n" +
- "public class BC {\n" +
- " interface Constants {\n" +
- " int OK;\n" +
- " int CANCEL;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " }\n" +
- " int Value1;\n" +
- " public BC() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Vector v;\n" +
- " <CompleteOnName:BC.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testBC_1FJ4GSG_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FJ4GSG\n" +
- " */\n" +
- "import java.util.Vector;\n" +
- "public class BC {\n" +
- " int Value1 = 0;\n" +
- " interface Constants {\n" +
- " int OK = 1;\n" +
- " int CANCEL = 2;\n" +
- " }\n" +
- " void foo() {\n" +
- " Vector v = \n" +
- " new Vector(\n" +
- " Value1, \n" +
- " BC.Constants.OK\n" +
- " | BC.Constants.CANCEL); \n" +
- " Object ans = v.elementAt(1);\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on member type method/field>";
- String completeBehind = "| BC.Constants.";
- String expectedCompletionNodeToString = "<CompleteOnName:BC.Constants.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "BC.Constants.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import java.util.Vector;\n" +
- "public class BC {\n" +
- " interface Constants {\n" +
- " int OK;\n" +
- " int CANCEL;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " }\n" +
- " int Value1;\n" +
- " public BC() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Vector v;\n" +
- " <CompleteOnName:BC.Constants.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testBC_1FJ4GSG_3() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FJ4GSG\n" +
- " */\n" +
- "import java.util.Vector;\n" +
- "public class BC {\n" +
- " int Value1 = 0;\n" +
- " interface Constants {\n" +
- " int OK = 1;\n" +
- " int CANCEL = 2;\n" +
- " }\n" +
- " void foo() {\n" +
- " Vector v = \n" +
- " new Vector(\n" +
- " Value1, \n" +
- " BC.Constants.OK\n" +
- " | BC.Constants.CANCEL); \n" +
- " Object ans = v.elementAt(1);\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field>";
- String completeBehind = "v.";
- String expectedCompletionNodeToString = "<CompleteOnName:v.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "v.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import java.util.Vector;\n" +
- "public class BC {\n" +
- " interface Constants {\n" +
- " int OK;\n" +
- " int CANCEL;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " }\n" +
- " int Value1;\n" +
- " public BC() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Vector v;\n" +
- " Object ans = <CompleteOnName:v.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testC() {
- String str =
- "package p; \n" +
- "public class C {\n" +
- " void foo() {\n" +
- " String string = n;\n" +
- " }\n" +
- "}\n";
-
- String completeBehind = "= n";
- String expectedCompletionNodeToString = "<CompleteOnName:n>";
- String completionIdentifier = "n";
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class C {\n" +
- " public C() {\n" +
- " }\n" +
- " void foo() {\n" +
- " String string = <CompleteOnName:n>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "n";
- String testName = "<complete on local variable initializer>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testCA_1FGPJQZ() {
- String str =
- "package p; \n" +
- "import p2.X; \n" +
- "/**\n" +
- " * 1FGPJQZ\n" +
- " */\n" +
- "public class CA {\n" +
- " void moo() {\n" +
- " unknownField.}\n" +
- "}\n";
-
- String testName = "<complete on method/field>";
- String completeBehind = "unknownField.";
- String expectedCompletionNodeToString = "<CompleteOnName:unknownField.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "unknownField.";
- String expectedUnitDisplayString =
- "package p;\n" +
- "import p2.X;\n" +
- "public class CA {\n" +
- " public CA() {\n" +
- " }\n" +
- " void moo() {\n" +
- " <CompleteOnName:unknownField.>;\n" +
- " }\n" +
- "}\n";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testCB_1FHSKQ9_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHSKQ9\n" +
- " */\n" +
- "public class CB {\n" +
- " void foo() {\n" +
- " int i = 0;\n" +
- " int[] tab1 = new int[10];\n" +
- " int j = tab1[i];\n" +
- " System.out.println(\n" +
- " \" \" + (i + 1)); \n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method call argument>";
- String completeBehind = "+ (i";
- String expectedCompletionNodeToString = "<CompleteOnName:i>";
- String completionIdentifier = "i";
- String expectedReplacedSource = "i";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class CB {\n" +
- " public CB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " int[] tab1;\n" +
- " int j;\n" +
- " <CompleteOnName:i>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testCB_1FHSKQ9_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHSKQ9\n" +
- " */\n" +
- "public class CB {\n" +
- " void foo() {\n" +
- " int i = 0;\n" +
- " int[] tab1 = new int[10];\n" +
- " int j = tab1[i];\n" +
- " System.out.println(\n" +
- " \" \" + (i + 1)); \n" +
- " }\n" +
- "}\n";
-
- String completeBehind = "i + 1";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = "";
- String expectedUnitDisplayString = null;
- String expectedReplacedSource = NONE;
- String testName = "<complete on digit into method call argument>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
-
- try {
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
- assertTrue("failed to detect invalid cursor location", false);
- } catch(InvalidCursorLocation e){
- assertEquals("invalid cursor location: ", e.irritant, InvalidCursorLocation.NO_COMPLETION_INSIDE_NUMBER);
- }
-}
-public void testCC_1FJ64I9() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FJ64I9\n" +
- " */\n" +
- "class CCHelper {\n" +
- " class Member1 {\n" +
- " }\n" +
- " class Member2 {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n" +
- "public class CC {\n" +
- " void foo() {\n" +
- " new CCHelper()\n" +
- " .new CCHelper()\n" +
- " .new M }\n" +
- "}\n";
-
- String testName = "<complete on qualified member type>";
- String completeBehind = ".new M";
- String expectedCompletionNodeToString = "<CompleteOnType:M>";
- String completionIdentifier = "M";
- String expectedReplacedSource = "M";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class CCHelper {\n" +
- " class Member1 {\n" +
- " Member1() {\n" +
- " }\n" +
- " }\n" +
- " class Member2 {\n" +
- " Member2() {\n" +
- " }\n" +
- " }\n" +
- " CCHelper() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n" +
- "public class CC {\n" +
- " public CC() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new CCHelper().new CCHelper().new <CompleteOnType:M>();\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testD_1() {
- String str =
- "package p; \n" +
- "import java.util.*;\n" +
- "public class D {\n" +
- " static int i;\n" +
- " static {\n" +
- " i = 5;\n" +
- " }\n" +
- " public int j;\n" +
- " Vector a = new Vector();\n" +
- " void foo(String s) {\n" +
- " String string = null;\n" +
- " int soso;\n" +
- " float f;\n" +
- " string.regionMatches(\n" +
- " 0, \n" +
- " \"\", \n" +
- " 0, \n" +
- " 0); \n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on variable into type initializer>";
- String completeBehind = "i";
- String expectedCompletionNodeToString = "<CompleteOnName:i>";
- String completionIdentifier = "i";
- String expectedReplacedSource = "i";
- int cursorLocation = str.indexOf("i = 5;") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import java.util.*;\n" +
- "public class D {\n" +
- " static int i;\n" +
- " static {\n" +
- " <CompleteOnName:i>;\n" +
- " }\n" +
- " public int j;\n" +
- " Vector a;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public D() {\n" +
- " }\n" +
- " void foo(String s) {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testD_2() {
- String str =
- "package p; \n" +
- "import java.util.*;\n" +
- "public class D {\n" +
- " static int i;\n" +
- " static {\n" +
- " i = 5;\n" +
- " }\n" +
- " public int j;\n" +
- " Vector a = new Vector();\n" +
- " void foo(String s) {\n" +
- " String string = null;\n" +
- " int soso;\n" +
- " float f;\n" +
- " string.regionMatches(\n" +
- " 0, \n" +
- " \"\", \n" +
- " 0, \n" +
- " 0); \n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field>";
- String completeBehind = "string.";
- String expectedCompletionNodeToString = "<CompleteOnName:string.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "string.";
- String expectedUnitDisplayString =
- "package p;\n" +
- "import java.util.*;\n" +
- "public class D {\n" +
- " static int i;\n" +
- " static {\n" +
- " }\n" +
- " public int j;\n" +
- " Vector a;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public D() {\n" +
- " }\n" +
- " void foo(String s) {\n" +
- " String string;\n" +
- " int soso;\n" +
- " float f;\n" +
- " <CompleteOnName:string.>;\n" +
- " }\n" +
- "}\n";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testDA_1() {
- String str =
- "package p; \n" +
- "public class DA {\n" +
- " void foo() {\n" +
- " new TestCase(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field into anonymous declaration>";
- String completeBehind = "v";
- String expectedCompletionNodeToString = "<CompleteOnName:v>";
- String completionIdentifier = "v";
- String expectedReplacedSource = "v";
- int cursorLocation = str.indexOf("v }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class DA {\n" +
- " public DA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new TestCase(\"error\") {\n" +
- " () {\n" +
- " }\n" +
- " protected void runTest() {\n" +
- " Vector v11111;\n" +
- " <CompleteOnName:v>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testDA_2() {
- String str =
- "package p; \n" +
- "public class DA {\n" +
- " void foo() {\n" +
- " new TestCase(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- String completeBehind = "protected v";
- String expectedCompletionNodeToString = "<CompleteOnType:v>";
- String completionIdentifier = "v";
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class DA {\n" +
- " public DA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new TestCase(\"error\") {\n" +
- " <CompleteOnType:v>;\n" +
- " () {\n" +
- " }\n" +
- " runTest() {\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "void";
- String testName = "<complete on return type into anonymous declaration>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testDA_3() {
- String str =
- "package p; \n" +
- "public class DA {\n" +
- " void foo() {\n" +
- " new TestCase(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method selector into anonymous declaration>";
- String completeBehind = "r";
- String expectedCompletionNodeToString = "<CompleteOnFieldName:void r>";
- String completionIdentifier = "r";
- String expectedReplacedSource = "runTest";
- int cursorLocation = str.indexOf("runTest") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class DA {\n" +
- " public DA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new TestCase(\"error\") {\n" +
- " <CompleteOnFieldName:void r>;\n" +
- " {\n" +
- " }\n" +
- " () {\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testDA_4() {
- String str =
- "package p; \n" +
- "public class DA {\n" +
- " void foo() {\n" +
- " new TestCase(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on local variable type into anonymous declaration>";
- String completeBehind = "V";
- String expectedCompletionNodeToString = "<CompleteOnName:V>";
- String completionIdentifier = "V";
- String expectedReplacedSource = "Vector";
- int cursorLocation = str.indexOf("Vector v11111") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class DA {\n" +
- " public DA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new TestCase(\"error\") {\n" +
- " () {\n" +
- " }\n" +
- " protected void runTest() {\n" +
- " <CompleteOnName:V>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testDA_5() {
- String str =
- "package p; \n" +
- "public class DA {\n" +
- " void foo() {\n" +
- " new TestCase(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on local type into anonymous declaration>";
- String completeBehind = "v";
- String expectedCompletionNodeToString = "<CompleteOnName:v>";
- String completionIdentifier = "v";
- String expectedReplacedSource = "v";
- int cursorLocation = str.indexOf("v }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class DA {\n" +
- " public DA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new TestCase(\"error\") {\n" +
- " () {\n" +
- " }\n" +
- " protected void runTest() {\n" +
- " Vector v11111;\n" +
- " <CompleteOnName:v>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testDB_1FHSLDR() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHSLDR\n" +
- " */\n" +
- "public class DB {\n" +
- " void foo() {\n" +
- " try {\n" +
- " System.out.println(\"\");\n" +
- " }\n" +
- " fi }\n" +
- "}\n";
-
- String testName = "<complete on finally keyword>";
- String completeBehind = "fi";
- String expectedCompletionNodeToString = "<CompleteOnName:fi>";
- String completionIdentifier = "fi";
- String expectedReplacedSource = "fi";
- int cursorLocation = str.indexOf("fi }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class DB {\n" +
- " public DB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:fi>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testDC_1FJJ0JR_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FJJ0JR\n" +
- " */\n" +
- "public class DC\n" +
- " extends ModelChangeOperation {\n" +
- " ISec public SetSecondarySourceOperation(\n" +
- " ISecondarySourceContainer element, \n" +
- " VersionID id) {\n" +
- " }\n" +
- " protected abstract void doExecute(IProgressMonitor monitor)\n" +
- " throws OperationFailedException {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method return type>";
- String completeBehind = "ISec";
- String expectedCompletionNodeToString = "<CompleteOnType:ISec>";
- String completionIdentifier = "ISec";
- String expectedReplacedSource = "ISec";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class DC extends ModelChangeOperation {\n" +
- " <CompleteOnType:ISec>;\n" +
- " public DC() {\n" +
- " }\n" +
- " public SetSecondarySourceOperation(ISecondarySourceContainer element, VersionID id) {\n" +
- " }\n" +
- " protected abstract void doExecute(IProgressMonitor monitor) throws OperationFailedException;\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testE_1FG1YDS_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FG1YDS\n" +
- " */\n" +
- "public class E {\n" +
- " {\n" +
- " new Y()\n" +
- " }\n" +
- " {\n" +
- " new Y().}\n" +
- " class Y\n" +
- " extends java.util.Vector {\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on type into type creation>";
- String completeBehind = "Y";
- String expectedCompletionNodeToString = "<CompleteOnType:Y>";
- String completionIdentifier = "Y";
- String expectedReplacedSource = "Y";
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class E {\n" +
- " class Y extends java.util.Vector {\n" +
- " Y() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- " {\n" +
- " new <CompleteOnType:Y>();\n" +
- " }\n" +
- " {\n" +
- " }\n" +
- " public E() {\n" +
- " }\n" +
- "}\n";
-
- int cursorLocation = str.indexOf("Y()\n") + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testE_1FG1YDS_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FG1YDS\n" +
- " */\n" +
- "public class E {\n" +
- " {\n" +
- " new Y()\n" +
- " }\n" +
- " {\n" +
- " new Y().}\n" +
- " class Y\n" +
- " extends java.util.Vector {\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on implicit method call into intializer>";
- String completeBehind = "new Y().";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new Y().>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class E {\n" +
- " class Y extends java.util.Vector {\n" +
- " Y() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- " {\n" +
- " }\n" +
- " {\n" +
- " <CompleteOnMemberAccess:new Y().>;\n" +
- " }\n" +
- " public E() {\n" +
- " }\n" +
- "}\n";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testE_1FG1YDS_3() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FG1YDS\n" +
- " */\n" +
- "public class E {\n" +
- " {\n" +
- " new Y()\n" +
- " }\n" +
- " {\n" +
- " new Y().}\n" +
- " class Y\n" +
- " extends java.util.Vector {\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on extend type>";
- String completeBehind = "java.util.";
- String expectedCompletionNodeToString = "<CompleteOnClass:java.util.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "java.util.Vector";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class E {\n" +
- " class Y extends <CompleteOnClass:java.util.> {\n" +
- " Y() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- " {\n" +
- " }\n" +
- " {\n" +
- " }\n" +
- " public E() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testEA_1() {
- String str =
- "package p; \n" +
- "public class EA {\n" +
- " void foo() {\n" +
- " try {\n" +
- " throw new Error();\n" +
- " } catch (Exception eeee) {\n" +
- " eeee.}\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on catch block exception type declaration>";
- String completeBehind = "E";
- String expectedCompletionNodeToString = "<CompleteOnException:E>";
- String completionIdentifier = "E";
- String expectedReplacedSource = "Exception";
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class EA {\n" +
- " public EA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnException:E>;\n" +
- " }\n" +
- "}\n";
-
- int cursorLocation = str.indexOf("Exception eeee") + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testEA_2() {
- String str =
- "package p; \n" +
- "public class EA {\n" +
- " void foo() {\n" +
- " try {\n" +
- " throw new Error();\n" +
- " } catch (Exception eeee) {\n" +
- " eeee.}\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of thrown exception into catch block>";
- String completeBehind = "eeee.";
- String expectedCompletionNodeToString = "<CompleteOnName:eeee.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "eeee.";
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class EA {\n" +
- " public EA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " Exception eeee;\n" +
- " <CompleteOnName:eeee.>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testEB_1FI74S3() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FI74S3\n" +
- " */\n" +
- "public class EB {\n" +
- " int[] table;\n" +
- " void foo() {\n" +
- " int x = table.}\n" +
- "}\n";
-
- String testName = "<complete on method/field of array>";
- String completeBehind = "table.";
- String expectedCompletionNodeToString = "<CompleteOnName:table.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "table.";
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class EB {\n" +
- " int[] table;\n" +
- " public EB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int x = <CompleteOnName:table.>;\n" +
- " }\n" +
- "}\n";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testEC_1FSBZ2Y() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FSBZ2Y\n" +
- " */\n" +
- "class EC {\n" +
- " void foo() {\n" +
- " EC\n" +
- " }\n" +
- "}\n" +
- "class ECOtherTopLevel {\n" +
- "}\n";
-
- String testName = "<complete on local variable decaration type>";
- String completeBehind = "EC";
- String expectedCompletionNodeToString = "<CompleteOnName:EC>";
- String completionIdentifier = "EC";
- String expectedReplacedSource = "EC";
- String expectedUnitDisplayString =
- "package p;\n" +
- "class EC {\n" +
- " EC() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:EC>;\n" +
- " }\n" +
- "}\n" +
- "class ECOtherTopLevel {\n" +
- " ECOtherTopLevel() {\n" +
- " }\n" +
- "}\n";
-
- int cursorLocation = str.indexOf("EC\n") + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testF() {
- String str =
- "package p; \n" +
- "public class F {\n" +
- " void bar() {\n" +
- " }\n" +
- " class Y {\n" +
- " void foo() {\n" +
- " ba }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field explicit access>";
- String completeBehind = "ba";
- String expectedCompletionNodeToString = "<CompleteOnName:ba>";
- String completionIdentifier = "ba";
- String expectedReplacedSource = "ba";
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class F {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:ba>;\n" +
- " }\n" +
- " }\n" +
- " public F() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- int cursorLocation = str.indexOf("ba }") + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testFA_1() {
- String str =
- "package p; \n" +
- "public class FA {\n" +
- " byte value;\n" +
- " public float foo() {\n" +
- " return (float) value;\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on cast expression type>";
- String completeBehind = "f";
- String expectedCompletionNodeToString = "<CompleteOnName:f>";
- String completionIdentifier = "f";
- String expectedReplacedSource = "float";
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class FA {\n" +
- " byte value;\n" +
- " public FA() {\n" +
- " }\n" +
- " public float foo() {\n" +
- " <CompleteOnName:f>;\n" +
- " }\n" +
- "}\n";
-
- int cursorLocation = str.indexOf("float)") + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testFA_2() {
- String str =
- "package p; \n" +
- "public class FA {\n" +
- " byte value;\n" +
- " public float foo() {\n" +
- " return (float) value; \n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on returned value>";
- String completeBehind = "v";
- String expectedCompletionNodeToString = "<CompleteOnName:v>";
- String completionIdentifier = "v";
- String expectedReplacedSource = "value";
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class FA {\n" +
- " byte value;\n" +
- " public FA() {\n" +
- " }\n" +
- " public float foo() {\n" +
- " <CompleteOnName:v>;\n" +
- " }\n" +
- "}\n";
-
- int cursorLocation = str.indexOf("value; \n") + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testFB_1FI74S3() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FI74S3\n" +
- " */\n" +
- "public class FB {\n" +
- " int[] table;\n" +
- " void foo() {\n" +
- " int x = table[1].}\n" +
- "}\n";
-
- String testName = "<complete on method/field of array element>";
- String completeBehind = "table[1].";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:table[1].>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class FB {\n" +
- " int[] table;\n" +
- " public FB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int x = <CompleteOnMemberAccess:table[1].>;\n" +
- " }\n" +
- "}\n";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testFC_1FSBZ9B() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FSBZ9B\n" +
- " */\n" +
- "class FC {\n" +
- " UNKOWNTYPE field;\n" +
- " void foo() {\n" +
- " f\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field implicit access>";
- String completeBehind = "f";
- String expectedCompletionNodeToString = "<CompleteOnName:f>";
- String completionIdentifier = "f";
- String expectedReplacedSource = "f";
- int cursorLocation = str.indexOf("f\n") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class FC {\n" +
- " UNKOWNTYPE field;\n" +
- " FC() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:f>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testG() {
- String str =
- "package p; \n" +
- "public class G {\n" +
- " int bar() {\n" +
- " }\n" +
- " class Y {\n" +
- " void foo(int b) {\n" +
- " return b }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on return value>";
- String completeBehind = "b";
- String expectedCompletionNodeToString = "<CompleteOnName:b>";
- String completionIdentifier = "b";
- String expectedReplacedSource = "b";
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class G {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " void foo(int b) {\n" +
- " <CompleteOnName:b>;\n" +
- " }\n" +
- " }\n" +
- " public G() {\n" +
- " }\n" +
- " int bar() {\n" +
- " }\n" +
- "}\n";
-
- int cursorLocation = str.indexOf("b }") + completeBehind.length() - 1;
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testGA() {
- String str =
- "package p; \n" +
- "public class GA {\n" +
- " void foo(String s) {\n" +
- " String string = s;\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on local variable initializer>";
- String completeBehind = "s";
- String expectedCompletionNodeToString = "<CompleteOnName:s>";
- String completionIdentifier = "s";
- String expectedReplacedSource = "s";
- int cursorLocation = str.indexOf("s;") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class GA {\n" +
- " public GA() {\n" +
- " }\n" +
- " void foo(String s) {\n" +
- " String string = <CompleteOnName:s>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testGB_1FI74S3() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FI74S3\n" +
- " */\n" +
- "public class GB {\n" +
- " String[] table;\n" +
- " void foo() {\n" +
- " int x = table[1].}\n" +
- "}\n";
-
- String testName = "<complete on method/field of array element>";
- String completeBehind = "table[1].";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:table[1].>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class GB {\n" +
- " String[] table;\n" +
- " public GB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int x = <CompleteOnMemberAccess:table[1].>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testGC_1FSHLHV_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FSHLHV\n" +
- " */\n" +
- "public class GC {\n" +
- "public static void main(String[] args) {\n" +
- " Object l = new Object() {\n" +
- " public void handleEvent(String[] event) {\n" +
- " String s = new String();\n" +
- " s.\n" +
- " try {\n" +
- " event.;\n" +
- " }\n" +
- " catch (Exception e) {\n" +
- " e.\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}\n" +
- "}\n";
-
- String testName = "<complete on anonymous declaration type>";
- String completeBehind = "O";
- String expectedCompletionNodeToString = "<CompleteOnType:O>";
- String completionIdentifier = "O";
- String expectedReplacedSource = "Object";
- int cursorLocation = str.indexOf("Object()") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class GC {\n" +
- " public GC() {\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " Object l;\n" +
- " new <CompleteOnType:O>();\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testGC_1FSHLHV_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FSHLHV\n" +
- " */\n" +
- "public class GC {\n" +
- "public static void main(String[] args) {\n" +
- " Object l = new Object() {\n" +
- " public void handleEvent(String[] event) {\n" +
- " String s = new String();\n" +
- " s.\n" +
- " try {\n" +
- " event.;\n" +
- " }\n" +
- " catch (Exception e) {\n" +
- " e.\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}\n" +
- "}\n";
-
- String testName = "<complete on method/field of local variable into anonymous declaration>";
- String completeBehind = "s.";
- String expectedCompletionNodeToString = "<CompleteOnName:s.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "s.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class GC {\n" +
- " public GC() {\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " Object l;\n" +
- " new Object() {\n" +
- " () {\n" +
- " }\n" +
- " public void handleEvent(String[] event) {\n" +
- " String s;\n" +
- " <CompleteOnName:s.>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testGC_1FSHLHV_3() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FSHLHV\n" +
- " */\n" +
- "public class GC {\n" +
- "public static void main(String[] args) {\n" +
- " Object l = new Object() {\n" +
- " public void handleEvent(String[] event) {\n" +
- " String s = new String();\n" +
- " s.\n" +
- " try {\n" +
- " event.;\n" +
- " }\n" +
- " catch (Exception e) {\n" +
- " e.\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}\n" +
- "}\n";
-
- String testName = "<complete on method/field of array>";
- String completeBehind = "event.";
- String expectedCompletionNodeToString = "<CompleteOnName:event.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "event.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class GC {\n" +
- " public GC() {\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " Object l;\n" +
- " new Object() {\n" +
- " () {\n" +
- " }\n" +
- " public void handleEvent(String[] event) {\n" +
- " String s;\n" +
- " {\n" +
- " <CompleteOnName:event.>;\n" +
- " }\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testGC_1FSHLHV_4() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FSHLHV\n" +
- " */\n" +
- "public class GC {\n" +
- "public static void main(String[] args) {\n" +
- " Object l = new Object() {\n" +
- " public void handleEvent(String[] event) {\n" +
- " String s = new String();\n" +
- " s.\n" +
- " try {\n" +
- " event.;\n" +
- " }\n" +
- " catch (Exception e) {\n" +
- " e.\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}\n" +
- "}\n";
-
- String testName = "<complete on method/field of thrown exception into catch block into anonymous declaration>";
- String completeBehind = "e.";
- String expectedCompletionNodeToString = "<CompleteOnName:e.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "e.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class GC {\n" +
- " public GC() {\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " Object l;\n" +
- " new Object() {\n" +
- " () {\n" +
- " }\n" +
- " public void handleEvent(String[] event) {\n" +
- " String s;\n" +
- " {\n" +
- " Exception e;\n" +
- " <CompleteOnName:e.>;\n" +
- " }\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testH() {
- String str =
- "package p; \n" +
- "public class H {\n" +
- " void foo(boolean bbbb) {\n" +
- " while (Xbm }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on while keyword argument>";
- String completeBehind = "Xbm";
- String expectedCompletionNodeToString = "<CompleteOnName:Xbm>";
- String completionIdentifier = "Xbm";
- String expectedReplacedSource = "Xbm";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class H {\n" +
- " public H() {\n" +
- " }\n" +
- " void foo(boolean bbbb) {\n" +
- " <CompleteOnName:Xbm>;\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testHA_1() {
- String str =
- "package p; \n" +
- "public class HA {\n" +
- " void foo() {\n" +
- " x.y.Z[] field1; \n" +
- " field1[1].}\n" +
- "}\n";
-
- String testName = "<complete on package member type>";
- String completeBehind = "x.y.";
- String expectedCompletionNodeToString = "<CompleteOnName:x.y.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "x.y.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class HA {\n" +
- " public HA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:x.y.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testHA_2() {
- String str =
- "package p; \n" +
- "public class HA {\n" +
- " void foo() {\n" +
- " x.y.Z[] field1; \n" +
- " field1[1].}\n" +
- "}\n";
-
- String testName = "<complete on method/field of array element>";
- String completeBehind = "field1[1].";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:field1[1].>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class HA {\n" +
- " public HA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " x.y.Z[] field1;\n" +
- " <CompleteOnMemberAccess:field1[1].>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testHB_1FHSLDR() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHSLDR\n" +
- " */\n" +
- "public class HB {\n" +
- " void foo() {\n" +
- " for (; i < totalUnits; i++) {\n" +
- " unit = unitsToProcess[i];\n" +
- " try {\n" +
- " if (options.verbose) {\n" +
- " System.out.println(\n" +
- " \"process \"\n" +
- " + (i + 1)\n" +
- " + \"/\"\n" +
- " + totalUnits\n" +
- " + \" : \"\n" +
- " + unitsToProcess[i]\n" +
- " .sourceFileName()); \n" +
- " }\n" +
- " process(unit, i);\n" +
- " }\n" +
- " fi }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on finally keyword>";
- String completeBehind = "fi";
- String expectedCompletionNodeToString = "<CompleteOnName:fi>";
- String completionIdentifier = "fi";
- String expectedReplacedSource = "fi";
- int cursorLocation = str.indexOf("fi }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class HB {\n" +
- " public HB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " <CompleteOnName:fi>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testHC_1FMPYO3_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FMPYO3\n" +
- " */\n" +
- "class HC {\n" +
- " HC(Object o){}\n" +
- " void foo(){\n" +
- " HC a = new HC(new Object()).\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of object creation>";
- String completeBehind = "new HC(new Object()).";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new HC(new Object()).>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class HC {\n" +
- " HC(Object o) {\n" +
- " }\n" +
- " void foo() {\n" +
- " HC a = <CompleteOnMemberAccess:new HC(new Object()).>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testHC_1FMPYO3_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FMPYO3\n" +
- " */\n" +
- "class HC {\n" +
- " HC(Object o){}\n" +
- " void foo(){\n" +
- " A a = new A(new Object()).\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on object of nested object creation declaration>";
- String completeBehind = "O";
- String expectedCompletionNodeToString = "<CompleteOnType:O>";
- String completionIdentifier = "O";
- String expectedReplacedSource = "Object";
- int cursorLocation = str.indexOf("Object()") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class HC {\n" +
- " HC(Object o) {\n" +
- " }\n" +
- " void foo() {\n" +
- " A a;\n" +
- " new <CompleteOnType:O>();\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testI() {
- String str =
- "package p; \n" +
- "public class I {\n" +
- " Component }\n";
-
- String testName = "<complete on incomplete field declaration type>";
- String completeBehind = "C";
- String expectedCompletionNodeToString = "<CompleteOnType:C>";
- String completionIdentifier = "C";
- String expectedReplacedSource = "Component";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class I {\n" +
- " <CompleteOnType:C>;\n" +
- " public I() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testIA_1FGNBPR_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGNBPR\n" +
- " */\n" +
- "public class IA {\n" +
- " void foo1() {\n" +
- " label1 : while (true) {\n" +
- " class A {\n" +
- " void foo2() {\n" +
- " label2 : while (true) {\n" +
- " break la }\n" +
- " }\n" +
- " }\n" +
- " A a = new A();\n" +
- " break la }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on label name>";
- String completeBehind = "la";
- String expectedCompletionNodeToString = "<CompleteOnName:la>";
- String completionIdentifier = "la";
- String expectedReplacedSource = "la";
- int cursorLocation = str.indexOf("la }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class IA {\n" +
- " public IA() {\n" +
- " }\n" +
- " void foo1() {\n" +
- " {\n" +
- " class A {\n" +
- " A() {\n" +
- " }\n" +
- " void foo2() {\n" +
- " <CompleteOnName:la>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testIA_1FGNBPR_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGNBPR\n" +
- " */\n" +
- "public class IA {\n" +
- " void foo1() {\n" +
- " label1 : while (true) {\n" +
- " class A {\n" +
- " void foo2() {\n" +
- " label2 : while (true) {\n" +
- " break la }\n" +
- " }\n" +
- " }\n" +
- " A a = new A();\n" +
- " break la }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on label name>";
- String completeBehind = "la";
- String expectedCompletionNodeToString = "<CompleteOnName:la>";
- String completionIdentifier = "la";
- String expectedReplacedSource = "la";
- int cursorLocation = str.indexOf("la }", str.indexOf("la }") + 1) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class IA {\n" +
- " public IA() {\n" +
- " }\n" +
- " void foo1() {\n" +
- " {\n" +
- " class A {\n" +
- " A() {\n" +
- " super();\n" + // could be optimized out ?
- " }\n" +
- " void foo2() {\n" +
- " }\n" +
- " };\n" +
- " A a;\n" +
- " <CompleteOnName:la>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testIB() {
- String str =
- "package p; \n" +
- "public class IB {\n" +
- " UnknownFieldTYPE field;\n" +
- " void foo() {\n" +
- " field.}\n" +
- "}\n";
-
- String testName = "<complete on method/field of field of unkown type>";
- String completeBehind = "field.";
- String expectedCompletionNodeToString = "<CompleteOnName:field.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "field.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class IB {\n" +
- " UnknownFieldTYPE field;\n" +
- " public IB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:field.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testIC_1FMGUPR() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FMGUPR\n" +
- " */\n" +
- "public class IC {\n" +
- " void foo(){\n" +
- " new String().toString().\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on multiple method/field call>";
- String completeBehind = "new String().toString().";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new String().toString().>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class IC {\n" +
- " public IC() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:new String().toString().>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testJ() {
- String str =
- "package p; \n" +
- "public class J {\n" +
- " int foo1()[void foo2() int i;\n" +
- " void foo3() {\n" +
- " f }\n";
-
- String testName = "<complete on method/field access into corrupted method declaration>";
- String completeBehind = "f";
- String expectedCompletionNodeToString = "<CompleteOnName:f>";
- String completionIdentifier = "f";
- String expectedReplacedSource = "f";
- int cursorLocation = str.indexOf("f }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class J {\n" +
- " public J() {\n" +
- " }\n" +
- " int foo1() {\n" +
- " }\n" +
- " void foo2() {\n" +
- " }\n" +
- " void foo3() {\n" +
- " <CompleteOnName:f>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testJA_1FGQVW2_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGQVW2\n" +
- " */\n" +
- "public class JA {\n" +
- " void foo() {\n" +
- " \"abc.txt\". 'a'.}\n" +
- "}\n";
-
- String testName = "<complete on string literal>";
- String completeBehind = "\"abc.txt\".";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:\"abc.txt\".>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class JA {\n" +
- " public JA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:\"abc.txt\".>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testJA_1FGQVW2_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGQVW2\n" +
- " */\n" +
- "public class JA {\n" +
- " void foo() {\n" +
- " \"abc.txt\". 'a'.}\n" +
- "}\n";
-
- String testName = "<complete on char literal>";
- String completeBehind = "'a'.";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:'a'.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class JA {\n" +
- " public JA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:'a'.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testJB() {
- String str =
- "package p; \n" +
- "public class JB\n" +
- " extends UnknownSUPERCLASS\n" +
- " implements UnknownSUPERINTERFACE {\n" +
- " void foo() {\n" +
- " f }\n" +
- "}\n";
-
- String testName = "<complete into method declared into corrupted class declaration>";
- String completeBehind = "f";
- String expectedCompletionNodeToString = "<CompleteOnName:f>";
- String completionIdentifier = "f";
- String expectedReplacedSource = "f";
- int cursorLocation = str.indexOf("f }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class JB extends UnknownSUPERCLASS implements UnknownSUPERINTERFACE {\n" +
- " public JB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:f>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testJC_1FLG1ZC() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FLG1ZC\n" +
- " */\n" +
- "public class JC {\n" +
- " void foo() {\n" +
- " new String ().\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of object creation with dummy spaces>";
- String completeBehind = "new String ().";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new String().>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class JC {\n" +
- " public JC() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:new String().>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testK_1() {
- String str =
- "package p; \n" +
- "class Other {\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n" +
- "public class K {\n" +
- " public static void main(\n" +
- " java.lang.String[] args) {\n" +
- " java.io.File bbbb = \n" +
- " new File(\"c:\\abc.txt\"); \n" +
- " O bb bbbb.}\n" +
- "}\n";
-
- String testName = "<complete on corrupted local variable declaration>";
- String completeBehind = " O";
- String expectedCompletionNodeToString = "<CompleteOnName:O>";
- String completionIdentifier = "O";
- String expectedReplacedSource = "O";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class Other {\n" +
- " Other() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n" +
- "public class K {\n" +
- " public K() {\n" +
- " }\n" +
- " public static void main(java.lang.String[] args) {\n" +
- " java.io.File bbbb;\n" +
- " <CompleteOnName:O>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testK_2() {
- String str =
- "package p; \n" +
- "class Other {\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n" +
- "public class K {\n" +
- " public static void main(\n" +
- " java.lang.String[] args) {\n" +
- " java.io.File bbbb = \n" +
- " new File(\"c:\\abc.txt\"); \n" +
- " O bb bbbb.}\n" +
- "}\n";
-
- String testName = "<complete on corrupted local variable declaration name>";
- String completeBehind = "bb";
- String expectedCompletionNodeToString = "<CompleteOnLocalName:O bb>";
- String completionIdentifier = "bb";
- String expectedReplacedSource = "bb";
- int cursorLocation = str.indexOf("bb bbbb.") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class Other {\n" +
- " Other() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n" +
- "public class K {\n" +
- " public K() {\n" +
- " }\n" +
- " public static void main(java.lang.String[] args) {\n" +
- " java.io.File bbbb;\n" +
- " <CompleteOnLocalName:O bb>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testK_3() {
- String str =
- "package p; \n" +
- "class Other {\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n" +
- "public class K {\n" +
- " public static void main(\n" +
- " java.lang.String[] args) {\n" +
- " java.io.File bbbb = \n" +
- " new File(\"c:\\abc.txt\"); \n" +
- " O bb bbbb.}\n" +
- "}\n";
-
- String testName = "<complete on corrupted local variable declaration>";
- String completeBehind = "bbbb";
- String expectedCompletionNodeToString = "<CompleteOnName:bbbb>";
- String completionIdentifier = "bbbb";
- String expectedReplacedSource = "bbbb";
- int cursorLocation = str.indexOf("bbbb.}") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class Other {\n" +
- " Other() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n" +
- "public class K {\n" +
- " public K() {\n" +
- " }\n" +
- " public static void main(java.lang.String[] args) {\n" +
- " java.io.File bbbb;\n" +
- " O bb;\n" +
- " <CompleteOnName:bbbb>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testK_4() {
- String str =
- "package p; \n" +
- "class Other {\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n" +
- "public class K {\n" +
- " public static void main(\n" +
- " java.lang.String[] args) {\n" +
- " java.io.File bbbb = \n" +
- " new File(\"c:\\abc.txt\"); \n" +
- " O bb bbbb.}\n" +
- "}\n";
-
- String testName = "<complete on method/field of local variable with corrupted declaration>";
- String completeBehind = "bbbb.";
- String expectedCompletionNodeToString = "<CompleteOnName:bbbb.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "bbbb.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class Other {\n" +
- " Other() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n" +
- "public class K {\n" +
- " public K() {\n" +
- " }\n" +
- " public static void main(java.lang.String[] args) {\n" +
- " java.io.File bbbb;\n" +
- " O bb;\n" +
- " <CompleteOnName:bbbb.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testKA_1FH5SU5() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FH5SU5\n" +
- " */\n" +
- "class KAHelper\n" +
- " extends java.util.Vector {\n" +
- "}\n" +
- "public class KA {\n" +
- " public int hashCode() {\n" +
- " return 10;\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " KA a = new KA;\n" +
- " a.has }\n" +
- "}\n";
-
- String testName = "<complete on method/field>";
- String completeBehind = "a.has";
- String expectedCompletionNodeToString = "<CompleteOnName:a.has>";
- String completionIdentifier = "has";
- String expectedReplacedSource = "a.has";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class KAHelper extends java.util.Vector {\n" +
- " KAHelper() {\n" +
- " }\n" +
- "}\n" +
- "public class KA {\n" +
- " public KA() {\n" +
- " }\n" +
- " public int hashCode() {\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " KA a;\n" +
- " <CompleteOnName:a.has>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testKB() {
- String str =
- "package p; \n" +
- "public class KB {\n" +
- " void foo()[i }\n" +
- "}\n";
-
- String testName = "<complete on corrupted method header>";
- String completeBehind = "void foo()[i";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = "i";
- String expectedReplacedSource = "i";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class KB {\n" +
- " public KB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testKC_1FLG1ZC() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FLG1ZC\n" +
- " */\n" +
- "import java.io.*;\n" +
- "public class KC {\n" +
- "private static char[] read(String fileName){\n" +
- " try {\n" +
- " File file = new File(fileName);\n" +
- " FileReader reader =\n" +
- " new FileReader(file);\n" +
- " int length;\n" +
- " char[] contents =\n" +
- " new char[\n" +
- " length =\n" +
- " (int) file.length()];\n" +
- " int len = 0;\n" +
- " int readSize = 0;\n" +
- " while ((readSize != -1)\n" +
- " && (len != length)) {\n" +
- " readSize = reader.read(\n" +
- " contents,\n" +
- " len,\n" +
- " length - len);\n" +
- " len += readSize;\n" +
- " }\n" +
- " reader. t\n";
-
- String testName = "<complete on method/field with dummy spaces>";
- String completeBehind = "reader. t";
- String expectedCompletionNodeToString = "<CompleteOnName:reader.t>";
- String completionIdentifier = "t";
- String expectedReplacedSource = "reader. t";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import java.io.*;\n" +
- "public class KC {\n" +
- " public KC() {\n" +
- " }\n" +
- " private static char[] read(String fileName) {\n" +
- " {\n" +
- " File file;\n" +
- " FileReader reader;\n" +
- " int length;\n" +
- " char[] contents;\n" +
- " int len;\n" +
- " int readSize;\n" +
- " <CompleteOnName:reader.t>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testL_1() {
- String str =
- "package p; \n" +
- "public class L {\n" +
- " void foo() {\n" +
- " x.y.Z[] field1, \n" +
- " field2; \n" +
- " field1.if (int[].class }\n" +
- "}\n";
-
- String testName = "<complete on method/field>";
- String completeBehind = "field1.";
- String expectedCompletionNodeToString = "<CompleteOnName:field1.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "field1.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class L {\n" +
- " public L() {\n" +
- " }\n" +
- " void foo() {\n" +
- " x.y.Z[] field1;\n" +
- " x.y.Z[] field2;\n" +
- " <CompleteOnName:field1.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testL_2() {
- String str =
- "package p; \n" +
- "public class L {\n" +
- " void foo() {\n" +
- " x.y.Z[] field1, \n" +
- " field2; \n" +
- " field1.if (int[].class }\n" +
- "}\n";
-
- String testName = "<complete on method/field of array>";
- String completeBehind = "int[].";
- String expectedCompletionNodeToString = "<CompleteOnClassLiteralAccess:int[].>";
- String completionIdentifier = "";
- String expectedReplacedSource = "int[].";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class L {\n" +
- " public L() {\n" +
- " }\n" +
- " void foo() {\n" +
- " x.y.Z[] field1;\n" +
- " x.y.Z[] field2;\n" +
- " <CompleteOnClassLiteralAccess:int[].>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testL_3() {
- String str =
- "package p; \n" +
- "public class L {\n" +
- " void foo() {\n" +
- " x.y.Z[] field1, \n" +
- " field2; \n" +
- " field1.if (int[].class }\n" +
- "}\n";
-
- String testName = "<complete on argument of corrupted if statement>";
- String completeBehind = "int";
- String expectedCompletionNodeToString = "<CompleteOnName:int>";
- String completionIdentifier = "int";
- String expectedReplacedSource = "int";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class L {\n" +
- " public L() {\n" +
- " }\n" +
- " void foo() {\n" +
- " x.y.Z[] field1;\n" +
- " x.y.Z[] field2;\n" +
- " <CompleteOnName:int>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testLA_1FGLMOF() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGLMOF\n" +
- " */\n" +
- "public class LA {\n" +
- " void[] foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " f }\n" +
- "}\n";
-
- String testName = "<complete on method/field with corrupted method header>";
- String completeBehind = "f";
- String expectedCompletionNodeToString = "<CompleteOnName:f>";
- String completionIdentifier = "f";
- String expectedReplacedSource = "f";
- int cursorLocation = str.indexOf("f }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class LA {\n" +
- " public LA() {\n" +
- " }\n" +
- " void[] foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " <CompleteOnName:f>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testLB() {
- String str =
- "package p; \n" +
- "public class LB {\n" +
- " void foo() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " i }\n" +
- "}\n";
-
- String testName = "<complete on method/field with duplicate method declaration>";
- String completeBehind = "i";
- String expectedCompletionNodeToString = "<CompleteOnName:i>";
- String completionIdentifier = "i";
- String expectedReplacedSource = "i";
- int cursorLocation = str.indexOf("i }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class LB {\n" +
- " public LB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " <CompleteOnName:i>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testLC_1FLG1E2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FLG1E2\n" +
- " */\n" +
- "public class LC {\n" +
- " void foo() {\n" +
- " Object[] x = new Object[10];\n" +
- " x [1].\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of array element with dummy spaces>";
- String completeBehind = "x [1].";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:x[1].>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class LC {\n" +
- " public LC() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Object[] x;\n" +
- " <CompleteOnMemberAccess:x[1].>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testM_1FGGLMT() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGGLMT\n" +
- " */\n" +
- "public class M {\n" +
- " class Member {\n" +
- " void fooMember() {\n" +
- " }\n" +
- " }\n" +
- " void foo() {\n" +
- " new Member().}\n" +
- "}\n" +
- "class MemberOfCU {\n" +
- "}\n";
-
- String testName = "<complete on method/field of explicit object creation>";
- String completeBehind = "new Member().";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new Member().>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class M {\n" +
- " class Member {\n" +
- " Member() {\n" +
- " }\n" +
- " void fooMember() {\n" +
- " }\n" +
- " }\n" +
- " public M() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:new Member().>;\n" +
- " }\n" +
- "}\n" +
- "class MemberOfCU {\n" +
- " MemberOfCU() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testMA_1() {
- String str =
- "package p; \n" +
- "public class MA {\n" +
- " class Member\n" +
- " extends java.util.Vector {\n" +
- " static void fooStaticMember() {\n" +
- " }\n" +
- " void fooMember() {\n" +
- " }\n" +
- " class MemberMember {\n" +
- " void fooMemberMember() {\n" +
- " MemberOfCUMA m = \n" +
- " new MemberOfCUMA(); \n" +
- " }\n" +
- " }\n" +
- " class MemberMember2 {\n" +
- " }\n" +
- " }\n" +
- " void foo() {\n" +
- " Membe }\n" +
- " void foobar() {\n" +
- " new Member().}\n" +
- " class Member2 {\n" +
- " }\n" +
- "}\n" +
- "class MemberOfCUMA {\n" +
- "}\n";
-
- String testName = "<complete on local variable declaration type>";
- String completeBehind = "Membe";
- String expectedCompletionNodeToString = "<CompleteOnName:Membe>";
- String completionIdentifier = "Membe";
- String expectedReplacedSource = "Membe";
- int cursorLocation = str.indexOf("Membe }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class MA {\n" +
- " class Member extends java.util.Vector {\n" +
- " class MemberMember {\n" +
- " MemberMember() {\n" +
- " }\n" +
- " void fooMemberMember() {\n" +
- " }\n" +
- " }\n" +
- " class MemberMember2 {\n" +
- " MemberMember2() {\n" +
- " }\n" +
- " }\n" +
- " Member() {\n" +
- " }\n" +
- " static void fooStaticMember() {\n" +
- " }\n" +
- " void fooMember() {\n" +
- " }\n" +
- " }\n" +
- " class Member2 {\n" +
- " Member2() {\n" +
- " }\n" +
- " }\n" +
- " public MA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:Membe>;\n" +
- " }\n" +
- " void foobar() {\n" +
- " }\n" +
- "}\n" +
- "class MemberOfCUMA {\n" +
- " MemberOfCUMA() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testMA_2() {
- String str =
- "package p; \n" +
- "public class MA {\n" +
- " class Member\n" +
- " extends java.util.Vector {\n" +
- " static void fooStaticMember() {\n" +
- " }\n" +
- " void fooMember() {\n" +
- " }\n" +
- " class MemberMember {\n" +
- " void fooMemberMember() {\n" +
- " MemberOfCUMA m = \n" +
- " new MemberOfCUMA(); \n" +
- " }\n" +
- " }\n" +
- " class MemberMember2 {\n" +
- " }\n" +
- " }\n" +
- " void foo() {\n" +
- " Membe }\n" +
- " void foobar() {\n" +
- " new Member().}\n" +
- " class Member2 {\n" +
- " }\n" +
- "}\n" +
- "class MemberOfCUMA {\n" +
- "}\n";
-
- String testName = "<complete on object creation type>";
- String completeBehind = "MemberOfCU";
- String expectedCompletionNodeToString = "<CompleteOnType:MemberOfCU>";
- String completionIdentifier = "MemberOfCU";
- String expectedReplacedSource = "MemberOfCUMA";
- int cursorLocation = str.indexOf("MemberOfCUMA();") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class MA {\n" +
- " class Member extends java.util.Vector {\n" +
- " class MemberMember {\n" +
- " MemberMember() {\n" +
- " }\n" +
- " void fooMemberMember() {\n" +
- " MemberOfCUMA m;\n" +
- " new <CompleteOnType:MemberOfCU>();\n" +
- " }\n" +
- " }\n" +
- " class MemberMember2 {\n" +
- " MemberMember2() {\n" +
- " }\n" +
- " }\n" +
- " Member() {\n" +
- " }\n" +
- " static void fooStaticMember() {\n" +
- " }\n" +
- " void fooMember() {\n" +
- " }\n" +
- " }\n" +
- " class Member2 {\n" +
- " Member2() {\n" +
- " }\n" +
- " }\n" +
- " public MA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void foobar() {\n" +
- " }\n" +
- "}\n" +
- "class MemberOfCUMA {\n" +
- " MemberOfCUMA() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testMA_3() {
- String str =
- "package p; \n" +
- "public class MA {\n" +
- " class Member\n" +
- " extends java.util.Vector {\n" +
- " static void fooStaticMember() {\n" +
- " }\n" +
- " void fooMember() {\n" +
- " }\n" +
- " class MemberMember {\n" +
- " void fooMemberMember() {\n" +
- " MemberOfCUMA m = \n" +
- " new MemberOfCUMA(); \n" +
- " }\n" +
- " }\n" +
- " class MemberMember2 {\n" +
- " }\n" +
- " }\n" +
- " void foo() {\n" +
- " Membe }\n" +
- " void foobar() {\n" +
- " new Member().}\n" +
- " class Member2 {\n" +
- " }\n" +
- "}\n" +
- "class MemberOfCUMA {\n" +
- "}\n";
-
- String testName = "<complete on method/field of object creation>";
- String completeBehind = "new Member().";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new Member().>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class MA {\n" +
- " class Member extends java.util.Vector {\n" +
- " class MemberMember {\n" +
- " MemberMember() {\n" +
- " }\n" +
- " void fooMemberMember() {\n" +
- " }\n" +
- " }\n" +
- " class MemberMember2 {\n" +
- " MemberMember2() {\n" +
- " }\n" +
- " }\n" +
- " Member() {\n" +
- " }\n" +
- " static void fooStaticMember() {\n" +
- " }\n" +
- " void fooMember() {\n" +
- " }\n" +
- " }\n" +
- " class Member2 {\n" +
- " Member2() {\n" +
- " }\n" +
- " }\n" +
- " public MA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void foobar() {\n" +
- " <CompleteOnMemberAccess:new Member().>;\n" +
- " }\n" +
- "}\n" +
- "class MemberOfCUMA {\n" +
- " MemberOfCUMA() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testMB_1FHSLMQ_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHSLMQ\n" +
- " */\n" +
- "public class MB {\n" +
- " void foo() {\n" +
- " try {\n" +
- " System.out.println(\"\");\n" +
- " } catch (Exception eFirst) {\n" +
- " e } catch (Exception eSecond) {\n" +
- " e }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on local variable name into catch block>";
- String completeBehind = "e";
- String expectedCompletionNodeToString = "<CompleteOnName:e>";
- String completionIdentifier = "e";
- String expectedReplacedSource = "e";
- int cursorLocation = str.indexOf("e }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class MB {\n" +
- " public MB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " Exception eFirst;\n" +
- " <CompleteOnName:e>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testMB_1FHSLMQ_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHSLMQ\n" +
- " */\n" +
- "public class MB {\n" +
- " void foo() {\n" +
- " try {\n" +
- " System.out.println(\"\");\n" +
- " } catch (Exeption eFirst) {\n" +
- " e } catch (Exception eSecond) {\n" +
- " e }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on local variable name into catch block>";
- String completeBehind = "e";
- String expectedCompletionNodeToString = "<CompleteOnName:e>";
- String completionIdentifier = "e";
- String expectedReplacedSource = "e";
- int cursorLocation = str.indexOf("e }\n") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class MB {\n" +
- " public MB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " Exception eSecond;\n" +
- " <CompleteOnName:e>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testMC_1FJ8D9Z() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FJ8D9Z\n" +
- " */\n" +
- "public class MC {\n" +
- " p2.X someField;\n" +
- " public void foo() {\n" +
- " new p2.X(\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on object creation argument>";
- String completeBehind = "new p2.X(";
- String expectedCompletionNodeToString = "<CompleteOnAllocationExpression:new p2.X()>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class MC {\n" +
- " p2.X someField;\n" +
- " public MC() {\n" +
- " }\n" +
- " public void foo() {\n" +
- " <CompleteOnAllocationExpression:new p2.X()>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testN() {
- String str =
- "package p; \n" +
- "public class N extends p.M {\n" +
- " void foo() {\n" +
- " class MLocal\n" +
- " extends Schmurz {\n" +
- " void foo() {\n" +
- " }\n" +
- " int field1;\n" +
- " class MLocalMember\n" +
- " extends myInnerC {\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " new M }\n" +
- " }\n" +
- " class MLocalMember2 {\n" +
- " void fooMyInnerC() {\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on object creation type>";
- String completeBehind = "new M";
- String expectedCompletionNodeToString = "<CompleteOnType:M>";
- String completionIdentifier = "M";
- String expectedReplacedSource = "M";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class N extends p.M {\n" +
- " public N() {\n" +
- " }\n" +
- " void foo() {\n" +
- " class MLocal extends Schmurz {\n" +
- " class MLocalMember extends myInnerC {\n" +
- " MLocalMember() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " new <CompleteOnType:M>();\n" +
- " }\n" +
- " }\n" +
- " class MLocalMember2 {\n" +
- " MLocalMember2() {\n" +
- " }\n" +
- " void fooMyInnerC() {\n" +
- " }\n" +
- " }\n" +
- " int field1;\n" +
- " MLocal() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testNA_1() {
- String str =
- "package p; \n" +
- "class NException2\n" +
- " extends NoClassDefFoundError {\n" +
- "}\n" +
- "interface NInterface {\n" +
- " void foo();\n" +
- "}\n" +
- "class DAB {\n" +
- " public DA foo() {\n" +
- " }\n" +
- " public int foufou;\n" +
- "}\n" +
- "class DANA {\n" +
- " public int f;\n" +
- " N fieldC;\n" +
- "}\n" +
- "public class NA\n" +
- " extends NException2\n" +
- " implements N {\n" +
- " DA fieldB;\n" +
- " class freak {\n" +
- " }\n" +
- " void dede() {\n" +
- " DA local;\n" +
- " local.fieldC.foo();\n" +
- " }\n" +
- "}\n" +
- "interface NCool {\n" +
- "}\n";
-
- String testName = "<complete on local variable name>";
- String completeBehind = "l";
- String expectedCompletionNodeToString = "<CompleteOnName:l>";
- String completionIdentifier = "l";
- String expectedReplacedSource = "local";
- int cursorLocation = str.indexOf("local.") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class NException2 extends NoClassDefFoundError {\n" +
- " NException2() {\n" +
- " }\n" +
- "}\n" +
- "interface NInterface {\n" +
- " void foo();\n" +
- "}\n" +
- "class DAB {\n" +
- " public int foufou;\n" +
- " DAB() {\n" +
- " }\n" +
- " public DA foo() {\n" +
- " }\n" +
- "}\n" +
- "class DANA {\n" +
- " public int f;\n" +
- " N fieldC;\n" +
- " DANA() {\n" +
- " }\n" +
- "}\n" +
- "public class NA extends NException2 implements N {\n" +
- " class freak {\n" +
- " freak() {\n" +
- " }\n" +
- " }\n" +
- " DA fieldB;\n" +
- " public NA() {\n" +
- " }\n" +
- " void dede() {\n" +
- " DA local;\n" +
- " <CompleteOnName:l>;\n" +
- " }\n" +
- "}\n" +
- "interface NCool {\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testNA_2() {
- String str =
- "package p; \n" +
- "class NException2\n" +
- " extends NoClassDefFoundError {\n" +
- "}\n" +
- "interface NInterface {\n" +
- " void foo();\n" +
- "}\n" +
- "class DAB {\n" +
- " public DA foo() {\n" +
- " }\n" +
- " public int foufou;\n" +
- "}\n" +
- "class DANA {\n" +
- " public int f;\n" +
- " N fieldC;\n" +
- "}\n" +
- "public class NA\n" +
- " extends NException2\n" +
- " implements N {\n" +
- " DA fieldB;\n" +
- " class freak {\n" +
- " }\n" +
- " void dede() {\n" +
- " DA local;\n" +
- " local.fieldC.foo();\n" +
- " }\n" +
- "}\n" +
- "interface NCool {\n" +
- "}\n";
-
- String testName = "<complete on method/field of local variable>";
- String completeBehind = "local.f";
- String expectedCompletionNodeToString = "<CompleteOnName:local.f>";
- String completionIdentifier = "f";
- String expectedReplacedSource = "local.fieldC";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class NException2 extends NoClassDefFoundError {\n" +
- " NException2() {\n" +
- " }\n" +
- "}\n" +
- "interface NInterface {\n" +
- " void foo();\n" +
- "}\n" +
- "class DAB {\n" +
- " public int foufou;\n" +
- " DAB() {\n" +
- " }\n" +
- " public DA foo() {\n" +
- " }\n" +
- "}\n" +
- "class DANA {\n" +
- " public int f;\n" +
- " N fieldC;\n" +
- " DANA() {\n" +
- " }\n" +
- "}\n" +
- "public class NA extends NException2 implements N {\n" +
- " class freak {\n" +
- " freak() {\n" +
- " }\n" +
- " }\n" +
- " DA fieldB;\n" +
- " public NA() {\n" +
- " }\n" +
- " void dede() {\n" +
- " DA local;\n" +
- " <CompleteOnName:local.f>;\n" +
- " }\n" +
- "}\n" +
- "interface NCool {\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testNA_3() {
- String str =
- "package p; \n" +
- "class NException2\n" +
- " extends NoClassDefFoundError {\n" +
- "}\n" +
- "interface NInterface {\n" +
- " void foo();\n" +
- "}\n" +
- "class DAB {\n" +
- " public DA foo() {\n" +
- " }\n" +
- " public int foufou;\n" +
- "}\n" +
- "class DANA {\n" +
- " public int f;\n" +
- " N fieldC;\n" +
- "}\n" +
- "public class NA\n" +
- " extends NException2\n" +
- " implements N {\n" +
- " DA fieldB;\n" +
- " class freak {\n" +
- " }\n" +
- " void dede() {\n" +
- " DA local;\n" +
- " local.fieldC.foo();\n" +
- " }\n" +
- "}\n" +
- "interface NCool {\n" +
- "}\n";
-
- String testName = "<complete on method/field of local variable>";
- String completeBehind = "local.fieldC.";
- String expectedCompletionNodeToString = "<CompleteOnName:local.fieldC.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "local.fieldC.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class NException2 extends NoClassDefFoundError {\n" +
- " NException2() {\n" +
- " }\n" +
- "}\n" +
- "interface NInterface {\n" +
- " void foo();\n" +
- "}\n" +
- "class DAB {\n" +
- " public int foufou;\n" +
- " DAB() {\n" +
- " }\n" +
- " public DA foo() {\n" +
- " }\n" +
- "}\n" +
- "class DANA {\n" +
- " public int f;\n" +
- " N fieldC;\n" +
- " DANA() {\n" +
- " }\n" +
- "}\n" +
- "public class NA extends NException2 implements N {\n" +
- " class freak {\n" +
- " freak() {\n" +
- " }\n" +
- " }\n" +
- " DA fieldB;\n" +
- " public NA() {\n" +
- " }\n" +
- " void dede() {\n" +
- " DA local;\n" +
- " <CompleteOnName:local.fieldC.>;\n" +
- " }\n" +
- "}\n" +
- "interface NCool {\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testNB() {
- String str =
- "package p; \n" +
- "public class NB {\n" +
- " void foo() {\n" +
- " int iOutside;\n" +
- " if (i != 0) {\n" +
- " for (int i = 10; --i >= 0;)\n" +
- " unit[i].parseMethod(\n" +
- " parser, \n" +
- " unit); \n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on variable name into for statement>";
- String completeBehind = "i";
- String expectedCompletionNodeToString = "<CompleteOnName:i>";
- String completionIdentifier = "i";
- String expectedReplacedSource = "i";
- int cursorLocation = str.indexOf("i >=") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class NB {\n" +
- " public NB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int iOutside;\n" +
- " {\n" +
- " int i;\n" +
- " <CompleteOnName:i>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testNC_1FJ8D9Z() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FJ8D9Z\n" +
- " */\n" +
- "public class NC {\n" +
- " String s = new String(\n";
-
- String testName = "<complete on field intializer into corrupted class declaration>";
- String completeBehind = "new String(";
- String expectedCompletionNodeToString = "<CompleteOnAllocationExpression:new String()>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class NC {\n" +
- " String s = <CompleteOnAllocationExpression:new String()>;\n" +
- " public NC() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testO_1FG1YU0() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FG1YU0\n" +
- " */\n" +
- "public class O\n" +
- " extends java.util.Vector {\n" +
- " void bar(boolean bbbb) {\n" +
- " this.}\n" +
- "}\n";
-
- String testName = "<complete on method/field of explicit this>";
- String completeBehind = "this.";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:this.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "this.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class O extends java.util.Vector {\n" +
- " public O() {\n" +
- " }\n" +
- " void bar(boolean bbbb) {\n" +
- " <CompleteOnMemberAccess:this.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testOA_1() {
- String str =
- "package p; \n" +
- "public class OA {\n" +
- " void proc() {\n" +
- " int[] a = new int[10];\n" +
- " Object b = a;\n" +
- " Class c = a.getClass();\n" +
- " String s = a.toString();\n" +
- " boolean l = a.equals(b);\n" +
- " int h = a.hashCode();\n" +
- " try {\n" +
- " a.wait();\n" +
- " a.wait(3);\n" +
- " a.wait(4, 5);\n" +
- " } catch (Exception e) {\n" +
- " }\n" +
- " a.notify();\n" +
- " a.notifyAll();\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of array>";
- String completeBehind = "a.n";
- String expectedCompletionNodeToString = "<CompleteOnName:a.n>";
- String completionIdentifier = "n";
- String expectedReplacedSource = "a.notify";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class OA {\n" +
- " public OA() {\n" +
- " }\n" +
- " void proc() {\n" +
- " int[] a;\n" +
- " Object b;\n" +
- " Class c;\n" +
- " String s;\n" +
- " boolean l;\n" +
- " int h;\n" +
- " <CompleteOnName:a.n>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testOA_2() {
- String str =
- "package p; \n" +
- "public class OA {\n" +
- " void proc() {\n" +
- " int[] a = new int[10];\n" +
- " Object b = a;\n" +
- " Class c = a.getClass();\n" +
- " String s = a.toString();\n" +
- " boolean l = a.equals(b);\n" +
- " int h = a.hashCode();\n" +
- " try {\n" +
- " a.wait();\n" +
- " a.wait(3);\n" +
- " a.wait(4, 5);\n" +
- " } catch (Exception e) {\n" +
- " }\n" +
- " a.notify();\n" +
- " a.notifyAll();\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of array>";
- String completeBehind = "a.w";
- String expectedCompletionNodeToString = "<CompleteOnName:a.w>";
- String completionIdentifier = "w";
- String expectedReplacedSource = "a.wait";
- int cursorLocation = str.indexOf("a.wait(4, 5)") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class OA {\n" +
- " public OA() {\n" +
- " }\n" +
- " void proc() {\n" +
- " int[] a;\n" +
- " Object b;\n" +
- " Class c;\n" +
- " String s;\n" +
- " boolean l;\n" +
- " int h;\n" +
- " {\n" +
- " <CompleteOnName:a.w>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testOB_1() {
- String str =
- "package p; \n" +
- "public class OB {\n" +
- " void foo() {\n" +
- " label : while (true) {\n" +
- " System.out.println(\"\");\n" +
- " break label;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on keyword>";
- String completeBehind = "b";
- String expectedCompletionNodeToString = "<CompleteOnName:b>";
- String completionIdentifier = "b";
- String expectedReplacedSource = "break";
- int cursorLocation = str.indexOf("break") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class OB {\n" +
- " public OB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " <CompleteOnName:b>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testOB_2() {
- String str =
- "package p; \n" +
- "public class OB {\n" +
- " void foo() {\n" +
- " label : while (true) {\n" +
- " System.out.println(\"\");\n" +
- " break label;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on label name>";
- String completeBehind = "l";
- String expectedCompletionNodeToString = "<CompleteOnName:l>";
- String completionIdentifier = "l";
- String expectedReplacedSource = "label";
- int cursorLocation = str.indexOf("label") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class OB {\n" +
- " public OB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:l>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testOC_1FM7J7F() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FM7J7F\n" +
- " */\n" +
- "class OC {\n" +
- " String s = new String(\n" +
- "}\n";
-
- String testName = "<complete on field initializer>";
- String completeBehind = "new String(";
- String expectedCompletionNodeToString = "<CompleteOnAllocationExpression:new String()>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class OC {\n" +
- " String s = <CompleteOnAllocationExpression:new String()>;\n" +
- " OC() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testP_1FG1YU0() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FG1YU0\n" +
- " */\n" +
- "public class P {\n" +
- " {\n" +
- " void bar() {\n" +
- " f }\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n";
-
- String testName = "<complete on method/field>";
- String completeBehind = "f";
- String expectedCompletionNodeToString = "<CompleteOnName:f>";
- String completionIdentifier = "f";
- String expectedReplacedSource = "f";
- int cursorLocation = str.indexOf("f }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class P {\n" +
- " {\n" +
- " }\n" +
- " public P() {\n" +
- " }\n" +
- " void bar() {\n" +
- " <CompleteOnName:f>;\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName); }
-public void testPA_1() {
- String str =
- "package p; \n" +
- "class PAHelper {\n" +
- " public int fieldPublic;\n" +
- " protected int fieldProtected;\n" +
- " private int fieldPrivate;\n" +
- " int fieldDefault;\n" +
- " static void staticFoo() {\n" +
- " }\n" +
- " static int i = 1;\n" +
- " int neuneu1() {\n" +
- " return 0;\n" +
- " }\n" +
- " void neuneu2() {\n" +
- " }\n" +
- "}\n" +
- "public class PA\n" +
- " extends PAHelper {\n" +
- " void foo() {\n" +
- " B[] b = \n" +
- " new java.lang.Number[]; \n" +
- " java.lang.Short s;\n" +
- " // b[1].;\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on comment>";
- String completeBehind = "b[1].";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = "";
- String expectedReplacedSource = NONE;
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString = null;
-
- try {
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
- assertTrue("failed to detect invalid cursor location", false);
- } catch(InvalidCursorLocation e){
- assertEquals("invalid cursor location: ", e.irritant, InvalidCursorLocation.NO_COMPLETION_INSIDE_COMMENT);
- }
-}
-public void testPA_2() {
- String str =
- "package p; \n" +
- "class PAHelper {\n" +
- " public int fieldPublic;\n" +
- " protected int fieldProtected;\n" +
- " private int fieldPrivate;\n" +
- " int fieldDefault;\n" +
- " static void staticFoo() {\n" +
- " }\n" +
- " static int i = 1;\n" +
- " int neuneu1() {\n" +
- " return 0;\n" +
- " }\n" +
- " void neuneu2() {\n" +
- " }\n" +
- "}\n" +
- "public class PA\n" +
- " extends PAHelper {\n" +
- " void foo() {\n" +
- " B[] b = \n" +
- " new java.lang.Number[]; \n" +
- " java.lang.Short s;\n" +
- " // b[1].;\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on new keyword>";
- String completeBehind = "n";
- String expectedCompletionNodeToString = "<CompleteOnName:n>";
- String completionIdentifier = "n";
- String expectedReplacedSource = "new";
- int cursorLocation = str.indexOf("new ") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class PAHelper {\n" +
- " public int fieldPublic;\n" +
- " protected int fieldProtected;\n" +
- " private int fieldPrivate;\n" +
- " int fieldDefault;\n" +
- " static int i;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " PAHelper() {\n" +
- " }\n" +
- " static void staticFoo() {\n" +
- " }\n" +
- " int neuneu1() {\n" +
- " }\n" +
- " void neuneu2() {\n" +
- " }\n" +
- "}\n" +
- "public class PA extends PAHelper {\n" +
- " public PA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " B[] b = <CompleteOnName:n>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testPB() {
- String str =
- "package p; \n" +
- "public class PB {\n" +
- " void foo() {\n" +
- " class Local {\n" +
- " void foo() {\n" +
- " }\n" +
- " class LocalMember1 {\n" +
- " void foo() {\n" +
- " class LocalMemberLocal {\n" +
- " void foo() {\n" +
- " f\n"+
- " }\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- " class LocalMember2 {\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field into nested local type>";
- String completeBehind = "f";
- String expectedCompletionNodeToString = "<CompleteOnName:f>";
- String completionIdentifier = "f";
- String expectedReplacedSource = "f";
- int cursorLocation = str.indexOf("f\n") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class PB {\n" +
- " public PB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " class Local {\n" +
- " class LocalMember1 {\n" +
- " LocalMember1() {\n" +
- " }\n" +
- " void foo() {\n" +
- " class LocalMemberLocal {\n" +
- " LocalMemberLocal() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:f>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- " }\n" +
- " class LocalMember2 {\n" +
- " LocalMember2() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- " Local() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testPC_1FSU4EF() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FSU4EF\n" +
- " */\n" +
- "import java.util.Vector;\n" +
- "public class PC {\n" +
- " void foo() {\n" +
- " class Inner {\n" +
- " Vector v = new Vector();\n" +
- " void foo() {\n" +
- " Vector v = new Vector();\n" +
- " v.addElement();\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field into local type>";
- String completeBehind = "v.a";
- String expectedCompletionNodeToString = "<CompleteOnName:v.a>";
- String completionIdentifier = "a";
- String expectedReplacedSource = "v.addElement";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import java.util.Vector;\n" +
- "public class PC {\n" +
- " public PC() {\n" +
- " }\n" +
- " void foo() {\n" +
- " class Inner {\n" +
- " Vector v;\n" +
- " Inner() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Vector v;\n" +
- " <CompleteOnName:v.a>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testQ_1FG1YU0() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FG1YU0\n" +
- " */\n" +
- "public class Q {\n" +
- " void bar(boolean bbbb) {\n" +
- " this.}\n" +
- "}\n";
-
- String testName = "<complete on method/field>";
- String completeBehind = "this.";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:this.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "this.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class Q {\n" +
- " public Q() {\n" +
- " }\n" +
- " void bar(boolean bbbb) {\n" +
- " <CompleteOnMemberAccess:this.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testQA_1() {
- String str =
- "package p; \n" +
- "class QAHelper {\n" +
- " int i = 10;\n" +
- " void f() {\n" +
- " Chk.chkIntVal(\n" +
- " \"err_0\", \n" +
- " \"i\", \n" +
- " this.i, \n" +
- " i); \n" +
- " }\n" +
- " static class Y\n" +
- " extends QAHelper {\n" +
- " public void f() {\n" +
- " super.f();\n" +
- " int j = super.i;\n" +
- " }\n" +
- " public static void main(String a[]) {\n" +
- " Y oy = new Y();\n" +
- " oy.f();\n" +
- " }\n" +
- " }\n" +
- "}\n" +
- "public class QA {\n" +
- " static String s[] = \n" +
- " {\"Dolby\", \"Thx\",}; \n" +
- " void check() {\n" +
- " new QAHelper().new Y().main(\n" +
- " s); \n" +
- " }\n" +
- " static public void main(String args[]) {\n" +
- " new QA().check();\n" +
- " Chk.endTest(\"ciner111\");\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field>";
- String completeBehind = "new QAHelper().new Y().m";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new QAHelper().new Y().m>";
- String completionIdentifier = "m";
- String expectedReplacedSource = "main";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class QAHelper {\n" +
- " static class Y extends QAHelper {\n" +
- " Y() {\n" +
- " }\n" +
- " public void f() {\n" +
- " }\n" +
- " public static void main(String[] a) {\n" +
- " }\n" +
- " }\n" +
- " int i;\n" +
- " QAHelper() {\n" +
- " }\n" +
- " void f() {\n" +
- " }\n" +
- "}\n" +
- "public class QA {\n" +
- " static String[] s;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public QA() {\n" +
- " }\n" +
- " void check() {\n" +
- " <CompleteOnMemberAccess:new QAHelper().new Y().m>;\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testQA_2() {
- String str =
- "package p; \n" +
- "class QAHelper {\n" +
- " int i = 10;\n" +
- " void f() {\n" +
- " Chk.chkIntVal(\n" +
- " \"err_0\", \n" +
- " \"i\", \n" +
- " this.i, \n" +
- " i); \n" +
- " }\n" +
- " static class Y\n" +
- " extends QAHelper {\n" +
- " public void f() {\n" +
- " super.f();\n" +
- " int j = super.i;\n" +
- " }\n" +
- " public static void main(String a[]) {\n" +
- " Y oy = new Y();\n" +
- " oy.f();\n" +
- " }\n" +
- " }\n" +
- "}\n" +
- "public class QA {\n" +
- " static String s[] = \n" +
- " {\"Dolby\", \"Thx\",}; \n" +
- " void check() {\n" +
- " new QAHelper().new Y().main(\n" +
- " s); \n" +
- " }\n" +
- " static public void main(String args[]) {\n" +
- " new QA().check();\n" +
- " Chk.endTest(\"ciner111\");\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of object creation>";
- String completeBehind = "new QAHelper().";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new QAHelper().>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class QAHelper {\n" +
- " static class Y extends QAHelper {\n" +
- " Y() {\n" +
- " }\n" +
- " public void f() {\n" +
- " }\n" +
- " public static void main(String[] a) {\n" +
- " }\n" +
- " }\n" +
- " int i;\n" +
- " QAHelper() {\n" +
- " }\n" +
- " void f() {\n" +
- " }\n" +
- "}\n" +
- "public class QA {\n" +
- " static String[] s;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public QA() {\n" +
- " }\n" +
- " void check() {\n" +
- " <CompleteOnMemberAccess:new QAHelper().>;\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testQA_3() {
- String str =
- "package p; \n" +
- "class QAHelper {\n" +
- " int i = 10;\n" +
- " void f() {\n" +
- " Chk.chkIntVal(\n" +
- " \"err_0\", \n" +
- " \"i\", \n" +
- " this.i, \n" +
- " i); \n" +
- " }\n" +
- " static class Y\n" +
- " extends QAHelper {\n" +
- " public void f() {\n" +
- " super.f();\n" +
- " int j = super.i;\n" +
- " }\n" +
- " public static void main(String a[]) {\n" +
- " Y oy = new Y();\n" +
- " oy.f();\n" +
- " }\n" +
- " }\n" +
- "}\n" +
- "public class QA {\n" +
- " static String s[] = \n" +
- " {\"Dolby\", \"Thx\",}; \n" +
- " void check() {\n" +
- " new QAHelper().new Y().main(\n" +
- " s); \n" +
- " }\n" +
- " static public void main(String args[]) {\n" +
- " new QA().check();\n" +
- " Chk.endTest(\"ciner111\");\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of object creation>";
- String completeBehind = "new QAHelper().new Y().";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new QAHelper().new Y().>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class QAHelper {\n" +
- " static class Y extends QAHelper {\n" +
- " Y() {\n" +
- " }\n" +
- " public void f() {\n" +
- " }\n" +
- " public static void main(String[] a) {\n" +
- " }\n" +
- " }\n" +
- " int i;\n" +
- " QAHelper() {\n" +
- " }\n" +
- " void f() {\n" +
- " }\n" +
- "}\n" +
- "public class QA {\n" +
- " static String[] s;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public QA() {\n" +
- " }\n" +
- " void check() {\n" +
- " <CompleteOnMemberAccess:new QAHelper().new Y().>;\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testQA_4() {
- String str =
- "package p; \n" +
- "class QAHelper {\n" +
- " int i = 10;\n" +
- " void f() {\n" +
- " Chk.chkIntVal(\n" +
- " \"err_0\", \n" +
- " \"i\", \n" +
- " this.i, \n" +
- " i); \n" +
- " }\n" +
- " static class Y\n" +
- " extends QAHelper {\n" +
- " public void f() {\n" +
- " super.f();\n" +
- " int j = super.i;\n" +
- " }\n" +
- " public static void main(String a[]) {\n" +
- " Y oy = new Y();\n" +
- " oy.f();\n" +
- " }\n" +
- " }\n" +
- "}\n" +
- "public class QA {\n" +
- " static String s[] = \n" +
- " {\"Dolby\", \"Thx\",}; \n" +
- " void check() {\n" +
- " new QAHelper().new Y().main(\n" +
- " s); \n" +
- " }\n" +
- " static public void main(String args[]) {\n" +
- " new QA().check();\n" +
- " Chk.endTest(\"ciner111\");\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of object creation>";
- String completeBehind = "new QA().";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new QA().>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class QAHelper {\n" +
- " static class Y extends QAHelper {\n" +
- " Y() {\n" +
- " }\n" +
- " public void f() {\n" +
- " }\n" +
- " public static void main(String[] a) {\n" +
- " }\n" +
- " }\n" +
- " int i;\n" +
- " QAHelper() {\n" +
- " }\n" +
- " void f() {\n" +
- " }\n" +
- "}\n" +
- "public class QA {\n" +
- " static String[] s;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public QA() {\n" +
- " }\n" +
- " void check() {\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " <CompleteOnMemberAccess:new QA().>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testQB_1FIK820() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FIK820\n" +
- " */\n" +
- "public class QB {\n" +
- " void foo() {\n" +
- " {\n" +
- " }\n" +
- " .}\n" +
- "}\n";
-
- String testName = "<complete on block (no answers wanted)>";
- String completeBehind = ".";
- String expectedCompletionNodeToString = "<CompleteOnName:>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(".}") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class QB {\n" +
- " public QB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testR_1FGD31E() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGD31E\n" +
- " */\n" +
- "public class R {\n" +
- " void moo() {\n" +
- " b }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field>";
- String completeBehind = "b";
- String expectedCompletionNodeToString = "<CompleteOnName:b>";
- String completionIdentifier = "b";
- String expectedReplacedSource = "b";
- int cursorLocation = str.indexOf("b }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class R {\n" +
- " public R() {\n" +
- " }\n" +
- " void moo() {\n" +
- " <CompleteOnName:b>;\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testRA_1() {
- String str =
- "package p; \n" +
- "public class RA extends A {\n" +
- " private int f = 5;\n" +
- " int i(int k) {\n" +
- " }\n" +
- " class B extends I {\n" +
- " void foo();\n" +
- " class C extends Z {\n" +
- " }\n" +
- " final int fo;\n" +
- " }\n" +
- " final void foo(k j) {\n" +
- " }\n" +
- " o o() throws Exc, Exc {\n" +
- " }\n" +
- " static {\n" +
- " this.ff = 5;\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on incorrect this call>";
- String completeBehind = "t";
- String expectedCompletionNodeToString = "<CompleteOnName:t>";
- String completionIdentifier = "t";
- String expectedReplacedSource = "this";
- int cursorLocation = str.indexOf("this.ff") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class RA extends A {\n" +
- " class B extends I {\n" +
- " class C extends Z {\n" +
- " C() {\n" +
- " }\n" +
- " }\n" +
- " final int fo;\n" +
- " B() {\n" +
- " }\n" +
- " void foo();\n" +
- " }\n" +
- " private int f;\n" +
- " static {\n" +
- " <CompleteOnName:t>;\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public RA() {\n" +
- " }\n" +
- " int i(int k) {\n" +
- " }\n" +
- " final void foo(k j) {\n" +
- " }\n" +
- " o o() throws Exc, Exc {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testRA_2() {
- String str =
- "package p; \n" +
- "public class RA extends A {\n" +
- " private int f = 5;\n" +
- " int i(int k) {\n" +
- " }\n" +
- " class B extends I {\n" +
- " void foo();\n" +
- " class C extends Z {\n" +
- " }\n" +
- " final int fo;\n" +
- " }\n" +
- " final void foo(k j) {\n" +
- " }\n" +
- " o o() throws Exc, Exc {\n" +
- " }\n" +
- " static {\n" +
- " this.ff = 5;\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on t>";
- String completeBehind = "t";
- String expectedCompletionNodeToString = "<CompleteOnName:t>";
- String completionIdentifier = "t";
- String expectedReplacedSource = "this";
- int cursorLocation = str.indexOf("this") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class RA extends A {\n" +
- " class B extends I {\n" +
- " class C extends Z {\n" +
- " C() {\n" +
- " }\n" +
- " }\n" +
- " final int fo;\n" +
- " B() {\n" +
- " }\n" +
- " void foo();\n" +
- " }\n" +
- " private int f;\n" +
- " static {\n" +
- " <CompleteOnName:t>;\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public RA() {\n" +
- " }\n" +
- " int i(int k) {\n" +
- " }\n" +
- " final void foo(k j) {\n" +
- " }\n" +
- " o o() throws Exc, Exc {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testRA_3() {
- String str =
- "package p; \n" +
- "public class RA extends A {\n" +
- " private int f = 5;\n" +
- " int i(int k) {\n" +
- " }\n" +
- " class B extends I {\n" +
- " void foo();\n" +
- " class C extends Z {\n" +
- " }\n" +
- " final int fo;\n" +
- " }\n" +
- " final void foo(k j) {\n" +
- " }\n" +
- " o o() throws Exc, Exc {\n" +
- " }\n" +
- " static {\n" +
- " this.ff = 5;\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on exception type>";
- String completeBehind = "Exc";
- String expectedCompletionNodeToString = "<CompleteOnException:Exc>";
- String completionIdentifier = "Exc";
- String expectedReplacedSource = "Exc";
- int cursorLocation = str.indexOf("Exc {") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class RA extends A {\n" +
- " class B extends I {\n" +
- " class C extends Z {\n" +
- " C() {\n" +
- " }\n" +
- " }\n" +
- " final int fo;\n" +
- " B() {\n" +
- " }\n" +
- " void foo();\n" +
- " }\n" +
- " private int f;\n" +
- " static {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public RA() {\n" +
- " }\n" +
- " int i(int k) {\n" +
- " }\n" +
- " final void foo(k j) {\n" +
- " }\n" +
- " o o() throws Exc, <CompleteOnException:Exc> {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testRB_1FI74S3() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FI74S3\n" +
- " */\n" +
- "public class RB {\n" +
- " int[] table;\n" +
- " void foo() {\n" +
- " int x = table.}\n" +
- "}\n";
-
- String testName = "<complete on method/field of arry>";
- String completeBehind = "table.";
- String expectedCompletionNodeToString = "<CompleteOnName:table.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "table.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class RB {\n" +
- " int[] table;\n" +
- " public RB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int x = <CompleteOnName:table.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testS_1FGF64P_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGF64P\n" +
- " */\n" +
- "public class S {\n" +
- " {\n" +
- " new Y()..}\n" +
- " class Y {\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on incorrect call>";
- String completeBehind = "new Y()..";
- String expectedCompletionNodeToString = "<CompleteOnName:>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class S {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- " {\n" +
- " {\n" +
- " <CompleteOnName:>;\n" +
- " }\n" +
- " }\n" +
- " public S() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testS_1FGF64P_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGF64P\n" +
- " */\n" +
- "public class S {\n" +
- " {\n" +
- " new Y()..}\n" +
- " class Y {\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of object creation>";
- String completeBehind = "new Y().";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new Y().>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class S {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- " {\n" +
- " <CompleteOnMemberAccess:new Y().>;\n" +
- " }\n" +
- " public S() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testS_1FGF64P_3() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGF64P\n" +
- " */\n" +
- "public class S {\n" +
- " {\n" +
- " new Y()..}\n" +
- " class Y {\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on incorrect call>";
- String completeBehind = "new Y()..";
- String expectedCompletionNodeToString = "<CompleteOnName:>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class S {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- " {\n" +
- " {\n" +
- " <CompleteOnName:>;\n" +
- " }\n" +
- " }\n" +
- " public S() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testSA() {
- String str =
- "package p; \n" +
- "public class SA {\n" +
- " public sy void foo() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method modifier>";
- String completeBehind = "sy";
- String expectedCompletionNodeToString = "<CompleteOnType:sy>";
- String completionIdentifier = "sy";
- String expectedReplacedSource = "sy";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class SA {\n" +
- " <CompleteOnType:sy>;\n" +
- " public SA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testSB_1FILFDG() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FILFDG\n" +
- " */\n" +
- "public class SB {\n" +
- " public void foo() {\n" +
- " String s = \"hello\n" +
- " int}\n" +
- "}\n";
-
- String testName = "<complete on field declaration type>";
- String completeBehind = "int";
- String expectedCompletionNodeToString = "<CompleteOnName:int>";
- String completionIdentifier = "int";
- String expectedReplacedSource = "int";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class SB {\n" +
- " public SB() {\n" +
- " }\n" +
- " public void foo() {\n" +
- " String s;\n" +
- " <CompleteOnName:int>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testT_1FGF64P() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGF64P\n" +
- " */\n" +
- "public class T {\n" +
- " {\n" +
- " new Y().}\n" +
- " class Y {\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on object creation>";
- String completeBehind = "new Y().";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new Y().>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class T {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- " {\n" +
- " <CompleteOnMemberAccess:new Y().>;\n" +
- " }\n" +
- " public T() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testTA_1FHISJJ_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHISJJ\n" +
- " */\n" +
- "public class TA {\n" +
- " void foo() {\n" +
- " Object[] items = \n" +
- " {\n" +
- " \"Mark unublishable\", \n" +
- " null, \n" +
- " \"Properties...\"}\n" +
- " .;\n" +
- " items.}\n" +
- "}\n";
-
- String testName = "<complete on array intializer value>";
- String completeBehind = "n";
- String expectedCompletionNodeToString = "<CompleteOnName:n>";
- String completionIdentifier = "n";
- String expectedReplacedSource = "null";
- int cursorLocation = str.indexOf("null, ") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class TA {\n" +
- " public TA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Object[] items;\n" +
- " <CompleteOnName:n>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testTA_1FHISJJ_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHISJJ\n" +
- " */\n" +
- "public class TA {\n" +
- " void foo() {\n" +
- " Object[] items = \n" +
- " {\n" +
- " \"Mark unublishable\", \n" +
- " null, \n" +
- " \"Properties...\"}\n" +
- " .;\n" +
- " items.}\n" +
- "}\n";
-
- String testName = "<complete on method/field of array intializer>";
- String completeBehind =
- " {\n" +
- " \"Mark unublishable\", \n" +
- " null, \n" +
- " \"Properties...\"}\n" +
- " .";
- String expectedCompletionNodeToString = "<CompleteOnName:>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class TA {\n" +
- " public TA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Object[] items;\n" +
- " <CompleteOnName:>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testTA_1FHISJJ_3() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHISJJ\n" +
- " */\n" +
- "public class TA {\n" +
- " void foo() {\n" +
- " Object[] items = \n" +
- " {\n" +
- " \"Mark unublishable\", \n" +
- " null, \n" +
- " \"Properties...\"}\n" +
- " .;\n" +
- " items.}\n" +
- "}\n";
-
- String testName = "<complete on method/field of array>";
- String completeBehind = "items.";
- String expectedCompletionNodeToString = "<CompleteOnName:items.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "items.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class TA {\n" +
- " public TA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Object[] items;\n" +
- " <CompleteOnName:items.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testTB_1FHSLMQ() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHSLMQ\n" +
- " */\n" +
- "public class TB {\n" +
- " void foo() {\n" +
- " if (true)\n" +
- " System.out.println(\"\");\n" +
- " e }\n" +
- "}\n";
-
- String testName = "<complete on else keyword>";
- String completeBehind = "e";
- String expectedCompletionNodeToString = "<CompleteOnName:e>";
- String completionIdentifier = "e";
- String expectedReplacedSource = "e";
- int cursorLocation = str.indexOf("e }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class TB {\n" +
- " public TB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:e>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testU_1FGGUME() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGGUME\n" +
- " */\n" +
- "public class U {\n" +
- " public static final int Source = \n" +
- " 5; \n" +
- "}\n";
-
- String testName = "<complete on digit>";
- String completeBehind = "5";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = "";
- String expectedReplacedSource = NONE;
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString = null;
-
- try {
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
- assertTrue("failed to detect invalid cursor location", false);
- } catch(InvalidCursorLocation e){
- assertEquals("invalid cursor location: ", e.irritant, InvalidCursorLocation.NO_COMPLETION_INSIDE_NUMBER);
- }
-}
-public void testUA_1FHISJJ_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHISJJ\n" +
- " */\n" +
- "public class UA {\n" +
- " void foo() {\n" +
- " Object[] items = \n" +
- " new String[] {\n" +
- " \"Mark unublishable\", \n" +
- " null, \n" +
- " \"Properties...\"}\n" +
- " .;\n" +
- " items.}\n" +
- "}\n";
-
- String testName = "<complete on array initializer>";
- String completeBehind =
- "new String[] {\n" +
- " \"Mark unublishable\", \n" +
- " null, \n" +
- " \"Properties...\"}\n" +
- " .";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new String[]{\"Mark unublishable\",null,\"Properties...\",}.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class UA {\n" +
- " public UA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Object[] items = <CompleteOnMemberAccess:new String[]{\"Mark unublishable\",null,\"Properties...\",}.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testUA_1FHISJJ_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHISJJ\n" +
- " */\n" +
- "public class UA {\n" +
- " void foo() {\n" +
- " Object[] items = \n" +
- " new String[] {\n" +
- " \"Mark unublishable\", \n" +
- " null, \n" +
- " \"Properties...\"}\n" +
- " .;\n" +
- " items.}\n" +
- "}\n";
-
- String testName = "<complete on method/field of array>";
- String completeBehind = "items.";
- String expectedCompletionNodeToString = "<CompleteOnName:items.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "items.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class UA {\n" +
- " public UA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Object[] items;\n" +
- " <CompleteOnName:items.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testUB_1FSBZ02() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FSBZ02\n" +
- " */\n" +
- "class UB {\n" +
- " void bar() {\n" +
- " }\n" +
- " class UBMember {\n" +
- " void bar2() {\n" +
- " }\n" +
- " void foo() {\n" +
- " b\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on keyword>";
- String completeBehind = "b";
- String expectedCompletionNodeToString = "<CompleteOnName:b>";
- String completionIdentifier = "b";
- String expectedReplacedSource = "b";
- int cursorLocation = str.indexOf("b\n") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class UB {\n" +
- " class UBMember {\n" +
- " UBMember() {\n" +
- " }\n" +
- " void bar2() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:b>;\n" +
- " }\n" +
- " }\n" +
- " UB() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testV_1FGGUOO_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGGUOO\n" +
- " */\n" +
- "public class V i java\n" +
- " .io\n" +
- " .Serializable {\n" +
- "}\n";
-
- String testName = "<complete on implements keyword>";
- String completeBehind = "i";
- String expectedCompletionNodeToString = "<CompleteOnType:i>";
- String completionIdentifier = "i";
- String expectedReplacedSource = "i";
- int cursorLocation = str.indexOf("i java") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class V {\n" +
- " <CompleteOnType:i>;\n" +
- " {\n" +
- " }\n" +
- " public V() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testV_1FGGUOO_2() {
- String str =
- "package x.y.z; \n" +
- "/**\n" +
- " * 1FGGUOO\n" +
- " */\n" +
- "public class V implements java.io.Serializable {\n" +
- "}\n";
-
- String testName = "<complete on package>";
- String completeBehind = "y";
- String expectedCompletionNodeToString = "<CompleteOnPackage:x.y>";
- String completionIdentifier = "y";
- String expectedReplacedSource =
- "x.y.z";
- int cursorLocation = str.indexOf("y") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package <CompleteOnPackage:x.y>;\n" +
- "public class V implements java.io.Serializable {\n" +
- " public V() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testVA_1FHISJJ_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHISJJ\n" +
- " */\n" +
- "public class VA {\n" +
- " void foo() {\n" +
- " Object item = new String() {\n" +
- " public boolean equals() {\n" +
- " return false;\n" +
- " }\n" +
- " }\n" +
- " .;\n" +
- " item.}\n" +
- "}\n";
-
- String testName = "<complete on anonymous type declaration>";
- String completeBehind =
- "new String() {\n" +
- " public boolean equals() {\n" +
- " return false;\n" +
- " }\n" +
- " }\n" +
- " .";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new String() {\n" +
- " public boolean equals() {\n" +
- " return false;\n" +
- " }\n" +
- "}.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class VA {\n" +
- " public VA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Object item = <CompleteOnMemberAccess:new String() {\n" +
- " public boolean equals() {\n" +
- " return false;\n" +
- " }\n" +
- "}.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testVA_1FHISJJ_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FHISJJ\n" +
- " */\n" +
- "public class VA {\n" +
- " void foo() {\n" +
- " Object item = new String() {\n" +
- " public boolean equals() {\n" +
- " return false;\n" +
- " }\n" +
- " }\n" +
- " .;\n" +
- " item.}\n" +
- "}\n";
-
- String testName = "<complete on local variable>";
- String completeBehind = "item.";
- String expectedCompletionNodeToString = "<CompleteOnName:item.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "item.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class VA {\n" +
- " public VA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Object item;\n" +
- " <CompleteOnName:item.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testVB_1() {
- String str =
- "package p; \n" +
- "public class VB {\n" +
- " void foo() {\n" +
- " new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " }\n" +
- " .;\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on local variable name into anonymous declaration>";
- String completeBehind = "v";
- String expectedCompletionNodeToString = "<CompleteOnName:v>";
- String completionIdentifier = "v";
- String expectedReplacedSource = "v";
- int cursorLocation = str.indexOf("v }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class VB {\n" +
- " public VB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new java.io.File(\"error\") {\n" +
- " () {\n" +
- " }\n" +
- " protected void runTest() {\n" +
- " Vector v11111;\n" +
- " <CompleteOnName:v>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testVB_2() {
- String str =
- "package p; \n" +
- "public class VB {\n" +
- " void foo() {\n" +
- " new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " }.\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on anonymous type declaration>";
- String completeBehind =
- "new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " }.";
- String expectedCompletionNodeToString =
- "<CompleteOnMemberAccess:new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " }\n" +
- "}.>";
- String completionIdentifier = "";
- String expectedReplacedSource =
- "new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " }.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class VB {\n" +
- " public VB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " }\n" +
- "}.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testVB_3() {
- String str =
- "package p; \n" +
- "public class VB {\n" +
- " void foo() {\n" +
- " new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " }\n" +
- " .;\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on constructor>";
- String completeBehind = "new java.io.File(";
- String expectedCompletionNodeToString = "<CompleteOnAllocationExpression:new java.io.File()>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class VB {\n" +
- " public VB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnAllocationExpression:new java.io.File()>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testVB_4() {
- String str =
- "package p; \n" +
- "public class VB {\n" +
- " void foo() {\n" +
- " new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " }\n" +
- " .;\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on anonymous type declaration with dummy spaces>";
- String completeBehind =
- "new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " }\n" +
- " .";
- String expectedCompletionNodeToString =
- "<CompleteOnName:new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " }\n" +
- "}.>";
- String completionIdentifier = "";
- String expectedReplacedSource =
- "new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " }\n" +
- " .";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class VB {\n" +
- " public VB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " }\n" +
- "}.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testVB_5() {
- String str =
- "package p; \n" +
- "public class VB {\n" +
- " void foo() {\n" +
- " new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " }.;\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on anonymous type declaration with trailing semi-colon>";
- String completeBehind =
- "new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " }.";
- String expectedCompletionNodeToString =
- "<CompleteOnMemberAccess:new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " }\n" +
- "}.>";
- String completionIdentifier = "";
- String expectedReplacedSource =
- "new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " Vector v11111 = new Vector();\n" +
- " v }\n" +
- " }.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class VB {\n" +
- " public VB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:new java.io.File(\"error\") {\n" +
- " protected void runTest() {\n" +
- " }\n" +
- "}.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testW_1FGGUS4() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGGUS4\n" +
- " */\n" +
- "public class W {\n" +
- " public static final int LA = \n" +
- " 1; \n" +
- " public static final int LAB = \n" +
- " 2; \n" +
- " public static final int LABO = \n" +
- " 4; \n" +
- " public int produceDebugAttributes = \n" +
- " LABO; \n" +
- "}\n";
-
- String testName = "<complete on field initializer>";
- String completeBehind = "L";
- String expectedCompletionNodeToString = "<CompleteOnName:L>";
- String completionIdentifier = "L";
- String expectedReplacedSource = "LABO";
- int cursorLocation = str.indexOf("LABO;") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class W {\n" +
- " public static final int LA;\n" +
- " public static final int LAB;\n" +
- " public static final int LABO;\n" +
- " public int produceDebugAttributes = <CompleteOnName:L>;\n" +
- " public W() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testWA_1() {
- String str =
- "package p; \n" +
- "public class WA {\n" +
- " void foo() {\n" +
- " int value = 10;\n" +
- " v int[] tab = new int[value];\n" +
- " }\n";
-
- String testName = "<complete on array size value>";
- String completeBehind = "v";
- String expectedCompletionNodeToString = "<CompleteOnName:v>";
- String completionIdentifier = "v";
- String expectedReplacedSource = "value";
- int cursorLocation = str.indexOf("value];") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class WA {\n" +
- " public WA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int value;\n" +
- " int[] tab;\n" +
- " <CompleteOnName:v>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testWA_2() {
- String str =
- "package p; \n" +
- "public class WA {\n" +
- " void foo() {\n" +
- " int value = 10;\n" +
- " v int[] tab = new int[value];\n" +
- " }\n";
-
- String testName = "<complete on corrupter local variable declaration>";
- String completeBehind = "v";
- String expectedCompletionNodeToString = "<CompleteOnName:v>";
- String completionIdentifier = "v";
- String expectedReplacedSource = "v";
- int cursorLocation = str.indexOf("v int[]") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class WA {\n" +
- " public WA() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int value;\n" +
- " <CompleteOnName:v>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testWB_1FI313C() {
- String str =
- "package p; \n" +
- "/*\n" +
- " * 1FI313C\n" +
- " */\n" +
- "class WBHelper {\n" +
- " public int fieldPublic;\n" +
- " protected int fieldProtected;\n" +
- " private int fieldPrivate;\n" +
- " int fieldDefault;\n" +
- " static void staticFoo() {\n" +
- " }\n" +
- " static int i = d;\n" +
- " int neuneu1() {\n" +
- " }\n" +
- " void neuneu2() {\n" +
- " }\n" +
- "}\n" +
- "public class WB\n" +
- " extends WBHelper {\n" +
- " void foo() {\n" +
- " BIJOUR[] b = \n" +
- " new java.lang.Number[]; \n" +
- " java.lang.Short s;\n" +
- " b[1].}\n" +
- " B() {\n" +
- " }\n" +
- " B(int) {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of array element>";
- String completeBehind = "b[1].";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:b[1].>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "class WBHelper {\n" +
- " public int fieldPublic;\n" +
- " protected int fieldProtected;\n" +
- " private int fieldPrivate;\n" +
- " int fieldDefault;\n" +
- " static int i;\n" +
- " WBHelper() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " static void staticFoo() {\n" +
- " }\n" +
- " int neuneu1() {\n" +
- " }\n" +
- " void neuneu2() {\n" +
- " }\n" +
- "}\n" +
- "public class WB extends WBHelper {\n" +
- " public WB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " BIJOUR[] b;\n" +
- " java.lang.Short s;\n" +
- " <CompleteOnMemberAccess:b[1].>;\n" +
- " }\n" +
- " B() {\n" +
- " }\n" +
- " B() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testX_1FGGV8C_1() {
- String str =
- "package p; \n" +
- "import p2.Y; \n" +
- "/**\n" +
- " * 1FGGV8C and 1FGPE8E\n" +
- " */\n" +
- "public class X {\n" +
- " public static final float Vars; \n" +
- " public static final float Lines; \n" +
- " public static final float Source; \n" +
- " public static final float UnreachableCode; \n" +
- " public static final float produceDebugAttributes; \n" +
- " void foo() {\n" +
- " int locale, \n" +
- " errorThreshold, \n" +
- " preserveAllLocalVariables; \n" +
- " return new Y[] {\n" +
- " new Y(\n" +
- " \"debug.vars\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Vars)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new Y(\n" +
- " \"debug.lines\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Lines)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new Y(\n" +
- " \"debug.source\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Source)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new Y(\n" +
- " \"debug.preserveAllLocals\", \n" +
- " this, \n" +
- " locale, \n" +
- " preserveAllLocalVariables\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new Y(\n" +
- " \"optionalError.unReachableCode\", \n" +
- " this, \n" +
- " locale, \n" +
- " (errorThreshold\n" +
- " & UnreachableCode)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1)\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on argument of anonymous type declaration>";
- String completeBehind = "t";
- String expectedCompletionNodeToString = "<CompleteOnName:t>";
- String completionIdentifier = "t";
- String expectedReplacedSource = "this";
- int cursorLocation = str.indexOf("this, ") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import p2.Y;\n" +
- "public class X {\n" +
- " public static final float Vars;\n" +
- " public static final float Lines;\n" +
- " public static final float Source;\n" +
- " public static final float UnreachableCode;\n" +
- " public static final float produceDebugAttributes;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int locale;\n" +
- " int errorThreshold;\n" +
- " int preserveAllLocalVariables;\n" +
- " <CompleteOnName:t>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testX_1FGGV8C_2() {
- String str =
- "package p; \n" +
- "import p2.YZA; \n" +
- "/**\n" +
- " * 1FGGV8C and 1FGPE8E\n" +
- " */\n" +
- "public class X {\n" +
- " public static final float Vars; \n" +
- " public static final float Lines; \n" +
- " public static final float Source; \n" +
- " public static final float UnreachableCode; \n" +
- " public static final float produceDebugAttributes; \n" +
- " void foo() {\n" +
- " int locale, \n" +
- " errorThreshold, \n" +
- " preserveAllLocalVariables; \n" +
- " return new YZA[] {\n" +
- " new YZA(\n" +
- " \"debug.vars\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Vars)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new YZA(\n" +
- " \"debug.lines\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Lines)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new YZA(\n" +
- " \"debug.source\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Source)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new YZA(\n" +
- " \"debug.preserveAllLocals\", \n" +
- " this, \n" +
- " locale, \n" +
- " preserveAllLocalVariables\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new YZA(\n" +
- " \"optionalError.unReachableCode\", \n" +
- " this, \n" +
- " locale, \n" +
- " (errorThreshold\n" +
- " & UnreachableCode)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1)\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on anonymous type declaration into a return statement>";
- String completeBehind = "Y";
- String expectedCompletionNodeToString = "<CompleteOnType:Y>";
- String completionIdentifier = "Y";
- String expectedReplacedSource = "YZA";
- int cursorLocation = str.indexOf("YZA[]") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import p2.YZA;\n" +
- "public class X {\n" +
- " public static final float Vars;\n" +
- " public static final float Lines;\n" +
- " public static final float Source;\n" +
- " public static final float UnreachableCode;\n" +
- " public static final float produceDebugAttributes;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int locale;\n" +
- " int errorThreshold;\n" +
- " int preserveAllLocalVariables;\n" +
- " new <CompleteOnType:Y>();\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testX_1FGGV8C_3() {
- String str =
- "package p; \n" +
- "import p2.YZA; \n" +
- "/**\n" +
- " * 1FGGV8C and 1FGPE8E\n" +
- " */\n" +
- "public class X {\n" +
- " public static final float Vars; \n" +
- " public static final float Lines; \n" +
- " public static final float Source; \n" +
- " public static final float UnreachableCode; \n" +
- " public static final float produceDebugAttributes; \n" +
- " void foo() {\n" +
- " int locale, \n" +
- " errorThreshold, \n" +
- " preserveAllLocalVariables; \n" +
- " return new YZA[] {\n" +
- " new YZA(\n" +
- " \"debug.vars\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Vars)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new YZA(\n" +
- " \"debug.lines\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Lines)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new YZA(\n" +
- " \"debug.source\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Source)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new YZA(\n" +
- " \"debug.preserveAllLocals\", \n" +
- " this, \n" +
- " locale, \n" +
- " preserveAllLocalVariables\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new YZA(\n" +
- " \"optionalError.unReachableCode\", \n" +
- " this, \n" +
- " locale, \n" +
- " (errorThreshold\n" +
- " & UnreachableCode)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1)\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on anonymous type declaration nested into an array initializer>";
- String completeBehind = "Y";
- String expectedCompletionNodeToString = "<CompleteOnType:Y>";
- String completionIdentifier = "Y";
- String expectedReplacedSource = "YZA";
- int cursorLocation = str.indexOf("YZA(") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import p2.YZA;\n" +
- "public class X {\n" +
- " public static final float Vars;\n" +
- " public static final float Lines;\n" +
- " public static final float Source;\n" +
- " public static final float UnreachableCode;\n" +
- " public static final float produceDebugAttributes;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int locale;\n" +
- " int errorThreshold;\n" +
- " int preserveAllLocalVariables;\n" +
- " new <CompleteOnType:Y>();\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testX_1FGGV8C_4() {
- String str =
- "package p; \n" +
- "import p2.Y; \n" +
- "/**\n" +
- " * 1FGGV8C and 1FGPE8E\n" +
- " */\n" +
- "public class X {\n" +
- " public static final float Vars; \n" +
- " public static final float Lines; \n" +
- " public static final float Source; \n" +
- " public static final float UnreachableCode; \n" +
- " public static final float produceDebugAttributes; \n" +
- " void foo() {\n" +
- " int locale, \n" +
- " errorThreshold, \n" +
- " preserveAllLocalVariables; \n" +
- " return new Y[] {\n" +
- " new Y(\n" +
- " \"debug.vars\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Vars)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new Y(\n" +
- " \"debug.lines\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Lines)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new Y(\n" +
- " \"debug.source\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Source)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new Y(\n" +
- " \"debug.preserveAllLocals\", \n" +
- " this, \n" +
- " locale, \n" +
- " preserveAllLocalVariables\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new Y(\n" +
- " \"optionalError.unReachableCode\", \n" +
- " this, \n" +
- " locale, \n" +
- " (errorThreshold\n" +
- " & UnreachableCode)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1)\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field into array intializer>";
- String completeBehind = "n";
- String expectedCompletionNodeToString = "<CompleteOnName:n>";
- String completionIdentifier = "n";
- String expectedReplacedSource = "new";
- int cursorLocation = str.indexOf("new Y(") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import p2.Y;\n" +
- "public class X {\n" +
- " public static final float Vars;\n" +
- " public static final float Lines;\n" +
- " public static final float Source;\n" +
- " public static final float UnreachableCode;\n" +
- " public static final float produceDebugAttributes;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int locale;\n" +
- " int errorThreshold;\n" +
- " int preserveAllLocalVariables;\n" +
- " <CompleteOnName:n>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testX_1FGPE8E() {
- String str =
- "package p; \n" +
- "import p2.Y; \n" +
- "/**\n" +
- " * 1FGGV8C and 1FGPE8E\n" +
- " */\n" +
- "public class X {\n" +
- " public static final float Vars; \n" +
- " public static final float Lines; \n" +
- " public static final float Source; \n" +
- " public static final float UnreachableCode; \n" +
- " public static final float produceDebugAttributes; \n" +
- " void foo() {\n" +
- " int locale, \n" +
- " errorThreshold, \n" +
- " preserveAllLocalVariables; \n" +
- " return new Y[] {\n" +
- " new Y(\n" +
- " \"debug.vars\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Vars)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new Y(\n" +
- " \"debug.lines\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Lines)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new Y(\n" +
- " \"debug.source\", \n" +
- " this, \n" +
- " locale, \n" +
- " (produceDebugAttributes\n" +
- " & Source)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new Y(\n" +
- " \"debug.preserveAllLocals\", \n" +
- " this, \n" +
- " locale, \n" +
- " preserveAllLocalVariables\n" +
- " ? 0\n" +
- " : 1), \n" +
- " new Y(\n" +
- " \"optionalError.unReachableCode\", \n" +
- " this, \n" +
- " locale, \n" +
- " (errorThreshold\n" +
- " & UnreachableCode)\n" +
- " != 0\n" +
- " ? 0\n" +
- " : 1)\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field into return statement>";
- String completeBehind = "n";
- String expectedCompletionNodeToString = "<CompleteOnName:n>";
- String completionIdentifier = "n";
- String expectedReplacedSource = "new";
- int cursorLocation = str.indexOf("new Y[]") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import p2.Y;\n" +
- "public class X {\n" +
- " public static final float Vars;\n" +
- " public static final float Lines;\n" +
- " public static final float Source;\n" +
- " public static final float UnreachableCode;\n" +
- " public static final float produceDebugAttributes;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int locale;\n" +
- " int errorThreshold;\n" +
- " int preserveAllLocalVariables;\n" +
- " <CompleteOnName:n>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testXA_1FGGUQF_1FHSL8H_1() {
- String str =
- "// int\n" +
- "package p; \n" +
- "/**\n" +
- " * 1FGGUQF and 1FHSL8H\n" +
- " */\n" +
- "/**\n" +
- " * int\n" +
- " */\n" +
- "/*\n" +
- " * int\n" +
- " */\n" +
- "// int\n" +
- "/**\n" +
- "int.\n" +
- " * Internal API used to resolve a compilation unit minimally for code assist engine\n" +
- " */\n" +
- "/**\n" +
- " * int\n" +
- " */\n" +
- "public class XA {\n" +
- " // int\n" +
- " /* int */\n" +
- " /** int */\n" +
- " /**\n" +
- " int.\n" +
- " * Internal API used to resolve a compilation unit minimally for code assist engine\n" +
- " */\n" +
- " void /* int */\n" +
- " foo() {\n" +
- " // int\n" +
- " /* int */\n" +
- " /** int */\n" +
- " }\n" +
- " /**\n" +
- " int.\n" +
- " * Internal API used to resolve a compilation unit minimally for code assist engine\n" +
- " */\n" +
- " int field /* int */\n" +
- " ;\n" +
- " /*\n" +
- " int\n" +
- " */\n" +
- " static {\n" +
- " // int\n" +
- " }\n" +
- "}\n" +
- "// int\n" +
- "/* int */\n" +
- "/** int */\n";
-
- String testName = "<complete on comment>";
- String completeBehind = "int.";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = "";
- String expectedReplacedSource = NONE;
- int cursorLocation = str.indexOf("int.\n") + completeBehind.length() - 1;
- String expectedUnitDisplayString = null;
-
- try {
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
- assertTrue("failed to detect invalid cursor location", false);
- } catch(InvalidCursorLocation e){
- assertEquals("invalid cursor location: ", e.irritant, InvalidCursorLocation.NO_COMPLETION_INSIDE_COMMENT);
- }
-}
-public void testXA_1FGGUQF_1FHSL8H_2() {
- String str =
- "// int\n" +
- "package p; \n" +
- "/**\n" +
- " * 1FGGUQF and 1FHSL8H\n" +
- " */\n" +
- "/**\n" +
- " * int\n" +
- " */\n" +
- "/*\n" +
- " * int\n" +
- " */\n" +
- "// int\n" +
- "/**\n" +
- "int.\n" +
- " * Internal API used to resolve a compilation unit minimally for code assist engine\n" +
- " */\n" +
- "/**\n" +
- " * int\n" +
- " */\n" +
- "public class XA {\n" +
- " // int\n" +
- " /* int */\n" +
- " /** int */\n" +
- " /**\n" +
- " int.\n" +
- " * Internal API used to resolve a compilation unit minimally for code assist engine\n" +
- " */\n" +
- " void /* int */\n" +
- " foo() {\n" +
- " // int\n" +
- " /* int */\n" +
- " /** int */\n" +
- " }\n" +
- " /**\n" +
- " int.\n" +
- " * Internal API used to resolve a compilation unit minimally for code assist engine\n" +
- " */\n" +
- " int field /* int */\n" +
- " ;\n" +
- " /*\n" +
- " int\n" +
- " */\n" +
- " static {\n" +
- " // int\n" +
- " }\n" +
- "}\n" +
- "// int\n" +
- "/* int */\n" +
- "/** int */\n";
-
- String testName = "<complete on comment>";
- String completeBehind = "i";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = "";
- String expectedReplacedSource = NONE;
- int cursorLocation = str.indexOf("int\n") + completeBehind.length() - 1;
- String expectedUnitDisplayString = null;
-
- try {
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
- assertTrue("failed to detect invalid cursor location", false);
- } catch(InvalidCursorLocation e){
- assertEquals("invalid cursor location: ", e.irritant, InvalidCursorLocation.NO_COMPLETION_INSIDE_COMMENT);
- }
-}
-public void testXA_1FGGUQF_1FHSL8H_3() {
- String str =
- "// int\n" +
- "package p; \n" +
- "/**\n" +
- " * 1FGGUQF and 1FHSL8H\n" +
- " */\n" +
- "/**\n" +
- " * int\n" +
- " */\n" +
- "/*\n" +
- " * int\n" +
- " */\n" +
- "// int\n" +
- "/**\n" +
- "int.\n" +
- " * Internal API used to resolve a compilation unit minimally for code assist engine\n" +
- " */\n" +
- "/**\n" +
- " * int\n" +
- " */\n" +
- "public class XA {\n" +
- " // int\n" +
- " /* int */\n" +
- " /** int */\n" +
- " /**\n" +
- " int.\n" +
- " * Internal API used to resolve a compilation unit minimally for code assist engine\n" +
- " */\n" +
- " void /* int */ foo() {\n" +
- " // int\n" +
- " /* int */\n" +
- " /** int */\n" +
- " }\n" +
- " /**\n" +
- " int.\n" +
- " * Internal API used to resolve a compilation unit minimally for code assist engine\n" +
- " */\n" +
- " int field /* int */\n" +
- " ;\n" +
- " /*\n" +
- " int\n" +
- " */\n" +
- " static {\n" +
- " // int\n" +
- " }\n" +
- "}\n" +
- "// int\n" +
- "/* int */\n" +
- "/** int */\n";
-
- String testName = "<complete on comment>";
- String completeBehind = "i";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = "";
- String expectedReplacedSource = NONE;
- int cursorLocation = str.indexOf("int */") + completeBehind.length() - 1;
- String expectedUnitDisplayString = null;
-
- try {
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
- assertTrue("failed to detect invalid cursor location", false);
- } catch(InvalidCursorLocation e){
- assertEquals("invalid cursor location: ", e.irritant, InvalidCursorLocation.NO_COMPLETION_INSIDE_COMMENT);
- }
-}
-public void testXA_1FGGUQF_1FHSL8H_4() {
- String str =
- "// int\n" +
- "package p; \n" +
- "/**\n" +
- " * 1FGGUQF and 1FHSL8H\n" +
- " */\n" +
- "/**\n" +
- " * int\n" +
- " */\n" +
- "/*\n" +
- " * int\n" +
- " */\n" +
- "// int\n" +
- "/**\n" +
- "int.\n" +
- " * Internal API used to resolve a compilation unit minimally for code assist engine\n" +
- " */\n" +
- "/**\n" +
- " * int\n" +
- " */\n" +
- "public class XA {\n" +
- " // int\n" +
- " /* int */\n" +
- " /** int */\n" +
- " /**\n" +
- " int.\n" +
- " * Internal API used to resolve a compilation unit minimally for code assist engine\n" +
- " */\n" +
- " void /* int */ foo() {\n" +
- " // int\n" +
- " /* int */\n" +
- " /** int */\n" +
- " }\n" +
- " /**\n" +
- " int.\n" +
- " * Internal API used to resolve a compilation unit minimally for code assist engine\n" +
- " */\n" +
- " int field /* int */\n" +
- " ;\n" +
- " /*\n" +
- " int\n" +
- " */\n" +
- " static {\n" +
- " // int\n" +
- " }\n" +
- "}\n" +
- "// int\n" +
- "/* int */\n" +
- "/** int */\n";
-
- String testName = "<complete on comment>";
- String completeBehind = "i";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = "";
- String expectedReplacedSource = NONE;
- int cursorLocation = str.indexOf("int */ foo()") + completeBehind.length() - 1;
- String expectedUnitDisplayString = null;
-
- try {
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
- assertTrue("failed to detect invalid cursor location", false);
- } catch(InvalidCursorLocation e){
- assertEquals("invalid cursor location: ", e.irritant, InvalidCursorLocation.NO_COMPLETION_INSIDE_COMMENT);
- }
-}
-public void testXB_1FIYM5I_1() {
- String str =
- "package p; \n" +
- "/*\n" +
- " * 1FIYM5I\n" +
- " */\n" +
- "public class XB\n" +
- " extends java.io.File {\n" +
- " void foo() {\n" +
- " XB xb = new XB();\n" +
- " this.separator.;\n" +
- " this.bar().;\n" +
- " }\n" +
- " String bar() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of explicit this access>";
- String completeBehind = "this.s";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:this.s>";
- String completionIdentifier = "s";
- String expectedReplacedSource = "this.separator";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class XB extends java.io.File {\n" +
- " public XB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " XB xb;\n" +
- " <CompleteOnMemberAccess:this.s>;\n" +
- " }\n" +
- " String bar() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testXB_1FIYM5I_2() {
- String str =
- "package p; \n" +
- "/*\n" +
- " * 1FIYM5I\n" +
- " */\n" +
- "public class XB\n" +
- " extends java.io.File {\n" +
- " void foo() {\n" +
- " XB xb = new XB();\n" +
- " this.separator.;\n" +
- " this.bar().;\n" +
- " }\n" +
- " String bar() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of explicitly accessed field>";
- String completeBehind = "this.separator.";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:this.separator.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class XB extends java.io.File {\n" +
- " public XB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " XB xb;\n" +
- " <CompleteOnMemberAccess:this.separator.>;\n" +
- " }\n" +
- " String bar() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testXB_1FIYM5I_3() {
- String str =
- "package p; \n" +
- "/*\n" +
- " * 1FIYM5I\n" +
- " */\n" +
- "public class XB\n" +
- " extends java.io.File {\n" +
- " void foo() {\n" +
- " XB xb = new XB();\n" +
- " this.separator.;\n" +
- " this.bar().;\n" +
- " }\n" +
- " String bar() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of explicit this access>";
- String completeBehind = "this.b";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:this.b>";
- String completionIdentifier = "b";
- String expectedReplacedSource = "this.bar";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class XB extends java.io.File {\n" +
- " public XB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " XB xb;\n" +
- " <CompleteOnMemberAccess:this.b>;\n" +
- " }\n" +
- " String bar() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testXB_1FIYM5I_4() {
- String str =
- "package p; \n" +
- "/*\n" +
- " * 1FIYM5I\n" +
- " */\n" +
- "public class XB\n" +
- " extends java.io.File {\n" +
- " void foo() {\n" +
- " XB xb = new XB();\n" +
- " this.separator.;\n" +
- " this.bar().;\n" +
- " }\n" +
- " String bar() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field of explicitly accessed method>";
- String completeBehind = "this.bar().";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:this.bar().>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class XB extends java.io.File {\n" +
- " public XB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " XB xb;\n" +
- " <CompleteOnMemberAccess:this.bar().>;\n" +
- " }\n" +
- " String bar() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testY_1FGPESI() {
- String str =
- "package p; \n" +
- "import p2.; \n" +
- "/**\n" +
- " * 1FGPESI\n" +
- " */\n" +
- "public class Y {\n" +
- "}\n";
-
- String testName = "<complete on imports>";
- String completeBehind = "p2.";
- String expectedCompletionNodeToString = "<CompleteOnImport:p2.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "p2.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import <CompleteOnImport:p2.>;\n" +
- "public class Y {\n" +
- " public Y() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testYA_1FGRIUH() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGRIUH\n" +
- " */\n" +
- "public class YA\n" +
- " extends YASecondTopLevel {\n" +
- " void eFoo() {\n" +
- " }\n" +
- " class YAMember {\n" +
- " void eFoo() {\n" +
- " }\n" +
- " void eBar() {\n" +
- " e }\n" +
- " }\n" +
- "}\n" +
- "class YASecondTopLevel {\n" +
- " public boolean equals(YA yaya) {\n" +
- " return true;\n" +
- " }\n" +
- " public eFoo() {\n" +
- " }\n" +
- " public void eFooBar() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete on method/field>";
- String completeBehind = "e";
- String expectedCompletionNodeToString = "<CompleteOnName:e>";
- String completionIdentifier = "e";
- String expectedReplacedSource = "e";
- int cursorLocation = str.indexOf("e }") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class YA extends YASecondTopLevel {\n" +
- " class YAMember {\n" +
- " YAMember() {\n" +
- " }\n" +
- " void eFoo() {\n" +
- " }\n" +
- " void eBar() {\n" +
- " <CompleteOnName:e>;\n" +
- " }\n" +
- " }\n" +
- " public YA() {\n" +
- " }\n" +
- " void eFoo() {\n" +
- " }\n" +
- "}\n" +
- "class YASecondTopLevel {\n" +
- " YASecondTopLevel() {\n" +
- " }\n" +
- " public boolean equals(YA yaya) {\n" +
- " }\n" +
- " public eFoo() {\n" +
- " }\n" +
- " public void eFooBar() {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testYB_1FJ4D46_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FJ4D46\n" +
- " */\n" +
- "public class YB {\n" +
- " void foo() {\n" +
- " new String(\"asdf\".getBytes()).}\n" +
- "}\n";
-
- String testName = "<complete on method/field of object creation>";
- String completeBehind = "new String(\"asdf\".getBytes()).";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:new String(\"asdf\".getBytes()).>";
- String completionIdentifier = "";
- String expectedReplacedSource = "";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class YB {\n" +
- " public YB() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:new String(\"asdf\".getBytes()).>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testZ_1FGPF3D_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGPF3D\n" +
- " */\n" +
- "public class Z imp Pro.Sev, \n" +
- " Bla.Blo {\n" +
- "}\n";
-
- String testName = "<complete on implements keyword>";
- String completeBehind = "imp";
- String expectedCompletionNodeToString = "<CompleteOnType:imp>";
- String completionIdentifier = "imp";
- String expectedReplacedSource = "imp";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class Z {\n" +
- " <CompleteOnType:imp>;\n" +
- " {\n" +
- " }\n" +
- " public Z() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testZ_1FGPF3D_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FGPF3D\n" +
- " */\n" +
- "public class Z implements Pro.Sev, \n" +
- " Bla.Blo {\n" +
- "}\n";
-
- String testName = "<complete on implented interface>";
- String completeBehind = "P";
- String expectedCompletionNodeToString = "<CompleteOnInterface:P>";
- String completionIdentifier = "P";
- String expectedReplacedSource = "Pro";
- int cursorLocation = str.indexOf("Pro.Sev") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class Z implements <CompleteOnInterface:P>, Bla.Blo {\n" +
- " public Z() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testZA_1() {
- String str =
- "package p; \n" +
- "import java.util.Vector;\n";
-
- String testName = "<complete on import keyword>";
- String completeBehind = "i";
- String expectedCompletionNodeToString = "<CompleteOnType:i>";
- String completionIdentifier = "i";
- String expectedReplacedSource = "import";
- int cursorLocation = str.indexOf("import") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testZA_2() {
- String str =
- "package p; \n" +
- "import java.util.Vector;\n";
-
- String testName = "<complete on imported package>";
- String completeBehind = "jav";
- String expectedCompletionNodeToString = "<CompleteOnImport:jav>";
- String completionIdentifier = "jav";
- String expectedReplacedSource = "java.util.Vector";
- int cursorLocation = str.indexOf("java.util.Vector") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import <CompleteOnImport:jav>;\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testZA_3() {
- String str =
- "package p; \n" +
- "import java.util.Vector;\n";
-
- String testName = "<complete on imported type>";
- String completeBehind = "java.util.V";
- String expectedCompletionNodeToString = "<CompleteOnImport:java.util.V>";
- String completionIdentifier = "V";
- String expectedReplacedSource = "java.util.Vector";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import <CompleteOnImport:java.util.V>;\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testZB_1FJ4D46_1() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FJ4D46\n" +
- " */\n" +
- "import java.util.zip.CRC32;\n" +
- "import java.io.*;\n" +
- "public class ZB {\n" +
- " public static void main(\n" +
- " java.lang.String[] args) {\n" +
- " File file = \n" +
- " new File(\"d:\\\\314\"); \n" +
- " CRC32 crc = new CRC32();\n" +
- " file.}\n" +
- "}\n";
-
- String testName = "<complete on method/field of local variable>";
- String completeBehind = "file.";
- String expectedCompletionNodeToString = "<CompleteOnName:file.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "file.";
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import java.util.zip.CRC32;\n" +
- "import java.io.*;\n" +
- "public class ZB {\n" +
- " public ZB() {\n" +
- " }\n" +
- " public static void main(java.lang.String[] args) {\n" +
- " File file;\n" +
- " CRC32 crc;\n" +
- " <CompleteOnName:file.>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-public void testZB_1FJ4D46_2() {
- String str =
- "package p; \n" +
- "/**\n" +
- " * 1FJ4D46\n" +
- " */\n" +
- "import java.util.zip.CRC32;\n" +
- "import java.io.*;\n" +
- "public class ZB {\n" +
- " public static void main(\n" +
- " java.lang.String[] args) {\n" +
- " File file = \n" +
- " new File(\"d:\\\\314\"); \n" +
- " CRC32 crc = new CRC32();\n" +
- " file.}\n" +
- "}\n";
-
- String testName = "<complete on local variable type>";
- String completeBehind = "CRC";
- String expectedCompletionNodeToString = "<CompleteOnName:CRC>";
- String completionIdentifier = "CRC";
- String expectedReplacedSource = "CRC32";
- int cursorLocation = str.indexOf("CRC32 crc") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "import java.util.zip.CRC32;\n" +
- "import java.io.*;\n" +
- "public class ZB {\n" +
- " public ZB() {\n" +
- " }\n" +
- " public static void main(java.lang.String[] args) {\n" +
- " File file;\n" +
- " <CompleteOnName:CRC>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/**
- * Complete in initializer
- */
-public void test001(){
- String str =
- "package p;\n" +
- "public class X {\n" +
- " void foo(){\n" +
- " int v1;\n" +
- " {\n" +
- " Obj\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete in initializer>";
- String completeBehind = "Obj";
- String expectedCompletionNodeToString = "<CompleteOnName:Obj>";
- String completionIdentifier = "Obj";
- String expectedReplacedSource = "Obj";
- int cursorLocation = str.indexOf("Obj") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int v1;\n" +
- " {\n" +
- " <CompleteOnName:Obj>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/**
- * Complete after initializer
- */
-public void test002(){
- String str =
- "package p;\n" +
- "public class X {\n" +
- " void foo(){\n" +
- " int v1;\n" +
- " {\n" +
- " int v2\n" +
- " }\n" +
- " Obj" +
- " }\n" +
- "}\n";
-
- String testName = "<complete after initializer>";
- String completeBehind = "Obj";
- String expectedCompletionNodeToString = "<CompleteOnName:Obj>";
- String completionIdentifier = "Obj";
- String expectedReplacedSource = "Obj";
- int cursorLocation = str.indexOf("Obj") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int v1;\n" +
- " <CompleteOnName:Obj>;\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/**
- * Complete in initializer
- */
-public void test003(){
- String str =
- "package p;\n" +
- "public class X {\n" +
- " void foo(){\n" +
- " int v1;\n" +
- " {\n" +
- " this.\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete in initializer>";
- String completeBehind = "this.";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:this.>";
- String completionIdentifier = "";
- String expectedReplacedSource = "this.";
- int cursorLocation = str.indexOf("this.") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "package p;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int v1;\n" +
- " {\n" +
- " <CompleteOnMemberAccess:this.>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-
-/**
- * Complete in switch
- */
-public void test004(){
- String str =
- "public class X {\n" +
- " final static int ZZZ = 1;\n"+
- " void foo(){\n" +
- " switch(2)\n" +
- " case 0 + ZZZ :\n" +
- " case 1 + ZZZ :\n" +
- " bar(ZZZ)\n" +
- " }\n" +
- " void bar(int y) {}\n"+
- "}\n";
-
- String testName = "<complete in switch>";
- String completeBehind = "ZZZ";
- String expectedCompletionNodeToString = "<CompleteOnName:ZZZ>";
- String completionIdentifier = "ZZZ";
- String expectedReplacedSource = "ZZZ";
- int cursorLocation = str.lastIndexOf("ZZZ") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "public class X {\n" +
- " static final int ZZZ;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:ZZZ>;\n" +
- " }\n" +
- " void bar(int y) {\n" +
- " }\n" +
- "}\n";
-
- checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/**
- * Complete in method type.
- */
-public void test005(){
- String str =
- "public class X {\n" +
- " clon foo(){\n" +
- " }\n" +
- "}\n";
-
- String testName = "<complete in method type>";
- String completeBehind = "clon";
- String expectedCompletionNodeToString = "<CompleteOnType:clon>";
- String completionIdentifier = "clon";
- String expectedReplacedSource = "clon";
- int cursorLocation = str.lastIndexOf("clon") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " <CompleteOnType:clon>\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/**
- * Complete in method type.
- */
-public void test006(){
- String str =
- "public class X {\n" +
- " clon\n" +
- " foo();\n" +
- "}\n";
-
- String testName = "<complete in method type>";
- String completeBehind = "clon";
- String expectedCompletionNodeToString = "<CompleteOnType:clon>";
- String completionIdentifier = "clon";
- String expectedReplacedSource = "clon";
- int cursorLocation = str.lastIndexOf("clon") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "public class X {\n" +
- " <CompleteOnType:clon>;\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/**
- * Complete in field type.
- */
-public void test007(){
- String str =
- "public class X {\n" +
- " clon x;\n" +
- "}\n";
-
- String testName = "<complete in field type>";
- String completeBehind = "clon";
- String expectedCompletionNodeToString = "<CompleteOnType:clon>";
- String completionIdentifier = "clon";
- String expectedReplacedSource = "clon";
- int cursorLocation = str.lastIndexOf("clon") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "public class X {\n" +
- " <CompleteOnType:clon>;\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/**
- * Complete in field type.
- */
-public void test008(){
- String str =
- "public class X {\n" +
- " clon\n" +
- " x;\n" +
- "}\n";
-
- String testName = "<complete in field type>";
- String completeBehind = "clon";
- String expectedCompletionNodeToString = "<CompleteOnType:clon>";
- String completionIdentifier = "clon";
- String expectedReplacedSource = "clon";
- int cursorLocation = str.lastIndexOf("clon") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "public class X {\n" +
- " <CompleteOnType:clon>;\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/**
- * Complete in field type.
- */
-public void test009(){
- String str =
- "public class X {\n" +
- " clon\n" +
- " x y;\n" +
- "}\n";
-
- String testName = "<complete in field tpye>";
- String completeBehind = "clon";
- String expectedCompletionNodeToString = "<CompleteOnType:clon>";
- String completionIdentifier = "clon";
- String expectedReplacedSource = "clon";
- int cursorLocation = str.lastIndexOf("clon") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "public class X {\n" +
- " <CompleteOnType:clon>;\n" +
- " x y;\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/**
- * Complete in method type.
- */
-public void test010(){
- String str =
- "public class X {\n" +
- " clon\n" +
- " x y(){}\n" +
- "}\n";
-
- String testName = "<complete in method type>";
- String completeBehind = "clon";
- String expectedCompletionNodeToString = "<CompleteOnType:clon>";
- String completionIdentifier = "clon";
- String expectedReplacedSource = "clon";
- int cursorLocation = str.lastIndexOf("clon") + completeBehind.length() - 1;
- String expectedUnitDisplayString =
- "public class X {\n" +
- " <CompleteOnType:clon>;\n" +
- " public X() {\n" +
- " }\n" +
- " x y() {\n" +
- " }\n" +
- "}\n";
-
- checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionRecoveryTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionRecoveryTest.java
deleted file mode 100644
index e5884d2..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionRecoveryTest.java
+++ /dev/null
@@ -1,1026 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-public class CompletionRecoveryTest extends AbstractCompletionTest {
-public CompletionRecoveryTest(String testName){
- super(testName);
-}
-/*
- * Complete on variable behind ill-formed declaration
- */
-public void test01() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends IOException { \n" +
- " int foo(){ \n" +
- " String str = ; \n" +
- " str. \n";
-
- String completeBehind = "str.";
- String expectedCompletionNodeToString = "<CompleteOnName:str.>";
- String completionIdentifier = "";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends IOException {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " String str;\n" +
- " <CompleteOnName:str.>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "str.";
- String testName = "<complete on variable behind ill-formed declaration>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on variable behind ill-formed declaration and nested block
- */
-public void test02() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends IOException { \n" +
- " int foo(){ \n" +
- " String str = ; \n" +
- " { \n" +
- " int i; \n" +
- " str. \n";
-
- String completeBehind = "str.";
- String expectedCompletionNodeToString = "<CompleteOnName:str.>";
- String completionIdentifier = "";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends IOException {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " String str;\n" +
- " {\n" +
- " int i;\n" +
- " <CompleteOnName:str.>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "str.";
- String testName = "<complete on variable behind ill-formed declaration and nested block>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on variable behind ill-formed declaration and inside local type field initialization
- */
-public void test03() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends IOException { \n" +
- " int foo(){ \n" +
- " final String str = ; \n" +
- " class L { \n" +
- " int i = str \n";
-
- String completeBehind = "i = str";
- String expectedCompletionNodeToString = "<CompleteOnName:str>";
- String completionIdentifier = "str";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends IOException {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " final String str;\n" +
- " class L {\n" +
- " int i = <CompleteOnName:str>;\n" +
- " L() {\n" +
- " super();\n" + // could be optimized out
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "str";
- String testName = "<complete on variable behind ill-formed declaration and inside local type field initialization>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on variable behind closed scope
- */
-public void test04() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends \n" +
- " int foo(String str) \n" +
- " String variable = ; \n" +
- " { \n" +
- " String variableNotInScope; \n" +
- " } \n" +
- " foo(varia \n";
-
- String completeBehind = "foo(var";
- String expectedCompletionNodeToString = "<CompleteOnName:var>";
- String completionIdentifier = "var";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo(String str) {\n" +
- " String variable;\n" +
- " <CompleteOnName:var>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "varia";
- String testName = "<complete on variable behind closed scope>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on variable str with sibling method stringAppend()
- */
-public void test05() {
-
- String str =
- "import java.io.*; \n"+
- " \n"+
- "public class X extends \n"+
- " int foo(String str) \n"+
- " String str = ; \n"+
- " { \n"+
- " String strNotInScope; \n"+
- " } \n"+
- " class L { \n"+
- " int bar(){ \n"+
- " foo(str \n"+
- " void stringAppend(String s1, String s2) \n";
-
- String completeBehind = "foo(str";
- String expectedCompletionNodeToString = "<CompleteOnName:str>";
- String completionIdentifier = "str";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo(String str) {\n" +
- " String str;\n" +
- " class L {\n" +
- " L() {\n" +
- " }\n" +
- " int bar() {\n" +
- " <CompleteOnName:str>;\n" +
- " }\n" +
- " void stringAppend(String s1, String s2) {\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "str";
- String testName = "<complete on variable str with sibling method stringAppend()>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on variable str with sibling method stringAppend(), eliminating
- * uninteresting method bodies
- */
-public void test06() {
-
- String str =
- "import java.io.*; \n"+
- " \n"+
- "public class X extends \n"+
- " int foo(String str) \n"+
- " String str = ; \n"+
- " { \n"+
- " String strNotInScope; \n"+
- " } \n"+
- " class L { \n"+
- " int notInterestingBody(){ \n"+
- " System.out.println(); \n"+
- " } \n"+
- " int bar(){ \n"+
- " foo(str \n"+
- " void stringAppend(String s1, String s2) \n";
-
- String completeBehind = "foo(str";
- String expectedCompletionNodeToString = "<CompleteOnName:str>";
- String completionIdentifier = "str";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo(String str) {\n" +
- " String str;\n" +
- " class L {\n" +
- " L() {\n" +
- " }\n" +
- " int notInterestingBody() {\n" +
- " }\n" +
- " int bar() {\n" +
- " <CompleteOnName:str>;\n" +
- " }\n" +
- " void stringAppend(String s1, String s2) {\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "str";
- String testName = "<complete on variable eliminating other uninteresting method bodies>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on new keyword
- */
-public void test07(){
-
- String str =
- "import java.io.* \n" +
- " \n" +
- "public class X extends IOException { \n" +
- " int foo() { \n" +
- " X x = new X( \n" +
- "} \n";
-
- String completeBehind = "= n";
- String expectedCompletionNodeToString = "<CompleteOnName:n>";
- String completionIdentifier = "n";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends IOException {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " X x = <CompleteOnName:n>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "new";
- String testName = "<complete on new keyword>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkMethodParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on field type in anonymous type.
- */
-public void test08() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "package test;\n" +
- "import java.util.Vector;\n" +
- "public class VA {\n" +
- " Object o1 = new Object() {\n" +
- " V\n" +
- " void foo2() {\n" +
- " int i = 1;\n" +
- " }\n" +
- " };\n" +
- " String s2;\n" +
- " void bar() {\n" +
- " }\n" +
- " void foo() { \n" +
- " new String[] {}..equals()\n" +
- " }\n" +
- "}\n",
- // completeBehind:
- " V",
- // expectedCompletionNodeToString:
- "<CompleteOnType:V>",
- // expectedUnitDisplayString:
- "package test;\n" +
- "import java.util.Vector;\n" +
- "public class VA {\n" +
- " Object o1 = new Object() {\n" +
- " <CompleteOnType:V>;\n" +
- " () {\n" +
- " super();\n" +
- " }\n" +
- " void foo2() {\n" +
- " }\n" +
- " };\n" +
- " String s2;\n" +
- " public VA() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "V",
- // expectedReplacedSource:
- "V",
- // test name
- "<completion on field type in anonymous type>"
- );
-}
-/*
- * Complete on argument name
- */
-public void test09() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "package pack; \n"+
- "class A { \n"+
- " \n"+
- " public static void main(String[] argv \n"+
- " new Member().f \n"+
- " ; \n"+
- " } \n"+
- " class Member { \n"+
- " int foo() \n"+
- " } \n"+
- " } \n"+
- "}; \n",
- // completeBehind:
- "argv",
- // expectedCompletionNodeToString:
- "<CompleteOnArgumentName:String[] argv>",
- // expectedUnitDisplayString:
- "package pack;\n" +
- "class A {\n" +
- " class Member {\n" +
- " Member() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " }\n" +
- " A() {\n" +
- " }\n" +
- " public static void main(<CompleteOnArgumentName:String[] argv>) {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "argv",
- // expectedReplacedSource:
- "argv",
- // test name
- "<completion on argument name>"
- );
-}
-/*
- * Complete on argument name
- */
-public void test10() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "package pack; \n"+
- "class A { \n"+
- " \n"+
- " public static void main(String[] argv \n"+
- " new Member().f \n"+
- " ; \n"+
- " } \n"+
- " class Member { \n"+
- " int foo() \n"+
- " } \n"+
- " } \n"+
- "}; \n",
- // completeBehind:
- "argv",
- // expectedCompletionNodeToString:
- "<CompleteOnName:>",
- // expectedUnitDisplayString:
- "package pack;\n" +
- "class A {\n" +
- " class Member {\n" +
- " Member() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " }\n" +
- " A() {\n" +
- " }\n" +
- " public static void main(<CompleteOnArgumentName:String[] argv>) {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<completion on argument name>"
- );
-}
-/*
- * Complete inside method with incomplete signature
- */
-public void test11() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "package pack; \n"+
- "class A { \n"+
- " \n"+
- " public static void main(String[] argv \n"+
- " new Member().f \n"+
- " ; \n"+
- " } \n"+
- " class Member { \n"+
- " int foo() \n"+
- " } \n"+
- " } \n"+
- "}; \n",
- // completeBehind:
- "new Member().f",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:new Member().f>",
- // expectedUnitDisplayString:
- "package pack;\n" +
- "class A {\n" +
- " class Member {\n" +
- " Member() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " }\n" +
- " A() {\n" +
- " }\n" +
- " public static void main(String[] argv) {\n" +
- " <CompleteOnMemberAccess:new Member().f>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "f",
- // expectedReplacedSource:
- "f",
- // test name
- "<complete inside method with incomplete signature>"
- );
-}
-/*
- * Complete on argument name with class decl later on
- */
-public void test12() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class DD { \n"+
- " public static void main(String[] argv \n"+
- " \n"+
- "class D { \n"+
- " \n"+
- " int i; \n"+
- " class Mem1 {} \n"+
- " int dumb(String s) \n"+
- " int dumb(float fNum, double dNum) { \n"+
- " dumb(\"world\", i); \n"+
- " \n"+
- " if (i == 0) { \n"+
- " class Local { \n"+
- " \n"+
- " int hello() \n",
- // completeBehind:
- "argv",
- // expectedCompletionNodeToString:
- "<CompleteOnName:>",
- // expectedUnitDisplayString:
- "class DD {\n" +
- " DD() {\n" +
- " }\n" +
- " public static void main(<CompleteOnArgumentName:String[] argv>) {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete on argument name with class decl later on>"
- );
-}
-/*
- * Complete behind array type
- */
-public void test13() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class C { \n"+
- " void test() { \n"+
- " String[]. \n"+
- " } \n"+
- "} \n",
- // completeBehind:
- "String[].",
- // expectedCompletionNodeToString:
- "<CompleteOnClassLiteralAccess:String[].>",
- // expectedUnitDisplayString:
- "class C {\n" +
- " C() {\n" +
- " }\n" +
- " void test() {\n" +
- " <CompleteOnClassLiteralAccess:String[].>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "String[].",
- // test name
- "<complete behind array type>"
- );
-}
-/*
- * Complete inside array type
- */
-public void test14() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "public class B { \n"+
- " class Member {} \n"+
- " \n"+
- " int[] j; \n",
- // completeBehind:
- "int[",
- // expectedCompletionNodeToString:
- NONE,
- // expectedUnitDisplayString:
- "public class B {\n" +
- " class Member {\n" +
- " Member() {\n" +
- " }\n" +
- " }\n" +
- " public B() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- NONE,
- // test name
- "<complete inside array type>"
- );
-}
-/*
- * Complete inside array type
- */
-public void test15() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "public class B { \n"+
- " class Member {} \n"+
- " \n"+
- " int[ \n",
- // completeBehind:
- "int[",
- // expectedCompletionNodeToString:
- NONE,
- // expectedUnitDisplayString:
- "public class B {\n" +
- " class Member {\n" +
- " Member() {\n" +
- " }\n" +
- " }\n" +
- " public B() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- NONE,
- // test name
- "<complete inside array type>"
- );
-}
-/*
- * Complete behind invalid array type
- */
-public void test16() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "public class B { \n"+
- " class Member {} \n"+
- " \n"+
- " int[ \n"+
- " Obje \n",
- // completeBehind:
- "Obje",
- // expectedCompletionNodeToString:
- "<CompleteOnType:Obje>",
- // expectedUnitDisplayString:
- "public class B {\n" +
- " class Member {\n" +
- " Member() {\n" +
- " }\n" +
- " }\n" +
- " <CompleteOnType:Obje>;\n" +
- " public B() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "Obje",
- // expectedReplacedSource:
- "Obje",
- // test name
- "<complete behind invalid array type>"
- );
-}
-/*
- * Complete behind invalid base type
- */
-public void test17() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class D { \n" +
- " class Member {} \n" +
- " \n" +
- " void test() { \n" +
- " int. \n" +
- " test(); \n" +
- " } \n",
- // completeBehind:
- "int.",
- // expectedCompletionNodeToString:
- "<CompleteOnClassLiteralAccess:int.>",
- // expectedUnitDisplayString:
- "class D {\n" +
- " class Member {\n" +
- " Member() {\n" +
- " }\n" +
- " }\n" +
- " D() {\n" +
- " }\n" +
- " void test() {\n" +
- " <CompleteOnClassLiteralAccess:int.>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "int.",
- // test name
- "<complete behind invalid base type>"
- );
-}
-/*
- * Complete behind incomplete local method header
- */
-public void test18() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class E { \n"+
- " int bar() { \n"+
- " class Local { \n"+
- " int hello() { \n",
- // completeBehind:
- "hello()",
- // expectedCompletionNodeToString:
- "<CompleteOnName:>",
- // expectedUnitDisplayString:
- "class E {\n" +
- " E() {\n" +
- " }\n" +
- " int bar() {\n" +
- " class Local {\n" +
- " Local() {\n" +
- " }\n" +
- " int hello() {\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete behind incomplete local method header>"
- );
-}
-/*
- * Complete behind catch variable
- */
-public void test19() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "public class Test { \n" +
- " void foo() { \n" +
- " try { \n" +
- " } catch (Exception e) { \n" +
- " } \n" +
- " e \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "\n\t\te",
- // expectedCompletionNodeToString:
- "<CompleteOnName:e>",
- // expectedUnitDisplayString:
- "public class Test {\n" +
- " public Test() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:e>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "e",
- // expectedReplacedSource:
- "e",
- // test name
- "<complete behind catch variable>"
- );
-}
-/*
- * Complete on catch variable
- */
-public void test20() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "public class Test { \n" +
- " void foo() { \n" +
- " try { \n" +
- " } catch (Exception e) { \n" +
- " e \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "\n\t\t\te",
- // expectedCompletionNodeToString:
- "<CompleteOnName:e>",
- // expectedUnitDisplayString:
- "public class Test {\n" +
- " public Test() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " Exception e;\n" +
- " <CompleteOnName:e>;\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "e",
- // expectedReplacedSource:
- "e",
- // test name
- "<complete on catch variable>"
- );
-}
-/*
- * Complete on catch variable after syntax error
- */
-public void test21() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "public class Test { \n" +
- " void foo() { \n" +
- " try { \n" +
- " bar \n" +
- " } catch (Exception e) { \n" +
- " e \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "\n\t\t\te",
- // expectedCompletionNodeToString:
- "<CompleteOnName:e>",
- // expectedUnitDisplayString:
- "public class Test {\n" +
- " public Test() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " Exception e;\n" +
- " <CompleteOnName:e>;\n" +
- " }\n" +
- " }\n" +
- "}\n"
- ,
- // expectedCompletionIdentifier:
- "e",
- // expectedReplacedSource:
- "e",
- // test name
- "<complete on catch variable after syntax error>"
- );
-}
-/*
- * Complete on constructor type name
- * 1G1HF7P: ITPCOM:WIN98 - CodeAssist may not work in constructor signature
- */
-public void test22() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "public class SomeType {\n" +
- " public SomeType(int i){}\n" +
- "}\n" +
- "\n" +
- "class SomeOtherType extends SomeType {\n" +
- " SomeOtherType(int i){\n" +
- " super(i);\n" +
- " }\n" +
- "}\n",
- // completeBehind:
- " SomeOther",
- // expectedCompletionNodeToString:
- "<CompleteOnType:SomeOther>",
- // expectedUnitDisplayString:
- "public class SomeType {\n" +
- " public SomeType(int i) {\n" +
- " }\n" +
- "}\n" +
- "class SomeOtherType extends SomeType {\n" +
- " <CompleteOnType:SomeOther>;\n" +
- " int i;\n" +
- " {\n" +
- " }\n" +
- " SomeOtherType() {\n" +
- " }\n" +
- "}\n"
- ,
- // expectedCompletionIdentifier:
- "SomeOther",
- // expectedReplacedSource:
- "SomeOtherType",
- // test name
- "<complete on constructor type name>"
- );
-}
-/**
- * Complete in initializer in recovery mode
- */
-public void test23() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "package p;\n" +
- "public class X {\n" +
- " void foo(){)\n" +
- " {\n" +
- " Obj\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // completeBehind:
- "Obj",
- // expectedCompletionNodeToString:
- "<CompleteOnName:Obj>",
- // expectedUnitDisplayString:
- "package p;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " <CompleteOnName:Obj>;\n" +
- " }\n" +
- " }\n" +
- "}\n"
- ,
- // expectedCompletionIdentifier:
- "Obj",
- // expectedReplacedSource:
- "Obj",
- // test name
- "<complete in initializer>"
- );
-}
-/**
- * Complete after initializer in recovery mode
- */
-public void test24() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "package p;\n" +
- "public class X {\n" +
- " void foo(){)\n" +
- " int v1;\n" +
- " {\n" +
- " int v2\n" +
- " }\n" +
- " Obj" +
- " }\n" +
- "}\n",
- // completeBehind:
- "Obj",
- // expectedCompletionNodeToString:
- "<CompleteOnName:Obj>",
- // expectedUnitDisplayString:
- "package p;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int v1;\n" +
- " <CompleteOnName:Obj>;\n" +
- " }\n" +
- "}\n"
- ,
- // expectedCompletionIdentifier:
- "Obj",
- // expectedReplacedSource:
- "Obj",
- // test name
- "<complete after initializer>"
- );
-}
-/**
- * Complete after dot, before a number .<|>12
- */
-public void test25() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "package p;\n" +
- "public class X {\n" +
- " void foo(){\n" +
- " this.12\n" +
- " }\n" +
- "}\n",
- // completeBehind:
- "this.",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:this.>",
- // expectedUnitDisplayString:
- "package p;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:this.>;\n" +
- " }\n" +
- "}\n"
- ,
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "this.",
- // test name
- "<complete after dot number>"
- );
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietCompletionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietCompletionTest.java
deleted file mode 100644
index e8df63e..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietCompletionTest.java
+++ /dev/null
@@ -1,1940 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-import org.eclipse.jdt.internal.codeassist.complete.InvalidCursorLocation;
-
-public class DietCompletionTest extends AbstractCompletionTest {
-public DietCompletionTest(String testName){
- super(testName);
-}
-/*
- * Complete on superclass
- */
-public void test01() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends IOException { \n" +
- "} \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = "<CompleteOnClass:IOEx>";
- String completionIdentifier = "IOEx";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends <CompleteOnClass:IOEx> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOException";
- String testName = "<complete on superclass>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on superinterface
- */
-public void test02() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends IOException implements Serializable { \n" +
- " int foo(){} \n" +
- "} \n";
-
- String completeBehind = "Seria";
- String expectedCompletionNodeToString = "<CompleteOnInterface:Seria>";
- String completionIdentifier = "Seria";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends IOException implements <CompleteOnInterface:Seria> {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "Serializable";
- String testName = "<complete on superinterface>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on qualified superclass
- */
-public void test03() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends java.io.IOException { \n" +
- "} \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = "<CompleteOnClass:java.io.IOEx>";
- String completionIdentifier = "IOEx";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends <CompleteOnClass:java.io.IOEx> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.io.IOException";
- String testName = "<complete on qualified superclass>";
-
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-
-}
-/*
- * Complete on qualified superinterface
- */
-public void test04() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends IOException implements java.io.Serializable { \n" +
- "} \n";
-
- String completeBehind = "Seria";
- String expectedCompletionNodeToString = "<CompleteOnInterface:java.io.Seria>";
- String completionIdentifier = "Seria";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends IOException implements <CompleteOnInterface:java.io.Seria> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.io.Serializable";
- String testName = "<complete on qualified superinterface>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on incomplete superclass
- */
-public void test05() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends IOEx { \n" +
- "} \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = "<CompleteOnClass:IOEx>";
- String completionIdentifier = "IOEx";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends <CompleteOnClass:IOEx> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOEx";
- String testName = "<complete on incomplete superclass>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on incomplete superinterface
- */
-public void test06() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends IOException implements Seria { \n" +
- "} \n";
-
- String completeBehind = "Seria";
- String expectedCompletionNodeToString = "<CompleteOnInterface:Seria>";
- String completionIdentifier = "Seria";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends IOException implements <CompleteOnInterface:Seria> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "Seria";
- String testName = "<complete on incomplete superinterface>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on incomplete qualified superclass
- */
-public void test07() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends java.io.IOEx { \n" +
- "} \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = "<CompleteOnClass:java.io.IOEx>";
- String completionIdentifier = "IOEx";
- String expectedUnitDisplayString = "import java.io.*;\n" +
- "public class X extends <CompleteOnClass:java.io.IOEx> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.io.IOEx";
- String testName = "<complete on incomplete qualified superclass>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on incomplete qualified superinterface
- */
-public void test08() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends IOException implements java.io.Seria { \n" +
- "} \n";
-
- String completeBehind = "Seria";
- String expectedCompletionNodeToString = "<CompleteOnInterface:java.io.Seria>";
- String completionIdentifier = "Seria";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends IOException implements <CompleteOnInterface:java.io.Seria> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.io.Seria";
- String testName = "<complete on incomplete qualified superinterface>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete inside qualified superclass
- */
-public void test09() {
-
- String str =
- " \n" +
- "public class X extends java.io.IOException { \n" +
- "} \n";
-
- String completeBehind = ".io";
- String expectedCompletionNodeToString = "<CompleteOnClass:java.io>";
- String completionIdentifier = "io";
- String expectedUnitDisplayString =
- "public class X extends <CompleteOnClass:java.io> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.io.IOException";
- String testName = "<complete inside qualified superclass>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete inside qualified superinterface
- */
-public void test10() {
-
- String str =
- "public class X extends IOException implements java.io.Serializable { \n" +
- "} \n";
-
- String completeBehind = ".io";
- String expectedCompletionNodeToString = "<CompleteOnInterface:java.io>";
- String completionIdentifier = "io";
- String expectedUnitDisplayString =
- "public class X extends IOException implements <CompleteOnInterface:java.io> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.io.Serializable";
- String testName = "<complete inside qualified superinterface>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete inside qualified superclass ending with dot
- */
-public void test11() {
-
- String str =
- " \n" +
- "public class X extends java.io. { \n" +
- "} \n";
-
- String completeBehind = ".io.";
- String expectedCompletionNodeToString = "<CompleteOnClass:java.io.>";
- String completionIdentifier = "";
- String expectedUnitDisplayString =
- "public class X extends <CompleteOnClass:java.io.> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.io.";
- String testName = "<complete inside qualified superclass ending with dot>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete inside qualified superinterface ending with dot
- */
-public void test12() {
-
- String str =
- "public class X extends IOException implements java.io. { \n" +
- "} \n";
-
- String completeBehind = ".io.";
- String expectedCompletionNodeToString = "<CompleteOnInterface:java.io.>";
- String completionIdentifier = "";
- String expectedUnitDisplayString =
- "public class X extends IOException implements <CompleteOnInterface:java.io.> {\n" +
- " public X() {\n" +
-
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.io.";
- String testName = "<complete inside qualified superinterface ending with dot>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on empty superclass
- */
-public void test13() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends { \n" +
- "} \n";
-
- String completeBehind = "extends ";
- String expectedCompletionNodeToString = "<CompleteOnClass:>";
- String completionIdentifier = "";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends <CompleteOnClass:> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "";
- String testName = "<complete on empty superclass>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on empty superinterface
- */
-public void test14() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends IOException implements { \n" +
- "} \n";
-
- String completeBehind = "implements ";
- String expectedCompletionNodeToString = "<CompleteOnInterface:>";
- String completionIdentifier = "";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends IOException implements <CompleteOnInterface:> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "";
- String testName = "<complete on empty superinterface>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on empty superclass followed by identifier
- */
-public void test15() {
-
- String str =
- "public class X extends java.io. IOException { \n" +
- "} \n";
-
- String completeBehind = "java.io.";
- String expectedCompletionNodeToString = "<CompleteOnClass:java.io.>";
- String completionIdentifier = "";
- String expectedUnitDisplayString =
- "public class X extends <CompleteOnClass:java.io.> {\n" +
- " {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.io.";
- String testName = "<complete on empty superclass followed by identifier>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on keyword extends
- */
-public void test16() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends { \n" +
- "} \n";
-
- String completeBehind = "extends";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = "extends";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X {\n" +
- " {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "extends";
- String testName = "<complete on keyword extends>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in keyword extends
- */
-public void test17() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X ext { \n" +
- "} \n";
-
- String completeBehind = "ext";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = "ext";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X {\n" +
- " {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "ext";
- String testName = "<complete in keyword extends>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in field type
- */
-public void test18() {
-
- String str =
- "class X { \n" +
- " \n" +
- " IOException x; \n" +
- "} \n";
-
- String completeBehind = "IO";
- String expectedCompletionNodeToString = "<CompleteOnType:IO>";
- String completionIdentifier = "IO";
- String expectedUnitDisplayString =
- "class X {\n" +
- " <CompleteOnType:IO>;\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOException";
- String testName = "<complete in field type>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete at beginning of field type
- */
-public void test19() {
-
- String str =
- "class X { \n" +
- " \n" +
- " final IOException x; \n" +
- "} \n";
-
- String completeBehind = "final ";
- String expectedCompletionNodeToString = "<CompleteOnType:>";
- String completionIdentifier = "";
- String expectedUnitDisplayString =
- "class X {\n" +
- " <CompleteOnType:>;\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOException";
- String testName = "<complete at beginning of field type>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete at beginning of superclass
- */
-public void test20() {
-
- String str =
- "class X extends IOException { \n" +
- " \n" +
- "} \n";
-
- String completeBehind = "extends ";
- String expectedCompletionNodeToString = "<CompleteOnClass:>";
- String completionIdentifier = "";
- String expectedUnitDisplayString =
- "class X extends <CompleteOnClass:> {\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOException";
- String testName = "<complete at beginning of superclass>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in return type
- */
-public void test21() {
-
- String str =
- "class X { \n" +
- " IOEx \n" +
- "} \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = "<CompleteOnType:IOEx>";
- String completionIdentifier = "IOEx";
- String expectedUnitDisplayString =
- "class X {\n" +
- " <CompleteOnType:IOEx>;\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOEx";
- String testName = "<complete in return type>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in argument type
- */
-public void test22() {
-
- String str =
- "class X { \n" +
- " int foo(IOEx \n" +
- "} \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = "<CompleteOnType:IOEx>";
- String completionIdentifier = "IOEx";
- String expectedUnitDisplayString =
- "class X {\n" +
- " <CompleteOnType:IOEx>;\n" +
- " X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOEx";
- String testName = "<complete in argument type>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in return type
- */
-public void test23() {
-
- String str =
- "class X { \n" +
- " IOEx \n" +
- " \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = "<CompleteOnType:IOEx>";
- String completionIdentifier = "IOEx";
- String expectedUnitDisplayString =
- "class X {\n" +
- " <CompleteOnType:IOEx>;\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOEx";
- String testName = "<complete in return type>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in argument type (no closing brace for type)
- */
-public void test24() {
-
- String str =
- "class X { \n" +
- " int foo(IOEx \n" +
- " \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = "<CompleteOnType:IOEx>";
- String completionIdentifier = "IOEx";
- String expectedUnitDisplayString =
- "class X {\n" +
- " <CompleteOnType:IOEx>;\n" +
- " X() {\n" +
-
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOEx";
- String testName = "<complete in argument type>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in return type with modifiers
- */
-public void test25() {
-
- String str =
- "class X { \n" +
- " public final IOEx \n" +
- " \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = "<CompleteOnType:IOEx>";
- String completionIdentifier = "IOEx";
- String expectedUnitDisplayString =
- "class X {\n" +
- " <CompleteOnType:IOEx>;\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOEx";
- String testName = "<complete in return type with modifiers>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in field initialization
- */
-public void test26() {
-
- String str =
- "class X { \n" +
- " public final int x = IOEx \n" +
- " \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = "<CompleteOnName:IOEx>";
- String completionIdentifier = "IOEx";
- String expectedUnitDisplayString =
- "class X {\n" +
- " public final int x = <CompleteOnName:IOEx>;\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOEx";
- String testName = "<complete in field initialization>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in nth argument type
- */
-public void test27() {
-
- String str =
- "class X { \n" +
- " int foo(AA a, BB b, IOEx \n" +
- " \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = "<CompleteOnType:IOEx>";
- String completionIdentifier = "IOEx";
- String expectedUnitDisplayString =
- "class X {\n" +
- " <CompleteOnType:IOEx>;\n" +
- " X() {\n" +
- " }\n" +
- " int foo(AA a, BB b) {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOEx";
- String testName = "<complete in nth argument type>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in nth argument qualified type
- */
-public void test28() {
-
- String str =
- "class X { \n" +
- " int foo(AA a, BB b, java.io.IOEx \n" +
- " \n";
-
- String completeBehind = ".io.";
- String expectedCompletionNodeToString = "<CompleteOnType:java.io.>";
- String completionIdentifier = "";
- String expectedUnitDisplayString =
- "class X {\n" +
- " <CompleteOnType:java.io.>;\n" +
- " X() {\n" +
- " }\n" +
- " int foo(AA a, BB b) {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.io.IOEx";
- String testName = "<complete in nth argument qualified type>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in nth thrown exception qualified type
- */
-public void test29() {
-
- String str =
- "class X { \n" +
- " public int foo(AA a, BB b) throws AA, java.io.IOEx \n" +
- " \n";
-
- String completeBehind = ".io";
- String expectedCompletionNodeToString = "<CompleteOnException:java.io>";
- String completionIdentifier = "io";
- String expectedUnitDisplayString =
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " public int foo(AA a, BB b) throws AA, <CompleteOnException:java.io> {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.io.IOEx";
- String testName = "<complete in nth thrown exception qualified type>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in completed argument
- */
-public void test30() {
-
- String str =
- "class X { \n" +
- " public int foo(AA a, java.io.BB b) \n" +
- " \n";
-
- String completeBehind = "io.";
- String expectedCompletionNodeToString = "<CompleteOnType:java.io.>";
- String completionIdentifier = "";
- String expectedUnitDisplayString =
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " public int foo(AA a, <CompleteOnType:java.io.> b) {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.io.BB";
- String testName = "<complete in in completed argument>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Negative test: no diet completion in allocation expression
- */
-public void test31() {
-
- String str =
- "class Bar { \n"+
- " void foo() { \n"+
- " new X().zzz(); \n"+
- " } \n"+
- "}\n";
-
- String completeBehind = "new X";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = NONE;
- String expectedUnitDisplayString =
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = null;
- String testName = "<no diet completion in allocation expression>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Completion in package statement
- */
-public void test32() {
-
- String str =
- "package x.abc \n"+
- "import x.util.*; \n"+
- "import x.*; \n"+
- "class X extends util{ \n"+
- " X(){} \n"+
- " X(int a, int b){} \n"+
- "} \n";
-
- String completeBehind = "x.ab";
- String expectedCompletionNodeToString = "<CompleteOnPackage:x.ab>";
- String completionIdentifier = "ab";
- String expectedUnitDisplayString =
- "package <CompleteOnPackage:x.ab>;\n" +
- "import x.util.*;\n" +
- "import x.*;\n" +
- "class X extends util {\n" +
- " X() {\n" +
- " }\n" +
- " X(int a, int b) {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "x.abc";
- String testName = "<complete in package statement>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Completion in import statement
- */
-public void test33() {
-
- String str =
- "package x.abc; \n"+
- "import x.util \n"+
- "import x.*; \n"+
- "class X extends util{ \n"+
- " X(){} \n"+
- " X(int a, int b){} \n"+
- "} \n";
-
- String completeBehind = "x.util";
- String expectedCompletionNodeToString = "<CompleteOnImport:x.util>";
- String completionIdentifier = "util";
- String expectedUnitDisplayString =
- "package x.abc;\n" +
- "import <CompleteOnImport:x.util>;\n" +
- "import x.*;\n" +
- "class X extends util {\n" +
- " X() {\n" +
- " }\n" +
- " X(int a, int b) {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "x.util";
- String testName = "<complete in import statement>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on superclass behind a unicode
- *
- * -- compute the unicode representation for a given string --
- [ String str = "IOEx";
- StringBuffer buffer = new StringBuffer("\"");
- for (int i = 0; i < str.length(); i++){
- String hex = Integer.toHexString(str.charAt(i));
- buffer.append("\\u0000".substring(0, 6-hex.length()));
- buffer.append(hex);
- }
- buffer.append("\"");
- buffer.toString()
- ]
- */
-public void test34() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends IOE\\u0078ception { \n" +
- "} \n";
-
- String completeBehind = "IOE\\u0078";
- String expectedCompletionNodeToString = "<CompleteOnClass:IOEx>";
- String completionIdentifier = "IOEx";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends <CompleteOnClass:IOEx> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOE\\u0078ception";
- String testName = "<complete on superclass behind a unicode>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Invalid completion inside a unicode
- *
- * -- compute the unicode representation for a given string --
- [ String str = "IOEx";
- StringBuffer buffer = new StringBuffer("\"");
- for (int i = 0; i < str.length(); i++){
- String hex = Integer.toHexString(str.charAt(i));
- buffer.append("\\u0000".substring(0, 6-hex.length()));
- buffer.append(hex);
- }
- buffer.append("\"");
- buffer.toString()
- ]
- */
-public void test35() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends IOE\\u0078ception { \n" +
- "} \n";
-
- String completeBehind = "IOE\\u00";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = NONE;
- String expectedUnitDisplayString = "";
- String expectedReplacedSource = NONE;
- String testName = "<complete inside unicode>";
-
- try {
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
- assertTrue("failed to detect invalid cursor location", false);
- } catch(InvalidCursorLocation e){
- assertEquals("invalid cursor location: ", e.irritant, InvalidCursorLocation.NO_COMPLETION_INSIDE_UNICODE);
- }
-}
-/*
- * Invalid completion inside a comment
- *
- */
-public void test36() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends /*IOException*/ { \n" +
- "} \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = NONE;
- String expectedUnitDisplayString = "";
- String expectedReplacedSource = NONE;
- String testName = "<complete inside comment>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- try {
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
- assertTrue("failed to detect invalid cursor location", false);
- } catch(InvalidCursorLocation e){
- assertEquals("invalid cursor location: ", e.irritant, InvalidCursorLocation.NO_COMPLETION_INSIDE_COMMENT);
- }
-}
-/*
- * Invalid completion inside a string literal
- *
- */
-public void test37() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X { \n" +
- " String s = \"IOException\"; \n" +
- "} \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = NONE;
- String expectedUnitDisplayString = "";
- String expectedReplacedSource = NONE;
- String testName = "<complete inside a string literal>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- try{
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
- assertTrue("failed to detect invalid cursor location", false);
- } catch(InvalidCursorLocation e){
- assertEquals("invalid cursor location: ", e.irritant, InvalidCursorLocation.NO_COMPLETION_INSIDE_STRING);
- }
-}
-/*
- * Invalid completion inside a number literal
- *
- */
-public void test38() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X { \n" +
- " int s = 12345678; \n" +
- "} \n";
-
- String completeBehind = "1234";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = NONE;
- String expectedUnitDisplayString = "";
- String expectedReplacedSource = NONE;
- String testName = "<complete inside a number literal>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- try{
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
- assertTrue("failed to detect invalid cursor location", false);
- } catch(InvalidCursorLocation e){
- assertEquals("invalid cursor location: ", e.irritant, InvalidCursorLocation.NO_COMPLETION_INSIDE_NUMBER);
- }
-}
-/*
- * Completion in import statement at the end of the unit
- */
-public void test39() {
-
- String str =
- "package x.abc; \n"+
- "import x.util";
-
- String completeBehind = "x.util";
- String expectedCompletionNodeToString = "<CompleteOnImport:x.util>";
- String completionIdentifier = "util";
- String expectedUnitDisplayString =
- "package x.abc;\n" +
- "import <CompleteOnImport:x.util>;\n";
- String expectedReplacedSource = "x.util";
- String testName = "<complete in import statement at the end of the unit>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Completion in import statement at the end of the unit (qualified empty name)
- */
-public void test40() {
-
- String str =
- "package a.b; \n"+
- "import java.";
-
- String completeBehind = "java.";
- String expectedCompletionNodeToString = "<CompleteOnImport:java.>";
- String completionIdentifier = "";
- String expectedUnitDisplayString =
- "package a.b;\n" +
- "import <CompleteOnImport:java.>;\n";
- String expectedReplacedSource = "java.";
- String testName = "<complete in import statement at the end of the unit>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Should not find any diet completion
- */
-public void test41() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends \n" +
- " int foo(String str) \n" +
- " String variable = ; \n" +
- " { \n" +
- " String variableNotInScope; \n" +
- " } \n" +
- " foo(varia \n";
-
- String completeBehind = "foo(var";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = "var";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo(String str) {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "varia";
- String testName = "<should not find diet completion>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on array type with prefix dimensions
- */
-public void test42() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X { \n" +
- " int[] foo(String str) \n";
-
- String completeBehind = "int";
- String expectedCompletionNodeToString = "<CompleteOnType:int>";
- String completionIdentifier = "int";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " <CompleteOnType:int>\n" +
- "}\n";
- String expectedReplacedSource = "int";
- String testName = "<completion on array type with prefix dimensions>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on array type with postfix dimensions
- */
-public void test43() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X { \n" +
- " int foo(String str) [] \n";
-
- String completeBehind = "int";
- String expectedCompletionNodeToString = "<CompleteOnType:int>";
- String completionIdentifier = "int";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " <CompleteOnType:int>\n" +
- "}\n";
- String expectedReplacedSource = "int";
- String testName = "<completion on array type with postfix dimensions>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in return type behind other member
- */
-public void test44() {
-
- String str =
- "class X { \n" +
- " int i; \n" +
- " IOEx \n" +
- "} \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = "<CompleteOnType:IOEx>";
- String completionIdentifier = "IOEx";
- String expectedUnitDisplayString =
- "class X {\n" +
- " int i;\n" +
- " <CompleteOnType:IOEx>;\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOEx";
- String testName = "<complete in return type>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in return type behind other member
- */
-public void test45() {
-
- String str =
- "class X { \n" +
- " int i; \n" +
- " public IOEx \n" +
- "} \n";
-
- String completeBehind = "IOEx";
- String expectedCompletionNodeToString = "<CompleteOnType:IOEx>";
- String completionIdentifier = "IOEx";
- String expectedUnitDisplayString =
- "class X {\n" +
- " int i;\n" +
- " <CompleteOnType:IOEx>;\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOEx";
- String testName = "<complete in return type>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on name in field initializer
- */
-public void test46() {
-
- String str =
- "class X { \n" +
- " String s = \"hello\"; \n" +
- " int f = s. \n" +
- "} \n";
-
- String completeBehind = "= s";
- String expectedCompletionNodeToString = "<CompleteOnName:s>";
- String completionIdentifier = "s";
- String expectedUnitDisplayString =
- "class X {\n" +
- " String s;\n" +
- " int f = <CompleteOnName:s>;\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "s";
- String testName = "<complete on name in field initializer>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete in field initializer in innner class
- */
-public void test47() {
-
- String str =
- "class X { \n" +
- " class Y { \n" +
- " Object[] f = { this.foo } \n" +
- " Object foo(){ return this; } \n" +
- "} \n";
-
- String completeBehind = "this.foo";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:this.foo>";
- String completionIdentifier = "foo";
- String expectedUnitDisplayString =
- "class X {\n" +
- " class Y {\n" +
- " Object[] f = <CompleteOnMemberAccess:this.foo>;\n" +
- " Y() {\n" +
- " }\n" +
- " Object foo() {\n" +
- " }\n" +
- " }\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "this.foo";
- String testName = "<complete in field initializer in inner class>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Should not find fake field of type <CompleteOnType:f>
- */
-public void test48() {
-
- String str =
- "package pack; \n"+
- "class A { \n"+
- " \n"+
- " public static void main(String[] argv) \n"+
- " new Member().f \n"+
- " ; \n"+
- " } \n"+
- " class Member { \n"+
- " int foo() \n"+
- " } \n"+
- " } \n"+
- "}; \n";
-
- String completeBehind = "new Member().f";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = "f";
- String expectedUnitDisplayString =
- "package pack;\n" +
- "class A {\n" +
- " class Member {\n" +
- " Member() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " }\n" +
- " A() {\n" +
- " }\n" +
- " public static void main(String[] argv) {\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "f";
- String testName = "<should not find fake field of type f>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Completion in middle of package import statement
- */
-public void test49() {
-
- String str =
- "import java.lang.reflect.*; \n"+
- "class X { \n"+
- "} \n";
-
- String completeBehind = "java.la";
- String expectedCompletionNodeToString = "<CompleteOnImport:java.la>";
- String completionIdentifier = "la";
- String expectedUnitDisplayString =
- "import <CompleteOnImport:java.la>;\n" +
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.lang.reflect";
- String testName = "<complete in middle of package import statement>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on instance creation in field initializer.
- */
-public void test50() {
-
- String str =
- "class X { \n" +
- " String s = \"hello\"; \n" +
- " Object o = new Xyz(); \n" +
- "} \n";
-
- String completeBehind = "new X";
- String expectedCompletionNodeToString = "<CompleteOnType:X>";
- String completionIdentifier = "X";
- String expectedUnitDisplayString =
- "class X {\n" +
- " String s;\n" +
- " Object o = new <CompleteOnType:X>();\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "Xyz";
- String testName = "<complete on instance creation in field initializer>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on member access in field initializer.
- */
-public void test51() {
-
- String str =
- "class X { \n" +
- " String s = \"hello\"; \n" +
- " Object o = fred().xyz; \n" +
- "} \n";
-
- String completeBehind = "fred().x";
- String expectedCompletionNodeToString = "<CompleteOnMemberAccess:fred().x>";
- String completionIdentifier = "x";
- String expectedUnitDisplayString =
- "class X {\n" +
- " String s;\n" +
- " Object o = <CompleteOnMemberAccess:fred().x>;\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "xyz";
- String testName = "<complete on member access in field initializer>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on class literal access in field initializer.
- */
-public void test52() {
-
- String str =
- "class X { \n" +
- " String s = \"hello\"; \n" +
- " Class c = int[].class; \n" +
- "} \n";
-
- String completeBehind = "int[].c";
- String expectedCompletionNodeToString = "<CompleteOnClassLiteralAccess:int[].c>";
- String completionIdentifier = "c";
- String expectedUnitDisplayString =
- "class X {\n" +
- " String s;\n" +
- " Class c = <CompleteOnClassLiteralAccess:int[].c>;\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "int[].class";
- String testName = "<complete on class literal access in field initializer>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on method invocation in field initializer.
- */
-public void test53() {
-
- String str =
- "class X { \n" +
- " String s = \"hello\"; \n" +
- " Object o = s.concat(); \n" +
- "} \n";
-
- String completeBehind = "s.concat(";
- String expectedCompletionNodeToString = "<CompleteOnMessageSend:s.concat()>";
- String completionIdentifier = "";
- String expectedUnitDisplayString =
- "class X {\n" +
- " String s;\n" +
- " Object o = <CompleteOnMessageSend:s.concat()>;\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "concat(";
- String testName = "<complete on method invocation in field initializer>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Should not find fake field of type <CompleteOnType:f>
- */
-public void test54() {
-
- String str =
- "package pack; \n"+
- "class A { \n"+
- " \n"+
- " public static void main(String[] argv \n"+
- " new Member().f \n"+
- " ; \n"+
- " } \n"+
- " class Member { \n"+
- " int foo() \n"+
- " } \n"+
- " } \n"+
- "}; \n";
-
- String completeBehind = "new Member().f";
- String expectedCompletionNodeToString = NONE;
- String completionIdentifier = "f";
- String expectedUnitDisplayString =
- "package pack;\n" +
- "class A {\n" +
- " class Member {\n" +
- " Member() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " }\n" +
- " A() {\n" +
- " }\n" +
- " public static void main(String[] argv) {\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "f";
- String testName = "<should not find fake field of type f>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Complete on anonymous type in field initializer.
- */
-public void test55() {
-
- String str =
- "class X { \n" +
- " Object o = new Object(){ \n" +
- " void foo(){ \n" +
- " String x = \"\"; \n" +
- " x.index \n" +
- " } \n" +
- " \n" +
- " void bar(){ \n" +
- " String y = \"\"; \n" +
- " } \n" +
- " }; \n" +
- "} \n";
-
- String completeBehind = "x.index";
- String expectedCompletionNodeToString = "<CompleteOnName:x.index>";
- String completionIdentifier = "index";
- String expectedUnitDisplayString =
- "class X {\n" +
- " Object o = new Object() {\n" +
- " () {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " String x;\n" +
- " <CompleteOnName:x.index>;\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " };\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "x.index";
- String testName = "<complete on anonymous type in field initializer>";
-
- int cursorLocation = str.indexOf(completeBehind) + completeBehind.length() - 1;
- this.checkDietParse(
- str.toCharArray(),
- cursorLocation,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
deleted file mode 100644
index 63cdcc4..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java
+++ /dev/null
@@ -1,5823 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-import java.util.Locale;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jdt.core.tests.util.Util;
-import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
-import org.eclipse.jdt.internal.compiler.CompilationResult;
-import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
-import org.eclipse.jdt.internal.compiler.SourceElementParser;
-import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.parser.Parser;
-import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
-import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-
-public class DietRecoveryTest extends TestCase {
- public static boolean optimizeStringLiterals = false;
- public static boolean assertMode = false;
-
-public DietRecoveryTest(String testName){
- super(testName);
-}
-
-public void checkParse(
- char[] source,
- String expectedDietUnitToString,
- String expectedDietPlusBodyUnitToString,
- String expectedFullUnitToString,
- String expectedCompletionDietUnitToString,
- String testName) {
-
- /* using regular parser in DIET mode */
- {
- Parser parser =
- new Parser(
- new ProblemReporter(
- DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- new CompilerOptions(),
- new DefaultProblemFactory(Locale.getDefault())),
- optimizeStringLiterals,
- assertMode);
-
- ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null);
- CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
-
- CompilationUnitDeclaration computedUnit = parser.dietParse(sourceUnit, compilationResult);
- String computedUnitToString = computedUnit.toString();
- if (!expectedDietUnitToString.equals(computedUnitToString)){
- System.out.println(Util.displayString(computedUnitToString));
- }
- assertEquals(
- "Invalid unit diet structure" + testName,
- expectedDietUnitToString,
- computedUnitToString);
- }
- /* using regular parser in DIET mode + getMethodBodies */
- {
- Parser parser =
- new Parser(
- new ProblemReporter(
- DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- new CompilerOptions(),
- new DefaultProblemFactory(Locale.getDefault())),
- optimizeStringLiterals,
- assertMode);
-
- ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null);
- CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
-
- CompilationUnitDeclaration computedUnit = parser.dietParse(sourceUnit, compilationResult);
- String computedUnitToString = computedUnit.toString();
- if (!expectedDietUnitToString.equals(computedUnitToString)){
- System.out.println(Util.displayString(computedUnitToString));
- }
- assertEquals(
- "Invalid unit diet structure" + testName,
- expectedDietUnitToString,
- computedUnitToString);
- if (computedUnit.types != null) {
- for (int i = computedUnit.types.length; --i >= 0;){
- computedUnit.types[i].binding = new SourceTypeBinding(){};
- computedUnit.types[i].parseMethod(parser, computedUnit);
- }
- }
- computedUnitToString = computedUnit.toString();
- if (!expectedDietPlusBodyUnitToString.equals(computedUnitToString)){
- System.out.println(Util.displayString(computedUnitToString));
- }
-
- assertEquals(
- "Invalid unit diet+body structure" + testName,
- expectedDietPlusBodyUnitToString,
- computedUnitToString);
- }
- /* using regular parser in FULL mode */
- {
- Parser parser =
- new Parser(
- new ProblemReporter(
- DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- new CompilerOptions(),
- new DefaultProblemFactory(Locale.getDefault())),
- optimizeStringLiterals,
- assertMode);
-
- ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null);
- CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
-
- CompilationUnitDeclaration computedUnit = parser.parse(sourceUnit, compilationResult);
- String computedUnitToString = computedUnit.toString();
- if (!expectedFullUnitToString.equals(computedUnitToString)){
- System.out.println(Util.displayString(computedUnitToString));
- }
- assertEquals(
- "Invalid unit full structure" + testName,
- expectedFullUnitToString,
- computedUnitToString);
-
- }
- /* using source element parser in DIET mode */
- {
- SourceElementParser parser =
- new SourceElementParser(
- new TestSourceElementRequestor(),
- new DefaultProblemFactory(Locale.getDefault()),
- new CompilerOptions());
-
- ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null);
- CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
-
- CompilationUnitDeclaration computedUnit = parser.dietParse(sourceUnit, compilationResult);
- String computedUnitToString = computedUnit.toString();
- if (!expectedDietUnitToString.equals(computedUnitToString)){
- System.out.println(Util.displayString(computedUnitToString));
- }
- assertEquals(
- "Invalid source element diet structure" + testName,
- expectedDietUnitToString,
- computedUnitToString);
- }
- /* using source element parser in FULL mode */
- {
- SourceElementParser parser =
- new SourceElementParser(
- new TestSourceElementRequestor(),
- new DefaultProblemFactory(Locale.getDefault()),
- new CompilerOptions());
-
- ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null);
- CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
-
- CompilationUnitDeclaration computedUnit = parser.parse(sourceUnit, compilationResult);
- String computedUnitToString = computedUnit.toString();
- if (!expectedFullUnitToString.equals(computedUnitToString)){
- System.out.println(Util.displayString(computedUnitToString));
- }
- assertEquals(
- "Invalid source element full structure" + testName,
- expectedFullUnitToString,
- computedUnitToString);
- }
- /* using completion parser in DIET mode */
- {
- CompilerOptions options = new CompilerOptions();
- CompletionParser parser =
- new CompletionParser(
- new ProblemReporter(
- DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- options,
- new DefaultProblemFactory(Locale.getDefault())),
- options.sourceLevel >= CompilerOptions.JDK1_4);
-
- ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null);
- CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
-
- CompilationUnitDeclaration computedUnit = parser.dietParse(sourceUnit, compilationResult, Integer.MAX_VALUE);
- String computedUnitToString = computedUnit.toString();
- if (!expectedCompletionDietUnitToString.equals(computedUnitToString)){
- System.out.println(Util.displayString(computedUnitToString));
- }
- assertEquals(
- "Invalid completion diet structure" + testName,
- expectedCompletionDietUnitToString,
- computedUnitToString);
- }
-}
-/*
- * Should treat variables 'h' and 'i' as fields since 'public'.
- */
-public void test01() {
-
- String s =
- "package a; \n"
- + "import java.lang.*; \n"
- + "import java.util.*; \n"
- + " \n"
- + "public class X { \n"
- + " void foo() { \n"
- + " System.out.println(); \n"
- + " \n"
- + " public int h; \n"
- + " public int[] i = { 0, 1 }; \n"
- + " \n"
- + " void bar(){ \n"
- + " void truc(){ \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public int[] i;\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<promote local vars into fields>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should filter out local type altogether
- */
-public void test02() {
-
- String s =
- "package a; \n"
- + "import java.lang.*; \n"
- + "import java.util.*; \n"
- + " \n"
- + "public class X { \n"
- + " void foo() { \n"
- + " System.out.println(); \n"
- + " \n"
- + " class L { \n"
- + " void baz(){} \n"
- + " } \n"
- + " \n"
- + " public int h; \n"
- + " public int[] i = { 0, 1 }; \n"
- + " \n"
- + " void bar(){ \n"
- + " void truc(){ \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public int[] i;\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<filter out local type>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should still be finding last method (#baz)
- */
-
-public void test03() {
-
- String s =
- "package a; \n"
- + "import java.lang.*; \n"
- + "import java.util.*; \n"
- + " \n"
- + "public class X { \n"
- + " void foo() { \n"
- + " System.out.println(); \n"
- + " \n"
- + " public int h; \n"
- + " public int[] i = { 0, 1 }; \n"
- + " \n"
- + " void bar(){ \n"
- + " void baz(){ \n"
- + " } \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public int[] i;\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<should find last method>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should finding 5 fields.
- */
-
-public void test04() {
-
- String s =
- "package a; \n"
- + "import java.lang.*; \n"
- + "import java.util.*; \n"
- + " \n"
- + "public class X { \n"
- + " X x; \n"
- + " Object a, b = null; \n"
- + " void foo() { \n"
- + " System.out.println(); \n"
- + " \n"
- + " public int h; \n"
- + " public int[] i = { 0, 1 }; \n"
- + " \n"
- + " void bar(){ \n"
- + " void truc(){ \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " X x;\n" +
- " Object a;\n" +
- " Object b = null;\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " X x;\n" +
- " Object a;\n" +
- " Object b = null;\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " X x;\n" +
- " Object a;\n" +
- " Object b;\n" +
- " public int h;\n" +
- " public int[] i;\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<five fields>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Diet parse thinks it is successful - no recovery
- */
-
-public void test05() {
-
- String s =
- "public class X { \n"
- + " void foo() { \n"
- + " System.out.println(); \n"
- + " void baz(){} \n"
- + " } \n"
- + " \n"
- + " void bar(){ \n"
- + " } \n"
- + " void truc(){ \n"
- + " } \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<diet was successful>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Recovery will not restart from scratch, and miss some signatures (#baz())
- */
-
-public void test06() {
-
- String s =
- "import java.lang.*; \n"
- + " \n"
- + "public class X { \n"
- + " void foo() { \n"
- + " System.out.println(); \n"
- + " void baz(){} \n"
- + " } \n"
- + " \n"
- + " void bar(){ \n"
- + " } \n"
- + " void truc(){ \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "import java.lang.*;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "import java.lang.*;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<will not miss nested method>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Attaching orphan methods and fields
- */
-
-public void test07() {
-
- String s =
- "public class X { \n"
- + " void foo() { \n"
- + " System.out.println(); \n"
- + " } \n"
- + "} \n"
- + " void bar(){ \n"
- + " } \n"
- + " int x; \n"
- + " void baz(){ \n"
- + " } \n"
- + " int y; \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " int x;\n" +
- " int y;\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " int x;\n" +
- " int y;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " System.out.println();\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<attaching orphans>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Properly attaching fields/methods to member type
- */
-
-public void test08() {
-
- String s =
- "public class X { \n"
- + " class Y { \n"
- + " void foo() { \n"
- + " System.out.println(); \n"
- + " } \n"
- + " public int h; \n"
- + " public int[] i = {0, 1}; \n"
- + " void bar(){ \n"
- + " void baz(){ \n"
- + " } \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " Y() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " Y() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " System.out.println();\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- " }\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " public int h;\n" +
- " public int[] i;\n" +
- " Y() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<attaching to member type>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Properly attaching fields/methods to enclosing type
- */
-
-public void test09() {
-
- String s =
- "public class X { \n"
- + " class Y { \n"
- + " void foo() { \n"
- + " System.out.println(); \n"
- + " } \n"
- + " } \n"
- + " public int h; \n"
- + " public int[] i = {0, 1}; \n"
- + " void bar(){ \n"
- + " void baz(){ \n"
- + " } \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " public X() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " System.out.println();\n" +
- " }\n" +
- " }\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " }\n" +
- " public int h;\n" +
- " public int[] i;\n" +
- " public X() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<attaching to enclosing type>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Properly attaching fields/methods to member type in presence of missing
- * member type opening brace (Y) (and array initializer for (i)).
- */
-
-public void test10() {
-
- String s =
- "public class X { \n"
- + " class Y \n"
- + " void foo() { \n"
- + " System.out.println(); \n"
- + " } \n"
- + " public int h; \n"
- + " public int[] i = {0, 1}; \n"
- + " void bar(){ \n"
- + " void baz(){ \n"
- + " } \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " Y() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " Y() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " System.out.println();\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- " }\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " public int h;\n" +
- " public int[] i;\n" +
- " Y() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<missing brace + array initializer>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Attaching orphan methods and fields, by counting brackets
- * variable 'x' should be eliminated (looks like a local variable)
- */
-
-public void test11() {
-
- String s =
- "public class X { \n"
- + " void foo() { \n"
- + " System.out.println(); \n"
- + " } \n"
- + "} \n"
- + " void bar(){ \n"
- + " int x; \n"
- + " void baz(){ \n"
- + " } \n"
- + " int y; \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " int y;\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " int y;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " System.out.println();\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<attaching orphans with missing brackets>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Attaching orphan methods and fields, by counting brackets
- * variable 'x' should NOT be eliminated given it looks like a field
- */
-
-public void test12() {
-
- String s =
- "public class X { \n"
- + " void foo() { \n"
- + " System.out.println(); \n"
- + " } \n"
- + "} \n"
- + " void bar(){ \n"
- + " public int x; \n"
- + " void baz(){ \n"
- + " } \n"
- + " int y; \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " public int x;\n" +
- " int y;\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " public int x;\n" +
- " int y;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " System.out.println();\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void baz() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<attaching orphans with missing brackets 2>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString ,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should still recover incomplete type signature (missing superclass)
- */
-
-public void test13() {
-
- String s =
- "public class X extends { \n"
- + " void foo() { \n"
- + " } \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<invalid type header>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should still recover incomplete method signature (missing opening brace)
- */
-
-public void test14() {
-
- String s =
- "public class X extends Thread { \n"
- + " void foo() \n"
- + " void bar() \n"
- + " } \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "public class X extends Thread {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X extends Thread {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<method header missing opening brace>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should still recover incomplete method signature (missing thrown exceptions)
- */
-
-public void test15() {
-
- String s =
- "public class X extends Thread { \n"
- + " void foo() throws \n"
- + " void bar() \n"
- + " } \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "public class X extends Thread {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X extends Thread {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<method header missing thrown exceptions>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should still recover incomplete type signature (missing superinterfaces)
- */
-
-public void test16() {
-
- String s =
- "public class X implements \n"
- + " void foo() \n"
- + " void bar() \n"
- + " } \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<type header missing superinterfaces>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should still recover incomplete type signature (missing superinterfaces)
- */
-
-public void test17() {
-
- String s =
- "public class X implements Y, \n"
- + " void foo() \n"
- + " void bar() \n"
- + " } \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "public class X implements Y {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X implements Y {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<type header missing superinterfaces 2>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should find member type behind incomplete enclosing type header
- */
-
-public void test18() {
-
- String s =
- "public class X implements \n"
- + " class Y { \n"
- + " void bar() \n"
- + " } \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " super();\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " }\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<member type behind incomplete enclosing type>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should find member type when missing opening brace
- */
-
-public void test19() {
-
- String s =
- "public class X \n"
- + " class Y { \n"
- + " void bar() \n"
- + " } \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " super();\n"+
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " }\n" +
- " public X() {\n" +
- " super();\n"+
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<member type when missing opening brace>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should not find fieldX signature behind missing brace
- */
-
-public void test20() {
-
- String s =
- "public class X \n"
- + " fieldX; \n"
- + " class Y { \n"
- + " void bar() \n"
- + " } \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " super();\n"+
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " }\n" +
- " public X() {\n" +
- " super();\n"+
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<no field behind missing brace>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should find Y as member type
- */
-
-public void test21() {
-
- String s =
- "public class X \n"
- + " fieldX; \n"
- + " class Y \n"
- + " } \n"
- + "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " super();\n"+
- " }\n" +
- " }\n" +
- " public X() {\n" +
- " super();\n"+
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should find Y as member type>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should filter out incomplete local type
- */
-
-public void test22() {
-
- String s =
- "package a; \n" +
- "import java.lang.*; \n" +
- "import java.util.*; \n" +
- " \n" +
- "public class X { \n" +
- " void foo() { \n" +
- " System.out.println(); \n" +
- " \n" +
- " class L extends { \n" +
- " public int l; \n" +
- " void baz(){} \n" +
- " } \n" +
- " \n" +
- " public int h; \n" +
- " \n" +
- " void bar(){ \n" +
- " void truc(){ \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public X() {\n" +
- " super();\n"+
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should filter out incomplete local type>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should filter out incomplete local type and method signature
- */
-
-public void test23() {
-
- String s =
- "package a; \n" +
- "import java.lang.*; \n" +
- "import java.util.*; \n" +
- " \n" +
- "public class X { \n" +
- " void foo() { \n" +
- " System.out.println(); \n" +
- " \n" +
- " class L extends { \n" +
- " public int l; \n" +
- " void baz() throws {} \n" +
- " } \n" +
- " \n" +
- " public int h; \n" +
- " \n" +
- " void bar(){ \n" +
- " void truc(){ \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public X() {\n" +
- " super();\n"+
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should filter out incomplete local type/method>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should filter out anonymous type
- */
-
-public void test24() {
-
- String s =
- "package a; \n" +
- "import java.lang.*; \n" +
- "import java.util.*; \n" +
- " \n" +
- "public class X { \n" +
- " void foo() { \n" +
- " System.out.println(); \n" +
- " \n" +
- " new X(){ \n" +
- " void baz() {} \n" +
- " }.baz(); \n" +
- " \n" +
- " public int h; \n" +
- " \n" +
- " void bar(){ \n" +
- " void truc(){ \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public X() {\n" +
- " super();\n"+
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should filter out incomplete anonymous type/method>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should filter out incomplete anonymous type
- */
-
-public void test25() {
-
- String s =
- "package a; \n" +
- "import java.lang.*; \n" +
- "import java.util.*; \n" +
- " \n" +
- "public class X { \n" +
- " void foo() { \n" +
- " System.out.println(); \n" +
- " \n" +
- " new X(){ \n" +
- " void baz() {} \n" +
- " \n" +
- " public int h; \n" +
- " \n" +
- " void bar(){ \n" +
- " void truc(){ \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " super();\n"+
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should filter out incomplete anonymous type>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should filter out incomplete anonymous method
- */
-
-public void test26() {
-
- String s =
- "package a; \n" +
- "import java.lang.*; \n" +
- "import java.util.*; \n" +
- " \n" +
- "public class X { \n" +
- " void foo() { \n" +
- " System.out.println(); \n" +
- " \n" +
- " new X(){ \n" +
- " void baz() \n" +
- " } \n" +
- " } \n" +
- " public int h; \n" +
- " \n" +
- " void bar(){ \n" +
- " void truc(){ \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public X() {\n" +
- " super();\n"+
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should filter out incomplete anonymous method>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should filter out incomplete local type and local var h
- */
-
-public void test27() {
-
- String s =
- "package a; \n" +
- "import java.lang.*; \n" +
- "import java.util.*; \n" +
- " \n" +
- "public class X { \n" +
- " void foo() { \n" +
- " System.out.println(); \n" +
- " \n" +
- " class L extends { \n" +
- " public int l; \n" +
- " void baz(){} \n" +
- " } \n" +
- " \n" +
- " int h; \n" +
- " \n" +
- " void bar(){ \n" +
- " void truc(){ \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " super();\n"+
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should filter incomplete local type L and variable h>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should find <y> as a field in Y
- */
-
-public void test28() {
-
- String s =
- "public class X { \n" +
- " int x; \n" +
- " \n" +
- " int foo(){ } \n" +
- " \n" +
- " class Y { \n" +
- " int y; \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " int y;\n" +
- " Y() {\n" +
- " }\n" +
- " }\n" +
- " int x;\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " int y;\n" +
- " Y() {\n" +
- " super();\n"+
- " }\n" +
- " }\n" +
- " int x;\n" +
- " public X() {\n" +
- " super();\n"+
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should find <y> as a field in Y>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should find <y> as a field in X
- */
-
-public void test29() {
-
- String s =
- "public class X { \n" +
- " int x; \n" +
- " \n" +
- " int foo(){ } \n" +
- " \n" +
- " class Y { \n" +
- "} \n" +
- " int y; \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " }\n" +
- " int x;\n" +
- " int y;\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " super();\n" +
- " }\n" +
- " }\n" +
- " int x;\n" +
- " int y;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should find <y> as a field in X>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should find <y> as a field in X
- */
-
-public void test30() {
-
- String s =
- "public class X { \n" +
- " int x; \n" +
- " \n" +
- " int foo(){ } \n" +
- " \n" +
- " class Y \n" +
- "} \n" +
- " int y; \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " }\n" +
- " int x;\n" +
- " int y;\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " super();\n" +
- " }\n" +
- " }\n" +
- " int x;\n" +
- " int y;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should find <y> as a field in X>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should recover from partial method header foo()
- */
-
-public void test31() {
-
- String s =
- "package a; \n"+
- "import java.lang.*; \n"+
- "import java.util.*; \n"+
- " \n"+
- "public class X { \n"+
- " void foo() \n"+
- " System.out.println(); \n"+
- " \n"+
- " public int h; \n"+
- " public int[] i = { 0, 1 }; \n"+
- " \n"+
- " void bar(){ \n"+
- " void truc(){ \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public int[] i = {0,1,};\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString =
- "package a;\n" +
- "import java.lang.*;\n" +
- "import java.util.*;\n" +
- "public class X {\n" +
- " public int h;\n" +
- " public int[] i;\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " void truc() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<should recover from partial method header>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should recover from method with missing argument names
- */
-
-public void test32() {
-
- String s =
- "public class WB2 { \n"+
- " public void foo(java.util.Locale, java.util.Vector) { \n"+
- " int i; \n"+
- " if(i instanceof O) { \n"+
- " } \n"+
- " String s = \"hello\"; \n"+
- " s. \n"+
- " } \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "public class WB2 {\n" +
- " public WB2() {\n" +
- " }\n" +
- " public void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class WB2 {\n" +
- " public WB2() {\n" +
- " super();\n" +
- " }\n" +
- " public void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should recover from method with missing argument names>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should not find message with no argument as a constructor
- */
-
-public void test33() {
-
- String s =
- "public class X { \n"+
- " void hello() \n"+
- " public X(int i) \n"+
- " void foo() { \n"+
- " System.out.println(); \n"+
- " \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " void hello() {\n" +
- " }\n" +
- " public X(int i) {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " void hello() {\n" +
- " }\n" +
- " public X(int i) {\n" +
- " }\n" +
- " void foo() {\n" +
- " System.out.println();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should not find message with no argument as a constructor>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should not find allocation as a constructor
- */
-
-public void test34() {
-
- String s =
- "public class X { \n"+
- " void hello() \n"+
- " public X(int i) \n"+
- " static void foo() { \n"+
- " X x; \n"+
- " x = new X(23); \n"+
- " System.out.println(); \n"+
- " \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " void hello() {\n" +
- " }\n" +
- " public X(int i) {\n" +
- " }\n" +
- " static void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " void hello() {\n" +
- " }\n" +
- " public X(int i) {\n" +
- " }\n" +
- " static void foo() {\n" +
- " X x;\n" +
- " x = new X(23);\n" +
- " System.out.println();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should not find allocation as a constructor>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Incomplete field header
- */
-
-public void test35() {
-
- String s =
- "public class X { \n" +
- " int x \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " int x;\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " int x;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<incomplete field header>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Incomplete multiple field headers
- */
-
-public void test36() {
-
- String s =
- "public class X { \n" +
- " int x, y \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " int x;\n" +
- " int y;\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " int x;\n" +
- " int y;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<incomplete multiple field headers>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Field header with started string initializer
- */
-
-public void test37() {
-
- String s =
- "public class X { \n" +
- " String s = \" \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " String s;\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " String s;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<field header with started string initializer>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Field header with started string initializer combined with incomplete superinterface
- */
-
-public void test38() {
-
- String s =
- "public class X implements Y, { \n" +
- " String s = \" \n";
-
- String expectedDietUnitToString =
- "public class X implements Y {\n" +
- " String s;\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X implements Y {\n" +
- " String s;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<field header and incomplete superinterface>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Field signature behind keyword implements
- */
-
-public void test39() {
-
- String s =
- "public class X implements \n"+
- "int x \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " int x;\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " int x;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<field signature behind keyword implements>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Field type read as interface
- */
-
-public void test40() {
-
- String s =
- "public class X implements Y, \n" +
- " String s = \" \n";
-
- String expectedDietUnitToString =
- "public class X implements Y, String {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X implements Y, String {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<field type read as interface>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Contiguous headers (checking checkpoint positions)
- */
-
-public void test41() {
-
- String s =
- "public class X public int foo(int bar(static String s";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " static String s;\n" +
- " public X() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public int foo() {\n" +
- " }\n" +
- " int bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " static String s;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public int foo() {\n" +
- " }\n" +
- " int bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<contiguous headers>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Contiguous headers without comma (checking checkpoint positions)
- */
-
-public void test42() {
-
- String s =
- "public class X public int foo(int x, int bar public String s;";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " public String s;\n" +
- " public X() {\n" +
- " }\n" +
- " public int foo(int x, int bar) {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " public String s;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " public int foo(int x, int bar) {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<contiguous headers without comma>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Contiguous headers without comma (checking checkpoint positions)
- */
-
-public void test43() {
-
- String s =
- "public class X \n" +
- " public int foo( \n" +
- " int bar( \n" +
- " static String s, int x \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " static String s;\n" +
- " int x;\n" +
- " public X() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public int foo() {\n" +
- " }\n" +
- " int bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " static String s;\n" +
- " int x;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public int foo() {\n" +
- " }\n" +
- " int bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<contiguous headers without comma>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should find static field <x>
- */
-
-public void test44() {
-
- String s =
- "class X { \n" +
- " String s; \n" +
- " \n" +
- " public void foo( \n" +
- " static int x \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "class X {\n" +
- " String s;\n" +
- " static int x;\n" +
- " X() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " String s;\n" +
- " static int x;\n" +
- " X() {\n" +
- " super();\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;;
-
- String testName = "<should find static field x>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Missing string literal quote inside method
- */
-
-public void test45() {
-
- String s =
- "public class X { \n"+
- " int foo(){ \n"+
- " String s = \" \n"+
- " } \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<missing string literal quote inside method>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Detecting member type closing when missing brackets
- */
-
-public void test46() {
-
- String s =
- "class X \n"+
- " String s = \"class y \n"+
- " class Member \n"+
- " int foo() \n"+
- " public int x; \n"+
- " } \n"+
- " int bar() \n";
-
- String expectedDietUnitToString =
- "class X {\n" +
- " class Member {\n" +
- " public int x;\n" +
- " Member() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " }\n" +
- " String s;\n" +
- " X() {\n" +
- " }\n" +
- " int bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " class Member {\n" +
- " public int x;\n" +
- " Member() {\n" +
- " super();\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " }\n" +
- " String s;\n" +
- " X() {\n" +
- " super();\n" +
- " }\n" +
- " int bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<detecting member type closing when missing brackets>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Unterminated method arguments
- */
-
-public void test47() {
-
- String s =
-
- "class X { \n" +
- " int foo(AA a, BB b, IOEx \n" +
- " \n";
-
- String expectedDietUnitToString =
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " int foo(AA a, BB b) {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " X() {\n" +
- " super();\n" +
- " }\n" +
- " int foo(AA a, BB b) {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<unterminated method arguments>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Unterminated literal string in method body
- */
-
-public void test48() {
-
- String s =
- "public class X { \n"+
- " final static int foo(){ \n"+
- " return \"1; \n"+
- " } \n"+
- " public static void main(String argv[]){ \n"+
- " foo(); \n"+
- " } \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " static final int foo() {\n" +
- " }\n" +
- " public static void main(String[] argv) {\n" +
- " }\n" +
- "}\n";
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " static final int foo() {\n" +
- " }\n" +
- " public static void main(String[] argv) {\n" +
- " foo();\n" +
- " }\n" +
- "}\n";
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<unterminated literal string in method body>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Unterminated initializer with local declaration
- */
-
-public void test49() {
-
- String s =
- "public class X { \n"+
- " { \n"+
- " int x; \n"+
- " \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " {\n" +
- " }\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<unterminated initializer with local declaration>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Unterminated if statement
- */
-
-public void test50() {
-
- String s =
- "public class X { \n"+
- " int foo(){ \n"+
- " if(true){ \n"+
- " int x; \n"+
- " \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<unterminated if statement>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Unterminated nested block with local declaration
- */
-
-public void test51() {
-
- String s =
- "public class X { \n"+
- " int foo(){ \n"+
- " { \n"+
- " int x; \n"+
- " \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<unterminated nested block with local declaration>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Unterminated nested block with field declaration
- */
-
-public void test52() {
-
- String s =
- "public class X { \n"+
- " int foo(){ \n"+
- " { \n"+
- " public int x; \n"+
- " \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " public int x;\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " public int x;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<unterminated nested block with field declaration>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Unterminated initializer with field declaration
- */
-
-public void test53() {
-
- String s =
- "public class X { \n"+
- " { \n"+
- " public int x; \n"+
- " \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " {\n" +
- " }\n" +
- " public int x;\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " {\n" +
- " }\n" +
- " public int x;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<unterminated initializer with field declaration>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Invalid class name
- */
-
-public void test54() {
-
- String s =
- "package p; \n"+
- "public class ZPro.Sev.Blo { \n"+
- "void ThisIsADummyMethodThatIsCreatedOnlyForThePurposesOfTheCompletionEngine() { \n"+
- " System.out.println(this.getClass()); \n"+
- "} \n"+
- " // COMMENT \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "package p;\n" +
- "public class ZPro {\n" +
- " {\n" +
- " }\n" +
- " public ZPro() {\n" +
- " }\n" +
- " void ThisIsADummyMethodThatIsCreatedOnlyForThePurposesOfTheCompletionEngine() {\n" +
- " }\n" +
- "}\n";
- String expectedDietPlusBodyUnitToString =
- "package p;\n" +
- "public class ZPro {\n" +
- " {\n" +
- " }\n" +
- " public ZPro() {\n" +
- " super();\n" +
- " }\n" +
- " void ThisIsADummyMethodThatIsCreatedOnlyForThePurposesOfTheCompletionEngine() {\n" +
- " System.out.println(this.getClass());\n" +
- " }\n" +
- "}\n";
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<Invalid class name>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Unterminated static initializer with field declaration
- */
-
-public void test55() {
-
- String s =
- "public class X { \n"+
- " static { \n"+
- " public int x; \n"+
- " \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " static {\n" +
- " }\n" +
- " public int x;\n" +
- " public X() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " static {\n" +
- " }\n" +
- " public int x;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<unterminated static initializer with field declaration>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Multiple initializers combined with array initializer
- */
-
-public void test56() {
-
- String s =
- "public class X \n"+
- " static int zz \n"+
- " { \n"+
- " } \n"+
- " static { \n"+
- " public int x; \n"+
- " int[] y = { 0, 1}; \n"+
- " { \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " static int zz;\n" +
- " {\n" +
- " }\n" +
- " static {\n" +
- " }\n" +
- " public int x;\n" +
- " int[] y = {0,1,};\n" +
- " {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " static int zz;\n" +
- " {\n" +
- " }\n" +
- " static {\n" +
- " }\n" +
- " public int x;\n" +
- " int[] y = {0,1,};\n" +
- " {\n" +
- " }\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString =
- "public class X {\n" +
- " static int zz;\n" +
- " {\n" +
- " }\n" +
- " static {\n" +
- " }\n" +
- " public int x;\n" +
- " int[] y;\n" +
- " {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<multiple initializers combined with array initializer>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Combination of unterminated methods and fields
- */
-
-public void test57() {
-
- String s =
- "class X \n"+
- " void foo(){ \n"+
- " { \n"+
- " public static int x; \n"+
- " void bar() \n"+
- " } \n"+
- " int y; \n";
-
- String expectedDietUnitToString =
- "class X {\n" +
- " public static int x;\n" +
- " int y;\n" +
- " X() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " public static int x;\n" +
- " int y;\n" +
- " X() {\n" +
- " super();\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<combination of unterminated methods and fields>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Illegal unicode inside method body
- */
-
-public void test58() {
-
- String s =
- "package p; \n"+
- " \n"+
- "class A { \n"+
- " void bar() { \n"+
- " String s = \"\\u000D\"; \n"+
- " } \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "package p;\n" +
- "class A {\n" +
- " A() {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package p;\n" +
- "class A {\n" +
- " A() {\n" +
- " super();\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<illegal unicode inside method body>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Extra identifier in type signature
- */
-
-public void test59() {
-
- String s =
- "public class X extends java.io.IOException IOException { \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "public class X extends java.io.IOException {\n" +
- " {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X extends java.io.IOException {\n" +
- " {\n" +
- " }\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<extra identifier in type signature>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Extra identifier in method signature
- */
-
-public void test60() {
-
- String s =
- "public class X extends java.io.IOException { \n" +
- " int foo() ExtraIdentifier { \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "public class X extends java.io.IOException {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X extends java.io.IOException {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<extra identifier in method signature>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Extra identifier behind thrown exception
- */
-
-public void test61() {
-
- String s =
- "public class X extends { \n" +
- " int foo() throws IOException ExtraIdentifier { \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() throws IOException {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " int foo() throws IOException {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<extra identifier behind thrown exception>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Unterminated array initializer
- */
-
-public void test62() {
-
- String s =
- "class X { \n"+
- " class Y \n"+
- " public String s; \n"+
- " int foo(){ \n"+
- " return 1; \n"+
- " static int y = {; \n"+ // can only be an initializer since type is not array one
- " } \n"+
- " public int i = 0; \n"+
- " \n"+
- " int baz() \n"+
- " \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "class X {\n" +
- " class Y {\n" +
- " public String s;\n" +
- " static int y;\n" +
- " {\n" +
- " }\n" +
- " public int i = 0;\n" +
- " Y() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " int baz() {\n" +
- " }\n" +
- " }\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " class Y {\n" +
- " public String s;\n" +
- " static int y;\n" +
- " {\n" +
- " ;;\n" +
- " }\n" +
- " public int i = 0;\n" +
- " Y() {\n" +
- " super();\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " int baz() {\n" +
- " }\n" +
- " }\n" +
- " X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString =
- "class X {\n" +
- " class Y {\n" +
- " public String s;\n" +
- " static int y;\n" +
- " {\n" +
- " }\n" +
- " public int i;\n" +
- " Y() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " int baz() {\n" +
- " }\n" +
- " }\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<unterminated array initializer>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Initializer behind array initializer
- */
-
-public void test63() {
-
- String s =
- "class X { \n"+
- " int x[] = {0, 1} \n"+
- " { \n"+
- " } \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "class X {\n" +
- " int[] x = {0,1,};\n" +
- " {\n" +
- " }\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " int[] x = {0,1,};\n" +
- " {\n" +
- " }\n" +
- " X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString =
- "class X {\n" +
- " int[] x;\n" +
- " {\n" +
- " }\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<initializer behind array initializer>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Initializers mixed with fields
- */
-
-public void test64() {
-
- String s =
- "public class X \n"+
- " int[] x = { 0, 1}; \n"+
- " static int zz \n"+
- " { \n"+
- " } \n"+
- " static { \n"+
- " public int x; \n"+
- " { \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " int[] x = {0,1,};\n" +
- " static int zz;\n" +
- " {\n" +
- " }\n" +
- " static {\n" +
- " }\n" +
- " public int x;\n" +
- " {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " int[] x = {0,1,};\n" +
- " static int zz;\n" +
- " {\n" +
- " }\n" +
- " static {\n" +
- " }\n" +
- " public int x;\n" +
- " {\n" +
- " }\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString =
- "public class X {\n" +
- " int[] x;\n" +
- " static int zz;\n" +
- " {\n" +
- " }\n" +
- " static {\n" +
- " }\n" +
- " public int x;\n" +
- " {\n" +
- " }\n" +
- " public X() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<initializers mixed with fields>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should find method behind some()
- */
-
-public void test65() {
-
- String s =
- "import java.lang.*; \n" +
- " \n" +
- "public class Hanoi { \n" +
- "private Post[] posts; \n" +
- "public static void main (String args[]) { \n" +
- "} \n" +
- "public void some(){ \n" +
- " \n" +
- "private void moveDisk (Post source, Post destination) { \n" +
- "} \n" +
- "protected void reportMove (Post source, Post destination) { \n" +
- "} \n" +
- "private void reset () { \n" +
- "} \n" +
- "public void solve () { \n" +
- "} \n" +
- "private void solve (int depth, Post start, Post free, Post end) { \n" +
- "} \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "import java.lang.*;\n" +
- "public class Hanoi {\n" +
- " private Post[] posts;\n" +
- " public Hanoi() {\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " }\n" +
- " public void some() {\n" +
- " }\n" +
- " private void moveDisk(Post source, Post destination) {\n" +
- " }\n" +
- " protected void reportMove(Post source, Post destination) {\n" +
- " }\n" +
- " private void reset() {\n" +
- " }\n" +
- " public void solve() {\n" +
- " }\n" +
- " private void solve(int depth, Post start, Post free, Post end) {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "import java.lang.*;\n" +
- "public class Hanoi {\n" +
- " private Post[] posts;\n" +
- " public Hanoi() {\n" +
- " super();\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " }\n" +
- " public void some() {\n" +
- " }\n" +
- " private void moveDisk(Post source, Post destination) {\n" +
- " }\n" +
- " protected void reportMove(Post source, Post destination) {\n" +
- " }\n" +
- " private void reset() {\n" +
- " }\n" +
- " public void solve() {\n" +
- " }\n" +
- " private void solve(int depth, Post start, Post free, Post end) {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should find method behind some()>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should detect X(int) as a method with no return type
- */
-
-public void test66() {
-
- String s =
- "class X { \n"+
- " class Y { \n"+
- " X(int i){} \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " X(int i) {\n" +
- " }\n" +
- " }\n" +
- " X() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " super();\n" +
- " }\n" +
- " X(int i) {\n" +
- " }\n" +
- " }\n" +
- " X() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should detect X(int) as a method with no return type>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should detect orphan X(int) as a constructor
- */
-
-public void test67() {
-
- String s =
- "class X { \n"+
- " class Y { \n"+
- " } \n"+
- "} \n"+
- " X(int i){ \n"+
- " } \n";
-
- String expectedDietUnitToString =
- "class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " }\n" +
- " X(int i) {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " super();\n" +
- " }\n" +
- " }\n" +
- " X(int i) {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should detect orphan X(int) as a constructor>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Empty unit
- */
-
-public void test68() {
-
- String s = "";
-
- String expectedDietUnitToString = "";
-
- String expectedDietPlusBodyUnitToString = expectedDietUnitToString;
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<empty unit>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Unit reduced to a method declaration
- */
-
-public void test69() {
-
- String s =
- " int foo(){ \n" +
- " System.out.println(); \n" +
- " } \n";
-
- String expectedDietUnitToString = "";
-
- String expectedDietPlusBodyUnitToString = expectedDietUnitToString;
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<unit reduced to a method declaration>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Unit reduced to a constructor declaration
- */
-
-public void test70() {
-
- String s =
- " X(){ \n" +
- " System.out.println(); \n" +
- " } \n";
-
- String expectedDietUnitToString = "";
-
- String expectedDietPlusBodyUnitToString = expectedDietUnitToString;
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<unit reduced to a constructor declaration>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Unit reduced to a field declaration
- */
-
-public void test71() {
-
- String s =
- " String str = new String();";
-
- String expectedDietUnitToString = "";
-
- String expectedDietPlusBodyUnitToString = expectedDietUnitToString;
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<unit reduced to a field declaration>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Unit reduced to a field declaration with array initializer
- */
-
-public void test72() {
-
- String s =
- " String[] str = { \"hello\" };";
-
- String expectedDietUnitToString = "";
-
- String expectedDietPlusBodyUnitToString = expectedDietUnitToString;
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<unit reduced to a field declaration with array initializer>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should not pick-up any constructor with no arg
- */
-
-public void test73() {
-
- String s =
- " class X { \n" +
- " X(int i){} \n" +
- " int foo(){ \n" +
- " new X( \n";
-
- String expectedDietUnitToString =
- "class X {\n" +
- " X(int i) {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " X(int i) {\n" +
- " super();\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should not pick-up any constructor with no arg>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should not detect any field
- */
-
-public void test74() {
-
- String s =
- "package pack; \n" +
- " \n" +
- "class A extends IOException { \n" +
- " \n" +
- " S{ \n" +
- " int x; \n" +
- " } \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "package pack;\n" +
- "class A extends IOException {\n" +
- " {\n" +
- " }\n" +
- " A() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package pack;\n" +
- "class A extends IOException {\n" +
- " {\n" +
- " }\n" +
- " A() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should not detect any field>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Bunch of syntax errors
- */
-
-public void test75() {
-
- String s =
- "package ZKentTest;\n"+
- "\n"+
- "import java.awt.color.*;\n"+
- "\n"+
- "public class A {\n"+
- " A foo(int i) { return this; }\n"+
- " int[] ii = {0, 1clone()\n"+
- "\n"+
- " int bar() {\n"+
- " class Local {\n"+
- " int hello(){\n"+
- " fo\n"+
- " }\n"+
- " int world()\n"+
- " }\n"+
- " void foo() {\n"+
- " ba \n";
-
- String expectedDietUnitToString =
- "package ZKentTest;\n" +
- "import java.awt.color.*;\n" +
- "public class A {\n" +
- " int[] ii;\n" +
- " public A() {\n" +
- " }\n" +
- " A foo(int i) {\n" +
- " }\n" +
- " int bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package ZKentTest;\n" +
- "import java.awt.color.*;\n" +
- "public class A {\n" +
- " int[] ii;\n" +
- " public A() {\n" +
- " super();\n" +
- " }\n" +
- " A foo(int i) {\n" +
- " return this;\n" +
- " }\n" +
- " int bar() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<bunch of syntax errors>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should find Member as a member type
- */
-
-public void test76() {
-
- String s =
- "package pack; \n"+
- "class A { \n"+
- " \n"+
- " public static void main(String[] argv) \n"+
- " new Member().f \n"+
- " ; \n"+
- " } \n"+
- " class Member { \n"+
- " int foo() \n"+
- " } \n"+
- " } \n"+
- "}; \n";
-
- String expectedDietUnitToString =
- "package pack;\n" +
- "class A {\n" +
- " class Member {\n" +
- " Member() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " }\n" +
- " A() {\n" +
- " }\n" +
- " public static void main(String[] argv) {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package pack;\n" +
- "class A {\n" +
- " class Member {\n" +
- " Member() {\n" +
- " super();\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " }\n" +
- " A() {\n" +
- " super();\n" +
- " }\n" +
- " public static void main(String[] argv) {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should find Member as a member type>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should not recover duplicate field numberOfDisks
- */
-
-public void test77() {
-
- String s =
- "package p; \n"+
- " \n"+
- "import java.lang.*; \n"+
- " \n"+
- "class IncompleteHanoi { \n"+
- "private Post[] posts; \n"+
- "private int numberOfDisks; \n"+
- " \n"+
- "public Hanoi (int numberOfDisks) { \n"+
- " this.numberOfDisks = numberOfDisks; \n"+
- "'' this.posts = new Post[3]; \n"+
- " String[] postNames = new String[]{\"Left\", \"Middle\", \"Right\"}; \n"+
- " \n"+
- " for (int i = 0; i < 3; ++i) \n"+
- " this.posts[i] = new Post(postNames[i], numberOfDisks); \n"+
- "} \n"+
- " \n"+
- "private void solve (int depth, Post start, Post free, Post end) { \n"+
- " if (depth == 1) \n"+
- " moveDisk(start, end); \n"+
- " else if (depth > 1) { \n"+
- " sol \n";
-
- String expectedDietUnitToString =
- "package p;\n" +
- "import java.lang.*;\n" +
- "class IncompleteHanoi {\n" +
- " private Post[] posts;\n" +
- " private int numberOfDisks;\n" +
- " IncompleteHanoi() {\n" +
- " }\n" +
- " public Hanoi(int numberOfDisks) {\n" +
- " }\n" +
- " private void solve(int depth, Post start, Post free, Post end) {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package p;\n" +
- "import java.lang.*;\n" +
- "class IncompleteHanoi {\n" +
- " private Post[] posts;\n" +
- " private int numberOfDisks;\n" +
- " IncompleteHanoi() {\n" +
- " super();\n" +
- " }\n" +
- " public Hanoi(int numberOfDisks) {\n" +
- " }\n" +
- " private void solve(int depth, Post start, Post free, Post end) {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should not recover duplicate field numberOfDisks>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should not detect a field v (1/2)
- */
-
-public void test78() {
-
- String s =
- "class X { \n" +
- " int foo(){ \n" +
- " Vector v = new Vector(); \n" +
- " s \n" +
- " v.addElement( \n" +
- " } \n";
-
- String expectedDietUnitToString =
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " X() {\n" +
- " super();\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should not detect a field v>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should not detect a field v (2/2)
- */
-
-public void test79() {
-
- String s =
- "class X { \n" +
- " int foo(){ \n" +
- " Vector v = new Vector(); \n" +
- " public s v.addElement( \n" +
- " } \n";
-
- String expectedDietUnitToString =
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " X() {\n" +
- " super();\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should not detect a field v>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should not detect a method bar
- */
-
-public void test80() {
-
- String s =
- "class X { \n" +
- " int test(){ \n" +
- " int[] i; \n" +
- " i \n" +
- " // some comment \n" +
- " bar(1); \n" +
- " } \n";
-
- String expectedDietUnitToString =
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " int test() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " X() {\n" +
- " super();\n" +
- " }\n" +
- " int test() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should not detect a method bar>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should not pick-up any constructor with no arg
- */
-
-public void test81() {
-
- String s =
- " class X { \n" +
- " X(int i){} \n" +
- " int foo(){ \n" +
- " X(12) \n";
-
- String expectedDietUnitToString =
- "class X {\n" +
- " X(int i) {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " X(int i) {\n" +
- " super();\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should not pick-up any constructor with no arg>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should not promote message sending as a method
- */
-
-public void test82() {
-
- String s =
- "public class A { \n"+
- " \n"+
- " void foo() \n"+
- " if (true) { \n"+
- " } else { \n"+
- " Bar s; \n"+
- " s.fred(); \n"+
- " } \n"+
- " } \n"+
- "} \n";
- String expectedDietUnitToString =
- "public class A {\n" +
- " public A() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class A {\n" +
- " public A() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should not promote message sending as a method>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should not promote message sending as a method 2
- */
-
-public void test83() {
-
- String s =
- "public class A { \n"+
- " \n"+
- " void foo() if (true) { \n"+
- " } else { \n"+
- " Bar s; \n"+
- " s.fred(); \n"+
- " } \n"+
- " } \n"+
- "} \n";
- String expectedDietUnitToString =
- "public class A {\n" +
- " public A() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class A {\n" +
- " public A() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should not promote message sending as a method>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should find a static initializer
- */
-
-public void test84() {
-
- String s =
- "public class A extends \n" +
- " \n" +
- " static { \n" +
- "} \n";
- String expectedDietUnitToString =
- "public class A {\n" +
- " static {\n" +
- " }\n" +
- " public A() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class A {\n" +
- " static {\n" +
- " }\n" +
- " public A() {\n" +
- " super();\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should find a static initializer>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should find a static initializer
- */
-
-public void test85() {
-
- String s =
- "public class A \n" +
- " \n" +
- " static { \n" +
- "} \n";
- String expectedDietUnitToString =
- "public class A {\n" +
- " static {\n" +
- " }\n" +
- " public A() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class A {\n" +
- " static {\n" +
- " }\n" +
- " public A() {\n" +
- " super();\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should find a static initializer>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should find an initializer
- */
-
-public void test86() {
-
- String s =
- "public class A \n" +
- " \n" +
- " int \n" +
- " { \n" +
- "} \n";
- String expectedDietUnitToString =
- "public class A {\n" +
- " {\n" +
- " }\n" +
- " public A() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class A {\n" +
- " {\n" +
- " }\n" +
- " public A() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should find an initializer>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Should find an initializer
- */
-
-public void test87() {
-
- String s =
- "public class A \n" +
- " \n" +
- " int x; \n" +
- " { \n" +
- " int y; \n" +
- "} \n";
- String expectedDietUnitToString =
- "public class A {\n" +
- " int x;\n" +
- " {\n" +
- " }\n" +
- " public A() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class A {\n" +
- " int x;\n" +
- " {\n" +
- " }\n" +
- " public A() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<should find an initializer>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * 1FVRQG0: ITPCOM:WINNT - NullPointerException in recovery mode
- */
-
-public void test88() {
-
- String s =
- "package p1; \n" +
- " \n" +
- "public class X { \n" +
- " int foo(String s, int x) \n" +
- " public int y = new X() { \n" +
- " \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "package p1;\n" +
- "public class X {\n" +
- " public int y;\n" +
- " public X() {\n" +
- " }\n" +
- " int foo(String s, int x) {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "package p1;\n" +
- "public class X {\n" +
- " public int y;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " int foo(String s, int x) {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString =
- "package p1;\n" +
- "public class X {\n" +
- " public int y;\n" +
- " public X() {\n" +
- " }\n" +
- " int foo(String s, int x) {\n" +
- " }\n" +
- "}\n";;
-
- String testName = "<1FVRQG0: ITPCOM:WINNT - NullPointerException in recovery mode>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * 1FVRN9V: ITPJCORE:WIN98 - Internal builder error compiling servlet
- */
-
-public void test89() {
-
- String s =
- "import javax.servlet.*; \n" +
- "import javax.servlet.http.*; \n" +
- " \n" +
- "public class Servlet1 extends HttpServlet { \n" +
- " protected (HttpServletRequest req, HttpServletResponse resp) { \n" +
- " } \n" +
- "} \n";
-
- String expectedDietUnitToString =
- "import javax.servlet.*;\n" +
- "import javax.servlet.http.*;\n" +
- "public class Servlet1 extends HttpServlet {\n" +
- " HttpServletRequest req;\n" +
- " HttpServletRequest HttpServletResponse;\n" +
- " {\n" +
- " }\n" +
- " public Servlet1() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "import javax.servlet.*;\n" +
- "import javax.servlet.http.*;\n" +
- "public class Servlet1 extends HttpServlet {\n" +
- " HttpServletRequest req;\n" +
- " HttpServletRequest HttpServletResponse;\n" +
- " {\n" +
- " }\n" +
- " public Servlet1() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<1FVRN9V: ITPJCORE:WIN98 - Internal builder error compiling servlet>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * 1FVXQZ4: ITPCOM:WIN98 - Walkback during parsing recovery
- */
-
-public void test90() {
-
- String s =
- "public class Test { \n"+
- " \n"+
- " int x; \n"+
- " int foo( \n"+
- " int bar( \n"+
- " baz(A a \n"+
- "} \n";
- String expectedDietUnitToString =
- "public class Test {\n" +
- " int x;\n" +
- " public Test() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " int bar() {\n" +
- " }\n" +
- " baz(A a) {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class Test {\n" +
- " int x;\n" +
- " public Test() {\n" +
- " super();\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " int bar() {\n" +
- " }\n" +
- " baz(A a) {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<1FVXQZ4: ITPCOM:WIN98 - Walkback during parsing recovery>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * 1FVXWKI: ITPCOM:WIN98 - Walkback when parsing a bogus interface
- */
-
-public void test91() {
-
- String s =
- "public interface Fred { \n" +
- " void foo(); \n" +
- " void bar(); \n" +
- " public fred(X x, int y); \n" +
- "} \n";
- String expectedDietUnitToString =
- "public interface Fred {\n" +
- " void foo();\n" +
- " void bar();\n" +
- " public fred(X x, int y) {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString = expectedDietUnitToString;
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<1FVXWKI: ITPCOM:WIN98 - Walkback when parsing a bogus interface>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * Variation on 1FVXWKI: ITPCOM:WIN98 - Walkback when parsing a bogus interface
- */
-
-public void test92() {
- String s =
- "public interface Test { \n"+
- " void foo(); \n"+
- " \n"+
- " public fred(Fred x, int y); \n"+
- "} \n";
- String expectedDietUnitToString =
- "public interface Test {\n" +
- " void foo();\n" +
- " public fred(Fred x, int y) {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString = expectedDietUnitToString;
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<1FVXWKI: ITPCOM:WIN98 - Walkback when parsing a bogus interface>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * 1FW5A4E: ITPCOM:WIN98 - Walkback reconciling
- */
-
-public void test93() {
- String s =
- "class X{ \n" +
- " int foo() \n" +
- " static { } \n" +
- "} \n";
- String expectedDietUnitToString =
- "class X {\n" +
- " static {\n" +
- " }\n" +
- " X() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " static {\n" +
- " }\n" +
- " X() {\n" +
- " super();\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<1FW5A4E: ITPCOM:WIN98 - Walkback reconciling>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * 1FW3663: ITPCOM:WIN98 - Outline - does not show method #fred()
- */
-
-public void test94() {
- String s =
- "public class X { \n" +
- " int[] array; \n" +
- " \n" +
- "void foo() { \n" +
- " bar(this.array.length, 10, fred( \n" +
- " \n" +
- "int fred( \n" +
- "} \n";
- String expectedDietUnitToString =
- "public class X {\n" +
- " int[] array;\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " int fred() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " int[] array;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- " int fred() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<1FW3663: ITPCOM:WIN98 - Outline - does not show method #fred()>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * 1FW6M5M: ITPJUI:ALL - NPE in SourceElementParser
- */
-
-public void test95() {
- String s =
- "public interface IP { \n"+
- " public static toString() { \n"+
- " } \n"+
- "} \n";
- String expectedDietUnitToString =
- "public interface IP {\n" +
- " public static toString() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString = expectedDietUnitToString;
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<1FW6M5M: ITPJUI:ALL - NPE in SourceElementParser>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * 1FWHXX7: ITPCOM:WINNT - ClassCastException compiling invalid import
- */
-
-public void test96() {
- String s =
- "import ;\n"+
- "class X {\n"+
- " int foo(){\n"+
- " System.out.println();\n"+
- " }\n"+
- " static {\n"+
- " int i = j;\n"+
- " }\n"+
- "}\n";
- String expectedDietUnitToString =
- "class X {\n" +
- " static {\n" +
- " }\n" +
- " X() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " static {\n" +
- " int i = j;\n" +
- " }\n" +
- " X() {\n" +
- " super();\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " int foo() {\n" +
- " System.out.println();\n" +
- " }\n" +
- "}\n";
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<1FWHXX7: ITPCOM:WINNT - ClassCastException compiling invalid import>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * variation on 1FWHXX7: ITPCOM:WINNT - ClassCastException compiling invalid import
- */
-
-public void test97() {
- String s =
- "import ;\n"+
- "class X {\n"+
- " int foo(){\n"+
- " System.out.println();\n"+
- " }\n"+
- " static {\n"+
- " }\n"+
- "}\n";
- String expectedDietUnitToString =
- "class X {\n" +
- " static {\n" +
- " }\n" +
- " X() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " static {\n" +
- " }\n" +
- " X() {\n" +
- " super();\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " int foo() {\n" +
- " System.out.println();\n" +
- " }\n" +
- "}\n";
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<variation on 1FWHXX7: ITPCOM:WINNT - ClassCastException compiling invalid import>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-/*
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=9084
- */
-
-public void test98() {
-
- String s =
- "public class A { \n"+
- " class Platform { \n"+
- " public static void run(Runnable r) { \n"+
- " } \n"+
- " } \n"+
- " Object [] array = null; \n"+
- " for (int nX = 0; nX < array.length; nX ++) { \n"+
- " final String part = \"\"; \n"+
- " final String sel = \"\"; \n"+
- " Object l = null; \n"+
- " if ((part != null && sel != null) || l instanceof String) { \n"+
- " Platform.run(new Runnable() { \n"+
- " public void run() { \n"+
- " } \n"+
- " public void handleException(Throwable e) { \n"+
- " } \n"+
- " }); \n"+
- " } \n"+
- " } \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "public class A {\n"+
- " class Platform {\n"+
- " Platform() {\n"+
- " }\n"+
- " public static void run(Runnable r) {\n"+
- " }\n"+
- " }\n"+
- " Object[] array = null;\n"+
- " int nX = 0;\n"+
- " {\n"+
- " }\n"+
- " final String sel = \"\";\n"+
- " Object l = null;\n"+
- " {\n"+
- " }\n"+
- " public A() {\n"+
- " }\n"+
- "}\n";
-
-
- String expectedDietPlusBodyUnitToString = "public class A {\n"+
- " class Platform {\n"+
- " Platform() {\n"+
- " super();\n"+
- " }\n"+
- " public static void run(Runnable r) {\n"+
- " }\n"+
- " }\n"+
- " Object[] array = null;\n"+
- " int nX = 0;\n"+
- " {\n"+
- " }\n"+
- " final String sel = \"\";\n"+
- " Object l = null;\n"+
- " {\n"+
- " Platform.run(new Runnable());\n"+
- " }\n"+
- " public A() {\n"+
- " super();\n"+
- " }\n"+
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString =
- "public class A {\n"+
- " class Platform {\n"+
- " Platform() {\n"+
- " }\n"+
- " public static void run(Runnable r) {\n"+
- " }\n"+
- " }\n"+
- " Object[] array;\n"+
- " int nX;\n"+
- " {\n"+
- " }\n"+
- " final String sel;\n"+
- " Object l;\n"+
- " {\n"+
- " }\n"+
- " public A() {\n"+
- " }\n"+
- "}\n";
-
- String testName = "<check for null inside RecoveredInitializer>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-
-public void test99() {
- String s =
- "import ;\n"+
- "class X {\n"+
- "}\n"+
- "- public void addThreadFilter(IJavaThread thread) - restricts breakpoint to \n"+
- "given thread and any other previously specified threads\n"+
- "- public void removeThreadFilter(IJavaThread thread)- removes the given thread \n"+
- "restriction (will need to re-create breakpoint request as JDI does not support \n"+
- "the removal of thread filters)\n"+
- "- public IJavaThread[] getThreadFilters() - return the set of threads this \n"+
- "breakpoint is currently restricted to\n";
- String expectedDietUnitToString =
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " public void addThreadFilter(IJavaThread thread) {\n" +
- " }\n" +
- " public void removeThreadFilter(IJavaThread thread) {\n" +
- " }\n" +
- " public IJavaThread[] getThreadFilters() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "class X {\n" +
- " X() {\n" +
- " super();\n" +
- " }\n" +
- " public void addThreadFilter(IJavaThread thread) {\n" +
- " }\n" +
- " public void removeThreadFilter(IJavaThread thread) {\n" +
- " }\n" +
- " public IJavaThread[] getThreadFilters() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<9101 - Parse error while typing in Java editor>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-public void test100() {
- String s =
- "public class Bug {\n" +
- " static boolean bold = false;\n" +
- "public static void main(String arguments[]) {\n" +
- " Shell shell = new Shell(SWT.MENU | SWT.RESIZE | SWT.TITLE | SWT.H_SCROLL);\n" +
- " StyledText text = new StyledText(shell, SWT.WRAP); \n" +
- " shell.addListener(SWT.Resize, new Listener() {\n" +
- " public void handleEvent(Event e) {\n" +
- " text.setBounds(shell.getClientArea()); \n" +
- " } \n" +
- " }); \n" +
- " shell.addListener(SWT.KeyDown, bew Listener () {\n" +
- " public void handleEvent(Event e) {\n" +
- " bold = !bold;\n" +
- " }\n" +
- " }); \n" +
- " text.addLineStyleListener(new LineStyleListener() { \n" +
- " public void lineGetStyle(LineStyleEvent event) {\n" +
- " }\n" +
- " });\n" +
- "}\n" +
- "}\n";
-
- String expectedDietUnitToString =
- "public class Bug {\n" +
- " static boolean bold = false;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public Bug() {\n" +
- " }\n" +
- " public static void main(String[] arguments) {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class Bug {\n" +
- " static boolean bold = false;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public Bug() {\n" +
- " super();\n" +
- " }\n" +
- " public static void main(String[] arguments) {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString =
- "public class Bug {\n" +
- " static boolean bold = false;\n" +
- " public Bug() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public static void main(String[] arguments) {\n" +
- " }\n" +
- " bew Listener() {\n" +
- " }\n" +
- " public void handleEvent(Event e) {\n" +
- " }\n" +
- "}\n";
-
- String expectedCompletionDietUnitToString =
- "public class Bug {\n" +
- " static boolean bold;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public Bug() {\n" +
- " }\n" +
- " public static void main(String[] arguments) {\n" +
- " }\n" +
- "}\n";
-
- String testName = "<10616 - local type outside method>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-public void test101() {
- String s =
- "public class X { \n"+
- " Object foo(Stack<X> s) { \n"+
- " } \n"+
- " List<T> bar(int pos, T x1, T x2, List<T> l) { \n"+
- " } \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " Object foo() {\n" +
- " }\n" +
- " bar(int pos, T x1, T x2) {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " Object foo() {\n" +
- " }\n" +
- " bar(int pos, T x1, T x2) {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<12387 out of memory with generics>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-public void test102() {
- String s =
- "void ___eval() { \n"+
- "new Runnable(){ \n"+
- "void ___run() throws Throwable { \n"+
- "return blah; \n"+
- "} \n"+
- "private String blarg; \n"+
- "public void run (){ \n"+
- " class Local { \n" +
- " void baz() { \n"+
- " } \n" +
- " } \n"+
- "} \n"+
- "} \n"+
- ";} \n"+
- "public class Hello{ \n"+
- "private static int x; \n"+
- "private String blah; \n"+
- "public static void main (String[] args){ \n"+
- "} \n"+
- "public void hello (){ \n"+
- "} \n"+
- "public boolean blah (){ \n"+
- "return false;} \n"+
- "public void foo (){ \n"+
- "} \n"+
- "} \n";
-
- String expectedDietUnitToString =
- "public class Hello {\n" +
- " private static int x;\n" +
- " private String blah;\n" +
- " public Hello() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " }\n" +
- " public void hello() {\n" +
- " }\n" +
- " public boolean blah() {\n" +
- " }\n" +
- " public void foo() {\n" +
- " }\n" +
- "}\n" ;
-
- String expectedDietPlusBodyUnitToString =
- "public class Hello {\n" +
- " private static int x;\n" +
- " private String blah;\n" +
- " public Hello() {\n" +
- " super();\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public static void main(String[] args) {\n" +
- " }\n" +
- " public void hello() {\n" +
- " }\n" +
- " public boolean blah() {\n" +
- " return false;\n" +
- " }\n" +
- " public void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<12454 - handling toplevel anonymous>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-public void test103() {
- String s =
- "public class X{ \n"+
- " void foo(int x, int y, void z";
-
- String expectedDietUnitToString =
- "public class X {\n" +
- " void z;\n" +
- " public X() {\n" +
- " }\n" +
- " void foo(int x, int y) {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class X {\n" +
- " void z;\n" +
- " public X() {\n" +
- " super();\n" +
- " }\n" +
- " void foo(int x, int y) {\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<14038 - third argument type is void>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-public void test104() {
- String s =
- "public class P#AField {\n" +
- " public void setP#A(String P#A) {\n" +
- " this.P#A = P#A;\n" +
- " }\n" +
- "}";
-
- String expectedDietUnitToString =
- "public class P {\n" +
- " {\n" +
- " }\n" +
- " public void setP;\n" +
- " String P;\n" +
- " {\n" +
- " }\n" +
- " public P() {\n" +
- " }\n" +
- "}\n";
-
- String expectedDietPlusBodyUnitToString =
- "public class P {\n" +
- " {\n" +
- " }\n" +
- " public void setP;\n" +
- " String P;\n" +
- " {\n" +
- " }\n" +
- " public P() {\n" +
- " super();\n" +
- " }\n" +
- "}\n";
-
- String expectedFullUnitToString = expectedDietUnitToString;
-
- String expectedCompletionDietUnitToString = expectedDietUnitToString;
-
- String testName = "<16126>";
- checkParse(
- s.toCharArray(),
- expectedDietUnitToString,
- expectedDietPlusBodyUnitToString,
- expectedFullUnitToString,
- expectedCompletionDietUnitToString,
- testName);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ExplicitConstructorInvocationCompletionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ExplicitConstructorInvocationCompletionTest.java
deleted file mode 100644
index 99f18ca..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ExplicitConstructorInvocationCompletionTest.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-/**
- * Completion is expected to be an ExplicitConstructorInvocation
- * or inside an ExplicitConstructorInvocation
- */
-public class ExplicitConstructorInvocationCompletionTest extends AbstractCompletionTest {
-public ExplicitConstructorInvocationCompletionTest(String testName) {
- super(testName);
-}
-/*
- * Completion on a qualified 'super' constructor invocation.
- *
- * ie. ExplicitConstructorInvocation ::= Primary '.' 'super' '(' ArgumentListopt ')' ';'
- */
-public void testPrimarySuper() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " static Bar x; \n" +
- " public class InnerBar { \n" +
- " InnerBar(Bar x) { \n" +
- " } \n" +
- " } \n" +
- " public class SubInnerBar extends InnerBar { \n" +
- " SubInnerBar(Bar x) { \n" +
- " primary().super(1, 2, i); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "super(1, 2,",
- // expectedCompletionNodeToString:
- "<CompleteOnExplicitConstructorCall:primary().super(1, 2)>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " public class InnerBar {\n" +
- " InnerBar(Bar x) {\n" +
- " }\n" +
- " }\n" +
- " public class SubInnerBar extends InnerBar {\n" +
- " SubInnerBar(Bar x) {\n" +
- " <CompleteOnExplicitConstructorCall:primary().super(1, 2)>;\n" +
- " }\n" +
- " }\n" +
- " static Bar x;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete on explicit constructor invocation primary super>"
- );
-}
-/*
- * Completion on a qualified 'this' constructor invocation.
- *
- * ie. ExplicitConstructorInvocation ::= Primary '.' 'this' '(' ArgumentListopt ')' ';'
- */
-public void testPrimaryThis() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " static Bar x; \n" +
- " public class InnerBar { \n" +
- " InnerBar(Bar x) { \n" +
- " } \n" +
- " } \n" +
- " public class SubInnerBar extends InnerBar { \n" +
- " SubInnerBar(Bar x) { \n" +
- " primary().this(1, 2, i); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "this(1, 2,",
- // expectedCompletionNodeToString:
- "<CompleteOnExplicitConstructorCall:primary().this(1, 2)>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " public class InnerBar {\n" +
- " InnerBar(Bar x) {\n" +
- " }\n" +
- " }\n" +
- " public class SubInnerBar extends InnerBar {\n" +
- " SubInnerBar(Bar x) {\n" +
- " <CompleteOnExplicitConstructorCall:primary().this(1, 2)>;\n" +
- " }\n" +
- " }\n" +
- " static Bar x;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete on explicit constructor invocation primary this>"
- );
-}
-/*
- * Completion on a 'super' constructor invocation.
- *
- * ie. ExplicitConstructorInvocation ::= 'super' '(' ArgumentListopt ')' ';'
- */
-public void testSuper() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " Bar() { \n" +
- " super(1, 2, i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "super(1, 2,",
- // expectedCompletionNodeToString:
- "<CompleteOnExplicitConstructorCall:super(1, 2)>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " <CompleteOnExplicitConstructorCall:super(1, 2)>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<completion on 'super' constructor invocation>"
- );
-}
-/*
- * Completion on a 'this' constructor invocation.
- *
- * ie. ExplicitConstructorInvocation ::= 'this' '(' ArgumentListopt ')' ';'
- */
-public void testThis() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " Bar() { \n" +
- " this(1, 2, i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "this(1, 2,",
- // expectedCompletionNodeToString:
- "<CompleteOnExplicitConstructorCall:this(1, 2)>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " <CompleteOnExplicitConstructorCall:this(1, 2)>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<completion on 'this' constructor invocation>"
- );
-}
-/*
- * ExplicitConstructorInvocation ::= Name '.' 'super' '(' <ArgumentListopt> ')' ';'
- */
-public void testWrapperNameSuper() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " static Bar x; \n" +
- " public class InnerBar { \n" +
- " InnerBar(Bar x) { \n" +
- " } \n" +
- " } \n" +
- " public class SubInnerBar extends InnerBar { \n" +
- " SubInnerBar() { \n" +
- " Bar.super(fred().xyz); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred().x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " public class InnerBar {\n" +
- " InnerBar(Bar x) {\n" +
- " }\n" +
- " }\n" +
- " public class SubInnerBar extends InnerBar {\n" +
- " SubInnerBar() {\n" +
- " super(<CompleteOnMemberAccess:fred().x>);\n" +
- " }\n" +
- " }\n" +
- " static Bar x;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on wrapper name super>"
- );
-}
-/*
- * ExplicitConstructorInvocation ::= Name '.' 'this' '(' <ArgumentListopt> ')' ';'
- */
-public void testWrapperNameThis() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " static Bar x; \n" +
- " public class InnerBar { \n" +
- " InnerBar(Bar x) { \n" +
- " } \n" +
- " } \n" +
- " public class SubInnerBar extends InnerBar { \n" +
- " SubInnerBar() { \n" +
- " Bar.this(fred().xyz); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred().x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " public class InnerBar {\n" +
- " InnerBar(Bar x) {\n" +
- " }\n" +
- " }\n" +
- " public class SubInnerBar extends InnerBar {\n" +
- " SubInnerBar() {\n" +
- " this(<CompleteOnMemberAccess:fred().x>);\n" +
- " }\n" +
- " }\n" +
- " static Bar x;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on wrapper name this>"
- );
-}
-/*
- * ExplicitConstructorInvocation ::= Primary '.' 'this' '(' <ArgumentListopt> ')' ';'
- */
-public void testWrapperPrimarySuper() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " static Bar x; \n" +
- " public class InnerBar { \n" +
- " InnerBar(Bar x) { \n" +
- " } \n" +
- " } \n" +
- " public class SubInnerBar extends InnerBar { \n" +
- " SubInnerBar(Bar x) { \n" +
- " primary().super(fred().xyz); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred().x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " public class InnerBar {\n" +
- " InnerBar(Bar x) {\n" +
- " }\n" +
- " }\n" +
- " public class SubInnerBar extends InnerBar {\n" +
- " SubInnerBar(Bar x) {\n" +
- " super(<CompleteOnMemberAccess:fred().x>);\n" +
- " }\n" +
- " }\n" +
- " static Bar x;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on wrapper primary super>"
- );
-}
-/*
- * ExplicitConstructorInvocation ::= 'super' '(' <ArgumentListopt> ')' ';'
- */
-public void testWrapperSuper() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " Bar() { \n" +
- " super(fred().xyz); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " super(<CompleteOnMemberAccess:fred().x>);\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on wrapper super>"
- );
-}
-/*
- * ExplicitConstructorInvocation ::= 'this' '(' <ArgumentListopt> ')' ';'
- */
-public void testWrapperThis() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " Bar() { \n" +
- " this(fred().xyz); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " this(<CompleteOnMemberAccess:fred().x>);\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on wrapper this>"
- );
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ExplicitConstructorInvocationSelectionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ExplicitConstructorInvocationSelectionTest.java
deleted file mode 100644
index 2507e79..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ExplicitConstructorInvocationSelectionTest.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-/**
- * Selection is expected to be wrapped with an explicit constructor invocation.
- */
-public class ExplicitConstructorInvocationSelectionTest extends AbstractSelectionTest {
-public ExplicitConstructorInvocationSelectionTest(String testName) {
- super(testName);
-}
-/*
- * ExplicitConstructorInvocation ::= Name '.' 'super' '(' <ArgumentListopt> ')' ';'
- */
-public void testNameSuper() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " static Bar x; \n" +
- " public class InnerBar { \n" +
- " InnerBar(Bar x) { \n" +
- " } \n" +
- " } \n" +
- " public class SubInnerBar extends InnerBar { \n" +
- " SubInnerBar() { \n" +
- " Bar.super(fred()); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // selectionStartBehind:
- "Bar.super(",
- // selectionEndBehind:
- "fred",
- // expectedSelectionNodeToString:
- "<SelectOnMessageSend:fred()>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " public class InnerBar {\n" +
- " InnerBar(Bar x) {\n" +
- " }\n" +
- " }\n" +
- " public class SubInnerBar extends InnerBar {\n" +
- " SubInnerBar() {\n" +
- " super(<SelectOnMessageSend:fred()>);\n" +
- " }\n" +
- " }\n" +
- " static Bar x;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedSelectionIdentifier:
- "fred",
- // expectedReplacedSource:
- "fred()",
- // testName:
- "<select on explicit constructor invocation name super>"
- );
-}
-/*
- * ExplicitConstructorInvocation ::= Name '.' 'this' '(' <ArgumentListopt> ')' ';'
- */
-public void testNameThis() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " static Bar x; \n" +
- " public class InnerBar { \n" +
- " InnerBar(Bar x) { \n" +
- " } \n" +
- " } \n" +
- " public class SubInnerBar extends InnerBar { \n" +
- " SubInnerBar() { \n" +
- " Bar.this(fred()); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // selectionStartBehind:
- "Bar.this(",
- // selectionEndBehind:
- "fred",
- // expectedSelectionNodeToString:
- "<SelectOnMessageSend:fred()>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " public class InnerBar {\n" +
- " InnerBar(Bar x) {\n" +
- " }\n" +
- " }\n" +
- " public class SubInnerBar extends InnerBar {\n" +
- " SubInnerBar() {\n" +
- " this(<SelectOnMessageSend:fred()>);\n" +
- " }\n" +
- " }\n" +
- " static Bar x;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedSelectionIdentifier:
- "fred",
- // expectedReplacedSource:
- "fred()",
- // testName:
- "<select on explicit constructor invocation name this>"
- );
-}
-/*
- * ExplicitConstructorInvocation ::= Primary '.' 'this' '(' <ArgumentListopt> ')' ';'
- */
-public void testPrimarySuper() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " static Bar x; \n" +
- " public class InnerBar { \n" +
- " InnerBar(Bar x) { \n" +
- " } \n" +
- " } \n" +
- " public class SubInnerBar extends InnerBar { \n" +
- " SubInnerBar(Bar x) { \n" +
- " primary().super(fred()); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // selectionStartBehind:
- "super(",
- // selectionEndBehind:
- "fred",
- // expectedSelectionNodeToString:
- "<SelectOnMessageSend:fred()>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " public class InnerBar {\n" +
- " InnerBar(Bar x) {\n" +
- " }\n" +
- " }\n" +
- " public class SubInnerBar extends InnerBar {\n" +
- " SubInnerBar(Bar x) {\n" +
- " super(<SelectOnMessageSend:fred()>);\n" +
- " }\n" +
- " }\n" +
- " static Bar x;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedSelectionIdentifier:
- "fred",
- // expectedReplacedSource:
- "fred()",
- // testName:
- "<select on explicit constructor invocation primary super>"
- );
-}
-/*
- * ExplicitConstructorInvocation ::= 'super' '(' <ArgumentListopt> ')' ';'
- */
-public void testSuper() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " Bar() { \n" +
- " super(fred()); \n" +
- " } \n" +
- "} \n",
- // selectionStartBehind:
- "super(",
- // selectionEndBehind:
- "fred",
- // expectedSelectionNodeToString:
- "<SelectOnMessageSend:fred()>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " super(<SelectOnMessageSend:fred()>);\n" +
- " }\n" +
- "}\n",
- // expectedSelectionIdentifier:
- "fred",
- // expectedReplacedSource:
- "fred()",
- // testName:
- "<select on explicit constructor invocation super>"
- );
-}
-/*
- * ExplicitConstructorInvocation ::= 'this' '(' <ArgumentListopt> ')' ';'
- */
-public void testThis() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " Bar() { \n" +
- " this(fred()); \n" +
- " } \n" +
- "} \n",
- // selectionStartBehind:
- "this(",
- // selectionEndBehind:
- "fred",
- // expectedSelectionNodeToString:
- "<SelectOnMessageSend:fred()>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " this(<SelectOnMessageSend:fred()>);\n" +
- " }\n" +
- "}\n",
- // expectedSelectionIdentifier:
- "fred",
- // expectedReplacedSource:
- "fred()",
- // testName:
- "<select on explicit constructor invocation this>"
- );
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/FieldAccessCompletionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/FieldAccessCompletionTest.java
deleted file mode 100644
index 77c5e0f..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/FieldAccessCompletionTest.java
+++ /dev/null
@@ -1,2422 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-/**
- * Completion is expected to be a FieldAccess.
- */
-public class FieldAccessCompletionTest extends AbstractCompletionTest {
-public FieldAccessCompletionTest(String testName) {
- super(testName);
-}
-/*
- * AdditiveExpression ::= AdditiveExpression '-' <MultiplicativeExpression>
- */
-public void testAdditiveExpressionMinus() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " int foo() { \n" +
- " return 1 - fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on additive expression minus>"
- );
-}
-/*
- * AdditiveExpression ::= AdditiveExpression '+' <MultiplicativeExpression>
- */
-public void testAdditiveExpressionPlus() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " int foo() { \n" +
- " return 1 + fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on additive expression plus>"
- );
-}
-/*
- * AndExpression ::= AndExpression '&' <EqualityExpression>
- */
-public void testAndExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " boolean foo() { \n" +
- " return isTrue & fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " boolean foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // expectedReplacedSource:
- "<complete on and expression>"
- );
-}
-/*
- * ArgumentList ::= ArgumentList ',' <Expression>
- */
-public void testArgumentList() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " bizz(1, \"2\", fred().xyz); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on argument list>"
- );
-}
-/*
- * ArrayAccess ::= Name '[' <Expression> ']'
- */
-public void testArrayAccess() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " int foo() { \n" +
- " return v[fred().xyz]; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on array access>"
- );
-}
-/*
- * ArrayAccess ::= PrimaryNoNewArray '[' <Expression> ']'
- */
-public void testArrayAccessPrimaryNoNewArray() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " int foo() { \n" +
- " return buzz()[fred().xyz]; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on array access primary no new array>"
- );
-}
-/*
- * ArrayInitializer ::= '{' <VariableInitializers> '}'
- */
-public void testArrayInitializer() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int[] i = new int[] {fred().xyz} \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int[] i;\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on array initializer>"
- );
-}
-/*
- * ArrayInitializer ::= '{' <VariableInitializers> , '}'
- */
-public void testArrayInitializerComma() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int[] i = new int[] {fred().xyz,} \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int[] i;\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on array initializer comma>"
- );
-}
-/*
- * Assignment ::= LeftHandSide AssignmentOperator <AssignmentExpression>
- */
-public void testAssignment() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " i = fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on assignment>"
- );
-}
-/*
- * Block ::= OpenBlock '{' <BlockStatementsopt> '}'
- */
-public void testBlock() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " try { \n" +
- " fred().xyz = new Foo(); \n" +
- " } catch (Exception e) {} \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on block>"
- );
-}
-/*
- * BlockStatements ::= BlockStatements <BlockStatement>
- */
-public void testBlockStatements() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 0; \n" +
- " fred().xyz = new Foo(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on block statements>"
- );
-}
-/*
- * ConstructorBody ::= NestedMethod '{' ExplicitConstructorInvocation <BlockStatements> '}'
- */
-public void testBlockStatementsInConstructorBody() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " Bar() { \n" +
- " super(); \n" +
- " fred().xyz = new Foo(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " super();\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on block statements in constructor body>"
- );
-}
-/*
- * BlockStatements ::= BlockStatements <BlockStatement>
- *
- * in a non static initializer.
- */
-public void testBlockStatementsInInitializer() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " { \n" +
- " int i = 0; \n" +
- " fred().xyz = new Foo(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " {\n" +
- " int i;\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on block statements in initializer>"
- );
-}
-/*
- * BlockStatements ::= BlockStatements <BlockStatement>
- *
- * in a static initializer.
- */
-public void testBlockStatementsInStaticInitializer() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " static { \n" +
- " int i = 0; \n" +
- " fred().xyz = new Foo(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " static {\n" +
- " int i;\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on block statements in static initializer>"
- );
-}
-/*
- * CastExpression ::= PushLPAREN <Expression> PushRPAREN UnaryExpressionNotPlusMinus
- *
- * NB: Valid syntaxically but not semantically
- */
-public void testCastExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " Bar foo() { \n" +
- " return (fred().xyz)buzz(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " Bar foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on cast expression>"
- );
-}
-/*
- * CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN <UnaryExpression>
- * or
- * CastExpression ::= PushLPAREN Name Dims PushRPAREN <UnaryExpressionNotPlusMinus>
- * or
- * CastExpression ::= PushLPAREN Expression PushRPAREN <UnaryExpressionNotPlusMinus>
- */
-public void testCastExpressionUnaryExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " Bar foo() { \n" +
- " return (Bar)(fred().xyz); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " Bar foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on cast expression unary expression>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= 'new' ClassType '(' <ArgumentListopt> ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " new Bar(fred().xyz); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on class instance creation expression>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpressionName() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " Bar.new Bar(fred().xyz); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on class instance creation expression name>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' <ArgumentListopt> ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpressionPrimary() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " bizz().new Bar(fred().xyz); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on class instance creation expression primary>"
- );
-}
-/*
- * ConditionalAndExpression ::= ConditionalAndExpression '&&' <InclusiveOrExpression>
- */
-public void testConditionalAndExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " boolean foo() { \n" +
- " return isTrue && fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " boolean foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on conditional and expression>"
- );
-}
-/*
- * ConditionalExpression ::= ConditionalOrExpression '?' <Expression> ':' ConditionalExpression
- */
-public void testConditionalExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " Bar foo() { \n" +
- " return fred().xyz == null ? null : new Bar(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " Bar foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on conditional expression>"
- );
-}
-/*
- * ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' <ConditionalExpression>
- */
-public void testConditionalExpressionConditionalExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " boolean foo() { \n" +
- " return isTrue ? true : fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " boolean foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on conditional expression conditional expression>"
- );
-}
-/*
- * ConditionalOrExpression ::= ConditionalOrExpression '||' <ConditionalAndExpression>
- */
-public void testConditionalOrExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " boolean foo() { \n" +
- " return isTrue || fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " boolean foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on conditional or expression>"
- );
-}
-/*
- * ConstructorBody ::= NestedMethod '{' <BlockStatementsopt> '}'
- */
-public void testConstructorBody() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " Bar() { \n" +
- " fred().xyz = new Foo(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " super();\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on constructor body>"
- );
-}
-/*
- * DimWithOrWithOutExpr ::= '[' <Expression> ']'
- */
-public void testDimWithOrWithOutExpr() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int[] v = new int[fred().xyz]; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int[] v;\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on dim with or without expr>"
- );
-}
-/*
- * DoStatement ::= 'do' Statement 'while' '(' <Expression> ')' ';'
- */
-public void testDoExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " do \n" +
- " System.out.println(); \n" +
- " while (fred().xyz); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on do expression>"
- );
-}
-/*
- * DoStatement ::= 'do' <Statement> 'while' '(' Expression ')' ';'
- */
-public void testDoStatement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " do \n" +
- " fred().xyz = new Foo(); \n" +
- " while (true); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on do statement>"
- );
-}
-/*
- * EqualityExpression ::= EqualityExpression '==' <RelationalExpression>
- */
-public void testEqualityExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " boolean foo() { \n" +
- " return 1 == fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " boolean foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on equality expression>"
- );
-}
-/*
- * EqualityExpression ::= EqualityExpression '!=' <RelationalExpression>
- */
-public void testEqualityExpressionNot() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " boolean foo() { \n" +
- " return 1 != fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " boolean foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on equality expression not>"
- );
-}
-/*
- * ExclusiveOrExpression ::= ExclusiveOrExpression '^' <AndExpression>
- */
-public void testExclusiveOrExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " boolean foo() { \n" +
- " return isTrue ^ fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " boolean foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on exclusive or expression>"
- );
-}
-/*
- * ConstructorBody ::= NestedMethod '{' <ExplicitConstructorInvocation> '}'
- * or
- * ConstructorBody ::= NestedMethod '{' <ExplicitConstructorInvocation> BlockStatements '}'
- */
-public void testExplicitConstructorInvocationInConstructorBody() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " static Bar x; \n" +
- " public class InnerBar { \n" +
- " } \n" +
- " public class SubInnerBar extends InnerBar { \n" +
- " SubInnerBar() { \n" +
- " Bar.x.x.super(); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "Bar.x.x",
- // expectedCompletionNodeToString:
- "<CompleteOnName:Bar.x.x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " public class InnerBar {\n" +
- " public InnerBar() {\n" +
- " }\n" +
- " }\n" +
- " public class SubInnerBar extends InnerBar {\n" +
- " SubInnerBar() {\n" +
- " super();\n" +
- " <CompleteOnName:Bar.x.x>;\n" +
- " }\n" +
- " }\n" +
- " static Bar x;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "Bar.x.x",
- // test name
- "<complete on explicit constructor invocation in constructor body>"
- );
-}
-/*
- * ForStatement ::= 'for' '(' <ForInitopt> ';' Expressionopt ';' ForUpdateopt ')' Statement
- * or
- * ForStatementNoShortIf ::= 'for' '(' <ForInitopt> ';' Expressionopt ';' ForUpdateopt ')' StatementNoShortIf
- */
-public void testForInit() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " for (int i = fred().xyz; i < 2; i++) \n" +
- " System.out.println(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i = <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on for init>"
- );
-}
-/*
- * ForStatement ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' <Statement>
- * or
- * ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' <StatementNoShortIf>
- */
-public void testForStatement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " for (int i = 0; i < 2; i++) \n" +
- " fred().xyz = new Foo(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on for statement>"
- );
-}
-/*
- * ForStatement ::= 'for' '(' ForInitopt ';' <Expressionopt> ';' ForUpdateopt ')' Statement
- * or
- * ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' <Expressionopt> ';' ForUpdateopt ')' StatementNoShortIf
- */
-public void testForStatementExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " for (int i = 0; fred().xyz > i; i++) \n" +
- " Systemout.println(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on for statement expression>"
- );
-}
-/*
- * ForStatement ::= 'for' '(' ForInitopt ';' Expressionopt ';' <ForUpdateopt> ')' Statement
- * or
- * ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' Expressionopt ';' <ForUpdateopt> ')' StatementNoShortIf
- */
-public void testForUpdate() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " for (int i = 0; i < 2; i+= fred().xyz) \n" +
- " System.out.println(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on for update>"
- );
-}
-/*
- * IfThenStatement ::= 'if' '(' <Expression> ')' Statement
- */
-public void testIfExpresionThen() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " if (fred().xyz) \n" +
- " System.out.println(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on \"if expression then\">"
- );
-}
-/*
- * IfThenElseStatement ::= 'if' '(' <Expression> ')' StatementNoShortIf 'else' Statement
- * or
- * IfThenElseStatementNoShortIf ::= 'if' '(' <Expression> ')' StatementNoShortIf 'else' StatementNoShortIf
- */
-public void testIfExpresionThenElse() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " if (fred().xyz) \n" +
- " System.out.println(); \n" +
- " else \n" +
- " System.out.println(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on \"if expression then else\">"
- );
-}
-/*
- * IfThenElseStatement ::= 'if' '(' Expression ')' StatementNoShortIf 'else' <Statement>
- * or
- * IfThenElseStatementNoShortIf ::= 'if' '(' Expression ')' StatementNoShortIf 'else' <StatementNoShortIf>
- */
-public void testIfThenElseStatement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " if (false) \n" +
- " System.out.println(); \n" +
- " else \n" +
- " fred().xyz = new Foo(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on \"if then else\" statement>"
- );
-}
-/*
- * IfThenStatement ::= 'if' '(' Expression ')' <Statement>
- */
-public void testIfThenStatement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " if (true) \n" +
- " fred().xyz = new Foo(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on \"if then\" statement>"
- );
-}
-/*
- * IfThenStatementElse ::= 'if' '(' Expression ')' <StatementNoShortIf> 'else' Statement
- * or
- * IfThenElseStatementNoShortIf ::= 'if' '(' Expression ')' <StatementNoShortIf> 'else' StatementNoShortIf
- */
-public void testIfThenStatementElse() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " if (true) \n" +
- " fred().xyz = new Foo(); \n" +
- " else \n" +
- " System.out.println(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on \"if then statement else\">"
- );
-}
-/*
- * InclusiveOrExpression ::= InclusiveOrExpression '|' <ExclusiveOrExpression>
- */
-public void testInclusiveOrExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " boolean foo() { \n" +
- " return isTrue | fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " boolean foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on inclusive or expression>"
- );
-}
-/*
- * LabeledStatement ::= 'Identifier' ':' <Statement>
- * or
- * LabeledStatementNoShortIf ::= 'Identifier' ':' <StatementNoShortIf>
- */
-public void testLabeledStatement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " fredCall: fred().xyz = new Foo(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // expectedLabels:
- new String[] {"fredCall"},
- // test name
- "<complete on labeled statement>"
- );
-}
-/*
- * MethodBody ::= NestedMethod '{' <BlockStatementsopt> '}'
- */
-public void testMethodBody() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " fred().xyz = new Foo(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on method body>"
- );
-}
-/*
- * MethodInvocation ::= Name '(' <ArgumentListopt> ')'
- */
-public void testMethodInvocation() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " bizz(fred().xyz); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on method invocation>"
- );
-}
-/*
- * MethodInvocation ::= Primary '.' 'Identifier' '(' <ArgumentListopt> ')'
- */
-public void testMethodInvocationPrimary() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " buzz().bizz(fred().xyz); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on method invocation primary>"
- );
-}
-/*
- * MethodInvocation ::= 'super' '.' 'Identifier' '(' <ArgumentListopt> ')'
- */
-public void testMethodInvocationSuper() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " super.bizz(fred().xyz); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on method invocation super>"
- );
-}
-/*
- * MultiplicativeExpression ::= MultiplicativeExpression '/' <UnaryExpression>
- */
-public void testMultiplicativeExpressiondDivision() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " double foo() { \n" +
- " return 2 / fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " double foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on multiplicative expression division>"
- );
-}
-/*
- * MultiplicativeExpression ::= MultiplicativeExpression '*' <UnaryExpression>
- */
-public void testMultiplicativeExpressionMultiplication() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " int foo() { \n" +
- " return 2 * fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on multiplicative expression multiplication>"
- );
-}
-/*
- * MultiplicativeExpression ::= MultiplicativeExpression '%' <UnaryExpression>
- */
-public void testMultiplicativeExpressionRemainder() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " int foo() { \n" +
- " return 2 % fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on multiplicative expression remainder>"
- );
-}
-/*
- * PreDecrementExpression ::= '--' PushPosition <UnaryExpression>
- */
-public void testPreIncrementExpressionMinusMinus() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " -- fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on pre increment expression minus minus>"
- );
-}
-/*
- * PreIncrementExpression ::= '++' PushPosition <UnaryExpression>
- */
-public void testPreIncrementExpressionPlusPlus() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " ++ fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on pre increment expression plus plus>"
- );
-}
-/*
- * PrimaryNoNewArray ::= PushLPAREN <Expression> PushRPAREN
- */
-public void testPrimaryNoNewArray() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " (fred().xyz).zzz(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on primary no new array>"
- );
-}
-/*
- * RelationalExpression ::= RelationalExpression '>' <ShiftExpression>
- */
-public void testRelationalExpressionGreaterThan() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " boolean foo() { \n" +
- " return 1 > fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " boolean foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on relational expression greater than>"
- );
-}
-/*
- * RelationalExpression ::= RelationalExpression '>=' <ShiftExpression>
- */
-public void testRelationalExpressionGreaterThanOrEquals() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " boolean foo() { \n" +
- " return 1 >= fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " boolean foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on relational expression greater than or equal>"
- );
-}
-/*
- * RelationalExpression ::= RelationalExpression '<' <ShiftExpression>
- */
-public void testRelationalExpressionLessThan() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " boolean foo() { \n" +
- " return 1 < fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " boolean foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on relational expression less than>"
- );
-}
-/*
- * RelationalExpression ::= RelationalExpression '<=' <ShiftExpression>
- */
-public void testRelationalExpressionLessThanOrEqual() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " boolean foo() { \n" +
- " return 1 <= fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " boolean foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on relational expression less than or equal>"
- );
-}
-/*
- * ReturnStatement ::= 'return' <Expressionopt> ';
- */
-public void testReturnStatement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " int foo() { \n" +
- " return fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on return statement>"
- );
-}
-/*
- * ShiftExpression ::= ShiftExpression '<<' <AdditiveExpression>
- */
-public void testShiftExpressionLeft() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " int foo() { \n" +
- " return i << fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on shift expression left>"
- );
-}
-/*
- * ShiftExpression ::= ShiftExpression '>>' <AdditiveExpression>
- */
-public void testShiftExpressionRight() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " int foo() { \n" +
- " return i >> fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on shift expression right>"
- );
-}
-/*
- * ShiftExpression ::= ShiftExpression '>>>' <AdditiveExpression>
- */
-public void testShiftExpressionRightUnSigned() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " int foo() { \n" +
- " return i >>> fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on shift expression right unsigned>"
- );
-}
-/*
- * StatementExpressionList ::= StatementExpressionList ',' <StatementExpression>
- */
-public void testStatementExpressionList() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " for (int i = 0, length = fred().xyz; i < 2; i++) \n" +
- " System.out.println(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " int length = <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on statement expression list>"
- );
-}
-/*
- * SwitchBlockStatement ::= SwitchLabels <BlockStatements>
- */
-public void testSwitchBlockStatement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 0; \n" +
- " switch (i) { \n" +
- " case 0: fred().xyz = new Foo(); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on switch block statement>"
- );
-}
-/*
- * SwitchStatement ::= 'switch' OpenBlock '(' <Expression> ')' SwitchBlock
- */
-public void testSwitchExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " switch (fred().xyz) { \n" +
- " case 0: System.out.println(); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on switch expression>"
- );
-}
-/*
- * SwitchLabel ::= 'case' <ConstantExpression> ':'
- */
-public void testSwitchLabel() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 0; \n" +
- " switch (i) { \n" +
- " case fred().xyz: System.out.println(); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on switch label>"
- );
-}
-/*
- * SynchronizedStatement ::= OnlySynchronized '(' <Expression> ')' Block
- */
-public void testSynchronizedStatement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " synchronized (fred().xyz) { \n" +
- " System.out.println(); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on synchronized expression>"
- );
-}
-/*
- * ThrowStatement ::= 'throw' <Expression> ';'
- */
-public void testThrowExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " throw fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on throw expression>"
- );
-}
-/*
- * UnaryExpressionNotPlusMinus ::= '~' PushPosition <UnaryExpression>
- */
-public void testUnaryExpressionBitwiseComplement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " i = ~ fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on unary expression bitwise complement>"
- );
-}
-/*
- * UnaryExpressionNotPlusMinus ::= '!' PushPosition <UnaryExpression>
- */
-public void testUnaryExpressionLogicalComplement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " i = ! fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on unary expression logical complement>"
- );
-}
-/*
- * UnaryExpression ::= '-' PushPosition <UnaryExpression>
- */
-public void testUnaryExpressionMinus() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " i = - fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on unary expression minus>"
- );
-}
-/*
- * UnaryExpression ::= '+' PushPosition <UnaryExpression>
- */
-public void testUnaryExpressionPlus() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " i = + fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on unary expression plus>"
- );
-}
-/*
- * VariableDeclarator ::= VariableDeclaratorId EnterField '=' ForceNoDiet <VariableInitializer> RestoreDiet ExitField
- */
-public void testVariableDeclarator() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i = <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on variable declarator>"
- );
-}
-/*
- * VariableInitializers ::= VariableInitializers ',' <VariableInitializer>
- */
-public void testVariableInitializers() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 0, j = fred().xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " int j = <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on variable initializers>"
- );
-}
-/*
- * WhileStatement ::= 'while' '(' <Expression> ')' Statement
- * or
- * WhileStatementNoShortIf ::= 'while' '(' <Expression> ')' StatementNoShortIf
- */
-public void testWhileExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " while (fred().xyz) \n" +
- " System.out.println(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on while expresion>"
- );
-}
-/*
- * WhileStatement ::= 'while' '(' Expression ')' <Statement>
- * or
- * WhileStatementNoShortIf ::= 'while' '(' Expression ')' <StatementNoShortIf>
- */
-public void testWhileStatement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " while (true) \n" +
- " fred().xyz = new Foo(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on while statement>"
- );
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/InnerTypeCompletionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/InnerTypeCompletionTest.java
deleted file mode 100644
index fdcb199..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/InnerTypeCompletionTest.java
+++ /dev/null
@@ -1,461 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-/**
- * Completion is expected to be in an inner type
- */
-public class InnerTypeCompletionTest extends AbstractCompletionTest {
-public InnerTypeCompletionTest(String testName) {
- super(testName);
-}
-/*
- * Test completion in the first method of an anonymous inner class
- */
-public void testAnonymousFirstMethod() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " Object o = new Object() { \n" +
- " void buzz() { \n" +
- " int i = fred().xyz; \n" +
- " } \n" +
- " void fuzz() { \n" +
- " } \n" +
- " }; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Object o;\n" +
- " new Object() {\n" +
- " () {\n" +
- " }\n" +
- " void buzz() {\n" +
- " int i = <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " void fuzz() {\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete in anonymous inner class in first method>"
- );
-}
-/*
- * Test completion in anonymous inner class with no statement defined before.
- */
-public void testAnonymousNoStatementBefore() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " Object o = new Object() { \n" +
- " void buzz() { \n" +
- " int i = fred().xyz; \n" +
- " } \n" +
- " }; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Object o;\n" +
- " new Object() {\n" +
- " () {\n" +
- " }\n" +
- " void buzz() {\n" +
- " int i = <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete in anonymous inner class with no statement before>"
- );
-}
-/*
- * Test completion in anonymous inner class with one field defined before
- * the method containing the completion.
- */
-public void testAnonymousOneFieldBefore() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " Object o = new Object() { \n" +
- " int field = 1; \n" +
- " void buzz() { \n" +
- " int i = fred().xyz; \n" +
- " } \n" +
- " }; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Object o;\n" +
- " new Object() {\n" +
- " int field;\n" +
- " () {\n" +
- " }\n" +
- " void buzz() {\n" +
- " int i = <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete in anonymous inner class with one field before>"
- );
-}
-/*
- * Test completion in anonymous inner class with one statement defined before.
- */
-public void testAnonymousOneStatementBefore() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 1; \n" +
- " Object o = new Object() { \n" +
- " void buzz() { \n" +
- " int i = fred().xyz; \n" +
- " } \n" +
- " }; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " Object o;\n" +
- " new Object() {\n" +
- " () {\n" +
- " }\n" +
- " void buzz() {\n" +
- " int i = <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete in anonymous inner class with one statement before>"
- );
-}
-/*
- * Test completion in the second method of an anonymous inner class
- */
-public void testAnonymousSecondMethod() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " Object o = new Object() { \n" +
- " void fuzz() { \n" +
- " } \n" +
- " void buzz() { \n" +
- " int i = fred().xyz; \n" +
- " } \n" +
- " }; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Object o;\n" +
- " new Object() {\n" +
- " () {\n" +
- " }\n" +
- " void fuzz() {\n" +
- " }\n" +
- " void buzz() {\n" +
- " int i = <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete in anonymous inner class in second method>"
- );
-}
-/*
- * Test completion in the first method of a local type declaration
- */
-public void testLocalTypeFirstMethod() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " class InnerBar { \n" +
- " void buzz() { \n" +
- " int i = fred().xyz; \n" +
- " } \n" +
- " void fuzz() { \n" +
- " } \n" +
- " }; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " class InnerBar {\n" +
- " InnerBar() {\n" +
- " }\n" +
- " void buzz() {\n" +
- " int i = <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " void fuzz() {\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete in local type declaration in first method>"
- );
-}
-/*
- * Test completion in local type declaration with no statement defined before.
- */
-public void testLocalTypeNoStatementBefore() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " class InnerBar { \n" +
- " void buzz() { \n" +
- " int i = fred().xyz; \n" +
- " } \n" +
- " }; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " class InnerBar {\n" +
- " InnerBar() {\n" +
- " }\n" +
- " void buzz() {\n" +
- " int i = <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete in local type declaration with no statement before>"
- );
-}
-/*
- * Test completion in local type declaration with one field defined before
- * the method containing the completion.
- */
-public void testLocalTypeOneFieldBefore() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " class InnerBar { \n" +
- " int field = 1; \n" +
- " void buzz() { \n" +
- " int i = fred().xyz; \n" +
- " } \n" +
- " }; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " class InnerBar {\n" +
- " int field;\n" +
- " InnerBar() {\n" +
- " }\n" +
- " void buzz() {\n" +
- " int i = <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete in local type declaration with one field before>"
- );
-}
-/*
- * Test completion in local type declaration with one statement defined before.
- */
-public void testLocalTypeOneStatementBefore() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 1; \n" +
- " class InnerBar { \n" +
- " void buzz() { \n" +
- " int i = fred().xyz; \n" +
- " } \n" +
- " }; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " class InnerBar {\n" +
- " InnerBar() {\n" +
- " }\n" +
- " void buzz() {\n" +
- " int i = <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete in local type declaration with 1 statement before>"
- );
-}
-/*
- * Test completion in the second method of a local type declaration
- */
-public void testLocalTypeSecondMethod() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " class InnerBar { \n" +
- " void fuzz() { \n" +
- " } \n" +
- " void buzz() { \n" +
- " int i = fred().xyz; \n" +
- " } \n" +
- " }; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:fred().x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " class InnerBar {\n" +
- " InnerBar() {\n" +
- " }\n" +
- " void fuzz() {\n" +
- " }\n" +
- " void buzz() {\n" +
- " int i = <CompleteOnMemberAccess:fred().x>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete in local type declaration in second method>"
- );
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LabelStatementCompletionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LabelStatementCompletionTest.java
deleted file mode 100644
index bbd7a21..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/LabelStatementCompletionTest.java
+++ /dev/null
@@ -1,491 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-/**
- * Completion is expected to be in a LabeledStatement.
- */
-public class LabelStatementCompletionTest extends AbstractCompletionTest {
-public LabelStatementCompletionTest(String testName) {
- super(testName);
-}
-/*
- * Completion inside an inner class defined inside a labeled statement.
- */
-public void test1FTEO9L() {
- String cu =
- "package p; \n" +
- " \n" +
- "class CCHelper { \n" +
- " class Member1 { \n" +
- " } \n" +
- " class Member2 { \n" +
- " } \n" +
- " void foo() { \n" +
- " } \n" +
- "} \n" +
- " \n" +
- "public class CC { \n" +
- " void foo() { \n" +
- " new CCHelper() \n" +
- " .new CCHelper() \n" +
- " .new M \n" +
- " } \n" +
- "} \n";
- // first case
- this.runTestCheckMethodParse(
- // compilationUnit:
- cu,
- // completeBehind:
- " .n",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:new CCHelper().n>",
- // expectedUnitDisplayString:
- "package p;\n" +
- "class CCHelper {\n" +
- " class Member1 {\n" +
- " Member1() {\n" +
- " }\n" +
- " }\n" +
- " class Member2 {\n" +
- " Member2() {\n" +
- " }\n" +
- " }\n" +
- " CCHelper() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n" +
- "public class CC {\n" +
- " public CC() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:new CCHelper().n>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "n",
- // expectedReplacedSource:
- "new",
- // test name
- "<regression test 1FTEO9L (first case)>"
- );
- // second case
- this.runTestCheckMethodParse(
- // compilationUnit:
- cu,
- // completeBehind:
- " .new CC",
- // expectedCompletionNodeToString:
- "<CompleteOnType:CC>",
- // expectedUnitDisplayString:
- "package p;\n" +
- "class CCHelper {\n" +
- " class Member1 {\n" +
- " Member1() {\n" +
- " }\n" +
- " }\n" +
- " class Member2 {\n" +
- " Member2() {\n" +
- " }\n" +
- " }\n" +
- " CCHelper() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n" +
- "public class CC {\n" +
- " public CC() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new CCHelper().new <CompleteOnType:CC>();\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "CC",
- // expectedReplacedSource:
- "CCHelper",
- // test name
- "<regression test 1FTEO9L (second case)>"
- );
- // third case
- this.runTestCheckMethodParse(
- // compilationUnit:
- cu,
- // completeBehind:
- " .new CCHelper() \n" +
- " .n",
- // expectedCompletionNodeToString:
- "<CompleteOnMemberAccess:new CCHelper().new CCHelper().n>",
- // expectedUnitDisplayString:
- "package p;\n" +
- "class CCHelper {\n" +
- " class Member1 {\n" +
- " Member1() {\n" +
- " }\n" +
- " }\n" +
- " class Member2 {\n" +
- " Member2() {\n" +
- " }\n" +
- " }\n" +
- " CCHelper() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n" +
- "public class CC {\n" +
- " public CC() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMemberAccess:new CCHelper().new CCHelper().n>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "n",
- // expectedReplacedSource:
- "new",
- // test name
- "<regression test 1FTEO9L (third case)>"
- );
- // fourth case
- this.runTestCheckMethodParse(
- // compilationUnit:
- cu,
- // completeBehind:
- " .new CCHelper() \n" +
- " .new M",
- // expectedCompletionNodeToString:
- "<CompleteOnType:M>",
- // expectedUnitDisplayString:
- "package p;\n" +
- "class CCHelper {\n" +
- " class Member1 {\n" +
- " Member1() {\n" +
- " }\n" +
- " }\n" +
- " class Member2 {\n" +
- " Member2() {\n" +
- " }\n" +
- " }\n" +
- " CCHelper() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n" +
- "public class CC {\n" +
- " public CC() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new CCHelper().new CCHelper().new <CompleteOnType:M>();\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "M",
- // expectedReplacedSource:
- "M",
- // test name
- "<regression test 1FTEO9L (fourth case)>"
- );
-}
-/*
- * Completion inside a case that has an identifier as its constant expression.
- */
-public void testInCaseWithIdentifier() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " label1: { \n" +
- " switch (i) { \n" +
- " case a: label2: X o = new Object(); \n" +
- " } \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " {\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "X",
- // expectedLabels:
- new String[] {"label1", "label2"},
- // test name
- "<complete in case with identifier>"
- );
-}
-/*
- * Completion inside a case that has a number as its constant expression.
- */
-public void testInCaseWithNumberConstant() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " label1: { \n" +
- " switch (i) { \n" +
- " case 1: label2: X o = new Object(); \n" +
- " } \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " {\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "X",
- // expectedLabels:
- new String[] {"label1", "label2"},
- // test name
- "<complete in case with number>"
- );
-}
-/*
- * Completion inside an inner class defined inside a labeled statement.
- */
-public void testInLabeledInnerClass() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " label1: { \n" +
- " Object o = new Object() { \n" +
- " void fred() { \n" +
- " label2: { \n" +
- " X o = new Object(); \n" +
- " } \n" +
- " } \n" +
- " }; \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " Object o;\n" +
- " new Object() {\n" +
- " () {\n" +
- " }\n" +
- " void fred() {\n" +
- " {\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "X",
- // expectedLabels:
- new String[] {"label2"},
- // test name
- "<complete in labeled inner class>"
- );
-}
-/*
- * Completion inside an inner class defined inside a labeled statement with a syntax error
- * just before the labeled statement.
- */
-public void testInLabeledInnerClassWithErrorBefore() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i == 2; \n" +
- " label1: { \n" +
- " Object o = new Object() { \n" +
- " void fred() { \n" +
- " label2: { \n" +
- " X o = new Object(); \n" +
- " } \n" +
- " } \n" +
- " }; \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " {\n" +
- " Object o;\n" +
- " new Object() {\n" +
- " () {\n" +
- " }\n" +
- " void fred() {\n" +
- " {\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "X",
- // expectedLabels:
- new String[] {"label2"},
- // test name
- "<complete in labeled inner class with syntax error before>"
- );
-}
-/*
- * Completion inside a labeled statement one level deep.
- */
-public void testOneLevelDeep() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " label1: X o = new Object(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "X",
- // expectedLabels:
- new String[] {"label1"},
- // test name
- "<complete in one level deep>"
- );
-}
-/*
- * Completion inside a labeled statement which is the second one in the method.
- */
-public void testSecondLabel() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " label1: buzz(); \n" +
- " label2: X o = new Object(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "X",
- // expectedLabels:
- new String[] {"label2"},
- // test name
- "<complete in second labeled statement>"
- );
-}
-/*
- * Completion inside a labeled statement two level deep.
- */
-public void testTwoLevelDeep() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " label1: { \n" +
- " label2: X o = new Object(); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "X",
- // expectedLabels:
- new String[] {"label1", "label2"},
- // test name
- "<complete in two level deep>"
- );
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/MethodInvocationCompletionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/MethodInvocationCompletionTest.java
deleted file mode 100644
index f9389d3..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/MethodInvocationCompletionTest.java
+++ /dev/null
@@ -1,857 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-/**
- * Completion is expected to be a MethodInvocation.
- */
-public class MethodInvocationCompletionTest extends AbstractCompletionTest {
-public MethodInvocationCompletionTest(String testName) {
- super(testName);
-}
-/*
- * Completion with no receiver inside a for statement.
- */
-public void test1FVVWS8_1() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " void foo() { \n" +
- " for (int i = 10; i > 0; --i) \n" +
- " fred( \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:fred()>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " <CompleteOnMessageSend:fred()>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(",
- // test name
- "<1FVVWS8_1>"
- );
-}
-/*
- * Completion with no receiver inside an if statement.
- */
-public void test1FVVWS8_2() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " void foo() { \n" +
- " if (true) \n" +
- " fred( \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:fred()>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:fred()>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(",
- // test name
- "<1FVVWS8_2>"
- );
-}
-/*
- * Completion with no receiver inside a for statement
- * and after a field access.
- */
-public void test1FW2ZTB_1() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " int[] array; \n" +
- " void foo() { \n" +
- " for (int i = this.array.length; i > 0; --i) \n" +
- " fred( \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:fred()>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " int[] array;\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " <CompleteOnMessageSend:fred()>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(",
- // test name
- "<1FW2ZTB_1"
- );
-}
-/*
- * Completion with no receiver inside another message send
- * and after a field access in a previous argument.
- */
-public void test1FW2ZTB_2() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " int[] array; \n" +
- " void foo() { \n" +
- " bar(this.array.length, 10, fred( \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:fred()>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " int[] array;\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:fred()>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(",
- // test name
- "<1FW2ZTB_2"
- );
-}
-/*
- * Complete on method invocation with expression receiver
- * inside another invocation with no receiver.
- */
-public void test1FW35YZ_1() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " bar(primary().fred( \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:primary().fred()>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:primary().fred()>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(",
- // test name
- "<1FW35YZ_1>"
- );
-}
-/*
- * Complete on qualified allocation expression
- * inside an invocation with no receiver.
- */
-public void test1FW35YZ_2() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " bar(primary().new X( \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X(",
- // expectedCompletionNodeToString:
- "<CompleteOnQualifiedAllocationExpression:primary().new X()>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnQualifiedAllocationExpression:primary().new X()>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<1FW35YZ_2>"
- );
-}
-/*
- * Completion with primary receiver.
- */
-public void test1FWYBKF() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " void foo() { \n" +
- " this.x.bar( \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "bar(",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:this.x.bar()>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:this.x.bar()>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "bar(",
- // test name
- "<1FWYBKF>"
- );
-}
-/*
- * Completion just after a parameter which is a message send.
- */
-public void test1GAJBUQ() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " x.y.Z.fred(buzz()); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(buzz()",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:x.y.Z.fred(buzz())>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:x.y.Z.fred(buzz())>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(buzz()",
- // test name
- "<1GAJBUQ>"
- );
-}
-/*
- * Completion just before the second parameter, the first parameter being an empty
- * anonymous class.
- */
-public void testAfterEmptyAnonymous() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " this.fred(new Runnable() {}, 2, i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(new Runnable() {}, ",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:this.fred(new Runnable())>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:this.fred(new Runnable())>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(new Runnable() {}, ",
- // test name
- "<completion just before second parameter, the first parameter being an empty anonymous class>"
- );
-}
-/*
- * Completion just after the first parameter.
- */
-public void testAfterFirstParameter() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " this.fred(\"abc\" , 2, i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(\"abc\" ",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:this.fred(\"abc\")>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:this.fred(\"abc\")>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(\"abc\" ",
- // test name
- "<completion just after first parameter>"
- );
-}
-/*
- * Completion just before the first parameter.
- */
-public void testBeforeFirstParameter() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " this.fred(1, 2, i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:this.fred()>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:this.fred()>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(",
- // test name
- "<completion just before first parameter>"
- );
-}
-/*
- * Completion just before the last parameter.
- */
-public void testBeforeLastParameter() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " this.fred(1, 2, i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(1, 2,",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:this.fred(1, 2)>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:this.fred(1, 2)>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(1, 2,",
- // test name
- "<completion just before last parameter>"
- );
-}
-/*
- * Completion just before the second parameter.
- */
-public void testBeforeSecondParameter() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " this.fred(1, 2, i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(1, ",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:this.fred(1)>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:this.fred(1)>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(1, ",
- // test name
- "<completion just before second parameter>"
- );
-}
-/*
- * Completion on empty name inside the expression of the first parameter.
- */
-public void testEmptyInFirstParameter() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " this.fred(\"abc\" + , 2, i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(\"abc\" +",
- // expectedCompletionNodeToString:
- "<CompleteOnName:>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<completion empty in first parameter>"
- );
-}
-/*
- * Completion inside the expression of the first parameter.
- */
-public void testInFirstParameter() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " this.fred(\"abc\" + bizz, 2, i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(\"abc\" + bi",
- // expectedCompletionNodeToString:
- "<CompleteOnName:bi>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:bi>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "bi",
- // expectedReplacedSource:
- "bizz",
- // test name
- "<completion inside first parameter>"
- );
-}
-/*
- * Completion inside an if statement.
- */
-public void testInIfStatement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " void foo() { \n" +
- " if (true) { \n" +
- " bar.fred(); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:bar.fred()>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " <CompleteOnMessageSend:bar.fred()>;\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(",
- // test name
- "<completion inside a if statement>"
- );
-}
-/*
- * Completion in labeled method invocation with expression receiver.
- */
-public void testLabeledWithExpressionReceiver() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " void foo() { \n" +
- " label1: bar().fred(1, 2, o); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(1, 2,",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:bar().fred(1, 2)>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:bar().fred(1, 2)>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(1, 2,",
- // expectedLabels:
- new String[] {"label1"},
- // test name
- "<completion in labeled method invocation with expression receiver>"
- );
-}
-/*
- * Completion in labeled method invocation without receiver.
- */
-public void testLabeledWithoutReceiver() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " label1: fred(1, 2, o); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(1, 2,",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:fred(1, 2)>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:fred(1, 2)>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(1, 2,",
- // expectedLabels:
- new String[] {"label1"},
- // test name
- "<completion in labeled method invocation without receiver>"
- );
-}
-/*
- * MethodInvocation ::= Name '(' ArgumentListopt ')'
- */
-public void testNoReceiver() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " fred(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:fred()>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:fred()>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(",
- // test name
- "<completion on method invocation with no receiver>"
- );
-}
-/*
- * Completion just before the first parameter with a space after the open parenthesis.
- */
-public void testSpaceThenFirstParameter() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " this.fred( 1, 2, i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred( ",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:this.fred()>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:this.fred()>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred( ",
- // test name
- "<completion just before first parameter with a space after open parenthesis>"
- );
-}
-/*
- * MethodInvocation ::= 'super' '.' 'Identifier' '(' ArgumentListopt ')'
- */
-public void testSuper() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " super.fred(1, 2, i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:super.fred()>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:super.fred()>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(",
- // test name
- "<completion on super method invocation>"
- );
-}
-/*
- * Complete on method invocation with expression receiver.
- */
-public void testWithExpressionReceiver() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " bar().fred(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:bar().fred()>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:bar().fred()>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(",
- // test name
- "<completion on method invocation with expression receiver>"
- );
-}
-/*
- * Completion with a name receiver.
- */
-public void testWithNameReceiver() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " Vector v = new Vector(); \n" +
- " v.addElement(\"1\"); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "addElement(",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:v.addElement()>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Vector v;\n" +
- " <CompleteOnMessageSend:v.addElement()>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "addElement(",
- // test name
- "<completion with name receiver>"
- );
-}
-/*
- * Completion with a name receiver after conditional expression.
- */
-public void testWithNameReceiverAfterConditionalExpression() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " void foo() { \n" +
- " buzz.test(cond ? max : min); \n" +
- " bar.fred(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred(",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:bar.fred()>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnMessageSend:bar.fred()>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(",
- // expectedLabels:
- new String[] {},
- // test name
- "<completion with name receiver after conditional expression>"
- );
-}
-/*
- * Completion with a name receiver and 2 arguments.
- */
-public void testWithNameReceiverAndTwoArgs() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " X x = new X(); \n" +
- " x.fred(1, 2, o); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x.fred(1, 2,",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:x.fred(1, 2)>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " X x;\n" +
- " <CompleteOnMessageSend:x.fred(1, 2)>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(1, 2,",
- // test name
- "<completion with name receiver and 2 arguments>"
- );
-}
-/*
- * Completion with a qualified name receiver.
- */
-public void testWithQualifiedNameReceiver() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " X x = new X(); \n" +
- " y.x.fred(1, 2, o); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x.fred(1, 2,",
- // expectedCompletionNodeToString:
- "<CompleteOnMessageSend:y.x.fred(1, 2)>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " X x;\n" +
- " <CompleteOnMessageSend:y.x.fred(1, 2)>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "fred(1, 2,",
- // test name
- "<completion with qualified name receiver>"
- );
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/NameReferenceCompletionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/NameReferenceCompletionTest.java
deleted file mode 100644
index 274bbe9..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/NameReferenceCompletionTest.java
+++ /dev/null
@@ -1,927 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-/**
- * Completion is expected to be a name reference.
- */
-public class NameReferenceCompletionTest extends AbstractCompletionTest {
-public NameReferenceCompletionTest(String testName) {
- super(testName);
-}
-/*
- * Regression test for 1FTZ849.
- * The instance creation before the completion is not properly closed, and thus
- * the completion parser used to think the completion was on a type.
- */
-public void test1FTZ849() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " X o = new X; \n" +
- " fred.xyz; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "fred.x",
- // expectedCompletionNodeToString:
- "<CompleteOnName:fred.x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " X o;\n" +
- " <CompleteOnName:fred.x>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "fred.xyz",
- // test name
- "<1FTZ849>"
- );
-}
-/*
- * Completion in a field initializer with no syntax error.
- */
-public void test1FUUP73() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "public class A { \n" +
- " String s = \"hello\"; \n" +
- " Object o = s.concat(\"boo\"); \n",
- // completeBehind:
- "Object o = s",
- // expectedCompletionNodeToString:
- "<CompleteOnName:s>",
- // expectedUnitDisplayString:
- "public class A {\n" +
- " String s;\n" +
- " Object o = <CompleteOnName:s>;\n" +
- " public A() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "s",
- // expectedReplacedSource:
- "s",
- // test name
- "<1FUUP73>"
- );
- this.runTestCheckDietParse(
- // compilationUnit:
- "public class A { \n" +
- " String s = \"hello\"; \n" +
- " Object o = s.concat(\"boo\"); \n",
- // completeBehind:
- "Object o = s.c",
- // expectedCompletionNodeToString:
- "<CompleteOnName:s.c>",
- // expectedUnitDisplayString:
- "public class A {\n" +
- " String s;\n" +
- " Object o = <CompleteOnName:s.c>;\n" +
- " public A() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "c",
- // expectedReplacedSource:
- "s.concat",
- // test name
- "<1FUUP73>"
- );
-}
-/*
- * Regression test for 1FVRQQA.
- */
-public void test1FVRQQA_1() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " void foo() { \n" +
- " Enumeration e = null; \n" +
- " e.to \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "e.to",
- // expectedCompletionNodeToString:
- "<CompleteOnName:e.to>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Enumeration e;\n" +
- " <CompleteOnName:e.to>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "to",
- // expectedReplacedSource:
- "e.to",
- // test name
- "<1FVRQQA_1>"
- );
-}
-/*
- * Regression test for 1FVRQQA.
- */
-public void test1FVRQQA_2() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " void foo() { \n" +
- " for (Enumeration e = getSomeEnumeration(); e.has \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "e.has",
- // expectedCompletionNodeToString:
- "<CompleteOnName:e.has>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Enumeration e;\n" +
- " <CompleteOnName:e.has>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "has",
- // expectedReplacedSource:
- "e.has",
- // test name
- "<1FVRQQA_2>"
- );
-}
-/*
- * Regression test for 1FVT66Q.
- */
-public void test1FVT66Q_1() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "package test; \n" +
- " \n" +
- "public class Test { \n" +
- " public void foo() { \n" +
- " final int codeAssistTarget= 3; \n" +
- " \n" +
- " Thread t= new Thread() { \n" +
- " public void run() { \n" +
- " codeAss \n" +
- " } \n" +
- " }; \n" +
- " codeA \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- " codeAss",
- // expectedCompletionNodeToString:
- "<CompleteOnName:codeAss>",
- // expectedUnitDisplayString:
- "package test;\n" +
- "public class Test {\n" +
- " public Test() {\n" +
- " }\n" +
- " public void foo() {\n" +
- " final int codeAssistTarget;\n" +
- " Thread t;\n" +
- " new Thread() {\n" +
- " () {\n" +
- " }\n" +
- " public void run() {\n" +
- " <CompleteOnName:codeAss>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "codeAss",
- // expectedReplacedSource:
- "codeAss",
- // test name
- "<1FVT66Q_1>"
- );
-}
-/*
- * Regression test for 1FVT66Q.
- */
-public void test1FVT66Q_2() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "package test; \n" +
- " \n" +
- "public class Test { \n" +
- " public void foo() { \n" +
- " final int codeAssistTarget= 3; \n" +
- " \n" +
- " Thread t= new Thread() { \n" +
- " public void run() { \n" +
- " codeAss \n" +
- " } \n" +
- " }; \n" +
- " codeA \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "\n codeA",
- // expectedCompletionNodeToString:
- "<CompleteOnName:codeA>",
- // expectedUnitDisplayString:
- "package test;\n" +
- "public class Test {\n" +
- " public Test() {\n" +
- " }\n" +
- " public void foo() {\n" +
- " final int codeAssistTarget;\n" +
- " Thread t;\n" +
- " <CompleteOnName:codeA>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "codeA",
- // expectedReplacedSource:
- "codeA",
- // test name
- "<1FVT66Q_2>"
- );
-}
-/*
- * Regression test for 1G8DE30.
- */
-public void test1G8DE30() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " new Runnable() { \n" +
- " public void run() { \n" +
- " Bar \n" +
- " } \n" +
- " }; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "public void run() { \n ",
- // expectedCompletionNodeToString:
- "<CompleteOnName:>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new Runnable() {\n" +
- " () {\n" +
- " }\n" +
- " public void run() {\n" +
- " <CompleteOnName:>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<1G8DE30>"
- );
-}
-/*
- * Completion on an empty name reference.
- */
-public void testEmptyNameReference() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 0; \n" +
- " \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "int i = 0; \n ",
- // expectedCompletionNodeToString:
- "<CompleteOnName:>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " <CompleteOnName:>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete on empty name reference>"
- );
-}
-/*
- * Completion on an empty name reference after a cast.
- */
-public void testEmptyNameReferenceAfterCast() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " void foo() { \n" +
- " X x = (X) \n" +
- " \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "(X)",
- // expectedCompletionNodeToString:
- "<CompleteOnName:>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " X x = (X) <CompleteOnName:>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete on empty name reference after cast>"
- );
-}
-/*
- * Completion on an empty name reference after + operator.
- */
-public void testEmptyNameReferenceAfterPlus() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " void foo() { \n" +
- " 1 + \n" +
- " \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "1 +",
- // expectedCompletionNodeToString:
- "<CompleteOnName:>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete on empty name reference after + operator>"
- );
-}
-/*
- * Completion on an empty name reference in an array dimension.
- */
-public void testEmptyNameReferenceInArrayDim() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " void foo() { \n" +
- " int[] \n" +
- " \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "int[",
- // expectedCompletionNodeToString:
- "<CompleteOnName:>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete on empty name reference in array dim>"
- );
-}
-/*
- * Completion on an empty name reference in inner class.
- */
-public void testEmptyNameReferenceInInnerClass() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " void foo() { \n" +
- " class Y { \n" +
- " void bar() { \n" +
- " \n" +
- " } \n" +
- " } \n" +
- " \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "\n ",
- // expectedCompletionNodeToString:
- "<CompleteOnName:>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " class Y {\n" +
- " Y() {\n" +
- " }\n" +
- " void bar() {\n" +
- " <CompleteOnName:>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete on empty name reference in inner class>"
- );
-}
-/*
- * Completion in the statement following an if expression.
- */
-public void testInIfThenStatement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " if (bar()) \n" +
- " \n" +
- " \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "\n ",
- // expectedCompletionNodeToString:
- "<CompleteOnName:>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete in if then statement>"
- );
-}
-/*
- * Completion on a name reference inside an inner class in a field initializer.
- */
-public void testInnerClassFieldInitializer() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar { \n" +
- " Object o = new Object() { \n" +
- " void foo() { \n" +
- " xyz \n" +
- " } \n" +
- " }; \n" +
- "} \n",
- // completeBehind:
- "xyz",
- // expectedCompletionNodeToString:
- "<CompleteOnName:xyz>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Object o = new Object() {\n" +
- " () {\n" +
- " super();\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:xyz>;\n" +
- " }\n" +
- " };\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "xyz",
- // expectedReplacedSource:
- "xyz",
- // test name
- "<complete on name reference in inner class in field initializer>"
- );
-}
-/*
- * Completion on an empty name reference inside an invocation in a field initializer.
- */
-public void testInvocationFieldInitializer() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar { \n" +
- " String s = fred(1 + ); \n" +
- " void foo() { \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "(1 + ",
- // expectedCompletionNodeToString:
- "<CompleteOnName:>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " String s = <CompleteOnName:>;\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "",
- // test name
- "<complete on empty name reference in invocation in field initializer>"
- );
-}
-/*
- * Completion inside an anonymous inner class which is
- * inside a method invocation with receiver.
- */
-public void testMethodInvocationAnonymousInnerClass() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " primary().bizz( \n" +
- " new X() { \n" +
- " void fuzz() { \n" +
- " x.y.z \n" +
- " } \n" +
- " } \n" +
- " ); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x.",
- // expectedCompletionNodeToString:
- "<CompleteOnName:x.>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new X() {\n" +
- " () {\n" +
- " }\n" +
- " void fuzz() {\n" +
- " <CompleteOnName:x.>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "x.",
- // test name
- "<complete inside anonymous inner class inside method invocation 1>"
- );
-}
-/*
- * Completion on a qualified name reference, where the cursor is in the
- * first type reference.
- */
-public void testQualifiedNameReferenceShrinkAll() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 0; \n" +
- " a.b.c.Xxx o = new Y(i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- " a",
- // expectedCompletionNodeToString:
- "<CompleteOnName:a>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " <CompleteOnName:a>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "a",
- // expectedReplacedSource:
- "a",
- // test name
- "<complete on qualified name reference (shrink all)>"
- );
-}
-/*
- * Completion on a qualified name reference, where the cursor is right after the first dot.
- */
-public void testQualifiedNameReferenceShrinkAllButOne() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " static Bar x; \n" +
- " public class InnerBar { \n" +
- " } \n" +
- " public class SubInnerBar extends InnerBar { \n" +
- " SubInnerBar() { \n" +
- " Bar.x.x.super(); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "Bar.",
- // expectedCompletionNodeToString:
- "<CompleteOnName:Bar.>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " public class InnerBar {\n" +
- " public InnerBar() {\n" +
- " }\n" +
- " }\n" +
- " public class SubInnerBar extends InnerBar {\n" +
- " SubInnerBar() {\n" +
- " super();\n" +
- " <CompleteOnName:Bar.>;\n" +
- " }\n" +
- " }\n" +
- " static Bar x;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "Bar.",
- // test name
- "<complete on qualified name reference (shrink all but one)>"
- );
-}
-/*
- * Completion on a qualified name reference, where the cursor is right after the first dot.
- */
-public void testQualifiedNameReferenceShrinkAllButOne2() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 0; \n" +
- " a.b.c.X o = new Y(i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- " a.",
- // expectedCompletionNodeToString:
- "<CompleteOnName:a.>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " <CompleteOnName:a.>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "a.",
- // test name
- "<complete on qualified name reference (shrink all but one) 2>"
- );
-}
-/*
- * Completion on a qualified name reference,where the cursor is right after the end
- * of the last name reference.
- */
-public void testQualifiedNameReferenceShrinkNone() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " static Bar x; \n" +
- " public class InnerBar { \n" +
- " } \n" +
- " public class SubInnerBar extends InnerBar { \n" +
- " SubInnerBar() { \n" +
- " Bar.x.x.super(); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "Bar.x.x",
- // expectedCompletionNodeToString:
- "<CompleteOnName:Bar.x.x>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " public class InnerBar {\n" +
- " public InnerBar() {\n" +
- " }\n" +
- " }\n" +
- " public class SubInnerBar extends InnerBar {\n" +
- " SubInnerBar() {\n" +
- " super();\n" +
- " <CompleteOnName:Bar.x.x>;\n" +
- " }\n" +
- " }\n" +
- " static Bar x;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "x",
- // expectedReplacedSource:
- "Bar.x.x",
- // test name
- "<complete on qualified name reference (shrink none)>"
- );
-}
-/*
- * Completion on a qualified name reference, where the cursor is right after the end
- * of the last type reference.
- */
-public void testQualifiedNameReferenceShrinkNone2() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 0; \n" +
- " a.b.c.Xxx o = new Y(i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:a.b.c.X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " <CompleteOnName:a.b.c.X>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "a.b.c.Xxx",
- // test name
- "<complete on qualified name reference (shrink none) 2>"
- );
-}
-/*
- * Completion on a qualified name reference, where the cursor is right after the
- * last dot.
- */
-public void testQualifiedNameReferenceShrinkOne() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " static Bar x; \n" +
- " public class InnerBar { \n" +
- " } \n" +
- " public class SubInnerBar extends InnerBar { \n" +
- " SubInnerBar() { \n" +
- " Bar.x.x.super(); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "Bar.x.",
- // expectedCompletionNodeToString:
- "<CompleteOnName:Bar.x.>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " public class InnerBar {\n" +
- " public InnerBar() {\n" +
- " }\n" +
- " }\n" +
- " public class SubInnerBar extends InnerBar {\n" +
- " SubInnerBar() {\n" +
- " super();\n" +
- " <CompleteOnName:Bar.x.>;\n" +
- " }\n" +
- " }\n" +
- " static Bar x;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "Bar.x.",
- // test name
- "<complete on qualified name reference (shrink one)>"
- );
-}
-/*
- * Completion on a qualified name reference, where the cursor is right after the
- * last dot.
- */
-public void testQualifiedNameReferenceShrinkOne2() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 0; \n" +
- " a.b.c.X o = new Y(i); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "a.b.c.",
- // expectedCompletionNodeToString:
- "<CompleteOnName:a.b.c.>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " <CompleteOnName:a.b.c.>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "a.b.c.",
- // test name
- "<complete on qualified name reference (shrink one) 2>"
- );
-}
-/*
- * Completion on a qualified name reference that contains a unicode.
- */
-public void testUnicode() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class X { \n" +
- " void foo() { \n" +
- " bar.\\u005ax \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x",
- // expectedCompletionNodeToString:
- "<CompleteOnName:bar.Zx>",
- // expectedUnitDisplayString:
- "class X {\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:bar.Zx>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "Zx",
- // expectedReplacedSource:
- "bar.\\u005ax",
- // test name
- "<complete on unicode>"
- );
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceTypeCompletionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceTypeCompletionTest.java
deleted file mode 100644
index 4dd54c6..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ReferenceTypeCompletionTest.java
+++ /dev/null
@@ -1,1539 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-/**
- * Completion is expected to be a ReferenceType.
- */
-public class ReferenceTypeCompletionTest extends AbstractCompletionTest {
-public ReferenceTypeCompletionTest(String testName) {
- super(testName);
-}
-/*
- * Regression test for 1FTZCIG.
- */
-public void test1FTZCIG() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " new X() { \n" +
- " protected void bar() { \n" +
- " } \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "p",
- // expectedCompletionNodeToString:
- "<CompleteOnType:p>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new X() {\n" +
- " <CompleteOnType:p>;\n" +
- " () {\n" +
- " }\n" +
- " void bar() {\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "p",
- // expectedReplacedSource:
- "protected",
- // test name
- "<1FTZCIG>"
- );
-}
-/*
- * Block ::= OpenBlock '{' <BlockStatementsopt> '}'
- */
-public void testBlock() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " try { \n" +
- " Xxx o = new Y(); \n" +
- " } catch (Exception e) { \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on block>"
- );
-}
-/*
- * BlockStatements ::= BlockStatements <BlockStatement>
- */
-public void testBlockStatements() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 0; \n" +
- " Xxx o = new Y(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on block statements>"
- );
-}
-/*
- * CatchClause ::= 'catch' '(' <FormalParameter> ')' Block
- */
-public void testCatchClause1() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " try { \n" +
- " fred(); \n" +
- " } catch (Xxx e) { \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnException:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnException:X>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on catch clause 1>"
- );
-}
-/*
- * CatchClause ::= 'catch' '(' <FormalParameter> ')' Block
- */
-public void testCatchClause2() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " try { \n" +
- " fred(); \n" +
- " } catch (final Xxx e) { \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnException:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnException:X>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on catch clause 2>"
- );
-}
-/*
- * CatchClause ::= 'catch' '(' <FormalParameter> ')' Block
- */
-public void testCatchClause3() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " try { \n" +
- " fred(); \n" +
- " } catch (x.y.Xxx e) { \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "x.y.X",
- // expectedCompletionNodeToString:
- "<CompleteOnException:x.y.X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnException:x.y.X>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "x.y.Xxx",
- // test name
- "<complete on catch clause 3>"
- );
-}
-/*
- * ClassBody ::= '{' <ClassBodyDeclarationsopt> '}'
- */
-public void testClassBody() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar { \n" +
- " Xxx foo() { \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " <CompleteOnType:X>\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class body>"
- );
-}
-/*
- * ClassBodyDeclarations ::= ClassBodyDeclarations <ClassBodyDeclaration>
- */
-public void testClassBodyDeclarations() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar { \n" +
- " int i = 0; \n" +
- " Xxx foo() { \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " int i;\n" +
- " Bar() {\n" +
- " }\n" +
- " <CompleteOnType:X>\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class body declarations>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= 'new' <ClassType> '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpression1() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " new Xxx().zzz(); \n" +
- " } \n" +
- "}\n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new <CompleteOnType:X>();\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class instance creation expression 1>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= 'new' <ClassType> '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpression2() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " new Y(new Xxx()).zzz(); \n" +
- " } \n" +
- "}\n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new <CompleteOnType:X>();\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class instance creation expression 2>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= 'new' <ClassType> '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpression3() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " new Y(1, true, new Xxx()).zzz(); \n" +
- " } \n" +
- "}\n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new <CompleteOnType:X>();\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class instance creation expression 3>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= 'new' <ClassType> '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpression4() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " fred().new Y(new Xxx()).zzz(); \n" +
- " } \n" +
- "}\n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new <CompleteOnType:X>();\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class instance creation expression 4>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpressionName1() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "public class Bar { \n" +
- " static Bar baz; \n" +
- " public class X { \n" +
- " void foo() { \n" +
- " Bar.baz.new Xxx(); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "new X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "public class Bar {\n" +
- " public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Bar.baz.new <CompleteOnType:X>();\n" +
- " }\n" +
- " }\n" +
- " static Bar baz;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class instance creation expression with name 1>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpressionName2() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "public class Bar { \n" +
- " static Bar baz; \n" +
- " public class X { \n" +
- " void foo() { \n" +
- " new Y(Bar.baz.new Xxx()); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "new X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "public class Bar {\n" +
- " public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Bar.baz.new <CompleteOnType:X>();\n" +
- " }\n" +
- " }\n" +
- " static Bar baz;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class instance creation expression with name 2>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpressionName3() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "public class Bar { \n" +
- " static Bar baz; \n" +
- " public class X { \n" +
- " void foo() { \n" +
- " new Y(1, true, Bar.baz.new Xxx()); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "new X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "public class Bar {\n" +
- " public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Bar.baz.new <CompleteOnType:X>();\n" +
- " }\n" +
- " }\n" +
- " static Bar baz;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class instance creation expression with name 3>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpressionName4() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "public class Bar { \n" +
- " static Bar baz; \n" +
- " public class X { \n" +
- " void foo() { \n" +
- " fred().new Y(Bar.baz.new Xxx()); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "new X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "public class Bar {\n" +
- " public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " Bar.baz.new <CompleteOnType:X>();\n" +
- " }\n" +
- " }\n" +
- " static Bar baz;\n" +
- " <clinit>() {\n" +
- " }\n" +
- " public Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class instance creation expression with name 4>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpressionPrimary1() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "public class Bar { \n" +
- " public class X { \n" +
- " void foo() { \n" +
- " new Bar().new Xxx(); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "new X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "public class Bar {\n" +
- " public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new Bar().new <CompleteOnType:X>();\n" +
- " }\n" +
- " }\n" +
- " public Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class instance creation expression with primary 1>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpressionPrimary2() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "public class Bar { \n" +
- " public class X { \n" +
- " void foo() { \n" +
- " new Y(new Bar().new Xxx()); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "new X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "public class Bar {\n" +
- " public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new Bar().new <CompleteOnType:X>();\n" +
- " }\n" +
- " }\n" +
- " public Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class instance creation expression with primary 2>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpressionPrimary3() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "public class Bar { \n" +
- " public class X { \n" +
- " void foo() { \n" +
- " fred().new Y(new Bar().new Xxx()); \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "new X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "public class Bar {\n" +
- " public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new Bar().new <CompleteOnType:X>();\n" +
- " }\n" +
- " }\n" +
- " public Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class instance creation expression with primary 3>"
- );
-}
-/*
- * ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
- */
-public void testClassInstanceCreationExpressionPrimary4() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "public class Bar { \n" +
- " public class X { \n" +
- " void foo() { \n" +
- " new Y(1, true, new Bar().new Xxx());\n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "new X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "public class Bar {\n" +
- " public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " new Bar().new <CompleteOnType:X>();\n" +
- " }\n" +
- " }\n" +
- " public Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class instance creation expression with primary 4>"
- );
-}
-/*
- * ClassTypeList ::= ClassTypeList ',' <ClassTypeElt>
- */
-public void testClassTypeList() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() throws Exception, Xxx { \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnException:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() throws Exception, <CompleteOnException:X> {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on class type list>"
- );
-}
-/*
- * ConstructorBody ::= NestedMethod '{' <BlockStatementsopt> '}'
- */
-public void testConstructorBody() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " Bar() { \n" +
- " Xxx o = new Y(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " super();\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on constructor body>"
- );
-}
-/*
- * ConstructorDeclarator ::= 'Identifier' '(' <FormalParameterListopt> ')'
- */
-public void testConstructorDeclarator() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar { \n" +
- " Bar(Xxx o) { \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar(<CompleteOnType:X> o) {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on constructor declarator>"
- );
-}
-/*
- * The reference type is burried in several blocks
- */
-public void testDeepReference() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " if (a == 2) { \n" +
- " } \n" +
- " try { \n" +
- " } finally { \n" +
- " if (1 == fgh) { \n" +
- " Xxx o = null; \n" +
- " } \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " {\n" +
- " {\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on deep type>"
- );
-}
-/*
- * Super ::= 'extends' <ClassType>
- */
-public void testExtendsClass() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar extends Xxx { \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnClass:X>",
- // expectedUnitDisplayString:
- "class Bar extends <CompleteOnClass:X> {\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on extends>"
- );
-}
-/*
- * ExtendsInterfaces ::= 'extends' <InterfaceTypeList>
- */
-public void testExtendsInterface() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "interface Bar extends Xxx { \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnInterface:X>",
- // expectedUnitDisplayString:
- "interface Bar extends <CompleteOnInterface:X> {\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on extends>"
- );
-}
-/*
- * FieldDeclaration ::= Modifiersopt <Type> VariableDeclarators ';'
- * where Modifiersopt is not empty
- */
-public void testFieldDeclarationWithModifiers() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar { \n" +
- " public final Xxx foo; \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " <CompleteOnType:X>;\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on field declaration with modifiers>"
- );
-}
-/*
- * FieldDeclaration ::= Modifiersopt <Type> VariableDeclarators ';'
- * where Modifiersopt is empty
- */
-public void testFieldDeclarationWithoutModifiers() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar { \n" +
- " Xxx foo; \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " <CompleteOnType:X>;\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on field declaration without modifiers>"
- );
-}
-/*
- * FormalParameter ::= Modifiers <Type> VariableDeclaratorId
- */
-public void testFormalParameter() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo(final Xxx x) { \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo(final <CompleteOnType:X> x) {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on formal parameter>"
- );
-}
-/*
- * FormalParameterList ::= FormalParameterList ',' <FormalParameter>
- */
-public void testFormalParameterList() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo(int i, final Object o, Xxx x) {\n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo(int i, final Object o, <CompleteOnType:X> x) {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on formal parameter list>"
- );
-}
-/*
- * ForStatement ::= 'for' '(' <ForInitopt> ';' Expressionopt ';' ForUpdateopt ')' Statement
- * or
- * ForStatementNoShortIf ::= 'for' '(' <ForInitopt> ';' Expressionopt ';' ForUpdateopt ')' StatementNoShortIf
- */
-public void testForStatement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " for (Xxx o = new Y(); o.size() < 10; ) {\n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on for statement>"
- );
-}
-/*
- * Interfaces ::= 'implements' <InterfaceTypeList>
- */
-public void testImplements() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar implements Xxx { \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnInterface:X>",
- // expectedUnitDisplayString:
- "class Bar implements <CompleteOnInterface:X> {\n" +
- " Bar() {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on implements>"
- );
-}
-/*
- * RelationalExpression ::= RelationalExpression 'instanceof' <ReferenceType>
- */
-public void testInstanceOf() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " boolean foo() { \n" +
- " return this instanceof Xxx; \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " boolean foo() {\n" +
- " <CompleteOnType:X>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on instanceof>"
- );
-}
-/*
- * InterfaceBody ::= '{' <InterfaceMemberDeclarationsopt> '}'
- */
-public void testInterfaceBody() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "interface Bar { \n" +
- " Xxx foo(); \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "interface Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " <CompleteOnType:X>\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on interface body>"
- );
-}
-/*
- * InterfaceMemberDeclarations ::= InterfaceMemberDeclarations <InterfaceMemberDeclaration>
- */
-public void testInterfaceMemberDeclarations() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "interface Bar { \n" +
- " int CONSTANT = 0; \n" +
- " Xxx foo(); \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "interface Bar {\n" +
- " int CONSTANT;\n" +
- " Bar() {\n" +
- " }\n" +
- " <clinit>() {\n" +
- " }\n" +
- " <CompleteOnType:X>\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on interface member declarations>"
- );
-}
-/*
- * InterfaceTypeList ::= InterfaceTypeList ',' <InterfaceType>
- */
-public void testInterfaceTypeList() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "interface Bar extends Comparable, Xxx { \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnInterface:X>",
- // expectedUnitDisplayString:
- "interface Bar extends Comparable, <CompleteOnInterface:X> {\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on interface list>"
- );
-}
-/*
- * LocalVariableDeclaration ::= Modifiers <Type> VariableDeclarators
- */
-public void testLocalVariableDeclaration() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " final Xxx o = new Y(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on local variable declaration>"
- );
-}
-/*
- * MethodBody ::= NestedMethod '{' <BlockStatementsopt> '}'
- */
-public void testMethodBody() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " Xxx o = new Y(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on method body>"
- );
-}
-/*
- * MethodDeclarator ::= 'Identifier' '(' <FormalParameterListopt> ')' Dimsopt
- */
-public void testMethodDeclarator() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo(Xxx o) { \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo(<CompleteOnType:X> o) {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on method declarator>"
- );
-}
-/*
- * MethodHeader ::= Modifiersopt <Type> MethodDeclarator Throwsopt
- * where Modifiersopt is not empty
- */
-public void testMethodHeaderWithModifiers() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar { \n" +
- " public static Xxx foo() { \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " <CompleteOnType:X>\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on method header with modifiers>"
- );
-}
-/*
- * MethodHeader ::= Modifiersopt <Type> MethodDeclarator Throwsopt
- * where Modifiersopt is empty
- */
-public void testMethodHeaderWithoutModifiers() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar { \n" +
- " Xxx foo() { \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " <CompleteOnType:X>\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on method header without modifiers>"
- );
-}
-/*
- * Completion on a qualified type reference, where the cursor is in the
- * first type reference.
- */
-public void testQualifiedTypeReferenceShrinkAll() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 0; \n" +
- " new a.b.c.Xxx(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- " new a",
- // expectedCompletionNodeToString:
- "<CompleteOnType:a>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " new <CompleteOnType:a>();\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "a",
- // expectedReplacedSource:
- "a",
- // test name
- "<complete on qualified type reference (shrink all)>"
- );
-}
-/*
- * Completion on a qualified type reference, where the cursor is right after the first dot.
- */
-public void testQualifiedTypeReferenceShrinkAllButOne() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 0; \n" +
- " new a.b.c.Xxx(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "a.",
- // expectedCompletionNodeToString:
- "<CompleteOnType:a.>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " new <CompleteOnType:a.>();\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "a.",
- // test name
- "<complete on qualified type reference (shrink all but one)>"
- );
-}
-/*
- * Completion on a qualified type reference, where the cursor is right after the end
- * of the last type reference.
- */
-public void testQualifiedTypeReferenceShrinkNone() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 0; \n" +
- " new a.b.c.Xxx(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnType:a.b.c.X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " new <CompleteOnType:a.b.c.X>();\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "a.b.c.Xxx",
- // test name
- "<complete on qualified type reference (shrink none)>"
- );
-}
-/*
- * Completion on a qualified type reference, where the cursor is right after the
- * last dot.
- */
-public void testQualifiedTypeReferenceShrinkOne() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 0; \n" +
- " new a.b.c.Xxx(); \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "a.b.c.",
- // expectedCompletionNodeToString:
- "<CompleteOnType:a.b.c.>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " new <CompleteOnType:a.b.c.>();\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "",
- // expectedReplacedSource:
- "a.b.c.",
- // test name
- "<complete on qualified type reference (shrink one)>"
- );
-}
-/*
- * SwitchBlockStatement ::= SwitchLabels <BlockStatements>
- */
-public void testSwitchBlockStatement() {
- this.runTestCheckMethodParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() { \n" +
- " int i = 1; \n" +
- " switch (i) { \n" +
- " case 1: \n" +
- " Xxx o = fred(i); \n" +
- " break; \n" +
- " default: \n" +
- " } \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnName:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() {\n" +
- " int i;\n" +
- " {\n" +
- " <CompleteOnName:X>;\n" +
- " }\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on switch block statement>"
- );
-}
-/*
- * Throws ::= 'throws' <ClassTypeList>
- */
-public void testThrows() {
- this.runTestCheckDietParse(
- // compilationUnit:
- "class Bar { \n" +
- " void foo() throws Xxx { \n" +
- " } \n" +
- "} \n",
- // completeBehind:
- "X",
- // expectedCompletionNodeToString:
- "<CompleteOnException:X>",
- // expectedUnitDisplayString:
- "class Bar {\n" +
- " Bar() {\n" +
- " }\n" +
- " void foo() throws <CompleteOnException:X> {\n" +
- " }\n" +
- "}\n",
- // expectedCompletionIdentifier:
- "X",
- // expectedReplacedSource:
- "Xxx",
- // test name
- "<complete on throws>"
- );
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionTest.java
deleted file mode 100644
index effe0ec..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionTest.java
+++ /dev/null
@@ -1,2118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-public class SelectionTest extends AbstractSelectionTest {
-public SelectionTest(String testName) {
- super(testName);
-}
-/*
- * Select superclass
- */
-public void test01() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends IOException { \n" +
- "} \n";
-
- String selectionStartBehind = "extends ";
- String selectionEndBehind = "IOException";
-
- String expectedCompletionNodeToString = "<SelectOnType:IOException>";
- String completionIdentifier = "IOException";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends <SelectOnType:IOException> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "IOException";
- String testName = "<select superclass>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkDietParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select superinterface
- */
-public void test02() {
-
- String str =
- "import java.io.*; \n" +
- " \n" +
- "public class X extends IOException implements Serializable { \n" +
- " int foo(){} \n" +
- "} \n";
-
- String selectionStartBehind = "implements ";
- String selectionEndBehind = "Serializable";
-
- String expectedCompletionNodeToString = "<SelectOnType:Serializable>";
- String completionIdentifier = "Serializable";
- String expectedUnitDisplayString =
- "import java.io.*;\n" +
- "public class X extends IOException implements <SelectOnType:Serializable> {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "Serializable";
- String testName = "<select superinterface>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkDietParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select qualified superclass
- */
-public void test03() {
-
- String str =
- "public class X extends java.io.IOException { \n" +
- "} \n";
-
- String selectionStartBehind = "java.io.";
- String selectionEndBehind = "IOException";
-
- String expectedCompletionNodeToString = "<SelectOnType:java.io.IOException>";
- String completionIdentifier = "IOException";
- String expectedUnitDisplayString =
- "public class X extends <SelectOnType:java.io.IOException> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.io.IOException";
- String testName = "<select qualified superclass>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkDietParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select package from qualified superclass
- */
-public void test04() {
-
- String str =
- "public class X extends java.io.IOException { \n" +
- "} \n";
-
- String selectionStartBehind = "java.";
- String selectionEndBehind = "java.io";
-
- String expectedCompletionNodeToString = "<SelectOnType:java.io>";
- String completionIdentifier = "io";
- String expectedUnitDisplayString =
- "public class X extends <SelectOnType:java.io> {\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.io.IOException";
- String testName = "<select package from qualified superclass>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkDietParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select message send
- */
-public void test05() {
-
- String str =
- "public class X extends java.io.IOException { \n" +
- " int foo(){ \n" +
- " System.out.println(\"hello\"); \n";
-
- String selectionStartBehind = "System.out.";
- String selectionEndBehind = "println";
-
- String expectedCompletionNodeToString = "<SelectOnMessageSend:System.out.println(\"hello\")>";
- String completionIdentifier = "println";
- String expectedUnitDisplayString =
- "public class X extends java.io.IOException {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <SelectOnMessageSend:System.out.println(\"hello\")>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "System.out.println(\"hello\")";
- String testName = "<select message send>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select message send with recovery before
- */
-public void test06() {
-
- String str =
- "public class X extends \n" +
- " int foo(){ \n" +
- " System.out.println(\"hello\"); \n";
-
- String selectionStartBehind = "System.out.";
- String selectionEndBehind = "println";
-
- String expectedCompletionNodeToString = "<SelectOnMessageSend:System.out.println(\"hello\")>";
- String completionIdentifier = "println";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <SelectOnMessageSend:System.out.println(\"hello\")>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "System.out.println(\"hello\")";
- String testName = "<select message send with recovery before>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select message send with sibling method
- */
-public void test07() {
-
- String str =
- "public class X extends \n" +
- " int foo(){ \n" +
- " this.bar(\"hello\"); \n" +
- " int bar(String s){ \n" +
- " return s.length(); \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "this.";
- String selectionEndBehind = "this.bar";
-
- String expectedCompletionNodeToString = "<SelectOnMessageSend:this.bar(\"hello\")>";
- String completionIdentifier = "bar";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <SelectOnMessageSend:this.bar(\"hello\")>;\n" +
- " }\n" +
- " int bar(String s) {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "this.bar(\"hello\")";
- String testName = "<select message send with sibling method>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select field reference
- */
-public void test08() {
-
- String str =
- "public class X { \n" +
- " int num = 0; \n" +
- " int foo(){ \n" +
- " int j = this.num; \n" +
- "} \n";
-
- String selectionStartBehind = "this.";
- String selectionEndBehind = "this.num";
-
- String expectedCompletionNodeToString = "<SelectionOnFieldReference:this.num>";
- String completionIdentifier = "num";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " int num;\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " int j;\n" +
- " <SelectionOnFieldReference:this.num>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "this.num";
- String testName = "<select field reference>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select field reference with syntax errors
- */
-public void test09() {
-
- String str =
- "public class X \n" +
- " int num \n" +
- " int foo(){ \n" +
- " int j = this.num; \n" +
- "} \n";
-
- String selectionStartBehind = "this.";
- String selectionEndBehind = "this.num";
-
- String expectedCompletionNodeToString = "<SelectionOnFieldReference:this.num>";
- String completionIdentifier = "num";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " int num;\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " int j;\n" +
- " <SelectionOnFieldReference:this.num>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "this.num";
- String testName = "<select field reference with syntax errors>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select field reference inside message receiver
- */
-public void test10() {
-
- String str =
- "public class X { \n" +
- " X x; \n" +
- " int foo(){ \n" +
- " int j = this.x.foo(); \n" +
- "} \n";
-
- String selectionStartBehind = "this.";
- String selectionEndBehind = "this.x";
-
- String expectedCompletionNodeToString = "<SelectionOnFieldReference:this.x>";
- String completionIdentifier = "x";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " X x;\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " int j;\n" +
- " <SelectionOnFieldReference:this.x>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "this.x";
- String testName = "<select field reference inside message receiver>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select allocation
- */
-public void test11() {
-
- String str =
- "public class X { \n" +
- " X(int i){} \n" +
- " int foo(){ \n" +
- " int j = 0; \n" +
- " X x = new X(j); \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "new ";
- String selectionEndBehind = "new X";
-
- String expectedCompletionNodeToString = "<SelectOnAllocationExpression:new X(j)>";
- String completionIdentifier = "X";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " X(int i) {\n" +
- " }\n" +
- " int foo() {\n" +
- " int j;\n" +
- " X x;\n" +
- " <SelectOnAllocationExpression:new X(j)>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "new X(j)";
- String testName = "<select allocation>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select qualified allocation
- */
-public void test12() {
-
- String str =
- "public class X { \n" +
- " class Y { \n" +
- " Y(int i){} \n" +
- " } \n" +
- " X(int i){} \n" +
- " int foo(){ \n" +
- " int j = 0; \n" +
- " X x = new X(j); \n" +
- " x.new Y(1); \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "x.new ";
- String selectionEndBehind = "x.new Y";
-
- String expectedCompletionNodeToString = "<SelectOnQualifiedAllocationExpression:x.new Y(1)>";
- String completionIdentifier = "Y";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " class Y {\n" +
- " Y(int i) {\n" +
- " }\n" +
- " }\n" +
- " X(int i) {\n" +
- " }\n" +
- " int foo() {\n" +
- " int j;\n" +
- " X x;\n" +
- " <SelectOnQualifiedAllocationExpression:x.new Y(1)>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "x.new Y(1)";
- String testName = "<select qualified allocation>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select qualified name reference receiver
- */
-public void test13() {
-
- String str =
- "public class X { \n" +
- " int foo(){ \n" +
- " java.lang.System.out.println(); \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "java.lang.";
- String selectionEndBehind = "java.lang.System";
-
- String expectedCompletionNodeToString = "<SelectOnName:java.lang.System>";
- String completionIdentifier = "System";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <SelectOnName:java.lang.System>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.lang.System.out";
- String testName = "<select qualified name receiver>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select qualified name reference
- */
-public void test14() {
-
- String str =
- "public class X { \n" +
- " int foo(){ \n" +
- " System sys = java.lang.System; \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "java.lang.";
- String selectionEndBehind = "java.lang.System";
-
- String expectedCompletionNodeToString = "<SelectOnName:java.lang.System>";
- String completionIdentifier = "System";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " System sys;\n" +
- " <SelectOnName:java.lang.System>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "java.lang.System";
- String testName = "<select qualified name>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select variable type with modifier
- */
-public void test15() {
-
- String str =
- "public class X { \n" +
- " int foo(){ \n" +
- " final System sys = null; \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "final ";
- String selectionEndBehind = "final System";
-
- String expectedCompletionNodeToString = "<SelectOnType:System>";
- String completionIdentifier = "System";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " final <SelectOnType:System> sys;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "System";
- String testName = "<select variable type with modifier>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select variable type
- */
-public void test16() {
-
- String str =
- "public class X { \n" +
- " int foo(){ \n" +
- " System sys = null; \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "\n ";
- String selectionEndBehind = "\n System";
-
- String expectedCompletionNodeToString = "<SelectOnType:System>";
- String completionIdentifier = "System";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <SelectOnType:System> sys;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "System";
- String testName = "<select variable type>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select name
- */
-public void test17() {
-
- String str =
- "public class X { \n" +
- " int foo(){ \n" +
- " System \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "\n ";
- String selectionEndBehind = "\n System";
-
- String expectedCompletionNodeToString = "<SelectOnName:System>";
- String completionIdentifier = "System";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <SelectOnName:System>;\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "System";
- String testName = "<select name>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select anonymous type
- */
-public void test18() {
-
- String str =
- "public class X { \n" +
- " int foo(){ \n" +
- " new Object(){ \n" +
- " int bar(){} \n" +
- " } \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "new ";
- String selectionEndBehind = "new Object";
-
- String expectedCompletionNodeToString =
- "<SelectOnAllocationExpression:new Object() {\n}>";
- String completionIdentifier = "Object";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " <SelectOnAllocationExpression:new Object() {\n" +
- " }>;\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "new Object()";
- String testName = "<select anonymous type>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select cast type
- */
-public void test19() {
-
- String str =
- "public class X { \n" +
- " Object foo(){ \n" +
- " return (Object) this; \n" +
- " } \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "return (";
- String selectionEndBehind = "return (Object";
-
- String expectedCompletionNodeToString = "<SelectOnName:Object>";
- String completionIdentifier = "Object";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " Object foo() {\n" +
- " <SelectOnName:Object>;\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "Object";
- String testName = "<select cast type>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select package
- */
-public void test20() {
-
- String str =
- "package x.y.other; \n" +
- "public class X { \n" +
- " int foo(){ \n" +
- " } \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "x.";
- String selectionEndBehind = "x.y";
-
- String expectedCompletionNodeToString = "<SelectOnPackage:x.y>";
- String completionIdentifier = "y";
- String expectedUnitDisplayString =
- "package <SelectOnPackage:x.y>;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "x.y.other";
- String testName = "<select package>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkDietParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select import
- */
-public void test21() {
-
- String str =
- "import x.y.Other; \n" +
- "public class X { \n" +
- " int foo(){ \n" +
- " } \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "y.";
- String selectionEndBehind = "y.Other";
-
- String expectedCompletionNodeToString = "<SelectOnImport:x.y.Other>";
- String completionIdentifier = "Other";
- String expectedUnitDisplayString =
- "import <SelectOnImport:x.y.Other>;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "x.y.Other";
- String testName = "<select import>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkDietParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select import on demand
- */
-public void test22() {
-
- String str =
- "import x.y.other.*; \n" +
- "public class X { \n" +
- " int foo(){ \n" +
- " } \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "y.";
- String selectionEndBehind = "y.other";
-
- String expectedCompletionNodeToString = "<SelectOnImport:x.y.other>";
- String completionIdentifier = "other";
- String expectedUnitDisplayString =
- "import <SelectOnImport:x.y.other>;\n" +
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "x.y.other";
- String testName = "<select import on demand>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkDietParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select array initializer type
- */
-public void test23() {
-
- String str =
- "public class X { \n" +
- " int foo(){ \n" +
- " String[] p = new String[]{\"Left\"};\n" +
-// " } \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "new ";
- String selectionEndBehind = "new String";
- String expectedCompletionNodeToString = "<SelectOnType:String>";
- String completionIdentifier = "String";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " int foo() {\n" +
- " String[] p;\n" +
- " <SelectOnType:String>;\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "String";
- String testName = "<select array initializer type>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select nested type superclass with syntax error behind
- */
-public void test24() {
-
- String str =
- "public class G { \n" +
- " void foo() { \n" +
- " class X { \n" +
- " class Y extends G { \n" +
- " int foo() \n" +
- " } \n" +
- " } \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "extends ";
- String selectionEndBehind = "extends G";
-
- String expectedCompletionNodeToString = "<SelectOnType:G>";
-
- String completionIdentifier = "G";
- String expectedUnitDisplayString =
- "public class G {\n" +
- " public G() {\n" +
- " }\n" +
- " void foo() {\n" +
- " class X {\n" +
- " class Y extends <SelectOnType:G> {\n" +
- " Y() {\n" +
- " }\n" +
- " int foo() {\n" +
- " }\n" +
- " }\n" +
- " X() {\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "G";
- String testName = "<select nested type superclass>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select super
- */
-public void test25() {
-
- String str =
- "public class G { \n" +
- " Object foo() { \n" +
- " return super.foo(); \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "return ";
- String selectionEndBehind = "return super";
-
- String expectedCompletionNodeToString = "<SelectOnSuper:super>";
-
- String completionIdentifier = "super";
- String expectedUnitDisplayString =
- "public class G {\n" +
- " public G() {\n" +
- " }\n" +
- " Object foo() {\n" +
- " <SelectOnSuper:super>;\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "super";
- String testName = "<select super>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select qualified super
- */
-public void test26() {
-
- String str =
- "public class G { \n" +
- " Object foo() { \n" +
- " new X(){ \n" +
- " Object bar(){ \n" +
- " return G.super.foo(); \n" +
- " } \n" +
- " } \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "G.";
- String selectionEndBehind = "G.super";
-
- String expectedCompletionNodeToString = "<SelectOnQualifiedSuper:G.super>";
-
- String completionIdentifier = "super";
- String expectedUnitDisplayString =
- "public class G {\n" +
- " public G() {\n" +
- " }\n" +
- " Object foo() {\n" +
- " new X() {\n" +
- " () {\n" +
- " }\n" +
- " Object bar() {\n" +
- " <SelectOnQualifiedSuper:G.super>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "G.super";
- String testName = "<select qualified super>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select super constructor call
- */
-public void test27() {
-
- String str =
- "public class G { \n" +
- " G() { \n" +
- " super(); \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "\n\t\t";
- String selectionEndBehind = "super";
-
- String expectedCompletionNodeToString = "<SelectOnExplicitConstructorCall:super()>";
-
- String completionIdentifier = "super";
- String expectedUnitDisplayString =
- "public class G {\n" +
- " G() {\n" +
- " <SelectOnExplicitConstructorCall:super()>;\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "super()";
- String testName = "<select super constructor call>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select qualified super constructor call
- */
-public void test28() {
-
- String str =
- "public class G { \n" +
- " class M {} \n" +
- " static Object foo() { \n" +
- " class X extends M { \n" +
- " X (){ \n" +
- " new G().super(); \n" +
- " } \n" +
- " } \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "new G().";
- String selectionEndBehind = "new G().super";
-
- String expectedCompletionNodeToString = "<SelectOnExplicitConstructorCall:new G().super()>";
-
- String completionIdentifier = "super";
- String expectedUnitDisplayString =
- "public class G {\n" +
- " class M {\n" +
- " M() {\n" +
- " }\n" +
- " }\n" +
- " public G() {\n" +
- " }\n" +
- " static Object foo() {\n" +
- " class X extends M {\n" +
- " X() {\n" +
- " <SelectOnExplicitConstructorCall:new G().super()>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "new G().super()";
- String testName = "<select qualified super constructor call>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select qualified super constructor call with arguments
- */
-public void test29() {
-
- String str =
- "public class G { \n" +
- " class M {} \n" +
- " static Object foo() { \n" +
- " class X extends M { \n" +
- " X (){ \n" +
- " new G().super(23 + \"hello\"); \n" +
- " } \n" +
- " } \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "new G().";
- String selectionEndBehind = "new G().super";
-
- String expectedCompletionNodeToString = "<SelectOnExplicitConstructorCall:new G().super((23 + \"hello\"))>";
-
- String completionIdentifier = "super";
- String expectedUnitDisplayString =
- "public class G {\n" +
- " class M {\n" +
- " M() {\n" +
- " }\n" +
- " }\n" +
- " public G() {\n" +
- " }\n" +
- " static Object foo() {\n" +
- " class X extends M {\n" +
- " X() {\n" +
- " <SelectOnExplicitConstructorCall:new G().super((23 + \"hello\"))>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "new G().super(23 + \"hello\")";
- String testName = "<select qualified super constructor call with arguments>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select super constructor call with arguments
- */
-public void test30() {
-
- String str =
- "public class G { \n" +
- " G() { \n" +
- " super(new G()); \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "\n\t\t";
- String selectionEndBehind = "super";
-
- String expectedCompletionNodeToString = "<SelectOnExplicitConstructorCall:super(new G())>";
-
- String completionIdentifier = "super";
- String expectedUnitDisplayString =
- "public class G {\n" +
- " G() {\n" +
- " <SelectOnExplicitConstructorCall:super(new G())>;\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "super(new G())";
- String testName = "<select super constructor call with arguments>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Regression test for 1FVQ0LK
- */
-public void test31() {
-
- String str =
- "class X { \n" +
- " Y f; \n" +
- " void foo() { \n" +
- " new Bar(fred()); \n" +
- " Z z= new Z(); \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "\n\t";
- String selectionEndBehind = "Y";
-
- String expectedCompletionNodeToString = "<SelectOnType:Y>";
-
- String completionIdentifier = "Y";
- String expectedUnitDisplayString =
- "class X {\n" +
- " <SelectOnType:Y> f;\n" +
- " X() {\n" +
- " }\n" +
- " void foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "Y";
- String testName = "<regression test for 1FVQ0LK>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkDietParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Regression test for 1FWT4AJ: ITPCOM:WIN98 - SelectionParser produces duplicate type declaration
- */
-public void test32() {
-
- String str =
- "package search; \n"+
- "import java.io.*; \n"+
- "public class PhraseQuery { \n"+
- " public boolean containsPhrase(){ \n"+
- " try { \n"+
- " char currentChar = \"hello\".toLowerCase() \n"+
- " } \n"+
- "} \n";
-
- String selectionStartBehind = "\"hello\".";
- String selectionEndBehind = "\"hello\".toLowerCase";
-
- String expectedCompletionNodeToString = "<SelectOnMessageSend:\"hello\".toLowerCase()>";
-
- String completionIdentifier = "toLowerCase";
- String expectedUnitDisplayString =
- "package search;\n" +
- "import java.io.*;\n" +
- "public class PhraseQuery {\n" +
- " public PhraseQuery() {\n" +
- " }\n" +
- " public boolean containsPhrase() {\n" +
- " {\n" +
- " char currentChar;\n" +
- " <SelectOnMessageSend:\"hello\".toLowerCase()>;\n" +
- " }\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "\"hello\".toLowerCase()";
- String testName = "<1FWT4AJ: ITPCOM:WIN98 - SelectionParser produces duplicate type declaration>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Regression test for 1G4CLZM: ITPJUI:WINNT - 'Import Selection' - Set not found
- */
-public void test33() {
-
- String str =
- " import java.util.AbstractMap; \n"+
- " public class c4 extends AbstractMap { \n"+
- " /** \n"+
- " * @see AbstractMap#entrySet \n"+
- " */ \n"+
- " public Set entrySet() { \n"+
- " return null; \n"+
- " } \n"+
- " } \n";
-
- String selectionStartBehind = "\n\t\tpublic ";
- String selectionEndBehind = "public Set";
-
- String expectedCompletionNodeToString = "<SelectOnType:Set>";
-
- String completionIdentifier = "Set";
- String expectedUnitDisplayString =
- "import java.util.AbstractMap;\n" +
- "public class c4 extends AbstractMap {\n" +
- " public c4() {\n" +
- " }\n" +
- " public <SelectOnType:Set> entrySet() {\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "Set";
- String testName = "<1G4CLZM: ITPJUI:WINNT - 'Import Selection' - Set not found>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkDietParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Regression test for 1GB99S3: ITPJUI:WINNT - SH: NPE in editor while getting hover help
- */
-public void test34() {
-
- String str =
- "public class X { \n"+
- " public int foo() { \n"+
- " Object[] array = new Object[0]; \n"+
- " return array.length; \n"+
- " } \n"+
- "} \n";
-
- String selectionStartBehind = "\n\t\treturn ";
- String selectionEndBehind = "array.length";
-
- String expectedCompletionNodeToString = NONE;
-
- String completionIdentifier = NONE;
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " public int foo() {\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = NONE;
- String testName = "<1GB99S3: ITPJUI:WINNT - SH: NPE in editor while getting hover help>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-
-/*
- * Select this constructor call
- */
-public void test35() {
-
- String str =
- "public class G { \n" +
- " G() { \n" +
- " } \n" +
- " G(int x) { \n" +
- " this(); \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "\n\t\t";
- String selectionEndBehind = "this";
-
- String expectedCompletionNodeToString = "<SelectOnExplicitConstructorCall:this()>";
-
- String completionIdentifier = "this";
- String expectedUnitDisplayString =
- "public class G {\n" +
- " G() {\n" +
- " }\n" +
- " G(int x) {\n" +
- " <SelectOnExplicitConstructorCall:this()>;\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "this()";
- String testName = "<select this constructor call>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-
-/*
- * Select qualified this constructor call
- */
-public void test36() {
-
- String str =
- "public class G { \n" +
- " static Object foo() { \n" +
- " class X { \n" +
- " X (){ \n" +
- " } \n" +
- " X (int x){ \n" +
- " new G().this(); \n" +
- " } \n" +
- " } \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "new G().";
- String selectionEndBehind = "new G().this";
-
- String expectedCompletionNodeToString = "<SelectOnExplicitConstructorCall:new G().this()>";
-
- String completionIdentifier = "this";
- String expectedUnitDisplayString =
- "public class G {\n" +
- " public G() {\n" +
- " }\n" +
- " static Object foo() {\n" +
- " class X {\n" +
- " X() {\n" +
- " super();\n"+
- " }\n" +
- " X(int x) {\n" +
- " <SelectOnExplicitConstructorCall:new G().this()>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "new G().this()";
- String testName = "<select qualified this constructor call>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select qualified this constructor call with arguments
- */
-public void test37() {
-
- String str =
- "public class G { \n" +
- " static Object foo() { \n" +
- " class X { \n" +
- " X (){ \n" +
- " } \n" +
- " X (int x){ \n" +
- " new G().this(23 + \"hello\"); \n" +
- " } \n" +
- " } \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "new G().";
- String selectionEndBehind = "new G().this";
-
- String expectedCompletionNodeToString = "<SelectOnExplicitConstructorCall:new G().this((23 + \"hello\"))>";
-
- String completionIdentifier = "this";
- String expectedUnitDisplayString =
- "public class G {\n" +
- " public G() {\n" +
- " }\n" +
- " static Object foo() {\n" +
- " class X {\n" +
- " X() {\n" +
- " super();\n"+
- " }\n" +
- " X(int x) {\n" +
- " <SelectOnExplicitConstructorCall:new G().this((23 + \"hello\"))>;\n" +
- " }\n" +
- " };\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "new G().this(23 + \"hello\")";
- String testName = "<select qualified this constructor call with arguments>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * Select this constructor call with arguments
- */
-public void test38() {
-
- String str =
- "public class G { \n" +
- " G() { \n" +
- " this(new G()); \n" +
- " } \n" +
- "} \n";
-
- String selectionStartBehind = "\n\t\t";
- String selectionEndBehind = "this";
-
- String expectedCompletionNodeToString = "<SelectOnExplicitConstructorCall:this(new G())>";
-
- String completionIdentifier = "this";
- String expectedUnitDisplayString =
- "public class G {\n" +
- " G() {\n" +
- " <SelectOnExplicitConstructorCall:this(new G())>;\n" +
- " }\n" +
- "}\n";
-
- String expectedReplacedSource = "this(new G())";
- String testName = "<select this constructor call with arguments>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * bugs 3293 search does not work in inner class (1GEUQHJ)
- */
-public void test39() {
-
- String str =
- "public class X { \n" +
- " Object hello = new Object(){ \n" +
- " public void foo(String s){ \n" +
- " s.length(); \n" +
- " } \n" +
- " }; \n" +
- "} \n";
-
- String selectionStartBehind = "s.";
- String selectionEndBehind = "length";
-
- String expectedCompletionNodeToString = "<SelectOnMessageSend:s.length()>";
-
- String completionIdentifier = "length";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " Object hello = new Object() {\n" +
- " public void foo(String s) {\n" +
- " <SelectOnMessageSend:s.length()>;\n" +
- " }\n" +
- " };\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "s.length()";
- String testName = "<select message send in anonymous class>";
-
- int selectionStart = str.indexOf(selectionStartBehind) + selectionStartBehind.length();
- int selectionEnd = str.indexOf(selectionEndBehind) + selectionEndBehind.length() - 1;
-
- this.checkDietParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-
-/*
- * bugs 3229 OpenOnSelection - strange behaviour of code resolve (1GAVL08)
- */
-public void test40() {
-
- String str =
- "public class X { \n" +
- " Object \n" +
- "} \n";
-
- String selection = "Object";
-
- String expectedCompletionNodeToString = "<SelectOnType:Object>";
-
- String completionIdentifier = "Object";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " <SelectOnType:Object>;\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "Object";
- String testName = "<select fake field>";
-
- int selectionStart = str.indexOf(selection);
- int selectionEnd = str.indexOf(selection) + selection.length() - 1;
-
- this.checkDietParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * bugs 11475 selection on local name.
- */
-public void test41() {
-
- String str =
- "public class X { \n" +
- " public void foo(){ \n" +
- " Object var; \n" +
- " } \n" +
- "} \n";
-
- String selection = "var";
-
- String expectedCompletionNodeToString = "<SelectionOnLocalName:Object var>";
-
- String completionIdentifier = "var";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " public void foo() {\n" +
- " <SelectionOnLocalName:Object var>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "var";
- String testName = "<select local name>";
-
- int selectionStart = str.indexOf(selection);
- int selectionEnd = str.indexOf(selection) + selection.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * bugs 11475 selection on argument name.
- */
-public void test42() {
-
- String str =
- "public class X { \n" +
- " public void foo(Object var){ \n" +
- " } \n" +
- "} \n";
-
- String selection = "var";
-
- String expectedCompletionNodeToString = "<SelectionOnArgumentName:Object var>";
-
- String completionIdentifier = "var";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " public void foo(<SelectionOnArgumentName:Object var>) {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "var";
- String testName = "<select argument name>";
-
- int selectionStart = str.indexOf(selection);
- int selectionEnd = str.indexOf(selection) + selection.length() - 1;
-
- this.checkDietParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * bugs 11475 selection on argument name inside catch statement.
- */
-public void test43() {
-
- String str =
- "public class X { \n" +
- " public void foo(){ \n" +
- " try{ \n" +
- " }catch(Object var){}\n" +
- " } \n" +
- "} \n";
-
- String selection = "var";
-
- String expectedCompletionNodeToString = "<SelectionOnArgumentName:Object var>";
-
- String completionIdentifier = "var";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " public X() {\n" +
- " }\n" +
- " public void foo() {\n" +
- " <SelectionOnArgumentName:Object var>;\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "var";
- String testName = "<select argument name inside catch statement>";
-
- int selectionStart = str.indexOf(selection);
- int selectionEnd = str.indexOf(selection) + selection.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * bugs 15430
- */
-public void test44() {
-
- String str =
- "public class X { \n" +
- " String x = super.foo() \n" +
- "} \n";
-
- String selection = "super";
-
- String expectedCompletionNodeToString = "<SelectOnSuper:super>";
-
- String completionIdentifier = "super";
- String expectedUnitDisplayString =
- "public class X {\n" +
- " String x = <SelectOnSuper:super>;\n" +
- " public X() {\n" +
- " }\n" +
- "}\n";
- String expectedReplacedSource = "super";
- String testName = "<select super in field initializer>";
-
- int selectionStart = str.indexOf(selection);
- int selectionEnd = str.indexOf(selection) + selection.length() - 1;
-
- this.checkDietParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * bugs 14468
- */
-public void test45() {
-
- String str =
- "public class X { \n" +
- " void foo() {\n" +
- " if(x instanceof Object){\n" +
- " }\n" +
- " } \n" +
- "} \n";
-
- String selection = "Object";
-
- String expectedCompletionNodeToString = "<SelectOnType:Object>";
-
- String completionIdentifier = "Object";
- String expectedUnitDisplayString =
- "public class X {\n"+
- " public X() {\n"+
- " }\n"+
- " void foo() {\n"+
- " <SelectOnType:Object>;\n"+
- " }\n"+
- "}\n";
- String expectedReplacedSource = "Object";
- String testName = "<select inside instanceof statement>";
-
- int selectionStart = str.indexOf(selection);
- int selectionEnd = str.indexOf(selection) + selection.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-
-/*
- * bugs 14468
- */
-public void test46() {
-
- String str =
- "public class X { \n" +
- " void foo() {\n" +
- " y = x instanceof Object;\n" +
- " } \n" +
- "} \n";
-
- String selection = "Object";
-
- String expectedCompletionNodeToString = "<SelectOnType:Object>";
-
- String completionIdentifier = "Object";
- String expectedUnitDisplayString =
- "public class X {\n"+
- " public X() {\n"+
- " }\n"+
- " void foo() {\n"+
- " <SelectOnType:Object>;\n"+
- " }\n"+
- "}\n";
- String expectedReplacedSource = "Object";
- String testName = "<select inside instanceof statement>";
-
- int selectionStart = str.indexOf(selection);
- int selectionEnd = str.indexOf(selection) + selection.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * bugs 14468
- */
-public void test47() {
-
- String str =
- "public class X { \n" +
- " void foo() {\n" +
- " boolean y = x instanceof Object;\n" +
- " } \n" +
- "} \n";
-
- String selection = "Object";
-
- String expectedCompletionNodeToString = "<SelectOnType:Object>";
-
- String completionIdentifier = "Object";
- String expectedUnitDisplayString =
- "public class X {\n"+
- " public X() {\n"+
- " }\n"+
- " void foo() {\n"+
- " boolean y;\n"+
- " <SelectOnType:Object>;\n"+
- " }\n"+
- "}\n";
- String expectedReplacedSource = "Object";
- String testName = "<select inside instanceof statement>";
-
- int selectionStart = str.indexOf(selection);
- int selectionEnd = str.indexOf(selection) + selection.length() - 1;
-
- this.checkMethodParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-/*
- * bugs 14468
- */
-public void test48() {
-
- String str =
- "public class X { \n" +
- " boolean y = x instanceof Object;\n" +
- "} \n";
-
- String selection = "Object";
-
- String expectedCompletionNodeToString = "<SelectOnType:Object>";
-
- String completionIdentifier = "Object";
- String expectedUnitDisplayString =
- "public class X {\n"+
- " boolean y = <SelectOnType:Object>;\n"+
- " public X() {\n"+
- " }\n"+
- "}\n";
- String expectedReplacedSource = "Object";
- String testName = "<select inside instanceof statement>";
-
- int selectionStart = str.indexOf(selection);
- int selectionEnd = str.indexOf(selection) + selection.length() - 1;
-
- this.checkDietParse(
- str.toCharArray(),
- selectionStart,
- selectionEnd,
- expectedCompletionNodeToString,
- expectedUnitDisplayString,
- completionIdentifier,
- expectedReplacedSource,
- testName);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SingleCompletionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SingleCompletionTest.java
deleted file mode 100644
index 72e0141..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SingleCompletionTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-import java.lang.reflect.InvocationTargetException;
-
-import junit.framework.TestCase;
-
-/**
- * Only 1 test should be in this class
- */
-public class SingleCompletionTest extends AbstractCompletionTest {
-/**
- * SingleCompletionTest constructor comment.
- * @param testName java.lang.String
- */
-public SingleCompletionTest(String testName) {
- super(testName);
-}
-private void run(Class testClass, String methodName) {
- try {
- java.lang.reflect.Constructor constructor = testClass.getDeclaredConstructor(new Class[] {String.class});
- TestCase test = (TestCase)constructor.newInstance(new Object[] {"single completion test"});
- java.lang.reflect.Method method = testClass.getDeclaredMethod(methodName, new Class[] {});
- method.invoke(test, new Object[] {});
- } catch (InstantiationException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- Throwable target = e.getTargetException();
- if (target instanceof RuntimeException) {
- throw (RuntimeException)target;
- }
- if (target instanceof Error) {
- throw (Error)target;
- }
- throw new Error(target.getMessage());
- }
-}
-/*
- * The test.
- */
-public void test() {
- run(NameReferenceCompletionTest.class, "testMethodInvocationAnonymousInnerClass2");
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java
deleted file mode 100644
index ba9b0ef..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceField.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceField.java
deleted file mode 100644
index be98d9d..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceField.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-import org.eclipse.jdt.internal.compiler.env.IConstants;
-import org.eclipse.jdt.internal.compiler.env.ISourceField;
-
-public class SourceField implements ISourceField, IConstants {
- protected int modifiers;
- protected char[] typeName;
- protected char[] name;
- protected int declarationStart;
- protected int declarationEnd;
- protected int nameSourceStart;
- protected int nameSourceEnd;
- protected char[] source;
-public SourceField(
- int declarationStart,
- int modifiers,
- char[] typeName,
- char[] name,
- int nameSourceStart,
- int nameSourceEnd,
- char[] source) {
-
- this.declarationStart = declarationStart;
- this.modifiers = modifiers;
- this.typeName = typeName;
- this.name = name;
- this.nameSourceStart = nameSourceStart;
- this.nameSourceEnd = nameSourceEnd;
- this.source = source;
-}
-public String displayModifiers(int modifiers) {
- StringBuffer buffer = new StringBuffer();
-
- if (modifiers == 0)
- return null;
- if ((modifiers & AccPublic) != 0)
- buffer.append("public ");
- if ((modifiers & AccProtected) != 0)
- buffer.append("protected ");
- if ((modifiers & AccPrivate) != 0)
- buffer.append("private ");
- if ((modifiers & AccFinal) != 0)
- buffer.append("final ");
- if ((modifiers & AccStatic) != 0)
- buffer.append("static ");
- if ((modifiers & AccAbstract) != 0)
- buffer.append("abstract ");
- if ((modifiers & AccNative) != 0)
- buffer.append("native ");
- if ((modifiers & AccSynchronized) != 0)
- buffer.append("synchronized ");
- return buffer.toString();
-}
-public String getActualName() {
- StringBuffer buffer = new StringBuffer();
- buffer.append(source, nameSourceStart, nameSourceEnd - nameSourceStart + 1);
- return buffer.toString();
-}
-public int getDeclarationSourceEnd() {
- return declarationEnd;
-}
-public int getDeclarationSourceStart() {
- return declarationStart;
-}
-public int getModifiers() {
- return modifiers;
-}
-public char[] getName() {
- return name;
-}
-public int getNameSourceEnd() {
- return nameSourceEnd;
-}
-public int getNameSourceStart() {
- return nameSourceStart;
-}
-public char[] getTypeName() {
- return typeName;
-}
-protected void setDeclarationSourceEnd(int position) {
- declarationEnd = position;
-}
-public String tabString(int tab) {
- /*slow code*/
-
- String s = "";
- for (int i = tab; i > 0; i--)
- s = s + "\t";
- return s;
-}
-public String toString() {
- return toString(0);
-}
-public String toString(int tab) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(tabString(tab));
- if (displayModifiers(modifiers) != null) {
- buffer.append(displayModifiers(modifiers));
- }
- buffer.append(typeName).append(" ").append(name);
- buffer.append(";");
- return buffer.toString();
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceImport.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceImport.java
deleted file mode 100644
index 9abd3e3..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceImport.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-public class SourceImport {
- int declarationSourceStart;
- int declarationSourceEnd;
- char[] name;
- boolean onDemand;
- char[] source;
-/**
- * @param declarationSourceStart int
- * @param declarationSourceEnd int
- * @param name char[]
- * @param onDemand boolean
- */
-public SourceImport(
- int declarationSourceStart,
- int declarationSourceEnd,
- char[] name,
- boolean onDemand,
- char[] source) {
-
- this.declarationSourceStart = declarationSourceStart;
- this.declarationSourceEnd = declarationSourceEnd;
- this.name = name;
- this.onDemand = onDemand;
- this.source = source;
-}
-/**
- *
- * @return java.lang.String
- */
-public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer
- .append(
- source,
- declarationSourceStart,
- declarationSourceEnd - declarationSourceStart + 1)
- .append("\n");
- return buffer.toString();
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceInitializer.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceInitializer.java
deleted file mode 100644
index 067e399..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceInitializer.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-public class SourceInitializer extends SourceField {
-public SourceInitializer(
- int declarationStart,
- int modifiers) {
- super(declarationStart, modifiers, null, null, -1, -1, null);
-}
-
-public void setDeclarationSourceEnd(int declarationSourceEnd) {
- this.declarationEnd = declarationSourceEnd;
-}
-
-public String toString(int tab) {
- if (modifiers == AccStatic) {
- return tabString(tab) + "static {}";
- }
- return tabString(tab) + "{}";
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceMethod.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceMethod.java
deleted file mode 100644
index bf97052..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceMethod.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-import org.eclipse.jdt.internal.compiler.env.IConstants;
-import org.eclipse.jdt.internal.compiler.env.ISourceMethod;
-
-public class SourceMethod implements ISourceMethod, IConstants {
- private int modifiers;
- private int declarationStart;
- private int declarationEnd;
- private char[] returnTypeName;
- private char[] selector;
- private int nameSourceStart;
- private int nameSourceEnd;
- private char[][] argumentTypeNames;
- private char[][] argumentNames;
- private char[][] exceptionTypeNames;
- private char[] source;
- private String explicitConstructorCall;
-public SourceMethod(
- int declarationStart,
- int modifiers,
- char[] returnTypeName,
- char[] selector,
- int nameSourceStart,
- int nameSourceEnd,
- char[][] argumentTypeNames,
- char[][] argumentNames,
- char[][] exceptionTypeNames,
- char[] source) {
-
- this.declarationStart = declarationStart;
- this.modifiers = modifiers;
- this.returnTypeName = returnTypeName;
- this.selector = selector;
- this.nameSourceStart = nameSourceStart;
- this.nameSourceEnd = nameSourceEnd;
- this.argumentTypeNames = argumentTypeNames;
- this.argumentNames = argumentNames;
- this.exceptionTypeNames = exceptionTypeNames;
- this.source = source;
-}
-public String displayModifiers(int modifiers) {
- StringBuffer buffer = new StringBuffer();
-
- if (modifiers == 0)
- return null;
- if ((modifiers & AccPublic) != 0)
- buffer.append("public ");
- if ((modifiers & AccProtected) != 0)
- buffer.append("protected ");
- if ((modifiers & AccPrivate) != 0)
- buffer.append("private ");
- if ((modifiers & AccFinal) != 0)
- buffer.append("final ");
- if ((modifiers & AccStatic) != 0)
- buffer.append("static ");
- if ((modifiers & AccAbstract) != 0)
- buffer.append("abstract ");
- if ((modifiers & AccNative) != 0)
- buffer.append("native ");
- if ((modifiers & AccSynchronized) != 0)
- buffer.append("synchronized ");
- if (buffer.toString().trim().equals(""))
- return null;
- return buffer.toString().trim();
-}
-public String getActualName() {
- StringBuffer buffer = new StringBuffer();
- buffer.append(source, nameSourceStart, nameSourceEnd - nameSourceStart + 1);
- return buffer.toString();
-}
-public char[][] getArgumentNames() {
- return argumentNames;
-}
-public char[][] getArgumentTypeNames() {
- return argumentTypeNames;
-}
-public int getDeclarationSourceEnd() {
- return declarationEnd;
-}
-public int getDeclarationSourceStart() {
- return declarationStart;
-}
-public char[][] getExceptionTypeNames() {
- return exceptionTypeNames;
-}
-public int getModifiers() {
- return modifiers;
-}
-public int getNameSourceEnd() {
- return nameSourceEnd;
-}
-public int getNameSourceStart() {
- return nameSourceStart;
-}
-public char[] getReturnTypeName() {
- return returnTypeName;
-}
-public char[] getSelector() {
- return selector;
-}
-public boolean isConstructor() {
- return returnTypeName == null;
-}
-protected void setDeclarationSourceEnd(int position) {
- declarationEnd = position;
-}
-protected void setExplicitConstructorCall(String s) {
- explicitConstructorCall = s;
-}
-public String tabString(int tab) {
- /*slow code*/
-
- String s = "";
- for (int i = tab; i > 0; i--)
- s = s + "\t";
- return s;
-}
-public String toString() {
- return toString(0);
-}
-public String toString(int tab) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(tabString(tab));
- if (displayModifiers(modifiers) != null) {
- buffer.append(displayModifiers(modifiers)).append(" ");
- }
- if (returnTypeName != null) {
- buffer.append(returnTypeName).append(" ");
- }
- buffer.append(selector).append("(");
- if (argumentTypeNames != null) {
- for (int i = 0, max = argumentTypeNames.length; i < max; i++) {
- buffer.append(argumentTypeNames[i]).append(" ").append(
- argumentNames[i]).append(
- ", ");
- }
- }
- buffer.append(") ");
- if (exceptionTypeNames != null) {
- buffer.append("throws ");
- for (int i = 0, max = exceptionTypeNames.length; i < max; i++) {
- buffer.append(exceptionTypeNames[i]).append(", ");
- }
- }
- if (explicitConstructorCall != null) {
- buffer.append("{\n").append(tabString(tab+1)).append(explicitConstructorCall).append(tabString(tab)).append("}");
- } else {
- buffer.append("{}");
- }
- return buffer.toString();
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourcePackage.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourcePackage.java
deleted file mode 100644
index 02bde48..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourcePackage.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-public class SourcePackage {
- int declarationSourceStart;
- int declarationSourceEnd;
- char[] name;
- char[] source;
-/**
- * @param declarationSourceStart int
- * @param declarationSourceEnd int
- * @param name char[]
- * @param onDemand boolean
- */
-public SourcePackage(
- int declarationSourceStart,
- int declarationSourceEnd,
- char[] name,
- char[] source) {
-
- this.declarationSourceStart = declarationSourceStart;
- this.declarationSourceEnd = declarationSourceEnd;
- this.name = name;
- this.source = source;
-}
-/**
- *
- * @return java.lang.String
- */
-public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer
- .append(
- source,
- declarationSourceStart,
- declarationSourceEnd - declarationSourceStart + 1)
- .append("\n");
- return buffer.toString();
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceType.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceType.java
deleted file mode 100644
index 963d670..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceType.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-import org.eclipse.jdt.internal.compiler.env.IConstants;
-import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
-
-public final class SourceType implements CompilerModifiers, IConstants {
- private int modifiers;
- private int declarationStart;
- private int declarationEnd;
- private char[] fileName;
- private SourcePackage packageName;
- private SourceImport[] imports;
- private int numberOfImports;
- private char[] enclosingTypeName;
- private char[] name;
- private int nameSourceStart;
- private int nameSourceEnd;
- private char[] superclassName;
- private char[][] interfaceNames;
- private SourceType[] memberTypes;
- private int numberOfMemberTypes;
- private SourceMethod[] methods;
- private int numberOfMethods;
- private SourceField[] fields;
- private int numberOfFields;
- private char[] source;
- SourceType parent;
-
- // Buffering.
- private char[] qualifiedName;
- private String defaultConstructor;
-public SourceType(
- char[] enclosingTypeName,
- int declarationStart,
- int modifiers,
- char[] name,
- int nameSourceStart,
- int nameSourceEnd,
- char[] superclassName,
- char[][] interfaceNames,
- char[] source) {
-
- this.enclosingTypeName = enclosingTypeName;
- this.declarationStart = declarationStart;
- this.declarationEnd = declarationEnd;
- this.modifiers = modifiers;
- this.name = name;
- this.nameSourceStart = nameSourceStart;
- this.nameSourceEnd = nameSourceEnd;
- this.superclassName = superclassName;
- this.interfaceNames = interfaceNames;
- this.source = source;
-}
-protected void addField(SourceField sourceField) {
- if (fields == null) {
- fields = new SourceField[4];
- }
-
- if (numberOfFields == fields.length) {
- System.arraycopy(
- fields,
- 0,
- fields = new SourceField[numberOfFields * 2],
- 0,
- numberOfFields);
- }
- fields[numberOfFields++] = sourceField;
-}
-protected void addMemberType(SourceType sourceMemberType) {
- if(memberTypes == null) {
- memberTypes = new SourceType[4];
- }
-
- if(numberOfMemberTypes == memberTypes.length) {
- System.arraycopy(memberTypes, 0, memberTypes = new SourceType[numberOfMemberTypes * 2], 0, numberOfMemberTypes);
- }
- memberTypes[numberOfMemberTypes++] = sourceMemberType;
-}
-protected void addMethod(SourceMethod sourceMethod) {
- if (methods == null) {
- methods = new SourceMethod[4];
- }
-
- if (numberOfMethods == methods.length) {
- System.arraycopy(
- methods,
- 0,
- methods = new SourceMethod[numberOfMethods * 2],
- 0,
- numberOfMethods);
- }
- methods[numberOfMethods++] = sourceMethod;
-}
-public String displayModifiers(int modifiers) {
- StringBuffer buffer = new StringBuffer();
-
- if (modifiers == 0)
- return null;
- if ((modifiers & AccPublic) != 0)
- buffer.append("public ");
- if ((modifiers & AccProtected) != 0)
- buffer.append("protected ");
- if ((modifiers & AccPrivate) != 0)
- buffer.append("private ");
- if ((modifiers & AccFinal) != 0)
- buffer.append("final ");
- if ((modifiers & AccStatic) != 0)
- buffer.append("static ");
- if ((modifiers & AccAbstract) != 0)
- buffer.append("abstract ");
- if ((modifiers & AccNative) != 0)
- buffer.append("native ");
- if ((modifiers & AccSynchronized) != 0)
- buffer.append("synchronized ");
- return buffer.toString().trim();
-}
-public String getActualName() {
- StringBuffer buffer = new StringBuffer();
- buffer.append(source, nameSourceStart, nameSourceEnd - nameSourceStart + 1);
- return buffer.toString();
-}
-public int getDeclarationSourceEnd() {
- return declarationEnd;
-}
-public int getDeclarationSourceStart() {
- return declarationStart;
-}
-public char[] getEnclosingTypeName() {
- return enclosingTypeName;
-}
-public SourceField[] getFields() {
- if (fields != null && fields.length != numberOfFields) {
- System.arraycopy(fields, 0, fields = new SourceField[numberOfFields], 0, numberOfFields);
- }
- return fields;
-}
-public char[] getFileName() {
- return fileName;
-}
-public char[][] getImports() {
- if (imports == null) return null;
- int importLength = imports.length;
- char[][] importNames = new char[importLength][];
- for (int i = 0, max = importLength; i < max; i++) {
- importNames[i] = imports[i].name;
- }
- return importNames;
-}
-public char[][] getInterfaceNames() {
- return interfaceNames;
-}
-public SourceType[] getMemberTypes() {
- if (memberTypes != null && memberTypes.length != numberOfMemberTypes) {
- System.arraycopy(
- memberTypes,
- 0,
- memberTypes = new SourceType[numberOfMemberTypes],
- 0,
- numberOfMemberTypes);
- }
- return memberTypes;
-}
-public SourceMethod[] getMethods() {
- if (methods != null && methods.length != numberOfMethods) {
- System.arraycopy(methods, 0, methods = new SourceMethod[numberOfMethods], 0, numberOfMethods);
- }
- return methods;
-}
-public int getModifiers() {
- return modifiers;
-}
-public char[] getName() {
- return name;
-}
-public int getNameSourceEnd() {
- return nameSourceEnd;
-}
-public int getNameSourceStart() {
- return nameSourceStart;
-}
-public char[] getPackageName() {
- return packageName.name;
-}
-public char[] getQualifiedName() {
- if (qualifiedName == null) {
- StringBuffer temp = new StringBuffer();
- temp.append(packageName);
- temp.append('.');
- temp.append(name);
- qualifiedName = temp.toString().toCharArray();
- }
- return qualifiedName;
-}
-public char[] getSuperclassName() {
- return superclassName;
-}
-public boolean isBinaryType() {
- return false;
-}
-public boolean isClass() {
- return (modifiers & AccInterface) == 0;
-}
-public boolean isInterface() {
- return (modifiers & AccInterface) == AccInterface;
-}
-public void setDeclarationSourceEnd(int position) {
- declarationEnd = position;
-}
-public void setDefaultConstructor(String s) {
- this.defaultConstructor = s;
-}
-public void setImports(SourceImport[] imports) {
- this.imports = imports;
-}
-public void setPackage(SourcePackage sourcePackage) {
- packageName = sourcePackage;
-}
-public void setSuperclass(char[] superclassName) {
- this.superclassName = superclassName;
-}
-public void setSuperinterfaces(char[][] superinterfacesNames) {
- this.interfaceNames = superinterfacesNames;
-}
-public String tabString(int tab) {
- /*slow code*/
-
- String s = "";
- for (int i = tab; i > 0; i--)
- s = s + "\t";
- return s;
-}
-public String toString() {
- return toString(0);
-}
-public String toString(int tab) {
-
- StringBuffer buffer = new StringBuffer();
- if (packageName != null) {
- buffer.append(tabString(tab)).append(packageName);
- }
- if (imports != null) {
- for (int i = 0, max = imports.length; i < max; i++) {
- buffer.append(tabString(tab)).append(imports[i]);
- }
- }
- buffer.append(tabString(tab));
- if (displayModifiers(modifiers) != null) {
- buffer.append(displayModifiers(modifiers)).append(" ");
- }
- buffer.append(isInterface() ? "interface " : "class ").append(name).append(" ");
- if (superclassName != null) {
- buffer.append("extends ").append(superclassName).append(" ");
- }
- if (interfaceNames != null) {
- buffer.append("implements ");
- for (int i = 0, max = interfaceNames.length; i < max; i++) {
- buffer.append(interfaceNames[i]).append(", ");
- }
- }
- buffer.append("{\n");
- if (memberTypes != null) {
- for (int i = 0, max = numberOfMemberTypes; i < max; i++) {
- buffer.append(memberTypes[i].toString(tab + 1)).append("\n");
- }
- }
- if (fields != null) {
- for (int i = 0, max = numberOfFields; i < max; i++) {
- buffer.append(fields[i].toString(tab + 1)).append("\n");
- }
- }
- if (defaultConstructor != null) {
- buffer.append(tabString(tab + 1)).append(defaultConstructor);
- }
- if (methods != null) {
- for (int i = 0, max = numberOfMethods; i < max; i++) {
- buffer.append(methods[i].toString(tab + 1)).append("\n");
- }
- }
- buffer.append(tabString(tab)).append("}");
- return buffer.toString();
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
deleted file mode 100644
index f071be5..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SyntaxErrorTest.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-import java.util.Locale;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.internal.compiler.CompilationResult;
-import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
-import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.compiler.parser.Parser;
-import org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
-import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
-import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-
-public class SyntaxErrorTest extends TestCase {
- public static boolean optimizeStringLiterals = false;
- public static boolean assertMode = false;
-
- public SyntaxErrorTest(String testName){
- super(testName);
-}
-public void checkParse(
- char[] source,
- String expectedSyntaxErrorDiagnosis,
- String testName) {
-
- /* using regular parser in DIET mode */
- Parser parser =
- new Parser(
- new ProblemReporter(
- DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- new CompilerOptions(),
- new DefaultProblemFactory(Locale.getDefault())),
- optimizeStringLiterals,
- assertMode);
- ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null);
- CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
-
- parser.parse(sourceUnit, compilationResult);
-
- StringBuffer buffer = new StringBuffer(100);
- if (compilationResult.hasProblems()) {
- IProblem[] problems = compilationResult.getProblems();
- int count = problems.length;
- int problemCount = 0;
- for (int i = 0; i < count; i++) {
- if (problems[i] != null) {
- if (problemCount == 0)
- buffer.append("----------\n");
- problemCount++;
- buffer.append(problemCount + (problems[i].isError() ? ". ERROR" : ". WARNING"));
- buffer.append(" in " + new String(problems[i].getOriginatingFileName()));
- try {
- buffer.append(((DefaultProblem)problems[i]).errorReportSource(compilationResult.compilationUnit));
- buffer.append("\n");
- buffer.append(problems[i].getMessage());
- buffer.append("\n");
- } catch (Exception e) {
- }
- buffer.append("----------\n");
- }
- };
- }
- String computedSyntaxErrorDiagnosis = buffer.toString();
- //System.out.println(Util.displayString(computedSyntaxErrorDiagnosis));
- assertEquals(
- "Invalid syntax error diagnosis" + testName,
- expectedSyntaxErrorDiagnosis,
- computedSyntaxErrorDiagnosis);
-}
-/*
- * Should diagnose parenthesis mismatch
- */
-public void test01() {
-
- String s =
- "public class X { \n"+
- " public void solve(){ \n"+
- " \n"+
- " X[] results = new X[10]; \n"+
- " for(int i = 0; i < 10; i++){ \n"+
- " X result = results[i]; \n"+
- " boolean found = false; \n"+
- " for(int j = 0; j < 10; j++){ \n"+
- " if (this.equals(result.documentName){ \n"+
- " found = true; \n"+
- " break; \n"+
- " } \n"+
- " } \n"+
- " } \n"+
- " return andResult; \n"+
- " } \n"+
- "} \n";
-
- String expectedSyntaxErrorDiagnosis =
- "----------\n" +
- "1. ERROR in <parenthesis mismatch> (at line 9)\n" +
- " if (this.equals(result.documentName){ \n" +
- " ^\n" +
- "Unmatched bracket\n" +
- "----------\n" +
- "2. ERROR in <parenthesis mismatch> (at line 9)\n" +
- " if (this.equals(result.documentName){ \n" +
- " ^\n" +
- "Syntax error on token \"{\", \")\" expected\n" +
- "----------\n";
-
- String testName = "<parenthesis mismatch>";
- checkParse(
- s.toCharArray(),
- expectedSyntaxErrorDiagnosis,
- testName);
-}
-/*
- * Should diagnose brace mismatch
- */
-public void test02() {
-
- String s =
- "class Bar { \n"+
- " Bar() { \n"+
- " this(fred().x{);\n"+
- " } \n"+
- "} \n";
-
- String expectedSyntaxErrorDiagnosis =
- "----------\n" +
- "1. ERROR in <brace mismatch> (at line 3)\n" +
- " this(fred().x{);\n" +
- " ^\n" +
- "Unmatched bracket\n" +
- "----------\n" +
- "2. ERROR in <brace mismatch> (at line 3)\n" +
- " this(fred().x{);\n" +
- " ^\n" +
- "Syntax error on token \"{\", \")\" expected\n" +
- "----------\n";
-
- String testName = "<brace mismatch>";
- checkParse(
- s.toCharArray(),
- expectedSyntaxErrorDiagnosis,
- testName);
-}
-/*
- * Should diagnose parenthesis mismatch
- */
-public void test03() {
-
- String s =
- "public class X { // should complain \n"+
- " int foo( \n"+
- " [ arg1, \n"+
- " { arg2, ] \n"+
- " arg3, \n"+
- " ){ \n"+
- " } \n"+
- "} \n";
-
- String expectedSyntaxErrorDiagnosis =
- "----------\n" +
- "1. ERROR in <parenthesis mismatch> (at line 2)\n" +
- " int foo( \n" +
- " ^\n" +
- "Unmatched bracket\n" +
- "----------\n" +
- "2. ERROR in <parenthesis mismatch> (at line 3)\n" +
- " [ arg1, \n" +
- " ^\n" +
- "Syntax error on token \"[\", \"float\", \"double\", \"byte\", \"short\", \"int\", \"long\", \"char\", \"boolean\", \"void\", \"Identifier\" expected\n" +
- "----------\n";
-
- String testName = "<parenthesis mismatch>";
- checkParse(
- s.toCharArray(),
- expectedSyntaxErrorDiagnosis,
- testName);
-}
-/*
- * Should not diagnose parenthesis mismatch
- */
-public void test04() {
-
- String s =
- "public class X { // should not complain \n"+
- " int foo( \n"+
- " { arg1, \n"+
- " { arg2, } \n"+
- " arg3, } \n"+
- " ){ \n"+
- " } \n"+
- "} \n";
-
- String expectedSyntaxErrorDiagnosis =
- "----------\n" +
- "1. ERROR in <no parenthesis mismatch> (at line 3)\n" +
- " { arg1, \n" +
- " ^\n" +
- "Syntax error on token \"{\", \"float\", \"double\", \"byte\", \"short\", \"int\", \"long\", \"char\", \"boolean\", \"void\", \"Identifier\" expected\n" +
- "----------\n";
-
- String testName = "<no parenthesis mismatch>";
- checkParse(
- s.toCharArray(),
- expectedSyntaxErrorDiagnosis,
- testName);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
deleted file mode 100644
index 428feff..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestAll.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.jdt.core.tests.junit.extension.ExcludedTestSuite;
-
-/**
- * Run all parser regression tests
- */
-public class TestAll extends TestCase {
- public static boolean EXPERT; // an expert doesn't exclude any tests
- public static String[] EXCLUDED_TESTS = new String[] {
- "CompletionParserTest", "testVB_2", // completion on field access on anonymous inner class with syntax error
- "CompletionParserTest", "testVB_4", // completion on field access on anonymous inner class with syntax error
- "CompletionParserTest", "testVB_5", // completion on field access on anonymous inner class with syntax error
- "LabelStatementCompletionTest", "testInLabeledInnerClassWithErrorBefore", // cannot get labels in recovery mode yet
- };
-/**
- * TestAll constructor comment.
- * @param testName java.lang.String
- */
-public TestAll(String testName) {
- super(testName);
-}
-/**
- * Adds all the tests in the given class to the suite except
- * the ones that are excluded.
- */
-public static void addTest(TestSuite suite, Class testClass) {
- TestSuite innerSuite = new TestSuite(testClass);
- suite.addTest(innerSuite);
-}
-public static Test suite() {
- TestSuite suite = new TestSuite(TestAll.class.getName());
-
- /* completion tests */
- addTest(suite, AllocationExpressionCompletionTest.class);
- addTest(suite, ClassLiteralAccessCompletionTest.class);
- addTest(suite, CompletionParserTest.class);
- addTest(suite, CompletionRecoveryTest.class);
- addTest(suite, DietCompletionTest.class);
- addTest(suite, ExplicitConstructorInvocationCompletionTest.class);
- addTest(suite, FieldAccessCompletionTest.class);
- addTest(suite, InnerTypeCompletionTest.class);
- addTest(suite, LabelStatementCompletionTest.class);
- addTest(suite, MethodInvocationCompletionTest.class);
- addTest(suite, NameReferenceCompletionTest.class);
- addTest(suite, ReferenceTypeCompletionTest.class);
-
- /* selection tests */
- addTest(suite, ExplicitConstructorInvocationSelectionTest.class);
- addTest(suite, SelectionTest.class);
-
- /* recovery tests */
- addTest(suite, DietRecoveryTest.class);
-
- /* source element parser tests */
- addTest(suite, SourceElementParserTest.class);
-
- /* syntax error diagnosis tests */
- addTest(suite, SyntaxErrorTest.class);
-
- if (EXPERT) {
- return suite;
- } else {
- return new ExcludedTestSuite(suite, EXCLUDED_TESTS);
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java
deleted file mode 100644
index 562a7fb..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.parser;
-
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.internal.compiler.ISourceElementRequestor;
-
-public class TestSourceElementRequestor implements ISourceElementRequestor {
-/**
- * DummySourceElementRequestor constructor comment.
- */
-public TestSourceElementRequestor() {
- super();
-}
-/**
- * acceptConstructorReference method comment.
- */
-public void acceptConstructorReference(char[] typeName, int argCount, int sourcePosition) {}
-/**
- * acceptFieldReference method comment.
- */
-public void acceptFieldReference(char[] fieldName, int sourcePosition) {}
-/**
- * acceptImport method comment.
- */
-public void acceptImport(int declarationStart, int declarationEnd, char[] name, boolean onDemand) {}
-/**
- * acceptInitializer method comment.
- */
-public void acceptInitializer(int modifiers, int declarationSourceStart, int declarationSourceEnd) {}
-/**
- * acceptLineSeparatorPositions method comment.
- */
-public void acceptLineSeparatorPositions(int[] positions) {}
-/**
- * acceptMethodReference method comment.
- */
-public void acceptMethodReference(char[] methodName, int argCount, int sourcePosition) {}
-/**
- * acceptPackage method comment.
- */
-public void acceptPackage(int declarationStart, int declarationEnd, char[] name) {}
-/**
- * acceptProblem method comment.
- */
-public void acceptProblem(IProblem problem) {}
-/**
- * acceptTypeReference method comment.
- */
-public void acceptTypeReference(char[][] typeName, int sourceStart, int sourceEnd) {}
-/**
- * acceptTypeReference method comment.
- */
-public void acceptTypeReference(char[] typeName, int sourcePosition) {}
-/**
- * acceptUnknownReference method comment.
- */
-public void acceptUnknownReference(char[][] name, int sourceStart, int sourceEnd) {}
-/**
- * acceptUnknownReference method comment.
- */
-public void acceptUnknownReference(char[] name, int sourcePosition) {}
-/**
- * enterClass method comment.
- */
-public void enterClass(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[] superclass, char[][] superinterfaces) {}
-/**
- * enterCompilationUnit method comment.
- */
-public void enterCompilationUnit() {}
-/**
- * enterConstructor method comment.
- */
-public void enterConstructor(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[][] parameterTypes, char[][] parameterNames, char[][] exceptionTypes) {}
-/**
- * enterField method comment.
- */
-public void enterField(int declarationStart, int modifiers, char[] type, char[] name, int nameSourceStart, int nameSourceEnd) {}
-/**
- * enterInterface method comment.
- */
-public void enterInterface(int declarationStart, int modifiers, char[] name, int nameSourceStart, int nameSourceEnd, char[][] superinterfaces) {}
-/**
- * enterMethod method comment.
- */
-public void enterMethod(int declarationStart, int modifiers, char[] returnType, char[] name, int nameSourceStart, int nameSourceEnd, char[][] parameterTypes, char[][] parameterNames, char[][] exceptionTypes) {}
-/**
- * exitClass method comment.
- */
-public void exitClass(int declarationEnd) {}
-/**
- * exitCompilationUnit method comment.
- */
-public void exitCompilationUnit(int declarationEnd) {}
-/**
- * exitConstructor method comment.
- */
-public void exitConstructor(int declarationEnd) {}
-/**
- * exitField method comment.
- */
-public void exitField(int declarationEnd) {}
-/**
- * exitInterface method comment.
- */
-public void exitInterface(int declarationEnd) {}
-/**
- * exitMethod method comment.
- */
-public void exitMethod(int declarationEnd) {}
-
-/**
- * enterInitializer method comment.
- */
-public void enterInitializer(int sourceStart, int sourceEnd) {
-}
-
-/**
- * exitInitializer method comment.
- */
-public void exitInitializer(int sourceEnd) {
-}
-
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
deleted file mode 100644
index 7e88b67..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-
-import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.core.tests.junit.extension.StopableTestCase;
-import org.eclipse.jdt.core.tests.util.*;
-import org.eclipse.jdt.internal.compiler.*;
-import org.eclipse.jdt.internal.compiler.batch.*;
-import org.eclipse.jdt.internal.compiler.Compiler;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
-
-import java.io.*;
-import java.util.*;
-import junit.framework.*;
-
-public abstract class AbstractRegressionTest extends StopableTestCase {
- public static String OUTPUT_DIR = Util.getOutputDirectory() + File.separator + "regression";
- public static String JAVA_CLASS_LIB_PATH = Util.getJavaClassLib();
-
- protected INameEnvironment javaClassLib;
- protected String[] classpaths;
- protected TestVerifier verifier;
- protected boolean createdVerifier;
-public AbstractRegressionTest(String name) {
- super(name);
-}
-protected CompilationUnit[] compilationUnits(String[] testFiles) {
- int length = (int)(testFiles.length / 2);
- CompilationUnit[] result = new CompilationUnit[length];
- int index = 0;
- for (int i = 0; i < length; i++) {
- result[i] = new CompilationUnit(testFiles[index + 1].toCharArray(), testFiles[index], null);
- index += 2;
- }
- return result;
-}
-protected INameEnvironment[] getClassLibs(String[] classpaths) {
- String encoding = (String) getCompilerOptions().get(CompilerOptions.OPTION_Encoding);
- if ("".equals(encoding)) encoding = null;
-
- int length = classpaths.length;
- INameEnvironment[] classLibs = new INameEnvironment[length];
- for (int i = 0; i < length; i++) {
- String classpath = classpaths[i];
- if (classpath.equals(JAVA_CLASS_LIB_PATH)) {
- if (this.javaClassLib == null) {
- this.javaClassLib =
- new FileSystem(
- new String[] {classpath},
- new String[] {}, // ignore initial file names
- encoding // default encoding
- );
- }
- classLibs[i] = this.javaClassLib;
- } else {
- classLibs[i] =
- new FileSystem(
- new String[] {classpath},
- new String[] {}, // ignore initial file names
- encoding // default encoding
- );
- }
- }
- return classLibs;
-}
-protected Map getCompilerOptions() {
- Hashtable options = new Hashtable();
- options.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
- options.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
- options.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE);
- options.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.PRESERVE);
- options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_1);
- options.put(CompilerOptions.OPTION_ReportUnreachableCode, CompilerOptions.ERROR);
- options.put(CompilerOptions.OPTION_ReportInvalidImport, CompilerOptions.ERROR);
- options.put(CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_ReportMethodWithConstructorName, CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_ReportHiddenCatchBlock, CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE);
- options.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.IGNORE);
- options.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, CompilerOptions.IGNORE);
- options.put(CompilerOptions.OPTION_ReportAssertIdentifier, CompilerOptions.IGNORE);
- options.put(CompilerOptions.OPTION_ReportStaticAccessReceiver, CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3);
- options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_3);
- options.put(CompilerOptions.OPTION_Encoding, "");
- return options;
-}
-protected String[] getDefaultClassPaths() {
- return new String[] {JAVA_CLASS_LIB_PATH, OUTPUT_DIR};
-}
-protected IErrorHandlingPolicy getErrorHandlingPolicy() {
- return new IErrorHandlingPolicy() {
- public boolean stopOnFirstError() {
- return false;
- }
- public boolean proceedOnErrors() {
- return true;
- }
- };
-}
-/*
- * Will consider first the source units passed as arguments, then
- * investigate the classpath: jdklib + output dir
- */
-protected INameEnvironment getNameEnvironment(final String[] testFiles, String[] classPaths) {
- this.classpaths =
- classPaths == null ?
- this.getDefaultClassPaths() :
- classPaths;
- return
- new InMemoryNameEnvironment(
- testFiles,
- this.getClassLibs(this.classpaths)
- );
-}
-protected IProblemFactory getProblemFactory() {
- return new DefaultProblemFactory(Locale.getDefault());
-}
-protected Requestor getRequestor(IProblemFactory problemFactory) {
- return new Requestor(problemFactory, OUTPUT_DIR.endsWith(File.separator) ? OUTPUT_DIR : OUTPUT_DIR + File.separator, false);
-}
-
-protected Requestor getRequestor(IProblemFactory problemFactory, boolean generateOutPut) {
- return new Requestor(problemFactory, OUTPUT_DIR.endsWith(File.separator) ? OUTPUT_DIR : OUTPUT_DIR + File.separator, true);
-}
-
-protected void runConformTest(String[] testFiles) {
- this.runConformTest(testFiles, null, null, true, null);
-}
-
-protected void runConformTest(String[] testFiles, String[] vmArguments) {
- this.runConformTest(testFiles, null, null, true, vmArguments);
-}
-protected void runConformTest(String[] testFiles, String expectedSuccessOutputString, String[] vmArguments) {
- this.runConformTest(testFiles, expectedSuccessOutputString, null, true, vmArguments);
-}
-
-protected void runConformTest(String[] testFiles, String expectedSuccessOutputString) {
- this.runConformTest(testFiles, expectedSuccessOutputString, null, true, null);
-}
-protected void runConformTest(String[] testFiles, String expectedSuccessOutputString, String[] classLib, boolean shouldFlushOutputDirectory, String[] vmArguments) {
- this.runConformTest( testFiles, expectedSuccessOutputString, classLib, shouldFlushOutputDirectory, vmArguments, null);
-}
-
-protected void runConformTest(String[] testFiles, String expectedSuccessOutputString, String[] classLib, boolean shouldFlushOutputDirectory, String[] vmArguments, Map customOptions) {
-
- if (shouldFlushOutputDirectory) Util.flushDirectoryContent(new File(OUTPUT_DIR));
-
- IProblemFactory problemFactory = getProblemFactory();
- LogRequestor requestor = new LogRequestor(problemFactory, OUTPUT_DIR.endsWith(File.separator) ? OUTPUT_DIR : OUTPUT_DIR + File.separator);
-
- Map options = getCompilerOptions();
- if (customOptions != null){
- options.putAll(customOptions);
- }
- Compiler batchCompiler =
- new Compiler(
- getNameEnvironment(new String[] {}, classLib),
- getErrorHandlingPolicy(),
- options,
- requestor,
- problemFactory);
- batchCompiler.compile(compilationUnits(testFiles)); // compile all files together
- if (!requestor.hasErrors) {
- String sourceFile = testFiles[0];
-
- // Compute class name by removing ".java" and replacing slashes with dots
- String className = sourceFile.substring(0, sourceFile.length() - 5).replace('/', '.').replace('\\', '.');
-
- if (vmArguments != null) {
- if (this.verifier != null) {
- this.verifier.shutDown();
- }
- this.verifier = new TestVerifier(false);
- this.createdVerifier = true;
- }
- boolean passed = this.verifier.verifyClassFiles(sourceFile, className, expectedSuccessOutputString, this.classpaths, null, vmArguments);
- assertTrue(
- this.verifier.failureReason, // computed by verifyClassFiles(...) action
- passed
- );
- if (vmArguments != null) {
- if (this.verifier != null) {
- this.verifier.shutDown();
- }
- this.verifier = new TestVerifier(false);
- this.createdVerifier = true;
- }
- } else {
- assertTrue("Unexpected problems: " + requestor.problemLog, false);
- }
-}
-
-protected void runConformTestThrowingError(String[] testFiles, String expectedSuccessOutputString, String[] classLib, boolean shouldFlushOutputDirectory, String[] vmArguments) {
-
- if (shouldFlushOutputDirectory) Util.flushDirectoryContent(new File(OUTPUT_DIR));
-
- IProblemFactory problemFactory = getProblemFactory();
- LogRequestor requestor = new LogRequestor(problemFactory, OUTPUT_DIR.endsWith(File.separator) ? OUTPUT_DIR : OUTPUT_DIR + File.separator);
- Compiler batchCompiler =
- new Compiler(
- getNameEnvironment(new String[] {}, classLib),
- getErrorHandlingPolicy(),
- getCompilerOptions(),
- requestor,
- problemFactory);
- batchCompiler.compile(compilationUnits(testFiles)); // compile all files together
- if (!requestor.hasErrors) {
- String sourceFile = testFiles[0];
-
- // Compute class name by removing ".java" and replacing slashes with dots
- String className = sourceFile.substring(0, sourceFile.length() - 5).replace('/', '.').replace('\\', '.');
-
- boolean passed = this.verifier.verifyClassFilesThrowingError(sourceFile, className, expectedSuccessOutputString, this.classpaths, null, vmArguments);
- assertTrue(
- this.verifier.failureReason, // computed by verifyClassFiles(...) action
- passed
- );
- } else {
- assertTrue("Unexpected problems: " + requestor.problemLog, false);
- }
-}
-
-protected void runNegativeTest(String[] testFiles, ExpectedProblem[] expectedProblems) {
- this.runNegativeTest(testFiles, expectedProblems, null, true);
-}
-protected void runNegativeTest(String[] testFiles, ExpectedProblem[] expectedProblems, String[] classLib, boolean shouldFlushOutputDirectory) {
-
- if (shouldFlushOutputDirectory) Util.flushDirectoryContent(new File(OUTPUT_DIR));
-
- IProblemFactory problemFactory = getProblemFactory();
- Requestor requestor = getRequestor(problemFactory);
- requestor.expectedProblems(expectedProblems);
- Compiler batchCompiler =
- new Compiler(
- getNameEnvironment(new String[] {}, classLib),
- getErrorHandlingPolicy(),
- getCompilerOptions(),
- requestor,
- problemFactory);
- batchCompiler.compile(compilationUnits(testFiles)); // compile all files together
- if (!requestor.hasErrors) {
- String sourceFile = testFiles[0];
-
- // Compute class name by removing ".java" and replacing slashes with dots
- String className = sourceFile.substring(0, sourceFile.length() - 5).replace('/', '.').replace('\\', '.');
-
- assertTrue(
- this.verifier.failureReason,
- this.verifier.verifyClassFiles(sourceFile, className, null, this.classpaths)
- );
- }
-}
-protected void runNegativeTest(String[] testFiles, ExpectedProblem[] expectedProblems, String[] classLib, boolean shouldFlushOutputDirectory, boolean generateOutput) {
-
-
- if (shouldFlushOutputDirectory) Util.flushDirectoryContent(new File(OUTPUT_DIR));
-
-
- IProblemFactory problemFactory = getProblemFactory();
- Requestor requestor = getRequestor(problemFactory, generateOutput);
- requestor.expectedProblems(expectedProblems);
- Compiler batchCompiler =
- new Compiler(
- getNameEnvironment(new String[] {}, classLib),
- getErrorHandlingPolicy(),
- getCompilerOptions(),
- requestor,
- problemFactory);
- batchCompiler.compile(compilationUnits(testFiles)); // compile all files together
- if (!requestor.hasErrors) {
- String sourceFile = testFiles[0];
-
- // Compute class name by removing ".java" and replacing slashes with dots
- String className = sourceFile.substring(0, sourceFile.length() - 5).replace('/', '.').replace('\\', '.');
-
- assertTrue(
- this.verifier.failureReason,
- this.verifier.verifyClassFiles(sourceFile, className, null, this.classpaths)
- );
- }
-}
-
-/**
- * Log contains all problems (warnings+errors)
- */
-protected void runNegativeTest(String[] testFiles, String expectedProblemLog) {
- this.runNegativeTest(testFiles, expectedProblemLog, null, true);
-}
-
-/**
- * Log contains all problems (warnings+errors)
- */
-protected void runNegativeTest(String[] testFiles, String expectedProblemLog, String[] classLib, boolean shouldFlushOutputDirectory) {
- this.runNegativeTest(testFiles, expectedProblemLog, classLib, shouldFlushOutputDirectory, null);
-}
-/**
- * Log contains all problems (warnings+errors)
- */
-protected void runNegativeTest(String[] testFiles, String expectedProblemLog, String[] classLib, boolean shouldFlushOutputDirectory, Map customOptions) {
-
- if (shouldFlushOutputDirectory) Util.flushDirectoryContent(new File(OUTPUT_DIR));
-
- IProblemFactory problemFactory = getProblemFactory();
- LogRequestor requestor = new LogRequestor(problemFactory, OUTPUT_DIR.endsWith(File.separator) ? OUTPUT_DIR : OUTPUT_DIR + File.separator);
- Map options = getCompilerOptions();
- if (customOptions != null){
- options.putAll(customOptions);
- }
- Compiler batchCompiler =
- new Compiler(
- getNameEnvironment(new String[] {}, classLib),
- getErrorHandlingPolicy(),
- options,
- requestor,
- problemFactory);
- batchCompiler.compile(compilationUnits(testFiles)); // compile all files together
-
- String computedProblemLog = requestor.problemLog.toString();
- if (!expectedProblemLog.equals(computedProblemLog)){
- System.out.println(Util.displayString(computedProblemLog, 2));
- }
- assertEquals(
- "Invalid problem log ",
- expectedProblemLog,
- computedProblemLog);
-}
-protected void setUp() throws Exception {
- if (this.verifier == null) {
- this.verifier = new TestVerifier(true);
- this.createdVerifier = true;
- }
-}
-public static Test setupSuite(Class clazz) {
- return new RegressionTestSetup(suite(clazz));
-}
-public void stop() {
- this.verifier.shutDown();
-}
-public static Test suite(Class evaluationTestClass) {
- TestSuite suite = new TestSuite(evaluationTestClass);
- return suite;
-}
-protected void tearDown() throws Exception {
- if (this.createdVerifier) {
- this.stop();
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java
deleted file mode 100644
index d5ece79..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssertionTest.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-import java.util.Map;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.core.tests.compiler.regression.*;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-
-public class AssertionTest extends AbstractRegressionTest {
-
- /*
- * Toggle compiler in mode -1.4
- */
- protected Map getCompilerOptions() {
- Map options = super.getCompilerOptions();
- options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4);
- options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4);
- return options;
- }
-
- public AssertionTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return setupSuite(testClass());
- }
-
- public static Class testClass() {
- return AssertionTest.class;
- }
-
- public void testAssertAsAnIdentifier() {
- this.runNegativeTest(
- new String[] {
- "assert.java",
- "public class assert {}\n",
- },
- "----------\n" +
- "1. ERROR in assert.java (at line 1)\n" +
- " public class assert {}\n" +
- " ^^^^^^\n" +
- "Syntax error on token \"assert\", \"Identifier\" expected\n" +
- "----------\n");
- }
-
- public void testAssertionEnabled() {
- this.runConformTest(new String[] {
- "A4.java",
- "public class A4 { \n"
- + " public static void main(String[] args) {\n"
- + " try { \n"
- + " int i = 4;\n"
- + " assert i != 4;\n"
- + " System.out.println(i);\n"
- + " } catch(AssertionError e){ \n"
- + " System.out.print(\"SUCCESS\"); \n"
- + " } \n"
- + " } \n"
- + "} \n" },
- "SUCCESS", //expected display
- null, // use default class-path
- true, // flush previous output dir content
- new String[] {"-ea"});
- }
-
- public void testAssertionDisabled() {
- this.runConformTest(new String[] {
- "A4.java",
- "public class A4 { \n"
- + " public static void main(String[] args) {\n"
- + " int i = 4;\n"
- + " assert i != 4;\n"
- + " System.out.println(i);\n"
- + " } \n"
- + "} \n" },
- "4",
- null, // use default class-path
- true, // flush previous output dir content
- new String[] {"-da"});
- }
- public void testAssertionWithObjectArguments() {
- this.runConformTest(new String[] {
- "A4.java",
- "public class A4 { \n"
- + " public static void main(String[] args) {\n"
- + " try { \n"
- + " assert false : \"SUC\"; \n"
- + " } catch(AssertionError e){ \n"
- + " System.out.print(e.getMessage()); \n"
- + " } \n"
- + " try { \n"
- + " assert false : new Object(){ public String toString(){ return \"CESS\";}}; \n"
- + " } catch(AssertionError e){ \n"
- + " System.out.println(e.getMessage()); \n"
- + " } \n"
- + " } \n"
- + "} \n" },
- "SUCCESS", //expected display
- null, // use default class-path
- true, // flush previous output dir content
- new String[] {"-ea"});
- }
- public void testAssertionWithIntArguments() {
- this.runConformTest(new String[] {
- "A4.java",
- "public class A4 { \n"
- + " public static void main(String[] args) {\n"
- + " try { \n"
- + " assert false : 1; \n"
- + " } catch(AssertionError e){ \n"
- + " System.out.print(e.getMessage()); \n"
- + " } \n"
- + " try { \n"
- + " int i = 2; \n"
- + " assert false : i; \n"
- + " } catch(AssertionError e){ \n"
- + " System.out.println(e.getMessage()); \n"
- + " } \n"
- + " } \n"
- + "} \n" },
- "12", //expected display
- null, // use default class-path
- true, // flush previous output dir content
- new String[] {"-ea"});
- }
- public void testAssertionWithUnboundVariable() {
- this.runNegativeTest(new String[] {
- "A4.java",
- "public class A4 { \n"
- + " public static void main(String[] args) {\n"
- + " try { \n"
- + " assert false : unbound; \n"
- + " } catch(AssertionError e){ \n"
- + " System.out.println(e.getMessage()); \n"
- + " } \n"
- + " } \n"
- + "} \n" },
- "----------\n" +
- "1. ERROR in A4.java (at line 4)\n" +
- " assert false : unbound; \n" +
- " ^^^^^^^\n" +
- "unbound cannot be resolved\n" +
- "----------\n");
- }
- public void testAssertionWithLongArguments() {
- this.runConformTest(new String[] {
- "A4.java",
- "public class A4 { \n"
- + " public static void main(String[] args) {\n"
- + " try { \n"
- + " assert false : 1L; \n"
- + " } catch(AssertionError e){ \n"
- + " System.out.print(e.getMessage()); \n"
- + " } \n"
- + " try { \n"
- + " assert false : 0L; \n" // 0L isn't 0
- + " } catch(AssertionError e){ \n"
- + " System.out.print(e.getMessage()); \n"
- + " } \n"
- + " try { \n"
- + " long l = 2L; \n"
- + " assert false : l; \n"
- + " } catch(AssertionError e){ \n"
- + " System.out.println(e.getMessage()); \n"
- + " } \n"
- + " } \n"
- + "} \n" },
- "102", //expected display
- null, // use default class-path
- true, // flush previous output dir content
- new String[] {"-ea"});
- }
- public void testAssertionWithFloatArguments() {
- this.runConformTest(new String[] {
- "A4.java",
- "public class A4 { \n"
- + " public static void main(String[] args) {\n"
- + " try { \n"
- + " assert false : 1.0f; \n"
- + " } catch(AssertionError e){ \n"
- + " System.out.print(e.getMessage()); \n"
- + " } \n"
- + " try { \n"
- + " float f = 2.0f; \n"
- + " assert false : f; \n"
- + " } catch(AssertionError e){ \n"
- + " System.out.println(e.getMessage()); \n"
- + " } \n"
- + " } \n"
- + "} \n" },
- "1.02.0", //expected display
- null, // use default class-path
- true, // do not flush previous output dir content
- new String[] {"-ea"});
- }
- public void testAssertionWithDoubleArguments() {
- this.runConformTest(new String[] {
- "A4.java",
- "public class A4 { \n"
- + " public static void main(String[] args) {\n"
- + " try { \n"
- + " assert false : 1.0; \n"
- + " } catch(AssertionError e){ \n"
- + " System.out.print(e.getMessage()); \n"
- + " } \n"
- + " try { \n"
- + " double d = 2.0; \n"
- + " assert false : d; \n"
- + " } catch(AssertionError e){ \n"
- + " System.out.println(e.getMessage()); \n"
- + " } \n"
- + " } \n"
- + "} \n" },
- "1.02.0", //expected display
- null, // use default class-path
- true, // flush previous output dir content
- new String[] {"-ea"});
- }
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=22334
- public void testAssertionInInterfaceStaticMember() {
- this.runConformTest(new String[] {
- "X.java",
- "public class X { \n" +
- " public static void main(String[] args) { \n" +
- " I.Inner inner = new I.Inner(); \n" +
- " try { \n" +
- " inner.test(); \n" +
- " System.out.println(\"FAILED\"); \n" +
- " } catch(AssertionError e){ \n" +
- " System.out.println(\"SUCCESS\"); \n" +
- " } \n" +
- " } \n" +
- "} \n" +
- "interface I { \n" +
- " public static class Inner { \n" +
- " public void test() { \n" +
- " assert false; \n" +
- " } \n" +
- " } \n" +
- "} \n" },
- "SUCCESS",
- null, // use default class-path
- true, // flush previous output dir content
- new String[] {"-ea"});
- }
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
deleted file mode 100644
index e630236..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileComparatorTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileComparatorTest.java
deleted file mode 100644
index e90636b..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileComparatorTest.java
+++ /dev/null
@@ -1,487 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-
-import junit.framework.Test;
-import java.io.*;
-import junit.framework.Assert;
-
-import org.eclipse.jdt.core.tests.compiler.regression.*;
-import org.eclipse.jdt.core.tests.util.Util;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
-
-public class ClassFileComparatorTest extends AbstractRegressionTest {
- private static final String SOURCE_DIRECTORY = Util.getOutputDirectory() + File.separator + "source";
- private static final String EVAL_DIRECTORY = Util.getOutputDirectory() + File.separator + "eval";
-
- public ClassFileComparatorTest(String name) {
- super(name);
- }
- public static Test suite() {
- return setupSuite(testClass());
- }
-
- public static Class testClass() {
- return ClassFileComparatorTest.class;
- }
-
- public void removeTempClass(String className) {
- File dir = new File(SOURCE_DIRECTORY);
- String[] fileNames = dir.list();
- if (fileNames != null) {
- for (int i = 0, max = fileNames.length; i < max; i++) {
- if (fileNames[i].indexOf(className) != -1) {
- new File(SOURCE_DIRECTORY + File.separator + fileNames[i]).delete();
- }
- }
- }
-
- dir = new File(EVAL_DIRECTORY);
- fileNames = dir.list();
- if (fileNames != null) {
- for (int i = 0, max = fileNames.length; i < max; i++) {
- if (fileNames[i].indexOf(className) != -1) {
- new File(EVAL_DIRECTORY + File.separator + fileNames[i]).delete();
- }
- }
- }
-
- }
-
- public void compileAndDeploy(String source, String className) {
- File directory = new File(SOURCE_DIRECTORY);
- if (!directory.exists()) {
- if (!directory.mkdirs()) {
- System.out.println("Could not create " + SOURCE_DIRECTORY);
- return;
- }
- }
- String fileName = SOURCE_DIRECTORY + File.separator + className + ".java";
- try {
- BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));
- writer.write(source);
- writer.flush();
- writer.close();
- } catch (IOException e) {
- e.printStackTrace();
- return;
- }
- StringBuffer buffer = new StringBuffer();
- buffer
- .append("\"")
- .append(fileName)
- .append("\" -d \"")
- .append(EVAL_DIRECTORY)
- .append("\" -nowarn -g -classpath \"")
- .append(Util.getJREDirectory() + "/lib/rt.jar;")
- .append(SOURCE_DIRECTORY)
- .append("\"");
- org.eclipse.jdt.internal.compiler.batch.Main.compile(buffer.toString());
- }
-
- public boolean areStructurallyDifferent(String classFile1, String classFile2, boolean orderRequired, boolean excludeSynthetic) {
- try {
- ClassFileReader reader = ClassFileReader.read(EVAL_DIRECTORY + File.separator + classFile1 + ".class");
- int fileLength;
- File file = new File(EVAL_DIRECTORY + File.separator + classFile2 + ".class");
- byte classFileBytes[] = new byte[fileLength = (int) file.length()];
- java.io.FileInputStream stream = new java.io.FileInputStream(file);
- int bytesRead = 0;
- int lastReadSize = 0;
- while ((lastReadSize != -1) && (bytesRead != fileLength)) {
- lastReadSize = stream.read(classFileBytes, bytesRead, fileLength - bytesRead);
- bytesRead += lastReadSize;
- }
- stream.close();
- return reader.hasStructuralChanges(classFileBytes, orderRequired, excludeSynthetic);
- } catch(IOException e) {
- return true;
- } catch(ClassFormatException e) {
- return true;
- }
- }
-
- public void test001() {
- try {
- String sourceA001 =
- "public class A001 {\n" +
- " public int foo() {\n" +
- " return 2;\n" +
- " }\n" +
- " public String toString() {\n" +
- " return \"hello\";\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA001, "A001");
- String sourceA001_2 =
- "public class A001_2 {\n" +
- " public int foo() {\n" +
- " return 2;\n" +
- " }\n" +
- " public String toString() {\n" +
- " return \"hello\";\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA001_2, "A001_2");
- Assert.assertTrue(!areStructurallyDifferent("A001", "A001_2", false, false));
- } finally {
- removeTempClass("A001");
- }
- }
-
- public void test002() {
- try {
- String sourceA002 =
- "public class A002 {\n" +
- " public int foo() {\n" +
- " return 2;\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA002, "A002");
- String sourceA002_2 =
- "public class A002_2 {\n" +
- " public int foo() {\n" +
- " return 2;\n" +
- " }\n" +
- " public String toString() {\n" +
- " return \"hello\";\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA002_2, "A002_2");
- Assert.assertTrue(areStructurallyDifferent("A002", "A002_2", false, false));
- } finally {
- removeTempClass("A002");
- }
- }
-
- public void test003() {
- try {
- String sourceA003 =
- "public class A003 {\n" +
- "public static final int II = 5;\n" +
- "}";
- compileAndDeploy(sourceA003, "A003");
- String sourceA003_2 =
- "public class A003_2 {\n" +
- "public static final int II = 6;\n" +
- "}";
- compileAndDeploy(sourceA003_2, "A003_2");
- Assert.assertTrue(areStructurallyDifferent("A003", "A003_2", false, false));
- } finally {
- removeTempClass("A003");
- }
- }
- public void test004() {
- try {
- String sourceA004 =
- "public class A004 {\n" +
- " public int foo() {\n" +
- " return 2;\n" +
- " }\n" +
- " public String toString() {\n" +
- " return \"hello\";\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA004, "A004");
- String sourceA004_2 =
- "public class A004_2 {\n" +
- " public int foo() {\n" +
- " return 2;\n" +
- " }\n" +
- " public String toString() {\n" +
- " return \"hello\";\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA004_2, "A004_2");
- Assert.assertTrue(!areStructurallyDifferent("A004", "A004_2", true, true));
- } finally {
- removeTempClass("A004");
- }
- }
- public void test005() {
- try {
- String sourceA005 =
- "public class A005 {\n" +
- " public int foo() {\n" +
- " return 2;\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA005, "A005");
- String sourceA005_2 =
- "public class A005_2 {\n" +
- " public int foo() {\n" +
- " return 2;\n" +
- " }\n" +
- " public String toString() {\n" +
- " return \"hello\";\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA005_2, "A005_2");
- Assert.assertTrue(areStructurallyDifferent("A005", "A005_2", true, true));
- } finally {
- removeTempClass("A005");
- }
- }
- public void test006() {
- try {
- String sourceA006 =
- "public class A006 {\n" +
- "public static final int II = 5;\n" +
- "}";
- compileAndDeploy(sourceA006, "A006");
- String sourceA006_2 =
- "public class A006_2 {\n" +
- "public static final int II = 6;\n" +
- "}";
- compileAndDeploy(sourceA006_2, "A006_2");
- Assert.assertTrue(areStructurallyDifferent("A006", "A006_2", true, true));
- } finally {
- removeTempClass("A006");
- }
- }
-
- public void test007() {
- try {
- String sourceA007 =
- "public class A007 {\n" +
- "public static final int II = 6;\n" +
- "public Runnable foo() {\n" +
- "\treturn null;\n"+
- "}\n" +
- "}";
- compileAndDeploy(sourceA007, "A007");
- String sourceA007_2 =
- "public class A007_2 {\n" +
- "public static final int II = 6;\n" +
- "public Runnable foo() {\n" +
- "\treturn new Runnable() {public void run() {}};\n"+
- "}\n" +
- "}";
- compileAndDeploy(sourceA007_2, "A007_2");
- Assert.assertTrue(!areStructurallyDifferent("A007", "A007_2", true, true));
- } finally {
- removeTempClass("A007");
- }
- }
- public void test008() {
- try {
- String sourceA008 =
- "public class A008 {\n" +
- "private int i = 6;\n" +
- "public int foo() {\n" +
- "\treturn i;\n"+
- "}\n" +
- "}";
- compileAndDeploy(sourceA008, "A008");
- String sourceA008_2 =
- "public class A008_2 {\n" +
- "private int i = 6;\n" +
- "public int foo() {\n" +
- "\treturn 2;\n"+
- "}\n" +
- "}";
- compileAndDeploy(sourceA008_2, "A008_2");
- Assert.assertTrue(!areStructurallyDifferent("A008", "A008_2", true, false));
- } finally {
- removeTempClass("A008");
- }
- }
-
- public void test009() {
- try {
- String sourceA009 =
- "public class A009 {\n" +
- "private int i = 6;\n" +
- "public int foo() {\n" +
- "\tclass A {\n" +
- "\t\tint get() {\n" +
- "\t\t\treturn i;\n" +
- "\t\t}\n" +
- "\t}\n" +
- "\treturn new A().get();\n" +
- "}\n" +
- "}";
- compileAndDeploy(sourceA009, "A009");
- String sourceA009_2 =
- "public class A009_2 {\n" +
- "private int i = 6;\n" +
- "public int foo() {\n" +
- "\treturn 2;\n"+
- "}\n" +
- "}";
- compileAndDeploy(sourceA009_2, "A009_2");
- Assert.assertTrue(areStructurallyDifferent("A009", "A009_2", true, false));
- } finally {
- removeTempClass("A009");
- }
- }
- public void test010() {
- try {
- String sourceA010 =
- "public class A010 {\n" +
- "private int i = 6;\n" +
- "public int foo() {\n" +
- "\tclass A {\n" +
- "\t\tint get() {\n" +
- "\t\t\treturn i;\n" +
- "\t\t}\n" +
- "\t}\n" +
- "\treturn new A().get();\n" +
- "}\n" +
- "}";
- compileAndDeploy(sourceA010, "A010");
- String sourceA010_2 =
- "public class A010_2 {\n" +
- "private int i = 6;\n" +
- "public int foo() {\n" +
- "\treturn 2;\n"+
- "}\n" +
- "}";
- compileAndDeploy(sourceA010_2, "A010_2");
- Assert.assertTrue(!areStructurallyDifferent("A010", "A010_2", true, true));
- } finally {
- removeTempClass("A010");
- }
- }
-
- public void test011() {
- try {
- String sourceA011 =
- "public class A011 {\n" +
- "private int i = 6;\n" +
- "public int foo() {\n" +
- "\tclass A {\n" +
- "\t\tint get() {\n" +
- "\t\t\treturn i;\n" +
- "\t\t}\n" +
- "\t}\n" +
- "\treturn new A().get();\n" +
- "}\n" +
- "}";
- compileAndDeploy(sourceA011, "A011");
- String sourceA011_2 =
- "public class A011_2 {\n" +
- "private int i = 6;\n" +
- "public int foo() {\n" +
- "\treturn 2;\n"+
- "}\n" +
- "}";
- compileAndDeploy(sourceA011_2, "A011_2");
- Assert.assertTrue(!areStructurallyDifferent("A011", "A011_2", false, true));
- } finally {
- removeTempClass("A011");
- }
- }
- public void test012() {
- try {
- String sourceA012 =
- "public class A012 {\n" +
- "public Class foo() {\n" +
- "\treturn null;\n" +
- "}\n" +
- "}";
- compileAndDeploy(sourceA012, "A012");
- String sourceA012_2 =
- "public class A012_2 {\n" +
- "public Class foo() {\n" +
- "\treturn A012_2.class;\n" +
- "}\n" +
- "}";
- compileAndDeploy(sourceA012_2, "A012_2");
- Assert.assertTrue(areStructurallyDifferent("A012", "A012_2", false, false));
- } finally {
- removeTempClass("A012");
- }
- }
- public void test013() {
- try {
- String sourceA013 =
- "public class A013 {\n" +
- "public Class foo() {\n" +
- "\treturn null;\n" +
- "}\n" +
- "}";
- compileAndDeploy(sourceA013, "A013");
- String sourceA013_2 =
- "public class A013_2 {\n" +
- "public Class foo() {\n" +
- "\treturn A013_2.class;\n" +
- "}\n" +
- "}";
- compileAndDeploy(sourceA013_2, "A013_2");
- Assert.assertTrue(!areStructurallyDifferent("A013", "A013_2", false, true));
- } finally {
- removeTempClass("A013");
- }
- }
- public void test014() {
- try {
- String sourceA014 =
- "public class A014 {\n" +
- "public Class foo() {\n" +
- "\treturn null;\n" +
- "}\n" +
- "}";
- compileAndDeploy(sourceA014, "A014");
- String sourceA014_2 =
- "public class A014_2 {\n" +
- "public Class foo() {\n" +
- "\treturn A014_2.class;\n" +
- "}\n" +
- "}";
- compileAndDeploy(sourceA014_2, "A014_2");
- Assert.assertTrue(!areStructurallyDifferent("A014", "A014_2", true, true));
- } finally {
- removeTempClass("A014");
- }
- }
-
- public void test015() {
- try {
- String sourceA015 =
- "public class A015 {\n" +
- " public class B {\n" +
- " }\n" +
- " public int foo() {\n" +
- " return 2;\n" +
- " }\n" +
- " public String toString() {\n" +
- " return \"hello\";\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA015, "A015");
- Assert.assertTrue(!areStructurallyDifferent("A015$B", "A015$B", false, false));
- } finally {
- removeTempClass("A015");
- }
- }
-
- public void test016() {
- try {
- String sourceA016 =
- "public class A016 {\n" +
- "public void boo() {\n" +
- "}\n" +
- "}";
- compileAndDeploy(sourceA016, "A016");
- String sourceA016_2 =
- "public class A016_2 {\n" +
- "public void foo() {\n" +
- "}\n" +
- "}";
- compileAndDeploy(sourceA016_2, "A016_2");
- Assert.assertTrue(areStructurallyDifferent("A016", "A016_2", false, false));
- } finally {
- removeTempClass("A016");
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest.java
deleted file mode 100644
index cf451fe..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-
-import junit.framework.Test;
-import java.io.*;
-
-import org.eclipse.jdt.core.tests.compiler.regression.*;
-import org.eclipse.jdt.core.tests.util.Util;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
-import org.eclipse.jdt.internal.compiler.classfmt.MethodInfo;
-import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
-
-public class ClassFileReaderTest extends AbstractRegressionTest {
- private static final String SOURCE_DIRECTORY = Util.getOutputDirectory() + File.separator + "source";
- private static final String EVAL_DIRECTORY = Util.getOutputDirectory() + File.separator + "eval";
-
- public ClassFileReaderTest(String name) {
- super(name);
- }
- public static Test suite() {
- return setupSuite(testClass());
- }
-
- public static Class testClass() {
- return ClassFileReaderTest.class;
- }
-
- public void removeTempClass(String className) {
- File dir = new File(SOURCE_DIRECTORY);
- String[] fileNames = dir.list();
- if (fileNames != null) {
- for (int i = 0, max = fileNames.length; i < max; i++) {
- if (fileNames[i].indexOf(className) != -1) {
- new File(SOURCE_DIRECTORY + File.separator + fileNames[i]).delete();
- }
- }
- }
-
- dir = new File(EVAL_DIRECTORY);
- fileNames = dir.list();
- if (fileNames != null) {
- for (int i = 0, max = fileNames.length; i < max; i++) {
- if (fileNames[i].indexOf(className) != -1) {
- new File(EVAL_DIRECTORY + File.separator + fileNames[i]).delete();
- }
- }
- }
-
- }
-
- public void compileAndDeploy(String source, String className) {
- File directory = new File(SOURCE_DIRECTORY);
- if (!directory.exists()) {
- if (!directory.mkdirs()) {
- System.out.println("Could not create " + SOURCE_DIRECTORY);
- return;
- }
- }
- String fileName = SOURCE_DIRECTORY + File.separator + className + ".java";
- try {
- BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));
- writer.write(source);
- writer.flush();
- writer.close();
- } catch (IOException e) {
- e.printStackTrace();
- return;
- }
- StringBuffer buffer = new StringBuffer();
- buffer
- .append("\"")
- .append(fileName)
- .append("\" -d \"")
- .append(EVAL_DIRECTORY)
- .append("\" -nowarn -g -classpath \"")
- .append(Util.getJREDirectory() + "/lib/rt.jar;")
- .append(SOURCE_DIRECTORY)
- .append("\"");
- org.eclipse.jdt.internal.compiler.batch.Main.compile(buffer.toString());
- }
-
- /**
- * http://bugs.eclipse.org/bugs/show_bug.cgi?id=15051
- */
- public void test001() {
- try {
- String sourceA001 =
- "public class A001 {\n" +
- " private int i = 6;\n" +
- " public int foo() {\n" +
- " class A {\n" +
- " int get() {\n" +
- " return i;\n" +
- " }\n" +
- " }\n" +
- " return new A().get();\n" +
- " }\n" +
- "};";
- compileAndDeploy(sourceA001, "A001");
- try {
- ClassFileReader classFileReader = ClassFileReader.read(EVAL_DIRECTORY + File.separator + "A001.class");
- IBinaryMethod[] methods = classFileReader.getMethods();
- assertEquals("wrong size", 3, methods.length);
- MethodInfo methodInfo = (MethodInfo) methods[2];
- assertEquals("wrong name", "access$0", new String(methodInfo.getSelector()));
- assertTrue("Not synthetic", methodInfo.isSynthetic());
- } catch (ClassFormatException e) {
- assertTrue(false);
- } catch (IOException e) {
- assertTrue(false);
- }
- } finally {
- removeTempClass("A001");
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java
deleted file mode 100644
index f6a3ec9..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java
deleted file mode 100644
index 14f1389..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java
deleted file mode 100644
index b4a5f7b..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.core.compiler.IProblem;
-
-public class DeprecatedTest extends AbstractRegressionTest {
-public DeprecatedTest(String name) {
- super(name);
-}
-public static Test suite() {
- return setupSuite(testClass());
-}
-public void test1() {
- this.runNegativeTest(new String[] {
- "p/B.java",
- "package p;\n" +
- "class B extends A {\n" +
- " float x = super.x;\n" +
- "}\n",
-
- "p/A.java",
- "package p;\n" +
- "class A {\n" +
- " /** @deprecated */\n" +
- " int x = 1;\n" +
- "}\n",
- },
- new ExpectedProblem[] {
- new ExpectedProblem("p/B.java", 33554505, new String[] {"A", "x", }),
- }
- );
-}
-public void test2() {
- this.runNegativeTest(new String[] {
- "p/C.java",
- "package p;\n" +
- "class C {\n" +
- " static int x = new A().x;\n" +
- "}\n",
-
- "p/A.java",
- "package p;\n" +
- "class A {\n" +
- " /** @deprecated */\n" +
- " int x = 1;\n" +
- "}\n",
-
- },
- new ExpectedProblem[] {
- new ExpectedProblem("p/C.java", 33554505, new String[] {"A", "x", }),
- }
- );
-}
-public void test3() {
- this.runNegativeTest(new String[] {
- "p/Top.java",
- "package p;\n" +
- "public class Top {\n" +
- " \n" +
- " class M1 {\n" +
- " class M2 {}\n" +
- " };\n" +
- " \n" +
- " static class StaticM1 {\n" +
- " static class StaticM2 {\n" +
- " class NonStaticM3{}};\n" +
- " };\n" +
- " \n" +
- "public static void main(String argv[]){\n" +
- " Top tip = new Top();\n" +
- " System.out.println(\"Still alive 0\");\n" +
- " tip.testStaticMember();\n" +
- " System.out.println(\"Still alive 1\");\n" +
- " tip.testStaticMember1();\n" +
- " System.out.println(\"Still alive 2\");\n" +
- " tip.testStaticMember2();\n" +
- " System.out.println(\"Still alive 3\");\n" +
- " tip.testStaticMember3();\n" +
- " System.out.println(\"Still alive 4\");\n" +
- " tip.testStaticMember4();\n" +
- " System.out.println(\"Completed\");\n" +
- "}\n" +
- " void testMember(){\n" +
- " new M1().new M2();}\n" +
- " void testStaticMember(){\n" +
- " new StaticM1().new StaticM2();}\n" +
- " void testStaticMember1(){\n" +
- " new StaticM1.StaticM2();}\n" +
- " void testStaticMember2(){\n" +
- " new StaticM1.StaticM2().new NonStaticM3();}\n" +
- " void testStaticMember3(){\n" +
- " // define an anonymous subclass of the non-static M3\n" +
- " new StaticM1.StaticM2().new NonStaticM3(){};\n" +
- " } \n" +
- " void testStaticMember4(){\n" +
- " // define an anonymous subclass of the non-static M3\n" +
- " new StaticM1.StaticM2().new NonStaticM3(){\n" +
- " Object hello(){\n" +
- " return new StaticM1.StaticM2().new NonStaticM3();\n" +
- " }};\n" +
- " \n" +
- " } \n" +
- "}\n",
- },
- new ExpectedProblem[] {
- new ExpectedProblem("p/Top.java", 16777239, new String[] {"Top.StaticM1.StaticM2", }),
- }
- );
-}
-/**
- * Regression test for PR #1G9ES9B
- */
-public void test4() {
- this.runNegativeTest(new String[] {
- "p/Warning.java",
- "package p;\n" +
- "import java.util.Date;\n" +
- "public class Warning {\n" +
- "public Warning() {\n" +
- " super();\n" +
- " Date dateObj = new Date();\n" +
- " dateObj.UTC(1,2,3,4,5,6);\n" +
- "}\n" +
- "}\n",
- },
- new ExpectedProblem[] {
- new ExpectedProblem("p/Warning.java", IProblem.UsingDeprecatedMethod, new String[] {"Date", "UTC", "int, int, int, int, int, int"}),
- new ExpectedProblem("p/Warning.java", IProblem.NonStaticAccessToStaticMethod, new String[] {"Date", "UTC", "int, int, int, int, int, int"}),
- }
- );
-}
-public static Class testClass() {
- return DeprecatedTest.class;
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExpectedProblem.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExpectedProblem.java
deleted file mode 100644
index 1bce1bd..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ExpectedProblem.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-
-public class ExpectedProblem {
- String fileName;
- int id;
- String[] arguments;
-public ExpectedProblem(String fileName, int id, String[] arguments) {
- this.fileName = fileName;
- this.id = id;
- this.arguments = arguments;
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InMemoryNameEnvironment.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InMemoryNameEnvironment.java
deleted file mode 100644
index df12038..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InMemoryNameEnvironment.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-
-import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
-import org.eclipse.jdt.internal.compiler.env.*;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
-import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
-
-public class InMemoryNameEnvironment implements INameEnvironment {
- INameEnvironment[] classLibs;
- HashtableOfObject compilationUnits = new HashtableOfObject();
-public InMemoryNameEnvironment(String[] compilationUnits, INameEnvironment[] classLibs) {
- this.classLibs = classLibs;
- for (int i = 0, length = compilationUnits.length - 1; i < length; i += 2) {
- String fileName = compilationUnits[i];
- char[] contents = compilationUnits[i + 1].toCharArray();
- String dirName = "";
- int lastSlash = -1;
- if ((lastSlash = fileName.lastIndexOf('/')) != -1) {
- dirName = fileName.substring(0, lastSlash);
- }
- char[] packageName = dirName.replace('/', '.').toCharArray();
- char[] cuName = fileName.substring(lastSlash == -1 ? 0 : lastSlash + 1, fileName.length() - 5).toCharArray(); // remove ".java"
- HashtableOfObject cus = (HashtableOfObject)this.compilationUnits.get(packageName);
- if (cus == null) {
- cus = new HashtableOfObject();
- this.compilationUnits.put(packageName, cus);
- }
- CompilationUnit unit = new CompilationUnit(contents, fileName, null);
- cus.put(cuName, unit);
- }
-}
-public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
- return findType(
- compoundTypeName[compoundTypeName.length - 1],
- CharOperation.subarray(compoundTypeName, 0, compoundTypeName.length - 1));
-}
-public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
- HashtableOfObject cus = (HashtableOfObject)this.compilationUnits.get(CharOperation.concatWith(packageName, '.'));
- if (cus == null) {
- return this.findTypeFromClassLibs(typeName, packageName);
- }
- CompilationUnit unit = (CompilationUnit)cus.get(typeName);
- if (unit == null) {
- return this.findTypeFromClassLibs(typeName, packageName);
- }
- return new NameEnvironmentAnswer(unit);
-}
-private NameEnvironmentAnswer findTypeFromClassLibs(char[] typeName, char[][] packageName) {
- for (int i = 0; i < this.classLibs.length; i++) {
- NameEnvironmentAnswer answer = this.classLibs[i].findType(typeName, packageName);
- if (answer != null) {
- return answer;
- }
- }
- return null;
-}
-public boolean isPackage(char[][] parentPackageName, char[] packageName) {
- char[] pkg = CharOperation.concatWith(parentPackageName, packageName, '.');
- return
- this.compilationUnits.get(pkg) != null ||
- this.isPackageFromClassLibs(parentPackageName, packageName);
-}
-public boolean isPackageFromClassLibs(char[][] parentPackageName, char[] packageName) {
- for (int i = 0; i < this.classLibs.length; i++) {
- if (this.classLibs[i].isPackage(parentPackageName, packageName)) {
- return true;
- }
- }
- return false;
-}
-public void cleanup() {
- for (int i = 0, max = this.classLibs.length; i < max; i++) {
- this.classLibs[i].cleanup();
- }
- this.compilationUnits = new HashtableOfObject();
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LogRequestor.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LogRequestor.java
deleted file mode 100644
index f55f281..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LogRequestor.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.internal.compiler.CompilationResult;
-import org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
-
-public class LogRequestor extends Requestor {
- String problemLog = "";
-public LogRequestor(org.eclipse.jdt.internal.compiler.IProblemFactory problemFactory, String outputPath) {
- super(problemFactory, outputPath, false);
-}
-public void acceptResult(CompilationResult compilationResult) {
- StringBuffer buffer = new StringBuffer(100);
- hasErrors |= compilationResult.hasErrors();
- if (compilationResult.hasProblems()) {
- IProblem[] problems = compilationResult.getProblems();
- int count = problems.length;
- int problemCount = 0;
- for (int i = 0; i < count; i++) {
- if (problems[i] != null) {
- if (problemCount == 0)
- buffer.append("----------\n");
- problemCount++;
- buffer.append(problemCount + (problems[i].isError() ? ". ERROR" : ". WARNING"));
- buffer.append(" in " + new String(problems[i].getOriginatingFileName()));
- try {
- buffer.append(((DefaultProblem)problems[i]).errorReportSource(compilationResult.compilationUnit));
- buffer.append("\n");
- buffer.append(problems[i].getMessage());
- buffer.append("\n");
- } catch (Exception e) {
- }
- buffer.append("----------\n");
- }
- }
- problemLog += buffer.toString();
- }
- outputClassFiles(compilationResult);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java
deleted file mode 100644
index c98ca04..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java
+++ /dev/null
@@ -1,945 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-
-import org.eclipse.jdt.core.tests.compiler.regression.*;
-
-import junit.framework.Test;
-/**
- * Name Lookup within Inner Classes
- * Creation date: (8/2/00 12:04:53 PM)
- * @author: Dennis Conway
- */
-public class LookupTest extends AbstractRegressionTest {
-public LookupTest(String name) {
- super(name);
-}
-public static Test suite() {
- return setupSuite(testClass());
-}
-/**
- * Non-static member class
- */
-public void test01() {
- this.runConformTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " private static int value = 23; \n"+
- " class B { \n"+
- " private int value; \n"+
- " B (int val) { \n"+
- " value = (A.value * 2) + val; \n"+
- " } \n"+
- " } \n"+
- " public static void main (String args[]) { \n"+
- " int result = new A().new B(12).value; \n"+
- " int expected = 58; \n"+
- " System.out.println( \n"+
- " result == expected \n"+
- " ? \"SUCCESS\" \n"+
- " : \"FAILED : got \"+result+\" instead of \"+ expected); \n"+
- " } \n"+
- "}"
- },
- "SUCCESS"
- );
-}
-/**
- * Attempt to access non-static field from static inner class (illegal)
- */
-public void test02() {
- this.runNegativeTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "class A { \n"+
- " private int value; \n"+
- " static class B { \n"+
- " B () { \n"+
- " value = 2; \n"+
- " } \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " B result = new B(); \n"+
- " } \n"+
- "}"
- },
- "----------\n" +
- "1. ERROR in p1\\A.java (at line 6)\n" +
- " value = 2; \n" +
- " ^^^^^\n" +
- "Cannot make a static reference to the non-static field value\n" +
- "----------\n"
- );
-}
-/**
- * Access static field from static inner class
- */
-public void test03() {
- this.runConformTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " private static int value; \n"+
- " static class B { \n"+
- " B () { \n"+
- " value = 2; \n"+
- " } \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " B result = new B(); \n"+
- " System.out.println(\"SUCCESS\"); \n"+
- " } \n"+
- "}",
- "SUCCESS"
- }
- );
-}
-/**
- *
- */
-public void test04() {
- this.runConformTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " private String value; \n"+
- " private A (String strIn) { \n"+
- " value = new B(strIn, \"E\").str; \n"+
- " } \n"+
- " class B { \n"+
- " String str; \n"+
- " private B (String strFromA, String strIn) {\n"+
- " str = strFromA + strIn + new C(\"S\").str;\n"+
- " } \n"+
- " class C { \n"+
- " String str; \n"+
- " private C (String strIn) { \n"+
- " str = strIn + new D(\"S\").str; \n"+
- " } \n"+
- " class D { \n"+
- " String str; \n"+
- " private D (String strIn) { \n"+
- " str = strIn; \n"+
- " } \n"+
- " } \n"+
- " } \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " System.out.println(new A(\"SUCC\").value); \n"+
- " } \n"+
- "}"
- },
- "SUCCESS"
- );
-}
-/**
- *
- */
-public void test05() {
- this.runConformTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " private static void doSomething(String showThis) {\n"+
- " System.out.print(showThis); \n"+
- " return; \n"+
- " } \n"+
- " class B { \n"+
- " void aMethod () { \n"+
- " p1.A.doSomething(\"SUCC\"); \n"+
- " A.doSomething(\"ES\"); \n"+
- " doSomething(\"S\"); \n"+
- " } \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " B foo = new A().new B(); \n"+
- " foo.aMethod(); \n"+
- " } \n"+
- "}"
- },
- "SUCCESS"
- );
-}
-/**
- * jdk1.2.2 reports: No variable sucess defined in nested class p1.A. B.C.
- * jdk1.3 reports: success has private access in p1.A
- */
-public void test06() {
- this.runNegativeTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "class A { \n"+
- " private static String success = \"SUCCESS\"; \n"+
- " public interface B { \n"+
- " public abstract void aTask(); \n"+
- " class C extends A implements B { \n"+
- " public void aTask() {System.out.println(this.success);}\n"+
- " } \n"+
- " } \n"+
- " public static void main (String[] argv) { \n"+
- " } \n"+
- "}"
- },
- "----------\n" +
- "1. ERROR in p1\\A.java (at line 7)\n" +
- " public void aTask() {System.out.println(this.success);}\n" +
- " ^^^^^^^^^^^^\n" +
- "The field success is not visible\n" +
- "----------\n"
- );
-}
-/**
- * No errors in jdk1.2.2, jdk1.3
- */
-public void test07() {
- this.runConformTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " private static String success = \"SUCCESS\"; \n"+
- " public interface B { \n"+
- " public abstract void aTask(); \n"+
- " class C extends A implements B { \n"+
- " public void aTask() {System.out.println(A.success);}\n"+
- " } \n"+
- " } \n"+
- " public static void main (String[] argv) { \n"+
- " } \n"+
- "}"
- }
- );
-}
-/**
- * jdk1.2.2 reports: Undefined variable: A.this
- * jdk1.3 reports: non-static variable this cannot be referenced from a static context
- */
-public void test08() {
- this.runNegativeTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "class A { \n"+
- " private static String success = \"SUCCESS\"; \n"+
- " public interface B { \n"+
- " public abstract void aTask(); \n"+
- " class C extends A implements B { \n"+
- " public void aTask() {System.out.println(A.this.success);}\n"+
- " } \n"+
- " } \n"+
- " public static void main (String[] argv) { \n"+
- " } \n"+
- "}"
- },
- "----------\n" +
- "1. ERROR in p1\\A.java (at line 7)\n" +
- " public void aTask() {System.out.println(A.this.success);}\n" +
- " ^^^^^^\n" +
- "No enclosing instance of the type A is accessible in scope\n" +
- "----------\n"
- );
-}
-/**
- * jdk1.2.2 reports: No variable success defined in nested class p1.A. B.C
- * jdk1.3 reports: success has private access in p1.A
- */
-public void test09() {
- this.runNegativeTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "class A { \n"+
- " private String success = \"SUCCESS\"; \n"+
- " public interface B { \n"+
- " public abstract void aTask(); \n"+
- " class C extends A implements B { \n"+
- " public void aTask() {System.out.println(this.success);}\n"+
- " } \n"+
- " } \n"+
- " public static void main (String[] argv) { \n"+
- " } \n"+
- "}"
- },
- "----------\n" +
- "1. ERROR in p1\\A.java (at line 7)\n" +
- " public void aTask() {System.out.println(this.success);}\n" +
- " ^^^^^^^^^^^^\n" +
- "The field success is not visible\n" +
- "----------\n"
- );
-}
-/**
- * jdk1.2.2 reports: Can't make a static reference to nonstatic variable success in class p1.A
- * jdk1.3 reports: non-static variable success cannot be referenced from a static context
- */
-public void test10() {
- this.runNegativeTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "class A { \n"+
- " private String success = \"SUCCESS\"; \n"+
- " public interface B { \n"+
- " public abstract void aTask(); \n"+
- " class C extends A implements B { \n"+
- " public void aTask() {System.out.println(A.success);}\n"+
- " } \n"+
- " } \n"+
- " public static void main (String[] argv) { \n"+
- " } \n"+
- "}"
- },
- "----------\n" +
- "1. ERROR in p1\\A.java (at line 7)\n" +
- " public void aTask() {System.out.println(A.success);}\n" +
- " ^^^^^^^^^\n" +
- "Cannot make a static reference to the non-static field A.success\n" +
- "----------\n"
- );
-}
-/**
- *
- */
-public void test11() {
- this.runNegativeTest(
- new String[] {
- /* p2.Aa */
- "p2/Aa.java",
- "package p2; \n"+
- "class Aa extends p1.A{ \n"+
- " class B implements p1.A.C { \n"+
- " } \n"+
- " public static void main (String args[]) { \n"+
- " } \n"+
- "}",
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " public A() { \n"+
- " } \n"+
- " class B implements C { \n"+
- " public int sMethod() { \n"+
- " return 23; \n"+
- " } \n"+
- " } \n"+
- " public interface C { \n"+
- " public abstract int sMethod(); \n"+
- " } \n"+
- "}",
-
- },
- "----------\n" +
- "1. ERROR in p2\\Aa.java (at line 3)\n" +
- " class B implements p1.A.C { \n" +
- " ^\n" +
- "Class must implement the inherited abstract method A.C.sMethod()\n" +
- "----------\n"
- );
-}
-/**
- *
- */
-public void test12() {
- this.runConformTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " public interface B { \n"+
- " public abstract void aMethod (int A); \n"+
- " public interface C { \n"+
- " public abstract void anotherMethod(); \n"+
- " } \n"+
- " } \n"+
- " public class aClass implements B, B.C { \n"+
- " public void aMethod (int A) { \n"+
- " } \n"+
- " public void anotherMethod(){} \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " System.out.println(\"SUCCESS\"); \n"+
- " } \n"+
- "}"
- },
- "SUCCESS"
- );
-}
-/**
- *
- */
-public void test13() {
- this.runNegativeTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " public interface B { \n"+
- " public abstract void aMethod (int A); \n"+
- " public interface C { \n"+
- " public abstract void anotherMethod(int A);\n"+
- " } \n"+
- " } \n"+
- " public class aClass implements B, B.C { \n"+
- " public void aMethod (int A) { \n"+
- " public void anotherMethod(int A) {}; \n"+
- " } \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " System.out.println(\"SUCCESS\"); \n"+
- " } \n"+
- "}"
- },
- "----------\n" +
- "1. ERROR in p1\\A.java (at line 9)\n" +
- " public class aClass implements B, B.C { \n" +
- " ^^^^^^\n" +
- "Class must implement the inherited abstract method A.B.C.anotherMethod(int)\n" +
- "----------\n" +
- "2. ERROR in p1\\A.java (at line 11)\n" +
- " public void anotherMethod(int A) {}; \n" +
- " ^\n" +
- "Syntax error on token \"(\", \";\" expected\n" +
- "----------\n"
- );
-}
-/**
- *
- */
-public void test14() {
- this.runNegativeTest(
- new String[] {
- /* pack1.First */
- "pack1/First.java",
- "package pack1; \n"+
- "public class First { \n"+
- " public static void something() {} \n"+
- " class Inner {} \n"+
- " public static void main (String argv[]) { \n"+
- " First.Inner foo = new First().new Inner(); \n"+
- " foo.something(); \n"+
- " System.out.println(\"SUCCESS\"); \n"+
- " } \n"+
- "}"
- },
- "----------\n" +
- "1. ERROR in pack1\\First.java (at line 7)\n" +
- " foo.something(); \n" +
- " ^^^^^^^^^\n" +
- "The method something() is undefined for the type First.Inner\n" +
- "----------\n"
- );
-}
-/**
- *
- */
-public void test15() {
- this.runConformTest(
- new String[] {
- /* pack1.First */
- "pack1/First.java",
- "package pack1; \n"+
- "public class First { \n"+
- " class Inner { \n"+
- " public void something() {} \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " First.Inner foo = new First().new Inner(); \n"+
- " foo.something(); \n"+
- " System.out.println(\"SUCCESS\"); \n"+
- " } \n"+
- "}"
- },
- "SUCCESS"
- );
-}
-/**
- *
- */
-public void test16() {
- this.runConformTest(
- new String[] {
- /* pack1.Outer */
- "pack1/Outer.java",
- "package pack1; \n"+
- "import pack2.*; \n"+
- "public class Outer { \n"+
- " int time, distance; \n"+
- " public Outer() { \n"+
- " } \n"+
- " public Outer(int d) { \n"+
- " distance = d; \n"+
- " } \n"+
- " public void aMethod() { \n"+
- " this.distance *= 2; \n"+
- " return; \n"+
- " } \n"+
- "}",
- /* pack2.OuterTwo */
- "pack2/OuterTwo.java",
- "package pack2; \n"+
- "import pack1.*; \n"+
- "public class OuterTwo extends Outer { \n"+
- " public OuterTwo(int bar) { \n"+
- " Outer A = new Outer(3) { \n"+
- " public void bMethod(){ \n"+
- " final class X { \n"+
- " int price; \n"+
- " public X(int inp) { \n"+
- " price = inp + 32; \n"+
- " } \n"+
- " } \n"+
- " } \n"+
- " }; \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " System.out.println(\"\"); \n"+
- " OuterTwo foo = new OuterTwo(12); \n"+
- " Outer bar = new Outer(8); \n"+
- " } \n"+
- "}"
- }
- );
-}
-/**
- *
- */
-public void test17() {
- this.runConformTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " int value; \n"+
- " public A(B bVal) { \n"+
- " bVal.sval += \"V\"; \n"+
- " } \n"+
- " static class B { \n"+
- " public static String sval; \n"+
- " public void aMethod() { \n"+
- " sval += \"S\"; \n"+
- " A bar = new A(this); \n"+
- " } \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " B foo = new B(); \n"+
- " foo.sval = \"U\"; \n"+
- " foo.aMethod(); \n"+
- " System.out.println(foo.sval); \n"+
- " } \n"+
- "}"
- },
- "USV"
- );
-}
-/**
- * member class
- */
-public void test18() {
- this.runConformTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " private String rating; \n"+
- " public class B { \n"+
- " String rating; \n"+
- " public B (A sth) { \n"+
- " sth.rating = \"m\"; \n"+
- " rating = \"er\"; \n"+
- " } \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " A foo = new A(); \n"+
- " foo.rating = \"o\"; \n"+
- " B bar = foo.new B(foo); \n"+
- " System.out.println(foo.rating + bar.rating);\n"+
- " } \n"+
- "}"
- },
- "mer"
- );
-}
-/**
- * member class
- */
-public void test19() {
- this.runNegativeTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " private String rating; \n"+
- " public void setRating(A sth, String setTo) { \n"+
- " sth.rating = setTo; \n"+
- " return; \n"+
- " } \n"+
- " public class B { \n"+
- " public B (A sth) { \n"+
- " setRating(sth, \"m\"); \n"+
- " } \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " A foo = new A(); \n"+
- " foo.rating = \"o\"; \n"+
- " B bar = foo.new B(foo); \n"+
- " System.out.println(foo.rating + bar.other); \n"+
- " } \n"+
- "}"
- },
- "----------\n" +
- "1. ERROR in p1\\A.java (at line 17)\n" +
- " System.out.println(foo.rating + bar.other); \n" +
- " ^^^^^^^^^\n" +
- "bar.other cannot be resolved or is not a field\n" +
- "----------\n"
- );
-}
-/**
- * member class
- */
-public void test20() {
- this.runNegativeTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " private String rating; \n"+
- " public class B { \n"+
- " public B (A sth) { \n"+
- " sth.rating = \"m\"; \n"+
- " } \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " A foo = new A(); \n"+
- " foo.rating = \"o\"; \n"+
- " B bar = foo.new B(foo); \n"+
- " System.out.println(foo.rating + bar.other); \n"+
- " } \n"+
- "}"
- },
- "----------\n" +
- "1. WARNING in p1\\A.java (at line 6)\n" +
- " sth.rating = \"m\"; \n" +
- " ^^^^^^^^^^\n" +
- "Write access to enclosing field A.rating is emulated by a synthetic accessor method\n" +
- "----------\n" +
- "2. ERROR in p1\\A.java (at line 13)\n" +
- " System.out.println(foo.rating + bar.other); \n" +
- " ^^^^^^^^^\n" +
- "bar.other cannot be resolved or is not a field\n" +
- "----------\n"
- );
-}
-/**
- * member class
- */
-public void test21() {
- this.runConformTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " private String rating; \n"+
- " public class B { \n"+
- " public B (A sth) { \n"+
- " sth.rating = \"m\"; \n"+
- " } \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " A foo = new A(); \n"+
- " foo.rating = \"o\"; \n"+
- " B bar = foo.new B(foo); \n"+
- " System.out.println(foo.rating); \n"+
- " } \n"+
- "}"
- }
- );
-}
-/**
- *
- */
-public void test22() {
- this.runConformTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "import p2.*; \n"+
- "public class A { \n"+
- " public int aValue; \n"+
- " public A() {} \n"+
- " public static class C extends A { \n"+
- " public String aString; \n"+
- " public C() { \n"+
- " } \n"+
- " } \n"+
- "}",
- /* p2.B */
- "p2/B.java",
- "package p2; \n"+
- "import p1.*; \n"+
- "public class B extends A.C { \n"+
- " public B() {} \n"+
- " public class D extends A { \n"+
- " public D() { \n"+
- " C val2 = new C(); \n"+
- " val2.aString = \"s\"; \n"+
- " A val = new A(); \n"+
- " val.aValue = 23; \n"+
- " } \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " D foo = new B().new D(); \n"+
- " } \n"+
- "}"
- }
- );
-}
-/**
- *
- */
-public void test23() {
- this.runConformTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1;\n"+
- "public class A implements B { \n"+
- "} \n"+
- "interface B { \n"+
- " public class A implements B { \n"+
- " public static void main (String argv[]) { \n"+
- " class Ba { \n"+
- " int time; \n"+
- " } \n"+
- " Ba foo = new Ba(); \n"+
- " foo.time = 3; \n"+
- " } \n"+
- " interface C { \n"+
- " } \n"+
- " interface Bb extends C { \n"+
- " } \n"+
- " } \n"+
- "}"
- }
- );
-}
-/**
- *
- */
-public void test24() {
- this.runConformTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " protected static String bleh; \n"+
- " interface B { \n"+
- " public String bleh(); \n"+
- " class C{ \n"+
- " public String bleh() {return \"B\";}\n"+
- " } \n"+
- " } \n"+
- " class C implements B { \n"+
- " public String bleh() {return \"A\";} \n"+
- " } \n"+
- " public static void main(String argv[]) { \n"+
- " C foo = new A().new C(); \n"+
- " } \n"+
- "}"
- }
- );
-}
-/**
- *
- */
-public void test25() {
- this.runConformTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "import p2.*; \n"+
- "public class A { \n"+
- " public static class B { \n"+
- " public static int B; \n"+
- " } \n"+
- " public static void main(String argv[]) {\n"+
- " B foo = new A.B(); \n"+
- " B bar = new B(); \n"+
- " foo.B = 2; \n"+
- " p2.B bbar = new p2.B(); \n"+
- " if (bar.B == 35) { \n"+
- " System.out.println(\"SUCCESS\");\n"+
- " } \n"+
- " else { \n"+
- " System.out.println(bar.B); \n"+
- " } \n"+
- " } \n"+
- "}",
- "p2/B.java",
- "package p2; \n"+
- "import p1.*; \n"+
- "public class B extends A { \n"+
- " public B() { \n"+
- " A.B bleh = new A.B(); \n"+
- " bleh.B = 35; \n"+
- " } \n"+
- "}"
- },
- "SUCCESS"
- );
-}
-/**
- *
- */
-public void test26() {
- this.runNegativeTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " public static class B { \n"+
- " protected static int B; \n"+
- " } \n"+
- " public static void main(String argv[]) {\n"+
- " B foo = new A.B(); \n"+
- " B bar = new B(); \n"+
- " B.B = 2; \n"+
- " p2.B bbar = new p2.B(); \n"+
- " if (B.B == 35) { \n"+
- " System.out.println(\"SUCCESS\");\n"+
- " } \n"+
- " else { \n"+
- " System.out.println(B.B); \n"+
- " } \n"+
- " } \n"+
- "}",
- "p2/B.java",
- "package p2; \n"+
- "import p1.*; \n"+
- "public class B extends A { \n"+
- " public B() { \n"+
- " A.B bleh = new A.B(); \n"+
- " bleh.B = 35; \n"+
- " } \n"+
- "}"
- },
- "----------\n" +
- "1. ERROR in p2\\B.java (at line 6)\n" +
- " bleh.B = 35; \n" +
- " ^^^^^^\n" +
- "The field bleh.B is not visible\n" +
- "----------\n"
- );
-}
-/**
- *
- */
-public void test27() {
- this.runNegativeTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " protected static class B { \n"+
- " public static int B; \n"+
- " } \n"+
- " public static void main(String argv[]) {\n"+
- " B foo = new A.B(); \n"+
- " B bar = new B(); \n"+
- " B.B = 2; \n"+
- " p2.B bbar = new p2.B(); \n"+
- " if (B.B == 35) { \n"+
- " System.out.println(\"SUCCESS\");\n"+
- " } \n"+
- " else { \n"+
- " System.out.println(B.B); \n"+
- " } \n"+
- " } \n"+
- "}",
- "p2/B.java",
- "package p2; \n"+
- "import p1.*; \n"+
- "public class B extends A { \n"+
- " public B() { \n"+
- " A.B bleh = new A.B(); \n"+
- " A.B.B = 35; \n"+
- " } \n"+
- "}"
- },
- "----------\n" +
- "1. ERROR in p2\\B.java (at line 5)\n" +
- " A.B bleh = new A.B(); \n" +
- " ^^^^^^^^^\n" +
- "The constructor A.B() is not visible\n" +
- "----------\n"
- );
-}
-/**
- *
- */
-public void test28() {
- this.runConformTest(
- new String[] {
- /* p1.A */
- "p1/A.java",
- "package p1; \n"+
- "public class A { \n"+
- " static class B { \n"+
- " public static class C { \n"+
- " private static int a; \n"+
- " private int b; \n"+
- " } \n"+
- " } \n"+
- " class D extends B { \n"+
- " int j = p1.A.B.C.a; \n"+
- " } \n"+
- " public static void main (String argv[]) { \n"+
- " System.out.println(\"SUCCESS\"); \n"+
- " } \n"+
- "}"
- },
- "SUCCESS"
- );
-}
-public static Class testClass() {
- return LookupTest.class;
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java
deleted file mode 100644
index fce0237..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Enumeration;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.core.tests.compiler.regression.*;
-import org.eclipse.jdt.internal.compiler.ClassFile;
-import org.eclipse.jdt.internal.compiler.CompilationResult;
-import org.eclipse.jdt.internal.compiler.IProblemFactory;
-
-public class ProblemConstructorTest extends AbstractRegressionTest {
-
-public ProblemConstructorTest(String name) {
- super(name);
-}
-public static Test suite() {
- return setupSuite(testClass());
-}
-public static Class testClass() {
- return ProblemConstructorTest.class;
-}
-
-protected Requestor getRequestor(IProblemFactory problemFactory) {
- return new Requestor(problemFactory, OUTPUT_DIR.endsWith(File.separator) ? OUTPUT_DIR : OUTPUT_DIR + File.separator, false) {
- public void acceptResult(CompilationResult cr) {
- super.acceptResult(cr);
- outputClassFiles(cr);
- }
-
- protected void outputClassFiles(CompilationResult unitResult) {
-
- if (unitResult != null) {
- Enumeration classFiles = unitResult.compiledTypes.elements();
- if (outputPath != null) {
- while (classFiles.hasMoreElements()) {
- // retrieve the key and the corresponding classfile
- ClassFile classFile = (ClassFile) classFiles.nextElement();
- String relativeName =
- new String(classFile.fileName()).replace('/', File.separatorChar) + ".class";
- try {
- ClassFile.writeToDisk(true, outputPath, relativeName, classFile.getBytes());
- } catch(IOException e) {
- }
- }
- }
- }
- }
- };
-}
-public void test001() {
- System.out.println("TEST RUN");
- this.runNegativeTest(
- new String[] {
- "prs/Test1.java",
- "package prs; \n" +
- "import java.io.IOException; \n" +
- "public class Test1 { \n" +
- "String s = 3; \n" +
- "Test1() throws IOException { \n" +
- "} \n" +
- "}"
- },
- new ExpectedProblem[] {
- new ExpectedProblem("prs/Test1.java", IProblem.TypeMismatch, new String[] {"int", "String"})
- }
- );
-
- this.runNegativeTest(
- new String[] {
- "prs/Test2.java",
- "package prs; \n" +
- "import java.io.IOException; \n" +
- "public class Test2 { \n" +
- "public void foo() { \n" +
- "try { \n" +
- "Test1 t = new Test1(); \n" +
- "System.out.println(); \n" +
- "} catch(IOException e) \n" +
- "{ \n" +
- "e.printStackTrace(); \n" +
- "} \n" +
- "} \n" +
- "}"
- },
- new ExpectedProblem[] {},
- null,
- false);
-}
-
-
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RegressionTestSetup.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RegressionTestSetup.java
deleted file mode 100644
index 267da4b..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RegressionTestSetup.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-
-import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.core.tests.compiler.regression.*;
-import org.eclipse.jdt.core.tests.util.*;
-import org.eclipse.jdt.internal.compiler.batch.FileSystem;
-import java.util.Enumeration;
-
-import junit.extensions.*;
-import junit.framework.*;
-
-public class RegressionTestSetup extends TestDecorator {
- TestVerifier verifier = new TestVerifier(true);
-public RegressionTestSetup(Test test) {
- super(test);
-}
-private void initTest(Object test, TestVerifier verifier, INameEnvironment javaClassLib) {
- if (test instanceof AbstractRegressionTest) {
- AbstractRegressionTest regressionTest = (AbstractRegressionTest)test;
- regressionTest.verifier = verifier;
- regressionTest.javaClassLib = javaClassLib;
- return;
- }
- if (test instanceof TestSuite) {
- TestSuite regressionTestClassSuite = (TestSuite) test;
- Enumeration regressionTestClassTests = regressionTestClassSuite.tests();
- while (regressionTestClassTests.hasMoreElements()) {
- initTest(regressionTestClassTests.nextElement(), verifier, javaClassLib);
- }
- return;
- }
-
-}
-public void run(TestResult result) {
- try {
- setUp();
- super.run(result);
- } finally {
- tearDown();
- }
-}
-protected void setUp() {
- // Create name environment
- INameEnvironment javaClassLib = new FileSystem(new String[] {Util.getJavaClassLib()}, new String[0], null);
-
- // Init wrapped suite
- initTest(fTest, this.verifier, javaClassLib);
-}
-protected void tearDown() {
- this.verifier.shutDown();
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Requestor.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Requestor.java
deleted file mode 100644
index 50c8102..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Requestor.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import junit.framework.Assert;
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.core.tests.compiler.regression.*;
-import org.eclipse.jdt.internal.compiler.ClassFile;
-import org.eclipse.jdt.internal.compiler.CompilationResult;
-import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
-import org.eclipse.jdt.internal.compiler.IProblemFactory;
-
-public class Requestor extends Assert implements ICompilerRequestor {
- public boolean hasErrors = false;
- public IProblemFactory problemFactory;
- public String outputPath;
- private boolean generateOutput;
- public Hashtable expectedProblems = new Hashtable();
-public Requestor(IProblemFactory problemFactory, String outputPath, boolean generateOutput) {
- this.problemFactory = problemFactory;
- this.outputPath = outputPath;
- this.generateOutput = generateOutput;
-}
- public void acceptResult(CompilationResult cr) {
- if (cr.hasProblems()) {
- if (cr.hasErrors()) {
- this.hasErrors = true;
- }
-
- IProblem[] actualProblems = cr.getProblems();
- int actualProblemsCount = actualProblems == null ? 0 : actualProblems.length;
- ExpectedProblem[] problems = (ExpectedProblem[])this.expectedProblems.get(new String(cr.getFileName()));
- int expectedProblemsCount = problems == null ? 0 : problems.length;
-
- if (actualProblemsCount > 0 || expectedProblemsCount > 0) {
- boolean areMessagesDifferent = false;
- String message = new String(cr.getFileName()) + " does not have the correct errors.\nFound :\n";
- for (int i = 0; i < actualProblemsCount; i++) {
- message += "\t" + actualProblems[i].getMessage() + "\n";
- /* START PRINT */
-/*
- System.out.print(actualProblems[i].getID()+":");
- String[] pbArgs = actualProblems[i].getArguments();
- for (int j = 0; j < pbArgs.length; j++){
- if (j > 0) System.out.print(", ");
- System.out.print(pbArgs[j]);
- }
- System.out.println();
-*/
- /* END PRINT */
- if (i < expectedProblemsCount
- && !actualProblems[i].getMessage().equals(problemFactory.getLocalizedMessage(problems[i].id, problems[i].arguments))) {
- areMessagesDifferent = true;
- System.out.print(actualProblems[i].getID()+":");
- String[] pbArgs = actualProblems[i].getArguments();
- for (int j = 0; j < pbArgs.length; j++){
- if (j > 0) System.out.print(", ");
- System.out.print(pbArgs[j]);
- }
- System.out.println();
- }
- }
- if (expectedProblemsCount == 0) {
- message += "Expecting no problems.";
- } else {
- message += "Expecting :\n";
- for (int i = 0; i < expectedProblemsCount; i++) {
- ExpectedProblem expectedProblem = problems[i];
- message += "\t" + problemFactory.getLocalizedMessage(expectedProblem.id, expectedProblem.arguments) + "\n";
- }
- }
- assertTrue(message, (actualProblemsCount == expectedProblemsCount) && !areMessagesDifferent);
- }
- }
- outputClassFiles(cr);
- }
-public void expectedProblems(ExpectedProblem[] problems) {
- for (int i = 0; i < problems.length; i++){
- ExpectedProblem problem = problems[i];
- String fileName = problem.fileName;
- if (File.separator.equals("/")) {
- if (fileName.indexOf("\\") != -1) {
- fileName = fileName.replace('\\', File.separatorChar);
- }
- } else {
- // the file separator is \
- if (fileName.indexOf('/') != -1) {
- fileName = fileName.replace('/', File.separatorChar);
- }
- }
-
- ExpectedProblem[] existingProblems = (ExpectedProblem[])this.expectedProblems.get(fileName);
- if (existingProblems == null) {
- this.expectedProblems.put(fileName, new ExpectedProblem[] {problem});
- } else {
- int length = existingProblems.length;
- ExpectedProblem[] newProblems = new ExpectedProblem[length + 1];
- System.arraycopy(existingProblems, 0, newProblems, 0, length);
- newProblems[length] = problem;
- this.expectedProblems.put(fileName, newProblems);
- }
- }
-}
-protected void outputClassFiles(CompilationResult unitResult) {
-
- if ((unitResult != null) && (!unitResult.hasErrors() || generateOutput)) {
- Enumeration classFiles = unitResult.compiledTypes.elements();
- if (outputPath != null) {
- while (classFiles.hasMoreElements()) {
- // retrieve the key and the corresponding classfile
- ClassFile classFile = (ClassFile) classFiles.nextElement();
- String relativeName =
- new String(classFile.fileName()).replace('/', File.separatorChar) + ".class";
- try {
- ClassFile.writeToDisk(true, outputPath, relativeName, classFile.getBytes());
- } catch(IOException e) {
- }
- }
- }
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java
deleted file mode 100644
index dd6c7be..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.core.ToolFactory;
-import org.eclipse.jdt.core.compiler.IScanner;
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
-import org.eclipse.jdt.core.compiler.InvalidInputException;
-
-public class ScannerTest extends AbstractRegressionTest {
-
- public ScannerTest(String name) {
- super(name);
- }
- public static Test suite() {
- return setupSuite(testClass());
- }
-
- public static Class testClass() {
- return ScannerTest.class;
- }
-
- /**
- * http://bugs.eclipse.org/bugs/show_bug.cgi?id=23181
- */
- public void test001() {
- String sourceA001 = "\\u003b";
- IScanner scanner = ToolFactory.createScanner(false, true, false, false);
- scanner.setSource(sourceA001.toCharArray());
- int token = 0;
- try {
- token = scanner.getNextToken();
- } catch (InvalidInputException e) {
- }
- assertEquals("Wrong token type", ITerminalSymbols.TokenNameSEMICOLON, token);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
deleted file mode 100644
index 4d31107..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-
-import org.eclipse.jdt.core.tests.compiler.regression.*;
-import org.eclipse.jdt.core.tests.junit.extension.*;
-
-import junit.framework.*;
-
-/**
- * Run all compiler regression tests
- */
-public class TestAll extends TestCase {
- public static boolean EXPERT; // an expert doesn't exclude any tests
- static String[] EXCLUDED_TESTS = new String[] {};
-public TestAll(String testName) {
- super(testName);
-}
-/**
- * Adds all the tests in the given class to the suite except
- * the ones that are excluded.
- */
-public static void addTest(TestSuite suite, Class testClass) {
- TestSuite innerSuite = new TestSuite(testClass);
- suite.addTest(innerSuite);
-}
-public static Test suite() {
- TestSuite suite = new TestSuite(TestAll.class.getName());
-
- String specVersion = System.getProperty("java.specification.version");
- if (!"1.0".equals(specVersion) && !"1.1".equals(specVersion) && !"1.2".equals(specVersion) && !"1.3".equals(specVersion)) {
- addTest(suite, AssertionTest.class);
- }
-
- addTest(suite, BatchCompilerTest.class);
- addTest(suite, ClassFileComparatorTest.class);
- addTest(suite, ClassFileReaderTest.class);
- addTest(suite, Compliance_1_3.class);
- addTest(suite, Compliance_1_4.class);
- addTest(suite, DeprecatedTest.class);
- addTest(suite, LookupTest.class);
- addTest(suite, ProblemConstructorTest.class);
- addTest(suite, UtilTest.class);
- addTest(suite, ScannerTest.class);
-
- if (EXPERT) {
- return new RegressionTestSetup(suite);
- } else {
- return new RegressionTestSetup(new ExcludedTestSuite(suite, EXCLUDED_TESTS));
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UtilTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UtilTest.java
deleted file mode 100644
index b28c487..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UtilTest.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.compiler.regression;
-
-import org.eclipse.jdt.core.tests.compiler.regression.*;
-import org.eclipse.jdt.internal.compiler.util.*;
-import junit.framework.Test;
-
-public class UtilTest extends AbstractRegressionTest {
-public UtilTest(String name) {
- super(name);
-}
-public static Test suite() {
- return setupSuite(testClass());
-}
-public void test01() {
-
- assertTrue("Pattern matching failure",
- !CharOperation.match("X".toCharArray(), "Xyz".toCharArray(), true));
-}
-public void test02() {
-
- assertTrue("Pattern matching failure",
- CharOperation.match("X*".toCharArray(), "Xyz".toCharArray(), true));
-}
-public void test03() {
-
- assertTrue("Pattern matching failure",
- CharOperation.match("X".toCharArray(), "X".toCharArray(), true));
-}
-public void test04() {
-
- assertTrue("Pattern matching failure",
- CharOperation.match("X*X".toCharArray(), "XYX".toCharArray(), true));
-}
-public void test05() {
-
- assertTrue("Pattern matching failure",
- CharOperation.match("XY*".toCharArray(), "XYZ".toCharArray(), true));
-}
-public void test06() {
-
- assertTrue("Pattern matching failure",
- CharOperation.match("*XY*".toCharArray(), "XYZ".toCharArray(), true));
-}
-public void test07() {
-
- assertTrue("Pattern matching failure",
- CharOperation.match("*".toCharArray(), "XYZ".toCharArray(), true));
-}
-public void test08() {
-
- assertTrue("Pattern matching failure",
- !CharOperation.match("a*".toCharArray(), "XYZ".toCharArray(), true));
-}
-public void test09() {
-
- assertTrue("Pattern matching failure",
- !CharOperation.match("abc".toCharArray(), "XYZ".toCharArray(), true));
-}
-public void test10() {
-
- assertTrue("Pattern matching failure",
- !CharOperation.match("ab*c".toCharArray(), "abX".toCharArray(), true));
-}
-public void test11() {
-
- assertTrue("Pattern matching failure",
- CharOperation.match("a*b*c".toCharArray(), "aXXbYYc".toCharArray(), true));
-}
-public void test12() {
-
- assertTrue("Pattern matching failure",
- !CharOperation.match("*a*bc".toCharArray(), "aXXbYYc".toCharArray(), true));
-}
-public void test13() {
-
- assertTrue("Pattern matching failure",
- !CharOperation.match("*foo*bar".toCharArray(), "".toCharArray(), true));
-}
-public void test14() {
-
- assertTrue("Pattern matching failure",
- CharOperation.match("*foo*bar".toCharArray(), "ffoobabar".toCharArray(), true));
-}
-public void test15() {
-
- assertTrue("Pattern matching failure",
- !CharOperation.match("*fol*bar".toCharArray(), "ffoobabar".toCharArray(), true));
-}
-public void test16() {
-
- assertTrue("Pattern matching failure",
- CharOperation.match("*X*Y*".toCharArray(), "XY".toCharArray(), true));
-}
-public void test17() {
-
- assertTrue("Pattern matching failure",
- CharOperation.match("*X*Y*".toCharArray(), "XYZ".toCharArray(), true));
-}
-public void test18() {
-
- assertTrue("Pattern matching failure",
- CharOperation.match("main(*)".toCharArray(), "main(java.lang.String[] argv)".toCharArray(), true));
-}
-public void test19() {
-
- assertTrue("Pattern matching failure",
- CharOperation.match("*rr*".toCharArray(), "ARRAY".toCharArray(), false));
-}
-
-public void test20() {
-
- assertTrue("Pattern matching failure",
- CharOperation.match("hello*World".toCharArray(), "helloWorld".toCharArray(), true));
-}
-
-public void test21() {
- assertEquals("Trim failure", "hello", new String(CharOperation.trim("hello".toCharArray())));
-}
-public void test22() {
- assertEquals("Trim failure", "hello", new String(CharOperation.trim(" hello".toCharArray())));
-}
-public void test23() {
- assertEquals("Trim failure", "hello", new String(CharOperation.trim(" hello ".toCharArray())));
-}
-public void test24() {
- assertEquals("Trim failure", "hello", new String(CharOperation.trim("hello ".toCharArray())));
-}
-public void test25() {
- assertEquals("Trim failure", "", new String(CharOperation.trim(" ".toCharArray())));
-}
-public void test26() {
- assertEquals("Trim failure", "hello world", new String(CharOperation.trim(" hello world ".toCharArray())));
-}
-public void test27() {
- char [][] tokens = CharOperation.splitAndTrimOn(','," hello,world".toCharArray());
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < tokens.length; i++){
- buffer.append('[').append(tokens[i]).append(']');
- }
- assertEquals("SplitTrim failure", "[hello][world]", buffer.toString());
-}
-public void test28() {
- char [][] tokens = CharOperation.splitAndTrimOn(','," hello , world".toCharArray());
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < tokens.length; i++){
- buffer.append('[').append(tokens[i]).append(']');
- }
- assertEquals("SplitTrim failure", "[hello][world]", buffer.toString());
-}
-public void test29() {
- char [][] tokens = CharOperation.splitAndTrimOn(','," hello, world ".toCharArray());
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < tokens.length; i++){
- buffer.append('[').append(tokens[i]).append(']');
- }
- assertEquals("SplitTrim failure", "[hello][world]", buffer.toString());
-}
-public void test30() {
- char [][] tokens = CharOperation.splitAndTrimOn(','," hello, world ,zork/, aaa bbb".toCharArray());
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < tokens.length; i++){
- buffer.append('[').append(tokens[i]).append(']');
- }
- assertEquals("SplitTrim failure", "[hello][world][zork/][aaa bbb]", buffer.toString());
-}
-public void test31() {
- char [][] tokens = CharOperation.splitAndTrimOn(','," , ".toCharArray());
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < tokens.length; i++){
- buffer.append('[').append(tokens[i]).append(']');
- }
- assertEquals("SplitTrim failure", "[][]", buffer.toString());
-}
-public void test32() {
- char [][] tokens = CharOperation.splitAndTrimOn(','," ".toCharArray());
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < tokens.length; i++){
- buffer.append('[').append(tokens[i]).append(']');
- }
- assertEquals("SplitTrim failure", "[]", buffer.toString());
-}
-public void test33() {
- char [][] tokens = CharOperation.splitAndTrimOn(','," , hello ".toCharArray());
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < tokens.length; i++){
- buffer.append('[').append(tokens[i]).append(']');
- }
- assertEquals("SplitTrim failure", "[][hello]", buffer.toString());
-}
-
-public static Class testClass() {
- return UtilTest.class;
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/CodeSnippetTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/CodeSnippetTest.java
deleted file mode 100644
index f6498a9..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/CodeSnippetTest.java
+++ /dev/null
@@ -1,665 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.internal.eval.EvaluationResult;
-import org.eclipse.jdt.internal.eval.IRequestor;
-/**
- * Test the code snippet evaluation.
- * This assumes that the EvaluationContext class and that the EvaluationResult class
- * are working correctly.
- */
-public class CodeSnippetTest extends EvaluationTest {
-/**
- * Creates a new CodeSnippetTest.
- */
-public CodeSnippetTest(String name) {
- super(name);
-}
-/**
- * Returns a requestor that expects no result.
- */
-private IRequestor getNoResultRequestor() {
- return new Requestor() {
- public void acceptResult(EvaluationResult result) {
- assertTrue("No result", false);
- }
- };
-}
-public static Test suite() {
- return setupSuite(testClass());
-}
-/**
- * Tests code snippet that throws a checked exception.
- * (Regression test for 1G0T5XK)
- */
-public void testCheckedException() {
- evaluateWithExpectedDisplayString(buildCharArray(new String[] {
- "try {",
- " throw new java.io.IOException();",
- "} finally {",
- " System.err.println(\"This is an expected exception:\");",
- "}"}),
- null);
-}
-public static Class testClass() {
- return CodeSnippetTest.class;
-}
-/**
- * Tests that no errors are reported for an empty statement followed by an expression.
- * (Regression test for PR #1G1HGHE)
- */
-public void testEmptyStatement() {
- evaluateWithExpectedDisplayString(buildCharArray(new String[] {
- "class X {",
- " public int fact(int n){",
- " return fact0(n, 1);",
- " }",
- " public int fact0(int n, int acc){",
- " if (n <= 1) return acc;",
- " return fact0(n - 1, acc * n);",
- " }",
- "};",
- "new X().fact(10)"}),
- "3628800".toCharArray());
-}
-/**
- * Tests that an error is reported for an empty import.
- */
-public void testEvaluateEmptyImport() {
- try {
- char[] importName = new char[0];
- context.setImports(new char[][] {importName});
- Requestor requestor = new Requestor();
- context.evaluateImports(getEnv(), requestor, getProblemFactory());
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Problems", result.hasProblems());
- assertEquals("Evaluation type", EvaluationResult.T_IMPORT, result.getEvaluationType());
- assertEquals("Evaluation ID", importName, result.getEvaluationID());
- } finally {
- // clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Tests that an error is reported for an existing package and a non existing type imports.
- */
-public void testEvaluateExistingPackageAndNonExistingTypeImports() {
- try {
- char[] importName = "non.existing.Type".toCharArray();
- context.setImports(new char[][] {"java.lang.reflect.*".toCharArray(), importName});
- Requestor requestor = new Requestor();
- context.evaluateImports(getEnv(), requestor, getProblemFactory());
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Problems", result.hasProblems());
- assertEquals("Evaluation type", EvaluationResult.T_IMPORT, result.getEvaluationType());
- assertEquals("Evaluation ID", importName, result.getEvaluationID());
- } finally {
- // clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Tests that an error is reported for a non existing package and an existing type imports.
- */
-public void testEvaluateNonExistingPackageAndExistingTypeImports() {
- try {
- char[] importName = "non.existing.*".toCharArray();
- context.setImports(new char[][] {importName, "java.math.BigInteger".toCharArray()});
- Requestor requestor = new Requestor();
- context.evaluateImports(getEnv(), requestor, getProblemFactory());
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Problems", result.hasProblems());
- assertEquals("Evaluation type", EvaluationResult.T_IMPORT, result.getEvaluationType());
- assertEquals("Evaluation ID", importName, result.getEvaluationID());
- } finally {
- // clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Tests that an error is reported for a non existing package import.
- */
-public void testEvaluateNonExistingPackageImport() {
- try {
- char[] importName = "non.existing.*".toCharArray();
- context.setImports(new char[][] {importName});
- Requestor requestor = new Requestor();
- context.evaluateImports(getEnv(), requestor, getProblemFactory());
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Problems", result.hasProblems());
- assertEquals("Evaluation type", EvaluationResult.T_IMPORT, result.getEvaluationType());
- assertEquals("Evaluation ID", importName, result.getEvaluationID());
- } finally {
- // clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Tests that an error is reported for a non existing type import.
- */
-public void testEvaluateNonExistingTypeImport() {
- try {
- char[] importName = "non.existing.Type".toCharArray();
- context.setImports(new char[][] {importName});
- Requestor requestor = new Requestor();
- context.evaluateImports(getEnv(), requestor, getProblemFactory());
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Problems", result.hasProblems());
- assertEquals("Evaluation type", EvaluationResult.T_IMPORT, result.getEvaluationType());
- assertEquals("Evaluation ID", importName, result.getEvaluationID());
- } finally {
- // clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Tests that no errors are reported for valid package and type imports.
- */
-public void testEvaluateValidPackageAndTypeImports() {
- try {
- context.setImports(new char[][] {"java.util.Enumeration".toCharArray(), "java.lang.reflect.*".toCharArray()});
- context.evaluateImports(getEnv(), getNoResultRequestor(), getProblemFactory());
- } finally {
- // clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Tests that no errors are reported for a valid package import.
- */
-public void testEvaluateValidPackageImport() {
- try {
- context.setImports(new char[][] {"java.io.*".toCharArray()});
- context.evaluateImports(getEnv(), getNoResultRequestor(), getProblemFactory());
- } finally {
- // clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Tests that no errors are reported for a valid type import.
- */
-public void testEvaluateValidTypeImport() {
- try {
- context.setImports(new char[][] {"java.math.BigInteger".toCharArray()});
- context.evaluateImports(getEnv(), getNoResultRequestor(), getProblemFactory());
- } finally {
- // clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Tests code snippet that include a finally block triggered by an error.
- */
-public void testFinallyError() {
- evaluateWithExpectedDisplayString(buildCharArray(new String[] {
- "try {",
- " throw new Error();",
- "} finally {",
- " System.err.println(\"This is an expected error:\");",
- "}"}),
- null);
-}
-/**
- * Tests code snippet that include one finally block.
- */
-public void testFinallyOneBlock() {
- evaluateWithExpectedDisplayString(buildCharArray(new String[] {
- "try {",
- " return 1;",
- "} finally {",
- " return 2;",
- "}"}),
- "2".toCharArray());
-}
-/**
- * Tests code snippet that include 2 finally blocks.
- */
-public void testFinallyTwoBlock() {
- evaluateWithExpectedDisplayString(buildCharArray(new String[] {
- "try {",
- " try {",
- " return 1;",
- " } finally {",
- " return 2;",
- " }",
- "} finally {",
- " return 3;",
- "}"}),
- "3".toCharArray());
-}
-/**
- * Tests the free return addition at the end of the code snippet
- * for an anonymous inner class.
- */
-public void testFreeReturnAnonymous() {
- evaluateWithExpectedDisplayString(buildCharArray(new String[] {
- "new Object() {",
- " public String toString() {",
- " return \"an object\";",
- " }",
- "}"}),
- "an object".toCharArray());
-}
-/**
- * Tests the free return addition at the end of the code snippet
- * for a class declaration followed by an expression.
- */
-public void testFreeReturnClassDeclaration() {
- evaluateWithExpectedDisplayString(buildCharArray(new String[] {
- "class Point {",
- " int x;",
- " int y;",
- " Point(int x, int y) {",
- " this.x = x;",
- " this.y = y;",
- " }",
- "}",
- "new Point(56, 99).x"}),
- "56".toCharArray());
-}
-/**
- * Tests the free return addition at the end of the code snippet
- * for an expression.
- */
-public void testFreeReturnExpression() {
- evaluateWithExpectedDisplayString("(1 + 2) * 3.0 / 4".toCharArray(), "2.25".toCharArray());
-}
-/**
- * Tests the free return addition at the end of the code snippet
- * for an integer.
- */
-public void testFreeReturnInteger() {
- evaluateWithExpectedDisplayString("1".toCharArray(), "1".toCharArray());
-}
-/**
- * Tests the free return addition at the end of the code snippet
- * for a local variable declaration followed by an expression.
- */
-public void testFreeReturnLocalVar() {
- evaluateWithExpectedDisplayString(buildCharArray(new String[] {
- "int i = 99;",
- "i + 4"}),
- "103".toCharArray());
-}
-/**
- * Tests the free return addition at the end of the code snippet
- * for a statement followed by an expression.
- */
-public void testFreeReturnStatement() {
- evaluateWithExpectedDisplayString(buildCharArray(new String[] {
- "int i = 2;",
- "for (int j=0;j<10;j++) {",
- " i++;",
- "}",
- "i"}),
- "12".toCharArray());
-}
-/**
- * Tests code snippet that include a package import.
- */
-public void testImportPackage() {
- try {
- context.setImports(new char[][] {"java.io.*".toCharArray()});
- evaluateWithExpectedDisplayString("return new File(\"!@#%\").exists();".toCharArray(), "false".toCharArray());
- } finally {
- // clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Tests code snippet that include a type import.
- */
-public void testImportType() {
- try {
- context.setImports(new char[][] {"java.math.BigInteger".toCharArray()});
- evaluateWithExpectedDisplayString("return new BigInteger(\"123456789012345678901234567890\");".toCharArray(), "123456789012345678901234567890".toCharArray());
- } finally {
- // clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Tests code snippet that include a type import and a package import.
- */
-public void testImportTypeAndPackage() {
- try {
- context.setImports(new char[][] {"java.util.Enumeration".toCharArray(), "java.lang.reflect.*".toCharArray()});
- evaluateWithExpectedDisplayString("Field[] fields = Enumeration.class.getDeclaredFields(); return fields.length;".toCharArray(), "0".toCharArray());
- } finally {
- // clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Tests code snippet that include an anonymous inner class.
- */
-public void testInnerClassAnonymous() {
- evaluateWithExpectedDisplayString(buildCharArray(new String[] {
- "return new Object() {",
- " public String toString() {",
- " return \"an inner class\";",
- " }",
- "};"}),
- "an inner class".toCharArray());
-}
-/**
- * Tests code snippet that include a named inner class.
- */
-public void testInnerClassNamed() {
- evaluateWithExpectedDisplayString(buildCharArray(new String[] {
- "class X {",
- " int foo = 1;",
- "}",
- "return new X().foo;"}),
- "1".toCharArray());
-}
-/**
- * Tests code snippet that include a package declaration.
- */
-public void testPackage() {
- // TBD: Test access to package private member
- // TBD: Test access to package class and members in anoother package than a java.* package
- try {
- // declare that the code snippet is run in java.util.zip and access a package private class
- context.setPackageName("java.util.zip".toCharArray());
- evaluateWithExpectedDisplayString("return ZipConstants.LOCSIG;".toCharArray(), "67324752".toCharArray());
- } finally {
- // clean up
- context.setPackageName(new char[0]);
- }
-}
-/**
- * Tests the return value display strings for a boolean.
- */
-public void testReturnDisplayStringBoolean() {
- evaluateWithExpectedDisplayString("return true;".toCharArray(), "true".toCharArray());
-}
-/**
- * Tests the return value display strings for a character.
- */
-public void testReturnDisplayStringCharacter() {
- evaluateWithExpectedDisplayString("return 'c';".toCharArray(), "c".toCharArray());
-}
-/**
- * Tests the return value display strings for a double.
- */
-public void testReturnDisplayStringDouble() {
- evaluateWithExpectedDisplayString("return 1.0;".toCharArray(), "1.0".toCharArray());
-}
-/**
- * Tests the return value display strings for no explicit returned value
- * because of an empty code snippet.
- */
-public void testReturnDisplayStringEmptyCodeSnippet() {
- evaluateWithExpectedDisplayString(new char[0], null);
-}
-/**
- * Tests the return value display strings for a float.
- */
-public void testReturnDisplayStringFloat() {
- evaluateWithExpectedDisplayString("return (float)1.0;".toCharArray(), "1.0".toCharArray());
-}
-/**
- * Tests the return value display strings for an integer.
- */
-public void testReturnDisplayStringInteger() {
- evaluateWithExpectedDisplayString("return 1;".toCharArray(), "1".toCharArray());
-}
-/**
- * Tests the return value display strings for a long.
- */
-public void testReturnDisplayStringLong() {
- evaluateWithExpectedDisplayString("return (long)1;".toCharArray(), "1".toCharArray());
-}
-/**
- * Tests the return value display strings for a code snippet
- * with no explicit returned value (implicitly the last expression is
- * wrapped inside a return statement).
- */
-public void testReturnDisplayStringNoExplicitReturnedValue() {
- evaluateWithExpectedDisplayString("new String(\"hello\".toCharArray());".toCharArray(), "hello".toCharArray());
-}
-/**
- * Tests the return value display strings for an object.
- */
-public void testReturnDisplayStringObject() {
- evaluateWithExpectedDisplayString(buildCharArray(new String[] {
- "return new Object() {",
- " public String toString() {",
- " return \"an object\";",
- " }",
- "};"}),
- "an object".toCharArray());
-}
-/**
- * Tests the return value display strings for a short.
- */
-public void testReturnDisplayStringShort() {
- evaluateWithExpectedDisplayString("return (short)1;".toCharArray(), "1".toCharArray());
-}
-/**
- * Tests the return value display strings for a String.
- */
-public void testReturnDisplayStringString() {
- evaluateWithExpectedDisplayString("return \"hello\";".toCharArray(), "hello".toCharArray());
-}
-/**
- * Tests the return value display strings for a code snippet
- * with a void returned value.
- */
-public void testReturnDisplayStringVoid() {
- evaluateWithExpectedDisplayString("new Thread().start()".toCharArray(), null);
-}
-/**
- * Tests the return type for a boolean.
- */
-public void testReturnTypeBoolean() {
- evaluateWithExpectedType("return true;".toCharArray(), "boolean".toCharArray());
-}
-/**
- * Tests the return type for a boolean array.
- */
-public void testReturnTypeBooleanArray() {
- evaluateWithExpectedType("return new boolean[] {true};".toCharArray(), "[Z".toCharArray());
-}
-/**
- * Tests the return type for a Boolean object.
- */
-public void testReturnTypeBooleanObject() {
- evaluateWithExpectedType("return new Boolean(true);".toCharArray(), "java.lang.Boolean".toCharArray());
-}
-/**
- * Tests the return type for a char.
- */
-public void testReturnTypeChar() {
- evaluateWithExpectedType("return 'c';".toCharArray(), "char".toCharArray());
-}
-/**
- * Tests the return type for a Character object.
- */
-public void testReturnTypeCharacterObject() {
- evaluateWithExpectedType("return new Character('c');".toCharArray(), "java.lang.Character".toCharArray());
-}
-/**
- * Tests the return type for a char array.
- */
-public void testReturnTypeCharArray() {
- evaluateWithExpectedType("return new char[] {'c'};".toCharArray(), "[C".toCharArray());
-}
-/**
- * Tests the return type for a double.
- */
-public void testReturnTypeDouble() {
- evaluateWithExpectedType("return 1.0;".toCharArray(), "double".toCharArray());
-}
-/**
- * Tests the return type for a double array.
- */
-public void testReturnTypeDoubleArray() {
- evaluateWithExpectedType("return new double[] {1.0};".toCharArray(), "[D".toCharArray());
-}
-/**
- * Tests the return type for a Double object.
- */
-public void testReturnTypeDoubleObject() {
- evaluateWithExpectedType("return new Double(1.0);".toCharArray(), "java.lang.Double".toCharArray());
-}
-/**
- * Tests the return type for an empty code snippet.
- */
-public void testReturnTypeEmptyCodeSnippet() {
- evaluateWithExpectedType(new char[0], null);
-}
-/**
- * Tests the return type for a float.
- */
-public void testReturnTypeFloat() {
- evaluateWithExpectedType("return (float)1.0;".toCharArray(), "float".toCharArray());
-}
-/**
- * Tests the return type for a float array.
- */
-public void testReturnTypeFloatArray() {
- evaluateWithExpectedType("return new float[] {(float)1.0};".toCharArray(), "[F".toCharArray());
-}
-/**
- * Tests the return type for a Float object.
- */
-public void testReturnTypeFloatObject() {
- evaluateWithExpectedType("return new Float(1.0);".toCharArray(), "java.lang.Float".toCharArray());
-}
-/**
- * Tests the return type for an int.
- */
-public void testReturnTypeInt() {
- evaluateWithExpectedType("return 1;".toCharArray(), "int".toCharArray());
-}
-/**
- * Tests the return type for an Integer object.
- */
-public void testReturnTypeIntegerObject() {
- evaluateWithExpectedType("return new Integer(1);".toCharArray(), "java.lang.Integer".toCharArray());
-}
-/**
- * Tests the return type for a long.
- */
-public void testReturnTypeLong() {
- evaluateWithExpectedType("return (long)1;".toCharArray(), "long".toCharArray());
-}
-/**
- * Tests the return type for a long array.
- */
-public void testReturnTypeLongArray() {
- evaluateWithExpectedType("return new long[] {(long)1};".toCharArray(), "[J".toCharArray());
-}
-/**
- * Tests the return type for a Long object.
- */
-public void testReturnTypeLongObject() {
- evaluateWithExpectedType("return new Long(1);".toCharArray(), "java.lang.Long".toCharArray());
-}
-/**
- * Tests the return type for no explicit returned value.
- */
-public void testReturnTypeNoExplicitReturnedValue() {
- evaluateWithExpectedType("new Object();".toCharArray(), "java.lang.Object".toCharArray());
-}
-/**
- * Tests the return type for an Object.
- */
-public void testReturnTypeObject() {
- evaluateWithExpectedType("return new Object();".toCharArray(), "java.lang.Object".toCharArray());
-}
-/**
- * Tests the return type for an Object array.
- */
-public void testReturnTypeObjectArray() {
- evaluateWithExpectedType("return new Object[] {new Object()};".toCharArray(), "[Ljava.lang.Object;".toCharArray());
-}
-/**
- * Tests the return type for a short.
- */
-public void testReturnTypeShort() {
- evaluateWithExpectedType("return (short)1;".toCharArray(), "short".toCharArray());
-}
-/**
- * Tests the return type for a short array.
- */
-public void testReturnTypeShortArray() {
- evaluateWithExpectedType("return new short[] {(short)1};".toCharArray(), "[S".toCharArray());
-}
-/**
- * Tests the return type for a Short object.
- */
-public void testReturnTypeShortObject() {
- evaluateWithExpectedType("return new Short((short)1);".toCharArray(), "java.lang.Short".toCharArray());
-}
-/**
- * Tests the return type for an int array.
- */
-public void testReturnTypesIntArray() {
- evaluateWithExpectedType("return new int[] {1};".toCharArray(), "[I".toCharArray());
-}
-/**
- * Tests the return type for a String.
- */
-public void testReturnTypeString() {
- evaluateWithExpectedType("return \"hello\";".toCharArray(), "java.lang.String".toCharArray());
-}
-/**
- * Tests the return type for a String array.
- */
-public void testReturnTypeStringArray() {
- evaluateWithExpectedType("return new String[] {\"hello\"};".toCharArray(), "[Ljava.lang.String;".toCharArray());
-}
-/**
- * Tests the return type for a void value.
- */
-public void testReturnTypeVoid() {
- evaluateWithExpectedType("new Thread().start()".toCharArray(), null);
-}
-/**
- * Tests that the run() method defined in an anonymous class doesn't interfer with the
- * code snippet support (see PR #1G1C0HR).
- */
-public void testRunMethodInAnonymous() {
- evaluateWithExpectedDisplayString(buildCharArray(new String[] {
- "class X {",
- " public int i = 0;",
- " public boolean finished = false;",
- "}",
- "final X x = new X();",
- "(new Thread() {",
- " public void run() {",
- " for (int i=0;i<10;i++) {",
- " try {",
- " Thread.currentThread().sleep(10);",
- " } catch (InterruptedException e) {",
- " }",
- " x.i++;",
- " }",
- " x.finished = true;",
- " }",
- "}).start();",
- "while (!x.finished) Thread.currentThread().sleep(100);",
- "x.i"}),
- "10".toCharArray());
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationSetup.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationSetup.java
deleted file mode 100644
index aecf30e..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationSetup.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestSuite;
-
-
-import org.eclipse.jdt.core.tests.runtime.LocalVMLauncher;
-import org.eclipse.jdt.core.tests.runtime.TargetException;
-import org.eclipse.jdt.core.tests.runtime.TargetInterface;
-import org.eclipse.jdt.core.tests.util.Util;
-import org.eclipse.jdt.internal.compiler.batch.FileSystem;
-import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.internal.eval.EvaluationContext;
-
-import com.sun.jdi.VirtualMachine;
-import com.sun.jdi.VirtualMachineManager;
-import com.sun.jdi.connect.AttachingConnector;
-import com.sun.jdi.connect.Connector;
-import com.sun.jdi.connect.IllegalConnectorArgumentsException;
-
-public class DebugEvaluationSetup extends EvaluationSetup {
-public DebugEvaluationSetup(junit.framework.Test test) {
- super(test);
-}
-protected void initTest(Object test, VirtualMachine jdiVM) {
- if (test instanceof DebugEvaluationTest) {
- DebugEvaluationTest evalTest = (DebugEvaluationTest)test;
- evalTest.jdiVM = jdiVM;
- return;
- }
- if (test instanceof TestSuite) {
- TestSuite evaluationTestClassSuite = (TestSuite) test;
- Enumeration evaluationTestClassTests = evaluationTestClassSuite.tests();
- while (evaluationTestClassTests.hasMoreElements()) {
- initTest(evaluationTestClassTests.nextElement(), jdiVM);
- }
- return;
- }
-
-}
-protected void setUp() {
- // Launch VM in evaluation mode
- int debugPort = Util.nextAvailablePortNumber();
- int evalPort = Util.nextAvailablePortNumber();
- LocalVMLauncher launcher;
- try {
- launcher = LocalVMLauncher.getLauncher();
- launcher.setVMArguments(new String[] {"-verify"});
- launcher.setVMPath(this.jrePath);
- launcher.setEvalPort(evalPort);
- launcher.setEvalTargetPath(this.evalDirectory);
- launcher.setDebugPort(debugPort);
- this.launchedVM = launcher.launch();
- } catch (TargetException e) {
- throw new Error(e.getMessage());
- }
-
- // Thread that read the stout of the VM so that the VM doesn't block
- try {
- startReader("VM's stdout reader", this.launchedVM.getInputStream());
- } catch (TargetException e) {
- }
-
- // Thread that read the sterr of the VM so that the VM doesn't block
- try {
- startReader("VM's sterr reader", this.launchedVM.getErrorStream());
- } catch (TargetException e) {
- }
-
- // Start JDI connection (try 10 times)
- VirtualMachine vm = null;
- for (int i = 0; i < 10; i++) {
- try {
- VirtualMachineManager manager = org.eclipse.jdi.Bootstrap.virtualMachineManager();
- List connectors = manager.attachingConnectors();
- if (connectors.size() == 0)
- break;
- AttachingConnector connector = (AttachingConnector)connectors.get(0);
- Map args = connector.defaultArguments();
- ((Connector.Argument)args.get("port")).setValue(String.valueOf(debugPort));
- ((Connector.Argument)args.get("hostname")).setValue(launcher.getTargetAddress());
- vm = connector.attach(args);
-
- // workaround pb with some VMs
- vm.resume();
-
- break;
- } catch (IllegalConnectorArgumentsException e) {
- } catch (IOException e) {
- System.out.println("Got exception: " + e.getMessage());
- try {
- System.out.println("Could not contact the VM at " + launcher.getTargetAddress() + ":" + debugPort + ". Retrying...");
- Thread.sleep(100);
- } catch (InterruptedException e2) {
- }
- }
- }
- if (vm == null) {
- if (this.launchedVM != null) {
- // If the VM is not running, output error stream
- try {
- if (!this.launchedVM.isRunning()) {
- InputStream in = this.launchedVM.getErrorStream();
- int read;
- do {
- read= in.read();
- if (read != -1)
- System.out.print((char) read);
- } while (read != -1);
- }
- } catch (TargetException e) {
- } catch (IOException e) {
- }
-
- // Shut it down
- try {
- target.disconnect(); // Close the socket first so that the OS resource has a chance to be freed.
- int retry = 0;
- while (launchedVM.isRunning() && (++retry < 20)) {
- try {
- Thread.sleep(retry * 100);
- } catch (InterruptedException e) {
- }
- }
- if (launchedVM.isRunning()) {
- launchedVM.shutDown();
- }
- } catch (TargetException e) {
- }
- }
- throw new Error("Could not contact the VM");
- }
-
- // Create context
- this.context = new EvaluationContext();
-
- // Create target
- this.target = new TargetInterface();
- this.target.connect("localhost", evalPort, 10000);
-
- // Create name environment
- INameEnvironment env = new FileSystem(new String[] {Util.getJavaClassLib()}, new String[0], null);
-
- // Init wrapped suite
- initTest(fTest, this.context, this.target, this.launchedVM, env);
- initTest(fTest, vm);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java
deleted file mode 100644
index 2c41171..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/DebugEvaluationTest.java
+++ /dev/null
@@ -1,3763 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Map;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.core.tests.runtime.LocalVMLauncher;
-import org.eclipse.jdt.core.tests.runtime.TargetInterface;
-import org.eclipse.jdt.core.tests.util.Util;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.eval.EvaluationResult;
-import org.eclipse.jdt.internal.eval.InstallException;
-
-import com.sun.jdi.VirtualMachine;
-
-public class DebugEvaluationTest extends EvaluationTest {
- VirtualMachine jdiVM;
- public JDIStackFrame jdiStackFrame;
- class DebugRequestor extends Requestor {
- public boolean acceptClassFiles(org.eclipse.jdt.internal.compiler.ClassFile[] classFiles, char[] codeSnippetClassName) {
- if (jdiStackFrame == null) {
- return super.acceptClassFiles(classFiles, codeSnippetClassName);
- } else {
- // Send but don't run
- super.acceptClassFiles(classFiles, null);
-
- // Run if needed
- if (codeSnippetClassName != null) {
- boolean success = jdiStackFrame.run(new String(codeSnippetClassName));
- if (success) {
- TargetInterface.Result result = target.getResult();
- if (result.displayString == null) {
- this.acceptResult(new EvaluationResult(null, EvaluationResult.T_CODE_SNIPPET, null, null));
- } else {
- this.acceptResult(new EvaluationResult(null, EvaluationResult.T_CODE_SNIPPET, result.displayString, result.typeName));
- }
- }
- return success;
- } else {
- return true;
- }
- }
- }
- }
-public DebugEvaluationTest(String name) {
- super(name);
-}
-public void compileAndDeploy(String source, String className) {
- resetEnv(); // needed to reinitialize the caches
- File directory = new File(SOURCE_DIRECTORY);
- if (!directory.exists()) {
- if (!directory.mkdir()) {
- System.out.println("Could not create " + SOURCE_DIRECTORY);
- return;
- }
- }
- String fileName = SOURCE_DIRECTORY + File.separator + className + ".java";
- try {
- BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));
- writer.write(source);
- writer.flush();
- writer.close();
- } catch(IOException e) {
- e.printStackTrace();
- return;
- }
- StringBuffer buffer = new StringBuffer();
- buffer
- .append("\"")
- .append(fileName)
- .append("\" -d \"")
- .append(EVAL_DIRECTORY + File.separator + LocalVMLauncher.REGULAR_CLASSPATH_DIRECTORY)
- .append("\" -nowarn -g -classpath \"")
- .append(Util.getJavaClassLib())
- .append(";")
- .append(SOURCE_DIRECTORY)
- .append("\"");
- org.eclipse.jdt.internal.compiler.batch.Main.compile(buffer.toString());
-}
-/**
- * Generate local variable attribute for these tests.
- */
-public Map getOptions() {
- Map options = super.getOptions();
- options.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
- options.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.PRESERVE);
- return options;
-}
-public void removeTempClass(String className) {
- resetEnv(); // needed to reinitialize the caches
- File sourceFile = new File(SOURCE_DIRECTORY + File.separator + className + ".java");
- sourceFile.delete();
-
- File binaryFile = new File(EVAL_DIRECTORY + File.separator + LocalVMLauncher.REGULAR_CLASSPATH_DIRECTORY + File.separator + className + ".class");
-
- binaryFile.delete();
-}
-public static Test setupSuite(Class clazz) {
- EvaluationSetup evalSetup = new DebugEvaluationSetup(suite(clazz));
- evalSetup.jrePath = JRE_PATH;
- evalSetup.evalDirectory = EVAL_DIRECTORY;
- return evalSetup;
-}
-public static Test suite() {
- return setupSuite(testClass());
-}
-/*public static Test suite(Class evaluationTestClass) {
- TestSuite suite = new TestSuite();
- suite.addTest(new DebugEvaluationTest("test023"));
- return suite;
-}*/
-/**
- * Sanity test of IEvaluationContext.evaluate(char[], char[][], char[][], int[], char[], boolean, boolean, IRunner, INameEnvironment, ConfigurableOption[], IRequestor , IProblemFactory)
- */
-public void test001() {
- String userCode =
- "";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return 1;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "1".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
-}
-/**
- * Return 'this'.
- */
-public void test002() {
- try {
- String sourceA002 =
- "public class A002 {\n" +
- " public int foo() {\n" +
- " return 2;\n" +
- " }\n" +
- " public String toString() {\n" +
- " return \"hello\";\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA002, "A002");
- String userCode =
- "new A002().foo();";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A002",
- "foo",
- -1);
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return this;".toCharArray();
- try {
- context.evaluate(
- snippet,
- null, // local var type names
- null, // local var names
- null, // local modifiers
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "hello".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "A002".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A002");
- }
-}
-/**
- * Return 'this'.
- */
-public void test003() {
- try {
- String sourceA003 =
- "public class A003 {\n" +
- " public int foo() {\n" +
- " return 2;\n" +
- " }\n" +
- " public String toString() {\n" +
- " return \"hello\";\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA003, "A003");
- String userCode =
- "new A003().foo();";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A003",
- "foo",
- -1);
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return this;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- null, // declaring type -- NO DELEGATE THIS
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should have a problem", result.hasProblems()); // 'this' cannot be referenced since there is no declaring type
- assertTrue("Result should not have a value", !result.hasValue());
- } finally {
- removeTempClass("A003");
- }
-}
-/**
- * Return 'thread'.
- */
-public void test004() {
- String userCode =
- "java.lang.Thread thread = new Thread() {\n" +
- " public String toString() {\n" +
- " return \"my thread\";\n" +
- " }\n" +
- "};";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return thread;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "my thread".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "java.lang.Thread".toCharArray(), result.getValueTypeName());
-}
-/**
- * Return 'x'.
- */
-public void test005() {
- try {
- String sourceA005 =
- "public class A005 {\n" +
- " public int x = 0;\n" +
- " public int foo() {\n" +
- " x++;\n" + // workaround pb with JDK 1.4.1 that doesn't stop if only return
- " return x;\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA005, "A005");
- String userCode =
- "new A005().foo();";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A005",
- "foo",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return x;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "0".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A005");
- }
-}
-/**
- * Return 'x' + new Object(){ int foo(){ return 17; }}.foo();
- */
-public void test006() {
- try {
- String sourceA006 =
- "public class A006 {\n" +
- " public int x = 0;\n" +
- " public int foo() {\n" +
- " x++;\n" + // workaround pb with JDK 1.4.1 that doesn't stop if only return
- " return x;\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA006, "A006");
- String userCode =
- "new A006().foo();";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A006",
- "foo",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return x + new Object(){ int foo(){ return 17; }}.foo();".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "17".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A006");
- }
-}
-/**
- * Return a static field.
- */
-public void test007() {
- try {
- String sourceA007 =
- "public class A007 {\n" +
- " public static int X = 1;\n" +
- " public int foo() {\n" +
- " X++;\n" + // workaround pb with JDK 1.4.1 that doesn't stop if only return
- " return X;\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA007, "A007");
- String userCode =
- "new A007().foo();";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A007",
- "foo",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return X;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "1".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A007");
- }
-}
-/**
- * Return x + new Object(){ int foo(int x){ return x; }}.foo(14);
- */
-public void test008() {
- try {
- String sourceA008 =
- "public class A008 {\n" +
- " public int x = 0;\n" +
- " public int foo() {\n" +
- " x++;\n" + // workaround pb with JDK 1.4.1 that doesn't stop if only return
- " return x;\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA008, "A008");
- String userCode =
- "new A008().foo();";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A008",
- "foo",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return x + new Object(){ int foo(int x){ return x; }}.foo(14);".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "14".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A008");
- }
-}
-/**
- * Free return of local variable 's'.
- */
-public void test009() {
- String userCode =
- "String s = \"test009\";\n";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "s".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "test009".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "java.lang.String".toCharArray(), result.getValueTypeName());
-}
-/**
- * Return 'this'.
- */
-public void test010() {
- try {
- String sourceA010 =
- "public class A010 {\n" +
- " public int foo() {\n" +
- " new Object().toString();\n" + // workaround pb with JDK 1.4.1 that doesn't stop if only return
- " return -1;\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA010, "A010");
- String userCode =
- "A010 a = new A010() {\n" +
- " public String toString() {\n" +
- " return \"my object\";\n" +
- " }\n" +
- "};\n" +
- "a.foo();";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A010",
- "foo",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return this;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "my object".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "A010".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A010");
- }
-}
-/**
- * Return local variable 'v'.
- */
-public void test011() {
- String userCode =
- "String s = \"s\";\n" +
- "java.util.Vector v = new java.util.Vector();\n" +
- "v.addElement(s);\n";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return v;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "[s]".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "java.util.Vector".toCharArray(), result.getValueTypeName());
-}
-/**
- * Set local variable 'date'.
- */
-public void test012() {
- String userCode =
- "java.util.GregorianCalendar cal = new java.util.GregorianCalendar();\n" +
- "java.util.Date date = cal.getGregorianChange();\n" +
- "date.toString();";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "date = new java.util.Date();".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- requestor = new DebugRequestor();
- snippet = "return date.after(cal.getGregorianChange());".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "true".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "boolean".toCharArray(), result.getValueTypeName());
-}
-/**
- * Set local variable 'i'.
- */
-public void test013() {
- String userCode = "int i = 0;";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "i = -1;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- requestor = new DebugRequestor();
- snippet = "return i != 0;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "true".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "boolean".toCharArray(), result.getValueTypeName());
-}
-/**
- * Set local variable 'i'.
- */
-public void test014() {
- String userCode = "int i = 0;";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "i++;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- requestor = new DebugRequestor();
- snippet = "return i!= 0;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "true".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "boolean".toCharArray(), result.getValueTypeName());
-}
-/**
- * Check java.lang.System.out != null
- */
-public void test015() {
- String userCode = "int i = 0;";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "java.lang.System.setOut(new java.io.PrintStream(new java.io.OutputStream()));".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
-
- requestor = new DebugRequestor();
- snippet = "return java.lang.System.out != null;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "true".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "boolean".toCharArray(), result.getValueTypeName());
-}
-/**
- * Check java.lang.System.out == null
- */
-public void test016() {
- String userCode = "";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "java.lang.System.setOut(null);".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- requestor = new DebugRequestor();
- snippet = "return java.lang.System.out == null;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "true".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "boolean".toCharArray(), result.getValueTypeName());
-}
-/**
- * Check the third prime number is 5
- */
-public void test017() {
- String userCode = "";
-
- JDIStackFrame stackFrame = new JDIStackFrame(this.jdiVM, this, userCode);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet =
- ("class Eratosthenes {\n"
- + " int[] primeNumbers;\n"
- + "\n"
- + " public Eratosthenes(int n) {\n"
- + " primeNumbers = new int[n + 1];\n"
- + "\n"
- + " for (int i = 2; i <= n; i++) {\n"
- + " primeNumbers[i] = i;\n"
- + " }\n"
- + " int p = 2;\n"
- + " while (p * p <= n) {\n"
- + " int j = 2 * p;\n"
- + " while (j <= n) {\n"
- + " primeNumbers[j] = 0;\n"
- + " j += p;\n"
- + " }\n"
- + " do {\n"
- + " p++;\n"
- + " } while (primeNumbers[p] == 1);\n"
- + " }\n"
- + " }\n"
- + "}\n"
- + "int[] primes = new Eratosthenes(10).primeNumbers;\n"
- + "int i = 0;\n"
- + "int max = primes.length;\n"
- + "int j = 0;\n"
- + "for (; i < max && j != 3; i++) {\n"
- + " if (primes[i] != 0) {\n"
- + " j++;\n"
- + " }\n"
- + "}\n"
- + "return primes[i-1];").toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "5".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
-}
-/**
- * changing the value of a public field
- */
-public void test018() {
- try {
- String sourceA018 =
- "public class A018 {\n" +
- " public int x = 1;\n" +
- " public int foo() {\n" +
- " x++;\n" + // workaround pb with JDK 1.4.1 that doesn't stop if only return
- " return x;\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA018, "A018");
- String userCode =
- "new A018().foo();";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A018",
- "foo",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "x = 5;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- requestor = new DebugRequestor();
- snippet = "return x;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "5".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A018");
- }
-}
-/**
- * Access to super reference
- */
-public void test019() {
-/* try {
- String sourceA019 =
- "public class A019 {\n" +
- " public int x = 1;\n" +
- " public int foo() {\n" +
- " x++;\n" + // workaround pb with JDK 1.4.1 that doesn't stop if only return
- " return x;\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA019, "A019");
- String userCode =
- "new A019().foo();";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A019",
- "foo",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return super.clone().equals(this);".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Should get one result but got " + requestor.resultIndex+1, requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "true".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "boolean".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A019");
- }
-*/
-}
-/**
- * Implicit message expression
- */
-public void test020() {
- try {
- String sourceA =
- "public class A {\n"
- + "\tObject o = null;\n"
- + "\tpublic int foo() {\n"
- + "\t\treturn 2;\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "\tpublic Object bar2() {\n"
- + "\t\treturn new Object();\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA, "A");
-
- String userCode = "new A().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return foo();".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A");
- }
-}
-/**
- * Implicit message expression
- */
-public void test021() {
- try {
- String sourceA21 =
- "public class A21 {\n"
- + "\tObject o = null;\n"
- + "\tpublic int foo() {\n"
- + "\t\treturn 2;\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "\tpublic Object bar2() {\n"
- + "\t\treturn \"toto\";\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA21, "A21");
-
- String userCode = "new A21().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A21",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "o = bar2();".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- requestor = new DebugRequestor();
- snippet = "return o;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "toto".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "java.lang.Object".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A21");
- }
-}
-/**
- * Qualified Name Reference: b.s
- */
-public void test022() {
- try {
- String sourceB22 =
- "public class B22 {\n"
- + "\tpublic String s = null;\n"
- + "}";
- compileAndDeploy(sourceB22, "B22");
-
- String sourceA22 =
- "public class A22 {\n"
- + "\tpublic B22 b = new B22();\n"
- + "\tpublic int foo() {\n"
- + "\t\treturn 2;\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "\tpublic Object bar2() {\n"
- + "\t\treturn \"toto\";\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA22, "A22");
-
- String userCode = "new A22().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A22",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "b.s = \"toto\"".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
-
- requestor = new DebugRequestor();
- snippet = "return b.s;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "toto".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "java.lang.String".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("B22");
- removeTempClass("A22");
- }
-}
-/**
- * Qualified Name Reference: b.c.c
- */
-public void test023() {
- try {
- String sourceC23 =
- "public class C23 {\n"
- + "\tpublic String c = null;\n"
- + "}";
- compileAndDeploy(sourceC23, "C23");
-
-
- String sourceB23 =
- "public class B23 {\n"
- + "\tpublic C23 c = new C23();\n"
- + "}";
- compileAndDeploy(sourceB23, "B23");
-
- String sourceA23 =
- "public class A23 {\n"
- + "\tpublic B23 b = new B23();\n"
- + "\tpublic int foo() {\n"
- + "\t\treturn 2;\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "\tpublic Object bar2() {\n"
- + "\t\treturn \"toto\";\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA23, "A23");
-
- String userCode = "new A23().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A23",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "b.c.c = \"toto\"".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
-
- requestor = new DebugRequestor();
- snippet = "return b.c.c;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "toto".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "java.lang.String".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("C23");
- removeTempClass("B23");
- removeTempClass("A23");
- }
-}
-/**
- * Array Reference
- */
-public void test024() {
- try {
- String sourceC24 =
- "public class C24 {\n"
- + "\tpublic int[] tab = {1,2,3,4,5};\n"
- + "}";
- compileAndDeploy(sourceC24, "C24");
-
-
- String sourceB24 =
- "public class B24 {\n"
- + "\tpublic C24 c = new C24();\n"
- + "}";
- compileAndDeploy(sourceB24, "B24");
-
- String sourceA24 =
- "public class A24 {\n"
- + "\tpublic B24 b = new B24();\n"
- + "\tpublic int foo() {\n"
- + "\t\treturn 2;\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "\tpublic Object bar2() {\n"
- + "\t\treturn \"toto\";\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA24, "A24");
-
- String userCode = "new A24().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A24",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "b.c.tab[3] = 8".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
-
- requestor = new DebugRequestor();
- snippet = "return b.c.tab[3];".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "8".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("C24");
- removeTempClass("B24");
- removeTempClass("A24");
- }
-}
-/**
- * Array Reference
- */
-public void test025() {
- try {
- String sourceA25 =
- "public class A25 {\n"
- + "\tpublic String[] tabString = new String[2];\n"
- + "\tpublic int foo() {\n"
- + "\t\treturn 2;\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "\tpublic Object bar2() {\n"
- + "\t\treturn \"toto\";\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA25, "A25");
-
- String userCode = "new A25().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A25",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "tabString[1] = \"toto\"".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
-
- requestor = new DebugRequestor();
- snippet = "return tabString[1];".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "toto".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "java.lang.String".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A25");
- }
-}
-/**
- * Array Reference
- */
-public void test026() {
- try {
- String sourceA26 =
- "public class A26 {\n"
- + "\tpublic int foo() {\n"
- + "\t\treturn 2;\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA26, "A26");
-
- String userCode = "new A26().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A26",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet =
- ("int[] tab = new int[1];\n"
- + "tab[0] = foo();\n"
- + "tab[0]").toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A26");
- }
-}
-/**
- * Array Reference
- */
-public void test027() {
- try {
- String sourceA27 =
- "public class A27 {\n"
- + "\tpublic int foo() {\n"
- + "\t\treturn 2;\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "\tpublic int bar2(int i) {\n"
- + "\t\tif (i == 2) {\n"
- + "\t\t\treturn 3;\n"
- + "\t\t} else {\n"
- + "\t\t\treturn 4;\n"
- + "\t\t}\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA27, "A27");
-
- String userCode = "new A27().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A27",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet =
- ("int[] tab = new int[] { 1, 2, 3, 4, 5};\n"
- + "switch(foo()) {\n"
- + "case 1 : return -1;\n"
- + "case 2 : return tab[bar2(foo())];\n"
- + "default: return -5;}").toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "4".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A27");
- }
-}
-/**
- * Array Reference
- */
-public void test028() {
- try {
- String sourceA28 =
- "public class A28 {\n"
- + "\tpublic int foo() {\n"
- + "\t\treturn 2;\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "\tpublic int bar2(int i) {\n"
- + "\t\tif (i == 2) {\n"
- + "\t\t\treturn 3;\n"
- + "\t\t} else {\n"
- + "\t\t\treturn 4;\n"
- + "\t\t}\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA28, "A28");
-
- String userCode = "new A28().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A28",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet =
- ("int[] tab = new int[] { 1, 2, 3, 4, 5};\n"
- + "int i =3;\n"
- + "switch(foo()) {\n"
- + "case 0 : return -1;\n"
- + "case 1 : return tab[bar2(foo())];\n"
- + "}\n"
- + "return tab[i++];").toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "4".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A28");
- }
-}
-/**
- * Array Reference
- */
-public void test029() {
- try {
- String sourceA29 =
- "public class A29 {\n"
- + "\tpublic int foo() {\n"
- + "\t\treturn 2;\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "\tpublic int bar2(int i) {\n"
- + "\t\tif (i == 2) {\n"
- + "\t\t\treturn 3;\n"
- + "\t\t} else {\n"
- + "\t\t\treturn 4;\n"
- + "\t\t}\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA29, "A29");
-
- String userCode = "new A29().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A29",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet =
- ("int[] tab = new int[] { 1, 2, 3, 4, 5};\n"
- + "int i =3;\n"
- + "switch(foo()) {\n"
- + "case 0 : return -1;\n"
- + "case 1 : return tab[bar2(foo())];\n"
- + "}\n"
- + "return tab[++i];").toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "5".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A29");
- }
-}
-/**
- * Array Reference: ArrayIndexOutOfBoundException
- */
-public void test030() {
- try {
- String sourceA30 =
- "public class A30 {\n"
- + "\tpublic int foo() {\n"
- + "\t\treturn 2;\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "\tpublic int bar2(int i) {\n"
- + "\t\tif (i == 2) {\n"
- + "\t\t\treturn 3;\n"
- + "\t\t} else {\n"
- + "\t\t\treturn 4;\n"
- + "\t\t}\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA30, "A30");
-
- String userCode = "new A30().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A30",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet =
- ("try {\n"
- + "int[] tab = new int[] { 1, 2, 3, 4};\n"
- + "int i =3;\n"
- + "switch(foo()) {\n"
- + "case 0 : return -1;\n"
- + "case 1 : return tab[bar2(foo())];\n"
- + "}\n"
- + "return tab[++i];"
- + "} catch(ArrayIndexOutOfBoundsException e) {\n"
- + "return -2;\n"
- + "}").toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("One targetException : ArrayIndexOutOfBoundsException " + e.getMessage(), true);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "-2".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A30");
- }
-}
-/**
- * Read access to an instance private member of the enclosing class
- */
-public void test031() {
- try {
- String sourceA31 =
- "public class A31 {\n"
- + "\tprivate int i = 2;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA31, "A31");
-
- String userCode = "new A31().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A31",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return i;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A31");
- }
-}
-/**
- * Read access to a instance private member of the class different from the enclosing class
- */
-public void test032() {
- try {
- String sourceA32 =
- "public class A32 {\n"
- + "\tprivate int i = 2;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA32, "A32");
-
- String sourceB32 =
- "public class B32 {\n"
- + "\tprivate int j = 2;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceB32, "B32");
-
- String userCode = "new A32().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A32",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return new B32().j;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", result.hasProblems());
- IProblem[] problems = result.getProblems();
- StringBuffer buffer = null;
- for (int i = 0, max = problems.length; i < max; i++){
- if (problems[i].isError()){
- if (buffer == null) buffer = new StringBuffer(10);
- buffer.append(problems[i].getMessage());
- buffer.append('|');
- }
- }
- assertEquals("Unexpected errors",
- "The field j is not visible|",
- buffer == null ? "none" : buffer.toString());
- } finally {
- removeTempClass("B32");
- removeTempClass("A32");
- }
-}
-/**
- * Read access to an instance private member of the enclosing class
- */
-public void test033() {
- try {
- String sourceA33 =
- "public class A33 {\n"
- + "\tprivate long l = 2000000L;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA33, "A33");
-
- String userCode = "new A33().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A33",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet =
- ("try {\n" +
- "Class c = Class.forName(\"A33\");\n" +
- "java.lang.reflect.Field field = c.getDeclaredField(\"l\");\n" +
- "field.setAccessible(true);\n" +
- "Object o = c.newInstance();\n" +
- "System.out.println(field.getInt(o));\n" +
- "} catch(Exception e) {}\n" +
- "return l;").toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2000000".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "long".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A33");
- }
-}
-/**
- * Write access to an instance private member of the enclosing class
- */
-public void test034() {
- try {
- String sourceA34 =
- "public class A34 {\n"
- + "\tprivate long l = 2000000L;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA34, "A34");
-
- String userCode = "new A34().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A34", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet =
- ("l = 100L;\n" +
- "return l;").toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "100".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "long".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A34");
- }
-}
-/**
- * Read access to a static private member of the enclosing class
- */
-public void test035() {
- try {
- String sourceA35 =
- "public class A35 {\n"
- + "\tstatic private int i = 2;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA35, "A35");
-
- String userCode = "new A35().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "A35",
- "bar",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return i;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A35");
- }
-}
-/**
- * Coumpound assignement to an instance private member of the enclosing class
- */
-public void test036() {
- try {
- String sourceA36 =
- "public class A36 {\n"
- + "\tprivate long l = 2000000L;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA36, "A36");
-
- String userCode = "new A36().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A36", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet =
- ("l+=4;\n" +
- "return l;").toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2000004".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "long".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A36");
- }
-}
-/**
- * Coumpound assignement to an instance private member of the enclosing class
- */
-public void test037() {
- try {
- String sourceA37 =
- "public class A37 {\n"
- + "\tprivate long l = 2000000L;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA37, "A37");
-
- String userCode = "new A37().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A37", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet =
- ("l++;\n" +
- "return l;").toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2000001".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "long".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A37");
- }
-}
-/**
- * Coumpound assignement to an instance private member of the enclosing class
- */
-public void test038() {
- try {
- String sourceA38 =
- "public class A38 {\n"
- + "\tprivate long l = 2000000L;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA38, "A38");
-
- String userCode = "new A38().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A38", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return l++;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2000000".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "long".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A38");
- }
-}
-/**
- * Coumpound assignement to an static private member of the enclosing class
- */
-public void test039() {
- try {
- String sourceA39 =
- "public class A39 {\n"
- + "\tstatic private int i = 2;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA39, "A39");
-
- String userCode = "new A39().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A39", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return A39.i;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A39");
- }
-}
-/**
- * Coumpound assignement to an static private member of the enclosing class
- */
-public void test040() {
- try {
- String sourceA40 =
- "public class A40 {\n"
- + "\tstatic private int[] tab = new int[] {1, 2};\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA40, "A40");
-
- String userCode = "new A40().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A40", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return A40.tab.length;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A40");
- }
-}
-/**
- * Coumpound assignement to an static private final member of the enclosing class
- */
-public void test041() {
- try {
- String sourceA41 =
- "public class A41 {\n"
- + "\tstatic private final int[] tab = new int[] {1, 2};\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA41, "A41");
-
- String userCode = "new A41().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A41", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return A41.tab.length;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A41");
- }
-}
-/**
- * Coumpound assignement to an static private final member of the enclosing class
- */
-public void test042() {
- try {
- String sourceA42 =
- "public class A42 {\n"
- + "\tstatic private int Counter = 0;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA42, "A42");
-
- String userCode = "new A42().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A42", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return ++A42.Counter;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "1".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A42");
- }
-}
-/**
- * Coumpound assignement to an static private final member of the enclosing class
- */
-public void test043() {
- try {
- String sourceA43 =
- "public class A43 {\n"
- + "\tstatic private int Counter = 0;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA43, "A43");
-
- String userCode = "new A43().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A43", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "A43.Counter++; return A43.Counter;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "1".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A43");
- }
-}
-/**
- * Coumpound assignement to an static private final member of the enclosing class
- */
-public void test044() {
- try {
- String sourceA44 =
- "public class A44 {\n"
- + "\tstatic private int Counter = 0;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA44, "A44");
-
- String userCode = "new A44().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A44", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "int j = A44.Counter++; return A44.Counter + j;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "1".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A44");
- }
-}
-/**
- * Coumpound assignement to an static private final member of the enclosing class
- */
-public void test045() {
- try {
- String sourceA45 =
- "public class A45 {\n"
- + "\tstatic private int Counter = 0;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA45, "A45");
-
- String userCode = "new A45().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A45", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "int j = ++A45.Counter; return A45.Counter + j;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A45");
- }
-}
-/**
- * Coumpound assignement to an static protected final member of the enclosing class
- */
-public void test046() {
- try {
- String sourceA46 =
- "public class A46 {\n"
- + "\tstatic protected int Counter = 0;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA46, "A46");
-
- String userCode = "new A46().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A46", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "int j = ++A46.Counter; return A46.Counter + j;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A46");
- }
-}
-/**
- * Return the value of a private static field throught a private static field
- */
-public void test047() {
- try {
- String sourceA47 =
- "public class A47 {\n"
- + "\tstatic private A47 instance = new A47();\n"
- + "\tstatic private int Counter = 2;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA47, "A47");
-
- String userCode = "new A47().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A47", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return A47.instance.Counter;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A47");
- }
-}
-/**
- * Return the value of a private static field throught a private static field
- * Using private field emulation on a field reference.
- */
-public void test048() {
- try {
- String sourceA48 =
- "public class A48 {\n"
- + "\tstatic private A48 instance = new A48();\n"
- + "\tstatic private int Counter = 2;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA48, "A48");
-
- String userCode = "new A48().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A48", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return new A48().instance.Counter;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A48");
- }
-}
-/**
- * Compound assignment of a private field.
- * Using private field emulation on a field reference.
- */
-public void test049() {
- try {
- String sourceA49 =
- "public class A49 {\n"
- + "\tstatic private A49 instance = new A49();\n"
- + "\tstatic private int Counter = 2;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA49, "A49");
-
- String userCode = "new A49().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A49", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return ++(new A49().Counter);".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "3".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A49");
- }
-}
-/**
- * Compound assignment of a private field.
- * Using private field emulation on a field reference.
- */
-public void test050() {
- try {
- String sourceA50 =
- "public class A50 {\n"
- + "\tstatic private A50 instance = new A50();\n"
- + "\tstatic private int Counter = 2;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA50, "A50");
-
- String userCode = "new A50().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A50", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "A50 a = new A50(); a.Counter = 5; return a.Counter;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "5".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A50");
- }
-}
-/**
- * Assignment of a private field.
- * Using private field emulation on a field reference.
- */
-public void test051() {
- try {
- String sourceA51 =
- "public class A51 {\n"
- + "\tstatic private A51 instance = new A51();\n"
- + "\tstatic private int Counter = 2;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA51, "A51");
-
- String userCode = "new A51().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A51", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "Counter = 5; return Counter;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "5".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A51");
- }
-}
-/**
- * Assignment of a private field.
- * Using private field emulation on a field reference.
- */
-public void test052() {
- try {
- String sourceA52 =
- "public class A52 {\n"
- + "\tstatic private A52 instance = new A52();\n"
- + "\tstatic private int Counter = 2;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA52, "A52");
-
- String userCode = "new A52().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A52", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "this.Counter = 5; return this.Counter;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "5".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A52");
- }
-}
-/**
- * Post assignement of a private field.
- * Using private field emulation on a field reference.
- */
-public void test053() {
- try {
- String sourceA53 =
- "public class A53 {\n"
- + "\tstatic private A53 instance = new A53();\n"
- + "\tstatic private int Counter = 2;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA53, "A53");
-
- String userCode = "new A53().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A53", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "this.Counter++; return this.Counter;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "3".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A53");
- }
-}
-/**
- * Post assignement of a private field.
- * Using private field emulation on a field reference.
- */
-public void test054() {
- try {
- String sourceA54 =
- "public class A54 {\n"
- + "\tstatic private A54 instance = new A54();\n"
- + "\tstatic private long Counter = 2L;\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA54, "A54");
-
- String userCode = "new A54().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A54", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "this.Counter++; return this.Counter;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "3".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "long".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A54");
- }
-}
-/**
- * Read access to a private method.
- */
-public void test055() {
- try {
- String sourceA55 =
- "public class A55 {\n"
- + "\tprivate int foo() {;\n"
- + "\t\treturn 3;\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA55, "A55");
-
- String userCode = "new A55().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A55", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return foo();".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "3".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A55");
- }
-}
-/**
- * Read access to a private method.
- */
-public void test056() {
- try {
- String sourceA56 =
- "public class A56 {\n"
- + "\tprivate Integer foo() {;\n"
- + "\t\treturn new Integer(3);\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA56, "A56");
-
- String userCode = "new A56().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A56", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return foo().intValue();".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "3".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A56");
- }
-}
-/**
- * Read access to a private method.
- */
-public void test057() {
- try {
- String sourceA57 =
- "public class A57 {\n"
- + "\tprivate Integer foo(int i) {;\n"
- + "\t\treturn new Integer(i);\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA57, "A57");
-
- String userCode = "new A57().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A57", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return foo(3).intValue();".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "3".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A57");
- }
-}
-/**
- * Read access to a private method.
- */
-public void test058() {
- try {
- String sourceA58 =
- "public class A58 {\n"
- + "\tprivate Integer foo(int i, int[] tab) {;\n"
- + "\t\treturn new Integer(i + tab.length);\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA58, "A58");
-
- String userCode = "new A58().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A58", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "int[] tab = new int[] {1,2,3};return foo(0, tab).intValue();".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "3".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A58");
- }
-}
-/**
- * Read access to a private method.
- */
-public void test059() {
- try {
- String sourceA59 =
- "public class A59 {\n"
- + "\tprivate Integer foo(int i, Object[][] tab) {;\n"
- + "\t\treturn new Integer(i + tab.length);\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA59, "A59");
-
- String userCode = "new A59().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A59", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "Object[][] tab = new Object[0][0];return foo(3, tab).intValue();".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "3".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A59");
- }
-}
-/**
- * Read access to a private method.
- */
-public void test060() {
- try {
- String sourceA60 =
- "public class A60 {\n"
- + "\tprivate int i;\n"
- + "\tpublic A60() {;\n"
- + "\t}\n"
- + "\tprivate A60(int i) {;\n"
- + "\t\tthis.i = i;\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA60, "A60");
-
- String userCode = "new A60().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A60", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return new A60(3).i;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "3".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A60");
- }
-}
-/**
- * Read access to a private method.
- */
-public void test061() {
- try {
- String sourceA61 =
- "public class A61 {\n"
- + "\tprivate int i;\n"
- + "\tpublic A61() {;\n"
- + "\t}\n"
- + "\tprivate A61(int[] tab) {;\n"
- + "\t\tthis.i = tab.length;\n"
- + "\t}\n"
- + "\tpublic void bar() {\n"
- + "\t}\n"
- + "}";
- compileAndDeploy(sourceA61, "A61");
-
- String userCode = "new A61().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A61", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return new A61(new int[] {1,2,3}).i;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "3".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A61");
- }
-}
-/**
- * Static context with a declaring type.
- */
-public void test062() {
- try {
- String sourceA62 =
- "public class A62 {\n" +
- " public static void bar() {\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceA62, "A62");
-
- String userCode = "new A62().bar();";
- JDIStackFrame stackFrame =
- new JDIStackFrame(this.jdiVM, this, userCode, "A62", "bar", -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "1 + 1".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue(
- "Should get one result but got " + (requestor.resultIndex + 1),
- requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Code snippet should not have problems", !result.hasProblems());
- assertTrue("Result should have a value", result.hasValue());
- assertEquals("Value", "2".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- removeTempClass("A62");
- }
-}
-public static Class testClass() {
- return DebugEvaluationTest.class;
-}
-/**
- * Return non-static field in static environment.
- */
-public void testNegative001() {
- try {
- String sourceANegative001 =
- "public class ANegative001 {\n" +
- " public int x = 1;\n" +
- " public int foo() {\n" +
- " x++;\n" + // workaround pb with JDK 1.4.1 that doesn't stop if only return
- " return x;\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceANegative001, "ANegative001");
- String userCode =
- "new ANegative001().foo();";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "ANegative001",
- "foo",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return this.x;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- true, // force is static
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- IProblem[] problems = result.getProblems();
- StringBuffer buffer = null;
- for (int i = 0, max = problems.length; i < max; i++){
- if (problems[i].isError()){
- if (buffer == null) buffer = new StringBuffer(10);
- buffer.append(problems[i].getMessage());
- buffer.append('|');
- }
- }
- assertEquals("Unexpected errors",
- "Cannot use this in a static context |",
- buffer == null ? "none" : buffer.toString());
- } finally {
- removeTempClass("ANegative001");
- }
-}
-/**
- * Return non-static field in static environment.
- */
-public void testNegative002() {
- try {
- String sourceANegative002 =
- "public class ANegative002 {\n" +
- " public int x = 1;\n" +
- " public int foo() {\n" +
- " x++;\n" + // workaround pb with JDK 1.4.1 that doesn't stop if only return
- " return x;\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceANegative002, "ANegative002");
- String userCode =
- "new ANegative002().foo();";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "ANegative002",
- "foo",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return x;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- true, // force is static
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- IProblem[] problems = result.getProblems();
- StringBuffer buffer = null;
- for (int i = 0, max = problems.length; i < max; i++){
- if (problems[i].isError()){
- if (buffer == null) buffer = new StringBuffer(10);
- buffer.append(problems[i].getMessage());
- buffer.append('|');
- }
- }
- assertEquals("Unexpected errors",
- "Cannot make a static reference to the non-static field x|",
- buffer == null ? "none" : buffer.toString());
- } finally {
- removeTempClass("ANegative002");
- }
-}
-/**
- * Return inexisting field in static environment.
- */
-public void testNegative003() {
- try {
- String sourceANegative003 =
- "public class ANegative003 {\n" +
- " public int x = 1;\n" +
- " public int foo() {\n" +
- " x++;\n" + // workaround pb with JDK 1.4.1 that doesn't stop if only return
- " return x;\n" +
- " }\n" +
- "}";
- compileAndDeploy(sourceANegative003, "ANegative003");
- String userCode =
- "new ANegative003().foo();";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode,
- "ANegative003",
- "foo",
- -1);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "return zork;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- true, // force is static
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- IProblem[] problems = result.getProblems();
- StringBuffer buffer = null;
- for (int i = 0, max = problems.length; i < max; i++){
- if (problems[i].isError()){
- if (buffer == null) buffer = new StringBuffer(10);
- buffer.append(problems[i].getMessage());
- buffer.append('|');
- }
- }
- assertEquals("Unexpected errors",
- "zork cannot be resolved|",
- buffer == null ? "none" : buffer.toString());
- } finally {
- removeTempClass("ANegative003");
- }
-}
-/**
- * Check java.lang.System.out = null returns an error
- */
-public void testNegative004() {
- String userCode = "";
- JDIStackFrame stackFrame = new JDIStackFrame(
- this.jdiVM,
- this,
- userCode);
-
- DebugRequestor requestor = new DebugRequestor();
- char[] snippet = "java.lang.System.out = null;".toCharArray();
- try {
- context.evaluate(
- snippet,
- stackFrame.localVariableTypeNames(),
- stackFrame.localVariableNames(),
- stackFrame.localVariableModifiers(),
- stackFrame.declaringTypeName(),
- stackFrame.isStatic(),
- stackFrame.isConstructorCall(),
- getEnv(),
- getOptions(),
- requestor,
- getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- IProblem[] problems = result.getProblems();
- StringBuffer buffer = null;
- for (int i = 0, max = problems.length; i < max; i++){
- if (problems[i].isError()){
- if (buffer == null) buffer = new StringBuffer(10);
- buffer.append(problems[i].getMessage());
- buffer.append('|');
- }
- }
- assertEquals("Unexpected errors",
- "Cannot assign a value to the final field System.out|",
- buffer == null ? "none" : buffer.toString());
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationSetup.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationSetup.java
deleted file mode 100644
index f5a5851..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationSetup.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import java.io.InputStream;
-import java.util.Enumeration;
-
-import junit.extensions.TestDecorator;
-import junit.framework.Test;
-import junit.framework.TestResult;
-import junit.framework.TestSuite;
-
-import org.eclipse.jdt.core.tests.runtime.LocalVirtualMachine;
-
-import org.eclipse.jdt.core.tests.runtime.LocalVMLauncher;
-import org.eclipse.jdt.core.tests.runtime.TargetException;
-import org.eclipse.jdt.core.tests.runtime.TargetInterface;
-import org.eclipse.jdt.core.tests.util.Util;
-import org.eclipse.jdt.internal.compiler.batch.FileSystem;
-import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.internal.eval.EvaluationContext;
-
-public class EvaluationSetup extends TestDecorator {
- String jrePath;
- String evalDirectory;
- EvaluationContext context;
- TargetInterface target;
- LocalVirtualMachine launchedVM;
-public EvaluationSetup(Test test) {
- super(test);
-}
-protected void initTest(Object test, EvaluationContext context, TargetInterface target, LocalVirtualMachine launchedVM, INameEnvironment env) {
- if (test instanceof EvaluationTest) {
- EvaluationTest evalTest = (EvaluationTest)test;
- evalTest.context = context;
- evalTest.target = target;
- evalTest.launchedVM = launchedVM;
- evalTest.env = env;
- return;
- }
- if (test instanceof TestSuite) {
- TestSuite evaluationTestClassSuite = (TestSuite) test;
- Enumeration evaluationTestClassTests = evaluationTestClassSuite.tests();
- while (evaluationTestClassTests.hasMoreElements()) {
- initTest(evaluationTestClassTests.nextElement(), context, target, launchedVM, env);
- }
- return;
- }
-
-}
-public void run(TestResult result) {
- try {
- setUp();
- super.run(result);
- } finally {
- tearDown();
- }
-}
-protected void setUp() {
- // Launch VM in evaluation mode
- int evalPort = Util.nextAvailablePortNumber();
- try {
- LocalVMLauncher launcher = LocalVMLauncher.getLauncher();
- launcher.setVMPath(this.jrePath);
- launcher.setEvalPort(evalPort);
- launcher.setEvalTargetPath(this.evalDirectory);
- this.launchedVM = launcher.launch();
- } catch (TargetException e) {
- throw new Error(e.getMessage());
- }
-
- // Thread that read the stout of the VM so that the VM doesn't block
- try {
- startReader("VM's stdout reader", this.launchedVM.getInputStream());
- } catch (TargetException e) {
- }
-
- // Thread that read the sterr of the VM so that the VM doesn't block
- try {
- startReader("VM's sterr reader",this.launchedVM.getErrorStream());
- } catch (TargetException e) {
- }
-
- // Create context
- this.context = new EvaluationContext();
-
- // Create target
- this.target = new TargetInterface();
- this.target.connect("localhost", evalPort, 10000);
-
- // Create name environment
- INameEnvironment env = new FileSystem(new String[] {Util.getJavaClassLib()}, new String[0], null);
-
- // Init wrapped suite
- initTest(fTest, this.context, this.target, this.launchedVM, env);
-}
-protected void startReader(String name, final InputStream in) {
- (new Thread(name) {
- public void run() {
- int read = 0;
- while (read != -1) {
- try {
- read = in.read();
- } catch (java.io.IOException e) {
- read = -1;
- }
- if (read != -1) {
- System.out.print((char) read);
- }
- }
- }
- }).start();
-}
-protected void tearDown() {
- if (context != null) {
- LocalVirtualMachine vm = this.launchedVM;
- if (vm != null) {
- try {
- this.target.disconnect(); // Close the socket first so that the OS resource has a chance to be freed.
- int retry = 0;
- while (launchedVM.isRunning() && (++retry < 20)) {
- try {
- Thread.sleep(retry * 100);
- } catch (InterruptedException e) {
- }
- }
- if (launchedVM.isRunning()) {
- launchedVM.shutDown();
- }
- this.context = null;
- } catch (TargetException e) {
- throw new Error(e.getMessage());
- }
- }
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationTest.java
deleted file mode 100644
index 447e4f4..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/EvaluationTest.java
+++ /dev/null
@@ -1,508 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import java.io.File;
-import java.lang.reflect.Modifier;
-import java.util.Hashtable;
-import java.util.Map;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.core.tests.junit.extension.StopableTestCase;
-import org.eclipse.jdt.core.tests.runtime.LocalVMLauncher;
-import org.eclipse.jdt.core.tests.runtime.LocalVirtualMachine;
-import org.eclipse.jdt.core.tests.runtime.TargetException;
-import org.eclipse.jdt.core.tests.runtime.TargetInterface;
-import org.eclipse.jdt.core.tests.util.Util;
-import org.eclipse.jdt.internal.compiler.ClassFile;
-import org.eclipse.jdt.internal.compiler.IProblemFactory;
-import org.eclipse.jdt.internal.compiler.batch.FileSystem;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
-import org.eclipse.jdt.internal.compiler.env.IBinaryField;
-import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
-import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
-import org.eclipse.jdt.internal.eval.EvaluationContext;
-import org.eclipse.jdt.internal.eval.EvaluationResult;
-import org.eclipse.jdt.internal.eval.GlobalVariable;
-import org.eclipse.jdt.internal.eval.IRequestor;
-import org.eclipse.jdt.internal.eval.InstallException;
-
-public class EvaluationTest extends StopableTestCase {
- protected static final String JRE_PATH = Util.getJREDirectory();
- protected static final String EVAL_DIRECTORY = Util.getOutputDirectory() + File.separator + "evaluation";
- protected static final String SOURCE_DIRECTORY = Util.getOutputDirectory() + File.separator + "source";
- public EvaluationContext context;
- LocalVirtualMachine launchedVM;
- String[] classPath;
- INameEnvironment env;
- TargetInterface target;
-
- public class Requestor implements IRequestor {
- public int resultIndex = -1;
- public EvaluationResult[] results = new EvaluationResult[5];
- public boolean acceptClassFiles(ClassFile[] classFiles, char[] codeSnippetClassName) {
- try {
- target.sendClasses(codeSnippetClassName != null, classFiles);
- } catch (TargetException e) {
- return false;
- }
- if (codeSnippetClassName != null) {
- TargetInterface.Result result = target.getResult();
- if (result.displayString == null) {
- this.acceptResult(new EvaluationResult(null, EvaluationResult.T_CODE_SNIPPET, null, null));
- } else {
- this.acceptResult(new EvaluationResult(null, EvaluationResult.T_CODE_SNIPPET, result.displayString, result.typeName));
- }
- } else {
- for (int i = 0, length = classFiles.length; i < length; i++) {
- char[][] compoundName = classFiles[i].getCompoundName();
- if (new String(compoundName[compoundName.length-1]).startsWith("GlobalVariable")) {
- try {
- IBinaryField[] fields = new ClassFileReader(classFiles[i].getBytes(), null).getFields();
- if (fields != null) {
- for (int j = 0; j < fields.length; j++) {
- IBinaryField field = fields[j];
- if (Modifier.isPublic(field.getModifiers())) {
- TargetInterface.Result result = target.getResult();
- if (result.displayString == null) {
- this.acceptResult(new EvaluationResult(field.getName(), EvaluationResult.T_VARIABLE, null, null));
- } else {
- this.acceptResult(new EvaluationResult(field.getName(), EvaluationResult.T_VARIABLE, result.displayString, result.typeName));
- }
- }
- }
- }
- } catch (ClassFormatException e) {
- }
- }
- }
- }
- return true;
- }
- public void acceptProblem(IProblem problem, char[] fragmentSource, int fragmentKind) {
- this.acceptResult(new EvaluationResult(fragmentSource, fragmentKind, new IProblem[] {problem}));
- }
- public void acceptResult(EvaluationResult result) {
- try {
- this.results[++this.resultIndex] = result;
- } catch (ArrayIndexOutOfBoundsException e) {
- int oldResultLength = this.results.length;
- System.arraycopy(this.results , 0, (this.results = new EvaluationResult[oldResultLength * 2]), 0, oldResultLength);
- this.results[this.resultIndex] = result;
- }
- }
- }
-/**
- * Creates a new EvaluationTest.
- */
-public EvaluationTest(String name) {
- super(name);
-}
-/**
- * Asserts that two char arrays are equal. If they are not
- * an AssertionFailedError is thrown.
- * @param message the detail message for this assertion
- * @param expected the expected value of a char array
- * @param actual the actual value of a char array
- */
-public void assertEquals(String message, char[] expected, char[] actual) {
- if (expected == null && actual == null)
- return;
- if (expected != null) {
- if (actual == null) {
- failNotEquals(message, expected, actual);
- return;
- }
- if (expected.length == actual.length) {
- for (int i = 0; i < expected.length; i++) {
- if (expected[i] != actual[i]) {
- failNotEquals(message, expected, actual);
- return;
- }
- }
- return;
- }
- }
- failNotEquals(message, expected, actual);
-}
-/**
- * Build a char array from the given lines
- */
-protected char[] buildCharArray(String[] lines) {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < lines.length; i++) {
- buffer.append(lines[i]);
- if (i < lines.length - 1) {
- buffer.append("\n");
- }
- }
- int length = buffer.length();
- char[] result = new char[length];
- buffer.getChars(0, length, result, 0);
- return result;
-}
-/**
- * Returns whether the 2 given arrays of strings are equals.
- */
-private boolean equals(String[] strings1, String[] strings2) {
- if (strings1.length != strings2.length) {
- return false;
- }
- for (int i = 0; i < strings1.length; i++) {
- if (!strings1[i].equals(strings2[i]))
- return false;
- }
- return true;
-}
-/**
- * Returns whether the 2 given problems are equals.
- */
-private boolean equals(IProblem pb1, IProblem pb2) {
- if ((pb1 == null) && (pb2 == null)) {
- return true;
- }
- if ((pb1 == null) || (pb2 == null)) {
- return false;
- }
- return
- (pb1.getID() == pb2.getID()) &&
- (pb1.isError() == pb2.isError()) &&
- (pb1.getSourceStart() == pb2.getSourceStart()) &&
- (pb1.getSourceEnd() == pb2.getSourceEnd()) &&
- (pb1.getSourceLineNumber() == pb2.getSourceLineNumber());
-}
-/**
- * Evaluates the given code snippet and makes sure it returns a result with the given display string.
- */
-public void evaluateWithExpectedDisplayString(char[] codeSnippet, char[] displayString) {
- Requestor requestor = new Requestor();
- try {
- context.evaluate(codeSnippet, getEnv(), getOptions(), requestor, getProblemFactory());
- } catch (InstallException e) {
- assertTrue("Target exception " + e.getMessage(), false);
- }
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Has problem", !result.hasProblems());
- assertTrue("Empty problem list", result.getProblems().length == 0);
- if (displayString == null) {
- assertTrue("Has value", !result.hasValue());
- } else {
- assertTrue("Has value", result.hasValue());
- assertEquals("Evaluation type", EvaluationResult.T_CODE_SNIPPET, result.getEvaluationType());
- //assertEquals("Evaluation id", codeSnippet, result.getEvaluationID());
- assertEquals("Value display string", displayString, result.getValueDisplayString());
- }
-}
-/**
- * Evaluates the given code snippet and makes sure the evaluation result has at least the given problem
- * on the given import.
- */
-protected void evaluateWithExpectedImportProblem(char[] codeSnippet, char[] importDeclaration, IProblem expected) {
- evaluateWithExpectedImportProblem(codeSnippet, importDeclaration, getOptions(), expected);
-}
-/**
- * Evaluates the given code snippet and makes sure the evaluation result has at least the given problem
- * on the given import.
- */
-protected void evaluateWithExpectedImportProblem(char[] codeSnippet, char[] importDeclaration, Map options, IProblem expected) {
- Requestor requestor = new Requestor();
- try {
- context.evaluate(codeSnippet, getEnv(), options, requestor, getProblemFactory());
- } catch (InstallException e) {
- assertTrue("Target exception " + e.getMessage(), false);
- }
- for (int i = 0; i <= requestor.resultIndex; i++) {
- EvaluationResult result = requestor.results[i];
- assertTrue("Has value", !result.hasValue());
- assertTrue("Has problem", result.hasProblems());
- assertEquals("Evaluation type", EvaluationResult.T_IMPORT, result.getEvaluationType());
- assertEquals("Evaluation id", importDeclaration, result.getEvaluationID());
- IProblem[] problems = result.getProblems();
- if (equals(expected, problems[0])) {
- return;
- }
- }
- assertTrue("Expected problem not found", false);
-}
-/**
- * Evaluates the given code snippet and makes sure the evaluation result has at least the given problem.
- */
-protected void evaluateWithExpectedProblem(char[] codeSnippet, String problemsString) {
- Requestor requestor = new Requestor();
- try {
- context.evaluate(codeSnippet, getEnv(), getOptions(), requestor, getProblemFactory());
- } catch (InstallException e) {
- assertTrue("Target exception " + e.getMessage(), false);
- }
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Has value", !result.hasValue());
- assertTrue("Has problem", result.hasProblems());
- assertEquals("Evaluation type", EvaluationResult.T_CODE_SNIPPET, result.getEvaluationType());
- assertEquals("Evaluation id", codeSnippet, result.getEvaluationID());
- StringBuffer problemBuffer = new StringBuffer(20);
- IProblem[] problems = result.getProblems();
- for (int i = 0; i < problems.length; i++) {
- problemBuffer.append(problems[i].getMessage()).append('\n');
- }
- assertEquals("Unexpected problems", problemsString, problemBuffer.toString());
-}
-/**
- * Evaluates the given code snippet and makes sure the evaluation result has at least the given problem.
- */
-protected void evaluateWithExpectedProblem(char[] codeSnippet, IProblem expected) {
- Requestor requestor = new Requestor();
- try {
- context.evaluate(codeSnippet, getEnv(), getOptions(), requestor, getProblemFactory());
- } catch (InstallException e) {
- assertTrue("Target exception " + e.getMessage(), false);
- }
- for (int i = 0; i <= requestor.resultIndex; i++) {
- EvaluationResult result = requestor.results[i];
- assertTrue("Has value", !result.hasValue());
- assertTrue("Has problem", result.hasProblems());
- assertEquals("Evaluation type", EvaluationResult.T_CODE_SNIPPET, result.getEvaluationType());
- assertEquals("Evaluation id", codeSnippet, result.getEvaluationID());
- IProblem[] problems = result.getProblems();
- if (equals(expected, problems[0])) {
- return;
- }
- }
- assertTrue("Expected problem not found", false);
-}
-/**
- * Evaluates the given variable and makes sure the evaluation result has at least the given problem.
- */
-protected void evaluateWithExpectedProblem(GlobalVariable var, IProblem expected) {
- Requestor requestor = new Requestor();
- try {
- context.evaluateVariables(getEnv(), getOptions(), requestor, getProblemFactory());
- } catch (InstallException e) {
- assertTrue("Target exception " + e.getMessage(), false);
- }
- for (int i = 0; i <= requestor.resultIndex; i++) {
- EvaluationResult result = requestor.results[i];
- assertTrue("Has value", !result.hasValue());
- assertTrue("Has problem", result.hasProblems());
- assertEquals("Evaluation type", EvaluationResult.T_VARIABLE, result.getEvaluationType());
- assertEquals("Evaluation id", var.getName(), result.getEvaluationID());
- IProblem[] problems = result.getProblems();
- if (equals(expected, problems[0])) {
- return;
- }
- }
- assertTrue("Expected problem not found", false);
-}
-/**
- * Evaluates the given code snippet and makes sure it returns a result with the given type name.
- */
-protected void evaluateWithExpectedType(char[] codeSnippet, char[] expectedTypeName) {
- Requestor requestor = new Requestor();
- try {
- context.evaluate(codeSnippet, getEnv(), getOptions(), requestor, getProblemFactory());
- } catch (InstallException e) {
- assertTrue("Target exception " + e.getMessage(), false);
- }
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- if (expectedTypeName == null) {
- assertTrue("Has value", !result.hasValue());
- } else {
- assertTrue("Has value", result.hasValue());
- assertEquals("Evaluation type", EvaluationResult.T_CODE_SNIPPET, result.getEvaluationType());
- //assertEquals("Evaluation id", codeSnippet, result.getEvaluationID());
- assertEquals("Value type name", expectedTypeName, result.getValueTypeName());
- }
-}
-/**
- * Evaluates the given code snippet and makes sure it returns a result with the given display string and type name.
- */
-protected void evaluateWithExpectedValue(char[] codeSnippet, char[] displayString, char[] typeName) {
- Requestor requestor = new Requestor();
- try {
- context.evaluate(codeSnippet, getEnv(), getOptions(), requestor, getProblemFactory());
- } catch (InstallException e) {
- assertTrue("Target exception " + e.getMessage(), false);
- }
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- if (displayString == null) {
- assertTrue("Has value", !result.hasValue());
- } else {
- assertTrue("Has value", result.hasValue());
- assertEquals("Evaluation type", EvaluationResult.T_CODE_SNIPPET, result.getEvaluationType());
- //assertEquals("Evaluation id", codeSnippet, result.getEvaluationID());
- assertEquals("Value display string", displayString, result.getValueDisplayString());
- assertEquals("Value type name", typeName, result.getValueTypeName());
- }
-}
-/**
- * Evaluates the given variable and makes sure it returns a result with the given display string and type name.
- */
-protected void evaluateWithExpectedValue(GlobalVariable var, char[] displayString, char[] typeName) {
- Requestor requestor = new Requestor();
- try {
- context.evaluateVariable(var, getEnv(), getOptions(), requestor, getProblemFactory());
- } catch (InstallException e) {
- assertTrue("Target exception " + e.getMessage(), false);
- }
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- if (displayString == null) {
- assertTrue("Has value", !result.hasValue());
- } else {
- assertTrue("Has value", result.hasValue());
- assertEquals("Value display string", displayString, result.getValueDisplayString());
- assertEquals("Value type name", typeName, result.getValueTypeName());
- }
-}
-/**
- * Evaluates the given code snippet and makes sure an evaluation result has at least the given warning,
- * and that another evaluation result has the given display string.
- */
-protected void evaluateWithExpectedWarningAndDisplayString(final char[] codeSnippet, final IProblem expected, final char[] displayString) {
- class ResultRequestor extends Requestor {
- boolean gotProblem = false;
- boolean gotDisplayString = false;
- public void acceptResult(EvaluationResult result) {
- assertEquals("Evaluation type", EvaluationResult.T_CODE_SNIPPET, result.getEvaluationType());
- //assertEquals("Evaluation id", codeSnippet, result.getEvaluationID());
- if (result.hasValue()) {
- if (CharOperation.equals(result.getValueDisplayString(), displayString)) {
- gotDisplayString = true;
- }
- } else {
- assertTrue("Has problem", result.hasProblems());
- IProblem[] problems = result.getProblems();
- for (int i = 0; i < problems.length; i++) {
- if (EvaluationTest.this.equals(expected, problems[i])) {
- gotProblem = true;
- }
- }
- }
- }
- };
- ResultRequestor requestor = new ResultRequestor();
- try {
- context.evaluate(codeSnippet, getEnv(), getOptions(), requestor, getProblemFactory());
- } catch (InstallException e) {
- assertTrue("Target exception " + e.getMessage(), false);
- }
- assertTrue("Expected warning", requestor.gotProblem);
- assertTrue("Expected display string", requestor.gotDisplayString);
-}
-private void failNotEquals(String message, char[] expected, char[] actual) {
- String formatted = "";
- if (message != null)
- formatted = message + " ";
- String expectedString = expected == null ? "null" : new String(expected);
- String actualString = actual == null ? "null" : new String(actual);
- fail(formatted + "expected:<" + expectedString + "> but was:<" + actualString + ">");
-}
-public INameEnvironment getEnv() {
- return env;
-}
-public Map getOptions() {
- Hashtable options = new Hashtable();
- options.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE);
- options.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE);
- options.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.DO_NOT_GENERATE);
- options.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT);
- options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_1);
- options.put(CompilerOptions.OPTION_ReportUnreachableCode, CompilerOptions.ERROR);
- options.put(CompilerOptions.OPTION_ReportInvalidImport, CompilerOptions.ERROR);
- options.put(CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_ReportMethodWithConstructorName, CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_ReportHiddenCatchBlock, CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, CompilerOptions.IGNORE);
- options.put(CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, CompilerOptions.IGNORE);
- options.put(CompilerOptions.OPTION_ReportAssertIdentifier, CompilerOptions.IGNORE);
- options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3);
- options.put(CompilerOptions.OPTION_Encoding, "");
- return options;
-}
-public IProblemFactory getProblemFactory() {
- return new DefaultProblemFactory(java.util.Locale.getDefault());
-}
-/**
- * Installs all the variables and check that the number of installed variables is the given number.
- */
-protected void installVariables(final int expectedNumber) {
- class InstallRequestor extends Requestor {
- int count = 0;
- public void acceptResult(EvaluationResult result) {
- assertTrue("Has problems", !result.hasProblems());
- assertTrue("Has value", result.hasValue());
- this.count++;
- }
- }
-
- InstallRequestor installRequestor = new InstallRequestor();
- try {
- context.evaluateVariables(getEnv(), getOptions(), installRequestor, getProblemFactory());
- } catch (InstallException e) {
- assertTrue("Target exception: " + e.getMessage(), false);
- }
- assertEquals("Number of installed variables", expectedNumber, installRequestor.count);
-}
-/**
- * Returns a new problem with the given id, severity, source positions and line number.
- */
-protected DefaultProblem newProblem(int id, int severity, int startPos, int endPos, int line) {
- return new DefaultProblem(null, null, id, null, severity, startPos, endPos, line);
-}
-public void resetEnv() {
- String encoding = (String) getOptions().get(CompilerOptions.OPTION_Encoding);
- if ("".equals(encoding)) encoding = null;
- env = new FileSystem(new String[] {Util.getJavaClassLib(), EvaluationTest.EVAL_DIRECTORY + File.separator + LocalVMLauncher.REGULAR_CLASSPATH_DIRECTORY}, new String[0], encoding);
-}
-public static Test setupSuite(Class clazz) {
- EvaluationSetup evalSetup = new EvaluationSetup(suite(clazz));
- evalSetup.jrePath = JRE_PATH;
- evalSetup.evalDirectory = EVAL_DIRECTORY;
- return evalSetup;
-}
-public void stop() {
- if (this.target != null) {
- this.target.disconnect(); // Close the socket first so that the OS resource has a chance to be freed.
- }
- if (this.launchedVM != null) {
- try {
- int retry = 0;
- while (this.launchedVM.isRunning() && (++retry < 20)) {
- try {
- Thread.sleep(retry * 100);
- } catch (InterruptedException e) {
- }
- }
- if (this.launchedVM.isRunning()) {
- this.launchedVM.shutDown();
- }
- } catch (TargetException e) {
- }
- }
-}
-public static Test suite(Class evaluationTestClass) {
- TestSuite suite = new TestSuite(evaluationTestClass);
- return suite;
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/JDIStackFrame.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/JDIStackFrame.java
deleted file mode 100644
index 533ce3b..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/JDIStackFrame.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.jdt.core.tests.runtime.RuntimeConstants;
-import org.eclipse.jdt.internal.eval.EvaluationConstants;
-import org.eclipse.jdt.internal.eval.EvaluationResult;
-import org.eclipse.jdt.internal.eval.InstallException;
-
-import com.sun.jdi.AbsentInformationException;
-import com.sun.jdi.ClassNotLoadedException;
-import com.sun.jdi.ClassType;
-import com.sun.jdi.Field;
-import com.sun.jdi.IncompatibleThreadStateException;
-import com.sun.jdi.InvalidTypeException;
-import com.sun.jdi.InvocationException;
-import com.sun.jdi.LocalVariable;
-import com.sun.jdi.Location;
-import com.sun.jdi.Method;
-import com.sun.jdi.ObjectReference;
-import com.sun.jdi.ReferenceType;
-import com.sun.jdi.StackFrame;
-import com.sun.jdi.ThreadReference;
-import com.sun.jdi.Value;
-import com.sun.jdi.VirtualMachine;
-import com.sun.jdi.event.BreakpointEvent;
-import com.sun.jdi.event.Event;
-import com.sun.jdi.event.EventSet;
-import com.sun.jdi.request.BreakpointRequest;
-import com.sun.jdi.request.EventRequest;
-
-public class JDIStackFrame implements EvaluationConstants, RuntimeConstants {
- VirtualMachine jdiVM;
- ThreadReference jdiThread;
- String userCode;
- String breakpointClassName;
- String breakpointMethodName;
- int breakpointLine;
-public JDIStackFrame(VirtualMachine jdiVM, DebugEvaluationTest test, String userCode) {
- this(jdiVM, test, userCode, "_JDIStackFrame_", "foo", Integer.MAX_VALUE);
-}
-public JDIStackFrame(
- VirtualMachine jdiVM,
- DebugEvaluationTest test,
- String userCode,
- String breakpointClassName,
- String breakpointMethodName,
- int breakpointLine) {
-
- this.jdiVM = jdiVM;
- this.userCode = userCode;
- this.breakpointClassName = breakpointClassName;
- this.breakpointMethodName = breakpointMethodName;
- this.breakpointLine = breakpointLine;
-
- test.jdiStackFrame = null;
- this.jdiThread = this.getDebuggedThread(test);
- test.jdiStackFrame = this;
-}
-public char[] declaringTypeName() {
- if (this.breakpointLine != Integer.MAX_VALUE) { // if not in a code snippet
- StackFrame frame = getStackFrame();
- return frame.location().declaringType().name().toCharArray();
- }
- return null;
-}
-protected ThreadReference getDebuggedThread(DebugEvaluationTest test) {
- try {
- // desintall previous breakpoints
- this.jdiVM.eventRequestManager().deleteAllBreakpoints();
-
- // install a breakpoint at the breakpointLine
- List classes = this.jdiVM.classesByName(this.breakpointClassName);
- if (classes.size() == 0) {
- if (this.breakpointClassName.equals("_JDIStackFrame_")) {
- // install special class
- String source =
- "public class _JDIStackFrame_ {\n" +
- " public int foo() {\n" +
- " return -1;\n" +
- " }\n" +
- "}";
- test.compileAndDeploy(source, "_JDIStackFrame_");
- }
-
- // force load of class
- test.evaluateWithExpectedDisplayString(
- ("return Class.forName(\"" + this.breakpointClassName + "\");").toCharArray(),
- ("class " + this.breakpointClassName).toCharArray()
- );
- classes = this.jdiVM.classesByName(this.breakpointClassName);
- if (classes.size() == 0) {
- // workaround bug in Standard VM
- Iterator iterator = this.jdiVM.allClasses().iterator();
- while (iterator.hasNext()) {
- ReferenceType type = (ReferenceType)iterator.next();
- if (type.name().equals(this.breakpointClassName)) {
- classes = new ArrayList(1);
- classes.add(type);
- break;
- }
- }
- if (classes.size() == 0) {
- throw new Error("JDI could not retrieve class for " + this.breakpointClassName);
- }
- }
- }
- ClassType clazz = (ClassType)classes.get(0);
- Method method = (Method)clazz.methodsByName(this.breakpointMethodName).get(0);
- Location location;
- if (this.breakpointLine < 0 || this.breakpointLine == Integer.MAX_VALUE) {
- location = method.location();
- } else {
- location = (Location)method.locationsOfLine(this.breakpointLine).get(0);
- }
- BreakpointRequest request = this.jdiVM.eventRequestManager().createBreakpointRequest(location);
- request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
- request.enable();
-
- // create a new thread that hit the breakpoint
- EvaluationTest.Requestor requestor = test.new Requestor();
- try {
- test.resetEnv();
- test.context.evaluate(
- ("(new Thread() {\n" +
- " public void run() {\n" +
- userCode + "\n" +
- (this.breakpointClassName.equals("_JDIStackFrame_") ? " new _JDIStackFrame_().foo();\n" : "") +
- " }\n" +
- " public String toString() {\n" +
- " return \"my thread\";\n" +
- " }\n" +
- "}).start();\n").toCharArray(),
- test.getEnv(),
- test.getOptions(),
- requestor,
- test.getProblemFactory());
- } catch (InstallException e) {
- EvaluationTest.assertTrue("Target exception " + e.getMessage(), false);
- }
- EvaluationResult[] results = requestor.results;
- for (int i = 0; i < requestor.resultIndex + 1; i++){
- if (results[i].hasErrors()) {
- EvaluationTest.assertTrue("Compilation error in user code", false);
- }
- }
-
- // Wait for the breakpoint event
- Event event = null;
- do {
- EventSet set = this.jdiVM.eventQueue().remove();
- Iterator iterator = set.eventIterator();
- while (iterator.hasNext()) {
- event = (Event)iterator.next();
- if (event instanceof BreakpointEvent)
- break;
- }
- } while (!(event instanceof BreakpointEvent));
-
- // Return the suspended thread
- return ((BreakpointEvent)event).thread();
- } catch (AbsentInformationException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- return null;
-}
-protected StackFrame getStackFrame() {
- try {
- if (this.breakpointLine == Integer.MAX_VALUE) {
- return this.jdiThread.frame(1);
- } else {
- return this.jdiThread.frame(0);
- }
- } catch (IncompatibleThreadStateException e) {
- e.printStackTrace();
- return null;
- }
-}
-public boolean isConstructorCall() {
- if (this.breakpointLine != Integer.MAX_VALUE) { // if not in a code snippet
- StackFrame frame = getStackFrame();
- return frame.location().method().isConstructor();
- }
- return false;
-}
-public boolean isStatic() {
- if (this.breakpointLine != Integer.MAX_VALUE) { // if not in a code snippet
- StackFrame frame = getStackFrame();
- return frame.location().method().isStatic();
- }
- return false;
-}
-public int[] localVariableModifiers() {
- try {
- StackFrame frame = getStackFrame();
- List variables = frame.visibleVariables();
- int[] modifiers = new int[variables.size()];
-/* Iterator iterator = variables.iterator();
- int i = 0;
- while (iterator.hasNext()) {
- LocalVariable var = (LocalVariable)iterator.next();
- // TBD modifiers[i++] = var. ??? ;
- }
-*/ return modifiers;
- } catch (AbsentInformationException e) {
- return null;
- }
-}
-public char[][] localVariableNames() {
- try {
- StackFrame frame = getStackFrame();
- Iterator variables = frame.visibleVariables().iterator();
- Vector names = new Vector();
- while (variables.hasNext()) {
- LocalVariable var = (LocalVariable)variables.next();
- names.addElement(var.name().toCharArray());
- }
- char[][] result = new char[names.size()][];
- names.copyInto(result);
- return result;
- } catch (AbsentInformationException e) {
- return null;
- }
-}
-public char[][] localVariableTypeNames() {
- try {
- StackFrame frame = getStackFrame();
- Iterator variables = frame.visibleVariables().iterator();
- Vector names = new Vector();
- while (variables.hasNext()) {
- LocalVariable var = (LocalVariable)variables.next();
- names.addElement(var.typeName().toCharArray());
- }
- char[][] result = new char[names.size()][];
- names.copyInto(result);
- return result;
- } catch (AbsentInformationException e) {
- return null;
- }
-}
-public boolean run(String codeSnippetClassName) {
- ClassType codeSnippetClass;
- ObjectReference codeSnippet;
- Method method;
- List arguments;
- ObjectReference codeSnippetRunner;
- try {
- // Get the code snippet class
- List classes = jdiVM.classesByName(codeSnippetClassName);
- while (classes.size() == 0) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- }
- classes = jdiVM.classesByName(codeSnippetClassName);
- if (classes.size() == 0) {
- // workaround bug in Standard VM
- Iterator iterator = this.jdiVM.allClasses().iterator();
- while (iterator.hasNext()) {
- ReferenceType type = (ReferenceType)iterator.next();
- if (type.name().equals(codeSnippetClassName)) {
- classes = new ArrayList(1);
- classes.add(type);
- break;
- }
- }
- }
- }
- codeSnippetClass = (ClassType)classes.get(0);
-
- // Create a new code snippet
- Method constructor = (Method)codeSnippetClass.methodsByName("<init>").get(0);
- codeSnippet = codeSnippetClass.newInstance(jdiThread, constructor, new ArrayList(), ClassType.INVOKE_SINGLE_THREADED);
-
- // Install local variables and "this" into generated fields
- StackFrame stackFrame = getStackFrame();
- try {
- Iterator variables = stackFrame.visibleVariables().iterator();
- while (variables.hasNext()) {
- LocalVariable jdiVariable = (LocalVariable)variables.next();
- Value value = stackFrame.getValue(jdiVariable);
- Field field = codeSnippetClass.fieldByName(new String(LOCAL_VAR_PREFIX) + jdiVariable.name());
- codeSnippet.setValue(field, value);
- }
- } catch (AbsentInformationException e) {
- // No variables
- }
- Field delegateThis = codeSnippetClass.fieldByName(new String(DELEGATE_THIS));
- ObjectReference thisObject;
- if (delegateThis != null && ((thisObject = stackFrame.thisObject()) != null)) {
- codeSnippet.setValue(delegateThis, thisObject);
- }
-
- // Get the code snippet runner
- ClassType codeSnippetRunnerClass = (ClassType)jdiVM.classesByName(CODE_SNIPPET_RUNNER_CLASS_NAME).get(0);
- Field theRunner = codeSnippetRunnerClass.fieldByName(THE_RUNNER_FIELD);
- codeSnippetRunner = (ObjectReference)codeSnippetRunnerClass.getValue(theRunner);
-
- // Get the method 'runCodeSnippet' and its arguments
- method = (Method)codeSnippetRunnerClass.methodsByName(RUN_CODE_SNIPPET_METHOD).get(0);
- arguments = new ArrayList();
- arguments.add(codeSnippet);
- } catch (ClassNotLoadedException e) {
- e.printStackTrace();
- return false;
- } catch (IncompatibleThreadStateException e) {
- e.printStackTrace();
- return false;
- } catch (InvalidTypeException e) {
- e.printStackTrace();
- return false;
- } catch (InvocationException e) {
- e.printStackTrace();
- return false;
- }
-
- try {
- // Invoke runCodeSnippet(CodeSnippet)
- codeSnippetRunner.invokeMethod(jdiThread, method, arguments, ClassType.INVOKE_SINGLE_THREADED);
-
- // Retrieve values of local variables and put them back in the stack frame
- StackFrame stackFrame = getStackFrame();
- try {
- Iterator variables = stackFrame.visibleVariables().iterator();
- while (variables.hasNext()) {
- LocalVariable jdiVariable = (LocalVariable)variables.next();
- Field field = codeSnippetClass.fieldByName(new String(LOCAL_VAR_PREFIX) + jdiVariable.name());
- Value value = codeSnippet.getValue(field);
- stackFrame.setValue(jdiVariable, value);
- }
- } catch (AbsentInformationException e) {
- // No variables
- }
- } catch (ClassNotLoadedException e) {
- e.printStackTrace();
- } catch (IncompatibleThreadStateException e) {
- e.printStackTrace();
- } catch (InvalidTypeException e) {
- e.printStackTrace();
- } catch (InvocationException e) {
- e.printStackTrace();
- }
- return true;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeCodeSnippetTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeCodeSnippetTest.java
deleted file mode 100644
index 946810a..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeCodeSnippetTest.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import java.util.Map;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
-import org.eclipse.jdt.internal.eval.GlobalVariable;
-/**
- * Negative tests for code snippet. Only compilation problems should be reported in
- * these tests.
- */
-public class NegativeCodeSnippetTest extends EvaluationTest implements ProblemSeverities, ProblemReasons {
-/**
- * Creates a new NegativeCodeSnippetTest.
- */
-public NegativeCodeSnippetTest(String name) {
- super(name);
-}
-public static Test suite() {
- return setupSuite(testClass());
-}
-/**
- * Test a scenario where the change of the package declaration causes a problem in a code snippet.
- */
-public void testChangePackage() {
- try {
- // define the package
- context.setPackageName("java.util.zip".toCharArray());
-
- // evaluate a code snippet that uses this variable
- char[] codeSnippet = "new InflaterInputStream(new java.io.ByteArrayInputStream(new byte[0])).len".toCharArray();
- evaluateWithExpectedDisplayString(
- codeSnippet,
- "0".toCharArray());
-
- // back to the default package but with correct import
- this.context.setPackageName(new char[0]);
- this.context.setImports(new char[][] {"java.util.zip.*".toCharArray()});
-
- // evaluate same code snippet
- evaluateWithExpectedProblem(
- codeSnippet,
- newProblem(IProblem.NotVisibleField, Error, 71, 73, 1)); // The field len is not visible
-
- // back to the default package and with no imports
- this.context.setImports(new char[0][]);
-
- // evaluate same code snippet
- evaluateWithExpectedProblem(
- codeSnippet,
- newProblem(IProblem.UndefinedType, Error, 4, 22, 1)); // The type InflaterInputStream is undefined
- } finally {
- // Clean up
- this.context.setPackageName(new char[0]);
- this.context.setImports(new char[0][]);
- }
-}
-public static Class testClass() {
- return NegativeCodeSnippetTest.class;
-}
-/**
- * Test a code snippet which declares a class that uses an expression as a returned statement
- * in one of its methods.
- */
-public void testExpressionInInnerClass() {
- evaluateWithExpectedProblem(buildCharArray(new String[] {
- "class X {",
- " int foo() {",
- " 1 + 1",
- " }",
- "}",
- "return new X().foo();"}),
- newProblem(IProblem.ParsingError, Error, 27, 27, 3)); // Syntax error on token "+"
-}
-/**
- * Test extra closing curly bracket.
- */
-public void testExtraClosingCurlyBracket() {
- // just an expression with an extra curly bracket
- evaluateWithExpectedProblem(
- "1 + 2}".toCharArray(),
- newProblem(IProblem.UnmatchedBracket, Error, 5, 5, 1)); // Unmatched bracket
-
- // a statement followed by an unreachable expression with an extra curly bracket
- evaluateWithExpectedProblem(buildCharArray(new String[] {
- "return 1 + 1;",
- " 2 + 2}"}),
- newProblem(IProblem.UnmatchedBracket, Error, 20, 20, 2)); // Unmatched bracket
-}
-/**
- * Test extra open round bracket.
- */
-public void testExtraOpenRoundBracket() {
- evaluateWithExpectedProblem(
- "foo((a);".toCharArray(),
- newProblem(IProblem.UnmatchedBracket, Error, 3, 3, 1)); // Unmatched bracket
-}
-/**
- * Test a code snippet that contains an expression followed by a semi-colon.
- */
-public void testExtraSemiColonInExpression() {
- evaluateWithExpectedProblem(
- "1;".toCharArray(),
- newProblem(IProblem.ParsingError, Error, 1, 1, 1)); // Syntax error on token EOF
-}
-/**
- * Test a code snippet which is valid but the evaluation context imports have problems.
- */
-public void testInvalidImport() {
- try {
- // problem on the first import
- context.setImports(new char[][] {"bar.Y".toCharArray()});
- evaluateWithExpectedImportProblem(buildCharArray(new String[] {
- "class X {",
- " Y foo = new Y();",
- "}",
- "return new X().foo;"}),
- "bar.Y".toCharArray(),
- newProblem(IProblem.ImportNotFound, Error, 0, 4, 1)); // The import bar.Y could not be resolved
-
- // problem on the second import
- context.setImports(new char[][] {"java.io.*".toCharArray(), "{".toCharArray()});
- evaluateWithExpectedImportProblem(buildCharArray(new String[] {
- "new File(\"c:\\temp\")"}),
- "{".toCharArray(),
- newProblem(IProblem.ParsingError, Error, 0, 0, 1)); // Syntax error on token "{", "Identifier" expected
- } finally {
- // Clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Test extra closing curly bracket.
- */
-public void testInvalidUseOfThisInSnippet() {
- // just an expression with an extra curly bracket
- evaluateWithExpectedProblem(
- "this".toCharArray(),
- "Cannot use this in a static context \n");
-
-}
-/**
- * Test extra closing curly bracket.
- */
-public void testInvalidUseOfThisInSnippet2() {
- // just an expression with an extra curly bracket
- evaluateWithExpectedProblem(
- "return this;".toCharArray(),
- "Cannot use this in a static context \n");
-
-}
-/**
- * Test a code snippet that misses a closing round bracket.
- */
-public void testMissingClosingRoundBracket() {
- evaluateWithExpectedProblem(buildCharArray(new String[] {
- "System.out.println(\"3 + 3\";"}),
- newProblem(IProblem.UnmatchedBracket, Error, 18, 18, 1)); // Unmatched bracket
-}
-/**
- * Test a code snippet that contains a string that misses the closing double quote .
- */
-public void testMissingDoubleQuote() {
- evaluateWithExpectedProblem(buildCharArray(new String[] {
- "System.out.println(\"3 + 3 = );",
- "3 + 3"}),
- newProblem(IProblem.UnterminatedString , Error, 19, 30, 1)); // String literal is not properly closed by a double-quote
-}
-/**
- * Test an expression which is not the last statement.
- */
-public void testNonLastExpressionStatement() {
- evaluateWithExpectedProblem(buildCharArray(new String[] {
- "1 == '1';",
- "true"}),
- newProblem(IProblem.ParsingError, Error, 8, 8, 1)); // Syntax error on token ";"
-}
-/**
- * Test a problem in the returned expression.
- */
-public void testProblemInExpression() {
- evaluateWithExpectedProblem(
- "new Object(); 3 + ".toCharArray(),
- newProblem(IProblem.ParsingError, Error, 17, 17, 1)); // Syntax error on token EOF
-}
-/**
- * Test a problem in the returned expression.
- */
-public void testProblemInExpression2() {
- evaluateWithExpectedProblem(
- "new UnknownClass()".toCharArray(),
- newProblem(IProblem.UndefinedType, Error, 4, 15, 1)); // UnknownClass cannot be resolved or is not a type
-}
-/**
- * Test a code snippet which declares a class that has a problem.
- */
-public void testProblemInInnerClass() {
- // class declared before the last expression
- evaluateWithExpectedProblem(buildCharArray(new String[] {
- "class X {",
- " Y foo = new Y();",
- "}",
- "return new X().foo;"}),
- newProblem(IProblem.FieldTypeNotFound, Error, 11, 11, 2)); // The type Y is undefined for the field X.foo
-
- // class declared as part of the last expression
- evaluateWithExpectedWarningAndDisplayString(buildCharArray(new String[] {
- "return new Object() {",
- " public String toString() {",
- " int i = 0;",
- " return \"an inner class\";",
- " }",
- "};"}),
- newProblem(IProblem.LocalVariableIsNeverUsed, Warning, 56, 56, 3), // The local variable i is never used
- "an inner class".toCharArray());
-}
-/**
- * Test a problem in the statement before the returned expression.
- */
-public void testProblemInPreviousStatement() {
- evaluateWithExpectedProblem(buildCharArray(new String[] {
- "return foo(a a);",
- "1 + 3"}),
- newProblem(IProblem.ParsingError, Error, 13, 13, 1)); // Syntax error on token "a"
-}
-/**
- * Test a code snippet that has a problem in a return statement.
- */
-public void testProblemInReturnStatement() {
- evaluateWithExpectedProblem(
- "return 1 ++ 1;".toCharArray(),
- newProblem(IProblem.InvalidUnaryExpression, Error, 7, 7, 1)); // Invalid argument to operation ++/--
-}
-/**
- * Test a scenario where the removal of an import causes a problem in a code snippet.
- */
-public void testRemoveImport() {
- try {
- // define the import
- this.context.setImports(new char[][] {"java.io.*".toCharArray()});
-
- // evaluate a code snippet that uses this variable
- char[] codeSnippet = "new File(\"c:\\\\temp\")".toCharArray();
- evaluateWithExpectedDisplayString(
- codeSnippet,
- "c:\\temp".toCharArray());
-
- // remove the import
- this.context.setImports(new char[0][]);
-
- // evaluate same code snippet
- evaluateWithExpectedProblem(
- codeSnippet,
- newProblem(IProblem.UndefinedType, Error, 4, 7, 1)); // The type File is undefined
- } finally {
- // Clean up
- this.context.setImports(new char[0][]);
- }
-}
-/**
- * Test a scenario where the removal of a variable causes a problem in a code snippet.
- */
-public void testRemoveVariable() {
- GlobalVariable var = null;
- try {
- // define the variable
- var = this.context.newVariable("int".toCharArray(), "i".toCharArray(), "1".toCharArray());
- installVariables(1);
-
- // evaluate a code snippet that uses this variable
- char[] codeSnippet = "i".toCharArray();
- evaluateWithExpectedDisplayString(
- codeSnippet,
- "1".toCharArray());
-
- // remove the variable
- this.context.deleteVariable(var);
- installVariables(0);
-
- // evaluate same code snippet
- evaluateWithExpectedProblem(
- codeSnippet,
- newProblem(IProblem.UndefinedName, Error, 0, 0, 1)); // i cannot be resolved
- } finally {
- // Clean up
- if (var != null) {
- this.context.deleteVariable(var);
- }
- }
-}
-/**
- * Test a code snippet that contains an expression which is not reachable.
- */
-public void testUnreachableExpression() {
- evaluateWithExpectedProblem(buildCharArray(new String[] {
- "return 1 + 1;",
- "2 + 2"}),
- newProblem(IProblem.CodeCannotBeReached, Error, 14, 18, 2)); // Unreachable code
-}
-/**
- * Test a code snippet which is valid but never uses the evaluation context imports.
- * (regression test for bug 18922 Scrapbook does not come back when errors in snippet)
- */
-public void testUnusedImport() {
- try {
- context.setImports(new char[][] {"java.util.*".toCharArray()});
-
- // evaluate with import as error
- Map options = this.getOptions();
- options.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.ERROR);
-
- // force evaluation so that the following evaluation will use a CodeSnippetEvaluator instead
- // of a VariableEvualator
- evaluateWithExpectedValue("1".toCharArray(), "1".toCharArray(), "int".toCharArray());
-
- evaluateWithExpectedImportProblem(
- "new String(\"NOPE\")".toCharArray(),
- "java.util.*".toCharArray(),
- options,
- newProblem(IProblem.UnusedImport, Error, 0, 10, 1)); // The import java.util.* is unused
- } finally {
- // Clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Test a code snippet that has warnings but no errors.
- */
-public void testWarning() {
- evaluateWithExpectedWarningAndDisplayString(buildCharArray(new String[] {
- "int i;",
- "1 + 1"}),
- newProblem(IProblem.LocalVariableIsNeverUsed, Warning, 4, 4, 1), // The local variable i is never used
- "2".toCharArray());
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeVariableTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeVariableTest.java
deleted file mode 100644
index aa0c4f2..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/NegativeVariableTest.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
-import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
-import org.eclipse.jdt.internal.eval.GlobalVariable;
-/**
- * Negative tests for variables. Only compilation problems should be reported in
- * these tests.
- */
-public class NegativeVariableTest extends EvaluationTest implements ProblemSeverities, ProblemReasons {
-/**
- * Creates a new NegativeVariableTest.
- */
-public NegativeVariableTest(String name) {
- super(name);
-}
-public static Test suite() {
- return setupSuite(testClass());
-}
-public static Class testClass() {
- return NegativeVariableTest.class;
-}
-/**
- * Test a variable that has a problem in its initializer.
- */
-public void testInitializerProblem() {
- // Problem in first variable
- GlobalVariable var = null;
- try {
- var = context.newVariable("int".toCharArray(), "i".toCharArray(), buildCharArray(new String[] {
- "(1 + 1) *",
- "(j + 2)"}));
- evaluateWithExpectedProblem(
- var,
- newProblem(IProblem.UndefinedName, Error, 11, 11, 2)); // j cannot be resolved
- } finally {
- if (var != null) {
- context.deleteVariable(var);
- }
- }
-
- // Problem in second variable
- GlobalVariable var1 = null;
- GlobalVariable var2 = null;
- try {
- var1 = context.newVariable("Object".toCharArray(), "o".toCharArray(), "new Object()".toCharArray());
- var2 = context.newVariable("int".toCharArray(), "i".toCharArray(), buildCharArray(new String[] {
- "(1 + 1) *",
- "(1 ++ 2)"}));
- evaluateWithExpectedProblem(
- var2,
- newProblem(IProblem.InvalidUnaryExpression, Error, 11, 11, 2)); // Invalid argument to operation ++/--
- } finally {
- if (var1 != null) {
- context.deleteVariable(var1);
- }
- if (var2 != null) {
- context.deleteVariable(var2);
- }
- }
-
-}
-/**
- * Test a variable that has a problem in its name.
- */
-public void testInvalidName() {
- // Problem in first variable
- GlobalVariable var = null;
- try {
- var = context.newVariable("int".toCharArray(), "!@#$%^&*()_".toCharArray(), "1".toCharArray());
- evaluateWithExpectedProblem(
- var,
- newProblem(IProblem.ParsingError, Error, 0, 0, 0)); // Syntax error on token "!", "Identifier" expected
- } finally {
- if (var != null) {
- context.deleteVariable(var);
- }
- }
-
- // Problem in second variable
- GlobalVariable var1 = null;
- GlobalVariable var2 = null;
- try {
- var1 = context.newVariable("String".toCharArray(), "foo".toCharArray(), "\"bar\"".toCharArray());
- var2 = context.newVariable("int".toCharArray(), "!@#$%^&*()_".toCharArray(), "1".toCharArray());
- evaluateWithExpectedProblem(
- var2,
- newProblem(IProblem.ParsingError, Error, 0, 0, 0)); // Syntax error on token "!", "Identifier" expected
- } finally {
- if (var1 != null) {
- context.deleteVariable(var1);
- }
- if (var2 != null) {
- context.deleteVariable(var2);
- }
- }
-}
-/**
- * Test a variable that has a problem in its type declaration.
- */
-public void testUnknownType() {
- // Problem in first variable
- GlobalVariable var = null;
- try {
- var = context.newVariable("foo.Bar".toCharArray(), "var".toCharArray(), null);
- evaluateWithExpectedProblem(
- var,
- newProblem(IProblem.FieldTypeNotFound, Error, 0, 6, -1)); // The type foo is undefined for the field GlobalVariables_1.var
- } finally {
- if (var != null) {
- context.deleteVariable(var);
- }
- }
-
- // Problem in second variable
- GlobalVariable var1 = null;
- GlobalVariable var2 = null;
- try {
- var1 = context.newVariable("int".toCharArray(), "x".toCharArray(), null);
- var2 = context.newVariable("foo.Bar".toCharArray(), "var".toCharArray(), null);
- evaluateWithExpectedProblem(
- var2,
- newProblem(IProblem.FieldTypeNotFound, Error, 0, 6, -1)); // The type foo is undefined for the field GlobalVariables_1.var
- } finally {
- if (var1 != null) {
- context.deleteVariable(var1);
- }
- if (var2 != null) {
- context.deleteVariable(var2);
- }
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SanityTestEvaluationContext.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SanityTestEvaluationContext.java
deleted file mode 100644
index 2c55a12..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SanityTestEvaluationContext.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.internal.eval.EvaluationResult;
-import org.eclipse.jdt.internal.eval.GlobalVariable;
-import org.eclipse.jdt.internal.eval.IRequestor;
-import org.eclipse.jdt.internal.eval.InstallException;
-/**
- * Sanity test the IEvaluationContext interface.
- * For in depth tests, see VariableTest or CodeSnippetTest.
- */
-public class SanityTestEvaluationContext extends EvaluationTest {
-/**
- * Creates a new SanityEvaluationContextTest.
- */
-public SanityTestEvaluationContext(String name) {
- super(name);
-}
-public static Test suite() {
- return setupSuite(testClass());
-}
-/**
- * Sanity test of IEvaluationContext.allVariables()
- */
-public void testAllVariables() {
- // No variables defined yet
- GlobalVariable[] vars = context.allVariables();
- assertEquals("No variables should be defined", 0, vars.length);
-
- // Define 3 variables
- context.newVariable("int".toCharArray(), "foo".toCharArray(), "1".toCharArray());
- context.newVariable("Object".toCharArray(), "bar".toCharArray(), null);
- context.newVariable("String".toCharArray(), "zip".toCharArray(), "\"abcdefg\"".toCharArray());
- vars = context.allVariables();
- assertEquals("3 variables should be defined", 3, vars.length);
- assertEquals("1st variable", "foo".toCharArray(), vars[0].getName());
- assertEquals("2nd variable", "bar".toCharArray(), vars[1].getName());
- assertEquals("3rd variable", "zip".toCharArray(), vars[2].getName());
-
- // Remove 2nd variable
- context.deleteVariable(vars[1]);
- vars = context.allVariables();
- assertEquals("2 variables should be defined", 2, vars.length);
- assertEquals("1st variable", "foo".toCharArray(), vars[0].getName());
- assertEquals("2nd variable", "zip".toCharArray(), vars[1].getName());
-
- // Remove last variable
- context.deleteVariable(vars[1]);
- vars = context.allVariables();
- assertEquals("1 variable should be defined", 1, vars.length);
- assertEquals("1st variable", "foo".toCharArray(), vars[0].getName());
-
- // Remove 1st variable
- context.deleteVariable(vars[0]);
- vars = context.allVariables();
- assertEquals("No variables should be defined", 0, vars.length);
-}
-public static Class testClass() {
- return SanityTestEvaluationContext.class;
-}
-/**
- * Sanity test of IEvaluationContext.evaluate(char[], INameEnvironment, ConfigurableOption[], IRequestor , IProblemFactory)
- */
-public void testEvaluate() {
- Requestor requestor = new Requestor();
- char[] snippet = "return 1;".toCharArray();
- try {
- context.evaluate(snippet, getEnv(), getOptions(), requestor, getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("No problems with the code snippet", !result.hasProblems());
- assertTrue("Result has a value", result.hasValue());
- assertEquals("Value", "1".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
-}
-/**
- * Sanity test of IEvaluationContext.evaluateImports(INameEnvironment, IRequestor , IProblemFactory)
- */
-public void testEvaluateImports() {
- try {
- // Define imports
- context.setImports(new char[][] {"java.util.*".toCharArray(), "java.lang.reflect.Method".toCharArray()});
-
- // Evaluate them
- IRequestor requestor = new Requestor() {
- public void acceptResult(EvaluationResult result) {
- assertTrue("No problems with the imports", !result.hasProblems());
- }
- };
- context.evaluateImports(getEnv(), requestor, getProblemFactory());
- } finally {
- // Clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Sanity test of IEvaluationContext.evaluateVariable(IGlobalVariable, IRequestor)
- */
-public void testEvaluateVariable() {
- GlobalVariable var = null;
- try {
- // Create the variable
- var = context.newVariable("int".toCharArray(), "foo".toCharArray(), "1".toCharArray());
-
- // Install it
- class NoPbRequestor extends Requestor {
- public void acceptResult(EvaluationResult result) {
- assertTrue("No problems with the variable", !result.hasProblems());
- }
- };
- try {
- context.evaluateVariables(getEnv(), getOptions(), new NoPbRequestor(), getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
-
- // Get its value
- Requestor requestor = new Requestor();
- try {
- context.evaluateVariable(var, getEnv(), getOptions(), requestor, getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("Result has value", result.hasValue());
- assertEquals("Value", "1".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- // Clean up
- if (var != null) {
- context.deleteVariable(var);
- }
- }
-}
-/**
- * Sanity test of IEvaluationContext.evaluateVariables(INameEnvironment, ConfigurableOption[], IRequestor, IProblemFactory)
- */
-public void testEvaluateVariables() {
- GlobalVariable var = null;
- try {
- // Create 1 variable
- var = context.newVariable("int".toCharArray(), "foo".toCharArray(), "1".toCharArray());
-
- // Install it and get its value
- Requestor requestor = new Requestor();
- try {
- context.evaluateVariables(getEnv(), getOptions(), requestor, getProblemFactory());
- } catch (InstallException e) {
- assertTrue("No targetException " + e.getMessage(), false);
- }
- assertTrue("Got one result", requestor.resultIndex == 0);
- EvaluationResult result = requestor.results[0];
- assertTrue("No problems with the variable", !result.hasProblems());
- assertTrue("Result has value", result.hasValue());
- assertEquals("Value", "1".toCharArray(), result.getValueDisplayString());
- assertEquals("Type", "int".toCharArray(), result.getValueTypeName());
- } finally {
- // Clean up
- if (var != null) {
- context.deleteVariable(var);
- }
- }
-}
-/**
- * Sanity test of IEvaluationContext.getImports() and IEvaluationContext.setImports(char[][])
- */
-public void testGetSetImports() {
- try {
- // No imports
- assertTrue("No imports defined", context.getImports().length == 0);
-
- // Define some imports
- char[][] imports = new char[][] {"java.util".toCharArray(), "java.lang.reflect.Method".toCharArray()};
- context.setImports(imports);
- char[][] storedImports = context.getImports();
- assertEquals("Same length", imports.length, storedImports.length);
- for (int i = 0; i < imports.length; i++){
- assertEquals("Import #" + i, imports[i], storedImports[i]);
- }
- } finally {
- // Clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Sanity test of IEvaluationContext.getPackageName() and IEvaluationContext.setPackageName(char[])
- */
-public void testGetSetPackageName() {
- try {
- // Default package
- assertTrue("Default package", context.getPackageName().length == 0);
-
- // Define a package
- char[] packageName = "x.y.z".toCharArray();
- context.setPackageName(packageName);
- char[] storedPackageName = context.getPackageName();
- assertEquals("Same package name", packageName, storedPackageName);
- } finally {
- // Clean up
- context.setPackageName(new char[0]);
- }
-}
-/**
- * Sanity test of IEvaluationContext.newVariable(char[], char[], char[]) and
- * IEvaluationContext.deleteVariable(IGlobalVariable)
- */
-public void testNewDeleteVariable() {
- // Define 1 variable
- GlobalVariable var = context.newVariable("int".toCharArray(), "deleted".toCharArray(), null);
-
- // Delete it
- context.deleteVariable(var);
- GlobalVariable[] vars = context.allVariables();
- for (int i = 0; i < vars.length; i++) {
- assertTrue("Variable should not exist", !var.getName().equals(vars[i].getName()));
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SanityTestEvaluationResult.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SanityTestEvaluationResult.java
deleted file mode 100644
index 9bf7ac3..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SanityTestEvaluationResult.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.internal.eval.EvaluationResult;
-import org.eclipse.jdt.internal.eval.IRequestor;
-import org.eclipse.jdt.internal.eval.InstallException;
-/**
- * Sanity test the IEvaluationResult interface.
- * For in depth tests, see VariableTest or CodeSnippetTest.
- */
-public class SanityTestEvaluationResult extends EvaluationTest {
- EvaluationResult result;
-/**
- * Creates a new SanityEvaluationResultTest.
- */
-public SanityTestEvaluationResult(String name) {
- super(name);
-}
-/**
- * Initializes this test with an evaluation result coming from the
- * evaluation of the following code snippet: "return 1;".
- */
-protected void setUp() {
- IRequestor requestor = new Requestor() {
- public void acceptResult(EvaluationResult result) {
- SanityTestEvaluationResult.this.result = result;
- }
- };
- try {
- this.context.evaluate("return 1;".toCharArray(), getEnv(), getOptions(), requestor, getProblemFactory());
- } catch (InstallException e) {
- throw new Error(e.getMessage());
- }
-}
-public static Test suite() {
- return setupSuite(testClass());
-}
-public static Class testClass() {
- return SanityTestEvaluationResult.class;
-}
-/**
- * Sanity test of IEvaluationResult.getEvaluationType()
- */
-public void testGetEvaluationType() {
- int evaluationType = result.getEvaluationType();
- assertEquals("Evaluation type", EvaluationResult.T_CODE_SNIPPET, evaluationType);
-}
-/**
- * Sanity test of IEvaluationResult.getProblems()
- */
-public void testGetProblems() {
- IProblem[] problems = result.getProblems();
- assertTrue("Problems", problems == null || problems.length == 0);
-}
-/**
- * Sanity test of IEvaluationResult.getValue()
- */
-public void testGetValue() {
- // TBD: Not implemented yet
-}
-/**
- * Sanity test of IEvaluationResult.getValueDisplayString()
- */
-public void testGetValueDisplayString() {
- char[] displayString = this.result.getValueDisplayString();
- assertEquals("Value display string", "1".toCharArray(), displayString);
-}
-/**
- * Sanity test of IEvaluationResult.getValueTypeName()
- */
-public void testGetValueTypeName() {
- char[] typeName = this.result.getValueTypeName();
- assertEquals("Value type name", "int".toCharArray(), typeName);
-}
-/**
- * Sanity test of IEvaluationResult.hasErrors()
- */
-public void testHasErrors() {
- assertTrue("Result has no errors", !result.hasErrors());
-}
-/**
- * Sanity test of IEvaluationResult.hasProblems()
- */
-public void testHasProblems() {
- assertTrue("Result has no problems", !result.hasProblems());
-}
-/**
- * Sanity test of IEvaluationResult.hasValue()
- */
-public void testHasValue() {
- assertTrue("Result has a value", result.hasValue());
-}
-/**
- * Sanity test of IEvaluationResult.hasWarnings()
- */
-public void testHasWarnings() {
- assertTrue("Result has no warnings", !result.hasWarnings());
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SimpleCodeSnippetTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SimpleCodeSnippetTest.java
deleted file mode 100644
index fda5c6a..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SimpleCodeSnippetTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import org.eclipse.jdt.core.tests.runtime.TargetException;
-import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.internal.eval.InstallException;
-
-
-public class SimpleCodeSnippetTest
- extends SimpleTest {
- public char[] getCodeSnippetSource() {
-
- return buildCharArray(new String[] { "1 + 1" });
- }
-
- public static void main(String[] args)
- throws TargetException, InstallException {
-
- SimpleCodeSnippetTest test = new SimpleCodeSnippetTest();
- test.runCodeSnippet();
- }
-
- void runCodeSnippet()
- throws TargetException, InstallException {
- this.startEvaluationContext();
-
- char[] snippet = getCodeSnippetSource();
- INameEnvironment env = getEnv();
- this.context.evaluate(snippet, env, null, this.requestor,
- getProblemFactory());
- this.stopEvaluationContext();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SimpleTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SimpleTest.java
deleted file mode 100644
index 01ff1c2..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SimpleTest.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import java.io.File;
-
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.core.tests.runtime.LocalVMLauncher;
-import org.eclipse.jdt.core.tests.runtime.LocalVirtualMachine;
-
-import org.eclipse.jdt.core.tests.runtime.TargetException;
-import org.eclipse.jdt.core.tests.runtime.TargetInterface;
-import org.eclipse.jdt.core.tests.util.Util;
-import org.eclipse.jdt.internal.compiler.ClassFile;
-import org.eclipse.jdt.internal.compiler.IProblemFactory;
-import org.eclipse.jdt.internal.compiler.batch.FileSystem;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
-import org.eclipse.jdt.internal.compiler.env.IBinaryField;
-import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
-import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
-import org.eclipse.jdt.internal.eval.EvaluationContext;
-import org.eclipse.jdt.internal.eval.EvaluationResult;
-import org.eclipse.jdt.internal.eval.GlobalVariable;
-import org.eclipse.jdt.internal.eval.IRequestor;
-
-public class SimpleTest {
- static final String JRE_PATH = Util.getJREDirectory();
- static final String[] COMPILATION_CLASSPATH = new String[] {Util.getJavaClassLib(), Util.getOutputDirectory()};
- static final String[] RUNTIME_CLASSPATH = new String[] {Util.getOutputDirectory()};
- static final String TARGET_PATH = Util.getOutputDirectory() + File.separator + "evaluation";
- protected EvaluationContext context;
- protected LocalVirtualMachine launchedVM;
- protected TargetInterface target;
- protected Requestor requestor;
-
- class Requestor implements IRequestor {
- int globalProblemCount = 0;
- public boolean acceptClassFiles(ClassFile[] classFiles, char[] codeSnippetClassName) {
- try {
- target.sendClasses(codeSnippetClassName != null, classFiles);
- } catch (TargetException e) {
- return false;
- }
- if (codeSnippetClassName != null) {
- TargetInterface.Result result = target.getResult();
- if (result.displayString == null) {
- System.out.println("(No explicit return value)");
- } else {
- System.out.print("(");
- System.out.print(result.typeName);
- System.out.print(") ");
- System.out.println(result.displayString);
- }
- } else {
- for (int i = 0, length = classFiles.length; i < length; i++) {
- char[][] compoundName = classFiles[i].getCompoundName();
- if (new String(compoundName[compoundName.length-1]).startsWith("GlobalVariable")) {
- try {
- IBinaryField[] fields = new ClassFileReader(classFiles[i].getBytes(), null).getFields();
- if (fields != null) {
- for (int j = 0; j < fields.length; j++) {
- TargetInterface.Result result = target.getResult();
- if (result.displayString == null) {
- System.out.println("(No explicit return value)");
- } else {
- System.out.print("(");
- System.out.print(result.typeName);
- System.out.print(") ");
- System.out.println(result.displayString);
- }
- }
- }
- } catch (ClassFormatException e) {
- }
- }
- }
- }
- return true;
- }
- public void acceptProblem(IProblem problem, char[] fragmentSource, int fragmentKind) {
- int localErrorCount = 0;
- globalProblemCount++;
- char[] source = fragmentSource;
- if (localErrorCount == 0)
- System.out.println("----------");
- if (fragmentKind == EvaluationResult.T_INTERNAL) {
- System.out.print(globalProblemCount + (problem.isError() ? ". INTERNAL ERROR" : ". INTERNAL WARNING"));
- System.out.print(" in generated compilation unit");
- } else {
- System.out.print(globalProblemCount + (problem.isError() ? ". ERROR" : ". WARNING"));
- System.out.print(" in ");
- switch (fragmentKind) {
- case EvaluationResult.T_PACKAGE:
- System.out.print("package");
- break;
- case EvaluationResult.T_IMPORT:
- System.out.print("import");
- break;
- case EvaluationResult.T_CODE_SNIPPET:
- System.out.print("code snippet");
- break;
- case EvaluationResult.T_VARIABLE:
- int line = problem.getSourceLineNumber();
- if (line == -1) {
- System.out.print("variable type");
- source = findVar(context, fragmentSource).getTypeName();
- } else if (line == 0) {
- System.out.print("variable name");
- source = findVar(context, fragmentSource).getName();
- } else {
- System.out.print("variable initializer");
- source = findVar(context, fragmentSource).getInitializer();
- }
- break;
- }
- }
- System.out.println(errorReportSource((DefaultProblem)problem, source));
- System.out.println(problem.getMessage());
- System.out.println("----------");
- if (problem.isError())
- localErrorCount++;
- }
- }
-/**
- * Build a char array from the given lines
- */
-protected char[] buildCharArray(String[] lines) {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < lines.length; i++) {
- buffer.append(lines[i]);
- if (i < lines.length -1) {
- buffer.append("\n");
- }
- }
- int length = buffer.length();
- char[] result = new char[length];
- buffer.getChars(0, length, result, 0);
- return result;
-}
-private String errorReportSource(DefaultProblem problem, char[] source) {
- //extra from the source the innacurate token
- //and "highlight" it using some underneath ^^^^^
- //put some context around too.
-
- //this code assumes that the font used in the console is fixed size
-
- //sanity .....
- if ((problem.getSourceStart() > problem.getSourceEnd()) || ((problem.getSourceStart() < 0) && (problem.getSourceEnd() < 0)))
- return "\n!! no source information available !!";
-
- //regular behavior....(slow code)
-
- final char SPACE = '\u0020';
- final char MARK = '^';
- final char TAB = '\t';
- //the next code tries to underline the token.....
- //it assumes (for a good display) that token source does not
- //contain any \r \n. This is false on statements !
- //(the code still works but the display is not optimal !)
-
- //compute the how-much-char we are displaying around the inaccurate token
- int begin = problem.getSourceStart() >= source.length ? source.length - 1 : problem.getSourceStart();
- int relativeStart = 0;
- int end = problem.getSourceEnd() >= source.length ? source.length - 1 : problem.getSourceEnd();
- int relativeEnd = 0;
- label : for (relativeStart = 0;; relativeStart++) {
- if (begin == 0)
- break label;
- if ((source[begin - 1] == '\n') || (source[begin - 1] == '\r'))
- break label;
- begin--;
- }
- label : for (relativeEnd = 0;; relativeEnd++) {
- if ((end + 1) >= source.length)
- break label;
- if ((source[end + 1] == '\r') || (source[end + 1] == '\n')) {
- break label;
- }
- end++;
- }
- //extract the message form the source
- char[] extract = new char[end - begin + 1];
- System.arraycopy(source, begin, extract, 0, extract.length);
- char c;
- //remove all SPACE and TAB that begin the error message...
- int trimLeftIndex = 0;
- while (((c = extract[trimLeftIndex++]) == TAB) || (c == SPACE)) {
- };
- System.arraycopy(extract, trimLeftIndex - 1, extract = new char[extract.length - trimLeftIndex + 1], 0, extract.length);
- relativeStart -= trimLeftIndex;
- //buffer spaces and tabs in order to reach the error position
- int pos = 0;
- char[] underneath = new char[extract.length]; // can't be bigger
- for (int i = 0; i <= relativeStart; i++) {
- if (extract[i] == TAB) {
- underneath[pos++] = TAB;
- } else {
- underneath[pos++] = SPACE;
- }
- }
- //mark the error position
- for (int i = problem.getSourceStart(); i <= (problem.getSourceEnd() >= source.length ? source.length - 1 : problem.getSourceEnd()); i++)
- underneath[pos++] = MARK;
- //resize underneathto remove 'null' chars
- System.arraycopy(underneath, 0, underneath = new char[pos], 0, pos);
- return
- ((problem.getSourceLineNumber() > 0) ?
- (" (at line " + String.valueOf(problem.getSourceLineNumber()) + ")") :
- ""
- ) +
- "\n\t" + new String(extract) + "\n\t" + new String(underneath);
-}
-private GlobalVariable findVar(EvaluationContext context, char[] varName) {
- GlobalVariable[] vars = context.allVariables();
- for (int i = 0; i < vars.length; i++) {
- GlobalVariable var = vars[i];
- if (CharOperation.equals(var.getName(), varName)) {
- return var;
- }
- }
- return null;
-}
-protected INameEnvironment getEnv() {
-
- return new FileSystem(COMPILATION_CLASSPATH, new String[0], null);
-}
-protected IProblemFactory getProblemFactory() {
- return new DefaultProblemFactory(java.util.Locale.getDefault());
-}
-protected void startEvaluationContext() throws TargetException {
- LocalVMLauncher launcher = LocalVMLauncher.getLauncher();
- launcher.setVMPath(JRE_PATH);
- launcher.setClassPath(RUNTIME_CLASSPATH);
- int evalPort = Util.nextAvailablePortNumber();
- launcher.setEvalPort(evalPort);
- launcher.setEvalTargetPath(TARGET_PATH);
- this.launchedVM = launcher.launch();
-
- (new Thread() {
- public void run() {
- try {
- java.io.InputStream in = SimpleTest.this.launchedVM.getInputStream();
- int read = 0;
- while (read != -1) {
- try {
- read = in.read();
- } catch (java.io.IOException e) {
- read = -1;
- }
- if (read != -1) {
- System.out.print((char)read);
- }
- }
- } catch (TargetException e) {
- }
- }
- }).start();
-
- (new Thread() {
- public void run() {
- try {
- java.io.InputStream in = SimpleTest.this.launchedVM.getErrorStream();
- int read = 0;
- while (read != -1) {
- try {
- read = in.read();
- } catch (java.io.IOException e) {
- read = -1;
- }
- if (read != -1) {
- System.out.print((char)read);
- }
- }
- } catch (TargetException e) {
- }
- }
- }).start();
-
- this.requestor = new Requestor();
- this.target = new TargetInterface();
- this.target.connect("localhost", evalPort, 10000);
- this.context = new EvaluationContext();
-}
-protected void stopEvaluationContext() throws TargetException {
- try {
- this.target.disconnect(); // Close the socket first so that the OS resource has a chance to be freed.
- int retry = 0;
- while (this.launchedVM.isRunning() && (++retry < 20)) {
- try {
- Thread.sleep(retry * 100);
- } catch (InterruptedException e) {
- }
- }
- if (this.launchedVM.isRunning()) {
- this.launchedVM.shutDown();
- }
- this.context = null;
- } catch (TargetException e) {
- throw new Error(e.getMessage());
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SimpleVariableTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SimpleVariableTest.java
deleted file mode 100644
index d176258..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/SimpleVariableTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import org.eclipse.jdt.core.tests.runtime.TargetException;
-import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.internal.eval.EvaluationContext;
-import org.eclipse.jdt.internal.eval.GlobalVariable;
-import org.eclipse.jdt.internal.eval.InstallException;
-
-public class SimpleVariableTest extends SimpleTest {
-void evaluateVariable() throws TargetException, InstallException {
- startEvaluationContext();
- GlobalVariable var = getVariable(context);
- INameEnvironment env = getEnv();
- this.context.evaluateVariables(env, null, this.requestor, getProblemFactory());
- this.context.deleteVariable(var);
- stopEvaluationContext();
-}
-public GlobalVariable getVariable(EvaluationContext context) {
- return context.newVariable(
- "int".toCharArray(),
- "var".toCharArray(),
- "1".toCharArray());
-}
-public static void main(String[] args) throws TargetException, InstallException {
- SimpleVariableTest test = new SimpleVariableTest();
- test.evaluateVariable();
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/TestAll.java
deleted file mode 100644
index b999025..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/TestAll.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-/**
- * Run all tests defined in this package.
- */
-public class TestAll extends EvaluationTest {
-public TestAll(String name) {
- super(name);
-}
-public static Test suite() {
- return suite(JRE_PATH, EVAL_DIRECTORY);
-}
-public static Test suite(String jrePath, String evalDirectory) {
- TestSuite suite = new TestSuite(TestAll.class.getName());
- suite.addTest(suite(SanityTestEvaluationContext.class));
- suite.addTest(suite(SanityTestEvaluationResult.class));
- suite.addTest(suite(VariableTest.class));
- suite.addTest(suite(CodeSnippetTest.class));
- suite.addTest(suite(NegativeCodeSnippetTest.class));
- suite.addTest(suite(NegativeVariableTest.class));
- suite.addTest(suite(DebugEvaluationTest.class));
- EvaluationSetup evalSetup = new DebugEvaluationSetup(suite);
- evalSetup.jrePath = jrePath;
- evalSetup.evalDirectory = evalDirectory;
- return evalSetup;
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/VariableTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/VariableTest.java
deleted file mode 100644
index 2683fca..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/VariableTest.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.internal.eval.GlobalVariable;
-/**
- * Test the global variable evaluation.
- * This assumes that the EvaluationContext class and that the GlobalVariable class
- * are working correctly.
- */
-public class VariableTest extends EvaluationTest {
-/**
- * Creates a new EvaluationContextTest.
- */
-public VariableTest(String name) {
- super(name);
-}
-public static Test suite() {
- return setupSuite(testClass());
-}
-/**
- * Tests the individual evaluation of variables with expected values of all kind of types.
- */
-public void testAllKindOfValues() {
- try {
- // Creates the variables
- GlobalVariable var1 = context.newVariable("int".toCharArray(), "var1".toCharArray(), "1".toCharArray());
- GlobalVariable var2 = context.newVariable("boolean".toCharArray(), "var2".toCharArray(), "true".toCharArray());
- GlobalVariable var3 = context.newVariable("char".toCharArray(), "var3".toCharArray(), "'c'".toCharArray());
- GlobalVariable var4 = context.newVariable("float".toCharArray(), "var4".toCharArray(), "(float)1.0".toCharArray());
- GlobalVariable var5 = context.newVariable("double".toCharArray(), "var5".toCharArray(), "1.0".toCharArray());
- GlobalVariable var6 = context.newVariable("short".toCharArray(), "var6".toCharArray(), "(short)1".toCharArray());
- GlobalVariable var7 = context.newVariable("long".toCharArray(), "var7".toCharArray(), "(long)1".toCharArray());
- GlobalVariable var8 = context.newVariable("String".toCharArray(), "var8".toCharArray(), "\"hello\"".toCharArray());
- GlobalVariable var9 = context.newVariable("Object".toCharArray(), "var9".toCharArray(), buildCharArray(new String[] {
- "new Object() {",
- " public String toString() {",
- " return \"an object\";",
- " }",
- "}"}));
- GlobalVariable var10 = context.newVariable("Object".toCharArray(), "var10".toCharArray(), null);
-
- // Install them
- installVariables(10);
-
- // Get values one by one
- evaluateWithExpectedValue(var1, "1".toCharArray(), "int".toCharArray());
- evaluateWithExpectedValue(var2, "true".toCharArray(), "boolean".toCharArray());
- evaluateWithExpectedValue(var3, "c".toCharArray(), "char".toCharArray());
- evaluateWithExpectedValue(var4, "1.0".toCharArray(), "float".toCharArray());
- evaluateWithExpectedValue(var5, "1.0".toCharArray(), "double".toCharArray());
- evaluateWithExpectedValue(var6, "1".toCharArray(), "short".toCharArray());
- evaluateWithExpectedValue(var7, "1".toCharArray(), "long".toCharArray());
- evaluateWithExpectedValue(var8, "hello".toCharArray(), "java.lang.String".toCharArray());
- evaluateWithExpectedValue(var9, "an object".toCharArray(), "java.lang.Object".toCharArray());
- evaluateWithExpectedValue(var10, "null".toCharArray(), "java.lang.Object".toCharArray());
- } finally {
- // Clean up
- GlobalVariable[] vars = context.allVariables();
- for (int i = 0; i < vars.length; i++) {
- context.deleteVariable(vars[i]);
- }
- }
-}
-public static Class testClass() {
- return VariableTest.class;
-}
-/**
- * Tests the assignment of a global variable in a code snippet.
- */
-public void testCodeSnippetVarAssign() {
- try {
- // Creates the variables
- GlobalVariable var1 = context.newVariable("int".toCharArray(), "var1".toCharArray(), null);
- GlobalVariable var2 = context.newVariable("boolean".toCharArray(), "var2".toCharArray(), null);
- GlobalVariable var3 = context.newVariable("char".toCharArray(), "var3".toCharArray(), null);
- GlobalVariable var4 = context.newVariable("float".toCharArray(), "var4".toCharArray(), null);
- GlobalVariable var5 = context.newVariable("double".toCharArray(), "var5".toCharArray(), null);
- GlobalVariable var6 = context.newVariable("short".toCharArray(), "var6".toCharArray(), null);
- GlobalVariable var7 = context.newVariable("long".toCharArray(), "var7".toCharArray(), null);
- GlobalVariable var8 = context.newVariable("String".toCharArray(), "var8".toCharArray(), null);
- GlobalVariable var9 = context.newVariable("Object".toCharArray(), "var9".toCharArray(), null);
- GlobalVariable var10 = context.newVariable("Object".toCharArray(), "var10".toCharArray(), null);
-
- // Install them
- installVariables(10);
-
- // Assign each of the variable and get its value
- evaluateWithExpectedDisplayString("var1 = 1;".toCharArray(), "1".toCharArray());
- evaluateWithExpectedValue(var1, "1".toCharArray(), "int".toCharArray());
-
- evaluateWithExpectedDisplayString("var2 = true;".toCharArray(), "true".toCharArray());
- evaluateWithExpectedValue(var2, "true".toCharArray(), "boolean".toCharArray());
-
- evaluateWithExpectedDisplayString("var3 = 'c';".toCharArray(), "c".toCharArray());
- evaluateWithExpectedValue(var3, "c".toCharArray(), "char".toCharArray());
-
- evaluateWithExpectedDisplayString("var4 = (float)1.0;".toCharArray(), "1.0".toCharArray());
- evaluateWithExpectedValue(var4, "1.0".toCharArray(), "float".toCharArray());
-
- evaluateWithExpectedDisplayString("var5 = 1.0;".toCharArray(), "1.0".toCharArray());
- evaluateWithExpectedValue(var5, "1.0".toCharArray(), "double".toCharArray());
-
- evaluateWithExpectedDisplayString("var6 = (short)1;".toCharArray(), "1".toCharArray());
- evaluateWithExpectedValue(var6, "1".toCharArray(), "short".toCharArray());
-
- evaluateWithExpectedDisplayString("var7 = (long)1;".toCharArray(), "1".toCharArray());
- evaluateWithExpectedValue(var7, "1".toCharArray(), "long".toCharArray());
-
- evaluateWithExpectedDisplayString("var8 = \"hello\";".toCharArray(), "hello".toCharArray());
- evaluateWithExpectedValue(var8, "hello".toCharArray(), "java.lang.String".toCharArray());
-
- evaluateWithExpectedDisplayString(buildCharArray(new String[] {
- "var9 = new Object() {",
- " public String toString() {",
- " return \"an object\";",
- " }",
- "};"}), "an object".toCharArray());
- evaluateWithExpectedValue(var9, "an object".toCharArray(), "java.lang.Object".toCharArray());
-
- evaluateWithExpectedDisplayString("var10 = null;".toCharArray(), "null".toCharArray());
- evaluateWithExpectedValue(var10, "null".toCharArray(), "java.lang.Object".toCharArray());
- } finally {
- // Clean up
- GlobalVariable[] vars = context.allVariables();
- for (int i = 0; i < vars.length; i++) {
- context.deleteVariable(vars[i]);
- }
- }
-}
-/**
- * Tests the retrieval of a global variable from a code snippet.
- */
-public void testCodeSnippetVarRetrieval() {
- try {
- // Creates the variables
- GlobalVariable var1 = context.newVariable("int".toCharArray(), "var1".toCharArray(), "1".toCharArray());
- GlobalVariable var2 = context.newVariable("boolean".toCharArray(), "var2".toCharArray(), "true".toCharArray());
- GlobalVariable var3 = context.newVariable("char".toCharArray(), "var3".toCharArray(), "'c'".toCharArray());
- GlobalVariable var4 = context.newVariable("float".toCharArray(), "var4".toCharArray(), "(float)1.0".toCharArray());
- GlobalVariable var5 = context.newVariable("double".toCharArray(), "var5".toCharArray(), "1.0".toCharArray());
- GlobalVariable var6 = context.newVariable("short".toCharArray(), "var6".toCharArray(), "(short)1".toCharArray());
- GlobalVariable var7 = context.newVariable("long".toCharArray(), "var7".toCharArray(), "(long)1".toCharArray());
- GlobalVariable var8 = context.newVariable("String".toCharArray(), "var8".toCharArray(), "\"hello\"".toCharArray());
- GlobalVariable var9 = context.newVariable("Object".toCharArray(), "var9".toCharArray(), buildCharArray(new String[] {
- "new Object() {",
- " public String toString() {",
- " return \"an object\";",
- " }",
- "}"}));
- GlobalVariable var10 = context.newVariable("Object".toCharArray(), "var10".toCharArray(), null);
-
- // Install them
- installVariables(10);
-
- // Get values one by one
- evaluateWithExpectedValue(var1, "1".toCharArray(), "int".toCharArray());
- evaluateWithExpectedValue(var2, "true".toCharArray(), "boolean".toCharArray());
- evaluateWithExpectedValue(var3, "c".toCharArray(), "char".toCharArray());
- evaluateWithExpectedValue(var4, "1.0".toCharArray(), "float".toCharArray());
- evaluateWithExpectedValue(var5, "1.0".toCharArray(), "double".toCharArray());
- evaluateWithExpectedValue(var6, "1".toCharArray(), "short".toCharArray());
- evaluateWithExpectedValue(var7, "1".toCharArray(), "long".toCharArray());
- evaluateWithExpectedValue(var8, "hello".toCharArray(), "java.lang.String".toCharArray());
- evaluateWithExpectedValue(var9, "an object".toCharArray(), "java.lang.Object".toCharArray());
- evaluateWithExpectedValue(var10, "null".toCharArray(), "java.lang.Object".toCharArray());
- } finally {
- // Clean up
- GlobalVariable[] vars = context.allVariables();
- for (int i = 0; i < vars.length; i++) {
- context.deleteVariable(vars[i]);
- }
- }
-}
-/**
- * Tests variables that include one or more imports.
- */
-public void testImports() {
- try {
- // import a package
- context.setImports(new char[][] {"java.io.*".toCharArray()});
- GlobalVariable file = context.newVariable("boolean".toCharArray(), "file".toCharArray(), "new File(\"!@#%\").exists()".toCharArray());
- installVariables(1);
- evaluateWithExpectedValue(file, "false".toCharArray(), "boolean".toCharArray());
- context.deleteVariable(file);
-
- // import a type
- context.setImports(new char[][] {"java.math.BigInteger".toCharArray()});
- GlobalVariable big = context.newVariable("BigInteger".toCharArray(), "big".toCharArray(), "new BigInteger(\"123456789012345678901234567890\")".toCharArray());
- installVariables(1);
- evaluateWithExpectedValue(big, "123456789012345678901234567890".toCharArray(), "java.math.BigInteger".toCharArray());
- context.deleteVariable(big);
-
- // import a type and a package
- context.setImports(new char[][] {"java.util.Enumeration".toCharArray(), "java.lang.reflect.*".toCharArray()});
- GlobalVariable fields = context.newVariable("Field[]".toCharArray(), "fields".toCharArray(), "Enumeration.class.getDeclaredFields()".toCharArray());
- installVariables(1);
- evaluateWithExpectedType("return fields;".toCharArray(), "[Ljava.lang.reflect.Field;".toCharArray());
- context.deleteVariable(fields);
- } finally {
- // clean up
- context.setImports(new char[0][]);
- }
-}
-/**
- * Tests the additions and deletion of variables, installing them each time.
- */
-public void testSeveralVariableInstallations() {
- try {
- // Creates 6 variables
- GlobalVariable var1 = context.newVariable("int".toCharArray(), "var1".toCharArray(), "1".toCharArray());
- GlobalVariable var2 = context.newVariable("boolean".toCharArray(), "var2".toCharArray(), "true".toCharArray());
- GlobalVariable var3 = context.newVariable("char".toCharArray(), "var3".toCharArray(), "'c'".toCharArray());
- GlobalVariable var4 = context.newVariable("float".toCharArray(), "var4".toCharArray(), "(float)1.0".toCharArray());
- GlobalVariable var5 = context.newVariable("double".toCharArray(), "var5".toCharArray(), "1.0".toCharArray());
- GlobalVariable var6 = context.newVariable("short".toCharArray(), "var6".toCharArray(), "(short)1".toCharArray());
-
- // Install the variables
- installVariables(6);
-
- // Get their values
- evaluateWithExpectedValue(var1, "1".toCharArray(), "int".toCharArray());
- evaluateWithExpectedValue(var2, "true".toCharArray(), "boolean".toCharArray());
- evaluateWithExpectedValue(var3, "c".toCharArray(), "char".toCharArray());
- evaluateWithExpectedValue(var4, "1.0".toCharArray(), "float".toCharArray());
- evaluateWithExpectedValue(var5, "1.0".toCharArray(), "double".toCharArray());
- evaluateWithExpectedValue(var6, "1".toCharArray(), "short".toCharArray());
-
- // Delete 3 variables
- context.deleteVariable(var2);
- context.deleteVariable(var5);
- context.deleteVariable(var6);
-
- // Install the variables
- installVariables(3);
-
- // Get their values
- evaluateWithExpectedValue(var1, "1".toCharArray(), "int".toCharArray());
- evaluateWithExpectedValue(var3, "c".toCharArray(), "char".toCharArray());
- evaluateWithExpectedValue(var4, "1.0".toCharArray(), "float".toCharArray());
-
- // Add 4 more variables
- GlobalVariable var7 = context.newVariable("long".toCharArray(), "var7".toCharArray(), "(long)1".toCharArray());
- GlobalVariable var8 = context.newVariable("String".toCharArray(), "var8".toCharArray(), "\"hello\"".toCharArray());
- GlobalVariable var9 = context.newVariable("Object".toCharArray(), "var9".toCharArray(), buildCharArray(new String[] {
- "new Object() {",
- " public String toString() {",
- " return \"an object\";",
- " }",
- "}"}));
- GlobalVariable var10 = context.newVariable("Object".toCharArray(), "var10".toCharArray(), null);
-
- // Install the variables
- installVariables(7);
-
- // Change value of a variable using a code snippet and move it
- evaluateWithExpectedValue("var3 = 'z'; return var3;".toCharArray(), "z".toCharArray(), "char".toCharArray());
- context.deleteVariable(var3);
- var3 = context.newVariable(var3.getTypeName(), var3.getName(), var3.getInitializer());
-
- // Change the type of another variable to an incompatible type
- context.deleteVariable(var4);
- var4 = context.newVariable("java.net.URL".toCharArray(), "var4".toCharArray(), "new java.net.URL(\"http://www.ibm.com/index.html\")".toCharArray());
-
- // Upadte the variables
- installVariables(7);
-
- // Get their values
- evaluateWithExpectedValue(var1, "1".toCharArray(), "int".toCharArray());
- evaluateWithExpectedValue(var3, "z".toCharArray(), "char".toCharArray());
- evaluateWithExpectedValue(var4, "http://www.ibm.com/index.html".toCharArray(), "java.net.URL".toCharArray());
- evaluateWithExpectedValue(var7, "1".toCharArray(), "long".toCharArray());
- evaluateWithExpectedValue(var8, "hello".toCharArray(), "java.lang.String".toCharArray());
- evaluateWithExpectedValue(var9, "an object".toCharArray(), "java.lang.Object".toCharArray());
- evaluateWithExpectedValue(var10, "null".toCharArray(), "java.lang.Object".toCharArray());
- } finally {
- // Clean up
- GlobalVariable[] vars = context.allVariables();
- for (int i = 0; i < vars.length; i++) {
- context.deleteVariable(vars[i]);
- }
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetClassLoader.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetClassLoader.java
deleted file mode 100644
index 6553548..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetClassLoader.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval.target;
-
-import java.util.*;
-
-/**
- * A code snippet class loader is a class loader that loads code snippet classes and global
- * variable classes.
- */
-public class CodeSnippetClassLoader extends ClassLoader {
- /**
- * Whether the code snippet support classes should be given by the IDE
- * or should be found on disk.
- */
- static boolean DEVELOPMENT_MODE = false;
-
- Hashtable loadedClasses = new Hashtable();
-/**
- * Asks the class loader that loaded this class to load the given class.
- * @throws a ClassNotFoundException if it could not be loaded.
- */
-private Class delegateLoadClass(String name) throws ClassNotFoundException {
- ClassLoader myLoader = getClass().getClassLoader();
- if (myLoader == null) {
- return Class.forName(name);
- } else {
- return myLoader.loadClass(name);
- }
-}
-/**
- * Loads the given class. If the class is known to this runner, returns it.
- * If only the class definition is known to this runner, makes it a class and returns it.
- * Otherwise delegates to the real class loader.
- */
-protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
- if (DEVELOPMENT_MODE) {
- try {
- return delegateLoadClass(name);
- } catch (ClassNotFoundException e) {
- Class clazz = makeClass(name, resolve);
- if (clazz == null) {
- throw e;
- } else {
- return clazz;
- }
- }
- } else {
- Class clazz = makeClass(name, resolve);
- if (clazz == null) {
- return delegateLoadClass(name);
- } else {
- return clazz;
- }
- }
-}
-/**
- * Loads the given class either from the stored class definition or from the system.
- * Returns the existing class if it has already been loaded.
- * Returns null if no class definition can be found.
- */
-Class loadIfNeeded(String className) {
- Class clazz = null;
- if (!supportsHotCodeReplacement()) {
- clazz = findLoadedClass(className);
- }
- if (clazz == null) {
- try {
- clazz = loadClass(className, true);
- } catch (NoClassDefFoundError e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- return clazz;
-}
-/**
- * Makes the class definition known by this code snippet runner a real class and
- * returns it.
- * Returns null if there is no class definition.
- */
-private Class makeClass(String name, boolean resolve) {
- Object o = this.loadedClasses.get(name);
- if (o == null) {
- return null;
- } else {
- if (o instanceof Class) {
- return (Class) o;
- } else {
- byte[] classDefinition = (byte[]) o;
- Class clazz = defineClass(null, classDefinition, 0, classDefinition.length);
- if (resolve) {
- resolveClass(clazz);
- }
- this.loadedClasses.put(name, clazz);
- return clazz;
- }
- }
-}
-/**
- * Stores the given class definition for the given class.
- */
-void storeClassDefinition(String className, byte[] classDefinition) {
- Object clazz = this.loadedClasses.get(className);
- if (clazz == null || supportsHotCodeReplacement()) {
- this.loadedClasses.put(className, classDefinition);
- }
-}
-/**
- * Returns whether this class loader supports Hot Code Replacement.
- */
-protected boolean supportsHotCodeReplacement() {
- return false;
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetRunner.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetRunner.java
deleted file mode 100644
index 7684200..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetRunner.java
+++ /dev/null
@@ -1,472 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval.target;
-
-import java.lang.reflect.*;
-import java.io.*;
-import java.util.*;
-
-/**
- * A code snippet runner loads code snippet classes and global
- * variable classes, and that run the code snippet classes.
- * <p>
- * When started, this runner first connects using TCP/IP to the provided port number.
- * If a regular classpath directory is provided, it writes the class definitions it gets from the IDE
- * to this directory (or to the bootclasspath directory if the class name starts with "java") and it
- * lets the system class loader (or the bootstrap class loader if it is a "java" class) load
- * the class.
- * If the regular classpath directory is null, it uses a code snippet class loader to load the classes
- * it gets from the IDE.
- * <p>
- * IMPORTANT NOTE:
- * Using a code snippet class loader has the following limitation when the code snippet is ran:
- * <ul>
- * <li>The code snippet class can access only public classes, and public members or these classes.
- * This is because the "runtime package" of the code snippet class is always different from
- * the "runtime package" of the class it is trying to access since the class loaders are
- * different.
- * <li>The code snippet class cannot be defined in a "java.*" package. Only the bootstrap class
- * loader can load such a class.
- * </ul>
- */
-public class CodeSnippetRunner {
- public static CodeSnippetRunner theRunner;
- static final String CODE_SNIPPET_CLASS_NAME = "org.eclipse.jdt.internal.eval.target.CodeSnippet";
- static final String RUN_METHOD_NAME = "run";
- static final String GET_RESULT_TYPE_METHOD_NAME = "getResultType";
- static final String GET_RESULT_VALUE_METHOD_NAME = "getResultValue";
-
- IDEInterface ide;
- String classPathDirectory;
- String bootclassPathDirectory;
- CodeSnippetClassLoader loader;
- Class codeSnippetClass = null;
-/**
- * Creates a new code snippet runner.
- */
-public CodeSnippetRunner(int portNumber, String classPathDirectory, String bootclassPathDirectory) {
- this.ide = new IDEInterface(portNumber);
- if (classPathDirectory != null) {
- this.classPathDirectory = classPathDirectory;
- if (bootclassPathDirectory != null) {
- this.bootclassPathDirectory = bootclassPathDirectory;
- }
- } else {
- this.loader = new CodeSnippetClassLoader();
- }
-}
-/**
- * Returns the forward slash separated class name from the given class definition.
- */
-private String className(byte[] classDefinition) {
- // NB: The following code was copied from org.eclipse.jdt.internal.compiler.cfmt,
- // thus it is highly dependent on the class file format.
- int readOffset = 10;
- try {
- int constantPoolCount = u2At(8, classDefinition);
- int[] constantPoolOffsets = new int[constantPoolCount];
- for (int i = 1; i < constantPoolCount; i++) {
- int tag = u1At(readOffset, classDefinition);
- switch (tag) {
- case 1 : // Utf8Tag
- constantPoolOffsets[i] = readOffset;
- readOffset += u2At(readOffset + 1, classDefinition);
- readOffset += 3; // ConstantUtf8.fixedSize
- break;
- case 3 : // IntegerTag
- constantPoolOffsets[i] = readOffset;
- readOffset += 5; // ConstantInteger.fixedSize
- break;
- case 4 : // FloatTag
- constantPoolOffsets[i] = readOffset;
- readOffset += 5; // ConstantFloat.fixedSize
- break;
- case 5 : // LongTag
- constantPoolOffsets[i] = readOffset;
- readOffset += 9; // ConstantLong.fixedSize
- i++;
- break;
- case 6 : // DoubleTag
- constantPoolOffsets[i] = readOffset;
- readOffset += 9; // ConstantDouble.fixedSize
- i++;
- break;
- case 7 : // ClassTag
- constantPoolOffsets[i] = readOffset;
- readOffset += 3; // ConstantClass.fixedSize
- break;
- case 8 : // StringTag
- constantPoolOffsets[i] = readOffset;
- readOffset += 3; // ConstantString.fixedSize
- break;
- case 9 : // FieldRefTag
- constantPoolOffsets[i] = readOffset;
- readOffset += 5; // ConstantFieldRef.fixedSize
- break;
- case 10 : // MethodRefTag
- constantPoolOffsets[i] = readOffset;
- readOffset += 5; // ConstantMethodRef.fixedSize
- break;
- case 11 : // InterfaceMethodRefTag
- constantPoolOffsets[i] = readOffset;
- readOffset += 5; // ConstantInterfaceMethodRef.fixedSize
- break;
- case 12 : // NameAndTypeTag
- constantPoolOffsets[i] = readOffset;
- readOffset += 5; // ConstantNameAndType.fixedSize
- }
- }
- // Skip access flags
- readOffset += 2;
-
- // Read the classname, use exception handlers to catch bad format
- int constantPoolIndex = u2At(readOffset, classDefinition);
- int utf8Offset = constantPoolOffsets[u2At(constantPoolOffsets[constantPoolIndex] + 1, classDefinition)];
- char[] className = utf8At(utf8Offset + 3, u2At(utf8Offset + 1, classDefinition), classDefinition);
- return new String(className);
- } catch (ArrayIndexOutOfBoundsException e) {
- e.printStackTrace();
- return null;
- }
-}
-/**
- * Creates a new instance of the given class. It is
- * assumed that it is a subclass of CodeSnippet.
- */
-Object createCodeSnippet(Class snippetClass) {
- Object object = null;
- try {
- object = snippetClass.newInstance();
- } catch (InstantiationException e) {
- e.printStackTrace();
- this.ide.sendResult(void.class, null);
- return null;
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- this.ide.sendResult(void.class, null);
- return null;
- }
- return object;
-}
-/**
- * Whether this code snippet runner is currently running.
- */
-public boolean isRunning() {
- return this.ide.isConnected();
-}
-/**
- * Starts a new CodeSnippetRunner that will serve code snippets from the IDE.
- * It waits for a connection on the given evaluation port number.
- * <p>
- * Usage: java org.eclipse.jdt.tests.eval.target.CodeSnippetRunner -evalport <portNumber> [-options] [<mainClassName>] [<arguments>]
- * where options include:
- * -cscp <codeSnippetClasspath> the the classpath directory for the code snippet classes.
- * that are not defined in a "java.*" package.
- * -csbp <codeSnippetBootClasspath> the bootclasspath directory for the code snippet classes
- * that are defined in a "java.*" package.
- * <p>
- * The mainClassName and its arguments are optional: when not present only the server will start
- * and run until the VM is shut down, when present the server will start, the main class will run
- * but the server will exit when the main class has finished running.
- */
-public static void main(String[] args) {
- int length = args.length;
- if (length < 2 || !args[0].toLowerCase().equals("-evalport")) {
- printUsage();
- return;
- } else {
- int evalPort = Integer.parseInt(args[1]);
- String classPath = null;
- String bootPath = null;
- int mainClass = -1;
- for (int i = 2; i < length; i++) {
- String arg = args[i];
- if (arg.startsWith("-")) {
- if (arg.toLowerCase().equals("-cscp")) {
- if (++i < length) {
- classPath = args[i];
- } else {
- printUsage();
- return;
- }
- } else if (arg.toLowerCase().equals("-csbp")) {
- if (++i < length) {
- bootPath = args[i];
- } else {
- printUsage();
- return;
- }
- }
- } else {
- mainClass = i;
- break;
- }
- }
- theRunner = new CodeSnippetRunner(evalPort, classPath, bootPath);
- if (mainClass == -1) {
- theRunner.start();
- } else {
- Thread server = new Thread() {
- public void run() {
- theRunner.start();
- }
- };
- server.setDaemon(true);
- server.start();
- int mainArgsLength = length-mainClass-1;
- String[] mainArgs = new String[mainArgsLength];
- System.arraycopy(args, mainClass+1, mainArgs, 0, mainArgsLength);
- try {
- Class clazz = Class.forName(args[mainClass]);
- Method mainMethod = clazz.getMethod("main", new Class[] {String[].class});
- mainMethod.invoke(null, new String[][] {mainArgs});
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- }
- }
-}
-private static void printUsage() {
- System.out.println("Usage: java org.eclipse.jdt.tests.eval.target.CodeSnippetRunner -evalport <portNumber> [-options] [<mainClassName>] [<arguments>]");
- System.out.println("where options include:");
- System.out.println("-cscp <codeSnippetClasspath> the the classpath directory for the code snippet classes.");
- System.out.println("that are not defined in a \"java.*\" package.");
- System.out.println("-csbp <codeSnippetBootClasspath> the bootclasspath directory for the code snippet classes");
- System.out.println("that are defined in a \"java.*\" package.");
-}
-/**
- * Loads the given class definitions. The way these class definitions are loaded is described
- * in the CodeSnippetRunner constructor.
- * The class definitions are code snippet classes and/or global variable classes.
- * Code snippet classes are assumed be direct or indirect subclasses of CodeSnippet and implement
- * only the run()V method.
- * They are instanciated and run.
- * Global variable classes are assumed to be direct subclasses of CodeSnippet. Their fields are assumed
- * to be static. The value of each field is sent back to the IDE.
- */
-void processClasses(boolean mustRun, byte[][] classDefinitions) {
- // store the class definitions (either in the code snippet class loader or on disk)
- String[] newClasses = new String[classDefinitions.length];
- for (int i = 0; i < classDefinitions.length; i++) {
- byte[] classDefinition = classDefinitions[i];
- String classFileName = className(classDefinition);
- String className = classFileName.replace('/', '.');
- if (this.loader != null) {
- this.loader.storeClassDefinition(className, classDefinition);
- } else {
- writeClassOnDisk(classFileName, classDefinition);
- }
- newClasses[i] = className;
- }
-
- // load the classes and collect code snippet classes
- Vector codeSnippetClasses = new Vector();
- for (int i = 0; i < newClasses.length; i++) {
- String className = newClasses[i];
- Class clazz = null;
- if (this.loader != null) {
- clazz = this.loader.loadIfNeeded(className);
- if (clazz == null) {
- System.err.println("Could not find class definition for " + className);
- break;
- }
- } else {
- // use the system class loader
- try {
- clazz = Class.forName(className);
- } catch (ClassNotFoundException e) {
- e.printStackTrace(); // should never happen since we just wrote it on disk
- this.ide.sendResult(void.class, null);
- break;
- }
- }
-
- Class superclass = clazz.getSuperclass();
- Method[] methods = clazz.getDeclaredMethods();
- if (this.codeSnippetClass == null) {
- if (superclass.equals(Object.class) && clazz.getName().equals(CODE_SNIPPET_CLASS_NAME)) {
- // The CodeSnippet class is being deployed
- this.codeSnippetClass = clazz;
- } else {
- System.out.println("Expecting CodeSnippet class to be deployed first");
- }
- } else if (superclass.equals(this.codeSnippetClass)) {
- // It may be a code snippet class with no global variable
- if (methods.length == 1 && methods[0].getName().equals(RUN_METHOD_NAME)) {
- codeSnippetClasses.addElement(clazz);
- }
- // Evaluate global variables and send result back
- Field[] fields = clazz.getDeclaredFields();
- for (int j = 0; j < fields.length; j++) {
- Field field = fields[j];
- if (Modifier.isPublic(field.getModifiers())) {
- try {
- this.ide.sendResult(field.getType(), field.get(null));
- } catch (IllegalAccessException e) {
- e.printStackTrace(); // Cannot happen because the field is public
- this.ide.sendResult(void.class, null);
- break;
- }
- }
- }
- } else if (this.codeSnippetClass.equals(superclass.getSuperclass()) && methods.length == 1 && methods[0].getName().equals("run")) {
- // It is a code snippet class with a global variable superclass
- codeSnippetClasses.addElement(clazz);
- }
- }
-
- // run the code snippet classes
- if (codeSnippetClasses.size() != 0 && mustRun) {
- for (Enumeration e = codeSnippetClasses.elements(); e.hasMoreElements();) {
- Object codeSnippet = this.createCodeSnippet((Class) e.nextElement());
- if (codeSnippet != null) {
- this.runCodeSnippet(codeSnippet);
- }
- }
- }
-}
-/**
- * Runs the given code snippet in a new thread and send the result back to the IDE.
- */
-void runCodeSnippet(final Object snippet) {
- Thread thread = new Thread() {
- public void run() {
- try {
- try {
- Method runMethod = codeSnippetClass.getMethod(RUN_METHOD_NAME, new Class[] {});
- runMethod.invoke(snippet, new Object[] {});
- } finally {
- Method getResultTypeMethod = codeSnippetClass.getMethod(GET_RESULT_TYPE_METHOD_NAME, new Class[] {});
- Class resultType = (Class)getResultTypeMethod.invoke(snippet, new Object[] {});
- Method getResultValueMethod = codeSnippetClass.getMethod(GET_RESULT_VALUE_METHOD_NAME, new Class[] {});
- Object resultValue = getResultValueMethod.invoke(snippet, new Object[] {});
- CodeSnippetRunner.this.ide.sendResult(resultType, resultValue);
- }
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- System.out.println("codeSnippetClass = " + codeSnippetClass.getName());
- System.out.println("snippet.class = " + snippet.getClass().getName());
- Class superclass = snippet.getClass().getSuperclass();
- System.out.println("snippet.superclass = " + (superclass == null ? "null" : superclass.getName()));
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.getTargetException().printStackTrace();
- }
- }
- };
- thread.setDaemon(true);
- thread.start();
-}
-/**
- * Starts this code snippet runner in a different thread.
- */
-public void start() {
- Thread thread = new Thread("Code snippet runner") {
- public void run() {
- try {
- ide.connect();
- } catch (IOException e) {
- e.printStackTrace();
- }
- while (ide.isConnected()) {
- try {
- processClasses(ide.getRunFlag(), ide.getNextClasses());
- } catch (Error e) {
- ide.sendResult(void.class, null);
- e.printStackTrace();
- } catch (RuntimeException e) {
- ide.sendResult(void.class, null);
- e.printStackTrace();
- }
- }
- };
- };
- thread.start();
-}
-/**
- * Stops this code snippet runner.
- */
-public void stop() {
- this.ide.disconnect();
-}
-private int u1At(int position, byte[] bytes) {
- return bytes[position] & 0xFF;
-}
-private int u2At(int position, byte[] bytes) {
- return ((bytes[position++] & 0xFF) << 8) + (bytes[position] & 0xFF);
-}
-private char[] utf8At(int readOffset, int bytesAvailable, byte[] bytes) {
- int x, y, z;
- int length = bytesAvailable;
- char outputBuf[] = new char[bytesAvailable];
- int outputPos = 0;
- while (length != 0) {
- x = bytes[readOffset++] & 0xFF;
- length--;
- if ((0x80 & x) != 0) {
- y = bytes[readOffset++] & 0xFF;
- length--;
- if ((x & 0x20) != 0) {
- z = bytes[readOffset++] & 0xFF;
- length--;
- x = ((x & 0x1F) << 12) + ((y & 0x3F) << 6) + (z & 0x3F);
- } else {
- x = ((x & 0x1F) << 6) + (y & 0x3F);
- }
- }
- outputBuf[outputPos++] = (char) x;
- }
-
- if (outputPos != bytesAvailable) {
- System.arraycopy(outputBuf, 0, (outputBuf = new char[outputPos]), 0, outputPos);
- }
- return outputBuf;
-}
-/**
- * Writes the given class definition on disk. The give name is the forward slash separated
- * fully qualified name of the class.
- */
-private void writeClassOnDisk(String className, byte[] classDefinition) {
- try {
- String fileName = className.replace('/', File.separatorChar) + ".class";
- File classFile = new File(
- (this.bootclassPathDirectory != null &&
- (className.startsWith("java") || className.replace('/', '.').equals(CODE_SNIPPET_CLASS_NAME))) ?
- this.bootclassPathDirectory :
- this.classPathDirectory, fileName);
- File parent = new File(classFile.getParent());
- parent.mkdirs();
- if (!parent.exists()) {
- throw new IOException("Could not create directory " + parent.getPath());
- }
- FileOutputStream out = null;
- try {
- out = new FileOutputStream(classFile);
- out.write(classDefinition);
- } finally {
- if (out != null) {
- out.close();
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/IDEInterface.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/IDEInterface.java
deleted file mode 100644
index d2ad3c1..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/IDEInterface.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.eval.target;
-
-import java.io.*;
-import java.net.*;
-/**
- * The interface to the IDE. When connected, it uses TCP/IP sockets
- * to get code snippet classes and global variable classes from the IDE.
- * It sends the result of the evaluation back using the same socket.
- * <p>
- * The format from the socket input stream is the following:
- * <pre>
- * [run flag: boolean coded on 1 byte]
- * [number of class files: int coded on 4 bytes]
- * *[
- * [length of class file: int coded on 4 bytes]
- * [class file: Java Class file format]
- * ]
- * </pre>
- * This sequence is infinitely repeated until the input socket stream is closed.
- * <p>
- * The format from the socket output stream is the following:
- * <pre>
- * [has result flag: 1 if there is a result, 0 otherwise]
- * if there is a result:
- * [fully qualified type name of result: utf8 encoded string]
- * [toString representation of result: utf8 encoded string]
- * </pre>
- * This sequence is infinitely repeated until the output socket stream is closed.
- */
-public class IDEInterface {
- /**
- * Whether timing info should be printed to stdout
- */
- static final boolean TIMING = false;
- long startTime;
-
- int portNumber = 0;
- Socket socket;
-/**
- * Creates a new IDEInterface.
- */
-IDEInterface(int portNumber) {
- this.portNumber = portNumber;
-}
-/**
- * Waits for a connection from the ide on the given port.
- * @throws IOException if the connection could not be established.
- */
-void connect() throws IOException {
- ServerSocket server = new ServerSocket(this.portNumber);
- this.socket = server.accept();
- this.socket.setTcpNoDelay(true);
- server.close();
-}
-/**
- * Disconnects this interface from the IDE.
- */
-void disconnect() {
- if (this.socket != null) {
- try {
- this.socket.close();
- } catch (IOException e2) {
- // Ignore
- }
- this.socket = null;
- }
-}
-/**
- * Returns the class definitions of the classes that compose the next code snippet to evaluate.
- */
-protected byte[][] getNextClasses() {
- if (this.socket == null) {
- return new byte[0][];
- }
- if (TIMING) {
- this.startTime = System.currentTimeMillis();
- }
- try {
- DataInputStream in = new DataInputStream(this.socket.getInputStream());
- int numberOfClasses = in.readInt();
- byte[][] result = new byte[numberOfClasses][];
- for (int i = 0; i < numberOfClasses; i++) {
- int lengthOfClassFile = in.readInt();
- byte[] classFile = new byte[lengthOfClassFile];
- int read = 0;
- while (read < lengthOfClassFile && read != -1) {
- read += in.read(classFile, read, lengthOfClassFile - read);
- }
- result[i] = classFile;
- }
- return result;
- } catch (IOException e) {
- // The socket has likely been closed on the other end, close this end too.
- disconnect();
- return new byte[0][];
- }
-}
-/**
- * Returns whether the code snippet classes that follow should be run or just loaded.
- */
-protected boolean getRunFlag() {
- if (this.socket == null) {
- return false;
- }
- if (TIMING) {
- this.startTime = System.currentTimeMillis();
- }
- try {
- DataInputStream in = new DataInputStream(this.socket.getInputStream());
- return in.readBoolean();
- } catch (IOException e) {
- // The socket has likely been closed on the other end, close this end too.
- disconnect();
- return false;
- }
-}
-/**
- * Returns whether this interface is connected to the IDE.
- */
-boolean isConnected() {
- return this.socket != null;
-}
-/**
- * Sends the result of the evaluation to the IDE.
- */
-protected void sendResult(Class resultType, Object resultValue) {
- if (this.socket == null) {
- return;
- }
- try {
- DataOutputStream out = new DataOutputStream(this.socket.getOutputStream());
- if (resultType == void.class) {
- out.writeBoolean(false);
- } else {
- out.writeBoolean(true);
- out.writeUTF(resultType.isPrimitive() ? resultType.toString() : resultType.getName());
- out.writeUTF(resultValue == null ? "null" : resultValue.toString());
- }
- } catch (IOException e) {
- // The socket has likely been closed on the other end, disconnect this end too
- disconnect();
- }
- if (TIMING) {
- System.out.println("Time to run on target is " + (System.currentTimeMillis() - this.startTime) + "ms");
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/ExcludedTestSuite.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/ExcludedTestSuite.java
deleted file mode 100644
index d131d95..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/ExcludedTestSuite.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.junit.extension;
-
-import junit.framework.*;
-public class ExcludedTestSuite extends TestSuite {
- String[] excludedTests = null;
-/**
- * Creates a new test suite by excluding the given tests
- * from the given test suite.
- */
-public ExcludedTestSuite(Test suite, String[] excludedTests) {
- this.excludedTests = excludedTests;
- this.addTest(suite);
-}
-/**
- * Adds a test to the suite.
- */
-public void addTest(Test test) {
- if (test instanceof TestCase) {
- if (!isExcluded((TestCase)test)) {
- super.addTest(test);
- }
- } else if (test instanceof TestSuite) {
- java.util.Enumeration enum = ((TestSuite)test).tests();
- while (enum.hasMoreElements()) {
- this.addTest((Test)enum.nextElement());
- }
- }
-}
-/**
- * Returns whether the test is excluded.
- */
-public boolean isExcluded(TestCase test) {
- if (this.excludedTests == null) {
- return false;
- }
- for (int i = 0; i < this.excludedTests.length; i += 2) {
- String className = this.excludedTests[i];
- String methodName = this.excludedTests[i+1];
- if (test.getName().equals(methodName) &&
- test.getClass().getName().endsWith(className)) {
- return true;
- }
- }
- return false;
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/StopableTestCase.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/StopableTestCase.java
deleted file mode 100644
index 3bb8005..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/StopableTestCase.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.junit.extension;
-
-/**
- * A test case that is being sent stop() when the user presses 'Stop' or 'Exit'.
- */
-public class StopableTestCase extends junit.framework.TestCase {
-public StopableTestCase(String name) {
- super(name);
-}
-/**
- * Default is to do nothing.
- */
-public void stop() {
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestListener.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestListener.java
deleted file mode 100644
index 0c25fff..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.junit.extension;
-
-import junit.framework.Test;
-import junit.framework.TestFailure;
-/**
- * A Listener for test progress
- */
-public interface TestListener extends junit.framework.TestListener {
- /**
- * An error occurred.
- */
- public void addError(Test test, TestFailure testFailure);
- /**
- * A failure occurred.
- */
- public void addFailure(Test test, TestFailure testFailure);
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestResult.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestResult.java
deleted file mode 100644
index a457ccc..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestResult.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.junit.extension;
-
-import java.util.*;
-import junit.framework.*;
-
-public class TestResult extends junit.framework.TestResult {
- TestCase currentTest;
-/**
- * TestResult constructor comment.
- */
-public TestResult() {
- super();
-}
- /**
- * Adds an error to the list of errors. The passed in exception
- * caused the error.
- */
- public synchronized void addError(Test test, Throwable t) {
- TestFailure testFailure= new TestFailure(test, t);
- fErrors.addElement(testFailure);
- for (Enumeration e= cloneListeners().elements(); e.hasMoreElements(); ) {
- ((TestListener)e.nextElement()).addError(test, testFailure);
- }
- }
- /**
- * Adds a failure to the list of failures. The passed in exception
- * caused the failure.
- */
- public synchronized void addFailure(Test test, AssertionFailedError t) {
- TestFailure testFailure= new TestFailure(test, t);
- fFailures.addElement(testFailure);
- for (Enumeration e= cloneListeners().elements(); e.hasMoreElements(); ) {
- ((TestListener)e.nextElement()).addFailure(test, testFailure);
- }
- }
- /**
- * Returns a copy of the listeners.
- */
- private synchronized Vector cloneListeners() {
- return (Vector)fListeners.clone();
- }
- protected void run(final TestCase test) {
- this.currentTest = test;
- super.run(test);
- this.currentTest = null;
- }
-public synchronized void stop() {
- super.stop();
- if (this.currentTest != null && this.currentTest instanceof StopableTestCase) {
- ((StopableTestCase)this.currentTest).stop();
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/AbstractReader.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/AbstractReader.java
deleted file mode 100644
index 879bb50..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/AbstractReader.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.runtime;
-
-/**
- * An abstract reader that continuously reads.
- */
-
-abstract public class AbstractReader {
- protected String name;
- protected Thread readerThread;
- protected boolean isStopping= false;
-/*
- * Creates a new reader with the given name.
- */
-public AbstractReader(String name) {
- this.name = name;
-}
-/**
- * Continuously reads. Note that if the read involves waiting
- * it can be interrupted and a InterruptedException will be thrown.
- */
-abstract protected void readerLoop();
-/**
- * Start the thread that reads events.
- *
- */
-public void start() {
- this.readerThread = new Thread(
- new Runnable() {
- public void run () {
- readerLoop();
- }
- },
- AbstractReader.this.name);
- this.readerThread.start();
-}
-/**
- * Tells the reader loop that it should stop.
- */
-public void stop() {
- this.isStopping= true;
- if (this.readerThread != null)
- this.readerThread.interrupt();
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VMLauncher.java
deleted file mode 100644
index a7be587..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VMLauncher.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.runtime;
-
-import java.io.*;
-
-import java.util.Vector;
-
-import org.eclipse.jdt.core.tests.util.Util;
-
-/**
- * A J9 VM launcher launches an external J9 VM (and J9 Proxy if needed) with
- * the given arguments on the same machine.
- * <p>
- * Unlike with the <code>StandardVMLauncher</code>, a debugger would have to
- * connect to the J9 Proxy instead of connecting to the VM directly. In this case,
- * the Proxy port is the specified debug port. Note that an internal debug port
- * must also be specified. This port is used for the communication between the
- * Proxy and the VM.
- */
-public class J9VMLauncher extends LocalVMLauncher implements RuntimeConstants {
- int internalDebugPort = -1;
- String proxyOutFile;
- String symbolPath;
-/**
- * Creates a new J9VMLauncher that launches a J9 VM
- * (and J9 Proxy if needed) on the same machine.
- */
-public J9VMLauncher() {
- super();
-}
-/**
- * Builds the actual boot class path that is going to be passed to the VM.
- */
-protected String buildBootClassPath() {
- StringBuffer bootPathString = new StringBuffer();
- char pathSeparator = File.pathSeparatorChar;
-
- if (this.bootPath != null) {
- // Add boot class path given by client
- int length = this.bootPath.length;
- for (int i = 0; i < length; i++){
- bootPathString.append(this.bootPath[i]);
- bootPathString.append(pathSeparator);
- }
- } else {
- // Add regular classes.zip
- bootPathString.append(this.vmPath);
- bootPathString.append(File.separator);
- bootPathString.append("lib");
- bootPathString.append(File.separator);
- bootPathString.append("jclMax");
- bootPathString.append(File.separator);
- bootPathString.append("classes.zip");
- bootPathString.append(pathSeparator);
- }
-
- // Add boot class path directory if needed
- if (this.evalTargetPath != null && TARGET_HAS_FILE_SYSTEM) {
- bootPathString.append(this.evalTargetPath);
- bootPathString.append(File.separatorChar);
- bootPathString.append(BOOT_CLASSPATH_DIRECTORY);
- }
-
- return bootPathString.toString();
-}
-/**
- * @see LocalVMLauncher#execCommandLine
- */
-protected Process execCommandLine() throws TargetException {
- // Check that the internal debug port has been specified if in debug mode
- if (this.debugPort != -1 && this.internalDebugPort == -1) {
- throw new TargetException("Internal debug port has not been specified");
- }
-
- return super.execCommandLine();
-}
-/**
- * @see LocalVMLauncher#getCommandLine
- */
-public String[] getCommandLine() {
- Vector commandLine = new Vector();
-
- // VM binary
- commandLine.addElement(
- this.vmPath +
- (this.vmPath.endsWith(File.separator) ? "" : File.separator) +
- "bin" +
- File.separator +
- "j9");
-
- // VM arguments
- if (this.vmArguments != null) {
- for (int i = 0; i < this.vmArguments.length; i++) {
- commandLine.addElement(this.vmArguments[i]);
- }
- }
-
- // debug mode
- if (this.debugPort != -1 && this.internalDebugPort != -1) {
- commandLine.addElement("-debug:" + this.internalDebugPort);
- }
-
- // boot class path
- commandLine.addElement("-Xbootclasspath:" + buildBootClassPath());
-
- // regular class path
- commandLine.addElement("-classpath");
- commandLine.addElement(buildClassPath());
-
- // code snippet runner class
- if (this.evalPort != -1) {
- commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME);
- }
-
- // code snippet runner arguments
- if (this.evalPort != -1) {
- commandLine.addElement(EVALPORT_ARG);
- commandLine.addElement(Integer.toString(this.evalPort));
- if (TARGET_HAS_FILE_SYSTEM) {
- commandLine.addElement(CODESNIPPET_CLASSPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
- commandLine.addElement(CODESNIPPET_BOOTPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
- }
- }
-
- // program class
- if (this.programClass != null) {
- commandLine.addElement(this.programClass);
- }
-
- // program arguments
- if (this.programArguments != null) {
- for (int i=0;i<this.programArguments.length;i++) {
- commandLine.addElement(this.programArguments[i]);
- }
- }
-
- String[] result= new String[commandLine.size()];
- commandLine.copyInto(result);
-
- // check for spaces in result
- for (int i = 0; i < result.length; i++) {
- String argument = result[i];
- if (argument.indexOf(' ') != -1) {
- result[i] = "\"" + argument + "\"";
- }
- }
-
- return result;
-}
-/**
- * Returns the debug port the J9 Proxy uses to connect to the J9 VM.
- * The value is unspecified if debug mode is disabled.
- * Note that the regular debug port is the port used to connect the J9 Proxy and
- * the IDE in the case of the J9 VM Launcher.
- */
-public int getInternalDebugPort() {
- return this.internalDebugPort;
-}
-/**
- * Returns the command line which will be used to launch the Proxy.
- */
-public String[] getProxyCommandLine() {
- Vector commandLine = new Vector();
-
- // Proxy binary
- commandLine.addElement(
- this.vmPath +
- (this.vmPath.endsWith(File.separator) ? "" : File.separator) +
- "bin" +
- File.separator +
- "j9proxy");
-
- // Arguments
- commandLine.addElement(getTargetAddress() + ":" + this.internalDebugPort);
- commandLine.addElement(Integer.toString(this.debugPort));
- if (this.symbolPath != null && this.symbolPath != "") {
- commandLine.addElement(this.symbolPath);
- }
-
- String[] result= new String[commandLine.size()];
- commandLine.copyInto(result);
- return result;
-}
-/**
- * Returns the full path name to the file where the proxy output is redirected.
- * Returns "con" if the proxy output is redirected to the stdout.
- * Returns null if the proxy output is not redirected.
- */
-public String getProxyOutFile() {
- return this.proxyOutFile;
-}
-/**
- * Returns the full path name to the symbol file used by the J9 Proxy.
- * Returns null if the no symbol file is passed to the J9 Proxy.
- */
-public String getSymbolPath() {
- return this.symbolPath;
-}
-/**
- * @see LocalVMLauncher#launch
- */
-public LocalVirtualMachine launch() throws TargetException {
- // Launch VM
- LocalVirtualMachine localVM = (LocalVirtualMachine)super.launch();
-
- // Launch Proxy if needed
- Process proxyProcess= null;
- if (this.debugPort != -1) {
- try {
- // Use Runtime.exec(String[]) with tokens because Runtime.exec(String) with commandLineString
- // does not properly handle spaces in arguments on Unix/Linux platforms.
- String[] commandLine = getProxyCommandLine();
-
- // DEBUG
- /*
- for (int i = 0; i < commandLine.length; i++) {
- System.out.print(commandLine[i] + " ");
- }
- System.out.println();
- */
-
- proxyProcess= Runtime.getRuntime().exec(commandLine);
- } catch (IOException e) {
- localVM.shutDown();
- throw new TargetException("Error launching J9 Proxy at " + this.vmPath);
- }
- }
-
- // Transform launched VM into J9 VM
- Process vmProcess = localVM.process;
- this.runningVMs.removeElement(localVM);
- J9VirtualMachine vm= new J9VirtualMachine(vmProcess, this.debugPort, this.evalTargetPath, proxyProcess, this.proxyOutFile);
- this.runningVMs.addElement(vm);
- return vm;
-}
-/* (non-Javadoc)
- * @see org.eclipse.jdt.core.tests.runtime.LocalVMLauncher#setDebugPort(int)
- */
-public void setDebugPort(int debugPort) {
- super.setDebugPort(debugPort);
-
- // specify default internal debug port as well
- this.setInternalDebugPort(Util.nextAvailablePortNumber());
-}
-
-/**
- * Sets the debug port the J9 Proxy uses to connect to the J9 VM.
- * This is mandatory if debug mode is enabled.
- * This is ignored if debug mode is disabled.
- * Note that the regular debug port is the port used to connect the J9 Proxy and
- * the IDE in the case of the J9 VM Launcher.
- */
-public void setInternalDebugPort(int internalDebugPort) {
- this.internalDebugPort = internalDebugPort;
-}
-/**
- * Sets the full path name to the file where the proxy output must be redirected.
- * Specify "con" if the proxy output must be redirected to the stdout.
- * Specify null if the proxy output must not be redirected (default value).
- * This is ignored if debug mode is disabled.
- */
-public void setProxyOutFile(String proxyOutFile) {
- this.proxyOutFile = proxyOutFile;
-}
-/**
- * Sets the full path name to the symbol file used by the J9 Proxy.
- * Specify null if the no symbol file must be passed to the J9 Proxy (default value).
- * This is ignored if debug mode is disabled.
- */
-public void setSymbolPath(String symbolPath) {
- this.symbolPath = symbolPath;
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VirtualMachine.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VirtualMachine.java
deleted file mode 100644
index e23a68b..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VirtualMachine.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.runtime;
-
-/**
- * Wrapper around the external processes that are running a J9 VM
- * and a J9 Proxy.
- * This allows to kill these processes when we exit this vm.
- */
-class J9VirtualMachine extends LocalVirtualMachine {
- private Process proxyProcess;
- private AbstractReader proxyConsoleReader;
- private String proxyOutputFile;
-/**
- * Creates a new J9VirtualMachine from the Processes that runs this VM
- * and its J9 Proxy and with the given info.
- */
-public J9VirtualMachine(Process vmProcess, int debugPort, String evalTargetPath, Process proxyProcess, String proxyOutputFile) {
- super(vmProcess, debugPort, evalTargetPath);
- this.proxyProcess = proxyProcess;
- this.proxyOutputFile = proxyOutputFile;
-
- // Start the Proxy console reader so that the proxy is not blocked on its stdout.
- if (this.proxyProcess != null) {
- if (this.proxyOutputFile == null) {
- this.proxyConsoleReader=
- new NullConsoleReader(
- "J9 Proxy Console Reader",
- this.proxyProcess.getInputStream());
- } else {
- this.proxyConsoleReader=
- new ProxyConsoleReader(
- "J9 Proxy Console Reader",
- this.proxyProcess.getInputStream(),
- this.proxyOutputFile);
- }
- this.proxyConsoleReader.start();
- }
-
-}
-private boolean isProxyRunning() {
- if (this.proxyProcess == null)
- return false;
- else {
- boolean hasExited;
- try {
- this.proxyProcess.exitValue();
- hasExited = true;
- } catch (IllegalThreadStateException e) {
- hasExited = false;
- }
- return !hasExited;
- }
-}
-/**
- * @see LocalVirtualMachine#shutDown
- */
-public void shutDown() throws TargetException {
- super.shutDown();
- if (this.proxyConsoleReader != null)
- this.proxyConsoleReader.stop();
- if ((this.proxyProcess != null) && isProxyRunning())
- this.proxyProcess.destroy();
-}
-/**
- * @see LocalVirtualMachine#shutDown
- */
-public void waitForTermination() throws InterruptedException {
- super.waitForTermination();
- if (this.proxyProcess != null)
- this.proxyProcess.waitFor();
- if (this.proxyConsoleReader != null)
- this.proxyConsoleReader.stop();
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java
deleted file mode 100644
index 98c4975..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java
+++ /dev/null
@@ -1,457 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.runtime;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * The root of the VM launchers that launch VMs on the same machine.
- * <p>
- * A local VM launcher has the following limitations:
- * <ul>
- * <li>It can only retrieve the running virtual machines that it has launched. So if
- * a client is using 2 instances of <code>LocalVMLauncher</code>, each of these
- * instances will be able to retrieve only a part of the running VMs.
- * </ul>
- */
-public abstract class LocalVMLauncher implements RuntimeConstants {
-
- /**
- * Whether the target has a file system and thus whether it supports writing
- * class files to disk. See org.eclipse.jdt.core.tests.eval.target.CodeSnippetRunner for more
- * information.
- */
- public static final boolean TARGET_HAS_FILE_SYSTEM = true;
- public static final String REGULAR_CLASSPATH_DIRECTORY = "regularPath";
- public static final String BOOT_CLASSPATH_DIRECTORY = "bootPath";
-
- protected String[] bootPath;
- protected String[] classPath;
- protected int debugPort = -1;
- protected int evalPort = -1;
- protected String evalTargetPath;
- protected String[] programArguments;
- protected String programClass;
- protected Vector runningVMs = new Vector(); // a Vector of LocalVirtualMachine
- protected String[] vmArguments;
- protected String vmPath;
-
-/**
- * Returns a launcher that will launch the same kind of VM that is currently running
- */
-public static LocalVMLauncher getLauncher() {
- if ("J9".equals(System.getProperty("java.vm.name"))) {
- return new J9VMLauncher();
- } else {
- return new StandardVMLauncher();
- }
-}
-/**
- * Builds the actual class path that is going to be passed to the VM.
- */
-protected String buildClassPath() {
- StringBuffer classPathString = new StringBuffer();
- char pathSeparator = File.pathSeparatorChar;
-
- // Add jar support if in evaluation mode
- if (this.evalPort != -1) {
- classPathString.append(new File(this.evalTargetPath, SUPPORT_ZIP_FILE_NAME).getPath());
- classPathString.append(pathSeparator);
- }
-
- // Add class path given by client
- if (this.classPath != null) {
- int length = this.classPath.length;
- for (int i = 0; i < length; i++){
- classPathString.append(this.classPath[i]);
- classPathString.append(pathSeparator);
- }
- }
-
- // Add regular classpath directory if needed
- if (this.evalPort != -1 && TARGET_HAS_FILE_SYSTEM) {
- classPathString.append(this.evalTargetPath);
- classPathString.append(File.separatorChar);
- classPathString.append(REGULAR_CLASSPATH_DIRECTORY);
- }
-
- return classPathString.toString();
-}
-/**
- * Launches the VM by exec'ing the command line and returns the resulting Process.
- */
-protected Process execCommandLine() throws TargetException {
- // Check that the VM path has been specified
- if (this.vmPath == null) {
- throw new TargetException("Path to the VM has not been specified");
- }
-
- // Check that the program class has been specified if not in evaluation mode
- if ((this.programClass == null) && (this.evalPort == -1)) {
- throw new TargetException("Program class has not been specified");
- }
-
- // Launch VM
- Process vmProcess= null;
- try {
- // Use Runtime.exec(String[]) with tokens because Runtime.exec(String) with commandLineString
- // does not properly handle spaces in arguments on Unix/Linux platforms.
- String[] commandLine = getCommandLine();
-
- // DEBUG
- /*for (int i = 0; i < commandLine.length; i++) {
- System.out.print(commandLine[i] + " ");
- }
- System.out.println();
- */
-
- vmProcess= Runtime.getRuntime().exec(commandLine);
- } catch (IOException e) {
- throw new TargetException("Error launching VM at " + this.vmPath);
- }
- return vmProcess;
-}
-/**
- * Returns the boot class path used when a VM is launched.
- */
-public String[] getBootClassPath() {
- return this.bootPath;
-}
-/**
- * Returns the class path used when a VM is launched.
- */
-public String[] getClassPath() {
- return this.classPath;
-}
-/**
- * Returns the command line which will be used to launch the VM.
- * The segments are in the following order:
- * <p><ul>
- * <li> VM path,
- * <li> VM arguments,
- * <li> the class path,
- * <li> the program class
- * <li> the program arguments
- * </ul>
- */
-public abstract String[] getCommandLine();
-/**
- * Returns the debug port, or -1 if debug mode is disabled.
- * The default is -1.
- */
-public int getDebugPort() {
- return this.debugPort;
-}
-/**
- * Returns the evaluation port for evaluation support.
- * The default is -1, indicating no evaluation support.
- *
- * @see setEvalPort
- */
-public int getEvalPort() {
- return this.evalPort;
-}
-/**
- * Returns the evaluation target path for evaluation support.
- *
- * @see setEvalTargetPath
- */
-public String getEvalTargetPath() {
- return this.evalTargetPath;
-}
-/**
- * Returns the arguments passed to the program class.
- * Returns null if the VM is being launched for evaluation support only.
- */
-public String[] getProgramArguments() {
- if (this.evalPort != -1) {
- return null;
- } else {
- return this.programArguments;
- }
-}
-/**
- * Returns the dot-separated, fully qualified name of the class to run.
- * It must implement main(String[] args).
- * Returns null if the VM is being launched for evaluation support only.
- */
-public String getProgramClass() {
- if (this.evalPort != -1) {
- return null;
- } else {
- return this.programClass;
- }
-}
-/**
- * Returns all the target VMs that are running at this launcher's target
- * address.
- * Note that these target VMs may or may not have been launched by this
- * launcher.
- * Note also that if the list of running VMs doesn't change on the target,
- * two calls to this method return VMs that are equal.
- *
- * @return the list of running target VMs
- * @exception TargetException if the target VMs could not be retrieved.
- */
-public LocalVirtualMachine[] getRunningVirtualMachines() throws TargetException {
- // Select the VMs that are actually running
- Vector actuallyRunning = new Vector();
- Enumeration enum = this.runningVMs.elements();
- while (enum.hasMoreElements()) {
- LocalVirtualMachine vm = (LocalVirtualMachine)enum.nextElement();
- if (vm.isRunning())
- actuallyRunning.addElement(vm);
- }
- this.runningVMs = actuallyRunning;
-
- // Return the running VMs
- int size = actuallyRunning.size();
- LocalVirtualMachine[] result = new LocalVirtualMachine[size];
- for (int i=0; i<size; i++)
- result[i] = (LocalVirtualMachine)actuallyRunning.elementAt(i);
- return result;
-}
-/**
- * Returns the address of the target where this launcher runs the target VMs. The format
- * of this address is transport specific.
- * For example, a VM launcher using a TCP/IP transport returns target addresses looking like:
- * <code>"localhost:2010"</code>, or <code>"joe.ibm.com"</code>.
- *
- * @return transport specific address of the target
- */
-public String getTargetAddress() {
- return "localhost";
-}
-/**
- * Returns the VM-specific arguments. This does not include:
- * <p><ul>
- * <li>the VM path
- * <li>the class path or the boot class path
- * <li>the program class or program arguments
- * </ul>
- */
-public String[] getVMArguments() {
- return this.vmArguments;
-}
-/**
- * Returns the path on disk of the VM to launch.
- */
-public String getVMPath() {
- return this.vmPath;
-}
-/**
- * Initializes this context's target path by copying the jar file for the code snippet support
- * and by creating the 2 directories that will contain the code snippet classes (see TARGET_HAS_FILE_SYSTEM).
- * Add the code snipport root class to the boot path directory so that code snippets can be run in
- * java.* packages
- *
- * @throws TargetException if the path could not be initialized with the code snippet support
- */
-protected void initTargetPath() throws TargetException {
- // create directories
- File directory = new File(this.evalTargetPath);
- directory.mkdirs();
- if (!directory.exists()) {
- throw new TargetException("Could not create directory " + this.evalTargetPath);
- }
- if (TARGET_HAS_FILE_SYSTEM) {
- File classesDirectory = new File(directory, REGULAR_CLASSPATH_DIRECTORY);
- classesDirectory.mkdir();
- if (!classesDirectory.exists()) {
- throw new TargetException("Could not create directory " + classesDirectory.getPath());
- }
- File bootDirectory = new File(directory, BOOT_CLASSPATH_DIRECTORY);
- bootDirectory.mkdir();
- if (!bootDirectory.exists()) {
- throw new TargetException("Could not create directory " + bootDirectory.getPath());
- }
- /*
- // add the code snippet root class to the boot path directory
- InputStream in = null;
- try {
- in = EvaluationContext.class.getResourceAsStream("/" + SUPPORT_ZIP_FILE_NAME);
- ZipInputStream zip = new ZipInputStream(in);
- String rootClassFileName = ROOT_FULL_CLASS_NAME.replace('.', '/') + ".class";
- while (true) {
- ZipEntry entry = zip.getNextEntry();
- if (entry.getName().equals(rootClassFileName)) {
- // read root class file contents
- int size = (int)entry.getSize();
- byte[] buffer = new byte[size];
- int totalRead = 0;
- int read = 0;
- while (totalRead < size) {
- read = zip.read(buffer, totalRead, size - totalRead);
- if (read != -1) {
- totalRead += read;
- }
- }
- // write root class file contents
- FileOutputStream out = null;
- try {
- File rootFile = new File(bootDirectory, rootClassFileName.replace('/', File.separatorChar));
- File parent = new File(rootFile.getParent());
- parent.mkdirs();
- out = new FileOutputStream(rootFile);
- out.write(buffer);
- out.close();
- } catch (IOException e) {
- e.printStackTrace();
- if (out != null) {
- try {
- out.close();
- } catch (IOException e2) {
- }
- }
- }
- break;
- }
- }
- in.close();
- } catch (IOException e) {
- e.printStackTrace();
- if (in != null) {
- try {
- in.close();
- } catch (IOException e2) {
- }
- }
- }*/
- }
-
- // copy jar file
- InputStream in = null;
- FileOutputStream out = null;
- try {
- in = this.getClass().getResourceAsStream("/" + SUPPORT_ZIP_FILE_NAME);
- if (in == null) {
- throw new TargetException("Could not find resource /" + SUPPORT_ZIP_FILE_NAME);
- }
- int bufferLength = 1024;
- byte[] buffer = new byte[bufferLength];
- File file = new File(directory, SUPPORT_ZIP_FILE_NAME);
- out = new FileOutputStream(file);
- int read = 0;
- while (read != -1) {
- read = in.read(buffer, 0, bufferLength);
- if (read != -1) {
- out.write(buffer, 0, read);
- }
- }
- } catch (IOException e) {
- throw new TargetException("IOException while copying " + SUPPORT_ZIP_FILE_NAME + ": " + e.getMessage());
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- }
- }
- if (out != null) {
- try {
- out.close();
- } catch (IOException e) {
- }
- }
- }
-}
-/**
- * Launches a new target VM with the registered arguments.
- * This operation returns once a new target VM has been launched.
- *
- * @exception TargetException if the target VM could not be launched.
- */
-public LocalVirtualMachine launch() throws TargetException {
- // evaluation mode
- if (this.evalTargetPath != null) {
- // init target path
- this.initTargetPath();
- }
-
- // launch VM
- LocalVirtualMachine vm;
- Process p = execCommandLine();
- vm = new LocalVirtualMachine(p, this.debugPort, this.evalTargetPath);
-
- // TBD: Start reading VM stdout and stderr right away otherwise this may prevent the connection
- // from happening.
-
- // add VM to list of known running VMs
- this.runningVMs.addElement(vm);
- return vm;
-}
-/**
- * Sets the boot class path used when a VM is launched.
- */
-public void setBootClassPath(java.lang.String[] bootClassPath) {
- this.bootPath = bootClassPath;
-}
-/**
- * Sets the class path used when a VM is launched.
- */
-public void setClassPath(String[] classPath) {
- this.classPath = classPath;
-}
-/**
- * Sets the debug port to use for debug support.
- * Specify -1 to disable debug mode.
- */
-public void setDebugPort(int debugPort) {
- this.debugPort = debugPort;
-}
-/**
- * Sets the evaluation port to use for evaluation support.
- * Setting the port enables evaluation support.
- * Specify null to disable evaluation support.
- */
-public void setEvalPort(int evalPort) {
- this.evalPort = evalPort;
-}
-/**
- * Sets the evaluation target path to use for evaluation support.
- */
-public void setEvalTargetPath(String evalTargetPath) {
- this.evalTargetPath = evalTargetPath;
-}
-/**
- * Sets the arguments passed to the program class.
- * This is ignored if the VM is being launched for evaluation support only.
- */
-public void setProgramArguments(String[] args) {
- this.programArguments = args;
-}
-/**
- * Sets the dot-separated, fully qualified name of the class to run.
- * It must implement main(String[] args).
- * This is ignored if the VM is being launched for evaluation support only.
- */
-public void setProgramClass(String programClass) {
- this.programClass = programClass;
-}
-/**
- * Sets the VM-specific arguments. This does not include:
- * <p><ul>
- * <li>the VM path
- * <li>the class path or the boot class path
- * <li>the program class or program arguments
- * </ul>
- */
-public void setVMArguments(String[] args) {
- this.vmArguments = args;
-}
-/**
- * Sets the path on disk of the VM to launch.
- */
-public void setVMPath(String vmPath) {
- this.vmPath = vmPath;
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVirtualMachine.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVirtualMachine.java
deleted file mode 100644
index 0427755..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVirtualMachine.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.runtime;
-
-import java.io.*;
-
-/**
- * Wrapper around the external process that is running a local VM.
- * This allows to kill this process when we exit this vm.
- */
-public class LocalVirtualMachine {
- protected Process process;
- protected int debugPort;
- protected String evalTargetPath;
-/**
- * Creates a new LocalVirtualMachine that doesn't run and that cannot be debugged nor used to
- * evaluate.
- */
-public LocalVirtualMachine() {
- this.process = null;
- this.debugPort = -1;
- this.evalTargetPath = null;
-}
-/**
- * Creates a new LocalVirtualMachine from the Process that runs this VM
- * and with the given debug port number.
- */
-public LocalVirtualMachine(Process p, int debugPort, String evalTargetPath) {
- this.process = p;
- this.debugPort = debugPort;
- this.evalTargetPath = evalTargetPath;
-}
-/**
- * Destroys the process running this VM.
- */
-protected void basicShutDown() {
- if ((this.process != null) && this.isRunning()) {
- this.process.destroy();
- }
-}
-/**
- * Cleans up the given directory by removing all the files it contains as well
- * but leaving the directory.
- * @throws TargetException if the target path could not be cleaned up
- */
-private void cleanupDirectory(File directory) throws TargetException {
- if (!directory.exists()) {
- return;
- }
- String[] fileNames = directory.list();
- for (int i = 0; i < fileNames.length; i++) {
- File file = new File(directory, fileNames[i]);
- if (file.isDirectory()) {
- cleanupDirectory(file);
- if (!file.delete()) {
- throw new TargetException("Could not delete directory " + directory.getPath());
- }
- } else {
- if (!file.delete()) {
- throw new TargetException("Could not delete file " + file.getPath());
- }
- }
- }
-}
-/**
- * Cleans up this context's target path by removing all the files it contains
- * but leaving the directory.
- * @throws TargetException if the target path could not be cleaned up
- */
-protected void cleanupTargetPath() throws TargetException {
- if (this.evalTargetPath == null) return;
- String targetPath = this.evalTargetPath;
- if (LocalVMLauncher.TARGET_HAS_FILE_SYSTEM) {
- cleanupDirectory(new File(targetPath, LocalVMLauncher.REGULAR_CLASSPATH_DIRECTORY));
- cleanupDirectory(new File(targetPath, LocalVMLauncher.BOOT_CLASSPATH_DIRECTORY));
- File file = new File(targetPath, LocalVMLauncher.SUPPORT_ZIP_FILE_NAME);
-
- // workaround pb with Process.exitValue() that returns the process has exited, but it has not free the file yet
- int count = 10;
- for (int i = 0; i < count; i++) {
- if (file.delete()) {
- break;
- } else {
- try {
- Thread.sleep(count * 100);
- } catch (InterruptedException e) {
- }
- }
- }
- if (file.exists()) {
- throw new TargetException("Could not delete " + file.getPath());
- }
- } else {
- cleanupDirectory(new File(targetPath));
- }
-}
-/**
- * Returns the debug port number for this VM. This is the port number that was
- * passed as the "-debug" option if this VM was launched using a <code>LocalVMLauncher</code>.
- * Returns -1 if this information is not available or if this VM is not running in
- * debug mode.
- */
-public int getDebugPortNumber() {
- return this.debugPort;
-}
-/**
- * Returns an input stream that is connected to the standard error
- * (<code>System.err</code>) of this target VM.
- * Bytes that are written to <code>System.err</code> by the target
- * program become available in the input stream.
- * <p>
- * Note 1: This stream is usually unbuffered.
- * <p>
- * Note 2: Two calls to this method return the same identical input stream.
- * <p>
- * See also <code>java.lang.Process.getErrorStream()</code>.
- *
- * @return an input stream connected to the target VM's <code>System.err</code>.
- * @exception org.eclipse.jdt.tests.eval.runtime.TargetException if the target VM is not reachable.
- */
-public InputStream getErrorStream() throws TargetException {
- if (this.process == null)
- throw new TargetException("The VM is not running");
- else
- return this.process.getErrorStream();
-}
-/**
- * Returns an input stream that is connected to the standard output
- * (<code>System.out</code>) of this target VM.
- * Bytes that are written to <code>System.out</code> by the target
- * program become available in the input stream.
- * <p>
- * Note 1: This stream is usually buffered.
- * <p>
- * Note 2: Two calls to this method return the same identical input stream.
- * <p>
- * See also <code>java.lang.Process.getInputStream()</code>.
- *
- * @return an input stream connected to the target VM's <code>System.out</code>.
- * @exception org.eclipse.jdt.tests.eval.runtime.TargetException if the target VM is not reachable.
- */
-public InputStream getInputStream() throws TargetException {
- if (this.process == null)
- throw new TargetException("The VM is not running");
- else
- // Workaround problem with input stream of a Process
- return new VMInputStream(this.process, this.process.getInputStream());
-}
-/**
- * Returns an output stream that is connected to the standard input
- * (<code>System.in</code>) of this target VM.
- * Bytes that are written to the output stream by a client become available to the target
- * program in <code>System.in</code>.
- * <p>
- * Note 1: This stream is usually buffered.
- * <p>
- * Note 2: Two calls to this method return the same identical output stream.
- * <p>
- * See also <code>java.lang.Process.getOutputStream()</code>.
- *
- * @return an output stream connected to the target VM's <code>System.in</code>.
- * @exception org.eclipse.jdt.tests.eval.runtime.TargetException if the target VM is not reachable.
- */
-public OutputStream getOutputStream() throws TargetException {
- if (this.process == null)
- throw new TargetException("The VM is not running");
- else
- return this.process.getOutputStream();
-}
-/**
- * Returns whether this target VM is still running.
- * <p>
- * Note: This operation may require contacting the target VM to find out
- * if it is still running.
- */
-public boolean isRunning() {
- if (this.process == null)
- return false;
- else {
- boolean hasExited;
- try {
- this.process.exitValue();
- hasExited = true;
- } catch (IllegalThreadStateException e) {
- hasExited = false;
- }
- return !hasExited;
- }
-}
-/**
- * Shuts down this target VM.
- * This causes the VM to exit. This operation is ignored
- * if the VM has already shut down.
- *
- * @exception org.eclipse.jdt.tests.eval.runtime.TargetException if the target VM could not be shut down.
- */
-public void shutDown() throws TargetException {
- this.basicShutDown();
- int retry = 0;
- while (this.isRunning() && (++retry < 20)) {
- try {
- Thread.sleep(retry * 100);
- } catch (InterruptedException e) {
- }
- }
- if (this.isRunning()) { // give up cleaning the target path if VM is still running
- throw new TargetException("Could not shut the VM down");
- } else {
- this.cleanupTargetPath();
- }
-}
-/**
- * Waits for the VM to shut down. This method returns
- * immediately if the VM has already shut down. If the
- * VM has not yet shut down, the calling thread will be
- * blocked until the VM shuts down.
- *
- * @exception InterruptedException if the <code>waitForTermination</code> was
- * interrupted.
- */
-public void waitForTermination() throws InterruptedException {
- if (this.process == null)
- return;
- else
- this.process.waitFor();
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/NullConsoleReader.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/NullConsoleReader.java
deleted file mode 100644
index 31820dc..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/NullConsoleReader.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.runtime;
-
-import java.io.InputStream;
-
-/**
- * A null console reader that continuously reads from the VM input stream
- * so that the VM doesn't block when the program writes to the stout.
- */
-
-public class NullConsoleReader extends AbstractReader {
- private InputStream input;
-/*
- * Creates a new console reader that will read from the given input stream.
- */
-public NullConsoleReader(String name, InputStream input) {
- super(name);
- this.input = input;
-}
-/**
- * Continuously reads events that are coming from the event queue.
- */
-protected void readerLoop() {
- java.io.BufferedReader bufferedInput = new java.io.BufferedReader(new java.io.InputStreamReader(this.input));
- try {
- int read= 0;
- while (!this.isStopping && read != -1) {
- read= bufferedInput.read();
- }
- } catch (java.io.IOException e) {
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/ProxyConsoleReader.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/ProxyConsoleReader.java
deleted file mode 100644
index f36401c..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/ProxyConsoleReader.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.runtime;
-
-import java.io.*;
-
-/**
- * A <code>ProxyConsoleReader</code> reads the ouput from the proxy and
- * redirects it to a file or to the stdout if "con" is the name of the file.
- */
-class ProxyConsoleReader extends AbstractReader {
- private InputStream input;
- private OutputStream output;
-/*
- * Creates a new proxy console reader that will read from the given input stream
- * and rewrite what's read to the given file (or the stdout is the file name is
- * "con")
- */
-public ProxyConsoleReader(String name, InputStream input, String fileName) {
- super(name);
- this.input = input;
- if (fileName.equals("con")) {
- this.output= System.out;
- } else {
- try {
- this.output= new FileOutputStream(fileName);
- } catch (IOException e) {
- System.out.println("Could not create file " + fileName + ". Redirecting to stdout");
- this.output= System.out;
- }
- }
-}
-/**
- * Continuously reads from the proxy output and redirect what's read to
- * this reader's file.
- */
-protected void readerLoop() {
- try {
- byte[] buffer= new byte[1024];
- int read= 0;
- while (!this.isStopping && read != -1) {
- read= this.input.read(buffer);
- if (read != -1)
- this.output.write(buffer, 0, read);
- }
- } catch (java.io.IOException e) {
- }
-}
-/**
- * Stop this reader
- */
-public void stop() {
- super.stop();
- try {
- if (this.output != System.out)
- this.output.close();
- } catch (IOException e) {
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/RuntimeConstants.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/RuntimeConstants.java
deleted file mode 100644
index 4ef4c64..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/RuntimeConstants.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.runtime;
-
-public interface RuntimeConstants {
- public static final String SUPPORT_ZIP_FILE_NAME = "EvalTestsTarget.zip";
- public static final String CODE_SNIPPET_RUNNER_CLASS_NAME = "org.eclipse.jdt.core.tests.eval.target.CodeSnippetRunner";
- public static final String RUN_CODE_SNIPPET_METHOD = "runCodeSnippet";
- public static final String THE_RUNNER_FIELD = "theRunner";
- public static final String EVALPORT_ARG = "-evalport";
- public static final String CODESNIPPET_CLASSPATH_ARG = "-cscp";
- public static final String CODESNIPPET_BOOTPATH_ARG = "-csbp";
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java
deleted file mode 100644
index ff75b66..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.runtime;
-
-import org.eclipse.jdt.core.tests.runtime.RuntimeConstants;
-
-import java.io.*;
-
-import java.util.Vector;
-import java.util.Enumeration;
-
-/**
- * A standard VM launcher launches an external standard VM with
- * the given arguments on the same machine.
- */
-public class StandardVMLauncher extends LocalVMLauncher implements RuntimeConstants {
- String batchFileName;
-/**
- * Creates a new StandardVMLauncher that launches a standard VM
- * on the same machine.
- */
-public StandardVMLauncher() {
- super();
-}
-/**
- * Builds the actual boot class path that is going to be passed to the VM.
- */
-protected String buildBootClassPath() {
- StringBuffer bootPathString = new StringBuffer();
- char pathSeparator = File.pathSeparatorChar;
-
- if (this.bootPath != null) {
- // Add boot class path given by client
- int length = this.bootPath.length;
- for (int i = 0; i < length; i++){
- bootPathString.append(this.bootPath[i]);
- bootPathString.append(pathSeparator);
- }
- } else {
- // Add regular rt.jar
- bootPathString.append(this.vmPath);
- bootPathString.append(File.separator);
- if (!(this.vmPath.toLowerCase().endsWith("jre") || this.vmPath.toLowerCase().endsWith("jre" + File.separator))) {
- bootPathString.append("jre");
- bootPathString.append(File.separator);
- }
- bootPathString.append("lib");
- bootPathString.append(File.separator);
- bootPathString.append("rt.jar");
- bootPathString.append(pathSeparator);
- }
-
- // Add boot class path directory if needed
- if (this.evalTargetPath != null && TARGET_HAS_FILE_SYSTEM) {
- bootPathString.append(this.evalTargetPath);
- bootPathString.append(File.separatorChar);
- bootPathString.append(BOOT_CLASSPATH_DIRECTORY);
- }
-
- return bootPathString.toString();
-}
-/**
- * Returns the name of the batch file used to launch the VM.
- */
-public String getBatchFileName() {
- return this.batchFileName;
-}
-/**
- * @see LocalVMLauncher#getCommandLine
- */
-public String[] getCommandLine() {
- Vector commandLine= new Vector();
-
- // VM binary
- commandLine.addElement(
- this.vmPath +
- (this.vmPath.endsWith(File.separator) ? "" : File.separator) +
- "bin" +
- File.separator +
- "javaw");
-
- // VM arguments
- if (this.vmArguments != null) {
- for (int i = 0; i < this.vmArguments.length; i++) {
- commandLine.addElement(this.vmArguments[i]);
- }
- }
-
- // debug mode
- if (this.debugPort != -1) {
- commandLine.addElement("-Xdebug");
- commandLine.addElement("-Xnoagent");
- //commandLine.addElement("-Djava.compiler=NONE");
- commandLine.addElement(
- "-Xrunjdwp:transport=dt_socket,address=" +
- this.debugPort +
- ",server=y,suspend=n");
- }
-
- // boot classpath
- commandLine.addElement("-Xbootclasspath:" + buildBootClassPath());
-
- // regular classpath
- commandLine.addElement("-classpath");
- commandLine.addElement(buildClassPath());
-
- // code snippet runner class
- if (this.evalPort != -1) {
- commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME);
- }
-
- // code snippet runner arguments
- if (this.evalPort != -1) {
- commandLine.addElement(EVALPORT_ARG);
- commandLine.addElement(Integer.toString(this.evalPort));
- if (TARGET_HAS_FILE_SYSTEM) {
- commandLine.addElement(CODESNIPPET_CLASSPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
- commandLine.addElement(CODESNIPPET_BOOTPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
- }
- }
-
- // program class
- if (this.programClass != null) {
- commandLine.addElement(this.programClass);
- }
-
- // program arguments
- if (this.programArguments != null) {
- for (int i=0;i<this.programArguments.length;i++) {
- commandLine.addElement(this.programArguments[i]);
- }
- }
-
- String[] result;
- if (this.batchFileName!= null) {
- // Write to batch file if specified
- writeBatchFile(this.batchFileName, commandLine);
- result = new String[] {this.batchFileName};
- } else {
- result = new String[commandLine.size()];
- commandLine.copyInto(result);
- }
-
- // check for spaces in result
- for (int i = 0; i < result.length; i++) {
- String argument = result[i];
- if (argument.indexOf(' ') != -1) {
- result[i] = "\"" + argument + "\"";
- }
- }
-
- return result;
-}
-/**
- * Sets the name of the batch file used to launch the VM.
- * When this option is set, the launcher writes the command line to the given batch file,
- * and it launches the batch file. This causes a DOS console to be opened. Note it
- * doesn't delete the batch file when done.
- */
-public void setBatchFileName(String batchFileName) {
- this.batchFileName = batchFileName;
-}
-private void writeBatchFile(String fileName, Vector commandLine) {
- FileOutputStream output = null;
- try {
- output = new FileOutputStream(fileName);
- PrintWriter out= new PrintWriter(output);
- for (Enumeration e = commandLine.elements(); e.hasMoreElements();) {
- out.print((String)e.nextElement());
- out.print(" ");
- }
- out.println("pause");
- out.close();
- } catch (IOException e) {
- e.printStackTrace();
- if (output != null) {
- try {
- output.close();
- } catch (IOException e2) {
- }
- }
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/TargetException.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/TargetException.java
deleted file mode 100644
index b7f132e..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/TargetException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.runtime;
-
-/**
- * A TargetException is thrown when an operation on a target has failed
- * for any reason.
- */
-public class TargetException extends Exception {
-/**
- * Constructs a <code>TargetException</code> with no detail message.
- */
-public TargetException() {
- super();
-}
-/**
- * Constructs a <code>TargetException</code> with the specified
- * detail message.
- *
- * @param s the detail message.
- */
-public TargetException(String s) {
- super(s);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/TargetInterface.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/TargetInterface.java
deleted file mode 100644
index 0ad8a03..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/TargetInterface.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.runtime;
-
-import org.eclipse.jdt.internal.compiler.ClassFile;
-import org.eclipse.jdt.core.tests.runtime.*;
-import java.io.*;
-import java.net.*;
-/**
- * This is the interface to the target VM. It connects to an IDEInterface on the target side
- * using TCP/IO to send request for code snippet evaluation and to get the result back.
- *
- * @see org.eclipse.jdt.core.tests.eval.target.IDEInterface for details about the protocol.
- */
-public class TargetInterface {
- /**
- * Whether class files should be written in d:\eval\ instead of sending them to the target
- * NB: d:\eval should contain a batch file TestCodeSnippet.bat with the following contents:
- * SET JDK=c:\jdk1.2.2
- * SET EVAL=d:\eval
- * %JDK%\bin\java -Xbootclasspath:%JDK%\jre\lib\rt.jar;%EVAL%\javaClasses; -classpath c:\temp;%EVAL%\snippets;%EVAL%\classes;"d:\ide\project_resources\Eclipse Java Evaluation\CodeSnippetSupport.jar" CodeSnippetTester %1
- */
- static final boolean DEBUG = false;
- String codeSnippetClassName;
-
- /**
- * Whether timing info should be printed to stdout
- */
- static final boolean TIMING = false;
- long sentTime;
-
- /**
- * The connection to the target's ide interface.
- */
- Socket socket;
-
- public class Result {
- public char[] displayString;
- public char[] typeName;
- }
-
-/**
- * (PRIVATE API)
- * Connects this interface to the target.
- * Try as long as the given time (in ms) has not expired.
- * Use isConnected() to find out if the connection was successful.
- */
-public void connect(String targetAddress, int portNumber, int timeout) {
- if (isConnected()) {
- return;
- }
- if (portNumber > 0) {
- long startTime = System.currentTimeMillis();
- do {
- try {
- this.socket = new Socket(targetAddress, portNumber);
- this.socket.setTcpNoDelay(true);
- break;
- } catch (UnknownHostException e) {
- } catch (IOException e) {
- }
- if (this.socket == null) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- }
- }
- } while (!isConnected() && (System.currentTimeMillis() - startTime) < timeout);
- }
-}
-/**
- * (PRIVATE API)
- * Disconnects this interface from the target.
- */
-public void disconnect() {
- if (this.socket != null) {
- try {
- this.socket.close();
- } catch (IOException e) {
- // Already closed. Nothing more to do
- }
- this.socket = null;
- }
-}
-/**
- * Returns the result of the evaluation sent previously to the target.
- */
-public Result getResult() {
- boolean hasValue = false;
- String typeName = null;
- String toString = null;
- if (DEBUG) {
- hasValue = true;
- typeName = "TargetInterface in debug mode. Run d:\\eval\\TestCodeSnippet.bat d:\\eval\\snippets\\" + codeSnippetClassName;
- toString = "";
- } else {
- if (this.isConnected()) {
- // TBD: Read type name and toString as a character array
- try {
- DataInputStream in = new DataInputStream(this.socket.getInputStream());
- hasValue = in.readBoolean();
- if (hasValue) {
- typeName = in.readUTF();
- toString = in.readUTF();
- } else {
- typeName = null;
- toString = null;
- }
- } catch (IOException e) {
- // The socket has likely been closed on the other end. So the code snippet runner has stopped.
- hasValue = true;
- typeName = e.getMessage();
- toString = "";
- this.disconnect();
- }
- } else {
- hasValue = true;
- typeName = "Connection has been lost";
- toString = "";
- }
- }
- if (TIMING) {
- System.out.println("Time to send compiled classes, run on target and get result is " + (System.currentTimeMillis() - this.sentTime) + "ms");
- }
- Result result = new Result();
- result.displayString = toString == null ? null : toString.toCharArray();
- result.typeName = typeName == null ? null : typeName.toCharArray();
- return result;
-}
-/**
- * Returns whether this interface is connected to the target.
- */
-boolean isConnected() {
- return this.socket != null;
-}
-/**
- * Sends the given class definitions to the target for loading and (if specified) for running.
- */
-public void sendClasses(boolean mustRun, ClassFile[] classes) throws TargetException {
- if (DEBUG) {
- for (int i = 0; i < classes.length; i++) {
- String className = new String(classes[i].fileName()).replace('/', '\\') + ".class";
- if ((i == 0) && (className.indexOf("CodeSnippet") != -1)) {
- codeSnippetClassName = className;
- try {
- ClassFile.writeToDisk(true, "d:\\eval\\snippets", className, classes[0].getBytes());
- } catch(IOException e) {
- }
- } else {
- String dirName;
- if (className.startsWith("java")) {
- dirName = "d:\\eval\\" + LocalVMLauncher.BOOT_CLASSPATH_DIRECTORY;
- } else {
- dirName = "d:\\eval\\" + LocalVMLauncher.REGULAR_CLASSPATH_DIRECTORY;
- }
- try {
- ClassFile.writeToDisk(true, dirName, className, classes[i].getBytes());
- } catch(IOException e) {
- }
- }
- }
- } else {
- if (TIMING) {
- this.sentTime = System.currentTimeMillis();
- }
- if (!isConnected()) {
- throw new TargetException("Connection to the target VM has been lost");
- }
- try {
- DataOutputStream out = new DataOutputStream(this.socket.getOutputStream());
- out.writeBoolean(mustRun);
- out.writeInt(classes.length);
- for (int i = 0; i < classes.length; i++) {
- byte[] classDefinition = classes[i].getBytes();
- out.writeInt(classDefinition.length);
- out.write(classDefinition);
- }
- } catch (IOException e) {
- // The socket has likely been closed on the other end. So the code snippet runner has stopped.
- this.disconnect();
- }
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/VMInputStream.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/VMInputStream.java
deleted file mode 100644
index eef0b79..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/VMInputStream.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.runtime;
-
-import java.io.*;
-
-/**
- * Workaround problem with input stream from a <code>java.lang.Process</code>
- * that throws an <code>IOException</code> even if there is something to read.
- */
-public class VMInputStream extends InputStream {
- InputStream input;
- Process process;
-public VMInputStream(Process process, InputStream input) {
- this.process= process;
- this.input= input;
-}
-public int available() throws IOException {
- return this.input.available();
-}
-public void close() throws IOException {
- this.input.close();
-}
-private boolean isRunning() {
- if (this.process == null)
- return false;
- else {
- boolean hasExited;
- try {
- this.process.exitValue();
- hasExited = true;
- } catch (IllegalThreadStateException e) {
- hasExited = false;
- }
- return !hasExited;
- }
-}
-public synchronized void mark(int readlimit) {
- this.input.mark(readlimit);
-}
-public boolean markSupported() {
- return this.input.markSupported();
-}
-public int read() throws IOException {
- try {
- return this.input.read();
- } catch (IOException e) {
- if (isRunning()) {
- return read();
- } else {
- throw e;
- }
- }
-}
-public int read(byte b[]) throws IOException {
- // Make sure the byte array is initialized (value of 0 is used in the workaround below)
- for (int i=0;i<b.length;i++)
- b[i]=0;
-
- int read;
- try {
- read = this.input.read(b);
- } catch (IOException e) {
- if (isRunning()) {
- // Workaround problem with implementation of Process.getInputStream()
- // (see PR 1PRW670: LFRE:WINNT - Program hangs running in LeapFrog)
- read= 0;
- while (read < b.length && b[read] != 0) {
- read++;
- }
- } else
- throw e;
- }
-
- return read;
-}
-public int read(byte b[], int off, int len) throws IOException {
- // Make sure the byte array is initialized (value of 0 is used in the workaround below)
- for (int i = off; i < len; i++)
- b[i] = 0;
-
- int read;
- try {
- read = this.input.read(b, off, len);
- } catch (IOException e) {
- if (isRunning()) {
- // Workaround problem with implementation of Process.getInputStream()
- // (see PR 1PRW670: LFRE:WINNT - Program hangs running in LeapFrog)
- read = 0;
- while (off + read < len && b[off + read] != 0) {
- read++;
- }
- } else
- throw e;
- }
- return read;
-}
-public synchronized void reset() throws IOException {
- this.input.reset();
-}
-public long skip(long n) throws IOException {
- return this.input.skip(n);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/SocketHelper.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/SocketHelper.java
deleted file mode 100644
index 864b74c..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/SocketHelper.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.util;
-
-import java.io.*;
-import java.net.*;
-public class SocketHelper {
- int localPort = -1;
-/**
- * Using the given port number to create a server, creates a connection to this server
- * and returns the local port of the client (after closing the connection so that
- * the local port is now available).
- * Returns -1 if the server could not be created.
- */
-public int getAvailablePort(final int portNumber) {
- this.localPort = -1;
- Thread server = new Thread() {
- public void run() {
- try {
- new ServerSocket(portNumber).accept().close();
- } catch (IOException e) {
- // address in use
- }
- }
- };
- server.start();
-
- try {
- Socket socket = new Socket("127.0.0.1", portNumber);
- server.join(2000);
- this.localPort = socket.getLocalPort();
- socket.close();
- } catch (InterruptedException e) {
- } catch (IOException e) {
- // connection refused
- }
-
- return this.localPort;
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java
deleted file mode 100644
index cbc54ac..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java
+++ /dev/null
@@ -1,589 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.util;
-
-import org.eclipse.jdt.core.tests.runtime.*;
-import java.io.*;
-import java.net.*;
-/**
- * Verifies that the .class files resulting from a compilation can be loaded
- * in a VM and that they can be run.
- */
-public class TestVerifier {
- public String failureReason;
-
- boolean reuseVM = true;
- String[] classpaths;
- LocalVirtualMachine vm;
- StringBuffer outputBuffer;
- StringBuffer errorBuffer;
- Socket socket;
-public TestVerifier(boolean reuseVM) {
- this.reuseVM = reuseVM;
-}
-private boolean checkBuffers(String errorString, String outputString, String sourceFileName, String expectedSuccessOutputString) {
-
- if (errorString.length() > 0) {
- this.failureReason =
- "Unexpected target error running resulting class file for "
- + sourceFileName
- + ":\n"
- + errorString;
- return false;
- }
- //System.out.println(Util.displayString(outputString, 2));
- if (expectedSuccessOutputString != null && outputString.indexOf(expectedSuccessOutputString) == -1) {
- this.failureReason =
- "Unexpected output running resulting class file for "
- + sourceFileName
- + ":\n"
- + "--[START]--\n"
- + outputString
- + "---[END]---\n";
- return false;
- }
-
- return true;
-}
-
-private boolean checkBuffersThrowingError(String errorString, String outputString, String sourceFileName, String expectedSuccessOutputString) {
-
- if (errorString.length() > 0 && errorString.indexOf(expectedSuccessOutputString) != -1) {
- return true;
- }
-
- this.failureReason =
- "Expected error not thrown for "
- + sourceFileName
- + ":\n"
- + expectedSuccessOutputString;
- return false;
-}
-
-private void compileVerifyTests(String verifierDir) {
- String fullyQualifiedName = VerifyTests.class.getName();
-
- int lastDot = fullyQualifiedName.lastIndexOf('.');
- String packageName = fullyQualifiedName.substring(0, lastDot);
- String simpleName = fullyQualifiedName.substring(lastDot + 1);
-
- String dirName = verifierDir.replace('\\', '/') + "/" + packageName.replace('.', '/');
- File dir = new File(dirName.replace('/', File.separatorChar));
- if (!dir.exists() && !dir.mkdirs()) {
- System.out.println("Could not create " + dir);
- return;
- }
- String fileName = dir + File.separator + simpleName + ".java";
- Util.writeToFile(this.getVerifyTestsCode(), fileName);
- org.eclipse.jdt.internal.compiler.batch.Main.compile("\"" + fileName + "\" -d \"" + verifierDir + "\" -classpath \"" + Util.getJavaClassLib() + "\"");
-}
-public void execute(String className, String[] classpaths) {
- this.outputBuffer = new StringBuffer();
- this.errorBuffer = new StringBuffer();
-
- launchAndRun(className, classpaths, null, null);
-}
-protected void finalize() throws Throwable {
- this.shutDown();
-}
-public String getExecutionOutput(){
- return outputBuffer.toString();
-}
-
-public String getExecutionError(){
- return errorBuffer.toString();
-}
-/**
- * Returns the code of the VerifyTests class.
- *
- * To generate:
- * - export VerifyTests to c:/temp/test
- * - inspect org.eclipse.jdt.core.tests.util.Util.fileContentToDisplayString("c:/temp/test/org/eclipse/jdt/core/tests/util/VerifyTests.java", 2)
- */
-private String getVerifyTestsCode() {
- return
- "package org.eclipse.jdt.core.tests.util;\n" +
- "import java.lang.reflect.*;\n" +
- "import java.io.*;\n" +
- "import java.net.*;\n" +
- "import java.util.*;\n" +
- "public class VerifyTests {\n" +
- " int portNumber;\n" +
- " Socket socket;\n" +
- "/**\n" +
- " * NOTE: Code copied from junit.util.TestCaseClassLoader.\n" +
- " *\n" +
- " * A custom class loader which enables the reloading\n" +
- " * of classes for each test run. The class loader\n" +
- " * can be configured with a list of package paths that\n" +
- " * should be excluded from loading. The loading\n" +
- " * of these packages is delegated to the system class\n" +
- " * loader. They will be shared across test runs.\n" +
- " * <p>\n" +
- " * The list of excluded package paths is specified in\n" +
- " * a properties file \"excluded.properties\" that is located in \n" +
- " * the same place as the TestCaseClassLoader class.\n" +
- " * <p>\n" +
- " * <b>Known limitation:</b> the VerifyClassLoader cannot load classes\n" +
- " * from jar files.\n" +
- " */\n" +
- "public class VerifyClassLoader extends ClassLoader {\n" +
- " /** scanned class path */\n" +
- " private String[] fPathItems;\n" +
- " \n" +
- " /** excluded paths */\n" +
- " private String[] fExcluded= {};\n" +
- " /**\n" +
- " * Constructs a VerifyClassLoader. It scans the class path\n" +
- " * and the excluded package paths\n" +
- " */\n" +
- " public VerifyClassLoader() {\n" +
- " super();\n" +
- " String classPath= System.getProperty(\"java.class.path\");\n" +
- " String separator= System.getProperty(\"path.separator\");\n" +
- " \n" +
- " // first pass: count elements\n" +
- " StringTokenizer st= new StringTokenizer(classPath, separator);\n" +
- " int i= 0;\n" +
- " while (st.hasMoreTokens()) {\n" +
- " st.nextToken();\n" +
- " i++;\n" +
- " }\n" +
- " // second pass: split\n" +
- " fPathItems= new String[i];\n" +
- " st= new StringTokenizer(classPath, separator);\n" +
- " i= 0;\n" +
- " while (st.hasMoreTokens()) {\n" +
- " fPathItems[i++]= st.nextToken();\n" +
- " }\n" +
- " }\n" +
- " public java.net.URL getResource(String name) {\n" +
- " return ClassLoader.getSystemResource(name);\n" +
- " }\n" +
- " public InputStream getResourceAsStream(String name) {\n" +
- " return ClassLoader.getSystemResourceAsStream(name);\n" +
- " }\n" +
- " protected boolean isExcluded(String name) {\n" +
- " // exclude the \"java\" packages.\n" +
- " // They always need to be excluded so that they are loaded by the system class loader\n" +
- " if (name.startsWith(\"java\"))\n" +
- " return true;\n" +
- " \n" +
- " // exclude the user defined package paths\n" +
- " for (int i= 0; i < fExcluded.length; i++) {\n" +
- " if (name.startsWith(fExcluded[i])) {\n" +
- " return true;\n" +
- " }\n" +
- " }\n" +
- " return false; \n" +
- " }\n" +
- " public synchronized Class loadClass(String name, boolean resolve)\n" +
- " throws ClassNotFoundException {\n" +
- " \n" +
- " Class c= findLoadedClass(name);\n" +
- " if (c != null)\n" +
- " return c;\n" +
- " //\n" +
- " // Delegate the loading of excluded classes to the\n" +
- " // standard class loader.\n" +
- " //\n" +
- " if (isExcluded(name)) {\n" +
- " try {\n" +
- " c= findSystemClass(name);\n" +
- " return c;\n" +
- " } catch (ClassNotFoundException e) {\n" +
- " // keep searching\n" +
- " }\n" +
- " }\n" +
- " if (c == null) {\n" +
- " File file= locate(name);\n" +
- " if (file == null)\n" +
- " throw new ClassNotFoundException();\n" +
- " byte data[]= loadClassData(file);\n" +
- " c= defineClass(name, data, 0, data.length);\n" +
- " }\n" +
- " if (resolve) \n" +
- " resolveClass(c);\n" +
- " return c;\n" +
- " }\n" +
- " private byte[] loadClassData(File f) throws ClassNotFoundException {\n" +
- " try {\n" +
- " //System.out.println(\"loading: \"+f.getPath());\n" +
- " FileInputStream stream= new FileInputStream(f);\n" +
- " \n" +
- " try {\n" +
- " byte[] b= new byte[stream.available()];\n" +
- " stream.read(b);\n" +
- " stream.close();\n" +
- " return b;\n" +
- " }\n" +
- " catch (IOException e) {\n" +
- " throw new ClassNotFoundException();\n" +
- " }\n" +
- " }\n" +
- " catch (FileNotFoundException e) {\n" +
- " throw new ClassNotFoundException();\n" +
- " }\n" +
- " }\n" +
- " /**\n" +
- " * Locate the given file.\n" +
- " * @return Returns null if file couldn\'t be found.\n" +
- " */\n" +
- " private File locate(String fileName) { \n" +
- " fileName= fileName.replace(\'.\', \'/\')+\".class\";\n" +
- " File path= null;\n" +
- " \n" +
- " if (fileName != null) {\n" +
- " for (int i= 0; i < fPathItems.length; i++) {\n" +
- " path= new File(fPathItems[i], fileName);\n" +
- " if (path.exists())\n" +
- " return path;\n" +
- " }\n" +
- " }\n" +
- " return null;\n" +
- " }\n" +
- "}\n" +
- " \n" +
- "public void loadAndRun(String className) throws Throwable {\n" +
- " //System.out.println(\"Loading \" + className + \"...\");\n" +
- " Class testClass = new VerifyClassLoader().loadClass(className);\n" +
- " //System.out.println(\"Loaded \" + className);\n" +
- " try {\n" +
- " Method main = testClass.getMethod(\"main\", new Class[] {String[].class});\n" +
- " //System.out.println(\"Running \" + className);\n" +
- " main.invoke(null, new Object[] {new String[] {}});\n" +
- " //System.out.println(\"Finished running \" + className);\n" +
- " } catch (NoSuchMethodException e) {\n" +
- " return;\n" +
- " } catch (InvocationTargetException e) {\n" +
- " throw e.getTargetException();\n" +
- " }\n" +
- "}\n" +
- "public static void main(String[] args) throws IOException {\n" +
- " VerifyTests verify = new VerifyTests();\n" +
- " verify.portNumber = Integer.parseInt(args[0]);\n" +
- " verify.run();\n" +
- "}\n" +
- "public void run() throws IOException {\n" +
- " ServerSocket server = new ServerSocket(this.portNumber);\n" +
- " this.socket = server.accept();\n" +
- " this.socket.setTcpNoDelay(true);\n" +
- " server.close();\n" +
- " DataInputStream in = new DataInputStream(this.socket.getInputStream());\n" +
- " final DataOutputStream out = new DataOutputStream(this.socket.getOutputStream());\n" +
- " while (true) {\n" +
- " final String className = in.readUTF();\n" +
- " Thread thread = new Thread() {\n" +
- " public void run() {\n" +
- " try {\n" +
- " loadAndRun(className);\n" +
- " out.writeBoolean(true);\n" +
- " System.err.println(VerifyTests.class.getName());\n" +
- " System.out.println(VerifyTests.class.getName());\n" +
- " } catch (Throwable e) {\n" +
- " e.printStackTrace();\n" +
- " try {\n" +
- " System.err.println(VerifyTests.class.getName());\n" +
- " System.out.println(VerifyTests.class.getName());\n" +
- " out.writeBoolean(false);\n" +
- " } catch (IOException e1) {\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- " };\n" +
- " thread.start();\n" +
- " }\n" +
- "}\n" +
- "}\n";
-}
-private void launchAndRun(String className, String[] classpaths, String[] programArguments, String[] vmArguments) {
- // we won't reuse the vm, shut the existing one if running
- if (this.vm != null) {
- try {
- vm.shutDown();
- } catch (TargetException e) {
- }
- }
- this.classpaths = null;
-
- // launch a new one
- LocalVMLauncher launcher = LocalVMLauncher.getLauncher();
- launcher.setClassPath(classpaths);
- launcher.setVMPath(Util.getJREDirectory());
- if (vmArguments != null) {
- String[] completeVmArguments = new String[vmArguments.length + 1];
- System.arraycopy(vmArguments, 0, completeVmArguments, 1, vmArguments.length);
- completeVmArguments[0] = "-verify";
- launcher.setVMArguments(completeVmArguments);
- } else {
- launcher.setVMArguments(new String[] {"-verify"});
- }
- launcher.setProgramClass(className);
- launcher.setProgramArguments(programArguments);
- Thread outputThread;
- Thread errorThread;
- try {
- this.vm = launcher.launch();
- final InputStream input = this.vm.getInputStream();
- outputThread = new Thread(new Runnable() {
- public void run() {
- try {
- int c = input.read();
- while (c != -1) {
- outputBuffer.append((char) c);
- c = input.read();
- }
- } catch(IOException ioEx) {
- }
- }
- });
- final InputStream errorStream = this.vm.getErrorStream();
- errorThread = new Thread(new Runnable() {
- public void run() {
- try {
- int c = errorStream.read();
- while (c != -1) {
- errorBuffer.append((char) c);
- c = errorStream.read();
- }
- } catch(IOException ioEx) {
- }
- }
- });
- outputThread.start();
- errorThread.start();
- } catch(TargetException e) {
- throw new Error(e.getMessage());
- }
-
- // wait for vm to shut down by itself
- try {
- outputThread.join(5000);
- errorThread.join(5000);
- } catch (InterruptedException e) {
- }
-}
-private void launchVerifyTestsIfNeeded(String[] classpaths, String[] vmArguments) {
- // determine if we can reuse the vm
- if (this.vm != null && this.vm.isRunning() && this.classpaths != null) {
- boolean sameClasspaths = true;
- for (int i = 0; i < classpaths.length; i++) {
- if (!this.classpaths[i].equals(classpaths[i])) {
- sameClasspaths = false;
- break;
- }
- }
- if (sameClasspaths) {
- return;
- }
- }
-
- // we could not reuse the vm, shut the existing one if running
- if (this.vm != null) {
- try {
- vm.shutDown();
- } catch (TargetException e) {
- }
- }
-
- this.classpaths = classpaths;
-
- // launch a new one
- LocalVMLauncher launcher = LocalVMLauncher.getLauncher();
- int length = classpaths.length;
- String[] cp = new String[length + 1];
- System.arraycopy(classpaths, 0, cp, 0, length);
- String verifierDir = Util.getOutputDirectory() + File.separator + "verifier";
- this.compileVerifyTests(verifierDir);
- cp[length] = verifierDir;
- launcher.setClassPath(cp);
- launcher.setVMPath(Util.getJREDirectory());
- if (vmArguments != null) {
- String[] completeVmArguments = new String[vmArguments.length + 1];
- System.arraycopy(vmArguments, 0, completeVmArguments, 1, vmArguments.length);
- completeVmArguments[0] = "-verify";
- launcher.setVMArguments(completeVmArguments);
- } else {
- launcher.setVMArguments(new String[] {"-verify"});
- }
- launcher.setProgramClass(VerifyTests.class.getName());
- int portNumber = Util.nextAvailablePortNumber();
- launcher.setProgramArguments(new String[] {Integer.toString(portNumber)});
- try {
- this.vm = launcher.launch();
- final InputStream input = this.vm.getInputStream();
- Thread outputThread = new Thread(new Runnable() {
- public void run() {
- try {
- int c = input.read();
- while (c != -1) {
- outputBuffer.append((char) c);
- c = input.read();
- }
- } catch(IOException ioEx) {
- }
- }
- });
- final InputStream errorStream = this.vm.getErrorStream();
- Thread errorThread = new Thread(new Runnable() {
- public void run() {
- try {
- int c = errorStream.read();
- while (c != -1) {
- errorBuffer.append((char) c);
- c = errorStream.read();
- }
- } catch(IOException ioEx) {
- }
- }
- });
- outputThread.start();
- errorThread.start();
- } catch(TargetException e) {
- throw new Error(e.getMessage());
- }
-
- // connect to the vm
- this.socket = null;
- boolean isVMRunning = false;
- do {
- try {
- this.socket = new Socket("localhost", portNumber);
- this.socket.setTcpNoDelay(true);
- break;
- } catch (UnknownHostException e) {
- } catch (IOException e) {
- }
- if (this.socket == null) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- }
- isVMRunning = vm.isRunning();
- }
- } while (this.socket == null && isVMRunning);
-
-}
-/**
- * Loads and runs the given class.
- * Return whether no exception was thrown while running the class.
- */
-private boolean loadAndRun(String className) {
- if (this.socket != null) {
- try {
- DataOutputStream out = new DataOutputStream(this.socket.getOutputStream());
- out.writeUTF(className);
- DataInputStream in = new DataInputStream(this.socket.getInputStream());
- try {
- boolean result = in.readBoolean();
- this.waitForFullBuffers();
- return result;
- } catch (SocketException e) {
- // connection was reset because target program has exited
- return true;
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return true;
-}
-public void shutDown() {
- // Close the socket first so that the OS resource has a chance to be freed.
- if (this.socket != null) {
- try {
- this.socket.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- // Wait for the vm to shut down by itself for 2 seconds. If not succesfull, force the shut down.
- if (this.vm != null) {
- try {
- int retry = 0;
- while (this.vm.isRunning() && (++retry < 20)) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- }
- }
- if (this.vm.isRunning()) {
- this.vm.shutDown();
- }
- } catch (TargetException e) {
- e.printStackTrace();
- }
- }
-}
-/**
- * Verify that the class files created for the given test file can be loaded by
- * a virtual machine.
- */
-public boolean verifyClassFiles(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths) {
- return verifyClassFiles(sourceFilePath, className, expectedSuccessOutputString, classpaths, null, null);
-}
-/**
- * Verify that the class files created for the given test file can be loaded by
- * a virtual machine.
- */
-public boolean verifyClassFiles(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths, String[] programArguments, String[] vmArguments) {
- this.outputBuffer = new StringBuffer();
- this.errorBuffer = new StringBuffer();
- if (this.reuseVM && programArguments == null) {
- this.launchVerifyTestsIfNeeded(classpaths, vmArguments);
- this.loadAndRun(className);
- } else {
- this.launchAndRun(className, classpaths, programArguments, vmArguments);
- }
-
- this.failureReason = null;
- return this.checkBuffers(this.errorBuffer.toString(), this.outputBuffer.toString(), sourceFilePath, expectedSuccessOutputString);
-}
-
-/**
- * Verify that the class files created for the given test file can be loaded and run with an expected error contained
- * in the expectedSuccessOutputString string.
- */
-public boolean verifyClassFilesThrowingError(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths, String[] programArguments, String[] vmArguments) {
- this.outputBuffer = new StringBuffer();
- this.errorBuffer = new StringBuffer();
- if (this.reuseVM && programArguments == null) {
- this.launchVerifyTestsIfNeeded(classpaths, vmArguments);
- this.loadAndRun(className);
- } else {
- this.launchAndRun(className, classpaths, programArguments, vmArguments);
- }
-
- this.failureReason = null;
- return this.checkBuffersThrowingError(this.errorBuffer.toString(), this.outputBuffer.toString(), sourceFilePath, expectedSuccessOutputString);
-}
-
-/**
- * Wait until there is nothing more to read from the stdout or sterr.
- */
-private void waitForFullBuffers() {
- String endString = VerifyTests.class.getName();
- int count = 50;
- int errorEndStringStart = this.errorBuffer.toString().indexOf(endString);
- int outputEndStringStart = this.outputBuffer.toString().indexOf(endString);
- while (errorEndStringStart == -1 || outputEndStringStart == -1) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- }
- if (--count == 0) return;
- errorEndStringStart = this.errorBuffer.toString().indexOf(endString);
- outputEndStringStart = this.outputBuffer.toString().indexOf(endString);
- }
- this.errorBuffer.setLength(errorEndStringStart);
- this.outputBuffer.setLength(outputEndStringStart);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java
deleted file mode 100644
index d79f2a0..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.util;
-
-import java.io.*;
-public class Util {
- public static String OUTPUT_DIRECTORY = "comptest";
-
- public static int MAX_PORT_NUMBER = 9999;
-/**
- * Copy the given source (a file or a directory that must exists) to the given destination (a directory that must exists).
- */
-public static void copy(String sourcePath, String destPath) {
- sourcePath = toNativePath(sourcePath);
- destPath = toNativePath(destPath);
- File source = new File(sourcePath);
- if (!source.exists()) return;
- File dest = new File(destPath);
- if (!dest.exists()) return;
- if (source.isDirectory()) {
- String[] files = source.list();
- if (files != null) {
- for (int i = 0; i < files.length; i++) {
- String file = files[i];
- File sourceFile = new File(source, file);
- if (sourceFile.isDirectory()) {
- File destSubDir = new File(dest, file);
- destSubDir.mkdir();
- copy(sourceFile.getPath(), destSubDir.getPath());
- } else {
- copy(sourceFile.getPath(), dest.getPath());
- }
- }
- }
- } else {
- FileInputStream in = null;
- FileOutputStream out = null;
- try {
- in = new FileInputStream(source);
- File destFile = new File(dest, source.getName());
- if (destFile.exists() && !destFile.delete()) {
- throw new IOException(destFile + " is in use");
- }
- out = new FileOutputStream(destFile);
- int bufferLength = 1024;
- byte[] buffer = new byte[bufferLength];
- int read = 0;
- while (read != -1) {
- read = in.read(buffer, 0, bufferLength);
- if (read != -1) {
- out.write(buffer, 0, read);
- }
- }
- } catch (IOException e) {
- throw new Error(e.toString());
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- }
- }
- if (out != null) {
- try {
- out.close();
- } catch (IOException e) {
- }
- }
- }
- }
-}
-/**
- * Generate a display string from the given String.
- * @param indent number of tabs are added at the begining of each line.
- *
- * Example of use: [org.eclipse.jdt.core.tests.util.Util.displayString("abc\ndef\tghi")]
-*/
-public static String displayString(String inputString){
- return displayString(inputString, 0);
-}
-/**
- * Generate a display string from the given String.
- * @param indent number of tabs are added at the begining of each line.
- *
- * Example of use: [org.eclipse.jdt.core.tests.util.Util.displayString("abc\ndef\tghi", 3)]
-*/
-public static String displayString(String inputString, int indent) {
- int length = inputString.length();
- StringBuffer buffer = new StringBuffer(length);
- java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(inputString, "\n\r");
- int count = 0;
- for (int i = 0; i < indent; i++) buffer.append("\t");
- buffer.append("\"");
- while (tokenizer.hasMoreTokens()){
- if (count++ != 0) {
- buffer.append("\\n\" + \n");
- for (int i = 0; i < indent; i++) buffer.append("\t");
- buffer.append("\"");
- }
- String token = tokenizer.nextToken();
- StringBuffer tokenBuffer = new StringBuffer();
- for (int i = 0; i < token.length(); i++){
- char c = token.charAt(i);
- switch (c) {
- case '\b' :
- tokenBuffer.append("\\b");
- break;
- case '\t' :
- tokenBuffer.append("\t");
- break;
- case '\n' :
- tokenBuffer.append("\\n");
- break;
- case '\f' :
- tokenBuffer.append("\\f");
- break;
- case '\r' :
- tokenBuffer.append("\\r");
- break;
- case '\"' :
- tokenBuffer.append("\\\"");
- break;
- case '\'' :
- tokenBuffer.append("\\'");
- break;
- case '\\' :
- tokenBuffer.append("\\\\");
- break;
- default :
- tokenBuffer.append(c);
- }
- }
- buffer.append(tokenBuffer.toString());
- }
- char lastChar = length == 0 ? 0 : inputString.charAt(length-1);
- if ((lastChar == '\n') || (lastChar == '\r')) buffer.append("\\n");
- buffer.append("\"");
- return buffer.toString();
-}
-/**
- * Reads the content of the given source file and converts it to a display string.
- *
- * Example of use: [org.eclipse.jdt.core.tests.util.Util.fileContentToDisplayString("c:/temp/X.java", 0)]
-*/
-public static String fileContentToDisplayString(String sourceFilePath, int indent) {
- File sourceFile = new File(sourceFilePath);
- if (!sourceFile.exists()) {
- System.out.println("File " + sourceFilePath + " does not exists.");
- return null;
- }
- if (!sourceFile.isFile()) {
- System.out.println(sourceFilePath + " is not a file.");
- return null;
- }
- StringBuffer sourceContentBuffer = new StringBuffer();
- FileInputStream input = null;
- try {
- input = new FileInputStream(sourceFile);
- } catch (FileNotFoundException e) {
- return null;
- }
- try {
- int read;
- do {
- read = input.read();
- if (read != -1) {
- sourceContentBuffer.append((char)read);
- }
- } while (read != -1);
- input.close();
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- } finally {
- try {
- input.close();
- } catch (IOException e2) {
- }
- }
- return displayString(sourceContentBuffer.toString(), indent);
-}
-/**
- * Reads the content of the given source file, converts it to a display string.
- * If the destination file path is not null, writes the result to this file.
- * Otherwise writes it to the console.
- *
- * Example of use: [org.eclipse.jdt.core.tests.util.Util.fileContentToDisplayString("c:/temp/X.java", 0, null)]
-*/
-public static void fileContentToDisplayString(String sourceFilePath, int indent, String destinationFilePath) {
- String displayString = fileContentToDisplayString(sourceFilePath, indent);
- if (destinationFilePath == null) {
- System.out.println(displayString);
- return;
- }
- writeToFile(displayString, destinationFilePath);
-}
-/**
- * Flush content of a given directory (leaving it empty),
- * no-op if not a directory.
- */
-public static void flushDirectoryContent(File dir) {
- if (dir.isDirectory()) {
- String[] files = dir.list();
- if (files == null) return;
- for (int i = 0, max = files.length; i < max; i++) {
- File current = new File(dir, files[i]);
- if (current.isDirectory()) {
- flushDirectoryContent(current);
- }
- current.delete();
- }
- }
-}
-/**
- * Search the user hard-drive for a Java class library.
- * Returns null if none could be found.
- *
- * Example of use: [org.eclipse.jdt.core.tests.util.Util.getJavaClassLib()]
-*/
-public static String getJavaClassLib() {
- String jreDir = getJREDirectory();
- if (jreDir == null) {
- return null;
- } else {
- if ("J9".equals(System.getProperty("java.vm.name"))) {
- return toNativePath(jreDir + "/lib/jclMax/classes.zip");
- } else {
- return toNativePath(jreDir + "/lib/rt.jar");
- }
- }
-}
-/**
- * Returns the JRE directory this tests are running on.
- * Returns null if none could be found.
- *
- * Example of use: [org.eclipse.jdt.core.tests.util.Util.getJREDirectory()]
-*/
-public static String getJREDirectory() {
- return System.getProperty("java.home");
-}
-/**
- * Search the user hard-drive for a possible output directory.
- * Returns null if none could be found.
- *
- * Example of use: [org.eclipse.jdt.core.tests.util.Util.getOutputDirectory()]
-*/
-public static String getOutputDirectory() {
- String container = System.getProperty("java.io.tmpdir");
- if (container == null){
- return null;
- } else {
- return toNativePath(container) + File.separator + OUTPUT_DIRECTORY;
- }
-}
-/**
- * Returns whether one of the arguments is "-expert".
- */
-public static boolean isExpert(String[] args) {
- for (int i = 0; i < args.length; i++) {
- if (args[i].toLowerCase().equals("-expert")) {
- return true;
- }
- }
- return false;
-}
-/**
- * Returns the next available port number on the local host.
- */
-public static int nextAvailablePortNumber() {
- for (int i = MAX_PORT_NUMBER; i > 1000; i--) {
- int localPort = new SocketHelper().getAvailablePort(i);
- if (localPort != -1) {
- return localPort;
- }
- }
- return -1;
-}
-/**
- * Makes the given path a path using native path separators as returned by File.getPath()
- * and trimming any extra slash.
- */
-public static String toNativePath(String path) {
- String nativePath = path.replace('\\', File.separatorChar).replace('/', File.separatorChar);
- return
- nativePath.endsWith("/") || nativePath.endsWith("\\") ?
- nativePath.substring(0, nativePath.length() - 1) :
- nativePath;
-}
-public static void writeToFile(String contents, String destinationFilePath) {
- File destFile = new File(destinationFilePath);
- FileOutputStream output = null;
- try {
- output = new FileOutputStream(destFile);
- PrintWriter writer = new PrintWriter(output);
- writer.print(contents);
- writer.flush();
- } catch (IOException e) {
- e.printStackTrace();
- return;
- } finally {
- if (output != null) {
- try {
- output.close();
- } catch (IOException e2) {
- }
- }
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/VerifyTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/VerifyTests.java
deleted file mode 100644
index d883ae2..0000000
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/VerifyTests.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.util;
-
-import java.lang.reflect.*;
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-public class VerifyTests {
- int portNumber;
- Socket socket;
-
-/**
- * NOTE: Code copied from junit.util.TestCaseClassLoader.
- *
- * A custom class loader which enables the reloading
- * of classes for each test run. The class loader
- * can be configured with a list of package paths that
- * should be excluded from loading. The loading
- * of these packages is delegated to the system class
- * loader. They will be shared across test runs.
- * <p>
- * The list of excluded package paths is specified in
- * a properties file "excluded.properties" that is located in
- * the same place as the TestCaseClassLoader class.
- * <p>
- * <b>Known limitation:</b> the VerifyClassLoader cannot load classes
- * from jar files.
- */
-
-
-public class VerifyClassLoader extends ClassLoader {
- /** scanned class path */
- private String[] fPathItems;
-
- /** excluded paths */
- private String[] fExcluded= {};
-
- /**
- * Constructs a VerifyClassLoader. It scans the class path
- * and the excluded package paths
- */
- public VerifyClassLoader() {
- super();
- String classPath= System.getProperty("java.class.path");
- String separator= System.getProperty("path.separator");
-
- // first pass: count elements
- StringTokenizer st= new StringTokenizer(classPath, separator);
- int i= 0;
- while (st.hasMoreTokens()) {
- st.nextToken();
- i++;
- }
- // second pass: split
- fPathItems= new String[i];
- st= new StringTokenizer(classPath, separator);
- i= 0;
- while (st.hasMoreTokens()) {
- fPathItems[i++]= st.nextToken();
- }
-
- }
- public java.net.URL getResource(String name) {
- return ClassLoader.getSystemResource(name);
- }
- public InputStream getResourceAsStream(String name) {
- return ClassLoader.getSystemResourceAsStream(name);
- }
- protected boolean isExcluded(String name) {
- // exclude the "java" packages.
- // They always need to be excluded so that they are loaded by the system class loader
- if (name.startsWith("java"))
- return true;
-
- // exclude the user defined package paths
- for (int i= 0; i < fExcluded.length; i++) {
- if (name.startsWith(fExcluded[i])) {
- return true;
- }
- }
- return false;
- }
- public synchronized Class loadClass(String name, boolean resolve)
- throws ClassNotFoundException {
-
- Class c= findLoadedClass(name);
- if (c != null)
- return c;
- //
- // Delegate the loading of excluded classes to the
- // standard class loader.
- //
- if (isExcluded(name)) {
- try {
- c= findSystemClass(name);
- return c;
- } catch (ClassNotFoundException e) {
- // keep searching
- }
- }
- if (c == null) {
- File file= locate(name);
- if (file == null)
- throw new ClassNotFoundException();
- byte data[]= loadClassData(file);
- c= defineClass(name, data, 0, data.length);
- }
- if (resolve)
- resolveClass(c);
- return c;
- }
- private byte[] loadClassData(File f) throws ClassNotFoundException {
- try {
- //System.out.println("loading: "+f.getPath());
- FileInputStream stream= new FileInputStream(f);
-
- try {
- byte[] b= new byte[stream.available()];
- stream.read(b);
- stream.close();
- return b;
- }
- catch (IOException e) {
- throw new ClassNotFoundException();
- }
- }
- catch (FileNotFoundException e) {
- throw new ClassNotFoundException();
- }
- }
- /**
- * Locate the given file.
- * @return Returns null if file couldn't be found.
- */
- private File locate(String fileName) {
- fileName= fileName.replace('.', '/')+".class";
- File path= null;
-
- if (fileName != null) {
- for (int i= 0; i < fPathItems.length; i++) {
- path= new File(fPathItems[i], fileName);
- if (path.exists())
- return path;
- }
- }
- return null;
- }
-}
-
-public void loadAndRun(String className) throws Throwable {
- //System.out.println("Loading " + className + "...");
- Class testClass = new VerifyClassLoader().loadClass(className);
- //System.out.println("Loaded " + className);
- try {
- Method main = testClass.getMethod("main", new Class[] {String[].class});
- //System.out.println("Running " + className);
- main.invoke(null, new Object[] {new String[] {}});
- //System.out.println("Finished running " + className);
- } catch (NoSuchMethodException e) {
- return;
- } catch (InvocationTargetException e) {
- throw e.getTargetException();
- }
-}
-public static void main(String[] args) throws IOException {
- VerifyTests verify = new VerifyTests();
- verify.portNumber = Integer.parseInt(args[0]);
- verify.run();
-}
-public void run() throws IOException {
- ServerSocket server = new ServerSocket(this.portNumber);
- this.socket = server.accept();
- this.socket.setTcpNoDelay(true);
- server.close();
-
- DataInputStream in = new DataInputStream(this.socket.getInputStream());
- final DataOutputStream out = new DataOutputStream(this.socket.getOutputStream());
- while (true) {
- final String className = in.readUTF();
- Thread thread = new Thread() {
- public void run() {
- try {
- loadAndRun(className);
- out.writeBoolean(true);
- System.err.println(VerifyTests.class.getName());
- System.out.println(VerifyTests.class.getName());
- } catch (Throwable e) {
- e.printStackTrace();
- try {
- System.err.println(VerifyTests.class.getName());
- System.out.println(VerifyTests.class.getName());
- out.writeBoolean(false);
- } catch (IOException e1) {
- }
- }
- }
- };
- thread.start();
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.compiler/test.xml b/org.eclipse.jdt.core.tests.compiler/test.xml
deleted file mode 100644
index 862e2d4..0000000
--- a/org.eclipse.jdt.core.tests.compiler/test.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0"?>
-
-<project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <property name="eclipse-home" value="${basedir}\..\.."/>
-
- <!-- sets the properties eclipse-home, and library-file -->
- <property name="plugin-name" value="org.eclipse.jdt.core.tests.compiler"/>
- <property name="library-file"
- value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/>
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- <delete>
- <fileset dir="${eclipse-home}" includes="org*.xml"/>
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <!-- Parser tests -->
- <property name="jdt-parser-folder"
- value="${eclipse-home}/jdt_parser_folder"/>
- <delete dir="${jdt-parser-folder}" quiet="true"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${jdt-parser-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.jdt.core.tests.compiler.parser.TestAll"/>
- </ant>
-
- <!-- Compiler regression tests -->
- <property name="jdt-compiler-folder"
- value="${eclipse-home}/jdt_compiler_folder"/>
- <delete dir="${jdt-compiler-folder}" quiet="true"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${jdt-compiler-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.jdt.core.tests.compiler.regression.TestAll"/>
- </ant>
-
- <!-- Evaluation tests -->
- <property name="jdt-eval-folder"
- value="${eclipse-home}/jdt_eval_folder"/>
- <delete dir="${jdt-eval-folder}" quiet="true"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${jdt-eval-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.jdt.core.tests.eval.TestAll"/>
- </ant>
-
- </target>
-
- <!-- This target holds code to cleanup the testing environment after -->
- <!-- after all of the tests have been run. You can use this target to -->
- <!-- delete temporary files that have been created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen -->
- <!-- after all the tests have been run should go here. -->
- <target name="run" depends="init,suite,cleanup">
- <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
- <property name="includes" value="org*.xml"/>
- <property name="output-file" value="${plugin-name}.xml"/>
- </ant>
- </target>
-
-</project>
diff --git a/org.eclipse.jdt.core.tests.model/.classpath b/org.eclipse.jdt.core.tests.model/.classpath
deleted file mode 100644
index 1121e11..0000000
--- a/org.eclipse.jdt.core.tests.model/.classpath
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="/org.eclipse.core.resources"/>
- <classpathentry kind="src" path="/org.eclipse.jdt.debug"/>
- <classpathentry kind="src" path="/org.eclipse.jdt.core"/>
- <classpathentry kind="src" path="/org.junit"/>
- <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
- <classpathentry kind="src" path="/org.eclipse.core.boot"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jdt.core.tests.model/.cvsignore b/org.eclipse.jdt.core.tests.model/.cvsignore
deleted file mode 100644
index c5e82d7..0000000
--- a/org.eclipse.jdt.core.tests.model/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/.project b/org.eclipse.jdt.core.tests.model/.project
deleted file mode 100644
index b3cafba..0000000
--- a/org.eclipse.jdt.core.tests.model/.project
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.core.tests</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.core.boot</project>
- <project>org.eclipse.core.resources</project>
- <project>org.eclipse.core.runtime</project>
- <project>org.eclipse.jdt.core</project>
- <project>org.eclipse.jdt.debug</project>
- <project>org.junit</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.jdt.core.tests.model/JCL/converterJclMin.jar b/org.eclipse.jdt.core.tests.model/JCL/converterJclMin.jar
deleted file mode 100644
index 8c7f786..0000000
--- a/org.eclipse.jdt.core.tests.model/JCL/converterJclMin.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/JCL/converterJclMinsrc.zip b/org.eclipse.jdt.core.tests.model/JCL/converterJclMinsrc.zip
deleted file mode 100644
index 10bd6fb..0000000
--- a/org.eclipse.jdt.core.tests.model/JCL/converterJclMinsrc.zip
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/JCL/jclMin.jar b/org.eclipse.jdt.core.tests.model/JCL/jclMin.jar
deleted file mode 100644
index 3907379..0000000
--- a/org.eclipse.jdt.core.tests.model/JCL/jclMin.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/JCL/jclMinsrc.zip b/org.eclipse.jdt.core.tests.model/JCL/jclMinsrc.zip
deleted file mode 100644
index 7c3809c..0000000
--- a/org.eclipse.jdt.core.tests.model/JCL/jclMinsrc.zip
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/about.html b/org.eclipse.jdt.core.tests.model/about.html
deleted file mode 100644
index f43b493..0000000
--- a/org.eclipse.jdt.core.tests.model/about.html
+++ /dev/null
@@ -1,44 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>20th June, 2002</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
-For purposes of the CPL, "Program" will mean the Content.</p>
-
-<h3>Third Party Content</h3>
-
-<p>The Content includes items that may be have been sourced from third parties as follows:</p>
-
-<p><b>JUnit 3.7</b></p>
-<p>The plug-in is based on software developed by JUnit.org. Your use of JUnit 3.7 in both source and binary code
-form contained in the plug-in is subject to the terms and conditions of the IBM Public License 1.0 which is available at
-<a href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</a>.
-The source code is located in workspace/Converter/junit.</p>
-
-<p>i) IBM effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;</p>
-<p>ii) IBM effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;</p>
-<p>iii) IBM states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.</p>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/build.properties b/org.eclipse.jdt.core.tests.model/build.properties
deleted file mode 100644
index 12de704..0000000
--- a/org.eclipse.jdt.core.tests.model/build.properties
+++ /dev/null
@@ -1 +0,0 @@
-source.jdtcoretestsmodel.jar = src
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/plugin.xml b/org.eclipse.jdt.core.tests.model/plugin.xml
deleted file mode 100644
index 27d03bd..0000000
--- a/org.eclipse.jdt.core.tests.model/plugin.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<plugin
- id="org.eclipse.jdt.core.tests.model"
- name="Java Model Tests"
- version="2.1.0">
-
- <runtime>
- <library name="jdtcoretestsmodel.jar"/>
- </runtime>
- <requires>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.jdt.debug"/>
- <import plugin="org.eclipse.jdt.core"/>
- <import plugin="org.junit"/>
- </requires>
-
-
-</plugin>
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java
deleted file mode 100644
index 3e7255f..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java
+++ /dev/null
@@ -1,10048 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial test suite for AST API
- ******************************************************************************/
-
-package org.eclipse.jdt.core.tests.dom;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.Enumeration;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTMatcher;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
-import org.eclipse.jdt.core.dom.ArrayCreation;
-import org.eclipse.jdt.core.dom.ArrayInitializer;
-import org.eclipse.jdt.core.dom.ArrayType;
-import org.eclipse.jdt.core.dom.Assignment;
-import org.eclipse.jdt.core.dom.Block;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
-import org.eclipse.jdt.core.dom.BooleanLiteral;
-import org.eclipse.jdt.core.dom.BreakStatement;
-import org.eclipse.jdt.core.dom.CastExpression;
-import org.eclipse.jdt.core.dom.CatchClause;
-import org.eclipse.jdt.core.dom.CharacterLiteral;
-import org.eclipse.jdt.core.dom.ClassInstanceCreation;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.ConditionalExpression;
-import org.eclipse.jdt.core.dom.ContinueStatement;
-import org.eclipse.jdt.core.dom.DoStatement;
-import org.eclipse.jdt.core.dom.EmptyStatement;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.ExpressionStatement;
-import org.eclipse.jdt.core.dom.FieldAccess;
-import org.eclipse.jdt.core.dom.FieldDeclaration;
-import org.eclipse.jdt.core.dom.ForStatement;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.IPackageBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jdt.core.dom.IfStatement;
-import org.eclipse.jdt.core.dom.ImportDeclaration;
-import org.eclipse.jdt.core.dom.InfixExpression;
-import org.eclipse.jdt.core.dom.Initializer;
-import org.eclipse.jdt.core.dom.InstanceofExpression;
-import org.eclipse.jdt.core.dom.Javadoc;
-import org.eclipse.jdt.core.dom.LabeledStatement;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.MethodInvocation;
-import org.eclipse.jdt.core.dom.Modifier;
-import org.eclipse.jdt.core.dom.Name;
-import org.eclipse.jdt.core.dom.NullLiteral;
-import org.eclipse.jdt.core.dom.NumberLiteral;
-import org.eclipse.jdt.core.dom.PackageDeclaration;
-import org.eclipse.jdt.core.dom.ParenthesizedExpression;
-import org.eclipse.jdt.core.dom.PostfixExpression;
-import org.eclipse.jdt.core.dom.PrefixExpression;
-import org.eclipse.jdt.core.dom.PrimitiveType;
-import org.eclipse.jdt.core.dom.QualifiedName;
-import org.eclipse.jdt.core.dom.ReturnStatement;
-import org.eclipse.jdt.core.dom.SimpleName;
-import org.eclipse.jdt.core.dom.SimpleType;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.Statement;
-import org.eclipse.jdt.core.dom.StringLiteral;
-import org.eclipse.jdt.core.dom.SuperConstructorInvocation;
-import org.eclipse.jdt.core.dom.SuperFieldAccess;
-import org.eclipse.jdt.core.dom.SuperMethodInvocation;
-import org.eclipse.jdt.core.dom.SwitchCase;
-import org.eclipse.jdt.core.dom.SwitchStatement;
-import org.eclipse.jdt.core.dom.SynchronizedStatement;
-import org.eclipse.jdt.core.dom.ThisExpression;
-import org.eclipse.jdt.core.dom.ThrowStatement;
-import org.eclipse.jdt.core.dom.TryStatement;
-import org.eclipse.jdt.core.dom.Type;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
-import org.eclipse.jdt.core.dom.TypeDeclarationStatement;
-import org.eclipse.jdt.core.dom.TypeLiteral;
-import org.eclipse.jdt.core.dom.VariableDeclarationExpression;
-import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
-import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
-import org.eclipse.jdt.core.dom.WhileStatement;
-import org.eclipse.jdt.core.jdom.DOMFactory;
-import org.eclipse.jdt.core.jdom.IDOMCompilationUnit;
-import org.eclipse.jdt.core.jdom.IDOMMethod;
-import org.eclipse.jdt.core.jdom.IDOMNode;
-import org.eclipse.jdt.core.jdom.IDOMType;
-import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests;
-import org.eclipse.jdt.core.util.IModifierConstants;
-
-public class ASTConverterTest extends AbstractJavaModelTests {
-
- AST ast;
-
- public ASTConverterTest(String name) {
- super(name);
- }
-
- /**
- * Create project and set the jar placeholder.
- */
- public void setUpSuite() throws Exception {
- super.setUpSuite();
- setupConverterJCL();
- ast = new AST();
- setUpJavaProject("Converter");
- // ensure variables are set
- if (JavaCore.getClasspathVariable("ConverterJCL_LIB") == null) {
- JavaCore.setClasspathVariables(
- new String[] {"CONVERTER_JCL_LIB", "CONVERTER_JCL_SRC", "CONVERTER_JCL_SRCROOT"},
- new Path[] {new Path(getConverterJCLPath()), new Path(getConverterJCLSourcePath()), new Path(getConverterJCLRootSourcePath())},
- null);
- }
- }
-
-
-
- /**
- * Check locally for the required JCL files, jclMin.jar and jclMinsrc.zip.
- * If not available, copy from the project resources.
- */
- public void setupConverterJCL() throws IOException {
- String separator = java.io.File.separator;
- String resourceJCLDir = getPluginDirectoryPath() + separator + "JCL";
- String localJCLPath =getWorkspaceRoot().getLocation().toFile().getParentFile().getCanonicalPath();
- EXTERNAL_JAR_DIR_PATH = localJCLPath;
- java.io.File jclDir = new java.io.File(localJCLPath);
- java.io.File jclMin =
- new java.io.File(localJCLPath + separator + "converterJclMin.jar");
- java.io.File jclMinsrc = new java.io.File(localJCLPath + separator + "converterJclMinsrc.zip");
- if (!jclDir.exists()) {
- if (!jclDir.mkdir()) {
- //mkdir failed
- throw new IOException("Could not create the directory " + jclDir);
- } else {
- //copy the two files to the JCL directory
- java.io.File resourceJCLMin =
- new java.io.File(resourceJCLDir + separator + "converterJclMin.jar");
- copy(resourceJCLMin, jclMin);
- java.io.File resourceJCLMinsrc =
- new java.io.File(resourceJCLDir + separator + "converterJclMinsrc.zip");
- copy(resourceJCLMinsrc, jclMinsrc);
- }
- } else {
- //check that the two files, jclMin.jar and jclMinsrc.zip are present
- //copy either file that is missing
- if (!jclMin.exists()) {
- java.io.File resourceJCLMin =
- new java.io.File(resourceJCLDir + separator + "converterJclMin.jar");
- copy(resourceJCLMin, jclMin);
- }
- if (!jclMinsrc.exists()) {
- java.io.File resourceJCLMinsrc =
- new java.io.File(resourceJCLDir + separator + "converterJclMinsrc.zip");
- copy(resourceJCLMinsrc, jclMinsrc);
- }
- }
- }
-
- protected static String getConverterJCLPath() {
- return EXTERNAL_JAR_DIR_PATH + File.separator + "converterJclMin.jar";
- }
-
- protected static String getConverterJCLSourcePath() {
- return EXTERNAL_JAR_DIR_PATH + File.separator + "converterJclMinsrc.zip";
- }
-
- protected static String getConverterJCLRootSourcePath() {
- return "";
- }
-
- /**
- * Reset the jar placeholder and delete project.
- */
- public void tearDownSuite() throws Exception {
- ast = null;
- this.deleteProject("Converter");
-
- super.tearDown();
- }
-
- public static Test suite() {
- TestSuite suite = new Suite(ASTConverterTest.class.getName());
-
- Class c = ASTConverterTest.class;
- Method[] methods = c.getMethods();
- for (int i = 0, max = methods.length; i < max; i++) {
- if (methods[i].getName().startsWith("test")) {
- suite.addTest(new ASTConverterTest(methods[i].getName()));
- }
- }
-// suite.addTest(new ASTConverterTest("test0402"));
- return suite;
- }
-
- public ASTNode runConversion(ICompilationUnit unit, boolean resolveBindings) {
- return AST.parseCompilationUnit(unit, resolveBindings);
- }
-
- public ASTNode runConversion(char[] source, String unitName, IJavaProject project) {
- return AST.parseCompilationUnit(source, unitName, project);
- }
-
- public void test0001() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0001", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
-
- // check that we have the right tree
- CompilationUnit unit = this.ast.newCompilationUnit();
- PackageDeclaration packageDeclaration = this.ast.newPackageDeclaration();
- packageDeclaration.setName(this.ast.newSimpleName("test0001"));//$NON-NLS-1$
- unit.setPackage(packageDeclaration);
- ImportDeclaration importDeclaration = this.ast.newImportDeclaration();
- QualifiedName name =
- this.ast.newQualifiedName(
- this.ast.newSimpleName("java"),//$NON-NLS-1$
- this.ast.newSimpleName("util"));//$NON-NLS-1$
- importDeclaration.setName(name);
- importDeclaration.setOnDemand(true);
- unit.imports().add(importDeclaration);
- TypeDeclaration type = this.ast.newTypeDeclaration();
- type.setInterface(false);
- type.setModifiers(Modifier.PUBLIC);
- type.setName(this.ast.newSimpleName("Test"));//$NON-NLS-1$
- MethodDeclaration methodDeclaration = this.ast.newMethodDeclaration();
- methodDeclaration.setConstructor(false);
- methodDeclaration.setModifiers(Modifier.PUBLIC | Modifier.STATIC);
- methodDeclaration.setName(this.ast.newSimpleName("main"));//$NON-NLS-1$
- methodDeclaration.setReturnType(this.ast.newPrimitiveType(PrimitiveType.VOID));
- SingleVariableDeclaration variableDeclaration = this.ast.newSingleVariableDeclaration();
- variableDeclaration.setModifiers(Modifier.NONE);
- variableDeclaration.setType(this.ast.newArrayType(this.ast.newSimpleType(this.ast.newSimpleName("String"))));//$NON-NLS-1$
- variableDeclaration.setName(this.ast.newSimpleName("args"));//$NON-NLS-1$
- methodDeclaration.parameters().add(variableDeclaration);
- org.eclipse.jdt.core.dom.Block block = this.ast.newBlock();
- MethodInvocation methodInvocation = this.ast.newMethodInvocation();
- name =
- this.ast.newQualifiedName(
- this.ast.newSimpleName("System"),//$NON-NLS-1$
- this.ast.newSimpleName("out"));//$NON-NLS-1$
- methodInvocation.setExpression(name);
- methodInvocation.setName(this.ast.newSimpleName("println")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setOperator(InfixExpression.Operator.PLUS);
- StringLiteral literal = this.ast.newStringLiteral();
- literal.setLiteralValue("Hello");//$NON-NLS-1$
- infixExpression.setLeftOperand(literal);
- literal = this.ast.newStringLiteral();
- literal.setLiteralValue(" world");//$NON-NLS-1$
- infixExpression.setRightOperand(literal);//$NON-NLS-1$
- methodInvocation.arguments().add(infixExpression);
- ExpressionStatement expressionStatement = this.ast.newExpressionStatement(methodInvocation);
- block.statements().add(expressionStatement);
- methodDeclaration.setBody(block);
- type.bodyDeclarations().add(methodDeclaration);
- unit.types().add(type);
- assertTrue("Both AST trees should be identical", result.subtreeMatch(new ASTMatcher(), unit));//$NON-NLS-1$
- checkSourceRange(result, new String(source), source);
- }
-
- /**
- * Test allocation expression: new Object() ==> ClassInstanceCreation
- */
- public void test0002() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0002", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- ClassInstanceCreation classInstanceCreation = this.ast.newClassInstanceCreation();
- classInstanceCreation.setName(this.ast.newSimpleName("Object")); //$NON-NLS-1$
- assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "new Object()", source); //$NON-NLS-1$
- }
-
- /**
- * Test allocation expression: new java.lang.Object() ==> ClassInstanceCreation
- */
- public void test0003() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0003", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- ClassInstanceCreation classInstanceCreation = this.ast.newClassInstanceCreation();
- QualifiedName name =
- this.ast.newQualifiedName(
- this.ast.newQualifiedName(
- this.ast.newSimpleName("java"), //$NON-NLS-1$
- this.ast.newSimpleName("lang")), //$NON-NLS-1$
- this.ast.newSimpleName("Object"));//$NON-NLS-1$
- classInstanceCreation.setName(name);
- assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "new java.lang.Object()", source); //$NON-NLS-1$
- }
-
- /**
- * Test allocation expression: new java.lang.Exception("ERROR") ==> ClassInstanceCreation
- */
- public void test0004() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0004", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- ClassInstanceCreation classInstanceCreation = this.ast.newClassInstanceCreation();
- QualifiedName name =
- this.ast.newQualifiedName(
- this.ast.newQualifiedName(
- this.ast.newSimpleName("java"), //$NON-NLS-1$
- this.ast.newSimpleName("lang")), //$NON-NLS-1$
- this.ast.newSimpleName("Exception"));//$NON-NLS-1$
- classInstanceCreation.setName(name);
- StringLiteral literal = this.ast.newStringLiteral();
- literal.setLiteralValue("ERROR");
- classInstanceCreation.arguments().add(literal);
- assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "new java.lang.Exception(\"ERROR\")", source); //$NON-NLS-1$
- }
-
- /**
- * Test allocation expression: new java.lang.Object() {} ==> ClassInstanceCreation
- */
- public void test0005() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0005", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- ClassInstanceCreation classInstanceCreation = this.ast.newClassInstanceCreation();
- QualifiedName name =
- this.ast.newQualifiedName(
- this.ast.newQualifiedName(
- this.ast.newSimpleName("java"), //$NON-NLS-1$
- this.ast.newSimpleName("lang")), //$NON-NLS-1$
- this.ast.newSimpleName("Object"));//$NON-NLS-1$
- classInstanceCreation.setName(name);
- AnonymousClassDeclaration anonymousClassDeclaration = this.ast.newAnonymousClassDeclaration();
- classInstanceCreation.setAnonymousClassDeclaration(anonymousClassDeclaration);
- assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "new java.lang.Object() {}", source); //$NON-NLS-1$
- ClassInstanceCreation classInstanceCreation2 = (ClassInstanceCreation) expression;
- Name name2 = classInstanceCreation2.getName();
- checkSourceRange(name2, "java.lang.Object", source);
- }
-
-
- /**
- * Test allocation expression: new java.lang.Runnable() { public void run() {}} ==> ClassInstanceCreation
- */
- public void test0006() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0006", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- ClassInstanceCreation classInstanceCreation = this.ast.newClassInstanceCreation();
- QualifiedName name =
- this.ast.newQualifiedName(
- this.ast.newQualifiedName(
- this.ast.newSimpleName("java"), //$NON-NLS-1$
- this.ast.newSimpleName("lang")), //$NON-NLS-1$
- this.ast.newSimpleName("Runnable"));//$NON-NLS-1$
- classInstanceCreation.setName(name);
- MethodDeclaration methodDeclaration = this.ast.newMethodDeclaration();
- methodDeclaration.setBody(this.ast.newBlock());
- methodDeclaration.setConstructor(false);
- methodDeclaration.setModifiers(Modifier.PUBLIC);
- methodDeclaration.setName(this.ast.newSimpleName("run"));//$NON-NLS-1$
- methodDeclaration.setReturnType(this.ast.newPrimitiveType(PrimitiveType.VOID));
- AnonymousClassDeclaration anonymousClassDeclaration = this.ast.newAnonymousClassDeclaration();
- anonymousClassDeclaration.bodyDeclarations().add(methodDeclaration);
- classInstanceCreation.setAnonymousClassDeclaration(anonymousClassDeclaration);
- assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "new java.lang.Runnable() { public void run() {}}", source); //$NON-NLS-1$
- }
-
- /**
- * Test allocation expression: new Test().new D() ==> ClassInstanceCreation
- */
- public void test0007() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0007", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- ASTNode expression = (ASTNode) ((MethodInvocation) expressionStatement.getExpression()).arguments().get(0);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- ClassInstanceCreation classInstanceCreation = this.ast.newClassInstanceCreation();
- classInstanceCreation.setName(this.ast.newSimpleName("D")); //$NON-NLS-1$
- ClassInstanceCreation classInstanceCreationExpression = this.ast.newClassInstanceCreation();
- classInstanceCreationExpression.setName(this.ast.newSimpleName("Test")); //$NON-NLS-1$
- classInstanceCreation.setExpression(classInstanceCreationExpression);
- assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "new Test().new D()", source); //$NON-NLS-1$
- }
-
- /**
- * Test allocation expression: new int[] {1, 2, 3, 4} ==> ArrayCreation
- */
- public void test0008() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0008", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- ArrayCreation arrayCreation = this.ast.newArrayCreation();
- arrayCreation.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 1));
- ArrayInitializer arrayInitializer = this.ast.newArrayInitializer();
- arrayInitializer.expressions().add(this.ast.newNumberLiteral("1"));//$NON-NLS-1$
- arrayInitializer.expressions().add(this.ast.newNumberLiteral("2"));//$NON-NLS-1$
- arrayInitializer.expressions().add(this.ast.newNumberLiteral("3"));//$NON-NLS-1$
- arrayInitializer.expressions().add(this.ast.newNumberLiteral("4"));//$NON-NLS-1$
- arrayCreation.setInitializer(arrayInitializer);
- assertTrue("Both AST trees should be identical", arrayCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "new int[] {1, 2, 3, 4}", source); //$NON-NLS-1$
- }
-
- /**
- * Test allocation expression: new int[][] {{1}, {2}} ==> ArrayCreation
- */
- public void test0009() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0009", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- ArrayCreation arrayCreation = this.ast.newArrayCreation();
- arrayCreation.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 2));
- ArrayInitializer arrayInitializer = this.ast.newArrayInitializer();
- ArrayInitializer innerArrayInitializer = this.ast.newArrayInitializer();
- innerArrayInitializer.expressions().add(this.ast.newNumberLiteral("1"));//$NON-NLS-1$
- arrayInitializer.expressions().add(innerArrayInitializer);
- innerArrayInitializer = this.ast.newArrayInitializer();
- innerArrayInitializer.expressions().add(this.ast.newNumberLiteral("2"));//$NON-NLS-1$
- arrayInitializer.expressions().add(innerArrayInitializer);
- arrayCreation.setInitializer(arrayInitializer);
- assertTrue("Both AST trees should be identical", arrayCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "new int[][] {{1}, {2}}", source); //$NON-NLS-1$
- }
-
- /**
- * Test allocation expression: new int[3] ==> ArrayCreation
- */
- public void test0010() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0010", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- ArrayCreation arrayCreation = this.ast.newArrayCreation();
- arrayCreation.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 1));
- arrayCreation.dimensions().add(this.ast.newNumberLiteral("3")); //$NON-NLS-1$
- assertTrue("Both AST trees should be identical", arrayCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "new int[3]", source); //$NON-NLS-1$
- }
-
- /**
- * Test allocation expression: new int[3][] ==> ArrayCreation
- */
- public void test0011() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0011", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- ArrayCreation arrayCreation = this.ast.newArrayCreation();
- arrayCreation.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 2));
- arrayCreation.dimensions().add(this.ast.newNumberLiteral("3")); //$NON-NLS-1$
- assertTrue("Both AST trees should be identical", arrayCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "new int[3][]", source); //$NON-NLS-1$
- }
-
- /**
- * Test allocation expression: new int[][] {{},{}} ==> ArrayCreation
- */
- public void test0012() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0012", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- ArrayCreation arrayCreation = this.ast.newArrayCreation();
- arrayCreation.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 2));
- ArrayInitializer arrayInitializer = this.ast.newArrayInitializer();
- ArrayInitializer innerArrayInitializer = this.ast.newArrayInitializer();
- arrayInitializer.expressions().add(innerArrayInitializer);
- innerArrayInitializer = this.ast.newArrayInitializer();
- arrayInitializer.expressions().add(innerArrayInitializer);
- arrayCreation.setInitializer(arrayInitializer);
- assertTrue("Both AST trees should be identical", arrayCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "new int[][] {{}, {}}", source); //$NON-NLS-1$
- }
-
- /**
- * int i; ==> VariableDeclarationFragment
- */
- public void test0013() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0013", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int i;", source); //$NON-NLS-1$
- }
-
- /**
- * int i = 0; ==> VariableDeclarationFragment
- */
- public void test0014() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0014", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
- variableDeclarationFragment.setInitializer(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int i = 0;", source); //$NON-NLS-1$
- }
-
- /**
- * i = 1; ==> ExpressionStatement(Assignment)
- */
- public void test0015() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0015", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Assignment assignment = this.ast.newAssignment();
- assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
- assignment.setRightHandSide(this.ast.newNumberLiteral("1")); //$NON-NLS-1$
- assignment.setOperator(Assignment.Operator.ASSIGN);
- ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "i = 1;", source); //$NON-NLS-1$
- }
-
- /**
- * i += 2; ==> ExpressionStatement(Assignment)
- */
- public void test0016() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0016", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Assignment assignment = this.ast.newAssignment();
- assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
- assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
- assignment.setOperator(Assignment.Operator.PLUS_ASSIGN);
- ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "i += 2;", source); //$NON-NLS-1$
- }
-
- /**
- * i -= 2; ==> ExpressionStatement(Assignment)
- */
- public void test0017() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0017", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Assignment assignment = this.ast.newAssignment();
- assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
- assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
- assignment.setOperator(Assignment.Operator.MINUS_ASSIGN);
- ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "i -= 2;", source); //$NON-NLS-1$
- }
-
- /**
- * i *= 2; ==> ExpressionStatement(Assignment)
- */
- public void test0018() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0018", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Assignment assignment = this.ast.newAssignment();
- assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
- assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
- assignment.setOperator(Assignment.Operator.TIMES_ASSIGN);
- ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "i *= 2;", source); //$NON-NLS-1$
- }
-
- /**
- * i /= 2; ==> ExpressionStatement(Assignment)
- */
- public void test0019() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0019", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Assignment assignment = this.ast.newAssignment();
- assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
- assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
- assignment.setOperator(Assignment.Operator.DIVIDE_ASSIGN);
- ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "i /= 2;", source); //$NON-NLS-1$
- }
-
- /**
- * i &= 2 ==> ExpressionStatement(Assignment)
- */
- public void test0020() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0020", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Assignment assignment = this.ast.newAssignment();
- assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
- assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
- assignment.setOperator(Assignment.Operator.BIT_AND_ASSIGN);
- ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "i &= 2;", source); //$NON-NLS-1$
- }
-
- /**
- * i |= 2; ==> ExpressionStatement(Assignment)
- */
- public void test0021() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0021", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Assignment assignment = this.ast.newAssignment();
- assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
- assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
- assignment.setOperator(Assignment.Operator.BIT_OR_ASSIGN);
- ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "i |= 2;", source); //$NON-NLS-1$
- }
-
- /**
- * i ^= 2; ==> ExpressionStatement(Assignment)
- */
- public void test0022() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0022", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Assignment assignment = this.ast.newAssignment();
- assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
- assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
- assignment.setOperator(Assignment.Operator.BIT_XOR_ASSIGN);
- ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "i ^= 2;", source); //$NON-NLS-1$
- }
-
- /**
- * i %= 2; ==> ExpressionStatement(Assignment)
- */
- public void test0023() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0023", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Assignment assignment = this.ast.newAssignment();
- assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
- assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
- assignment.setOperator(Assignment.Operator.REMAINDER_ASSIGN);
- ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "i %= 2;", source); //$NON-NLS-1$
- }
-
- /**
- * i <<= 2; ==> ExpressionStatement(Assignment)
- */
- public void test0024() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0024", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Assignment assignment = this.ast.newAssignment();
- assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
- assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
- assignment.setOperator(Assignment.Operator.LEFT_SHIFT_ASSIGN);
- ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "i <<= 2;", source); //$NON-NLS-1$
- }
-
- /**
- * i >>= 2; ==> ExpressionStatement(Assignment)
- */
- public void test0025() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0025", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Assignment assignment = this.ast.newAssignment();
- assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
- assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
- assignment.setOperator(Assignment.Operator.RIGHT_SHIFT_SIGNED_ASSIGN);
- ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "i >>= 2;", source); //$NON-NLS-1$
- }
-
- /**
- * i >>>= 2; ==> ExpressionStatement(Assignment)
- */
- public void test0026() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0026", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Assignment assignment = this.ast.newAssignment();
- assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
- assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
- assignment.setOperator(Assignment.Operator.RIGHT_SHIFT_UNSIGNED_ASSIGN);
- ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "i >>>= 2;", source); //$NON-NLS-1$
- }
-
- /**
- * --i; ==> ExpressionStatement(PrefixExpression)
- */
- public void test0027() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0027", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- PrefixExpression prefixExpression = this.ast.newPrefixExpression();
- prefixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
- prefixExpression.setOperator(PrefixExpression.Operator.DECREMENT);//$NON-NLS-1$
- ExpressionStatement statement = this.ast.newExpressionStatement(prefixExpression);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "--i;", source); //$NON-NLS-1$
- }
-
- /**
- * --i; ==> ExpressionStatement(PrefixExpression)
- */
- public void test0028() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0028", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- PrefixExpression prefixExpression = this.ast.newPrefixExpression();
- prefixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
- prefixExpression.setOperator(PrefixExpression.Operator.INCREMENT);//$NON-NLS-1$
- ExpressionStatement statement = this.ast.newExpressionStatement(prefixExpression);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "++i;", source); //$NON-NLS-1$
- }
-
- /**
- * i--; ==> ExpressionStatement(PostfixExpression)
- */
- public void test0029() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0029", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- PostfixExpression postfixExpression = this.ast.newPostfixExpression();
- postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
- postfixExpression.setOperator(PostfixExpression.Operator.DECREMENT);//$NON-NLS-1$
- ExpressionStatement statement = this.ast.newExpressionStatement(postfixExpression);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "i--;", source); //$NON-NLS-1$
- }
-
- /**
- * i++; ==> ExpressionStatement(PostfixExpression)
- */
- public void test0030() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0030", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- PostfixExpression postfixExpression = this.ast.newPostfixExpression();
- postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
- postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);//$NON-NLS-1$
- ExpressionStatement statement = this.ast.newExpressionStatement(postfixExpression);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "i++;", source); //$NON-NLS-1$
- }
-
- /**
- * (String) o; ==> ExpressionStatement(CastExpression)
- */
- public void test0031() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0031", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("s")); //$NON-NLS-1$
- CastExpression castExpression = this.ast.newCastExpression();
- castExpression.setExpression(this.ast.newSimpleName("o"));//$NON-NLS-1$
- castExpression.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
- variableDeclarationFragment.setInitializer(castExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "String s = (String) o;", source); //$NON-NLS-1$
- }
-
- /**
- * (int) d; ==> ExpressionStatement(CastExpression)
- */
- public void test0032() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0032", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
- CastExpression castExpression = this.ast.newCastExpression();
- castExpression.setExpression(this.ast.newSimpleName("d"));//$NON-NLS-1$
- castExpression.setType(this.ast.newPrimitiveType(PrimitiveType.INT));//$NON-NLS-1$
- variableDeclarationFragment.setInitializer(castExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));//$NON-NLS-1$
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int i = (int) d;", source); //$NON-NLS-1$
- }
-
- /**
- * (float) d; ==> ExpressionStatement(CastExpression)
- */
- public void test0033() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0033", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("f")); //$NON-NLS-1$
- CastExpression castExpression = this.ast.newCastExpression();
- castExpression.setExpression(this.ast.newSimpleName("d"));//$NON-NLS-1$
- castExpression.setType(this.ast.newPrimitiveType(PrimitiveType.FLOAT));//$NON-NLS-1$
- variableDeclarationFragment.setInitializer(castExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.FLOAT));//$NON-NLS-1$
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "float f = (float) d;", source); //$NON-NLS-1$
- }
-
- /**
- * (byte) d; ==> ExpressionStatement(CastExpression)
- */
- public void test0034() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0034", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("b")); //$NON-NLS-1$
- CastExpression castExpression = this.ast.newCastExpression();
- castExpression.setExpression(this.ast.newSimpleName("d"));//$NON-NLS-1$
- castExpression.setType(this.ast.newPrimitiveType(PrimitiveType.BYTE));//$NON-NLS-1$
- variableDeclarationFragment.setInitializer(castExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.BYTE));//$NON-NLS-1$
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "byte b = (byte) d;", source); //$NON-NLS-1$
- }
-
- /**
- * (short) d; ==> ExpressionStatement(CastExpression)
- */
- public void test0035() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0035", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("s")); //$NON-NLS-1$
- CastExpression castExpression = this.ast.newCastExpression();
- castExpression.setExpression(this.ast.newSimpleName("d"));//$NON-NLS-1$
- castExpression.setType(this.ast.newPrimitiveType(PrimitiveType.SHORT));//$NON-NLS-1$
- variableDeclarationFragment.setInitializer(castExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.SHORT));//$NON-NLS-1$
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "short s = (short) d;", source); //$NON-NLS-1$
- }
-
- /**
- * (long) d; ==> ExpressionStatement(CastExpression)
- */
- public void test0036() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0036", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("l")); //$NON-NLS-1$
- CastExpression castExpression = this.ast.newCastExpression();
- castExpression.setExpression(this.ast.newSimpleName("d"));//$NON-NLS-1$
- castExpression.setType(this.ast.newPrimitiveType(PrimitiveType.LONG));//$NON-NLS-1$
- variableDeclarationFragment.setInitializer(castExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.LONG));//$NON-NLS-1$
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "long l = (long) d;", source); //$NON-NLS-1$
- }
-
- /**
- * (char) i; ==> ExpressionStatement(CastExpression)
- */
- public void test0037() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0037", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("c")); //$NON-NLS-1$
- CastExpression castExpression = this.ast.newCastExpression();
- castExpression.setExpression(this.ast.newSimpleName("i"));//$NON-NLS-1$
- castExpression.setType(this.ast.newPrimitiveType(PrimitiveType.CHAR));//$NON-NLS-1$
- variableDeclarationFragment.setInitializer(castExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.CHAR));//$NON-NLS-1$
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "char c = (char) i;", source); //$NON-NLS-1$
- }
-
- /**
- * int.class; ==> ExpressionStatement(TypeLiteral)
- */
- public void test0038() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0038", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("c")); //$NON-NLS-1$
- TypeLiteral typeLiteral = this.ast.newTypeLiteral();
- typeLiteral.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
- variableDeclarationFragment.setInitializer(typeLiteral);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newSimpleType(this.ast.newSimpleName("Class")));//$NON-NLS-1$
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(((VariableDeclarationFragment)((VariableDeclarationStatement)node).fragments().get(0)).getInitializer(), "int.class", source); //$NON-NLS-1$
- }
-
- /**
- * void.class; ==> ExpressionStatement(TypeLiteral)
- */
- public void test0039() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0039", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("c")); //$NON-NLS-1$
- TypeLiteral typeLiteral = this.ast.newTypeLiteral();
- typeLiteral.setType(this.ast.newPrimitiveType(PrimitiveType.VOID));
- variableDeclarationFragment.setInitializer(typeLiteral);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newSimpleType(this.ast.newSimpleName("Class")));//$NON-NLS-1$
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(((VariableDeclarationFragment)((VariableDeclarationStatement)node).fragments().get(0)).getInitializer(), "void.class", source); //$NON-NLS-1$
- }
-
- /**
- * double.class; ==> ExpressionStatement(TypeLiteral)
- */
- public void test0040() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0040", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("c")); //$NON-NLS-1$
- TypeLiteral typeLiteral = this.ast.newTypeLiteral();
- typeLiteral.setType(this.ast.newPrimitiveType(PrimitiveType.DOUBLE));
- variableDeclarationFragment.setInitializer(typeLiteral);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newSimpleType(this.ast.newSimpleName("Class")));//$NON-NLS-1$
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(((VariableDeclarationFragment)((VariableDeclarationStatement)node).fragments().get(0)).getInitializer(), "double.class", source); //$NON-NLS-1$
- }
-
- /**
- * long.class; ==> ExpressionStatement(TypeLiteral)
- */
- public void test0041() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0041", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("c")); //$NON-NLS-1$
- TypeLiteral typeLiteral = this.ast.newTypeLiteral();
- typeLiteral.setType(this.ast.newPrimitiveType(PrimitiveType.LONG));
- variableDeclarationFragment.setInitializer(typeLiteral);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newSimpleType(this.ast.newSimpleName("Class")));//$NON-NLS-1$
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(((VariableDeclarationFragment)((VariableDeclarationStatement)node).fragments().get(0)).getInitializer(), "long.class", source); //$NON-NLS-1$
- }
-
- /**
- * false ==> BooleanLiteral
- */
- public void test0042() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0042", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- BooleanLiteral literal = this.ast.newBooleanLiteral(false);
- assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "false", source); //$NON-NLS-1$
- }
-
- /**
- * true ==> BooleanLiteral
- */
- public void test0043() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0043", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- BooleanLiteral literal = this.ast.newBooleanLiteral(true);
- assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "true", source); //$NON-NLS-1$
- }
-
- /**
- * null ==> NullLiteral
- */
- public void test0044() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0044", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- NullLiteral literal = this.ast.newNullLiteral();
- assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "null", source); //$NON-NLS-1$
- }
-
- /**
- * CharLiteral ==> CharacterLiteral
- */
- public void test0045() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0045", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- CharacterLiteral literal = this.ast.newCharacterLiteral();
- literal.setEscapedValue("'c'");
- assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "'c'", source); //$NON-NLS-1$
- }
-
- /**
- * DoubleLiteral ==> NumberLiteral
- */
- public void test0046() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0046", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- NumberLiteral literal = this.ast.newNumberLiteral("1.00001");//$NON-NLS-1$
- assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "1.00001", source); //$NON-NLS-1$
- }
-
- /**
- * FloatLiteral ==> NumberLiteral
- */
- public void test0047() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0047", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- NumberLiteral literal = this.ast.newNumberLiteral("1.00001f");//$NON-NLS-1$
- assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "1.00001f", source); //$NON-NLS-1$
- }
-
- /**
- * IntLiteral ==> NumberLiteral
- */
- public void test0048() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0048", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- NumberLiteral literal = this.ast.newNumberLiteral("30000");//$NON-NLS-1$
- assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "30000", source); //$NON-NLS-1$
- }
-
- /**
- * IntLiteralMinValue ==> NumberLiteral
- */
- public void test0049() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0049", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- NumberLiteral literal = this.ast.newNumberLiteral("-2147483648");//$NON-NLS-1$
- assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "-2147483648", source); //$NON-NLS-1$
- }
-
- /**
- * LongLiteral ==> NumberLiteral
- */
- public void test0050() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0050", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- NumberLiteral literal = this.ast.newNumberLiteral("2147483648L");//$NON-NLS-1$
- assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "2147483648L", source); //$NON-NLS-1$
- }
-
- /**
- * LongLiteral ==> NumberLiteral (negative value)
- */
- public void test0051() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0051", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- NumberLiteral literal = this.ast.newNumberLiteral("2147483648L");//$NON-NLS-1$
- PrefixExpression prefixExpression = this.ast.newPrefixExpression();
- prefixExpression.setOperand(literal);
- prefixExpression.setOperator(PrefixExpression.Operator.MINUS);
- assertTrue("Both AST trees should be identical", prefixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "-2147483648L", source); //$NON-NLS-1$
- }
-
- /**
- * LongLiteralMinValue ==> NumberLiteral
- */
- public void test0052() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0052", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- NumberLiteral literal = this.ast.newNumberLiteral("-9223372036854775808L");//$NON-NLS-1$
- assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "-9223372036854775808L", source); //$NON-NLS-1$
- }
-
- /**
- * ExtendedStringLiteral ==> StringLiteral
- */
- public void test0053() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0053", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- /*
- StringLiteral literal = this.ast.newStringLiteral();//$NON-NLS-1$
- literal.setLiteralValue("Hello World");*/
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setOperator(InfixExpression.Operator.PLUS);
- StringLiteral literal = this.ast.newStringLiteral();
- literal.setLiteralValue("Hello");//$NON-NLS-1$
- infixExpression.setLeftOperand(literal);
- literal = this.ast.newStringLiteral();
- literal.setLiteralValue(" World");//$NON-NLS-1$
- infixExpression.setRightOperand(literal);//$NON-NLS-1$
-
- assertTrue("Both AST trees should be identical", infixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "\"Hello\" + \" World\"", source); //$NON-NLS-1$
- }
-
- /**
- * AND_AND_Expression ==> InfixExpression
- */
- public void test0054() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0054", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("b3")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("b2")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_AND);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "boolean b3 = b && b2;", source); //$NON-NLS-1$
- }
-
- /**
- * OR_OR_Expression ==> InfixExpression
- */
- public void test0055() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0055", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("b3")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("b2")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_OR);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "boolean b3 = b || b2;", source); //$NON-NLS-1$
- }
-
- /**
- * EqualExpression ==> InfixExpression
- */
- public void test0056() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0056", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("b3")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("b2")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.EQUALS);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "boolean b3 = b == b2;", source); //$NON-NLS-1$
- }
-
- /**
- * BinaryExpression (+) ==> InfixExpression
- */
- public void test0057() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0057", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.PLUS);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int n = i + j;", source); //$NON-NLS-1$
- }
-
- /**
- * BinaryExpression (-) ==> InfixExpression
- */
- public void test0058() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0058", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.MINUS);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int n = i - j;", source); //$NON-NLS-1$
- }
-
- /**
- * BinaryExpression (*) ==> InfixExpression
- */
- public void test0059() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0059", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.TIMES);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int n = i * j;", source); //$NON-NLS-1$
- }
-
- /**
- * BinaryExpression (/) ==> InfixExpression
- */
- public void test0060() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0060", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.DIVIDE);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int n = i / j;", source); //$NON-NLS-1$
- }
-
- /**
- * BinaryExpression (%) ==> InfixExpression
- */
- public void test0061() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0061", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.REMAINDER);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int n = i % j;", source); //$NON-NLS-1$
- }
-
- /**
- * BinaryExpression (^) ==> InfixExpression
- */
- public void test0062() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0062", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.XOR);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int n = i ^ j;", source); //$NON-NLS-1$
- }
-
- /**
- * BinaryExpression (&) ==> InfixExpression
- */
- public void test0063() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0063", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.AND);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int n = i & j;", source); //$NON-NLS-1$
- }
-
- /**
- * BinaryExpression (|) ==> InfixExpression
- */
- public void test0064() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0064", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.OR);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int n = i | j;", source); //$NON-NLS-1$
- }
-
- /**
- * BinaryExpression (<) ==> InfixExpression
- */
- public void test0065() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0065", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("b2")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("b1")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.LESS);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "boolean b2 = b < b1;", source); //$NON-NLS-1$
- }
-
- /**
- * BinaryExpression (<=) ==> InfixExpression
- */
- public void test0066() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0066", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("b2")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("b1")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.LESS_EQUALS);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "boolean b2 = b <= b1;", source); //$NON-NLS-1$
- }
-
- /**
- * BinaryExpression (>) ==> InfixExpression
- */
- public void test0067() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0067", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("b2")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("b1")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.GREATER);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "boolean b2 = b > b1;", source); //$NON-NLS-1$
- }
-
- /**
- * BinaryExpression (>=) ==> InfixExpression
- */
- public void test0068() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0068", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("b2")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("b1")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.GREATER_EQUALS);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "boolean b2 = b >= b1;", source); //$NON-NLS-1$
- }
-
- /**
- * BinaryExpression (!=) ==> InfixExpression
- */
- public void test0069() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0069", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("b2")); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
- infixExpression.setRightOperand(this.ast.newSimpleName("b1")); //$NON-NLS-1$
- infixExpression.setOperator(InfixExpression.Operator.NOT_EQUALS);
- variableDeclarationFragment.setInitializer(infixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "boolean b2 = b != b1;", source); //$NON-NLS-1$
- }
-
- /**
- * InstanceofExpression ==> InfixExpression
- */
- public void test0070() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0070", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("b")); //$NON-NLS-1$
- InstanceofExpression instanceOfExpression = this.ast.newInstanceofExpression();
- instanceOfExpression.setLeftOperand(this.ast.newSimpleName("o"));//$NON-NLS-1$
- SimpleType simpleType = this.ast.newSimpleType(this.ast.newSimpleName("Integer"));//$NON-NLS-1$
- instanceOfExpression.setRightOperand(simpleType);
- variableDeclarationFragment.setInitializer(instanceOfExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "boolean b = o instanceof Integer;", source); //$NON-NLS-1$
- }
-
- /**
- * InstanceofExpression ==> InfixExpression
- */
- public void test0071() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0071", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("b")); //$NON-NLS-1$
- InstanceofExpression instanceOfExpression = this.ast.newInstanceofExpression();
- instanceOfExpression.setLeftOperand(this.ast.newSimpleName("o")); //$NON-NLS-1$
- QualifiedName name =
- this.ast.newQualifiedName(
- this.ast.newQualifiedName(
- this.ast.newSimpleName("java"), //$NON-NLS-1$
- this.ast.newSimpleName("lang")), //$NON-NLS-1$
- this.ast.newSimpleName("Integer")); //$NON-NLS-1$
- Type type = ast.newSimpleType(name);
- instanceOfExpression.setRightOperand(type);
- variableDeclarationFragment.setInitializer(instanceOfExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "boolean b = o instanceof java.lang.Integer;", source); //$NON-NLS-1$
- }
-
- /**
- * UnaryExpression (!) ==> PrefixExpression
- */
- public void test0072() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0072", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("b1")); //$NON-NLS-1$
- PrefixExpression prefixExpression = this.ast.newPrefixExpression();
- prefixExpression.setOperator(PrefixExpression.Operator.NOT);
- prefixExpression.setOperand(this.ast.newSimpleName("b"));//$NON-NLS-1$
- variableDeclarationFragment.setInitializer(prefixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "boolean b1 = !b;", source); //$NON-NLS-1$
- }
-
- /**
- * UnaryExpression (~) ==> PrefixExpression
- */
- public void test0073() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0073", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
- PrefixExpression prefixExpression = this.ast.newPrefixExpression();
- prefixExpression.setOperator(PrefixExpression.Operator.COMPLEMENT);
- prefixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
- variableDeclarationFragment.setInitializer(prefixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int n = ~i;", source); //$NON-NLS-1$
- }
-
- /**
- * UnaryExpression (+) ==> PrefixExpression
- */
- public void test0074() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0074", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
- PrefixExpression prefixExpression = this.ast.newPrefixExpression();
- prefixExpression.setOperator(PrefixExpression.Operator.PLUS);
- prefixExpression.setOperand(this.ast.newNumberLiteral("2"));//$NON-NLS-1$
- variableDeclarationFragment.setInitializer(prefixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int i = +2;", source); //$NON-NLS-1$
- }
-
- /**
- * UnaryExpression (-) ==> PrefixExpression
- */
- public void test0075() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0075", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
- PrefixExpression prefixExpression = this.ast.newPrefixExpression();
- prefixExpression.setOperator(PrefixExpression.Operator.MINUS);
- prefixExpression.setOperand(this.ast.newNumberLiteral("2"));//$NON-NLS-1$
- variableDeclarationFragment.setInitializer(prefixExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int i = -2;", source); //$NON-NLS-1$
- }
-
- /**
- * ConditionalExpression ==> ConditionalExpression
- */
- public void test0076() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0076", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("b")); //$NON-NLS-1$
- ConditionalExpression conditionalExpression = this.ast.newConditionalExpression();
- InfixExpression condition = this.ast.newInfixExpression();
- condition.setLeftOperand(this.ast.newSimpleName("args")); //$NON-NLS-1$
- condition.setRightOperand(this.ast.newNullLiteral()); //$NON-NLS-1$
- condition.setOperator(InfixExpression.Operator.NOT_EQUALS);
- conditionalExpression.setExpression(condition);
- conditionalExpression.setThenExpression(this.ast.newBooleanLiteral(true));
- conditionalExpression.setElseExpression(this.ast.newBooleanLiteral(false));
- variableDeclarationFragment.setInitializer(conditionalExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "boolean b = args != null ? true : false;", source); //$NON-NLS-1$
- }
-
- /**
- * ConditionalExpression ==> ConditionalExpression
- */
- public void test0077() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0077", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
- ConditionalExpression conditionalExpression = this.ast.newConditionalExpression();
- conditionalExpression.setExpression(this.ast.newBooleanLiteral(true));
- QualifiedName name =
- this.ast.newQualifiedName(
- this.ast.newSimpleName("args"), //$NON-NLS-1$
- this.ast.newSimpleName("length")); //$NON-NLS-1$
- conditionalExpression.setThenExpression(name);
- conditionalExpression.setElseExpression(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
- variableDeclarationFragment.setInitializer(conditionalExpression);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setModifiers(Modifier.NONE);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int i = true ? args.length: 0;", source); //$NON-NLS-1$
- }
-
- /**
- * MessageSend ==> SuperMethodInvocation
- */
- public void test0078() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0078", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- SuperMethodInvocation superMethodInvocation = this.ast.newSuperMethodInvocation();
- superMethodInvocation.setName(this.ast.newSimpleName("bar")); //$NON-NLS-1$
- ExpressionStatement statement = this.ast.newExpressionStatement(superMethodInvocation);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "super.bar();", source); //$NON-NLS-1$
- }
-
- /**
- * MessageSend ==> SuperMethodInvocation
- */
- public void test0079() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0079", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- SuperMethodInvocation superMethodInvocation = this.ast.newSuperMethodInvocation();
- superMethodInvocation.setName(this.ast.newSimpleName("bar")); //$NON-NLS-1$
- superMethodInvocation.arguments().add(this.ast.newNumberLiteral("4"));//$NON-NLS-1$
- ExpressionStatement statement = this.ast.newExpressionStatement(superMethodInvocation);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "super.bar(4);", source); //$NON-NLS-1$
- }
-
- /**
- * MessageSend ==> MethodInvocation
- */
- public void test0080() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0080", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- MethodInvocation methodInvocation = this.ast.newMethodInvocation();
- methodInvocation.setName(this.ast.newSimpleName("bar")); //$NON-NLS-1$
- methodInvocation.arguments().add(this.ast.newNumberLiteral("4"));//$NON-NLS-1$
- ExpressionStatement statement = this.ast.newExpressionStatement(methodInvocation);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "bar(4);", source); //$NON-NLS-1$
- }
-
- /**
- * MessageSend ==> MethodInvocation
- */
- public void test0081() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0081", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- MethodInvocation methodInvocation = this.ast.newMethodInvocation();
- methodInvocation.setName(this.ast.newSimpleName("bar")); //$NON-NLS-1$
- methodInvocation.setExpression(this.ast.newThisExpression());
- methodInvocation.arguments().add(this.ast.newNumberLiteral("4"));//$NON-NLS-1$
- ExpressionStatement statement = this.ast.newExpressionStatement(methodInvocation);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "this.bar(4);", source); //$NON-NLS-1$
- }
-
- /**
- * ForStatement ==> ForStatement
- */
- public void test0082() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0082", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ForStatement forStatement = this.ast.newForStatement();
- forStatement.setBody(this.ast.newEmptyStatement());
- assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "for (;;);", source); //$NON-NLS-1$
- }
-
- /**
- * ForStatement ==> ForStatement
- */
- public void test0083() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0083", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ForStatement forStatement = this.ast.newForStatement();
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
- variableDeclarationFragment.setInitializer(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
- VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
- variableDeclarationExpression.setModifiers(Modifier.NONE);
- variableDeclarationExpression.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
- forStatement.initializers().add(variableDeclarationExpression);
- PostfixExpression postfixExpression = this.ast.newPostfixExpression();
- postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
- postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
- forStatement.updaters().add(postfixExpression);
- forStatement.setBody(this.ast.newBlock());
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("i"));
- infixExpression.setOperator(InfixExpression.Operator.LESS);
- infixExpression.setRightOperand(this.ast.newNumberLiteral("10"));
- forStatement.setExpression(infixExpression);
- assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "for (int i = 0; i < 10; i++) {}", source); //$NON-NLS-1$
- }
-
- /**
- * ForStatement ==> ForStatement
- */
- public void test0084() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0084", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ForStatement forStatement = this.ast.newForStatement();
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
- variableDeclarationFragment.setInitializer(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
-
- VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
- variableDeclarationExpression.setModifiers(Modifier.NONE);
- variableDeclarationExpression.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
- forStatement.initializers().add(variableDeclarationExpression);
- PostfixExpression postfixExpression = this.ast.newPostfixExpression();
- postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
- postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
- forStatement.updaters().add(postfixExpression);
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("i"));
- infixExpression.setOperator(InfixExpression.Operator.LESS);
- infixExpression.setRightOperand(this.ast.newNumberLiteral("10"));
- forStatement.setExpression(infixExpression);
- forStatement.setBody(this.ast.newEmptyStatement());
- assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "for (int i = 0; i < 10; i++);", source); //$NON-NLS-1$
- }
-
- /**
- * ForStatement ==> ForStatement
- */
- public void test0085() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0085", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ForStatement forStatement = this.ast.newForStatement();
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
- variableDeclarationFragment.setInitializer(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
-
- VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
- variableDeclarationExpression.setModifiers(Modifier.NONE);
- variableDeclarationExpression.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
-
- forStatement.initializers().add(variableDeclarationExpression);
- PostfixExpression postfixExpression = this.ast.newPostfixExpression();
- postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
- postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
- forStatement.updaters().add(postfixExpression);
- forStatement.setBody(this.ast.newEmptyStatement());
- assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "for (int i = 0;; i++);", source); //$NON-NLS-1$
- }
-
- /**
- * ForStatement ==> ForStatement
- */
- public void test0086() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0086", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ForStatement forStatement = this.ast.newForStatement();
- PostfixExpression postfixExpression = this.ast.newPostfixExpression();
- postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
- postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
- forStatement.updaters().add(postfixExpression);
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("i"));
- infixExpression.setOperator(InfixExpression.Operator.LESS);
- infixExpression.setRightOperand(this.ast.newNumberLiteral("10"));
- forStatement.setExpression(infixExpression);
- forStatement.setBody(this.ast.newEmptyStatement());
- assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "for (; i < 10; i++);", source); //$NON-NLS-1$
- }
-
- /**
- * ForStatement ==> ForStatement
- */
- public void test0087() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0087", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ForStatement forStatement = this.ast.newForStatement();
- PostfixExpression postfixExpression = this.ast.newPostfixExpression();
- postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
- postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
- forStatement.updaters().add(postfixExpression);
- forStatement.setBody(this.ast.newEmptyStatement());
- assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "for (;;i++);", source); //$NON-NLS-1$
- }
-
- /**
- * LocalDeclaration ==> VariableDeclarationStatement
- */
- public void test0088() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0088", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
-
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
- statement.setModifiers(Modifier.NONE);
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int i;", source); //$NON-NLS-1$
- }
-
- /**
- * LocalDeclaration ==> VariableDeclarationStatement
- */
- public void test0089() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0089", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("s")); //$NON-NLS-1$
-
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- QualifiedName name =
- this.ast.newQualifiedName(
- this.ast.newQualifiedName(
- this.ast.newSimpleName("java"),//$NON-NLS-1$
- this.ast.newSimpleName("lang")//$NON-NLS-1$
- ),
- this.ast.newSimpleName("String") //$NON-NLS-1$
- );
- statement.setType(this.ast.newSimpleType(name));
- statement.setModifiers(Modifier.NONE);
-
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "java.lang.String s;", source); //$NON-NLS-1$
- }
-
- /**
- * LocalDeclaration ==> VariableDeclarationStatement
- */
- public void test0090() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0090", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
-
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- ArrayInitializer initializer = this.ast.newArrayInitializer();
- initializer.expressions().add(this.ast.newNumberLiteral("1"));//$NON-NLS-1$
- initializer.expressions().add(this.ast.newNumberLiteral("2"));//$NON-NLS-1$
- variableDeclarationFragment.setInitializer(initializer);
- variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
-
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
- statement.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 1));
- statement.setModifiers(Modifier.NONE);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int[] tab = {1, 2};", source); //$NON-NLS-1$
- }
-
- /**
- * Argument ==> SingleVariableDeclaration
- */
- public void test0091() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0091", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- MethodDeclaration method = (MethodDeclaration)((TypeDeclaration) ((CompilationUnit) result).types().get(0)).bodyDeclarations().get(0);
- SingleVariableDeclaration node = (SingleVariableDeclaration) method.parameters().get(0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- SingleVariableDeclaration variableDeclaration = this.ast.newSingleVariableDeclaration();
- variableDeclaration.setModifiers(Modifier.NONE);
- variableDeclaration.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
- variableDeclaration.setName(this.ast.newSimpleName("s")); //$NON-NLS-1$
- assertTrue("Both AST trees should be identical", variableDeclaration.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "String s", source); //$NON-NLS-1$
- }
-
- /**
- * Argument ==> SingleVariableDeclaration
- */
- public void test0092() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0092", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- MethodDeclaration method = (MethodDeclaration)((TypeDeclaration) ((CompilationUnit) result).types().get(0)).bodyDeclarations().get(0);
- SingleVariableDeclaration node = (SingleVariableDeclaration) method.parameters().get(0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- SingleVariableDeclaration variableDeclaration = this.ast.newSingleVariableDeclaration();
- variableDeclaration.setModifiers(Modifier.FINAL);
- variableDeclaration.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
- variableDeclaration.setName(this.ast.newSimpleName("s")); //$NON-NLS-1$
- assertTrue("Both AST trees should be identical", variableDeclaration.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "final String s", source); //$NON-NLS-1$
- assertEquals("Wrong dimension", 0, node.getExtraDimensions());
- }
-
- /**
- * Break ==> BreakStatement
- */
- public void test0093() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0093", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- ForStatement forStatement = (ForStatement) node;
- BreakStatement statement = (BreakStatement) ((Block) forStatement.getBody()).statements().get(0);
- assertNotNull("Expression should not be null", statement); //$NON-NLS-1$
- BreakStatement breakStatement = this.ast.newBreakStatement();
- assertTrue("Both AST trees should be identical", breakStatement.subtreeMatch(new ASTMatcher(), statement)); //$NON-NLS-1$
- checkSourceRange(statement, "break;", source); //$NON-NLS-1$
- }
-
- /**
- * Continue ==> ContinueStatement
- */
- public void test0094() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0094", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- ForStatement forStatement = (ForStatement) node;
- ContinueStatement statement = (ContinueStatement) ((Block) forStatement.getBody()).statements().get(0);
- assertNotNull("Expression should not be null", statement); //$NON-NLS-1$
- ContinueStatement continueStatement = this.ast.newContinueStatement();
- assertTrue("Both AST trees should be identical", continueStatement.subtreeMatch(new ASTMatcher(), statement)); //$NON-NLS-1$
- checkSourceRange(statement, "continue;", source); //$NON-NLS-1$
- }
-
- /**
- * Continue with Label ==> ContinueStatement
- */
- public void test0095() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0095", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- LabeledStatement labeledStatement = (LabeledStatement) getASTNode((CompilationUnit) result, 0, 0, 0);
- ForStatement forStatement = (ForStatement) labeledStatement.getBody();
- ContinueStatement statement = (ContinueStatement) ((Block) forStatement.getBody()).statements().get(0);
- assertNotNull("Expression should not be null", statement); //$NON-NLS-1$
- ContinueStatement continueStatement = this.ast.newContinueStatement();
- continueStatement.setLabel(this.ast.newSimpleName("label"));
- assertTrue("Both AST trees should be identical", continueStatement.subtreeMatch(new ASTMatcher(), statement)); //$NON-NLS-1$
- checkSourceRange(statement, "continue label;", source); //$NON-NLS-1$
- }
-
- /**
- * Break + label ==> BreakStatement
- */
- public void test0096() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0096", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- LabeledStatement labeledStatement = (LabeledStatement) getASTNode((CompilationUnit) result, 0, 0, 0);
- ForStatement forStatement = (ForStatement) labeledStatement.getBody();
- BreakStatement statement = (BreakStatement) ((Block) forStatement.getBody()).statements().get(0);
- assertNotNull("Expression should not be null", statement); //$NON-NLS-1$
- BreakStatement breakStatement = this.ast.newBreakStatement();
- breakStatement.setLabel(this.ast.newSimpleName("label")); //$NON-NLS-1$
- assertTrue("Both AST trees should be identical", breakStatement.subtreeMatch(new ASTMatcher(), statement)); //$NON-NLS-1$
- checkSourceRange(statement, "break label;", source); //$NON-NLS-1$
- }
-
- /**
- * SwitchStatement ==> SwitchStatement
- */
- public void test0097() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0097", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- SwitchStatement switchStatement = this.ast.newSwitchStatement();
- switchStatement.setExpression(this.ast.newSimpleName("i"));//$NON-NLS-1$
- SwitchCase _case = this.ast.newSwitchCase();
- _case.setExpression(this.ast.newNumberLiteral("1"));//$NON-NLS-1$
- switchStatement.statements().add(_case);
- switchStatement.statements().add(this.ast.newBreakStatement());
- _case = this.ast.newSwitchCase();
- _case.setExpression(this.ast.newNumberLiteral("2"));//$NON-NLS-1$
- switchStatement.statements().add(_case);
- MethodInvocation methodInvocation = this.ast.newMethodInvocation();
- QualifiedName name =
- this.ast.newQualifiedName(
- this.ast.newSimpleName("System"),//$NON-NLS-1$
- this.ast.newSimpleName("out"));//$NON-NLS-1$
- methodInvocation.setExpression(name);
- methodInvocation.setName(this.ast.newSimpleName("println")); //$NON-NLS-1$
- methodInvocation.arguments().add(this.ast.newNumberLiteral("2"));//$NON-NLS-1$
- ExpressionStatement expressionStatement = this.ast.newExpressionStatement(methodInvocation);
- switchStatement.statements().add(expressionStatement);
- switchStatement.statements().add(this.ast.newBreakStatement());
- _case = this.ast.newSwitchCase();
- _case.setExpression(null);
- switchStatement.statements().add(_case);
- methodInvocation = this.ast.newMethodInvocation();
- name =
- this.ast.newQualifiedName(
- this.ast.newSimpleName("System"),//$NON-NLS-1$
- this.ast.newSimpleName("out"));//$NON-NLS-1$
- methodInvocation.setExpression(name);
- methodInvocation.setName(this.ast.newSimpleName("println")); //$NON-NLS-1$
- StringLiteral literal = this.ast.newStringLiteral();
- literal.setLiteralValue("default"); //$NON-NLS-1$
- methodInvocation.arguments().add(literal);
- expressionStatement = this.ast.newExpressionStatement(methodInvocation);
- switchStatement.statements().add(expressionStatement);
- assertTrue("Both AST trees should be identical", switchStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- String expectedSource = "switch(i) {\r\n" +//$NON-NLS-1$
- " case 1: \r\n" +//$NON-NLS-1$
- " break;\r\n" +//$NON-NLS-1$
- " case 2:\r\n" +//$NON-NLS-1$
- " System.out.println(2);\r\n" +//$NON-NLS-1$
- " break;\r\n" +//$NON-NLS-1$
- " default:\r\n" +//$NON-NLS-1$
- " System.out.println(\"default\");\r\n" +//$NON-NLS-1$
- " }";
- checkSourceRange(node, expectedSource, source);
- SwitchStatement switchStatement2 = (SwitchStatement) node;
- List statements = switchStatement2.statements();
- assertEquals("wrong size", 7, statements.size());
- Statement stmt = (Statement) statements.get(5);
- assertTrue("Not a case statement", stmt instanceof SwitchCase);
- SwitchCase switchCase = (SwitchCase) stmt;
- assertTrue("Not the default case", switchCase.isDefault());
- }
-
- /**
- * EmptyStatement ==> EmptyStatement
- */
- public void test0098() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0098", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- EmptyStatement emptyStatement = this.ast.newEmptyStatement();
- assertTrue("Both AST trees should be identical", emptyStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, ";", source); //$NON-NLS-1$
- }
-
- /**
- * DoStatement ==> DoStatement
- */
- public void test0099() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0099", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- DoStatement doStatement = this.ast.newDoStatement();
- Block block = this.ast.newBlock();
- block.statements().add(this.ast.newEmptyStatement());
- doStatement.setBody(block);
- doStatement.setExpression(this.ast.newBooleanLiteral(true));
- assertTrue("Both AST trees should be identical", doStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- String expectedSource = "do {;\r\n" +//$NON-NLS-1$
- " } while(true);";//$NON-NLS-1$
- checkSourceRange(node, expectedSource, source);
- }
-
- /**
- * WhileStatement ==> WhileStatement
- */
- public void test0100() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0100", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- WhileStatement whileStatement = this.ast.newWhileStatement();
- whileStatement.setExpression(this.ast.newBooleanLiteral(true));
- whileStatement.setBody(this.ast.newEmptyStatement());
- assertTrue("Both AST trees should be identical", whileStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "while(true);", source);//$NON-NLS-1$
- }
-
- /**
- * WhileStatement ==> WhileStatement
- */
- public void test0101() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0101", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- WhileStatement whileStatement = this.ast.newWhileStatement();
- whileStatement.setExpression(this.ast.newBooleanLiteral(true));
- whileStatement.setBody(this.ast.newBlock());
- assertTrue("Both AST trees should be identical", whileStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "while(true) {}", source);//$NON-NLS-1$
- }
-
- /**
- * ExtendedStringLiteral ==> StringLiteral
- */
- public void test0102() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0102", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setOperator(InfixExpression.Operator.PLUS);
- StringLiteral literal = this.ast.newStringLiteral();//$NON-NLS-1$
- literal.setLiteralValue("Hello");
- infixExpression.setLeftOperand(literal);
- literal = this.ast.newStringLiteral();//$NON-NLS-1$
- literal.setLiteralValue(" World");
- infixExpression.setRightOperand(literal);
- literal = this.ast.newStringLiteral();//$NON-NLS-1$
- literal.setLiteralValue("!");
- infixExpression.extendedOperands().add(literal);
- assertTrue("Both AST trees should be identical", infixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "\"Hello\" + \" World\" + \"!\"", source);//$NON-NLS-1$
- }
-
- /**
- * ExtendedStringLiteral ==> StringLiteral
- */
- public void test0103() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0103", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setOperator(InfixExpression.Operator.PLUS);
- StringLiteral literal = this.ast.newStringLiteral();//$NON-NLS-1$
- literal.setLiteralValue("Hello");
- infixExpression.setLeftOperand(literal);
- literal = this.ast.newStringLiteral();//$NON-NLS-1$
- literal.setLiteralValue(" World");
- infixExpression.setRightOperand(literal);
- literal = this.ast.newStringLiteral();//$NON-NLS-1$
- literal.setLiteralValue("!");
- infixExpression.extendedOperands().add(literal);
- literal = this.ast.newStringLiteral();//$NON-NLS-1$
- literal.setLiteralValue("!");
- infixExpression.extendedOperands().add(literal);
- assertTrue("Both AST trees should be identical", infixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "\"Hello\" + \" World\" + \"!\" + \"!\"", source);//$NON-NLS-1$
- }
-
- /**
- * ExtendedStringLiteral ==> StringLiteral
- */
- public void test0104() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0104", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setOperator(InfixExpression.Operator.PLUS);
- StringLiteral literal = this.ast.newStringLiteral();//$NON-NLS-1$
- literal.setLiteralValue("Hello");
- infixExpression.setLeftOperand(literal);
- literal = this.ast.newStringLiteral();//$NON-NLS-1$
- literal.setLiteralValue(" World");
- infixExpression.setRightOperand(literal);
- literal = this.ast.newStringLiteral();//$NON-NLS-1$
- literal.setLiteralValue("!");
- infixExpression.extendedOperands().add(literal);
- NumberLiteral numberLiteral = this.ast.newNumberLiteral();//$NON-NLS-1$
- numberLiteral.setToken("4");
- infixExpression.extendedOperands().add(numberLiteral);
- assertTrue("Both AST trees should be identical", infixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "\"Hello\" + \" World\" + \"!\" + 4", source);//$NON-NLS-1$
- }
-
- /**
- * NumberLiteral ==> InfixExpression
- */
- public void test0105() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0105", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setOperator(InfixExpression.Operator.PLUS);
- NumberLiteral literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("4");
- infixExpression.setLeftOperand(literal);
- literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("5");
- infixExpression.setRightOperand(literal);
- literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("6");
- infixExpression.extendedOperands().add(literal);
- literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("4");
- infixExpression.extendedOperands().add(literal);
- assertTrue("Both AST trees should be identical", infixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "4 + 5 + 6 + 4", source);//$NON-NLS-1$
- }
-
- /**
- * NumberLiteral ==> InfixExpression
- */
- public void test0106() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0106", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setOperator(InfixExpression.Operator.MINUS);
- NumberLiteral literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("4");
- infixExpression.setLeftOperand(literal);
- literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("5");
- infixExpression.setRightOperand(literal);
-
- InfixExpression infixExpression2 = this.ast.newInfixExpression();
- infixExpression2.setOperator(InfixExpression.Operator.PLUS);
- infixExpression2.setLeftOperand(infixExpression);
- literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("6");
- infixExpression2.setRightOperand(literal);
-
- InfixExpression infixExpression3 = this.ast.newInfixExpression();
- infixExpression3.setOperator(InfixExpression.Operator.PLUS);
- infixExpression3.setLeftOperand(infixExpression2);
- literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("4");
- infixExpression3.setRightOperand(literal);
-
- assertTrue("Both AST trees should be identical", infixExpression3.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "4 - 5 + 6 + 4", source);//$NON-NLS-1$
- }
-
- /**
- * NumberLiteral ==> InfixExpression
- */
- public void test0107() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0107", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setOperator(InfixExpression.Operator.MINUS);
- NumberLiteral literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("4");
- infixExpression.setLeftOperand(literal);
- literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("5");
- infixExpression.setRightOperand(literal);
- literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("6");
- infixExpression.extendedOperands().add(literal);
- literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("4");
- infixExpression.extendedOperands().add(literal);
- assertTrue("Both AST trees should be identical", infixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "4 - 5 - 6 - 4", source);//$NON-NLS-1$
- }
-
- /**
- * NumberLiteral ==> InfixExpression
- */
- public void test0108() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0108", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setOperator(InfixExpression.Operator.PLUS);
- StringLiteral stringLiteral = this.ast.newStringLiteral();//$NON-NLS-1$
- stringLiteral.setLiteralValue("4");
- infixExpression.setLeftOperand(stringLiteral);
- NumberLiteral literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("5");
- infixExpression.setRightOperand(literal);
- literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("6");
- infixExpression.extendedOperands().add(literal);
- literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("4");
- infixExpression.extendedOperands().add(literal);
- assertTrue("Both AST trees should be identical", infixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "\"4\" + 5 + 6 + 4", source);//$NON-NLS-1$
- }
-
- /**
- * NumberLiteral ==> InfixExpression
- */
- public void test0109() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0109", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setOperator(InfixExpression.Operator.MINUS);
- StringLiteral stringLiteral = this.ast.newStringLiteral();//$NON-NLS-1$
- stringLiteral.setLiteralValue("4");
- infixExpression.setLeftOperand(stringLiteral);
- NumberLiteral literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("5");
- infixExpression.setRightOperand(literal);
-
- InfixExpression infixExpression2 = this.ast.newInfixExpression();
- infixExpression2.setOperator(InfixExpression.Operator.PLUS);
- infixExpression2.setLeftOperand(infixExpression);
- literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("6");
- infixExpression2.setRightOperand(literal);
-
- InfixExpression infixExpression3 = this.ast.newInfixExpression();
- infixExpression3.setOperator(InfixExpression.Operator.PLUS);
- infixExpression3.setLeftOperand(infixExpression2);
- literal = this.ast.newNumberLiteral();//$NON-NLS-1$
- literal.setToken("4");
- infixExpression3.setRightOperand(literal);
-
- assertTrue("Both AST trees should be identical", infixExpression3.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
- checkSourceRange(expression, "\"4\" - 5 + 6 + 4", source);//$NON-NLS-1$
- }
-
- /**
- * ReturnStatement ==> ReturnStatement
- */
- public void test0110() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0110", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ReturnStatement returnStatement = this.ast.newReturnStatement();
- NumberLiteral literal = this.ast.newNumberLiteral();
- literal.setToken("2");//$NON-NLS-1$
- returnStatement.setExpression(literal);
- assertTrue("Both AST trees should be identical", returnStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "return 2;", source);//$NON-NLS-1$
- }
-
- /**
- * ReturnStatement ==> ReturnStatement
- */
- public void test0111() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0111", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ReturnStatement returnStatement = this.ast.newReturnStatement();
- NumberLiteral literal = this.ast.newNumberLiteral();
- literal.setToken("2");//$NON-NLS-1$
- returnStatement.setExpression(literal);
- assertTrue("Both AST trees should be identical", returnStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "return 2\\u003B", source);//$NON-NLS-1$
- }
-
- /**
- * SynchronizedStatement ==> SynchronizedStatement
- */
- public void test0112() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0112", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- SynchronizedStatement synchronizedStatement = this.ast.newSynchronizedStatement();
- synchronizedStatement.setExpression(this.ast.newThisExpression());
- synchronizedStatement.setBody(this.ast.newBlock());
- assertTrue("Both AST trees should be identical", synchronizedStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- String expectedSource = "synchronized(this) {\r\n" +//$NON-NLS-1$
- " }"; //$NON-NLS-1$
- checkSourceRange(node, expectedSource, source);
- }
-
- /**
- * TryStatement ==> TryStatement
- */
- public void test0113() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0113", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- TryStatement tryStatement = this.ast.newTryStatement();
- tryStatement.setBody(this.ast.newBlock());
- tryStatement.setFinally(this.ast.newBlock());
- CatchClause catchBlock = this.ast.newCatchClause();
- catchBlock.setBody(this.ast.newBlock());
- SingleVariableDeclaration exceptionVariable = this.ast.newSingleVariableDeclaration();
- exceptionVariable.setModifiers(Modifier.NONE);
- exceptionVariable.setName(this.ast.newSimpleName("e"));//$NON-NLS-1$
- exceptionVariable.setType(this.ast.newSimpleType(this.ast.newSimpleName("Exception")));//$NON-NLS-1$
- catchBlock.setException(exceptionVariable);
- tryStatement.catchClauses().add(catchBlock);
- assertTrue("Both AST trees should be identical", tryStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- String expectedSource = "try {\r\n" +//$NON-NLS-1$
- " } catch(Exception e) {\r\n" +//$NON-NLS-1$
- " } finally {\r\n" +//$NON-NLS-1$
- " }"; //$NON-NLS-1$
- checkSourceRange(node, expectedSource, source);
- }
-
- /**
- * TryStatement ==> TryStatement
- */
- public void test0114() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0114", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- TryStatement tryStatement = this.ast.newTryStatement();
- tryStatement.setBody(this.ast.newBlock());
- CatchClause catchBlock = this.ast.newCatchClause();
- catchBlock.setBody(this.ast.newBlock());
- SingleVariableDeclaration exceptionVariable = this.ast.newSingleVariableDeclaration();
- exceptionVariable.setModifiers(Modifier.NONE);
- exceptionVariable.setName(this.ast.newSimpleName("e"));//$NON-NLS-1$
- exceptionVariable.setType(this.ast.newSimpleType(this.ast.newSimpleName("Exception")));//$NON-NLS-1$
- catchBlock.setException(exceptionVariable);
- tryStatement.catchClauses().add(catchBlock);
- assertTrue("Both AST trees should be identical", tryStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- String expectedSource = "try {\r\n" +//$NON-NLS-1$
- " } catch(Exception e) {\r\n" +//$NON-NLS-1$
- " }"; //$NON-NLS-1$
- checkSourceRange(node, expectedSource, source);
- }
-
- /**
- * TryStatement ==> TryStatement
- */
- public void test0115() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0115", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- TryStatement tryStatement = this.ast.newTryStatement();
- Block block = this.ast.newBlock();
- ReturnStatement returnStatement = this.ast.newReturnStatement();
- NumberLiteral literal = this.ast.newNumberLiteral();
- literal.setToken("2");//$NON-NLS-1$
- returnStatement.setExpression(literal);
- block.statements().add(returnStatement);
- tryStatement.setBody(block);
- CatchClause catchBlock = this.ast.newCatchClause();
- catchBlock.setBody(this.ast.newBlock());
- SingleVariableDeclaration exceptionVariable = this.ast.newSingleVariableDeclaration();
- exceptionVariable.setModifiers(Modifier.NONE);
- exceptionVariable.setName(this.ast.newSimpleName("e"));//$NON-NLS-1$
- exceptionVariable.setType(this.ast.newSimpleType(this.ast.newSimpleName("Exception")));//$NON-NLS-1$
- catchBlock.setException(exceptionVariable);
- tryStatement.catchClauses().add(catchBlock);
- assertTrue("Both AST trees should be identical", tryStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- String expectedSource = "try {\r\n" +//$NON-NLS-1$
- " return 2;\r\n" +//$NON-NLS-1$
- " } catch(Exception e) {\r\n" +//$NON-NLS-1$
- " }"; //$NON-NLS-1$
- checkSourceRange(node, expectedSource, source);
- }
-
- /**
- * ThrowStatement ==> ThrowStatement
- */
- public void test0116() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0116", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ThrowStatement throwStatement = this.ast.newThrowStatement();
- throwStatement.setExpression(this.ast.newSimpleName("e")); //$NON-NLS-1$
- assertTrue("Both AST trees should be identical", throwStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "throw e \\u003B", source);//$NON-NLS-1$
- }
-
- /**
- * ThrowStatement ==> ThrowStatement
- */
- public void test0117() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0117", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ThrowStatement throwStatement = this.ast.newThrowStatement();
- throwStatement.setExpression(this.ast.newSimpleName("e")); //$NON-NLS-1$
- assertTrue("Both AST trees should be identical", throwStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "throw e /* comment in the middle of a throw */ \\u003B", source);//$NON-NLS-1$
- }
-
- /**
- * ThrowStatement ==> ThrowStatement
- */
- public void test0118() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0118", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ThrowStatement throwStatement = this.ast.newThrowStatement();
- throwStatement.setExpression(this.ast.newSimpleName("e")); //$NON-NLS-1$
- assertTrue("Both AST trees should be identical", throwStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "throw e /* comment in the middle of a throw */ \\u003B", source);//$NON-NLS-1$
- }
-
- /**
- * IfStatement ==> IfStatement
- */
- public void test0119() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0119", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- IfStatement ifStatement = this.ast.newIfStatement();
- ifStatement.setExpression(this.ast.newBooleanLiteral(true));
- ifStatement.setThenStatement(this.ast.newEmptyStatement());
- assertTrue("Both AST trees should be identical", ifStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "if (true)\\u003B", source);//$NON-NLS-1$
- }
-
- /**
- * IfStatement ==> IfStatement
- */
- public void test0120() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0120", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- IfStatement ifStatement = this.ast.newIfStatement();
- ifStatement.setExpression(this.ast.newBooleanLiteral(true));
- ifStatement.setThenStatement(this.ast.newEmptyStatement());
- ifStatement.setElseStatement(this.ast.newEmptyStatement());
- assertTrue("Both AST trees should be identical", ifStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- String expectedSource = "if (true)\\u003B\r\n" +//$NON-NLS-1$
- "\t\telse ;"; //$NON-NLS-1$
- checkSourceRange(node, expectedSource, source);
- }
-
- /**
- * IfStatement ==> IfStatement
- */
- public void test0121() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0121", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- IfStatement ifStatement = this.ast.newIfStatement();
- ifStatement.setExpression(this.ast.newBooleanLiteral(true));
- ifStatement.setThenStatement(this.ast.newBlock());
- ifStatement.setElseStatement(this.ast.newEmptyStatement());
- assertTrue("Both AST trees should be identical", ifStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- String expectedSource = "if (true) {}\r\n" +//$NON-NLS-1$
- " else ;"; //$NON-NLS-1$
- checkSourceRange(node, expectedSource, source);
- }
-
- /**
- * IfStatement ==> IfStatement
- */
- public void test0122() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0122", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- IfStatement ifStatement = this.ast.newIfStatement();
- ifStatement.setExpression(this.ast.newBooleanLiteral(true));
- ReturnStatement returnStatement = this.ast.newReturnStatement();
- NumberLiteral literal = this.ast.newNumberLiteral();
- literal.setToken("2");//$NON-NLS-1$
- returnStatement.setExpression(literal);
- ifStatement.setThenStatement(returnStatement);
- assertTrue("Both AST trees should be identical", ifStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "if (true) return 2\\u003B", source);//$NON-NLS-1$
- }
-
- /**
- * IfStatement ==> IfStatement
- */
- public void test0123() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0123", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- IfStatement ifStatement = this.ast.newIfStatement();
- ifStatement.setExpression(this.ast.newBooleanLiteral(true));
- ReturnStatement returnStatement = this.ast.newReturnStatement();
- NumberLiteral literal = this.ast.newNumberLiteral();
- literal.setToken("2");//$NON-NLS-1$
- returnStatement.setExpression(literal);
- ifStatement.setThenStatement(returnStatement);
- returnStatement = this.ast.newReturnStatement();
- literal = this.ast.newNumberLiteral();
- literal.setToken("3");//$NON-NLS-1$
- returnStatement.setExpression(literal);
- ifStatement.setElseStatement(returnStatement);
- assertTrue("Both AST trees should be identical", ifStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- String expectedSource = "if (true) return 2;\r\n" +//$NON-NLS-1$
- " else return 3;"; //$NON-NLS-1$
- checkSourceRange(node, expectedSource, source);
- }
-
- /**
- * Multiple local declaration => VariabledeclarationStatement
- */
- public void test0124() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0124", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- VariableDeclarationFragment fragment = this.ast.newVariableDeclarationFragment();
- fragment.setName(this.ast.newSimpleName("x"));//$NON-NLS-1$
- NumberLiteral literal = this.ast.newNumberLiteral();
- literal.setToken("10");//$NON-NLS-1$
- fragment.setInitializer(literal);
- fragment.setExtraDimensions(0);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(fragment);
- fragment = this.ast.newVariableDeclarationFragment();
- fragment.setName(this.ast.newSimpleName("z"));//$NON-NLS-1$
- fragment.setInitializer(this.ast.newNullLiteral());
- fragment.setExtraDimensions(1);
- statement.fragments().add(fragment);
- fragment = this.ast.newVariableDeclarationFragment();
- fragment.setName(this.ast.newSimpleName("i"));//$NON-NLS-1$
- fragment.setExtraDimensions(0);
- statement.fragments().add(fragment);
- fragment = this.ast.newVariableDeclarationFragment();
- fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
- fragment.setExtraDimensions(2);
- statement.fragments().add(fragment);
- statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
- statement.setModifiers(Modifier.NONE);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- VariableDeclarationFragment[] fragments = (VariableDeclarationFragment[])((VariableDeclarationStatement) node).fragments().toArray(new VariableDeclarationFragment[4]);
- assertTrue("fragments.length != 4", fragments.length == 4);
- checkSourceRange(fragments[0], "x= 10", source);//$NON-NLS-1$
- checkSourceRange(fragments[1], "z[] = null", source);//$NON-NLS-1$
- checkSourceRange(fragments[2], "i", source);//$NON-NLS-1$
- checkSourceRange(fragments[3], "j[][]", source);//$NON-NLS-1$
- checkSourceRange(node, "int x= 10, z[] = null, i, j[][];", source);//$NON-NLS-1$
- }
-
- /**
- * Multiple local declaration => VariabledeclarationStatement
- */
- public void test0125() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0125", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- VariableDeclarationFragment fragment = this.ast.newVariableDeclarationFragment();
- fragment.setName(this.ast.newSimpleName("x"));//$NON-NLS-1$
- NumberLiteral literal = this.ast.newNumberLiteral();
- literal.setToken("10");//$NON-NLS-1$
- fragment.setInitializer(literal);
- fragment.setExtraDimensions(0);
- VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(fragment);
- fragment = this.ast.newVariableDeclarationFragment();
- fragment.setName(this.ast.newSimpleName("z"));//$NON-NLS-1$
- fragment.setInitializer(this.ast.newNullLiteral());
- fragment.setExtraDimensions(1);
- statement.fragments().add(fragment);
- fragment = this.ast.newVariableDeclarationFragment();
- fragment.setName(this.ast.newSimpleName("i"));//$NON-NLS-1$
- fragment.setExtraDimensions(0);
- statement.fragments().add(fragment);
- fragment = this.ast.newVariableDeclarationFragment();
- fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
- fragment.setExtraDimensions(2);
- statement.fragments().add(fragment);
- statement.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 1));
- statement.setModifiers(Modifier.NONE);
- assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int[] x= 10, z[] = null, i, j[][];", source);
- VariableDeclarationFragment[] fragments = (VariableDeclarationFragment[])((VariableDeclarationStatement) node).fragments().toArray(new VariableDeclarationFragment[4]);
- assertTrue("fragments.length != 4", fragments.length == 4);
- checkSourceRange(fragments[0], "x= 10", source);//$NON-NLS-1$
- checkSourceRange(fragments[1], "z[] = null", source);//$NON-NLS-1$
- checkSourceRange(fragments[2], "i", source);//$NON-NLS-1$
- checkSourceRange(fragments[3], "j[][]", source);//$NON-NLS-1$
- }
-
- /**
- * ForStatement
- */
- public void test0126() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0126", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ForStatement forStatement = this.ast.newForStatement();
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
- variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
- variableDeclarationFragment.setExtraDimensions(1);
- VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
- variableDeclarationExpression.setModifiers(Modifier.NONE);
- variableDeclarationExpression.setType(this.ast.newArrayType(this.ast.newSimpleType(this.ast.newSimpleName("String")), 1));//$NON-NLS-1$
- forStatement.initializers().add(variableDeclarationExpression);
- PrefixExpression prefixExpression = this.ast.newPrefixExpression();
- prefixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
- prefixExpression.setOperator(PrefixExpression.Operator.INCREMENT);
- forStatement.updaters().add(prefixExpression);
- forStatement.setBody(this.ast.newBlock());
- assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "for (String[] tab[] = null;; ++i) {}", source); //$NON-NLS-1$
- checkSourceRange((ASTNode) ((ForStatement) node).updaters().get(0), "++i", source); //$NON-NLS-1$
- checkSourceRange((ASTNode) ((ForStatement) node).initializers().get(0), "String[] tab[] = null", source); //$NON-NLS-1$
- }
-
- /**
- * ForStatement
- */
- public void test0127() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0127", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ForStatement forStatement = this.ast.newForStatement();
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
- variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
- variableDeclarationFragment.setExtraDimensions(1);
- VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
- variableDeclarationExpression.setModifiers(Modifier.NONE);
- variableDeclarationExpression.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
- forStatement.initializers().add(variableDeclarationExpression);
- PrefixExpression prefixExpression = this.ast.newPrefixExpression();
- prefixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
- prefixExpression.setOperator(PrefixExpression.Operator.INCREMENT);
- forStatement.updaters().add(prefixExpression);
- forStatement.setBody(this.ast.newBlock());
- assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "for (String tab[] = null;; ++i) {}", source); //$NON-NLS-1$
- checkSourceRange((ASTNode) ((ForStatement) node).updaters().get(0), "++i", source); //$NON-NLS-1$
- checkSourceRange((ASTNode) ((ForStatement) node).initializers().get(0), "String tab[] = null", source); //$NON-NLS-1$
- }
-
- /**
- * ForStatement
- */
- public void test0128() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0128", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ForStatement forStatement = this.ast.newForStatement();
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
- variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
- variableDeclarationFragment.setExtraDimensions(1);
- VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
- variableDeclarationExpression.setModifiers(Modifier.NONE);
- variableDeclarationExpression.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
- forStatement.initializers().add(variableDeclarationExpression);
- PostfixExpression postfixExpression = this.ast.newPostfixExpression();
- postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
- postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
- forStatement.updaters().add(postfixExpression);
- forStatement.setBody(this.ast.newBlock());
- assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "for (String tab[] = null;; i++/**/) {}", source); //$NON-NLS-1$
- checkSourceRange((ASTNode) ((ForStatement) node).updaters().get(0), "i++", source); //$NON-NLS-1$
- checkSourceRange((ASTNode) ((ForStatement) node).initializers().get(0), "String tab[] = null", source); //$NON-NLS-1$
- }
-
- /**
- * FieldDeclaration
- */
- public void test0129() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0129", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration);
- VariableDeclarationFragment frag = (VariableDeclarationFragment) ((FieldDeclaration) node).fragments().get(0);
- assertTrue("Not a declaration", frag.getName().isDeclaration());
- VariableDeclarationFragment fragment = this.ast.newVariableDeclarationFragment();
- fragment.setName(this.ast.newSimpleName("i"));
- fragment.setExtraDimensions(0);
- FieldDeclaration fieldDeclaration = this.ast.newFieldDeclaration(fragment);
- fieldDeclaration.setModifiers(Modifier.NONE);
- fieldDeclaration.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
- assertTrue("Both AST trees should be identical", fieldDeclaration.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "int i;", source); //$NON-NLS-1$
- }
-
- /**
- * FieldDeclaration
- */
- public void test0130() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0130", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration);
- VariableDeclarationFragment fragment = this.ast.newVariableDeclarationFragment();
- fragment.setName(this.ast.newSimpleName("x"));
- NumberLiteral literal = this.ast.newNumberLiteral();
- literal.setToken("10");
- fragment.setInitializer(literal);
- fragment.setExtraDimensions(0);
- FieldDeclaration fieldDeclaration = this.ast.newFieldDeclaration(fragment);
- fieldDeclaration.setModifiers(Modifier.PUBLIC);
- fieldDeclaration.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
- fragment = this.ast.newVariableDeclarationFragment();
- fragment.setName(this.ast.newSimpleName("y"));//$NON-NLS-1$
- fragment.setExtraDimensions(1);
- fragment.setInitializer(this.ast.newNullLiteral());
- fieldDeclaration.fragments().add(fragment);
- fragment = this.ast.newVariableDeclarationFragment();
- fragment.setName(this.ast.newSimpleName("i"));//$NON-NLS-1$
- fragment.setExtraDimensions(0);
- fieldDeclaration.fragments().add(fragment);
- fragment = this.ast.newVariableDeclarationFragment();
- fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
- fragment.setExtraDimensions(2);
- fieldDeclaration.fragments().add(fragment);
- assertTrue("Both AST trees should be identical", fieldDeclaration.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "public int x= 10, y[] = null, i, j[][];", source); //$NON-NLS-1$
- VariableDeclarationFragment[] fragments = (VariableDeclarationFragment[])((FieldDeclaration) node).fragments().toArray(new VariableDeclarationFragment[4]);
- assertTrue("fragments.length != 4", fragments.length == 4);
- checkSourceRange(fragments[0], "x= 10", source);//$NON-NLS-1$
- checkSourceRange(fragments[1], "y[] = null", source);//$NON-NLS-1$
- checkSourceRange(fragments[2], "i", source);//$NON-NLS-1$
- checkSourceRange(fragments[3], "j[][]", source);//$NON-NLS-1$
- }
-
- /**
- * Argument with final modifier
- */
- public void test0131() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0131", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a MethodDeclaration", node instanceof MethodDeclaration);
- assertTrue("Not a declaration", ((MethodDeclaration) node).getName().isDeclaration());
- List parameters = ((MethodDeclaration) node).parameters();
- assertTrue("Parameters.length != 1", parameters.size() == 1); //$NON-NLS-1$
- SingleVariableDeclaration arg = (SingleVariableDeclaration) ((MethodDeclaration) node).parameters().get(0);
- SingleVariableDeclaration singleVariableDeclaration = this.ast.newSingleVariableDeclaration();
- singleVariableDeclaration.setModifiers(Modifier.FINAL);
- singleVariableDeclaration.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
- singleVariableDeclaration.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
- assertTrue("Both AST trees should be identical", singleVariableDeclaration.subtreeMatch(new ASTMatcher(), arg)); //$NON-NLS-1$
- checkSourceRange(node, "void foo(final int i) {}", source); //$NON-NLS-1$
- checkSourceRange(arg, "final int i", source);
- }
-
- /**
- * Check javadoc for MethodDeclaration
- */
- public void test0132() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0132", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a MethodDeclaration", node instanceof MethodDeclaration);
- Javadoc actualJavadoc = ((MethodDeclaration) node).getJavadoc();
- Javadoc javadoc = this.ast.newJavadoc();
- javadoc.setComment("/** JavaDoc Comment\r\n */");//$NON-NLS-1$*/
- assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
- checkSourceRange(node, "/** JavaDoc Comment\r\n */\r\n void foo(final int i) {}", source); //$NON-NLS-1$
- checkSourceRange(actualJavadoc, "/** JavaDoc Comment\r\n */", source);
- }
-
- /**
- * Check javadoc for MethodDeclaration
- */
- public void test0133() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0133", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a MethodDeclaration", node instanceof MethodDeclaration);
- Javadoc actualJavadoc = ((MethodDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- checkSourceRange(node, "void foo(final int i) {}", source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for MethodDeclaration
- */
- public void test0134() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0134", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a MethodDeclaration", node instanceof MethodDeclaration);
- Javadoc actualJavadoc = ((MethodDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- checkSourceRange(node, "void foo(final int i) {}", source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for FieldDeclaration
- */
- public void test0135() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0135", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration);
- Javadoc actualJavadoc = ((FieldDeclaration) node).getJavadoc();
- Javadoc javadoc = this.ast.newJavadoc();
- javadoc.setComment("/** JavaDoc Comment\r\n */");//$NON-NLS-1$*/
- assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
- checkSourceRange(node, "/** JavaDoc Comment\r\n */\r\n int i;", source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for FieldDeclaration
- */
- public void test0136() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0136", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration);
- Javadoc actualJavadoc = ((FieldDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- checkSourceRange(node, "int i;", source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for FieldDeclaration
- */
- public void test0137() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0137", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration);
- Javadoc actualJavadoc = ((FieldDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- checkSourceRange(node, "int i;", source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for TypeDeclaration
- */
- public void test0138() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0138", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration);
- Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- String expectedContents = "public class Test {\r\n" +//$NON-NLS-1$
- " int i;\r\n" +//$NON-NLS-1$
- "}";//$NON-NLS-1$
- checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for TypeDeclaration
- */
- public void test0139() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0139", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration);
- Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- String expectedContents = "public class Test {\r\n" +//$NON-NLS-1$
- " int i;\r\n" +//$NON-NLS-1$
- "}";//$NON-NLS-1$
- checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for TypeDeclaration
- */
- public void test0140() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0140", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration);
- Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
- Javadoc javadoc = this.ast.newJavadoc();
- javadoc.setComment("/** JavaDoc Comment\r\n */");//$NON-NLS-1$*/
- assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
- String expectedContents =
- "/** JavaDoc Comment\r\n" + //$NON-NLS-1$
- " */\r\n" + //$NON-NLS-1$
- "public class Test {\r\n" +//$NON-NLS-1$
- " int i;\r\n" +//$NON-NLS-1$
- "}";//$NON-NLS-1$
- checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
- checkSourceRange(actualJavadoc, "/** JavaDoc Comment\r\n */", source);
- }
-
- /**
- * Check javadoc for MemberTypeDeclaration
- */
- public void test0141() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0141", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration);
- Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
- Javadoc javadoc = this.ast.newJavadoc();
- javadoc.setComment("/** JavaDoc Comment\r\n */");//$NON-NLS-1$*/
- assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
- String expectedContents =
- "/** JavaDoc Comment\r\n" + //$NON-NLS-1$
- " */\r\n" + //$NON-NLS-1$
- " class B {}";//$NON-NLS-1$
- checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
- checkSourceRange(actualJavadoc, "/** JavaDoc Comment\r\n */", source);
- }
-
- /**
- * Check javadoc for MemberTypeDeclaration
- */
- public void test0142() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0142", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration);
- Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- checkSourceRange(node, "class B {}", source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for MemberTypeDeclaration
- */
- public void test0143() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0143", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration);
- Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- checkSourceRange(node, "public static class B {}", source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for MemberTypeDeclaration
- */
- public void test0144() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0144", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration);
- Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- checkSourceRange(node, "public static class B {}", source); //$NON-NLS-1$
- }
-
- /**
- * Checking initializers
- */
- public void test0145() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0145", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- checkSourceRange(node, "{}", source); //$NON-NLS-1$
- }
-
- /**
- * Checking initializers
- */
- public void test0146() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0146", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- checkSourceRange(node, "static {}", source); //$NON-NLS-1$
- }
-
- /**
- * Checking initializers
- */
- public void test0147() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0147", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Javadoc actualJavadoc = ((Initializer) node).getJavadoc();
- assertNotNull("Javadoc comment should no be null", actualJavadoc); //$NON-NLS-1$
- Javadoc javadoc = this.ast.newJavadoc();
- javadoc.setComment("/** JavaDoc Comment\r\n */");//$NON-NLS-1$*/
- assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
- String expectedContents =
- "/** JavaDoc Comment\r\n" + //$NON-NLS-1$
- " */\r\n" + //$NON-NLS-1$
- " static {}";//$NON-NLS-1$
- checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
- checkSourceRange(actualJavadoc, "/** JavaDoc Comment\r\n */", source);
-
- }
-
- /**
- * Checking initializers
- */
- public void test0148() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0148", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Javadoc actualJavadoc = ((Initializer) node).getJavadoc();
- assertNotNull("Javadoc comment should not be null", actualJavadoc); //$NON-NLS-1$
- Javadoc javadoc = this.ast.newJavadoc();
- javadoc.setComment("/** JavaDoc Comment\r\n */");//$NON-NLS-1$*/
- assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
- String expectedContents =
- "/** JavaDoc Comment\r\n" + //$NON-NLS-1$
- " */\r\n" + //$NON-NLS-1$
- " {}";//$NON-NLS-1$
- checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
- checkSourceRange(actualJavadoc, "/** JavaDoc Comment\r\n */", source);
-
- }
-
- /**
- * Checking initializers
- */
- public void test0149() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0149", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Javadoc actualJavadoc = ((Initializer) node).getJavadoc();
- assertNull("Javadoc comment should be null", actualJavadoc); //$NON-NLS-1$
- checkSourceRange(node, "{}", source); //$NON-NLS-1$
- }
-
- /**
- * Checking syntax error
- */
- public void test0150() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0150", "Test.java");
- ASTNode result = runConversion(sourceUnit, false);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit unit = (CompilationUnit) result;
- assertTrue("The compilation unit is malformed", !isMalformed(unit));
- assertTrue("The package declaration is malformed", !isMalformed(unit.getPackage()));
- List imports = unit.imports();
- assertTrue("The imports list size is not one", imports.size() == 1);
- assertTrue("The first import is not malformed", isMalformed((ASTNode) imports.get(0)));
- }
-
- /**
- * Checking syntax error
- */
- public void test0151() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0151", "Test.java");
- ASTNode result = runConversion(sourceUnit, false);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The compilation unit is malformed", !isMalformed(result));
- }
-
- /**
- * Checking syntax error
- */
- public void test0152() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0152", "Test.java");
- ASTNode result = runConversion(sourceUnit, false);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The compilation unit is malformed", !isMalformed(result));
- ASTNode node = getASTNode((CompilationUnit) result, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The type is malformed", !isMalformed(node));
- node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The field is not malformed", isMalformed(node));
- }
-
- /**
- * Checking syntax error
- */
- public void test0153() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0153", "Test.java");
- ASTNode result = runConversion(sourceUnit, false);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The compilation unit is malformed", !isMalformed(result));
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The method is not malformed", isMalformed(node));
- }
-
- /**
- * Checking binding of package declaration
- */
- public void test0154() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0154", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- IBinding binding = compilationUnit.getPackage().getName().resolveBinding();
- assertNotNull("The package binding is null", binding); //$NON-NLS-1$
- assertTrue("The binding is not a package binding", binding instanceof IPackageBinding); //$NON-NLS-1$
- IPackageBinding packageBinding = (IPackageBinding) binding;
- assertEquals("The package name is incorrect", "test0154", packageBinding.getName());
- IBinding binding2 = compilationUnit.getPackage().getName().resolveBinding();
- assertTrue("The package binding is not canonical", binding == binding2); //$NON-NLS-1$
- }
-
- /**
- * Checking arguments positions
- */
- public void test0155() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0155", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertTrue("The result is not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
- MethodDeclaration methodDecl = (MethodDeclaration) node;
- List parameters = methodDecl.parameters();
- assertTrue("The parameters size is different from 2", parameters.size() == 2); //$NON-NLS-1$
- Object parameter = parameters.get(0);
- assertTrue("The parameter is not a SingleVariableDeclaration", parameter instanceof SingleVariableDeclaration); //$NON-NLS-1$
- checkSourceRange((ASTNode) parameter, "int i", source);
- parameter = parameters.get(1);
- assertTrue("The parameter is not a SingleVariableDeclaration", parameter instanceof SingleVariableDeclaration); //$NON-NLS-1$
- checkSourceRange((ASTNode) parameter, "final boolean b", source);
- }
-
- /**
- * Checking arguments positions
- */
- public void test0156() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0156", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertTrue("The result is not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
- MethodDeclaration methodDecl = (MethodDeclaration) node;
- List parameters = methodDecl.parameters();
- assertTrue("The parameters size is different from 1", parameters.size() == 1); //$NON-NLS-1$
- Object parameter = parameters.get(0);
- assertTrue("The parameter is not a SingleVariableDeclaration", parameter instanceof SingleVariableDeclaration); //$NON-NLS-1$
- checkSourceRange((ASTNode) parameter, "int i", source);
- Block block = methodDecl.getBody();
- List statements = block.statements();
- assertTrue("The statements size is different from 2", statements.size() == 2); //$NON-NLS-1$
- ASTNode statement = (ASTNode) statements.get(0);
- assertTrue("The statements[0] is a postfixExpression statement", statement instanceof ExpressionStatement); //$NON-NLS-1$
- }
-
- /**
- * Check canonic binding for fields
- */
- public void test0157() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "", "Test0157.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- List types = compilationUnit.types();
- assertTrue("The types list is empty", types.size() != 0);
- TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("Type binding is null", typeBinding);
- assertTrue("The type binding is canonical", typeBinding == typeDeclaration.resolveBinding());
- List bodyDeclarations = typeDeclaration.bodyDeclarations();
- assertTrue("The body declaration list is empty", bodyDeclarations.size() != 0);
- BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
- assertTrue("This is not a field", bodyDeclaration instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) bodyDeclaration;
- List variableFragments = fieldDeclaration.fragments();
- assertTrue("The fragment list is empty", variableFragments.size() != 0);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableFragments.get(0);
- IVariableBinding variableBinding = fragment.resolveBinding();
- assertNotNull("the field binding is null", variableBinding);
- assertTrue("The field binding is not canonical", variableBinding == fragment.resolveBinding());
- typeBinding = variableBinding.getType();
- assertTrue("The type is not an array type", typeBinding.isArray());
- assertTrue("The type binding for the field is not canonical", typeBinding == variableBinding.getType());
- SimpleName name = fragment.getName();
- assertTrue("is a declaration", name.isDeclaration());
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("wrong type", IBinding.VARIABLE, binding.getKind());
- assertTrue("not a field", ((IVariableBinding) binding).isField());
- }
-
- /**
- * Check canonic bindings for fields
- */
- public void test0158() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "", "Test0158.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- List types = compilationUnit.types();
- assertTrue("The types list is empty", types.size() != 0);
- TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("Type binding is null", typeBinding);
- assertTrue("The type binding is canonical", typeBinding == typeDeclaration.resolveBinding());
- SimpleName simpleName = typeDeclaration.getName();
- assertTrue("is a declaration", simpleName.isDeclaration());
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("wrong type", IBinding.TYPE, binding.getKind());
- assertEquals("wrong name", simpleName.getIdentifier(), binding.getName());
- List bodyDeclarations = typeDeclaration.bodyDeclarations();
- assertTrue("The body declaration list is empty", bodyDeclarations.size() != 0);
- BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
- assertTrue("This is not a field", bodyDeclaration instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) bodyDeclaration;
- List variableFragments = fieldDeclaration.fragments();
- assertTrue("The fragment list is empty", variableFragments.size() != 0);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableFragments.get(0);
- IVariableBinding variableBinding = fragment.resolveBinding();
- assertNotNull("the field binding is null", variableBinding);
- assertTrue("The field binding is not canonical", variableBinding == fragment.resolveBinding());
- ITypeBinding typeBinding2 = variableBinding.getType();
- assertTrue("The type is not an array type", typeBinding2.isArray());
- assertTrue("The type binding for the field is not canonical", typeBinding2 == variableBinding.getType());
- assertTrue("The type binding for the field is not canonical with the declaration type binding", typeBinding == typeBinding2.getElementType());
- }
-
- /**
- * Define an anonymous type
- */
- public void test0159() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0159", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit);
- }
-
- /**
- * Check bindings for multiple field declarations
- */
- public void test0160() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0160", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- List types = compilationUnit.types();
- assertTrue("The types list is empty", types.size() != 0);
- TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("Type binding is null", typeBinding);
- assertTrue("The type binding is canonical", typeBinding == typeDeclaration.resolveBinding());
- List bodyDeclarations = typeDeclaration.bodyDeclarations();
- assertTrue("The body declaration list is empty", bodyDeclarations.size() != 0);
- BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
- assertTrue("This is not a field", bodyDeclaration instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) bodyDeclaration;
- List variableFragments = fieldDeclaration.fragments();
- assertTrue("The fragment list size is not 2", variableFragments.size() == 2);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableFragments.get(0);
- IVariableBinding variableBinding1 = fragment.resolveBinding();
- assertNotNull("the field binding is null", variableBinding1);
- assertTrue("The field binding is not canonical", variableBinding1 == fragment.resolveBinding());
- ITypeBinding type1 = variableBinding1.getType();
- assertNotNull("The type is null", type1);
- assertTrue("The field type is canonical", type1 == variableBinding1.getType());
- assertTrue("The type is not an array type",type1.isArray());
- assertTrue("The type dimension is 1", type1.getDimensions() == 1);
- fragment = (VariableDeclarationFragment) variableFragments.get(1);
- IVariableBinding variableBinding2 = fragment.resolveBinding();
- assertNotNull("the field binding is null", variableBinding2);
- assertTrue("The field binding is not canonical", variableBinding2 == fragment.resolveBinding());
- ITypeBinding type2 = variableBinding2.getType();
- type2 = variableBinding2.getType();
- assertNotNull("The type is null", type2);
- assertTrue("The field type is canonical", type2 == variableBinding2.getType());
- assertTrue("The type is not an array type",type2.isArray());
- assertTrue("The type dimension is 2", type2.getDimensions() == 2);
- assertTrue("Element type is canonical", type1.getElementType() == type2.getElementType());
- assertTrue("type1.id < type2.id", variableBinding1.getVariableId() < variableBinding2.getVariableId());
-
- }
-
- /**
- * Check ITypeBinding APIs:
- * - getModifiers()
- * - getElementType() when it is not an array type
- * - getDimensions() when it is not an array type
- * - getDeclaringClass()
- * - getDeclaringName()
- * - getName()
- * - isNested()
- * - isAnonymous()
- * - isLocal()
- * - isMember()
- * - isArray()
- * - getDeclaredMethods() => returns binding for default constructor
- * - isPrimitive()
- * - isTopLevel()
- * - getSuperclass()
- */
- public void test0161() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0161", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- List types = compilationUnit.types();
- assertTrue("The types list is empty", types.size() != 0);
- TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("The type binding should not be null", typeBinding);
- assertEquals("The modifier is PUBLIC", Modifier.PUBLIC, typeBinding.getModifiers());
- assertNull("There is no element type", typeBinding.getElementType());
- assertEquals("There is no dimension", 0, typeBinding.getDimensions());
- assertNull("This is not a member type", typeBinding.getDeclaringClass());
- IMethodBinding[] methods = typeBinding.getDeclaredMethods();
- assertEquals("Contains the default constructor", 1, methods.length);
- assertEquals("The name is not Test", "Test", typeBinding.getName());
- assertTrue("An anonymous class", !typeBinding.isAnonymous());
- assertTrue("A local class", !typeBinding.isLocal());
- assertTrue("A nested class", !typeBinding.isNested());
- assertTrue("A member class", !typeBinding.isMember());
- assertTrue("An array", !typeBinding.isArray());
- assertTrue("Not a class", typeBinding.isClass());
- assertTrue("An interface", !typeBinding.isInterface());
- assertTrue("Not from source", typeBinding.isFromSource());
- assertTrue("Is nested", typeBinding.isTopLevel());
- assertTrue("A primitive type", !typeBinding.isPrimitive());
- ITypeBinding superclass = typeBinding.getSuperclass();
- assertNotNull("No superclass", superclass);
- assertTrue("From source", !superclass.isFromSource());
- ITypeBinding supersuperclass = superclass.getSuperclass();
- assertNull("No superclass for java.lang.Object", supersuperclass);
- ITypeBinding[] interfaces = typeBinding.getInterfaces();
- assertNotNull("No interfaces", interfaces);
- assertEquals("More then one super interface", 1, interfaces.length);
- assertTrue("is not an interface", interfaces[0].isInterface());
- assertTrue("From source", !interfaces[0].isFromSource());
- assertEquals("Has fields", 0, typeBinding.getDeclaredFields().length);
- }
-
- /**
- * Check ITypeBinding APIs:
- * - getModifiers()
- * - getElementType() when it is not an array type
- * - getDimensions() when it is not an array type
- * - getDeclaringClass()
- * - getDeclaringName()
- * - getName()
- * - isNested()
- * - isAnonymous()
- * - isLocal()
- * - isMember()
- * - isArray()
- * - getDeclaredMethods() => returns binding for default constructor
- * - isPrimitive()
- * - isTopLevel()
- * - getSuperclass()
- */
- public void test0162() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0162", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- List types = compilationUnit.types();
- assertTrue("The types list is empty", types.size() != 0);
- TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("The type binding should not be null", typeBinding);
- assertEquals("The modifier is PUBLIC", Modifier.PUBLIC, typeBinding.getModifiers());
- assertNull("There is no element type", typeBinding.getElementType());
- assertEquals("There is no dimension", 0, typeBinding.getDimensions());
- assertNull("This is not a member type", typeBinding.getDeclaringClass());
- IMethodBinding[] methods = typeBinding.getDeclaredMethods();
- assertEquals("Contains no methos", 0, methods.length);
- assertEquals("The name is not Test", "Test", typeBinding.getName());
- assertTrue("An anonymous class", !typeBinding.isAnonymous());
- assertTrue("A local class", !typeBinding.isLocal());
- assertTrue("A nested class", !typeBinding.isNested());
- assertTrue("A member class", !typeBinding.isMember());
- assertTrue("An array", !typeBinding.isArray());
- assertTrue("A class", !typeBinding.isClass());
- assertTrue("Not an interface", typeBinding.isInterface());
- assertTrue("Not from source", typeBinding.isFromSource());
- assertTrue("Is nested", typeBinding.isTopLevel());
- assertTrue("A primitive type", !typeBinding.isPrimitive());
- ITypeBinding superclass = typeBinding.getSuperclass();
- assertNull("No superclass", superclass);
- assertEquals("Has fields", 0, typeBinding.getDeclaredFields().length);
- }
-
- /**
- * Test binding for anonymous declaration: new java.lang.Object() {}
- */
- public void test0163() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0163", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- assertTrue("Not an anonymous type declaration", expression instanceof ClassInstanceCreation);
- ClassInstanceCreation anonymousClass = (ClassInstanceCreation) expression;
- ITypeBinding typeBinding = anonymousClass.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertTrue("Not an anonymous class", typeBinding.isAnonymous());
- assertEquals("The modifier is not default", Modifier.NONE, typeBinding.getModifiers());
- assertNull("There is no element type", typeBinding.getElementType());
- assertEquals("There is no dimension", 0, typeBinding.getDimensions());
- assertNotNull("This is a member type", typeBinding.getDeclaringClass());
- assertEquals("The name is not empty", "", typeBinding.getName());
- IMethodBinding[] methods = typeBinding.getDeclaredMethods();
- assertEquals("Contains the default constructor", 1, methods.length);
- assertTrue("Not a local class", typeBinding.isLocal());
- assertTrue("Not a nested class", typeBinding.isNested());
- assertTrue("A member class", !typeBinding.isMember());
- assertTrue("An array", !typeBinding.isArray());
- assertTrue("Not a class", typeBinding.isClass());
- assertTrue("An interface", !typeBinding.isInterface());
- assertTrue("Not from source", typeBinding.isFromSource());
- assertTrue("Is a top level", !typeBinding.isTopLevel());
- assertTrue("A primitive type", !typeBinding.isPrimitive());
- assertEquals("wrong qualified name", "", typeBinding.getQualifiedName());
- ITypeBinding superclass = typeBinding.getSuperclass();
- assertNotNull("No superclass", superclass);
- assertEquals("Has fields", 0, typeBinding.getDeclaredFields().length);
- }
-
- /**
- * Test binding for member type declaration
- */
- public void test0164() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0164", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("Not an type declaration", node instanceof TypeDeclaration);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("No binding", typeBinding);
- assertTrue("An anonymous class", !typeBinding.isAnonymous());
- assertEquals("The modifier is not default", Modifier.PRIVATE, typeBinding.getModifiers());
- assertNull("There is no element type", typeBinding.getElementType());
- assertEquals("There is no dimension", 0, typeBinding.getDimensions());
- assertNotNull("This is not a member type", typeBinding.getDeclaringClass());
- assertEquals("The name is not 'B'", "B", typeBinding.getName());
- IMethodBinding[] methods = typeBinding.getDeclaredMethods();
- assertEquals("Contains the default constructor", 1, methods.length);
- assertTrue("A local class", !typeBinding.isLocal());
- assertTrue("Not a nested class", typeBinding.isNested());
- assertTrue("Not a member class", typeBinding.isMember());
- assertTrue("An array", !typeBinding.isArray());
- assertTrue("Not a class", typeBinding.isClass());
- assertTrue("An interface", !typeBinding.isInterface());
- assertTrue("Not from source", typeBinding.isFromSource());
- assertTrue("Is a top level", !typeBinding.isTopLevel());
- assertTrue("A primitive type", !typeBinding.isPrimitive());
- ITypeBinding superclass = typeBinding.getSuperclass();
- assertNotNull("No superclass", superclass);
- assertEquals("Has fields", 0, typeBinding.getDeclaredFields().length);
- }
-
- /**
- * Test binding for local type declaration
- */
- public void test0165() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0165", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("Not an type declaration", node instanceof TypeDeclarationStatement);
- TypeDeclarationStatement statement = (TypeDeclarationStatement) node;
- TypeDeclaration typeDeclaration = statement.getTypeDeclaration();
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("No binding", typeBinding);
- assertTrue("An anonymous class", !typeBinding.isAnonymous());
- assertEquals("The modifier is not default", Modifier.NONE, typeBinding.getModifiers());
- assertNull("There is no element type", typeBinding.getElementType());
- assertEquals("There is no dimension", 0, typeBinding.getDimensions());
- assertNotNull("This is not a member type", typeBinding.getDeclaringClass());
- assertEquals("The name is not 'C'", "C", typeBinding.getName());
- IMethodBinding[] methods = typeBinding.getDeclaredMethods();
- assertEquals("Contains the default constructor", 1, methods.length);
- assertTrue("Not a local class", typeBinding.isLocal());
- assertTrue("Not a nested class", typeBinding.isNested());
- assertTrue("A member class", !typeBinding.isMember());
- assertTrue("An array", !typeBinding.isArray());
- assertTrue("Not a class", typeBinding.isClass());
- assertTrue("An interface", !typeBinding.isInterface());
- assertTrue("Not from source", typeBinding.isFromSource());
- assertTrue("Is a top level", !typeBinding.isTopLevel());
- assertTrue("A primitive type", !typeBinding.isPrimitive());
- assertEquals("wrong qualified name", "", typeBinding.getQualifiedName());
- ITypeBinding superclass = typeBinding.getSuperclass();
- assertNotNull("No superclass", superclass);
- assertEquals("Has fields", 0, typeBinding.getDeclaredFields().length);
- }
-
- /**
- * Multiple local declaration => VariabledeclarationStatement
- */
- public void test0166() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0166", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertTrue("Fragment list is not 4 ", fragments.size() == 4);
- VariableDeclarationFragment fragment1 = (VariableDeclarationFragment) fragments.get(0);
- IVariableBinding binding1 = fragment1.resolveBinding();
- assertNotNull("Binding is null", binding1);
- assertEquals("wrong name for binding1", "x", binding1.getName());
- assertEquals("wrong modifier for binding1", 0, binding1.getModifiers());
- assertTrue("a field", !binding1.isField());
- assertNull("declaring class is not null", binding1.getDeclaringClass());
- ITypeBinding typeBinding1 = binding1.getType();
- assertNotNull("typeBinding1 is null", typeBinding1);
- assertTrue("typeBinding1 is not a primitive type", typeBinding1.isPrimitive());
- assertTrue("typeBinding1 is not canonical", typeBinding1 == binding1.getType());
- VariableDeclarationFragment fragment2 = (VariableDeclarationFragment) fragments.get(1);
- IVariableBinding binding2 = fragment2.resolveBinding();
- assertNotNull("Binding is null", binding2);
- assertEquals("wrong name for binding2", "z", binding2.getName());
- assertEquals("wrong modifier for binding2", 0, binding2.getModifiers());
- assertTrue("a field", !binding2.isField());
- assertNull("declaring class is not null", binding2.getDeclaringClass());
- ITypeBinding typeBinding2 = binding2.getType();
- assertNotNull("typeBinding2 is null", typeBinding2);
- assertTrue("typeBinding2 is not an array type", typeBinding2.isArray());
- assertTrue("typeBinding2 is not canonical", typeBinding2 == binding2.getType());
- assertTrue("primitive type is not canonical", typeBinding1 == typeBinding2.getElementType());
- assertEquals("dimension is 1", 1, typeBinding2.getDimensions());
- assertEquals("it is not int[]", "int[]", typeBinding2.getName());
- VariableDeclarationFragment fragment3 = (VariableDeclarationFragment) fragments.get(2);
- IVariableBinding binding3 = fragment3.resolveBinding();
- assertNotNull("Binding is null", binding3);
- assertEquals("wrong name for binding3", "i", binding3.getName());
- assertEquals("wrong modifier for binding3", 0, binding3.getModifiers());
- assertTrue("a field", !binding3.isField());
- assertNull("declaring class is not null", binding3.getDeclaringClass());
- ITypeBinding typeBinding3 = binding3.getType();
- assertNotNull("typeBinding3 is null", typeBinding3);
- assertTrue("typeBinding3 is not an primitive type", typeBinding3.isPrimitive());
- assertTrue("typeBinding3 is not canonical", typeBinding3 == binding3.getType());
- assertTrue("primitive type is not canonical", typeBinding1 == typeBinding3);
- assertEquals("dimension is 0", 0, typeBinding3.getDimensions());
- assertEquals("it is not the primitive type int", "int", typeBinding3.getName());
- VariableDeclarationFragment fragment4 = (VariableDeclarationFragment) fragments.get(3);
- IVariableBinding binding4 = fragment4.resolveBinding();
- assertNotNull("Binding is null", binding4);
- assertEquals("wrong name for binding4", "j", binding4.getName());
- assertEquals("wrong modifier for binding4", 0, binding4.getModifiers());
- assertTrue("a field", !binding4.isField());
- assertNull("declaring class is not null", binding4.getDeclaringClass());
- ITypeBinding typeBinding4 = binding4.getType();
- assertNotNull("typeBinding4 is null", typeBinding4);
- assertTrue("typeBinding4 is not an array type", typeBinding4.isArray());
- assertTrue("typeBinding4 is not canonical", typeBinding4 == binding4.getType());
- assertTrue("primitive type is not canonical", typeBinding1 == typeBinding4.getElementType());
- assertEquals("dimension is 2", 2, typeBinding4.getDimensions());
- assertEquals("it is not int[][]", "int[][]", typeBinding4.getName());
- assertTrue("ids in the wrong order", binding1.getVariableId() < binding2.getVariableId());
- assertTrue("ids in the wrong order", binding2.getVariableId() < binding3.getVariableId());
- assertTrue("ids in the wrong order", binding3.getVariableId() < binding4.getVariableId());
- }
-
- /**
- * Check source position for new Test[1+2].length.
- */
- public void test0167() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0167", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("Instance of VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertTrue("fragment list size is not 1", fragments.size() == 1);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- Expression initialization = fragment.getInitializer();
- assertNotNull("No initialization", initialization);
- assertTrue("Not a FieldAccess", initialization instanceof FieldAccess);
- checkSourceRange(initialization, "new Test[1+2].length", source); //$NON-NLS-1$
- }
-
- /**
- * Check package binding: test0168.test
- */
- public void test0168() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0168.test1", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- List types = compilationUnit.types();
- assertTrue("The types list is empty", types.size() != 0);
- TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("Binding not null", typeBinding);
- IPackageBinding packageBinding = typeBinding.getPackage();
- assertNotNull("No package binding", packageBinding);
- assertEquals("wrong name", "test0168.test1", packageBinding.getName());
- String[] components = packageBinding.getNameComponents();
- assertNotNull("no components", components);
- assertTrue("components size != 2", components.length == 2);
- assertEquals("wrong component name", "test0168", components[0]);
- assertEquals("wrong component name", "test1", components[1]);
- assertEquals("wrong type", IPackageBinding.PACKAGE, packageBinding.getKind());
- assertTrue("Unnamed package", !packageBinding.isUnnamed());
- assertTrue("Package binding is not canonical", packageBinding == typeBinding.getPackage());
- }
-
- /**
- * Check package binding: test0169
- */
- public void test0169() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0169", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- List types = compilationUnit.types();
- assertTrue("The types list is empty", types.size() != 0);
- TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("Binding not null", typeBinding);
- IPackageBinding packageBinding = typeBinding.getPackage();
- assertNotNull("No package binding", packageBinding);
- assertEquals("wrong name", "test0169", packageBinding.getName());
- String[] components = packageBinding.getNameComponents();
- assertNotNull("no components", components);
- assertTrue("components size != 1", components.length == 1);
- assertEquals("wrong component name", "test0169", components[0]);
- assertEquals("wrong type", IPackageBinding.PACKAGE, packageBinding.getKind());
- assertTrue("Unnamed package", !packageBinding.isUnnamed());
- assertTrue("Package binding is not canonical", packageBinding == typeBinding.getPackage());
- }
-
- /**
- * Check package binding: test0170
- */
- public void test0170() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "", "Test0170.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- List types = compilationUnit.types();
- assertTrue("The types list is empty", types.size() != 0);
- TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("Binding not null", typeBinding);
- IPackageBinding packageBinding = typeBinding.getPackage();
- assertNotNull("No package binding", packageBinding);
- assertEquals("wrong name", "UNNAMED", packageBinding.getName());
- String[] components = packageBinding.getNameComponents();
- assertNotNull("no components", components);
- assertTrue("components size != 0", components.length == 0);
- assertEquals("wrong type", IPackageBinding.PACKAGE, packageBinding.getKind());
- assertTrue("Not an unnamed package", packageBinding.isUnnamed());
- assertTrue("Package binding is not canonical", packageBinding == typeBinding.getPackage());
- }
-
- /**
- * Check package binding: test0171
- */
- public void test0171() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0171", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- List types = compilationUnit.types();
- assertTrue("The types list is empty", types.size() == 2);
- TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("Binding not null", typeBinding);
- IPackageBinding packageBinding = typeBinding.getPackage();
- assertNotNull("No package binding", packageBinding);
- assertEquals("wrong name", "test0171", packageBinding.getName());
- String[] components = packageBinding.getNameComponents();
- assertNotNull("no components", components);
- assertTrue("components size != 1", components.length == 1);
- assertEquals("wrong component name", "test0171", components[0]);
- assertEquals("wrong type", IPackageBinding.PACKAGE, packageBinding.getKind());
- assertTrue("Unnamed package", !packageBinding.isUnnamed());
- assertTrue("Package binding is not canonical", packageBinding == typeBinding.getPackage());
-
- typeDeclaration = (TypeDeclaration) types.get(1);
- typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("Binding not null", typeBinding);
- IPackageBinding packageBinding2 = typeBinding.getPackage();
- assertNotNull("No package binding", packageBinding);
- assertTrue("Package binding is not canonical", packageBinding == packageBinding2);
- }
-
- /**
- * Check method binding
- */
- public void test0172() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0172", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- List types = compilationUnit.types();
- assertTrue("The types list is empty", types.size() != 0);
- TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("Binding not null", typeBinding);
- IMethodBinding[] methods = typeBinding.getDeclaredMethods();
- assertEquals("methods.length != 4", 4, methods.length);
- List bodyDeclarations = typeDeclaration.bodyDeclarations();
- assertEquals("body declaration size != 3", 3, bodyDeclarations.size());
- MethodDeclaration method1 = (MethodDeclaration) bodyDeclarations.get(0);
- IMethodBinding methodBinding1 = method1.resolveBinding();
- assertNotNull("No method binding for foo", methodBinding1);
- SimpleName simpleName = method1.getName();
- assertTrue("not a declaration", simpleName.isDeclaration());
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("wrong name", binding.getName(), simpleName.getIdentifier());
- assertTrue("Canonical method binding", methodBinding1 == methods[1]);
- assertTrue("declaring class is canonical", typeBinding == methodBinding1.getDeclaringClass());
- ITypeBinding[] exceptionTypes = methodBinding1.getExceptionTypes();
- assertNotNull("No exception types", exceptionTypes);
- assertEquals("One exception", 1, exceptionTypes.length);
- assertEquals("wrong name for exception", "IOException", exceptionTypes[0].getName());
- assertEquals("wrong modifier", Modifier.NONE, methodBinding1.getModifiers());
- assertEquals("wrong name for method", "foo", methodBinding1.getName());
- ITypeBinding[] parameters = methodBinding1.getParameterTypes();
- assertNotNull("No parameters", parameters);
- assertEquals("wrong size", 1, parameters.length);
- assertEquals("wrong type", "int[]", parameters[0].getName());
- assertEquals("wrong return type", "void", methodBinding1.getReturnType().getName());
- assertTrue("A constructor", !methodBinding1.isConstructor());
-
- MethodDeclaration method2 = (MethodDeclaration) bodyDeclarations.get(1);
- IMethodBinding methodBinding2 = method2.resolveBinding();
- assertNotNull("No method binding for main", methodBinding2);
- assertTrue("Canonical method binding", methodBinding2 == methods[2]);
- assertTrue("declaring class is canonical", typeBinding == methodBinding2.getDeclaringClass());
- ITypeBinding[] exceptionTypes2 = methodBinding2.getExceptionTypes();
- assertNotNull("No exception types", exceptionTypes2);
- assertEquals("No exception", 0, exceptionTypes2.length);
- assertEquals("wrong modifier", Modifier.PUBLIC | Modifier.STATIC, methodBinding2.getModifiers());
- assertEquals("wrong name for method", "main", methodBinding2.getName());
- ITypeBinding[] parameters2 = methodBinding2.getParameterTypes();
- assertNotNull("No parameters", parameters2);
- assertEquals("wrong size", 1, parameters2.length);
- assertEquals("wrong type for parameter2[0]", "String[]", parameters2[0].getName());
- assertEquals("wrong return type", "void", methodBinding2.getReturnType().getName());
- assertTrue("A constructor", !methodBinding2.isConstructor());
-
- MethodDeclaration method3 = (MethodDeclaration) bodyDeclarations.get(2);
- IMethodBinding methodBinding3 = method3.resolveBinding();
- assertNotNull("No method binding for main", methodBinding3);
- assertTrue("Canonical method binding", methodBinding3 == methods[3]);
- assertTrue("declaring class is canonical", typeBinding == methodBinding3.getDeclaringClass());
- ITypeBinding[] exceptionTypes3 = methodBinding3.getExceptionTypes();
- assertNotNull("No exception types", exceptionTypes3);
- assertEquals("No exception", 1, exceptionTypes3.length);
- assertEquals("wrong modifier", Modifier.PRIVATE, methodBinding3.getModifiers());
- assertEquals("wrong name for method", "bar", methodBinding3.getName());
- ITypeBinding[] parameters3 = methodBinding3.getParameterTypes();
- assertNotNull("No parameters", parameters3);
- assertEquals("wrong size", 1, parameters3.length);
- assertEquals("wrong type", "String", parameters3[0].getName());
- assertEquals("wrong return type", "String", methodBinding3.getReturnType().getName());
- assertTrue("A constructor", !methodBinding3.isConstructor());
- assertTrue("The binding is not canonical", parameters3[0] == methodBinding3.getReturnType());
- }
-
- /**
- * i++; IVariableBinding
- */
- public void test0173() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0173", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("Not an expressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression ex = expressionStatement.getExpression();
- assertTrue("Not a postfixexpression", ex instanceof PostfixExpression);
- PostfixExpression postfixExpression = (PostfixExpression) ex;
- Expression expr = postfixExpression.getOperand();
- assertTrue("Not a simpleName", expr instanceof SimpleName);
- SimpleName name = (SimpleName) expr;
- assertTrue("a declaration", !name.isDeclaration());
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding", binding);
-
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
- List fragments = variableDeclarationStatement.fragments();
- assertTrue("No fragment", fragments.size() == 1);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- IVariableBinding variableBinding = fragment.resolveBinding();
- assertTrue(variableBinding == binding);
- }
-
- /**
- * i++; IVariableBinding (field)
- */
- public void test0174() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0174", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 1, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("Not an expressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression ex = expressionStatement.getExpression();
- assertTrue("Not a postfixexpression", ex instanceof PostfixExpression);
- PostfixExpression postfixExpression = (PostfixExpression) ex;
- Expression expr = postfixExpression.getOperand();
- assertTrue("Not a simpleName", expr instanceof SimpleName);
- SimpleName name = (SimpleName) expr;
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding", binding);
-
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0);
- assertTrue("FieldDeclaration", node2 instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node2;
- List fragments = fieldDeclaration.fragments();
- assertTrue("No fragment", fragments.size() == 1);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- IVariableBinding variableBinding = fragment.resolveBinding();
- assertTrue(variableBinding == binding);
- }
-
- /**
- * int i = 0; Test IntBinding for the field declaration and the 0 literal
- */
- public void test0175() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0175", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0);
- assertTrue("VariableDeclarationStatement", node2 instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node2;
- List fragments = fieldDeclaration.fragments();
- assertTrue("No fragment", fragments.size() == 1);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- IVariableBinding variableBinding = fragment.resolveBinding();
- ITypeBinding typeBinding = fragment.getInitializer().resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertTrue("Not a primitive type", typeBinding.isPrimitive());
- assertEquals("Not int", "int", typeBinding.getName());
- assertTrue(variableBinding.getType() == typeBinding);
- }
-
- /**
- * ThisReference
- */
- public void test0176() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0176", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 1, 0);
- assertTrue("Return statement", node2 instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node2;
- assertTrue("Not a field access", returnStatement.getExpression() instanceof FieldAccess);
- FieldAccess fieldAccess = (FieldAccess) returnStatement.getExpression();
- ITypeBinding typeBinding = fieldAccess.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertTrue("Not a primitive type", typeBinding.isPrimitive());
- assertEquals("Not int", "int", typeBinding.getName());
- Expression expr = fieldAccess.getExpression();
- assertTrue("Not a this expression", expr instanceof ThisExpression);
- ThisExpression thisExpression = (ThisExpression) expr;
- ITypeBinding typeBinding2 = thisExpression.resolveTypeBinding();
- assertNotNull("No type binding2", typeBinding2);
- assertEquals("Not Test", "Test", typeBinding2.getName());
- }
-
- /**
- * i++; IVariableBinding
- */
- public void test0177() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0177", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 1, 1);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("Not an expressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression ex = expressionStatement.getExpression();
- assertTrue("Not a postfixexpression", ex instanceof PostfixExpression);
- PostfixExpression postfixExpression = (PostfixExpression) ex;
- Expression expr = postfixExpression.getOperand();
- assertTrue("Not a simpleName", expr instanceof SimpleName);
- SimpleName name = (SimpleName) expr;
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding", binding);
-
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 1, 0);
- assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
- List fragments = variableDeclarationStatement.fragments();
- assertTrue("No fragment", fragments.size() == 1);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- IVariableBinding variableBinding = fragment.resolveBinding();
- assertEquals("return type is not int", "int", variableBinding.getType().getName());
- assertTrue(variableBinding == binding);
- }
-
- /**
- * SuperReference
- */
- public void test0178() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0178", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 1, 0, 0);
- assertTrue("Return statement", node2 instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node2;
- Expression expr = returnStatement.getExpression();
- assertTrue("Not a field access", expr instanceof SuperFieldAccess);
- SuperFieldAccess fieldAccess = (SuperFieldAccess) expr;
- ITypeBinding typeBinding = fieldAccess.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertTrue("Not a primitive type", typeBinding.isPrimitive());
- assertEquals("Not int", "int", typeBinding.getName());
- }
-
- /**
- * Allocation expression
- */
- public void test0179() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0179", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
- List fragments = variableDeclarationStatement.fragments();
- assertTrue("No fragment", fragments.size() == 1);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- IVariableBinding variableBinding = fragment.resolveBinding();
- Expression initialization = fragment.getInitializer();
- ITypeBinding typeBinding = initialization.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertTrue(variableBinding.getType() == typeBinding);
- }
-
- /**
- * Allocation expression
- */
- public void test0180() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0180", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
- List fragments = variableDeclarationStatement.fragments();
- assertTrue("No fragment", fragments.size() == 1);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- IVariableBinding variableBinding = fragment.resolveBinding();
- Expression initialization = fragment.getInitializer();
- assertTrue("No an array creation", initialization instanceof ArrayCreation);
- ITypeBinding typeBinding = initialization.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertTrue("Not an array", typeBinding.isArray());
- assertTrue(variableBinding.getType() == typeBinding);
- }
-
- /**
- * Allocation expression
- */
- public void test0181() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0181", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
- List fragments = variableDeclarationStatement.fragments();
- assertTrue("No fragment", fragments.size() == 1);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- IVariableBinding variableBinding = fragment.resolveBinding();
- Expression initialization = fragment.getInitializer();
- ITypeBinding typeBinding = initialization.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertTrue("Not an array", typeBinding.isArray());
- assertTrue(variableBinding.getType() == typeBinding);
- }
-
- /**
- * BinaryExpression
- */
- public void test0182() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0182", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertTrue("IfStatement", node2 instanceof IfStatement);
- IfStatement ifStatement = (IfStatement) node2;
- Expression expr = ifStatement.getExpression();
- assertNotNull("No condition", expr);
- ITypeBinding typeBinding = expr.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Not a boolean", "boolean", typeBinding.getName());
- checkSourceRange(expr, "i < 10", source);
- }
-
- /**
- * BinaryExpression
- */
- public void test0183() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0183", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertTrue("IfStatement", node2 instanceof IfStatement);
- IfStatement ifStatement = (IfStatement) node2;
- Expression expr = ifStatement.getExpression();
- assertNotNull("No condition", expr);
- ITypeBinding typeBinding = expr.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Not a boolean", "boolean", typeBinding.getName());
- checkSourceRange(expr, "i < 10 && i < 20", source);
- }
-
- /**
- * BinaryExpression
- */
- public void test0184() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0184", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertTrue("IfStatement", node2 instanceof IfStatement);
- IfStatement ifStatement = (IfStatement) node2;
- Expression expr = ifStatement.getExpression();
- assertNotNull("No condition", expr);
- ITypeBinding typeBinding = expr.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Not a boolean", "boolean", typeBinding.getName());
- checkSourceRange(expr, "i < 10 || i < 20", source);
- }
-
- /**
- * BinaryExpression
- */
- public void test0185() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0185", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertTrue("IfStatement", node2 instanceof IfStatement);
- IfStatement ifStatement = (IfStatement) node2;
- Expression expr = ifStatement.getExpression();
- assertNotNull("No condition", expr);
- ITypeBinding typeBinding = expr.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Not a boolean", "boolean", typeBinding.getName());
- checkSourceRange(expr, "i == 10", source);
- }
-
- /**
- * BinaryExpression
- */
- public void test0186() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0186", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertTrue("IfStatement", node2 instanceof IfStatement);
- IfStatement ifStatement = (IfStatement) node2;
- Expression expr = ifStatement.getExpression();
- assertNotNull("No condition", expr);
- ITypeBinding typeBinding = expr.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Not a boolean", "boolean", typeBinding.getName());
- checkSourceRange(expr, "o == o", source);
- }
-
- /**
- * BinaryExpression
- */
- public void test0187() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0187", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertTrue("IfStatement", node2 instanceof WhileStatement);
- WhileStatement whileStatement = (WhileStatement) node2;
- Expression expr = whileStatement.getExpression();
- assertNotNull("No condition", expr);
- ITypeBinding typeBinding = expr.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Not a boolean", "boolean", typeBinding.getName());
- checkSourceRange(expr, "i <= 10", source);
- }
-
- /**
- * BinaryExpression
- */
- public void test0188() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0188", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 2);
- assertTrue("DoStatement", node2 instanceof DoStatement);
- DoStatement statement = (DoStatement) node2;
- Expression expr = statement.getExpression();
- assertNotNull("No condition", expr);
- ITypeBinding typeBinding = expr.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Not a boolean", "boolean", typeBinding.getName());
- checkSourceRange(expr, "i <= 10", source);
- }
-
- /**
- * BinaryExpression
- */
- public void test0189() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0189", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("ForStatement", node2 instanceof ForStatement);
- ForStatement statement = (ForStatement) node2;
- Expression expr = statement.getExpression();
- assertNotNull("No condition", expr);
- ITypeBinding typeBinding = expr.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Not a boolean", "boolean", typeBinding.getName());
- checkSourceRange(expr, "i < 10", source);
- }
-
- /**
- * BinaryExpression
- */
- public void test0190() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0190", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 2, 1);
- assertTrue("IfStatement", node2 instanceof IfStatement);
- IfStatement statement = (IfStatement) node2;
- Expression expr = statement.getExpression();
- assertNotNull("No condition", expr);
- ITypeBinding typeBinding = expr.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Not a boolean", "boolean", typeBinding.getName());
- checkSourceRange(expr, "scanner.x < selection.start && selection.start < scanner.y", source);
- }
-
- /**
- * BinaryExpression
- */
- public void test0191() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0191", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertTrue("ExpressionStatement", node2 instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node2;
- Expression ex = expressionStatement.getExpression();
- assertTrue("Assignment", ex instanceof Assignment);
- Assignment statement = (Assignment) ex;
- Expression rightExpr = statement.getRightHandSide();
- assertTrue("Not an infix expression", rightExpr instanceof InfixExpression);
- InfixExpression infixExpression = (InfixExpression) rightExpr;
- Expression expr = infixExpression.getRightOperand();
- assertNotNull("No right hand side expression", expr);
- ITypeBinding typeBinding = expr.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Not a boolean", "boolean", typeBinding.getName());
- checkSourceRange(expr, "2 < 20", source);
- }
-
- /**
- * Initializer
- */
- public void test0192() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0192", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
- List fragments = variableDeclarationStatement.fragments();
- assertTrue("No fragment", fragments.size() == 1);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- IVariableBinding variableBinding = fragment.resolveBinding();
- Expression initialization = fragment.getInitializer();
- ITypeBinding typeBinding = initialization.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertTrue(variableBinding.getType() == typeBinding);
- checkSourceRange(initialization, "0", source);
- }
-
- /**
- * Initializer
- */
- public void test0193() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0193", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 1, 0);
- assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
- List fragments = variableDeclarationStatement.fragments();
- assertTrue("No fragment", fragments.size() == 1);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- IVariableBinding variableBinding = fragment.resolveBinding();
- Expression initialization = fragment.getInitializer();
- ITypeBinding typeBinding = initialization.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertTrue(variableBinding.getType() == typeBinding);
- checkSourceRange(initialization, "new Inner()", source);
- assertEquals("Wrong type", "Inner", typeBinding.getName());
- }
-
- /**
- * Initializer
- */
- public void test0194() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0194", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 1, 0);
- assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
- List fragments = variableDeclarationStatement.fragments();
- assertTrue("No fragment", fragments.size() == 1);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- IVariableBinding variableBinding = fragment.resolveBinding();
- Expression initialization = fragment.getInitializer();
- ITypeBinding typeBinding = initialization.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertTrue(variableBinding.getType() == typeBinding);
- checkSourceRange(initialization, "new Inner[10]", source);
- assertTrue("Not an array", typeBinding.isArray());
- assertEquals("Wrong type", "Inner[]", typeBinding.getName());
- }
-
- /**
- * Initializer
- */
- public void test0195() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0195", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 1, 0, 1);
- assertTrue("ExpressionStatement", node2 instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node2;
- Expression ex = expressionStatement.getExpression();
- assertTrue("MethodInvocation", ex instanceof MethodInvocation);
- MethodInvocation methodInvocation = (MethodInvocation) ex;
- checkSourceRange(methodInvocation, "a.useFile(/*]*/a.getFile()/*[*/)", source);
- List list = methodInvocation.arguments();
- assertTrue("Parameter list not empty", list.size() == 1);
- Expression parameter = (Expression) list.get(0);
- assertTrue("Not a method invocation", parameter instanceof MethodInvocation);
- ITypeBinding typeBinding = parameter.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Not a boolean", "File", typeBinding.getName());
- checkSourceRange(parameter, "a.getFile()", source);
- }
-
- /**
- * Initializer
- */
- public void test0196() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0196", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 1, 2);
- assertTrue("ExpressionStatement", node2 instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node2;
- Expression ex = expressionStatement.getExpression();
- assertTrue("Assignment", ex instanceof Assignment);
- Assignment statement = (Assignment) ex;
- Expression rightExpr = statement.getRightHandSide();
- assertTrue("Not an instanceof expression", rightExpr instanceof InstanceofExpression);
- ITypeBinding typeBinding = rightExpr.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("wrong type", "boolean", typeBinding.getName());
- checkSourceRange(rightExpr, "inner instanceof Inner", source);
- }
-
- /**
- * Initializer
- */
- public void test0197() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0197", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 1, 0, 1);
- assertTrue("ExpressionStatement", node2 instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node2;
- Expression ex = expressionStatement.getExpression();
- assertTrue("MethodInvocation", ex instanceof MethodInvocation);
- MethodInvocation methodInvocation = (MethodInvocation) ex;
- checkSourceRange(methodInvocation, "a.getFile()/*[*/.getName()", source);
- Expression receiver = methodInvocation.getExpression();
- assertTrue("Not a method invocation", receiver instanceof MethodInvocation);
- MethodInvocation methodInvocation2 = (MethodInvocation) receiver;
- ITypeBinding typeBinding = methodInvocation2.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Wrong name", "File", typeBinding.getName());
- checkSourceRange(methodInvocation2, "a.getFile()", source);
- }
-
- /**
- * Initializer
- */
- public void test0198() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0198", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("ReturnStatement", node2 instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node2;
- Expression expr = returnStatement.getExpression();
- assertTrue("Not an infixExpression", expr instanceof InfixExpression);
- InfixExpression infixExpression = (InfixExpression) expr;
- Expression left = infixExpression.getLeftOperand();
- assertTrue("Not an InfixExpression", left instanceof InfixExpression);
- InfixExpression infixExpression2 = (InfixExpression) left;
- Expression right = infixExpression2.getRightOperand();
- assertTrue("Not an InfixExpression", right instanceof InfixExpression);
- InfixExpression infixExpression3 = (InfixExpression) right;
- assertEquals("A multiplication", InfixExpression.Operator.TIMES, infixExpression3.getOperator());
- ITypeBinding typeBinding = infixExpression3.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Not int", "int", typeBinding.getName());
- checkSourceRange(infixExpression3, "20 * 30", source);
- }
-
- /**
- * Initializer
- */
- public void test0199() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0199", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
- List fragments = variableDeclarationStatement.fragments();
- assertTrue("No fragment", fragments.size() == 1);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- Expression initialization = fragment.getInitializer();
- assertTrue("Not an infixExpression", initialization instanceof InfixExpression);
- InfixExpression infixExpression = (InfixExpression) initialization;
- Expression left = infixExpression.getLeftOperand();
- assertTrue("Not an InfixExpression", left instanceof InfixExpression);
- InfixExpression infixExpression2 = (InfixExpression) left;
- Expression right = infixExpression2.getRightOperand();
- assertTrue("Not an InfixExpression", right instanceof InfixExpression);
- InfixExpression infixExpression3 = (InfixExpression) right;
- assertEquals("A multiplication", InfixExpression.Operator.TIMES, infixExpression3.getOperator());
- ITypeBinding typeBinding = infixExpression3.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Not int", "int", typeBinding.getName());
- checkSourceRange(infixExpression3, "10 * 30", source);
- }
-
- /**
- * Initializer
- */
- public void test0200() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0200", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 1, 0, 0);
- assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
- List fragments = variableDeclarationStatement.fragments();
- assertTrue("No fragment", fragments.size() == 1);
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- Expression initialization = fragment.getInitializer();
- assertTrue("Not an infixExpression", initialization instanceof FieldAccess);
- FieldAccess fieldAccess = (FieldAccess) initialization;
- Expression receiver = fieldAccess.getExpression();
- assertTrue("ArrayCreation", receiver instanceof ArrayCreation);
- ArrayCreation arrayCreation = (ArrayCreation) receiver;
- List dimensions = arrayCreation.dimensions();
- assertEquals("Wrong dimension", 1, dimensions.size());
- Expression dim = (Expression) dimensions.get(0);
- assertTrue("InfixExpression", dim instanceof InfixExpression);
- InfixExpression infixExpression = (InfixExpression) dim;
- ITypeBinding typeBinding = infixExpression.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Not int", "int", typeBinding.getName());
- checkSourceRange(infixExpression, "1 + 2", source);
- }
-
- /**
- * Position inside for statement: PR 3300
- */
- public void test0201() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0201", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertTrue("ForStatement", node2 instanceof ForStatement);
- ForStatement forStatement = (ForStatement) node2;
- List initializers = forStatement.initializers();
- assertTrue("wrong size", initializers.size() == 1);
- Expression init = (Expression) initializers.get(0);
- checkSourceRange(init, "int i= 0", source);
- }
-
- /**
- * PR 7386
- */
- public void test0202() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0202", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0);
- assertTrue("FieldDeclaration", node2 instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node2;
- checkSourceRange(fieldDeclaration, "int f= (2);", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- Expression initialization = fragment.getInitializer();
- assertTrue("Not a parenthesized expression", initialization instanceof ParenthesizedExpression);
- checkSourceRange(initialization, "(2)", source);
- ITypeBinding typeBinding = initialization.resolveTypeBinding();
- assertNotNull("no binding", typeBinding);
- assertEquals("not int", "int", typeBinding.getName());
- }
-
- /**
- * PR 7386
- */
- public void test0203() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0203", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0);
- assertTrue("FieldDeclaration", node2 instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node2;
- checkSourceRange(fieldDeclaration, "int f= (2);", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- Expression initialization = fragment.getInitializer();
- assertTrue("Not a parenthesized expression", initialization instanceof ParenthesizedExpression);
- ParenthesizedExpression parenthesizedExpression = (ParenthesizedExpression) initialization;
- checkSourceRange(parenthesizedExpression, "(2)", source);
- Expression expr = parenthesizedExpression.getExpression();
- checkSourceRange(expr, "2", source);
- ITypeBinding typeBinding = expr.resolveTypeBinding();
- assertNotNull("no binding", typeBinding);
- assertEquals("not int", "int", typeBinding.getName());
- assertTrue("type binding is canonical", typeBinding == parenthesizedExpression.resolveTypeBinding());
- }
-
- /**
- * PR 7386
- */
- public void test0204() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0204", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0);
- assertTrue("FieldDeclaration", node2 instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node2;
- checkSourceRange(fieldDeclaration, "int f= ((2));", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- Expression initialization = fragment.getInitializer();
- assertTrue("Not a parenthesized expression", initialization instanceof ParenthesizedExpression);
- ParenthesizedExpression parenthesizedExpression = (ParenthesizedExpression) initialization;
- checkSourceRange(parenthesizedExpression, "((2))", source);
- Expression expr = parenthesizedExpression.getExpression();
- assertTrue("Not a parenthesized expression", expr instanceof ParenthesizedExpression);
- ParenthesizedExpression parenthesizedExpression2 = (ParenthesizedExpression) expr;
- checkSourceRange(parenthesizedExpression2, "(2)", source);
- expr = parenthesizedExpression2.getExpression();
- checkSourceRange(expr, "2", source);
- ITypeBinding typeBinding = expr.resolveTypeBinding();
- assertNotNull("no binding", typeBinding);
- assertEquals("not int", "int", typeBinding.getName());
- typeBinding = parenthesizedExpression.resolveTypeBinding();
- assertNotNull("no binding", typeBinding);
- assertEquals("not int", "int", typeBinding.getName());
- assertTrue("type binding is canonical", typeBinding == parenthesizedExpression2.resolveTypeBinding());
- }
-
-
- /**
- * Local class end position when trailing comment
- */
- public void test0205() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0205", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("TypeDeclarationStatement", node2 instanceof TypeDeclarationStatement);
- TypeDeclarationStatement typeDeclarationStatement = (TypeDeclarationStatement) node2;
- TypeDeclaration typeDeclaration = typeDeclarationStatement.getTypeDeclaration();
- assertEquals("wrong name", "AA", typeDeclaration.getName().getIdentifier());
- checkSourceRange(typeDeclaration, "class AA extends Test {}", source);
- }
-
- /**
- * QualifiedName
- */
- public void test0206() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0206", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 2, 0);
- assertTrue("ReturnStatement", node2 instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node2;
- Expression expr = returnStatement.getExpression();
- assertTrue("Not a qualifiedName", expr instanceof QualifiedName);
- QualifiedName qualifiedName = (QualifiedName) expr;
- ITypeBinding typeBinding = expr.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Not an int (typeBinding)", "int", typeBinding.getName());
- checkSourceRange(qualifiedName, "field.field.field.field.i", source);
- assertTrue("Not a simple name", qualifiedName.getName().isSimpleName());
- SimpleName simpleName = qualifiedName.getName();
- assertTrue("a declaration", !simpleName.isDeclaration());
- checkSourceRange(simpleName, "i", source);
- ITypeBinding typeBinding2 = simpleName.resolveTypeBinding();
- assertNotNull("No typebinding2", typeBinding2);
- assertEquals("Not an int (typeBinding2)", "int", typeBinding2.getName());
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("No binding", binding);
- assertTrue("VariableBinding", binding instanceof IVariableBinding);
- IVariableBinding variableBinding = (IVariableBinding) binding;
- assertEquals("Not Test", "Test", variableBinding.getDeclaringClass().getName());
- assertEquals("Not default", Modifier.PUBLIC, variableBinding.getModifiers());
- Name qualifierName = qualifiedName.getQualifier();
- assertTrue("Not a qualified name", qualifierName.isQualifiedName());
- checkSourceRange(qualifierName, "field.field.field.field", source);
- ITypeBinding typeBinding5 = qualifierName.resolveTypeBinding();
- assertNotNull("No binding5", typeBinding5);
- assertEquals("Not Test", "Test", typeBinding5.getName());
-
- qualifiedName = (QualifiedName) qualifierName;
- simpleName = qualifiedName.getName();
- checkSourceRange(simpleName, "field", source);
- ITypeBinding typeBinding6 = simpleName.resolveTypeBinding();
- assertNotNull("No binding6", typeBinding6);
- assertEquals("Not Test", "Test", typeBinding6.getName());
-
- qualifierName = qualifiedName.getQualifier();
- assertTrue("Not a qualified name", qualifierName.isQualifiedName());
- checkSourceRange(qualifierName, "field.field.field", source);
- ITypeBinding typeBinding7 = qualifierName.resolveTypeBinding();
- assertNotNull("No binding7", typeBinding7);
- assertEquals("Not Test", "Test", typeBinding7.getName());
-
- qualifiedName = (QualifiedName) qualifierName;
- simpleName = qualifiedName.getName();
- checkSourceRange(simpleName, "field", source);
- qualifierName = qualifiedName.getQualifier();
- assertTrue("Not a qualified name", qualifierName.isQualifiedName());
- checkSourceRange(qualifierName, "field.field", source);
- ITypeBinding typeBinding3 = qualifierName.resolveTypeBinding();
- assertNotNull("No binding3", typeBinding3);
- assertEquals("Not Test", "Test", typeBinding3.getName());
- qualifiedName = (QualifiedName) qualifierName;
- simpleName = qualifiedName.getName();
- checkSourceRange(simpleName, "field", source);
- qualifierName = qualifiedName.getQualifier();
- assertTrue("Not a simple name", qualifierName.isSimpleName());
- assertTrue("a declaration", !((SimpleName)qualifierName).isDeclaration());
- checkSourceRange(qualifierName, "field", source);
- ITypeBinding typeBinding4 = qualifierName.resolveTypeBinding();
- assertNotNull("No binding4", typeBinding4);
- assertEquals("Not Test", "Test", typeBinding4.getName());
- }
-
- /**
- * Check javadoc for MethodDeclaration
- */
- public void test0207() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0207", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a MethodDeclaration", node instanceof MethodDeclaration);
- Javadoc actualJavadoc = ((MethodDeclaration) node).getJavadoc();
- Javadoc javadoc = this.ast.newJavadoc();
- javadoc.setComment("/** JavaDoc Comment\r\n */");//$NON-NLS-1$*/
- assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
- checkSourceRange(node, "/** JavaDoc Comment\r\n */\r\n void foo(final int i) {}", source); //$NON-NLS-1$
- checkSourceRange(actualJavadoc, "/** JavaDoc Comment\r\n */", source);
- }
-
- /**
- * Check javadoc for MethodDeclaration
- */
- public void test0208() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0208", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a MethodDeclaration", node instanceof MethodDeclaration);
- Javadoc actualJavadoc = ((MethodDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- checkSourceRange(node, "void foo(final int i) {}", source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for MethodDeclaration
- */
- public void test0209() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0209", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a MethodDeclaration", node instanceof MethodDeclaration);
- Javadoc actualJavadoc = ((MethodDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- checkSourceRange(node, "void foo(final int i) {}", source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for FieldDeclaration
- */
- public void test0210() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0210", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration);
- Javadoc actualJavadoc = ((FieldDeclaration) node).getJavadoc();
- Javadoc javadoc = this.ast.newJavadoc();
- javadoc.setComment("/** JavaDoc Comment\r\n */");//$NON-NLS-1$*/
- assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
- checkSourceRange(node, "/** JavaDoc Comment\r\n */\r\n int i;", source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for FieldDeclaration
- */
- public void test0211() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0211", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration);
- Javadoc actualJavadoc = ((FieldDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- checkSourceRange(node, "int i;", source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for FieldDeclaration
- */
- public void test0212() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0212", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration);
- Javadoc actualJavadoc = ((FieldDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- checkSourceRange(node, "int i;", source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for TypeDeclaration
- */
- public void test0213() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0213", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration);
- Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- String expectedContents = "public class Test {\r\n" +//$NON-NLS-1$
- " int i;\r\n" +//$NON-NLS-1$
- "}";//$NON-NLS-1$
- checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for TypeDeclaration
- */
- public void test0214() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0214", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration);
- Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- String expectedContents = "public class Test {\r\n" +//$NON-NLS-1$
- " int i;\r\n" +//$NON-NLS-1$
- "}";//$NON-NLS-1$
- checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for TypeDeclaration
- */
- public void test0215() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0215", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration);
- Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
- Javadoc javadoc = this.ast.newJavadoc();
- javadoc.setComment("/** JavaDoc Comment\r\n */");//$NON-NLS-1$*/
- assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
- String expectedContents =
- "/** JavaDoc Comment\r\n" + //$NON-NLS-1$
- " */\r\n" + //$NON-NLS-1$
- "public class Test {\r\n" +//$NON-NLS-1$
- " int i;\r\n" +//$NON-NLS-1$
- "}";//$NON-NLS-1$
- checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
- checkSourceRange(actualJavadoc, "/** JavaDoc Comment\r\n */", source);
- }
-
- /**
- * Check javadoc for MemberTypeDeclaration
- */
- public void test0216() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0216", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration);
- Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
- Javadoc javadoc = this.ast.newJavadoc();
- javadoc.setComment("/** JavaDoc Comment\r\n */");//$NON-NLS-1$*/
- assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
- String expectedContents =
- "/** JavaDoc Comment\r\n" + //$NON-NLS-1$
- " */\r\n" + //$NON-NLS-1$
- " class B {}";//$NON-NLS-1$
- checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
- checkSourceRange(actualJavadoc, "/** JavaDoc Comment\r\n */", source);
- }
-
- /**
- * Check javadoc for MemberTypeDeclaration
- */
- public void test0217() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0217", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration);
- Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- checkSourceRange(node, "class B {}", source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for MemberTypeDeclaration
- */
- public void test0218() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0218", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration);
- Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- checkSourceRange(node, "public static class B {}", source); //$NON-NLS-1$
- }
-
- /**
- * Check javadoc for MemberTypeDeclaration
- */
- public void test0219() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0219", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration);
- Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
- assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
- checkSourceRange(node, "public static class B {}", source); //$NON-NLS-1$
- }
-
- /**
- * Checking initializers
- */
- public void test0220() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0220", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- checkSourceRange(node, "{}", source); //$NON-NLS-1$
- }
-
- /**
- * Checking initializers
- */
- public void test0221() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0221", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- checkSourceRange(node, "static {}", source); //$NON-NLS-1$
- }
-
- /**
- * Checking initializers
- */
- public void test0222() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0222", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Javadoc actualJavadoc = ((Initializer) node).getJavadoc();
- assertNotNull("Javadoc comment should no be null", actualJavadoc); //$NON-NLS-1$
- Javadoc javadoc = this.ast.newJavadoc();
- javadoc.setComment("/** JavaDoc Comment\r\n */");//$NON-NLS-1$*/
- assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
- String expectedContents =
- "/** JavaDoc Comment\r\n" + //$NON-NLS-1$
- " */\r\n" + //$NON-NLS-1$
- " static {}";//$NON-NLS-1$
- checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
- checkSourceRange(actualJavadoc, "/** JavaDoc Comment\r\n */", source);
-
- }
-
- /**
- * Checking initializers
- */
- public void test0223() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0223", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Javadoc actualJavadoc = ((Initializer) node).getJavadoc();
- assertNotNull("Javadoc comment should not be null", actualJavadoc); //$NON-NLS-1$
- Javadoc javadoc = this.ast.newJavadoc();
- javadoc.setComment("/** JavaDoc Comment\r\n */");//$NON-NLS-1$*/
- assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
- String expectedContents =
- "/** JavaDoc Comment\r\n" + //$NON-NLS-1$
- " */\r\n" + //$NON-NLS-1$
- " {}";//$NON-NLS-1$
- checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
- checkSourceRange(actualJavadoc, "/** JavaDoc Comment\r\n */", source);
-
- }
-
- /**
- * Checking initializers
- */
- public void test0224() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0224", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- Javadoc actualJavadoc = ((Initializer) node).getJavadoc();
- assertNull("Javadoc comment should be null", actualJavadoc); //$NON-NLS-1$
- checkSourceRange(node, "{}", source); //$NON-NLS-1$
- }
-
- /**
- * Continue ==> ContinueStatement
- */
- public void test0225() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0225", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- LabeledStatement labeledStatement = (LabeledStatement) getASTNode((CompilationUnit) result, 0, 0, 0);
- checkSourceRange(labeledStatement.getLabel(), "label", source);
- ForStatement forStatement = (ForStatement) labeledStatement.getBody();
- ContinueStatement statement = (ContinueStatement) ((Block) forStatement.getBody()).statements().get(0);
- assertNotNull("Expression should not be null", statement); //$NON-NLS-1$
- ContinueStatement continueStatement = this.ast.newContinueStatement();
- continueStatement.setLabel(this.ast.newSimpleName("label"));
- assertTrue("Both AST trees should be identical", continueStatement.subtreeMatch(new ASTMatcher(), statement)); //$NON-NLS-1$
- checkSourceRange(statement, "continue label;", source); //$NON-NLS-1$
- checkSourceRange(statement.getLabel(), "label", source);
- }
-
- /**
- * Break + label ==> BreakStatement
- */
- public void test0226() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0226", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- LabeledStatement labeledStatement = (LabeledStatement) getASTNode((CompilationUnit) result, 0, 0, 0);
- checkSourceRange(labeledStatement.getLabel(), "label", source);
- ForStatement forStatement = (ForStatement) labeledStatement.getBody();
- BreakStatement statement = (BreakStatement) ((Block) forStatement.getBody()).statements().get(0);
- assertNotNull("Expression should not be null", statement); //$NON-NLS-1$
- BreakStatement breakStatement = this.ast.newBreakStatement();
- breakStatement.setLabel(this.ast.newSimpleName("label")); //$NON-NLS-1$
- assertTrue("Both AST trees should be identical", breakStatement.subtreeMatch(new ASTMatcher(), statement)); //$NON-NLS-1$
- checkSourceRange(statement, "break label;", source); //$NON-NLS-1$
- checkSourceRange(statement.getLabel(), "label", source);
- }
-
- /**
- * QualifiedName
- */
- public void test0227() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0227", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 3, 2, 0);
- assertTrue("ReturnStatement", node2 instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node2;
- Expression expr = returnStatement.getExpression();
- assertTrue("Not a qualifiedName", expr instanceof QualifiedName);
- QualifiedName qualifiedName = (QualifiedName) expr;
- ITypeBinding typeBinding = expr.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Not an long (typeBinding)", "long", typeBinding.getName());
- checkSourceRange(qualifiedName, "field.fB.fA.j", source);
-
- SimpleName simpleName = qualifiedName.getName();
- checkSourceRange(simpleName, "j", source);
- ITypeBinding typeBinding2 = simpleName.resolveTypeBinding();
- assertEquals("Not an long (typeBinding2)", "long", typeBinding2.getName());
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("No binding", binding);
- assertTrue("VariableBinding", binding instanceof IVariableBinding);
- IVariableBinding variableBinding = (IVariableBinding) binding;
- assertEquals("Not A", "A", variableBinding.getDeclaringClass().getName());
- assertEquals("Not default", Modifier.NONE, variableBinding.getModifiers());
- assertEquals("wrong name", "j", variableBinding.getName());
-
- Name qualifierName = qualifiedName.getQualifier();
- assertTrue("Not a qualified name", qualifierName.isQualifiedName());
- checkSourceRange(qualifierName, "field.fB.fA", source);
- qualifiedName = (QualifiedName) qualifierName;
- ITypeBinding typeBinding3 = qualifiedName.resolveTypeBinding();
- assertNotNull("No type binding3", typeBinding3);
- assertEquals("Not an A", "A", typeBinding3.getName());
- simpleName = qualifiedName.getName();
- checkSourceRange(simpleName, "fA", source);
- ITypeBinding typeBinding4 = simpleName.resolveTypeBinding();
- assertNotNull("No typeBinding4", typeBinding4);
- assertEquals("Not an A", "A", typeBinding4.getName());
- IBinding binding2 = qualifiedName.resolveBinding();
- assertNotNull("No binding2", binding2);
- assertTrue("VariableBinding", binding2 instanceof IVariableBinding);
- IVariableBinding variableBinding2 = (IVariableBinding) binding2;
- assertEquals("Not B", "B", variableBinding2.getDeclaringClass().getName());
- assertEquals("Not default", Modifier.NONE, variableBinding2.getModifiers());
- assertEquals("wrong name", "fA", variableBinding2.getName());
-
- qualifierName = qualifiedName.getQualifier();
- assertTrue("Not a qualified name", qualifierName.isQualifiedName());
- checkSourceRange(qualifierName, "field.fB", source);
- qualifiedName = (QualifiedName) qualifierName;
- ITypeBinding typeBinding5 = qualifiedName.resolveTypeBinding();
- assertNotNull("No typeBinding5", typeBinding5);
- assertEquals("Not a B", "B", typeBinding5.getName());
- simpleName = qualifiedName.getName();
- checkSourceRange(simpleName, "fB", source);
- ITypeBinding typeBinding6 = simpleName.resolveTypeBinding();
- assertNotNull("No typebinding6", typeBinding6);
- assertEquals("not a B", "B", typeBinding6.getName());
- IBinding binding3 = qualifiedName.resolveBinding();
- assertNotNull("No binding2", binding3);
- assertTrue("VariableBinding", binding3 instanceof IVariableBinding);
- IVariableBinding variableBinding3 = (IVariableBinding) binding3;
- assertEquals("Not C", "C", variableBinding3.getDeclaringClass().getName());
- assertEquals("Not default", Modifier.NONE, variableBinding3.getModifiers());
- assertEquals("wrong name", "fB", variableBinding3.getName());
-
- qualifierName = qualifiedName.getQualifier();
- assertTrue("Not a simple name", qualifierName.isSimpleName());
- checkSourceRange(qualifierName, "field", source);
- simpleName = (SimpleName) qualifierName;
- ITypeBinding typeBinding7 = simpleName.resolveTypeBinding();
- assertNotNull("No typeBinding7", typeBinding7);
- assertEquals("Not a C", "C", typeBinding7.getName());
- IBinding binding4 = simpleName.resolveBinding();
- assertNotNull("No binding4", binding4);
- assertTrue("VariableBinding", binding4 instanceof IVariableBinding);
- IVariableBinding variableBinding4 = (IVariableBinding) binding4;
- assertEquals("Not Test", "Test", variableBinding4.getDeclaringClass().getName());
- assertEquals("Not public", Modifier.PUBLIC, variableBinding4.getModifiers());
- assertEquals("wrong name", "field", variableBinding4.getName());
- assertEquals("wrong return type", "C", variableBinding4.getType().getName());
- }
-
- /**
- * QualifiedName as TypeReference
- */
- public void test0228() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0228", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 1, 0);
- assertTrue("ReturnStatement", node2 instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node2;
- Expression expr = returnStatement.getExpression();
- checkSourceRange(expr, "test0228.Test.foo()", source);
- assertTrue("MethodInvocation", expr instanceof MethodInvocation);
- MethodInvocation methodInvocation = (MethodInvocation) expr;
- Expression qualifier = methodInvocation.getExpression();
- assertNotNull("no qualifier", qualifier);
- assertTrue("QualifiedName", qualifier instanceof QualifiedName);
- QualifiedName qualifiedName = (QualifiedName) qualifier;
- checkSourceRange(qualifiedName, "test0228.Test", source);
- ITypeBinding typeBinding = qualifiedName.resolveTypeBinding();
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong type", "Test", typeBinding.getName());
- IBinding binding = qualifiedName.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Not a type", IBinding.TYPE, binding.getKind());
-
- }
-
- /**
- * MethodInvocation
- */
- public void test0229() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0229", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("ExpressionStatement", node2 instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node2;
- Expression expr = expressionStatement.getExpression();
- assertTrue("MethodInvocation", expr instanceof MethodInvocation);
- checkSourceRange(expr, "System.err.println()", source);
- MethodInvocation methodInvocation = (MethodInvocation) expr;
- Expression qualifier = methodInvocation.getExpression();
- assertTrue("QualifiedName", qualifier instanceof QualifiedName);
- QualifiedName qualifiedName = (QualifiedName) qualifier;
- ITypeBinding typeBinding = qualifier.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong name", "PrintStream", typeBinding.getName());
- IBinding binding = qualifiedName.resolveBinding();
- assertNotNull("No binding", binding);
- assertTrue("VariableBinding", binding instanceof IVariableBinding);
- IVariableBinding variableBinding = (IVariableBinding) binding;
- assertEquals("wrong name", "err", variableBinding.getName());
- SimpleName methodName = methodInvocation.getName();
- IBinding binding2 = methodName.resolveBinding();
- assertNotNull("No binding2", binding2);
- }
-
- /**
- * MethodInvocation
- */
- public void test0230() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0230", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 1, 0);
- assertTrue("ExpressionStatement", node2 instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node2;
- Expression expr = expressionStatement.getExpression();
- assertTrue("MethodInvocation", expr instanceof MethodInvocation);
- checkSourceRange(expr, "err.println()", source);
- MethodInvocation methodInvocation = (MethodInvocation) expr;
- Expression qualifier = methodInvocation.getExpression();
- assertTrue("SimpleName", qualifier instanceof SimpleName);
- SimpleName name = (SimpleName) qualifier;
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong name", "err", binding.getName());
- ITypeBinding typeBinding = name.resolveTypeBinding();
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wron type name", "PrintStream", typeBinding.getName());
- }
-
- /**
- * MethodInvocation
- */
- public void test0231() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0231", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("ExpressionStatement", node2 instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node2;
- Expression expr = expressionStatement.getExpression();
- assertTrue("MethodInvocation", expr instanceof MethodInvocation);
- checkSourceRange(expr, "System.err.println()", source);
- MethodInvocation methodInvocation = (MethodInvocation) expr;
- Expression qualifier = methodInvocation.getExpression();
- assertTrue("QualifiedName", qualifier instanceof QualifiedName);
- QualifiedName qualifiedName = (QualifiedName) qualifier;
- ITypeBinding typeBinding = qualifier.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong name", "PrintStream", typeBinding.getName());
- IBinding binding = qualifiedName.resolveBinding();
- assertNotNull("No binding", binding);
- assertTrue("VariableBinding", binding instanceof IVariableBinding);
- IVariableBinding variableBinding = (IVariableBinding) binding;
- assertEquals("wrong name", "err", variableBinding.getName());
- SimpleName methodName = methodInvocation.getName();
- IBinding binding2 = methodName.resolveBinding();
- assertNotNull("No binding2", binding2);
- Name name = qualifiedName.getQualifier();
- assertTrue("SimpleName", name.isSimpleName());
- SimpleName simpleName = (SimpleName) name;
- ITypeBinding typeBinding2 = simpleName.resolveTypeBinding();
- assertNotNull("No typeBinding2", typeBinding2);
- assertEquals("wrong type name", "System", typeBinding2.getName());
- }
-
- /**
- * MethodInvocation
- */
- public void test0232() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0232", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression initialization = variableDeclarationFragment.getInitializer();
- ITypeBinding typeBinding = initialization.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertTrue("Not a primitive type", typeBinding.isPrimitive());
- assertEquals("wrong name", "int", typeBinding.getName());
- assertTrue("QualifiedName", initialization instanceof QualifiedName);
- QualifiedName qualifiedName = (QualifiedName) initialization;
- SimpleName simpleName = qualifiedName.getName();
- ITypeBinding typeBinding2 = simpleName.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding2);
- assertTrue("Not a primitive type", typeBinding2.isPrimitive());
- assertEquals("wrong name", "int", typeBinding2.getName());
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("No binding", binding);
- assertTrue("IVariableBinding", binding instanceof IVariableBinding);
- IVariableBinding variableBinding = (IVariableBinding) binding;
- assertNull("No declaring class", variableBinding.getDeclaringClass());
- }
-
- /**
- * Checking that only syntax errors are reported for the MALFORMED tag
- */
- public void test0233() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0233", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("Expression should not be null", result); //$NON-NLS-1$
- assertTrue("The compilation unit is malformed", !isMalformed(result));
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit unit = (CompilationUnit) result;
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertTrue("The fiels is not malformed", !isMalformed(node));
- assertEquals("No problem found", 1, unit.getMessages().length);
- assertEquals("No problem found", 1, unit.getProblems().length);
- }
-
- /**
- * Checking that null is returned for a resolveBinding if the type is unknown
- */
- public void test0234() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0234", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertTrue("The fiels is not malformed", !isMalformed(node));
- CompilationUnit unit = (CompilationUnit) result;
- assertEquals("No problem found", 1, unit.getMessages().length);
- assertEquals("No problem found", 1, unit.getProblems().length);
- assertTrue("FieldDeclaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- List fragments = fieldDeclaration.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- IVariableBinding variableBinding = fragment.resolveBinding();
- assertNull("binding not null", variableBinding);
- }
-
- /**
- * Checking that null is returned for a resolveBinding if the type is unknown
- */
- public void test0235() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0235", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertTrue("The fiels is not malformed", !isMalformed(node));
- CompilationUnit unit = (CompilationUnit) result;
- assertEquals("problems found", 0, unit.getMessages().length);
- assertEquals("problems found", 0, unit.getProblems().length);
- assertTrue("FieldDeclaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- List fragments = fieldDeclaration.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
- IVariableBinding variableBinding = fragment.resolveBinding();
- assertNotNull("No binding", variableBinding);
- }
-
- /**
- * Test the removal of a IField inside a CU that has an initializer
- */
- public void test0236() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0236", "Test.java");
- IType type = sourceUnit.getType("Test");
- assertNotNull("No type", type);
- IField field = type.getField("i");
- assertNotNull("No field", field);
- field.delete(true, null);
- }
-
- /**
- * http://bugs.eclipse.org/bugs/show_bug.cgi?id=9452
- */
- public void test0237() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "junit.framework", "TestCase.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- }
-
- /**
- * Check ThisExpression
- */
- public void test0238() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0238", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- char[] source = sourceUnit.getSource().toCharArray();
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("Not a type declaration statement", node instanceof TypeDeclarationStatement);
- TypeDeclarationStatement typeDeclarationStatement = (TypeDeclarationStatement) node;
- TypeDeclaration typeDecl = typeDeclarationStatement.getTypeDeclaration();
- Object o = typeDecl.bodyDeclarations().get(0);
- assertTrue("Not a method", o instanceof MethodDeclaration);
- MethodDeclaration methodDecl = (MethodDeclaration) o;
- Block block = methodDecl.getBody();
- List statements = block.statements();
- assertEquals("Not 1", 1, statements.size());
- Statement stmt = (Statement) statements.get(0);
- assertTrue("Not a return statement", stmt instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) stmt;
- Expression expr = returnStatement.getExpression();
- assertTrue("Not a method invocation", expr instanceof MethodInvocation);
- MethodInvocation methodInvocation = (MethodInvocation) expr;
- checkSourceRange(methodInvocation, "Test.this.bar()", source);
- Expression qualifier = methodInvocation.getExpression();
- assertTrue("Not a ThisExpression", qualifier instanceof ThisExpression);
- ThisExpression thisExpression = (ThisExpression) qualifier;
- Name name = thisExpression.getQualifier();
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("wrong name", "Test", binding.getName());
- }
-
- /**
- * Check ThisExpression
- */
- public void test0239() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0239", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 1, 0, 0);
- assertTrue("Not a type declaration statement", node instanceof TypeDeclarationStatement);
- TypeDeclarationStatement typeDeclarationStatement = (TypeDeclarationStatement) node;
- TypeDeclaration typeDecl = typeDeclarationStatement.getTypeDeclaration();
- Object o = typeDecl.bodyDeclarations().get(0);
- assertTrue("Not a method", o instanceof MethodDeclaration);
- MethodDeclaration methodDecl = (MethodDeclaration) o;
- Block block = methodDecl.getBody();
- List statements = block.statements();
- assertEquals("Not 1", 1, statements.size());
- Statement stmt = (Statement) statements.get(0);
- assertTrue("Not a return statement", stmt instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) stmt;
- Expression expr = returnStatement.getExpression();
- assertTrue("Not a SuperMethodInvocation", expr instanceof SuperMethodInvocation);
- SuperMethodInvocation superMethodInvocation = (SuperMethodInvocation) expr;
- Name name = superMethodInvocation.getQualifier();
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding", binding);
- assertTrue("A type binding", binding instanceof ITypeBinding);
- assertEquals("Not Test", "Test", binding.getName());
- Name methodName = superMethodInvocation.getName();
- IBinding binding2 = methodName.resolveBinding();
- assertNotNull("No binding2", binding2);
- assertTrue("No an IMethodBinding", binding2 instanceof IMethodBinding);
- IMethodBinding methodBinding = (IMethodBinding) binding2;
- assertEquals("Not bar", "bar", methodBinding.getName());
- assertEquals("Not T", "T", methodBinding.getDeclaringClass().getName());
- }
-
- /**
- * Check FieldAccess
- */
- public void test0240() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0240", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("Not a type declaration statement", node instanceof TypeDeclarationStatement);
- TypeDeclarationStatement typeDeclarationStatement = (TypeDeclarationStatement) node;
- TypeDeclaration typeDecl = typeDeclarationStatement.getTypeDeclaration();
- Object o = typeDecl.bodyDeclarations().get(0);
- assertTrue("Not a method", o instanceof MethodDeclaration);
- MethodDeclaration methodDecl = (MethodDeclaration) o;
- Block block = methodDecl.getBody();
- List statements = block.statements();
- assertEquals("Not 1", 1, statements.size());
- Statement stmt = (Statement) statements.get(0);
- assertTrue("Not a return statement", stmt instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) stmt;
- Expression expr = returnStatement.getExpression();
- assertTrue("Not a field access", expr instanceof FieldAccess);
- FieldAccess fieldAccess = (FieldAccess) expr;
- Expression qualifier = fieldAccess.getExpression();
- assertTrue("Not a ThisExpression", qualifier instanceof ThisExpression);
- ThisExpression thisExpression = (ThisExpression) qualifier;
- Name name = thisExpression.getQualifier();
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Not Test", "Test", binding.getName());
- Name fieldName = fieldAccess.getName();
- IBinding binding2 = fieldName.resolveBinding();
- assertNotNull("No binding2", binding2);
- assertEquals("Wrong name", "f", binding2.getName());
- assertEquals("Wrong modifier", Modifier.PUBLIC, binding2.getModifiers());
- ITypeBinding typeBinding = fieldName.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Not int", "int", typeBinding.getName());
- }
-
- /**
- * Check order of body declarations
- */
- public void test0241() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0241", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0);
- assertTrue("Not a type declaration", node instanceof TypeDeclaration);
- assertTrue("Not a declaration", ((TypeDeclaration) node).getName().isDeclaration());
- assertEquals("Wrong size", 11, ((TypeDeclaration)node).bodyDeclarations().size());
- node = getASTNode((CompilationUnit) result, 0, 0);
- assertTrue("Not a field declaration", node instanceof FieldDeclaration);
- node = getASTNode((CompilationUnit) result, 0, 1);
- assertTrue("Not a MethodDeclaration", node instanceof MethodDeclaration);
- node = getASTNode((CompilationUnit) result, 0, 2);
- assertTrue("Not a Type declaration", node instanceof TypeDeclaration);
- node = getASTNode((CompilationUnit) result, 0, 3);
- assertTrue("Not a Type declaration", node instanceof TypeDeclaration);
- node = getASTNode((CompilationUnit) result, 0, 4);
- assertTrue("Not a MethodDeclaration", node instanceof MethodDeclaration);
- node = getASTNode((CompilationUnit) result, 0, 5);
- assertTrue("Not a field declaration", node instanceof FieldDeclaration);
- node = getASTNode((CompilationUnit) result, 0, 6);
- assertTrue("Not a MethodDeclaration", node instanceof MethodDeclaration);
- node = getASTNode((CompilationUnit) result, 0, 7);
- assertTrue("Not a field declaration", node instanceof FieldDeclaration);
- node = getASTNode((CompilationUnit) result, 0, 8);
- assertTrue("Not a field declaration", node instanceof FieldDeclaration);
- node = getASTNode((CompilationUnit) result, 0, 9);
- assertTrue("Not a MethodDeclaration", node instanceof MethodDeclaration);
- node = getASTNode((CompilationUnit) result, 0, 10);
- assertTrue("Not a Type declaration", node instanceof TypeDeclaration);
- }
-
- /**
- * Check ThisExpression
- */
- public void test0242() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0242", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 1, 0, 0);
- assertTrue("Not a type declaration statement", node instanceof TypeDeclarationStatement);
- TypeDeclarationStatement typeDeclarationStatement = (TypeDeclarationStatement) node;
- TypeDeclaration typeDecl = typeDeclarationStatement.getTypeDeclaration();
- Object o = typeDecl.bodyDeclarations().get(0);
- assertTrue("Not a method", o instanceof MethodDeclaration);
- MethodDeclaration methodDecl = (MethodDeclaration) o;
- Block block = methodDecl.getBody();
- List statements = block.statements();
- assertEquals("Not 1", 1, statements.size());
- Statement stmt = (Statement) statements.get(0);
- assertTrue("Not a return statement", stmt instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) stmt;
- Expression expr = returnStatement.getExpression();
- assertTrue("Not a SuperFieldAccess", expr instanceof SuperFieldAccess);
- SuperFieldAccess superFieldAccess = (SuperFieldAccess) expr;
- Name name = superFieldAccess.getQualifier();
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding", binding);
- assertTrue("A type binding", binding instanceof ITypeBinding);
- assertEquals("Not Test", "Test", binding.getName());
- Name fieldName = superFieldAccess.getName();
- IBinding binding2 = fieldName.resolveBinding();
- assertNotNull("No binding2", binding2);
- assertTrue("No an IVariableBinding", binding2 instanceof IVariableBinding);
- IVariableBinding variableBinding = (IVariableBinding) binding2;
- assertEquals("Not f", "f", variableBinding.getName());
- assertEquals("Not T", "T", variableBinding.getDeclaringClass().getName());
- ITypeBinding typeBinding2 = fieldName.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding2);
- assertEquals("Not int", "int", typeBinding2.getName());
- }
-
- /**
- * Check catch clause positions:
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10570
- */
- public void test0243() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0243", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("Not a try statement", node instanceof TryStatement);
- TryStatement tryStatement = (TryStatement) node;
- List catchClauses = tryStatement.catchClauses();
- assertEquals("wrong size", 1, catchClauses.size());
- CatchClause catchClause = (CatchClause) catchClauses.get(0);
- checkSourceRange(catchClause, "catch (Exception e){m();}", source);
- }
-
- /**
- * Check catch clause positions:
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10570
- */
- public void test0244() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0244", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("Not a try statement", node instanceof TryStatement);
- TryStatement tryStatement = (TryStatement) node;
- List catchClauses = tryStatement.catchClauses();
- assertEquals("wrong size", 2, catchClauses.size());
- CatchClause catchClause = (CatchClause) catchClauses.get(0);
- checkSourceRange(catchClause, "catch (RuntimeException e){m();}", source);
- catchClause = (CatchClause) catchClauses.get(1);
- checkSourceRange(catchClause, "catch(Exception e) {}", source);
- }
-
- /**
- * http://bugs.eclipse.org/bugs/show_bug.cgi?id=10587
- */
- public void test0245() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0245", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit unit = (CompilationUnit) result;
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertTrue("Not a return statement", node instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node;
- Expression expr = returnStatement.getExpression();
- assertTrue("not a name", expr instanceof Name);
- Name name = (Name) expr;
- IBinding binding = name.resolveBinding();
- assertTrue("Not a variable binding", binding instanceof IVariableBinding);
- IVariableBinding variableBinding = (IVariableBinding) binding;
- assertEquals("Not i", "i", variableBinding.getName());
- assertEquals("Not int", "int", variableBinding.getType().getName());
- ASTNode declaringNode = unit.findDeclaringNode(variableBinding);
- assertNotNull("No declaring node", declaringNode);
- assertTrue("Not a VariableDeclarationFragment", declaringNode instanceof VariableDeclarationFragment);
- }
-
- /**
- * Test binding resolution for import declaration
- */
- public void test0246() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0246", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit unit = (CompilationUnit) result;
- List imports = unit.imports();
- assertEquals("wrong imports size", 2, imports.size());
- ImportDeclaration importDeclaration = (ImportDeclaration) imports.get(0);
- assertTrue("Not on demand", importDeclaration.isOnDemand());
- checkSourceRange(importDeclaration, "import java.util.*;", source);
- IBinding binding = importDeclaration.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong type", IBinding.PACKAGE, binding.getKind());
- assertEquals("Wrong name", "java.util", binding.getName());
- importDeclaration = (ImportDeclaration) imports.get(1);
- assertTrue("On demand", !importDeclaration.isOnDemand());
- checkSourceRange(importDeclaration, "import java.io.IOException;", source);
- binding = importDeclaration.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong type", IBinding.TYPE, binding.getKind());
- assertEquals("Wrong name", "IOException", binding.getName());
- }
-
- /**
- * Test binding resolution for import declaration
- */
- public void test0247() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0247", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit unit = (CompilationUnit) result;
- PackageDeclaration packageDeclaration = unit.getPackage();
- checkSourceRange(packageDeclaration, "package test0247;", source);
- IPackageBinding binding = packageDeclaration.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong type", IBinding.PACKAGE, binding.getKind());
- assertEquals("Wrong name", "test0247", binding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10592
- */
- public void test0248() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0248", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertTrue("Not a method declaration", node instanceof MethodDeclaration);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- List parameters = methodDeclaration.parameters();
- assertEquals("wrong size", 1, parameters.size());
- SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
- Name name = singleVariableDeclaration.getName();
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding", binding);
- assertTrue("Not a variable binding", binding instanceof IVariableBinding);
- IVariableBinding variableBinding = (IVariableBinding) binding;
- assertEquals("Wrong name", "i", variableBinding.getName());
- assertEquals("Wrong type", "int", variableBinding.getType().getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10592
- */
- public void test0249() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0249", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 2, 1);
- assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression expression = expressionStatement.getExpression();
- assertTrue("Not an assignment", expression instanceof Assignment);
- Assignment assignment = (Assignment) expression;
- Expression leftHandSide = assignment.getLeftHandSide();
- assertTrue("Not a qualified name", leftHandSide instanceof QualifiedName);
- QualifiedName qualifiedName = (QualifiedName) leftHandSide;
- Name simpleName = qualifiedName.getName();
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("no binding", binding);
- assertTrue("Not a IVariableBinding", binding instanceof IVariableBinding);
- IVariableBinding variableBinding = (IVariableBinding) binding;
- assertEquals("Wrong name", "k", variableBinding.getName());
- assertEquals("Wrong modifier", Modifier.STATIC, variableBinding.getModifiers());
- assertEquals("Wrong type", "int", variableBinding.getType().getName());
- assertEquals("Wrong declaring class name", "j", variableBinding.getDeclaringClass().getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10592
- */
- public void test0250() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0250", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertTrue("Not a method declaration", node instanceof MethodDeclaration);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- List parameters = methodDeclaration.parameters();
- assertEquals("wrong size", 2, parameters.size());
- SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
- Name name = singleVariableDeclaration.getName();
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding", binding);
- assertTrue("Not a variable binding", binding instanceof IVariableBinding);
- IVariableBinding variableBinding = (IVariableBinding) binding;
- assertEquals("Wrong name", "i", variableBinding.getName());
- assertEquals("Wrong type", "int", variableBinding.getType().getName());
- }
-
- /**
- * Check qualified name resolution for static fields
- */
- public void test0251() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0251", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("Not a ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression expression = expressionStatement.getExpression();
- assertTrue("Not a method invocation", expression instanceof MethodInvocation);
- MethodInvocation methodInvocation = (MethodInvocation) expression;
- checkSourceRange(methodInvocation, "java.lang.System.out.println()", source);
- Expression qualifier = methodInvocation.getExpression();
- assertTrue("Not a qualified name", qualifier instanceof QualifiedName);
- checkSourceRange(qualifier, "java.lang.System.out", source);
- QualifiedName qualifiedName = (QualifiedName) qualifier;
- Name typeName = qualifiedName.getQualifier();
- assertTrue("Not a QualifiedName", typeName instanceof QualifiedName);
- QualifiedName qualifiedTypeName = (QualifiedName) typeName;
- IBinding binding = qualifiedTypeName.getName().resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong name", "System", binding.getName());
- binding = qualifiedTypeName.getQualifier().resolveBinding();
- assertNotNull("No binding2", binding);
- assertEquals("Wrong type binding", IBinding.PACKAGE, binding.getKind());
- }
-
- /**
- * Check binding for anonymous class
- */
- public void test0252() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0252", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
- assertTrue("Not a return statement", node instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node;
- Expression expression = returnStatement.getExpression();
- assertTrue("Not a classinstancecreation", expression instanceof ClassInstanceCreation);
- ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
- IMethodBinding methodBinding = classInstanceCreation.resolveConstructorBinding();
- assertNotNull("No methodBinding", methodBinding);
- assertTrue("Not a constructor", methodBinding.isConstructor());
- assertTrue("Not an anonymous class", methodBinding.getDeclaringClass().isAnonymous());
- assertEquals("Not an anonymous class of java.lang.Object", "Object", methodBinding.getDeclaringClass().getSuperclass().getName());
- assertEquals("Not an anonymous class of java.lang.Object", "java.lang", methodBinding.getDeclaringClass().getSuperclass().getPackage().getName());
- }
-
- /**
- * Check binding for allocation expression
- */
- public void test0253() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0253", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("Not a return statement", node instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node;
- Expression expression = returnStatement.getExpression();
- assertTrue("Not a classinstancecreation", expression instanceof ClassInstanceCreation);
- ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
- IMethodBinding methodBinding = classInstanceCreation.resolveConstructorBinding();
- assertNotNull("No methodBinding", methodBinding);
- assertTrue("Not a constructor", methodBinding.isConstructor());
- assertEquals("Wrong size", 1, methodBinding.getParameterTypes().length);
- assertEquals("Wrong type", "String", methodBinding.getParameterTypes()[0].getName());
- }
-
- /**
- * Check binding for allocation expression
- */
- public void test0254() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0254", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 1, 0);
- assertTrue("Not a return statement", node instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node;
- Expression expression = returnStatement.getExpression();
- assertTrue("Not a class instance creation", expression instanceof ClassInstanceCreation);
- ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
- IMethodBinding binding = classInstanceCreation.resolveConstructorBinding();
- assertNotNull("No binding", binding);
- assertEquals("wrong type", "C", binding.getDeclaringClass().getName());
- }
-
-
- /**
- * Check binding for allocation expression
- */
- public void test0255() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0255", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression expression = expressionStatement.getExpression();
- assertTrue("Not a MethodInvocation", expression instanceof MethodInvocation);
- MethodInvocation methodInvocation = (MethodInvocation) expression;
- List arguments = methodInvocation.arguments();
- assertEquals("wrong size", 1, arguments.size());
- Expression expression2 = (Expression) arguments.get(0);
- assertTrue("Not a CastExpression", expression2 instanceof CastExpression);
- CastExpression castExpression = (CastExpression) expression2;
- Type type = castExpression.getType();
- ITypeBinding binding = type.resolveBinding();
- assertNotNull("No binding", binding);
- assertTrue("Not an array type", binding.isArray());
- }
-
- /**
- * Check binding for allocation expression
- */
- public void test0256() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0256", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression expression = expressionStatement.getExpression();
- assertTrue("Not a MethodInvocation", expression instanceof MethodInvocation);
- MethodInvocation methodInvocation = (MethodInvocation) expression;
- List arguments = methodInvocation.arguments();
- assertEquals("wrong size", 1, arguments.size());
- Expression expression2 = (Expression) arguments.get(0);
- assertTrue("Not a CastExpression", expression2 instanceof CastExpression);
- CastExpression castExpression = (CastExpression) expression2;
- Type type = castExpression.getType();
- assertTrue("Not a simple type", type.isSimpleType());
- SimpleType simpleType = (SimpleType) type;
- ITypeBinding binding = type.resolveBinding();
- assertNotNull("No binding", binding);
- assertTrue("Not a class", binding.isClass());
- Name name = simpleType.getName();
- IBinding binding2 = name.resolveBinding();
- assertNotNull("No binding2", binding2);
- assertEquals("Wrong type", "Object", binding2.getName());
- }
-
- /**
- * Check binding for allocation expression
- */
- public void test0257() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0257", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression expression = expressionStatement.getExpression();
- assertTrue("Not a MethodInvocation", expression instanceof MethodInvocation);
- MethodInvocation methodInvocation = (MethodInvocation) expression;
- List arguments = methodInvocation.arguments();
- assertEquals("wrong size", 1, arguments.size());
- Expression expression2 = (Expression) arguments.get(0);
- assertTrue("Not a CastExpression", expression2 instanceof CastExpression);
- CastExpression castExpression = (CastExpression) expression2;
- Type type = castExpression.getType();
- assertTrue("Not a primitive type", type.isPrimitiveType());
- PrimitiveType primitiveType = (PrimitiveType) type;
- assertEquals("Not int", PrimitiveType.INT, primitiveType.getPrimitiveTypeCode());
- }
-
- /**
- * Check binding for allocation expression
- */
- public void test0258() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0258", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression expression = expressionStatement.getExpression();
- assertTrue("Not a MethodInvocation", expression instanceof MethodInvocation);
- MethodInvocation methodInvocation = (MethodInvocation) expression;
- List arguments = methodInvocation.arguments();
- assertEquals("wrong size", 1, arguments.size());
- Expression expression2 = (Expression) arguments.get(0);
- assertTrue("Not a CastExpression", expression2 instanceof CastExpression);
- CastExpression castExpression = (CastExpression) expression2;
- Type type = castExpression.getType();
- assertTrue("Not a simple type", type.isSimpleType());
- SimpleType simpleType = (SimpleType) type;
- ITypeBinding binding = type.resolveBinding();
- assertNotNull("No binding", binding);
- assertTrue("Not a class", binding.isClass());
- Name name = simpleType.getName();
- IBinding binding2 = name.resolveBinding();
- assertNotNull("No binding2", binding2);
- assertEquals("Wrong type", "Object", binding2.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10663
- */
- public void test0259() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0259", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10592
- */
- public void test0260() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0260", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertTrue("Not a method declaration", node instanceof MethodDeclaration);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- List parameters = methodDeclaration.parameters();
- assertEquals("wrong size", 2, parameters.size());
- SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
- IBinding binding = singleVariableDeclaration.resolveBinding();
- assertNotNull("No binding", binding);
- Name name = singleVariableDeclaration.getName();
- assertTrue("Not a simple name", name instanceof SimpleName);
- SimpleName simpleName = (SimpleName) name;
- assertEquals("Wrong name", "i", simpleName.getIdentifier());
- IBinding binding2 = name.resolveBinding();
- assertNotNull("No binding", binding2);
- assertTrue("binding == binding2", binding == binding2);
- assertTrue("Not a variable binding", binding2 instanceof IVariableBinding);
- IVariableBinding variableBinding = (IVariableBinding) binding2;
- assertEquals("Wrong name", "i", variableBinding.getName());
- assertEquals("Wrong type", "int", variableBinding.getType().getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10679
- */
- public void test0261() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0261", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("Wrong size", 1, compilationUnit.getMessages().length);
- assertEquals("Wrong size", 1, compilationUnit.getProblems().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a return statement", node instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node;
- Expression expression = returnStatement.getExpression();
- ITypeBinding binding = expression.resolveTypeBinding();
- assertNull("got a binding", binding);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10676
- */
- public void test0262() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0262", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression expr = expressionStatement.getExpression();
- assertTrue("Not a MethodInvocation", expr instanceof MethodInvocation);
- MethodInvocation methodInvocation = (MethodInvocation) expr;
- List arguments = methodInvocation.arguments();
- assertEquals("Wrong argument list size", 1, arguments.size());
- Expression expr2 = (Expression) arguments.get(0);
- assertTrue("Not a class instance creation", expr2 instanceof ClassInstanceCreation);
- ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expr2;
- arguments = classInstanceCreation.arguments();
- assertEquals("Wrong size", 1, arguments.size());
- Expression expression2 = (Expression) arguments.get(0);
- assertTrue("Not a string literal", expression2 instanceof StringLiteral);
- StringLiteral stringLiteral = (StringLiteral) expression2;
- ITypeBinding typeBinding = stringLiteral.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong name", "String", typeBinding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10700
- */
- public void test0263() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0263", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression expr = expressionStatement.getExpression();
- assertTrue("Not a MethodInvocation", expr instanceof MethodInvocation);
- MethodInvocation methodInvocation = (MethodInvocation) expr;
- List arguments = methodInvocation.arguments();
- assertEquals("Wrong argument list size", 1, arguments.size());
- Expression expr2 = (Expression) arguments.get(0);
- assertTrue("Not a simple name", expr2 instanceof SimpleName);
- SimpleName simpleName = (SimpleName) expr2;
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("No binding", binding);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10699
- */
- public void test0264() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0264", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("Wrong fragment size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a classinstancecreation", expression instanceof ClassInstanceCreation);
- ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
- AnonymousClassDeclaration anonymousClassDeclaration = classInstanceCreation.getAnonymousClassDeclaration();
- assertNotNull("No anonymousclassdeclaration", anonymousClassDeclaration);
- String expectedSourceRange =
- "{\r\n"+
- " void m(int k){\r\n"+
- " k= i;\r\n"+
- " }\r\n"+
- " }";
- checkSourceRange(anonymousClassDeclaration, expectedSourceRange, source);
- List bodyDeclarations = anonymousClassDeclaration.bodyDeclarations();
- assertEquals("Wrong size", 1, bodyDeclarations.size());
- BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
- assertTrue("Not a method declaration", bodyDeclaration instanceof MethodDeclaration);
- MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration;
- assertEquals("Wrong name", "m", methodDeclaration.getName().getIdentifier());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10698
- */
- public void test0265() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0265", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
- */
- public void test0266() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0266", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- checkSourceRange(type, "Inner\\u005b]", source);
- assertTrue("Not an array type", type.isArrayType());
- ArrayType arrayType = (ArrayType) type;
- Type type2 = arrayType.getElementType();
- assertTrue("Not a simple type", type2.isSimpleType());
- SimpleType simpleType = (SimpleType) type2;
- checkSourceRange(simpleType, "Inner", source);
- Name name = simpleType.getName();
- assertTrue("not a simple name", name.isSimpleName());
- SimpleName simpleName = (SimpleName) name;
- checkSourceRange(simpleName, "Inner", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
- */
- public void test0267() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0267", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- checkSourceRange(type, "Inner[]", source);
- assertTrue("Not an array type", type.isArrayType());
- ArrayType arrayType = (ArrayType) type;
- Type type2 = arrayType.getElementType();
- assertTrue("Not a simple type", type2.isSimpleType());
- SimpleType simpleType = (SimpleType) type2;
- checkSourceRange(simpleType, "Inner", source);
- Name name = simpleType.getName();
- assertTrue("not a simple name", name.isSimpleName());
- SimpleName simpleName = (SimpleName) name;
- checkSourceRange(simpleName, "Inner", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
- */
- public void test0268() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0268", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- checkSourceRange(type, "test0268.Test.Inner[]", source);
- assertTrue("Not an array type", type.isArrayType());
- ArrayType arrayType = (ArrayType) type;
- Type type2 = arrayType.getElementType();
- assertTrue("Not a simple type", type2.isSimpleType());
- SimpleType simpleType = (SimpleType) type2;
- checkSourceRange(simpleType, "test0268.Test.Inner", source);
- Name name = simpleType.getName();
- assertTrue("not a qualified name", name.isQualifiedName());
- checkSourceRange(name, "test0268.Test.Inner", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
- */
- public void test0269() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0269", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- checkSourceRange(type, "test0269.Test.Inner[/**/]", source);
- assertTrue("Not an array type", type.isArrayType());
- ArrayType arrayType = (ArrayType) type;
- Type type2 = arrayType.getElementType();
- assertTrue("Not a simple type", type2.isSimpleType());
- SimpleType simpleType = (SimpleType) type2;
- checkSourceRange(simpleType, "test0269.Test.Inner", source);
- Name name = simpleType.getName();
- assertTrue("not a qualified name", name.isQualifiedName());
- checkSourceRange(name, "test0269.Test.Inner", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
- */
- public void test0270() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0270", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- checkSourceRange(type, "test0270.Test.Inner", source);
- assertTrue("Not a simple type", type.isSimpleType());
- SimpleType simpleType = (SimpleType) type;
- Name name = simpleType.getName();
- assertTrue("not a qualified name", name.isQualifiedName());
- checkSourceRange(name, "test0270.Test.Inner", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
- */
- public void test0271() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0271", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- checkSourceRange(type, "test0271.Test.Inner[]", source);
- assertTrue("Not an array type", type.isArrayType());
- ArrayType arrayType = (ArrayType) type;
- Type type2 = arrayType.getElementType();
- assertTrue("Not a simple type", type2.isSimpleType());
- SimpleType simpleType = (SimpleType) type2;
- checkSourceRange(simpleType, "test0271.Test.Inner", source);
- Name name = simpleType.getName();
- assertTrue("not a qualified name", name.isQualifiedName());
- checkSourceRange(name, "test0271.Test.Inner", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10843
- */
- public void test0272() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0272", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a For statement", node instanceof ForStatement);
- ForStatement forStatement = (ForStatement) node;
- checkSourceRange(forStatement, "for (int i= 0; i < 10; i++) foo();", source);
- Statement action = forStatement.getBody();
- checkSourceRange(action, "foo();", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10843
- */
- public void test0273() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0273", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a For statement", node instanceof ForStatement);
- ForStatement forStatement = (ForStatement) node;
- checkSourceRange(forStatement, "for (int i= 0; i < 10; i++) { foo(); }", source);
- Statement action = forStatement.getBody();
- checkSourceRange(action, "{ foo(); }", source);
- assertTrue("Not a block", action instanceof Block);
- Block block = (Block) action;
- List statements = block.statements();
- assertEquals("Wrong size", 1, statements.size());
- Statement stmt = (Statement) statements.get(0);
- checkSourceRange(stmt, "foo();", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10843
- */
- public void test0274() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0274", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
- assertTrue("Not a While statement", node instanceof WhileStatement);
- WhileStatement whileStatement = (WhileStatement) node;
- checkSourceRange(whileStatement, "while (i < 10) { foo(i++); }", source);
- Statement action = whileStatement.getBody();
- checkSourceRange(action, "{ foo(i++); }", source);
- assertTrue("Not a block", action instanceof Block);
- Block block = (Block) action;
- List statements = block.statements();
- assertEquals("Wrong size", 1, statements.size());
- Statement stmt = (Statement) statements.get(0);
- checkSourceRange(stmt, "foo(i++);", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10843
- */
- public void test0275() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0275", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
- assertTrue("Not a While statement", node instanceof WhileStatement);
- WhileStatement whileStatement = (WhileStatement) node;
- checkSourceRange(whileStatement, "while (i < 10) foo(i++);", source);
- Statement action = whileStatement.getBody();
- checkSourceRange(action, "foo(i++);", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10798
- */
- public void test0276() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0276", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a method declaration", node instanceof MethodDeclaration);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- String expectedSource =
- "public void foo() {\r\n" +
- " foo();\r\n" +
- " }";
- checkSourceRange(methodDeclaration, expectedSource, source);
- expectedSource =
- "{\r\n" +
- " foo();\r\n" +
- " }";
- checkSourceRange(methodDeclaration.getBody(), expectedSource, source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10798
- */
- public void test0277() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0277", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a method declaration", node instanceof MethodDeclaration);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- String expectedSource =
- "public void foo() {\r\n" +
- " }";
- checkSourceRange(methodDeclaration, expectedSource, source);
- expectedSource =
- "{\r\n" +
- " }";
- checkSourceRange(methodDeclaration.getBody(), expectedSource, source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10861
- */
- public void test0278() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0278", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a Field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "Class c = java.lang.String.class;", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a type literal", expression instanceof TypeLiteral);
- ITypeBinding typeBinding = expression.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong name", "Class", typeBinding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10861
- */
- public void test0279() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0279", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0,0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- checkSourceRange(variableDeclarationStatement, "Class c = java.lang.String.class;", source);
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a type literal", expression instanceof TypeLiteral);
- ITypeBinding typeBinding = expression.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong name", "Class", typeBinding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10865
- * Check well known types
- */
- public void test0280() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0280", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- AST ast = result.getAST();
- ITypeBinding typeBinding = ast.resolveWellKnownType("boolean");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "boolean", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("char");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "char", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("byte");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "byte", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("short");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "short", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("int");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "int", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("long");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "long", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("float");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "float", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("double");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "double", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("void");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "void", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("java.lang.Object");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "Object", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("java.lang.String");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "String", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("java.lang.StringBuffer");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "StringBuffer", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("java.lang.Throwable");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "Throwable", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("java.lang.Exception");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "Exception", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("java.lang.RuntimeException");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "RuntimeException", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("java.lang.Error");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "Error", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("java.lang.Class");
- assertNotNull("No typeBinding", typeBinding);
- assertEquals("Wrong name", "Class", typeBinding.getName());
- typeBinding = ast.resolveWellKnownType("java.lang.Runnable");
- assertNull("typeBinding not null", typeBinding);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
- */
- public void test0281() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0281", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a Field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "Object o= /*]*/new Object()/*[*/;", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- checkSourceRange(expression, "new Object()", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
- */
- public void test0282() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0282", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a Field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "boolean b = /*]*/true/*[*/;", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- checkSourceRange(expression, "true", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
- */
- public void test0283() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0283", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a Field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "char c = /*]*/'c'/*[*/;", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- checkSourceRange(expression, "'c'", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
- */
- public void test0284() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0284", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a Field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "Object o = /*]*/null/*[*/;", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- checkSourceRange(expression, "null", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
- */
- public void test0285() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0285", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a Field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "Object o = /*]*/Object.class/*[*/;", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- checkSourceRange(expression, "Object.class", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
- */
- public void test0286() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0286", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a Field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "int i = /**/(2)/**/;", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- checkSourceRange(expression, "(2)", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
- */
- public void test0287() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0287", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a Field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "String[] tab = /**/new String[3]/**/;", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- checkSourceRange(expression, "new String[3]", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
- */
- public void test0288() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0288", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a Field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "String[] tab = /**/{ }/**/;", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- checkSourceRange(expression, "{ }", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
- */
- public void test0289() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0289", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 1);
- assertTrue("Not a Field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "String s = /**/tab1[0]/**/;", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- checkSourceRange(expression, "tab1[0]", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
- */
- public void test0290() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0290", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a Field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "Object o = /*]*/new java.lang.Object()/*[*/;", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- checkSourceRange(expression, "new java.lang.Object()", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10898
- */
- public void test0291() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0291", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit unit = (CompilationUnit) result;
- assertEquals("no errors", 1, unit.getMessages().length);
- assertEquals("no errors", 1, unit.getProblems().length);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10913
- */
- public void test0292() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0292", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a return statement", node instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node;
- Expression expression = returnStatement.getExpression();
- assertTrue("Not a qualifiedName", expression instanceof QualifiedName);
- QualifiedName qualifiedName = (QualifiedName) expression;
- SimpleName simpleName = qualifiedName.getName();
- assertEquals("Wrong name", "x", simpleName.getIdentifier());
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("NO binding", binding);
- assertTrue("Not a variable binding", binding instanceof IVariableBinding);
- assertEquals("wrong name", "x", binding.getName());
- Name name = qualifiedName.getQualifier();
- assertTrue("Not a simpleName", name instanceof SimpleName);
- SimpleName simpleName2 = (SimpleName) name;
- IBinding binding2 = simpleName2.resolveBinding();
- assertNotNull("No binding2", binding2);
- assertTrue("Not a type binding", binding2 instanceof ITypeBinding);
- assertEquals("Wrong name", "Test", binding2.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10933
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10935
- */
- public void test0293() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0293", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a class instance creation", expression instanceof ClassInstanceCreation);
- ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
- AnonymousClassDeclaration anonymousClassDeclaration = classInstanceCreation.getAnonymousClassDeclaration();
- assertNotNull("No body", anonymousClassDeclaration);
- String expectedSource =
- "{\r\n" +
- " public void run() {\r\n" +
- " /*]*/foo();/*[*/\r\n" +
- " }\r\n" +
- " }";
- checkSourceRange(anonymousClassDeclaration, expectedSource, source);
- expectedSource =
- "run= new Runnable() {\r\n" +
- " public void run() {\r\n" +
- " /*]*/foo();/*[*/\r\n" +
- " }\r\n" +
- " }";
- checkSourceRange(variableDeclarationFragment, expectedSource, source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10984
- */
- public void test0294() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0294", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a method declaration", node instanceof MethodDeclaration);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- String expectedSource =
- "public void fails() {\r\n" +
- " foo()\r\n" +
- " }";
- checkSourceRange(methodDeclaration, expectedSource, source);
- Block block = methodDeclaration.getBody();
- expectedSource =
- "{\r\n" +
- " foo()\r\n" +
- " }";
- checkSourceRange(block, expectedSource, source);
- node = getASTNode(compilationUnit, 0, 1);
- assertTrue("Not a method declaration", node instanceof MethodDeclaration);
- methodDeclaration = (MethodDeclaration) node;
- block = methodDeclaration.getBody();
- List statements = block.statements();
- assertEquals("wrong size", 1, statements.size());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10986
- */
- public void test0295() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0295", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("Wrong size", 2, compilationUnit.getMessages().length);
- assertEquals("Wrong size", 2, compilationUnit.getProblems().length);
- ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
- assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression expression = expressionStatement.getExpression();
- assertTrue("not a method invocation", expression instanceof MethodInvocation);
- MethodInvocation methodInvocation = (MethodInvocation) expression;
- ITypeBinding typeBinding = methodInvocation.resolveTypeBinding();
- assertNull("type binding is not null", typeBinding);
- }
-
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10984
- */
- public void test0296() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0296", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a method declaration", node instanceof MethodDeclaration);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- String expectedSource =
- "public void fails() {\r\n" +
- " foo()\r\n" +
- " }";
- checkSourceRange(methodDeclaration, expectedSource, source);
- Block block = methodDeclaration.getBody();
- expectedSource =
- "{\r\n" +
- " foo()\r\n" +
- " }";
- checkSourceRange(block, expectedSource, source);
- node = getASTNode(compilationUnit, 0, 1);
- assertTrue("Not a method declaration", node instanceof MethodDeclaration);
- methodDeclaration = (MethodDeclaration) node;
- block = methodDeclaration.getBody();
- List statements = block.statements();
- assertEquals("wrong size", 1, statements.size());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11037
- */
- public void test0297() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0297", "Test.java");
- runConversion(sourceUnit, false);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10984
- */
- public void test0298() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0298", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a ReturnStatement", node instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node;
- Expression expression = returnStatement.getExpression();
- checkSourceRange(expression, "a().length != 3", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11104
- */
- public void test0299() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0299", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a Field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "int i = (/**/2/**/);", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a parenthesized expression", expression instanceof ParenthesizedExpression);
- ParenthesizedExpression parenthesizedExpression = (ParenthesizedExpression) expression;
- Expression expression2 = parenthesizedExpression.getExpression();
- checkSourceRange(expression2, "2", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11104
- */
- public void test0300() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0300", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a Field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "boolean b = /**/true/**/;", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- checkSourceRange(expression, "true", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11104
- */
- public void test0301() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0301", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a Field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- checkSourceRange(fieldDeclaration, "Object o = /**/null/**/;", source);
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- checkSourceRange(expression, "null", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11106
- */
- public void test0302() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0302", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a DoStatement", node instanceof DoStatement);
- DoStatement doStatement = (DoStatement) node;
- String expectedSource =
- "do\r\n" +
- " foo();\r\n" +
- " while(1 < 10);";
- checkSourceRange(doStatement, expectedSource, source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11129
- */
- public void test0303() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0303", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
- assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression expression2 = expressionStatement.getExpression();
- assertTrue("Not an Assignement", expression2 instanceof Assignment);
- Assignment assignment = (Assignment) expression2;
- Expression expression = assignment.getRightHandSide();
- assertTrue("Not a CastExpression", expression instanceof CastExpression);
- CastExpression castExpression = (CastExpression) expression;
- ITypeBinding typeBinding = castExpression.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Wrong name", "char", typeBinding.getName());
- Type type = castExpression.getType();
- ITypeBinding typeBinding2 = type.resolveBinding();
- assertNotNull("No binding2", typeBinding2);
- assertEquals("Wrong name", "char", typeBinding2.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11151
- */
- public void test0304() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0304", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("not a method declaration", node instanceof MethodDeclaration);
- checkSourceRange(node, "public void foo(int arg);", source);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Block block = methodDeclaration.getBody();
- assertNull("Has a body", block);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11125
- */
- public void test0305() throws JavaModelException {
- char[] source =
- ("package test0304;\r\n" +
- "\r\n" +
- "class Test {\r\n" +
- " public void foo(int arg) {}\r\n" +
- "}").toCharArray();
- IJavaProject project = getJavaProject("Converter");
- ASTNode result = runConversion(source, "Test.java", project);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0);
- assertTrue("not a TypeDeclaration", node instanceof TypeDeclaration);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong name", "Test", typeBinding.getName());
- assertEquals("Wrong package", "test0304", typeBinding.getPackage().getName());
- assertTrue("Not an interface", typeBinding.isClass());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11125
- */
- public void test0306() throws JavaModelException {
- char[] source =
- ("package java.lang;\r\n" +
- "\r\n" +
- "class Object {\r\n" +
- " public void foo(int arg) {}\r\n" +
- "}").toCharArray();
- IJavaProject project = getJavaProject("Converter");
- ASTNode result = runConversion(source, "Object.java", project);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0);
- assertTrue("not a TypeDeclaration", node instanceof TypeDeclaration);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong name", "Object", typeBinding.getName());
- assertEquals("Wrong package", "java.lang", typeBinding.getPackage().getName());
- assertTrue("Not an interface", typeBinding.isClass());
- assertEquals("Wrong size", 2, typeBinding.getDeclaredMethods().length);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11371
- */
- public void test0307() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0307", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
- assertTrue("not a method declaration", node instanceof MethodDeclaration);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Block block = methodDeclaration.getBody();
- assertNotNull("No body", block);
- List statements = block.statements();
- assertEquals("wrong size", 1, statements.size());
- Statement statement = (Statement) statements.get(0);
- assertTrue("Not a super constructor invocation", statement instanceof SuperConstructorInvocation);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11371
- */
- public void test0308() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0308", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
- assertTrue("not a method declaration", node instanceof MethodDeclaration);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Block block = methodDeclaration.getBody();
- assertNotNull("No body", block);
- List statements = block.statements();
- assertEquals("wrong size", 1, statements.size());
- Statement statement = (Statement) statements.get(0);
- assertTrue("Not a super constructor invocation", statement instanceof SuperConstructorInvocation);
- SuperConstructorInvocation superConstructorInvocation = (SuperConstructorInvocation) statement;
- IMethodBinding methodBinding = superConstructorInvocation.resolveConstructorBinding();
- assertNotNull("No methodBinding", methodBinding);
- IMethodBinding methodBinding2 = methodDeclaration.resolveBinding();
- assertNotNull("No methodBinding2", methodBinding2);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11380
- */
- public void test0309() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0309", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a conditional expression", expression instanceof ConditionalExpression);
- ConditionalExpression conditionalExpression = (ConditionalExpression) expression;
- ITypeBinding typeBinding = conditionalExpression.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("wrong name", "int", typeBinding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11380
- */
- public void test0310() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0310", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("not a FieldDeclaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- List fragments = fieldDeclaration.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a qualified name", expression instanceof QualifiedName);
- QualifiedName qualifiedName = (QualifiedName) expression;
- Name qualifier = qualifiedName.getQualifier();
- IBinding binding = qualifier.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("wrong name", "I", binding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11638
- */
- public void test0311() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0311", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("not a class instance creation", expression instanceof ClassInstanceCreation);
- ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
- AnonymousClassDeclaration anonymousClassDeclaration = classInstanceCreation.getAnonymousClassDeclaration();
- assertNotNull("No body", anonymousClassDeclaration);
- List bodyDeclarations = anonymousClassDeclaration.bodyDeclarations();
- assertEquals("wrong size for body declarations", 1, bodyDeclarations.size());
- BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
- assertTrue("Not a method declaration", bodyDeclaration instanceof MethodDeclaration);
- MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration;
- Block block = methodDeclaration.getBody();
- assertNotNull("no body", block);
- List statements = block.statements();
- assertEquals("Wrong size for statements", 1, statements.size());
- Statement statement = (Statement) statements.get(0);
- assertTrue("not a variable declaration statement", statement instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement2 = (VariableDeclarationStatement) statement;
- List fragments2 = variableDeclarationStatement2.fragments();
- assertEquals("wrong size for fragments2", 1, fragments2.size());
- VariableDeclarationFragment variableDeclarationFragment2 = (VariableDeclarationFragment) fragments2.get(0);
- Expression expression2 = variableDeclarationFragment2.getInitializer();
- assertTrue("Not a name", expression2 instanceof Name);
- Name name = (Name) expression2;
- checkSourceRange(name, "j", source);
- IBinding binding = name.resolveBinding();
- ASTNode declaringNode = compilationUnit.findDeclaringNode(binding);
- assertNotNull("No declaring node", declaringNode);
- checkSourceRange(declaringNode, "int j", source);
- assertTrue("Not a single variable declaration", declaringNode instanceof SingleVariableDeclaration);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11638
- * There is a error in this source. A is unresolved. Then there is no
- * declaring node.
- */
- public void test0312() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0312", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("not a class instance creation", expression instanceof ClassInstanceCreation);
- ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
- AnonymousClassDeclaration anonymousClassDeclaration = classInstanceCreation.getAnonymousClassDeclaration();
- assertNotNull("No body", anonymousClassDeclaration);
- List bodyDeclarations = anonymousClassDeclaration.bodyDeclarations();
- assertEquals("wrong size for body declarations", 1, bodyDeclarations.size());
- BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
- assertTrue("Not a method declaration", bodyDeclaration instanceof MethodDeclaration);
- MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration;
- Block block = methodDeclaration.getBody();
- assertNotNull("no body", block);
- List statements = block.statements();
- assertEquals("Wrong size for statements", 1, statements.size());
- Statement statement = (Statement) statements.get(0);
- assertTrue("not a variable declaration statement", statement instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement2 = (VariableDeclarationStatement) statement;
- List fragments2 = variableDeclarationStatement2.fragments();
- assertEquals("wrong size for fragments2", 1, fragments2.size());
- VariableDeclarationFragment variableDeclarationFragment2 = (VariableDeclarationFragment) fragments2.get(0);
- Expression expression2 = variableDeclarationFragment2.getInitializer();
- assertTrue("Not a name", expression2 instanceof Name);
- Name name = (Name) expression2;
- checkSourceRange(name, "j", source);
- IBinding binding = name.resolveBinding();
- ASTNode declaringNode = compilationUnit.findDeclaringNode(binding);
- assertNull("No declaring node is available", declaringNode);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11659
- */
- public void test0313() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0313", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not an InfixExpression", expression instanceof InfixExpression);
- InfixExpression infixExpression = (InfixExpression) expression;
- checkSourceRange(infixExpression, "i+j", source);
- Expression expression2 = infixExpression.getLeftOperand();
- checkSourceRange(expression2, "i", source);
- assertTrue("Not a name", expression2 instanceof Name);
- Name name = (Name) expression2;
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding", binding);
- ASTNode astNode = compilationUnit.findDeclaringNode(binding);
- assertNotNull("No declaring node", astNode);
- checkSourceRange(astNode, "int i", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=12326
- */
- public void test0314() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0314", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- assertNotNull("No result", result);
- assertTrue("Not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("Wrong line number", 1, compilationUnit.lineNumber(0));
- // ensure that last character is on the last line
- assertEquals("Wrong line number", 3, compilationUnit.lineNumber(source.length - 1));
- // source.length is beyond the size of the compilation unit source
- assertEquals("Wrong line number", 1, compilationUnit.lineNumber(source.length));
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=12326
- */
- public void test0315() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0315", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a Return statement", node instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node;
- Expression expression = returnStatement.getExpression();
- assertTrue("Not an instanceof expression", expression instanceof InstanceofExpression);
- InstanceofExpression instanceOfExpression = (InstanceofExpression) expression;
- Type rightOperand = instanceOfExpression.getRightOperand();
- assertTrue("Not a simpleType", rightOperand instanceof SimpleType);
- SimpleType simpleType = (SimpleType) rightOperand;
- Name n = simpleType.getName();
- assertTrue("Not a qualified name", n instanceof QualifiedName);
- QualifiedName name = (QualifiedName) n;
- checkSourceRange(name, "java.io.Serializable", source);
- ITypeBinding typeBinding = name.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong name", "Serializable", typeBinding.getName());
- Name qualifier = name.getQualifier();
- assertTrue("Not a qualified name", qualifier instanceof QualifiedName);
- ITypeBinding typeBinding2 = qualifier.resolveTypeBinding();
- assertNull("typebinding2 is not null", typeBinding2);
- IBinding binding = qualifier.resolveBinding();
- assertNotNull("no binding", binding);
- assertEquals("Wrong type", IBinding.PACKAGE, binding.getKind());
- IPackageBinding pBinding = (IPackageBinding) binding;
- assertEquals("Wrong name", "java.io", pBinding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=12454
- */
- public void test0316() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "", "Hello.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No result", result);
- assertTrue("Not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("Wrong size", 2, compilationUnit.getMessages().length);
- assertEquals("Wrong size", 2, compilationUnit.getProblems().length);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=12781
- */
- public void test0317() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0317", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a return statement", node instanceof ReturnStatement);
- ReturnStatement returnStatement = (ReturnStatement) node;
- Expression expression = returnStatement.getExpression();
- assertTrue("not an instanceof expression", expression instanceof InstanceofExpression);
- InstanceofExpression instanceOfExpression = (InstanceofExpression) expression;
- Expression left = instanceOfExpression.getLeftOperand();
- assertTrue("Not a Name", left instanceof Name);
- Name name = (Name) left;
- IBinding binding = name.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("wrong name", "x", binding.getName());
- ITypeBinding typeBinding = name.resolveTypeBinding();
- assertNotNull("No typebinding", typeBinding);
- assertEquals("wrong type", "Object", typeBinding.getName());
- Type right = instanceOfExpression.getRightOperand();
- assertTrue("Not a simpleType", right instanceof SimpleType);
- SimpleType simpleType = (SimpleType) right;
- name = simpleType.getName();
- assertTrue("Not a simpleName", name instanceof SimpleName);
- SimpleName simpleName = (SimpleName) name;
- IBinding binding2 = simpleName.resolveBinding();
- assertNotNull("No binding2", binding2);
- assertEquals("Wrong name", "Vector", binding2.getName());
- ITypeBinding typeBinding2 = simpleName.resolveTypeBinding();
- assertNotNull("No typeBinding2", typeBinding2);
- assertEquals("Wrong name", "Vector", typeBinding2.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=13233
- */
- public void test0318() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0318", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit unit = (CompilationUnit) result;
- assertEquals("No error", 1, unit.getMessages().length);
- assertEquals("No error", 1, unit.getProblems().length);
- ASTNode node = getASTNode(unit, 0, 0, 0);
- assertTrue("Not a variable declaration statement", node instanceof VariableDeclarationStatement);
- assertTrue("Not malformed", isMalformed(node));
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=13807
- */
- public void test0319() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0319", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not an array creation", expression instanceof ArrayCreation);
- ArrayCreation arrayCreation = (ArrayCreation) expression;
- ITypeBinding typeBinding = arrayCreation.resolveTypeBinding();
- assertNotNull("no type binding", typeBinding);
- assertEquals("wrong name", "Object[]", typeBinding.getName());
- ArrayType arrayType = arrayCreation.getType();
- ITypeBinding typeBinding2 = arrayType.resolveBinding();
- assertNotNull("no type binding2", typeBinding2);
- assertEquals("wrong name", "Object[]", typeBinding2.getName());
- Type type = arrayType.getElementType();
- assertTrue("Not a simple type", type instanceof SimpleType);
- SimpleType simpleType = (SimpleType) type;
- ITypeBinding typeBinding3 = simpleType.resolveBinding();
- assertNotNull("no type binding3", typeBinding3);
- assertEquals("wrong name", "Object", typeBinding3.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=13807
- */
- public void test0320() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0320", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- checkSourceRange(type, "int[]", source);
- assertTrue("Not an array type", type.isArrayType());
- ArrayType arrayType = (ArrayType) type;
- ITypeBinding typeBinding = arrayType.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- Type elementType = arrayType.getElementType();
- assertTrue("Not a simple type", elementType.isPrimitiveType());
- ITypeBinding typeBinding2 = elementType.resolveBinding();
- assertNotNull("No type binding2", typeBinding2);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=13807
- */
- public void test0321() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0321", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- assertTrue("Not an array type", type.isArrayType());
- ArrayType arrayType = (ArrayType) type;
- ITypeBinding typeBinding = arrayType.resolveBinding();
- checkSourceRange(type, "java.lang.Object[][]", source);
- assertNotNull("No type binding", typeBinding);
- Type elementType = arrayType.getComponentType();
- ITypeBinding typeBinding2 = elementType.resolveBinding();
- assertNotNull("No type binding2", typeBinding2);
- assertEquals("wrong dimension", 1, typeBinding2.getDimensions());
- assertEquals("wrong name", "Object[]", typeBinding2.getName());
- assertTrue("Not an array type", elementType.isArrayType());
- Type elementType2 = ((ArrayType) elementType).getComponentType();
- assertTrue("Not a simple type", elementType2.isSimpleType());
- ITypeBinding typeBinding3 = elementType2.resolveBinding();
- assertNotNull("No type binding3", typeBinding3);
- assertEquals("wrong dimension", 0, typeBinding3.getDimensions());
- assertEquals("wrong name", "Object", typeBinding3.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=13231
- */
- public void test0322() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0322", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a FieldDeclaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- List fragments = fieldDeclaration.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a null literal", expression instanceof NullLiteral);
- NullLiteral nullLiteral = (NullLiteral) expression;
- ITypeBinding typeBinding = nullLiteral.resolveTypeBinding();
- assertNotNull("no type binding", typeBinding);
- assertTrue("Not the null type", typeBinding.isNullType());
- assertEquals("Wrong qualified name", typeBinding.getQualifiedName(), "null");
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=14198
- */
- public void test0323() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0323", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
- assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression expression2 = expressionStatement.getExpression();
- assertTrue("Not an Assignement", expression2 instanceof Assignment);
- Assignment assignment = (Assignment) expression2;
- Expression expression = assignment.getRightHandSide();
- assertTrue("Not a CastExpression", expression instanceof CastExpression);
- CastExpression castExpression = (CastExpression) expression;
- ITypeBinding typeBinding = castExpression.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Wrong name", "Object", typeBinding.getName());
- Type type = castExpression.getType();
- ITypeBinding typeBinding2 = type.resolveBinding();
- assertNotNull("No binding2", typeBinding2);
- assertEquals("Wrong name", "Object", typeBinding2.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=14198
- */
- public void test0324() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0324", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
- assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression expression2 = expressionStatement.getExpression();
- assertTrue("Not an Assignement", expression2 instanceof Assignment);
- Assignment assignment = (Assignment) expression2;
- Expression expression = assignment.getRightHandSide();
- assertTrue("Not a CastExpression", expression instanceof CastExpression);
- CastExpression castExpression = (CastExpression) expression;
- ITypeBinding typeBinding = castExpression.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Wrong name", "Object[]", typeBinding.getName());
- Type type = castExpression.getType();
- ITypeBinding typeBinding2 = type.resolveBinding();
- assertNotNull("No binding2", typeBinding2);
- assertEquals("Wrong name", "Object[]", typeBinding2.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=14198
- */
- public void test0325() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0325", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
- assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression expression2 = expressionStatement.getExpression();
- assertTrue("Not an Assignement", expression2 instanceof Assignment);
- Assignment assignment = (Assignment) expression2;
- Expression expression = assignment.getRightHandSide();
- assertTrue("Not a CastExpression", expression instanceof CastExpression);
- CastExpression castExpression = (CastExpression) expression;
- ITypeBinding typeBinding = castExpression.resolveTypeBinding();
- assertNotNull("No binding", typeBinding);
- assertEquals("Wrong name", "int[]", typeBinding.getName());
- Type type = castExpression.getType();
- ITypeBinding typeBinding2 = type.resolveBinding();
- assertNotNull("No binding2", typeBinding2);
- assertEquals("Wrong name", "int[]", typeBinding2.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=14217
- */
- public void test0326() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0326", "A.java");
- ASTNode result = runConversion(sourceUnit, true);
- char[] source = sourceUnit.getSource().toCharArray();
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
- assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- checkSourceRange(expressionStatement.getExpression(), "a().f= a()", source);
- checkSourceRange(expressionStatement, "a().f= a();", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=14198
- */
- public void test0327() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0327", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not an VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a CastExpression", expression instanceof CastExpression);
- CastExpression castExpression = (CastExpression) expression;
- ITypeBinding typeBinding = castExpression.resolveTypeBinding();
- assertNull("typeBinding is not null", typeBinding);
- Type type = castExpression.getType();
- ITypeBinding typeBinding2 = type.resolveBinding();
- assertNull("typeBinding2 is not null", typeBinding2);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=13807
- */
- public void test0328() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0328", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- checkSourceRange(type, "java.lang.Object[]", source);
- assertTrue("Not an array type", type.isArrayType());
- ArrayType arrayType = (ArrayType) type;
- ITypeBinding typeBinding = arrayType.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("wrong name", "Object[]", typeBinding.getName());
- Type elementType = arrayType.getElementType();
- assertTrue("Not a simple type", elementType.isSimpleType());
- ITypeBinding typeBinding2 = elementType.resolveBinding();
- assertNotNull("No type binding2", typeBinding2);
- assertEquals("wrong name", "Object", typeBinding2.getName());
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a array creation", expression instanceof ArrayCreation);
- ITypeBinding typeBinding3 = expression.resolveTypeBinding();
- assertNotNull("No typeBinding3", typeBinding3);
- assertEquals("wrong name", "Object[]", typeBinding3.getName());
- ArrayCreation arrayCreation = (ArrayCreation) expression;
- ArrayInitializer arrayInitializer = arrayCreation.getInitializer();
- assertNotNull("not array initializer", arrayInitializer);
- ITypeBinding typeBinding4 = arrayInitializer.resolveTypeBinding();
- assertNotNull("No typeBinding4", typeBinding3);
- assertEquals("wrong name", "Object[]", typeBinding4.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=13807
- */
- public void test0329() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0329", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- checkSourceRange(type, "java.lang.Object[]", source);
- assertTrue("Not an array type", type.isArrayType());
- ArrayType arrayType = (ArrayType) type;
- ITypeBinding typeBinding = arrayType.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("wrong name", "Object[]", typeBinding.getName());
- Type elementType = arrayType.getElementType();
- assertTrue("Not a simple type", elementType.isSimpleType());
- ITypeBinding typeBinding2 = elementType.resolveBinding();
- assertNotNull("No type binding2", typeBinding2);
- assertEquals("wrong name", "Object", typeBinding2.getName());
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a array creation", expression instanceof ArrayCreation);
- ITypeBinding typeBinding3 = expression.resolveTypeBinding();
- assertNotNull("No typeBinding3", typeBinding3);
- assertEquals("wrong name", "Object[]", typeBinding3.getName());
- ArrayCreation arrayCreation = (ArrayCreation) expression;
- ArrayInitializer arrayInitializer = arrayCreation.getInitializer();
- assertNotNull("not array initializer", arrayInitializer);
- ITypeBinding typeBinding4 = arrayInitializer.resolveTypeBinding();
- assertNotNull("No typeBinding4", typeBinding3);
- assertEquals("wrong name", "Object[]", typeBinding4.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=14313
- */
- public void test0330() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0330", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("wrong size", 2, compilationUnit.getMessages().length);
- assertEquals("wrong size", 2, compilationUnit.getProblems().length);
- ASTNode node = getASTNode(compilationUnit, 0);
- assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("no type binding", typeBinding);
- IMethodBinding[] methods = typeBinding.getDeclaredMethods();
- assertEquals("wrong size", 1, methods.length);
- assertTrue("not a constructor", methods[0].isConstructor());
- assertTrue("wrong name", !methods[0].getName().equals("foo"));
- node = getASTNode(compilationUnit, 0, 0);
- assertTrue("Not a methodDeclaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- IMethodBinding methodBinding = methodDeclaration.resolveBinding();
- assertNull("method binding not null", methodBinding);
- node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a return statement", node.getNodeType() == ASTNode.RETURN_STATEMENT);
- ReturnStatement returnStatement = (ReturnStatement) node;
- Expression expression = returnStatement.getExpression();
- ITypeBinding typeBinding2 = expression.resolveTypeBinding();
- assertNotNull("no type binding2", typeBinding2);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=14322
- */
- public void test0331() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0331", "Test.java");
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not an VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a QualifiedName", expression instanceof QualifiedName);
- QualifiedName qualifiedName = (QualifiedName) expression;
- IBinding binding = qualifiedName.getName().resolveBinding();
- assertNotNull("no binding", binding);
- assertEquals("Wrong type", IBinding.VARIABLE, binding.getKind());
- IVariableBinding variableBinding = (IVariableBinding) binding;
- assertTrue("Not a field", variableBinding.isField());
- assertNull("Got a declaring class", variableBinding.getDeclaringClass());
- assertEquals("wrong name", "length", variableBinding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=14403
- */
- public void test0332() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0332", "LocalSelectionTransfer.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=13807
- */
- public void test0333() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0333", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not an array creation", expression instanceof ArrayCreation);
- ArrayCreation arrayCreation = (ArrayCreation) expression;
- ITypeBinding typeBinding = arrayCreation.resolveTypeBinding();
- assertNotNull("no type binding", typeBinding);
- assertEquals("wrong name", "Object[][]", typeBinding.getName());
- ArrayType arrayType = arrayCreation.getType();
- ITypeBinding typeBinding2 = arrayType.resolveBinding();
- assertNotNull("no type binding2", typeBinding2);
- assertEquals("wrong name", "Object[][]", typeBinding2.getName());
- Type type = arrayType.getElementType();
- assertTrue("Not a simple type", type instanceof SimpleType);
- SimpleType simpleType = (SimpleType) type;
- ITypeBinding typeBinding3 = simpleType.resolveBinding();
- assertNotNull("no type binding3", typeBinding3);
- assertEquals("wrong name", "Object", typeBinding3.getName());
- type = arrayType.getComponentType();
- assertTrue("Not an array type", type instanceof ArrayType);
- ArrayType arrayType2 = (ArrayType) type;
- ITypeBinding typeBinding4 = arrayType2.resolveBinding();
- assertNotNull("no type binding4", typeBinding4);
- assertEquals("wrong name", "Object[]", typeBinding4.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=13807
- */
- public void test0334() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0334", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not an array creation", expression instanceof ArrayCreation);
- ArrayCreation arrayCreation = (ArrayCreation) expression;
- ITypeBinding typeBinding = arrayCreation.resolveTypeBinding();
- assertNotNull("no type binding", typeBinding);
- assertEquals("wrong name", "Object[][][]", typeBinding.getName());
- ArrayType arrayType = arrayCreation.getType();
- checkSourceRange(arrayType, "Object[10][][]", source);
- ITypeBinding typeBinding2 = arrayType.resolveBinding();
- assertNotNull("no type binding2", typeBinding2);
- assertEquals("wrong name", "Object[][][]", typeBinding2.getName());
- Type type = arrayType.getElementType();
- assertTrue("Not a simple type", type instanceof SimpleType);
- SimpleType simpleType = (SimpleType) type;
- checkSourceRange(simpleType, "Object", source);
- ITypeBinding typeBinding3 = simpleType.resolveBinding();
- assertNotNull("no type binding3", typeBinding3);
- assertEquals("wrong name", "Object", typeBinding3.getName());
- type = arrayType.getComponentType();
- assertTrue("Not an array type", type instanceof ArrayType);
- ArrayType arrayType2 = (ArrayType) type;
- checkSourceRange(arrayType2, "Object[10][]", source);
- ITypeBinding typeBinding4 = arrayType2.resolveBinding();
- assertNotNull("no type binding4", typeBinding4);
- assertEquals("wrong name", "Object[][]", typeBinding4.getName());
- type = arrayType2.getComponentType();
- assertTrue("Not an array type", type instanceof ArrayType);
- ArrayType arrayType3 = (ArrayType) type;
- ITypeBinding typeBinding5 = arrayType3.resolveBinding();
- assertNotNull("no type binding5", typeBinding5);
- assertEquals("wrong name", "Object[]", typeBinding5.getName());
- checkSourceRange(arrayType3, "Object[10]", source);
- }
-
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=14526
- */
- public void test0335() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0335", "ExceptionTestCaseTest.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0);
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- assertEquals("errors found", 0, compilationUnit.getProblems().length);
- assertNotNull("not null", node);
- assertTrue("not a type declaration", node instanceof TypeDeclaration);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- Name name = typeDeclaration.getSuperclass();
- assertNotNull("no super class", name);
- assertTrue("not a qualified name", name.isQualifiedName());
- QualifiedName qualifiedName = (QualifiedName) name;
- name = qualifiedName.getQualifier();
- assertTrue("not a qualified name", name.isQualifiedName());
- qualifiedName = (QualifiedName) name;
- name = qualifiedName.getQualifier();
- assertTrue("not a simple name", name.isSimpleName());
- SimpleName simpleName = (SimpleName) name;
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("no binding", binding);
- assertEquals("wrong type", IBinding.PACKAGE, binding.getKind());
- assertEquals("wrong name", "junit", binding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=14526
- */
- public void test0336() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0336", "SorterTest.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- assertEquals("errors found", 0, compilationUnit.getProblems().length);
- assertNotNull("not null", node);
- assertTrue("not a type declaration", node instanceof TypeDeclaration);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- List superInterfaces = typeDeclaration.superInterfaces();
- assertEquals("wrong size", 1, superInterfaces.size());
- Name name = (Name) superInterfaces.get(0);
- assertTrue("not a qualified name", name.isQualifiedName());
- QualifiedName qualifiedName = (QualifiedName) name;
- name = qualifiedName.getQualifier();
- assertTrue("not a simple name", name.isSimpleName());
- SimpleName simpleName = (SimpleName) name;
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("no binding", binding);
- assertEquals("wrong type", IBinding.TYPE, binding.getKind());
- assertEquals("wrong name", "Sorter", binding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=14602
- */
- public void test0337() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0337", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- assertNotNull("not null", node);
- assertTrue("not a field declaration", node instanceof FieldDeclaration);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- List fragments = fieldDeclaration.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- checkSourceRange(variableDeclarationFragment, "message= Test.m(\"s\", new String[]{\"g\"})", source);
- checkSourceRange(fieldDeclaration, "String message= Test.m(\"s\", new String[]{\"g\"});", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=14852
- */
- public void test0338() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0338", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- assertNotNull("not null", node);
- assertTrue("not a MethodDeclaration", node instanceof MethodDeclaration);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- List thrownExceptions = methodDeclaration.thrownExceptions();
- assertEquals("Wrong size", 1, thrownExceptions.size());
- Name name = (Name) thrownExceptions.get(0);
- IBinding binding = name.resolveBinding();
- assertEquals("wrong type", IBinding.TYPE, binding.getKind());
- assertEquals("wrong name", "IOException", binding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=15061
- */
- public void test0339() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0339", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("No errors found", 2, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull("not null", node);
- assertTrue("not a Type declaration", node instanceof TypeDeclaration);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- List bodyDeclarations = typeDeclaration.bodyDeclarations();
- assertEquals("wrong size", 1, bodyDeclarations.size());
- MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclarations.get(0);
- checkSourceRange(methodDeclaration, "int doQuery(boolean x);", source);
- node = getASTNode(compilationUnit, 0, 1);
- assertNotNull("not null", node);
- assertTrue("not a MethodDeclaration", node instanceof MethodDeclaration);
- String expectedSource =
- "public void setX(boolean x) {\r\n" +
- " {\r\n" +
- " z\r\n" +
- " }\r\n" +
- "}";
- checkSourceRange(node, expectedSource, source);
- int methodEndPosition = node.getStartPosition() + node.getLength();
- node = getASTNode(compilationUnit, 0);
- assertNotNull("not null", node);
- assertTrue("not a TypeDeclaration", node instanceof TypeDeclaration);
- int typeEndPosition = node.getStartPosition() + node.getLength();
- assertEquals("different positions", methodEndPosition, typeEndPosition);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=14852
- */
- public void test0340() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "p3", "B.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull("not null", node);
- assertTrue("Not an expression statement", node.getNodeType() == ASTNode.EXPRESSION_STATEMENT);
- ExpressionStatement expressionStatement = (ExpressionStatement) node;
- Expression expression = expressionStatement.getExpression();
- assertTrue("Not an method invocation", expression.getNodeType() == ASTNode.METHOD_INVOCATION);
- MethodInvocation methodInvocation = (MethodInvocation) expression;
- Expression expression2 = methodInvocation.getExpression();
- assertNotNull("No receiver", expression2);
- ITypeBinding binding = expression2.resolveTypeBinding();
- assertNotNull("No type binding", binding);
- assertEquals("wrong name", "A", binding.getName());
- assertEquals("wrong name", "p2", binding.getPackage().getName());
- assertTrue("Not a qualified name", expression2.getNodeType() == ASTNode.QUALIFIED_NAME);
- QualifiedName qualifiedName = (QualifiedName) expression2;
- SimpleName simpleName = qualifiedName.getName();
- assertEquals("wrong name", "A", simpleName.getIdentifier());
- ITypeBinding typeBinding = simpleName.resolveTypeBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("wrong name", "A", typeBinding.getName());
- assertEquals("wrong name", "p2", typeBinding.getPackage().getName());
- Name name = qualifiedName.getQualifier();
- assertTrue("Not a simple name", name.getNodeType() == ASTNode.SIMPLE_NAME);
- SimpleName simpleName2 = (SimpleName) name;
- assertEquals("wrong name", "p2", simpleName2.getIdentifier());
- IBinding binding2 = simpleName2.resolveBinding();
- assertNotNull("No binding", binding2);
- assertEquals("wrong type", IBinding.PACKAGE, binding2.getKind());
- assertEquals("wrong name", "p2", binding2.getName());
- node = getASTNode(compilationUnit, 0, 1, 0);
- assertNotNull("not null", node);
- assertTrue("Not an expression statement", node.getNodeType() == ASTNode.EXPRESSION_STATEMENT);
- ExpressionStatement expressionStatement2 = (ExpressionStatement) node;
- Expression expression3 = expressionStatement2.getExpression();
- assertTrue("Not an method invocation", expression3.getNodeType() == ASTNode.METHOD_INVOCATION);
- MethodInvocation methodInvocation2 = (MethodInvocation) expression3;
- Expression expression4 = methodInvocation2.getExpression();
- assertNotNull("No receiver", expression4);
- ITypeBinding binding3 = expression4.resolveTypeBinding();
- assertNotNull("No type binding", binding3);
- assertEquals("wrong name", "A", binding3.getName());
- assertEquals("wrong name", "p1", binding3.getPackage().getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=15804
- */
- public void test0341() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0341", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
- assertNotNull("not null", node);
- assertTrue("Not an if statement", node.getNodeType() == ASTNode.IF_STATEMENT);
- String expectedSource =
- "if (field != null) {\r\n" +
- " throw new IOException();\r\n" +
- " } else if (field == null) {\r\n" +
- " throw new MalformedURLException();\r\n" +
- " } else if (field == null) {\r\n" +
- " throw new InterruptedIOException();\r\n" +
- " } else {\r\n" +
- " throw new UnsupportedEncodingException();\r\n" +
- " }";
- checkSourceRange(node, expectedSource, source);
- IfStatement ifStatement = (IfStatement) node;
- Statement thenStatement = ifStatement.getThenStatement();
- expectedSource =
- "{\r\n" +
- " throw new IOException();\r\n" +
- " }";
- checkSourceRange(thenStatement, expectedSource, source);
- Statement elseStatement = ifStatement.getElseStatement();
- expectedSource =
- "if (field == null) {\r\n" +
- " throw new MalformedURLException();\r\n" +
- " } else if (field == null) {\r\n" +
- " throw new InterruptedIOException();\r\n" +
- " } else {\r\n" +
- " throw new UnsupportedEncodingException();\r\n" +
- " }";
- checkSourceRange(elseStatement, expectedSource, source);
- assertTrue("Not a if statement", elseStatement.getNodeType() == ASTNode.IF_STATEMENT);
- ifStatement = (IfStatement) elseStatement;
- thenStatement = ifStatement.getThenStatement();
- expectedSource =
- "{\r\n" +
- " throw new MalformedURLException();\r\n" +
- " }";
- checkSourceRange(thenStatement, expectedSource, source);
- elseStatement = ifStatement.getElseStatement();
- expectedSource =
- "if (field == null) {\r\n" +
- " throw new InterruptedIOException();\r\n" +
- " } else {\r\n" +
- " throw new UnsupportedEncodingException();\r\n" +
- " }";
- checkSourceRange(elseStatement, expectedSource, source);
- assertTrue("Not a if statement", elseStatement.getNodeType() == ASTNode.IF_STATEMENT);
- ifStatement = (IfStatement) elseStatement;
- thenStatement = ifStatement.getThenStatement();
- expectedSource =
- "{\r\n" +
- " throw new InterruptedIOException();\r\n" +
- " }";
- checkSourceRange(thenStatement, expectedSource, source);
- elseStatement = ifStatement.getElseStatement();
- expectedSource =
- "{\r\n" +
- " throw new UnsupportedEncodingException();\r\n" +
- " }";
- checkSourceRange(elseStatement, expectedSource, source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=15657
- */
- public void test0342() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0342", "Test.java");
- IDOMCompilationUnit dcompUnit = new DOMFactory().createCompilationUnit(sourceUnit.getSource(), sourceUnit.getElementName());
- assertNotNull("dcompUnit is null", dcompUnit);
-
- // searching class
- IDOMType classNode = null;
- Enumeration children = dcompUnit.getChildren();
- assertNotNull("dcompUnit has no children", children);
-
- while (children.hasMoreElements()) {
- IDOMNode child = (IDOMNode) children.nextElement();
- if (child.getNodeType() == IDOMNode.TYPE) {
- classNode = (IDOMType) child;
- break;
- }
- }
- assertNotNull("classNode is null", classNode);
-
- // searching for methods
- children = classNode.getChildren();
-
- assertNotNull("classNode has no children", children);
-
- while (children.hasMoreElements()) {
- IDOMNode child = (IDOMNode) children.nextElement();
- if (child.getNodeType() == IDOMNode.METHOD) {
- IDOMMethod childMethod = (IDOMMethod) child;
-
- // returnType is always null;
- String returnType = childMethod.getReturnType();
- if (childMethod.isConstructor()) {
- assertNull(returnType);
- } else {
- assertNotNull("no return type", returnType);
- }
- }
- }
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=16051
- */
- public void test0343() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0343", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 1, 1);
- assertNotNull("not null", node);
- assertTrue("Not an if statement", node.getNodeType() == ASTNode.IF_STATEMENT);
- String expectedSource =
- "if (flag)\r\n" +
- " i= 10;";
- checkSourceRange(node, expectedSource, source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=16132
- */
- public void test0344() throws JavaModelException {
- Preferences preferences = null;
- String pb_assert = null;
- String compiler_source = null;
- String compiler_compliance = null;
- try {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0344", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- preferences = JavaCore.getPlugin().getPluginPreferences();
- pb_assert = preferences.getString(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER);
- compiler_source = preferences.getString(JavaCore.COMPILER_SOURCE);
- compiler_compliance = preferences.getString(JavaCore.COMPILER_COMPLIANCE);
-
- preferences.setValue(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
- preferences.setValue(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4);
- preferences.setValue(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
-
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- } finally {
- if (preferences != null) {
- preferences.setValue(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, pb_assert);
- preferences.setValue(JavaCore.COMPILER_SOURCE, compiler_source);
- preferences.setValue(JavaCore.COMPILER_COMPLIANCE, compiler_compliance);
- }
- }
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=17922
- */
- public void test0345() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0345", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull("not null", node);
- assertTrue("Not an field declaration", node.getNodeType() == ASTNode.FIELD_DECLARATION);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- List fragments = fieldDeclaration.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not an ArrayCreation", expression.getNodeType() == ASTNode.ARRAY_CREATION);
- ArrayCreation arrayCreation = (ArrayCreation) expression;
- ArrayType arrayType = arrayCreation.getType();
- IBinding binding2 = arrayType.resolveBinding();
- assertNotNull("no binding2", binding2);
- assertEquals("not a type", binding2.getKind(), IBinding.TYPE);
- ITypeBinding typeBinding2 = (ITypeBinding) binding2;
- assertTrue("Not an array type binding2", typeBinding2.isArray());
- Type type = arrayType.getElementType();
- assertTrue("Not a simple type", type.isSimpleType());
- SimpleType simpleType = (SimpleType) type;
- Name name = simpleType.getName();
- assertTrue("QualifiedName", name.getNodeType() == ASTNode.QUALIFIED_NAME);
- SimpleName simpleName = ((QualifiedName) name).getName();
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("no binding", binding);
- assertEquals("not a type", binding.getKind(), IBinding.TYPE);
- ITypeBinding typeBinding = (ITypeBinding) binding;
- assertTrue("An array type binding", !typeBinding.isArray());
- Type type2 = fieldDeclaration.getType();
- assertTrue("Not a array type", type2.isArrayType());
- ArrayType arrayType2 = (ArrayType) type2;
- Type type3 = arrayType2.getElementType();
- assertTrue("Not a simple type", type3.isSimpleType());
- SimpleType simpleType2 = (SimpleType) type3;
- Name name2 = simpleType2.getName();
- assertTrue("Not a qualified name", name2.getNodeType() == ASTNode.QUALIFIED_NAME);
- SimpleName simpleName2 = ((QualifiedName) name2).getName();
- IBinding binding3 = simpleName2.resolveBinding();
- assertNotNull("no binding", binding3);
- assertEquals("not a type", binding3.getKind(), IBinding.TYPE);
- ITypeBinding typeBinding3 = (ITypeBinding) binding3;
- assertTrue("An array type binding", !typeBinding3.isArray());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=18138
- */
- public void test0346() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0346", "Test2.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull("not null", node);
- assertTrue("Not an variable declaration", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- checkSourceRange(type, "Vector", source);
- assertTrue("not an array type", !type.isArrayType());
- assertTrue("Not a simple type", type.isSimpleType());
- SimpleType simpleType = (SimpleType) type;
- Name name = simpleType.getName();
- assertTrue("Not a simpleName", name.isSimpleName());
- SimpleName simpleName = (SimpleName) name;
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong type", IBinding.TYPE, binding.getKind());
- ITypeBinding typeBinding = (ITypeBinding) binding;
- assertTrue("An array", !typeBinding.isArray());
- assertEquals("Wrong name", "Vector", binding.getName());
- ITypeBinding typeBinding2 = simpleType.resolveBinding();
- assertNotNull("No binding", typeBinding2);
- assertEquals("Wrong type", IBinding.TYPE, typeBinding2.getKind());
- assertTrue("An array", !typeBinding2.isArray());
- assertEquals("Wrong name", "Vector", typeBinding2.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=18138
- */
- public void test0347() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0347", "Test2.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull("not null", node);
- assertTrue("Not an variable declaration", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- checkSourceRange(type, "Vector[]", source);
- assertTrue("not an array type", type.isArrayType());
- ArrayType arrayType = (ArrayType) type;
- ITypeBinding binding = arrayType.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong type", IBinding.TYPE, binding.getKind());
- assertTrue("Not an array type", binding.isArray());
- assertEquals("Wrong name", "Vector[]", binding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=18138
- */
- public void test0348() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0348", "Test2.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull("not null", node);
- assertTrue("Not an variable declaration", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- checkSourceRange(type, "Vector[][]", source);
- assertTrue("not an array type", type.isArrayType());
- ArrayType arrayType = (ArrayType) type;
- ITypeBinding binding = arrayType.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong type", IBinding.TYPE, binding.getKind());
- assertTrue("Not an array type", binding.isArray());
- assertEquals("Wrong name", "Vector[][]", binding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=18138
- */
- public void test0349() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0349", "Test2.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull("not null", node);
- assertTrue("Not an field declaration", node.getNodeType() == ASTNode.FIELD_DECLARATION);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- Type type = fieldDeclaration.getType();
- checkSourceRange(type, "Vector[][]", source);
- assertTrue("not an array type", type.isArrayType());
- ArrayType arrayType = (ArrayType) type;
- ITypeBinding binding = arrayType.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong type", IBinding.TYPE, binding.getKind());
- assertTrue("Not an array type", binding.isArray());
- assertEquals("Wrong name", "Vector[][]", binding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=18138
- */
- public void test0350() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0350", "Test2.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull("not null", node);
- assertTrue("Not an field declaration", node.getNodeType() == ASTNode.FIELD_DECLARATION);
- FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
- Type type = fieldDeclaration.getType();
- checkSourceRange(type, "Vector", source);
- assertTrue("not a simple type", type.isSimpleType());
- SimpleType simpleType = (SimpleType) type;
- ITypeBinding binding = simpleType.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong type", IBinding.TYPE, binding.getKind());
- assertTrue("An array type", binding.isClass());
- assertEquals("Wrong name", "Vector", binding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=18169
- */
- public void test0351() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0351", "Test2.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull("not null", node);
- assertTrue("Not an method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- List parameters = methodDeclaration.parameters();
- assertEquals("wrong size", 2, parameters.size());
- SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
- checkSourceRange(singleVariableDeclaration, "int a", source);
- singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(1);
- checkSourceRange(singleVariableDeclaration, "int[] b", source);
- node = getASTNode(compilationUnit, 0, 1);
- assertNotNull("not null", node);
- assertTrue("Not an method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- methodDeclaration = (MethodDeclaration) node;
- parameters = methodDeclaration.parameters();
- assertEquals("wrong size", 2, parameters.size());
- singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
- checkSourceRange(singleVariableDeclaration, "int a", source);
- singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(1);
- checkSourceRange(singleVariableDeclaration, "int b[]", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=18169
- */
- public void test0352() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0352", "Test2.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull("not null", node);
- assertTrue("Not an method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- List parameters = methodDeclaration.parameters();
- assertEquals("wrong size", 2, parameters.size());
- SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
- checkSourceRange(singleVariableDeclaration, "final int a", source);
- singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(1);
- checkSourceRange(singleVariableDeclaration, "final int[] b", source);
- node = getASTNode(compilationUnit, 0, 1);
- assertNotNull("not null", node);
- assertTrue("Not an method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- methodDeclaration = (MethodDeclaration) node;
- parameters = methodDeclaration.parameters();
- assertEquals("wrong size", 2, parameters.size());
- singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
- checkSourceRange(singleVariableDeclaration, "final int a", source);
- singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(1);
- checkSourceRange(singleVariableDeclaration, "final int b[]", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=18042
- */
- public void test0353() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0353", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull("not null", node);
- assertTrue("Not an variable declaration", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- checkSourceRange(type, "InputStream", source);
- assertTrue("not a simple type", type.isSimpleType());
- ITypeBinding binding = type.resolveBinding();
- assertNotNull("No binding", binding);
- assertEquals("Wrong type", IBinding.TYPE, binding.getKind());
- assertTrue("Not a class", binding.isClass());
- assertEquals("Wrong name", "InputStream", binding.getName());
- assertEquals("Wrong package", "java.io", binding.getPackage().getName());
- SimpleType simpleType = (SimpleType) type;
- Name name = simpleType.getName();
- IBinding binding2 = name.resolveBinding();
- assertNotNull("No binding", binding2);
- assertEquals("Wrong type", IBinding.TYPE, binding2.getKind());
- ITypeBinding typeBinding = (ITypeBinding) binding2;
- assertTrue("Not a class", typeBinding.isClass());
- assertEquals("Wrong name", "InputStream", typeBinding.getName());
- assertEquals("Wrong package", "java.io", typeBinding.getPackage().getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=19851
- */
- public void test0354() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0354", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 3, compilationUnit.getMessages().length);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=20520
- */
- public void test0355() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0355", "Foo.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not an if statement", node.getNodeType() == ASTNode.IF_STATEMENT);
- IfStatement ifStatement = (IfStatement) node;
- Expression condition = ifStatement.getExpression();
- assertTrue("Not an infixExpression", condition.getNodeType() == ASTNode.INFIX_EXPRESSION);
- InfixExpression infixExpression = (InfixExpression) condition;
- Expression expression = infixExpression.getLeftOperand();
- assertTrue("Not a method invocation expression", expression.getNodeType() == ASTNode.METHOD_INVOCATION);
- MethodInvocation methodInvocation = (MethodInvocation) expression;
- Expression expression2 = methodInvocation.getExpression();
- assertTrue("Not a parenthesis expression", expression2.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=20865
- */
- public void test0356() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0356", "X.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 2, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- Type type = variableDeclarationStatement.getType();
- ITypeBinding binding = type.resolveBinding();
- assertNull(binding);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=21757
- */
- public void test0357() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0357", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0);
- assertNotNull(node);
- assertTrue("Not a type declaration statement", node.getNodeType() == ASTNode.TYPE_DECLARATION);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- SimpleName name = typeDeclaration.getName();
- checkSourceRange(name, "A", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=21768
- */
- public void test0358() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0358", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0,0);
- assertNotNull(node);
- assertTrue("Not a method declaration statement", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- SimpleName name = methodDeclaration.getName();
- checkSourceRange(name, "mdd", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=21768
- */
- public void test0359() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0359", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0,0);
- assertNotNull(node);
- assertTrue("Not a method declaration statement", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- SimpleName name = methodDeclaration.getName();
- checkSourceRange(name, "mdd", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=21916
- */
- public void test0360() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0360", "X.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0,0, 0);
- assertNotNull(node);
- assertTrue("Not a for statement", node.getNodeType() == ASTNode.FOR_STATEMENT);
- ForStatement forStatement = (ForStatement) node;
- List initializers = forStatement.initializers();
- assertEquals("Wrong size", 1, initializers.size());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=21916
- */
- public void test0361() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0361", "X.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0,0, 0);
- assertNotNull(node);
- assertTrue("Not a for statement", node.getNodeType() == ASTNode.FOR_STATEMENT);
- ForStatement forStatement = (ForStatement) node;
- List initializers = forStatement.initializers();
- assertEquals("Wrong size", 1, initializers.size());
- }
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=21916
- */
- public void test0362() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0362", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, false);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- ForStatement forStatement = this.ast.newForStatement();
-
- VariableDeclarationFragment iFragment = this.ast.newVariableDeclarationFragment();
- iFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
- iFragment.setInitializer(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
- VariableDeclarationFragment jFragment = this.ast.newVariableDeclarationFragment();
- jFragment.setName(this.ast.newSimpleName("j")); //$NON-NLS-1$
- jFragment.setInitializer(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
- VariableDeclarationFragment kFragment = this.ast.newVariableDeclarationFragment();
- kFragment.setName(this.ast.newSimpleName("k")); //$NON-NLS-1$
- kFragment.setInitializer(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
-
- VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(iFragment);
- variableDeclarationExpression.setModifiers(Modifier.NONE);
- variableDeclarationExpression.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
- variableDeclarationExpression.fragments().add(jFragment);
- variableDeclarationExpression.fragments().add(kFragment);
- forStatement.initializers().add(variableDeclarationExpression);
-
- PostfixExpression iPostfixExpression = this.ast.newPostfixExpression();
- iPostfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
- iPostfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
- forStatement.updaters().add(iPostfixExpression);
-
- PostfixExpression jPostfixExpression = this.ast.newPostfixExpression();
- jPostfixExpression.setOperand(this.ast.newSimpleName("j"));//$NON-NLS-1$
- jPostfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
- forStatement.updaters().add(jPostfixExpression);
-
- PostfixExpression kPostfixExpression = this.ast.newPostfixExpression();
- kPostfixExpression.setOperand(this.ast.newSimpleName("k"));//$NON-NLS-1$
- kPostfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
- forStatement.updaters().add(kPostfixExpression);
-
- forStatement.setBody(this.ast.newBlock());
-
- InfixExpression infixExpression = this.ast.newInfixExpression();
- infixExpression.setLeftOperand(this.ast.newSimpleName("i"));
- infixExpression.setOperator(InfixExpression.Operator.LESS);
- infixExpression.setRightOperand(this.ast.newNumberLiteral("10"));
- forStatement.setExpression(infixExpression);
-
- assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- checkSourceRange(node, "for (int i=0, j=0, k=0; i<10 ; i++, j++, k++) {}", source); //$NON-NLS-1$
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22939
- */
- public void test0363() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0363", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
- assertNotNull(node);
- assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a parenthesized expression", expression.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION);
- Expression expression2 = ((ParenthesizedExpression) expression).getExpression();
- checkSourceRange(expression2, "xxxx", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11529
- */
- public void test0364() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0364", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- checkSourceRange(variableDeclarationStatement, "int local;", source);
- SimpleName simpleName = variableDeclarationFragment.getName();
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("No binding", binding);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11529
- */
- public void test0365() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0365", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a for statement", node.getNodeType() == ASTNode.FOR_STATEMENT);
- ForStatement forStatement = (ForStatement) node;
- List initializers = forStatement.initializers();
- assertEquals("Wrong size", 1, initializers.size());
- VariableDeclarationExpression variableDeclarationExpression = (VariableDeclarationExpression) initializers.get(0);
- List fragments = variableDeclarationExpression.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- SimpleName simpleName = variableDeclarationFragment.getName();
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("No binding", binding);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23048
- */
- public void test0366() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0366", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a for statement", node.getNodeType() == ASTNode.FOR_STATEMENT);
- ForStatement forStatement = (ForStatement) node;
- checkSourceRange(forStatement, "for (int i = 0; i < 5; ++i);", source);
- Statement statement = forStatement.getBody();
- assertTrue("Not an empty statement", statement.getNodeType() == ASTNode.EMPTY_STATEMENT);
- checkSourceRange(statement, ";", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23048
- */
- public void test0367() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0367", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a while statement", node.getNodeType() == ASTNode.WHILE_STATEMENT);
- WhileStatement whileStatement = (WhileStatement) node;
- checkSourceRange(whileStatement, "while(i == 2);", source);
- Statement statement = whileStatement.getBody();
- assertTrue("Not an empty statement", statement.getNodeType() == ASTNode.EMPTY_STATEMENT);
- checkSourceRange(statement, ";", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23048
- */
- public void test0368() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0368", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a labeled statement", node.getNodeType() == ASTNode.LABELED_STATEMENT);
- LabeledStatement labeledStatement = (LabeledStatement) node;
- checkSourceRange(labeledStatement, "test:;", source);
- Statement statement = labeledStatement.getBody();
- assertTrue("Not an empty statement", statement.getNodeType() == ASTNode.EMPTY_STATEMENT);
- checkSourceRange(statement, ";", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23048
- */
- public void test0369() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0369", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a labeled statement", node.getNodeType() == ASTNode.LABELED_STATEMENT);
- LabeledStatement labeledStatement = (LabeledStatement) node;
- checkSourceRange(labeledStatement, "test:\\u003B", source);
- Statement statement = labeledStatement.getBody();
- assertTrue("Not an empty statement", statement.getNodeType() == ASTNode.EMPTY_STATEMENT);
- checkSourceRange(statement, "\\u003B", source);
- }
-
- /**
- * DoStatement ==> DoStatement
- */
- public void test0370() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0370", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull("Expression should not be null", node); //$NON-NLS-1$
- DoStatement doStatement = this.ast.newDoStatement();
- doStatement.setBody(this.ast.newEmptyStatement());
- doStatement.setExpression(this.ast.newBooleanLiteral(true));
- assertTrue("Both AST trees should be identical", doStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
- String expectedSource = "do ; while(true);";//$NON-NLS-1$
- checkSourceRange(node, expectedSource, source);
- DoStatement doStatement2 = (DoStatement) node;
- Statement statement = doStatement2.getBody();
- assertTrue("Not an empty statement", statement.getNodeType() == ASTNode.EMPTY_STATEMENT);
- checkSourceRange(statement, ";", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23048
- */
- public void test0371() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0371", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a labeled statement", node.getNodeType() == ASTNode.IF_STATEMENT);
- IfStatement ifStatement = (IfStatement) node;
- checkSourceRange(ifStatement, "if (i == 6);", source);
- Statement statement = ifStatement.getThenStatement();
- assertTrue("Not an empty statement", statement.getNodeType() == ASTNode.EMPTY_STATEMENT);
- checkSourceRange(statement, ";", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23048
- */
- public void test0372() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0372", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a labeled statement", node.getNodeType() == ASTNode.IF_STATEMENT);
- IfStatement ifStatement = (IfStatement) node;
- checkSourceRange(ifStatement, "if (i == 6) {} else ;", source);
- Statement statement = ifStatement.getElseStatement();
- assertTrue("Not an empty statement", statement.getNodeType() == ASTNode.EMPTY_STATEMENT);
- checkSourceRange(statement, ";", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23118
- */
- public void test0373() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0373", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a for statement", node.getNodeType() == ASTNode.FOR_STATEMENT);
- ForStatement forStatement = (ForStatement) node;
- Statement statement = forStatement.getBody();
- assertTrue("Not a block statement", statement.getNodeType() == ASTNode.BLOCK);
- Block block = (Block) statement;
- List statements = block.statements();
- assertEquals("Wrong size", 1, statements.size());
- Statement statement2 = (Statement) statements.get(0);
- assertTrue("Not a break statement", statement2.getNodeType() == ASTNode.BREAK_STATEMENT);
- BreakStatement breakStatement = (BreakStatement) statement2;
- checkSourceRange(breakStatement, "break;", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23118
- */
- public void test0374() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0374", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a for statement", node.getNodeType() == ASTNode.FOR_STATEMENT);
- ForStatement forStatement = (ForStatement) node;
- Statement statement = forStatement.getBody();
- assertTrue("Not a block statement", statement.getNodeType() == ASTNode.BLOCK);
- Block block = (Block) statement;
- List statements = block.statements();
- assertEquals("Wrong size", 1, statements.size());
- Statement statement2 = (Statement) statements.get(0);
- assertTrue("Not a break statement", statement2.getNodeType() == ASTNode.CONTINUE_STATEMENT);
- ContinueStatement continueStatement = (ContinueStatement) statement2;
- checkSourceRange(continueStatement, "continue;", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23052
- */
- public void test0375() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0375", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- List imports = compilationUnit.imports();
- assertEquals("wrong size", 1, imports.size());
- ImportDeclaration importDeclaration = (ImportDeclaration) imports.get(0);
- IBinding binding = importDeclaration.resolveBinding();
- assertNotNull("no binding", binding);
- assertEquals("Not a type binding", IBinding.TYPE, binding.getKind());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22939
- */
- public void test0376() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0376", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a cast expression", expression.getNodeType() == ASTNode.CAST_EXPRESSION);
- Type type = ((CastExpression) expression).getType();
- checkSourceRange(type, "A", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23050
- */
- public void test0377() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0377", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- IVariableBinding variableBinding = variableDeclarationFragment.resolveBinding();
- assertNotNull("No variable binding", variableBinding);
- assertEquals("Wrong modifier", IModifierConstants.ACC_FINAL, variableBinding.getModifiers());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22161
- */
- public void test0378() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0378", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull(node);
- assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- SimpleName name = typeDeclaration.getName();
- checkSourceRange(name, "B", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22161
- */
- public void test0379() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0379", "Test.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
- assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
- assertTrue("Not a class instance creation", expression.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION); //$NON-NLS-1$
- ClassInstanceCreation classInstanceCreation2 = (ClassInstanceCreation) expression;
- Name name2 = classInstanceCreation2.getName();
- checkSourceRange(name2, "Object", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22054
- */
- public void test0380() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0380", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a return statement", node.getNodeType() == ASTNode.RETURN_STATEMENT);
- ReturnStatement returnStatement = (ReturnStatement) node;
- Expression expression = returnStatement.getExpression();
- assertTrue("Not a super method invocation", expression.getNodeType() == ASTNode.SUPER_METHOD_INVOCATION);
- SuperMethodInvocation superMethodInvocation = (SuperMethodInvocation) expression;
- ITypeBinding typeBinding = superMethodInvocation.resolveTypeBinding();
- assertNotNull("no type binding", typeBinding);
- assertEquals("wrong declaring class", typeBinding.getSuperclass().getName(), "Object");
- SimpleName simpleName = superMethodInvocation.getName();
- IBinding binding = simpleName.resolveBinding();
- assertNotNull("no binding", binding);
- assertEquals("Wrong type", IBinding.METHOD, binding.getKind());
- IMethodBinding methodBinding = (IMethodBinding) binding;
- assertEquals("Wrong declaring class", methodBinding.getDeclaringClass().getName(), "Object");
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23054
- */
- public void test0381() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0381", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0);
- assertNotNull(node);
- assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- Javadoc javadoc = typeDeclaration.getJavadoc();
- assertNull("Javadoc not null", javadoc);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
- */
- public void test0382() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0382", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0);
- assertNotNull(node);
- assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertEquals("Wrong fully qualified name", typeBinding.getQualifiedName(), "test0382.A");
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
- */
- public void test0383() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0383", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull(node);
- assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertEquals("Wrong fully qualified name", typeBinding.getQualifiedName(), "test0383.A.B");
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
- */
- public void test0384() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0384", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertEquals("Wrong fully qualified name", typeBinding.getQualifiedName(), "test0384.A.B.D");
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23117
- */
- public void test0385() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0385", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 1, compilationUnit.getMessages().length);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23259
- */
- public void test0386() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0386", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a switch statement", node.getNodeType() == ASTNode.SWITCH_STATEMENT);
- SwitchStatement switchStatement = (SwitchStatement) node;
- List statements = switchStatement.statements();
- assertEquals("Wrong size", 5, statements.size());
- Statement statement = (Statement) statements.get(0);
- assertTrue("Not a case statement", statement.getNodeType() == ASTNode.SWITCH_CASE);
- checkSourceRange(statement, "case 1:", source);
- statement = (Statement) statements.get(3);
- assertTrue("Not a default case statement", statement.getNodeType() == ASTNode.SWITCH_CASE);
- checkSourceRange(statement, "default :", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22939
- */
- public void test0387() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0387", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("Wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not a cast expression", expression.getNodeType() == ASTNode.CAST_EXPRESSION);
- Type type = ((CastExpression) expression).getType();
- checkSourceRange(type, "A", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
- */
- public void test0388() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0388", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0);
- assertNotNull(node);
- assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong qualified name", "test0388.A", typeBinding.getQualifiedName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
- */
- public void test0389() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0389", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull(node);
- assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION);
- TypeDeclaration typeDeclaration = (TypeDeclaration) node;
- ITypeBinding typeBinding = typeDeclaration.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong qualified name", "test0389.A.B", typeBinding.getQualifiedName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
- */
- public void test0390() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0390", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull(node);
- assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
- ITypeBinding typeBinding = type.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong qualified name", "int", typeBinding.getQualifiedName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
- */
- public void test0391() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0391", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull(node);
- assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
- ITypeBinding typeBinding = type.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong qualified name", "int[]", typeBinding.getQualifiedName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
- */
- public void test0392() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0392", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull(node);
- assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
- ITypeBinding typeBinding = type.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong qualified name", "java.lang.String[]", typeBinding.getQualifiedName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23284
- */
- public void test0393() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0393", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull(node);
- assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
- checkSourceRange(type, "String", source);
- ITypeBinding typeBinding = type.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong dimension", 0, typeBinding.getDimensions());
- assertEquals("Wrong qualified name", "java.lang.String", typeBinding.getQualifiedName());
- assertEquals("Wrong dimension", 1, methodDeclaration.getExtraDimensions());
- IMethodBinding methodBinding = methodDeclaration.resolveBinding();
- assertNotNull("No method binding", methodBinding);
- ITypeBinding typeBinding2 = methodBinding.getReturnType();
- assertNotNull("No type binding", typeBinding2);
- assertEquals("Wrong qualified name", "java.lang.String[]", typeBinding2.getQualifiedName());
- assertEquals("Wrong dimension", 1, typeBinding2.getDimensions());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23284
- */
- public void test0394() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0394", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull(node);
- assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
- checkSourceRange(type, "String", source);
- ITypeBinding typeBinding = type.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong qualified name", "java.lang.String", typeBinding.getQualifiedName());
- assertEquals("Wrong dimension", 0, methodDeclaration.getExtraDimensions());
- }
-
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23284
- */
- public void test0395() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0395", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- assertNotNull("No compilation unit", result);
- assertTrue("result is not a compilation unit", result instanceof CompilationUnit);
- CompilationUnit compilationUnit = (CompilationUnit) result;
- assertEquals("errors found", 0, compilationUnit.getMessages().length);
- ASTNode node = getASTNode(compilationUnit, 0, 0);
- assertNotNull(node);
- assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Type type = methodDeclaration.getReturnType();
- checkSourceRange(type, "String[]", source);
- ITypeBinding typeBinding = type.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- assertEquals("Wrong dimension", 1, typeBinding.getDimensions());
- assertEquals("Wrong qualified name", "java.lang.String[]", typeBinding.getQualifiedName());
- assertEquals("Wrong dimension", 1, methodDeclaration.getExtraDimensions());
- IMethodBinding methodBinding = methodDeclaration.resolveBinding();
- assertNotNull("No method binding", methodBinding);
- ITypeBinding typeBinding2 = methodBinding.getReturnType();
- assertNotNull("No type binding", typeBinding2);
- assertEquals("Wrong qualified name", "java.lang.String[][]", typeBinding2.getQualifiedName());
- assertEquals("Wrong dimension", 2, typeBinding2.getDimensions());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23284
- */
- public void test0396() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0396", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull(node);
- assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration method = (MethodDeclaration) node;
- SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) method.parameters().get(0);
- assertNotNull("Expression should not be null", singleVariableDeclaration); //$NON-NLS-1$
- checkSourceRange(singleVariableDeclaration, "final String s[]", source); //$NON-NLS-1$
- Type type = singleVariableDeclaration.getType();
- checkSourceRange(type, "String", source); //$NON-NLS-1$
- assertEquals("Wrong dimension", 1, singleVariableDeclaration.getExtraDimensions());
- ITypeBinding typeBinding = type.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- assertTrue("An array binding", !typeBinding.isArray());
- assertEquals("Wrong dimension", 0, typeBinding.getDimensions());
- assertEquals("wrong fully qualified name", "java.lang.String", typeBinding.getQualifiedName());
- IVariableBinding variableBinding = singleVariableDeclaration.resolveBinding();
- assertNotNull("No variable binding", variableBinding);
- ITypeBinding typeBinding2 = variableBinding.getType();
- assertNotNull("No type binding", typeBinding2);
- assertTrue("Not an array binding", typeBinding2.isArray());
- assertEquals("Wrong dimension", 1, typeBinding2.getDimensions());
- assertEquals("wrong fully qualified name", "java.lang.String[]", typeBinding2.getQualifiedName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23284
- */
- public void test0397() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0397", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull(node);
- assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration method = (MethodDeclaration) node;
- SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) method.parameters().get(0);
- assertNotNull("Expression should not be null", singleVariableDeclaration); //$NON-NLS-1$
- checkSourceRange(singleVariableDeclaration, "final String[] \\u0073\\u005B][]", source); //$NON-NLS-1$
- Type type = singleVariableDeclaration.getType();
- checkSourceRange(type, "String[]", source); //$NON-NLS-1$
- assertEquals("Wrong dimension", 2, singleVariableDeclaration.getExtraDimensions());
- ITypeBinding typeBinding = type.resolveBinding();
- assertNotNull("No type binding", typeBinding);
- assertTrue("Not an array binding", typeBinding.isArray());
- assertEquals("Wrong dimension", 1, typeBinding.getDimensions());
- assertEquals("wrong fully qualified name", "java.lang.String[]", typeBinding.getQualifiedName());
- IVariableBinding variableBinding = singleVariableDeclaration.resolveBinding();
- assertNotNull("No variable binding", variableBinding);
- ITypeBinding typeBinding2 = variableBinding.getType();
- assertNotNull("No type binding", typeBinding2);
- assertTrue("Not an array binding", typeBinding2.isArray());
- assertEquals("Wrong dimension", 3, typeBinding2.getDimensions());
- assertEquals("wrong fully qualified name", "java.lang.String[][][]", typeBinding2.getQualifiedName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23362
- */
- public void test0398() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0398", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
- assertNotNull(node);
- assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT);
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
- List fragments = variableDeclarationStatement.fragments();
- assertEquals("wrong size", 1, fragments.size());
- VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
- Expression expression = variableDeclarationFragment.getInitializer();
- assertTrue("Not an infix expression", expression.getNodeType() == ASTNode.INFIX_EXPRESSION);
- InfixExpression infixExpression = (InfixExpression) expression;
- checkSourceRange(infixExpression, "(1 + 2) * 3", source);
- Expression expression2 = infixExpression.getLeftOperand();
- assertTrue("Not an parenthesis expression", expression2.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION);
- ParenthesizedExpression parenthesizedExpression = (ParenthesizedExpression) expression2;
- Expression expression3 = parenthesizedExpression.getExpression();
- assertTrue("Not an infix expression", expression3.getNodeType() == ASTNode.INFIX_EXPRESSION);
- checkSourceRange(expression3, "1 + 2", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22306
- */
- public void test0399() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0399", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull(node);
- assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- assertTrue("Not a constructor", methodDeclaration.isConstructor());
- Block block = methodDeclaration.getBody();
- List statements = block.statements();
- assertEquals("wrong size", 2, statements.size());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22306
- */
- public void test0400() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0400", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull(node);
- assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- assertTrue("Not a constructor", methodDeclaration.isConstructor());
- Block block = methodDeclaration.getBody();
- List statements = block.statements();
- assertEquals("wrong size", 3, statements.size());
- Statement statement = (Statement) statements.get(0);
- assertTrue("Not an superconstructorinvocation", statement.getNodeType() == ASTNode.SUPER_CONSTRUCTOR_INVOCATION);
- checkSourceRange(statement, "super();", source);
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=22560
- */
- public void test0401() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0401", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
- assertNotNull(node);
- assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION);
- MethodDeclaration methodDeclaration = (MethodDeclaration) node;
- Block block = methodDeclaration.getBody();
- List statements = block.statements();
- assertEquals("wrong size", 1, statements.size());
- Statement statement = (Statement) statements.get(0);
- assertTrue("Not a return statement", statement.getNodeType() == ASTNode.RETURN_STATEMENT);
- ReturnStatement returnStatement = (ReturnStatement) statement;
- Expression expression = returnStatement.getExpression();
- assertNotNull("there is no expression", expression);
- // call the default initialization
- methodDeclaration.getReturnType();
- ITypeBinding typeBinding = expression.resolveTypeBinding();
- assertNotNull("No typebinding", typeBinding);
- assertEquals("wrong name", "int", typeBinding.getName());
- }
-
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=23464
- */
- public void test0402() throws JavaModelException {
- ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", "test0402", "A.java");
- char[] source = sourceUnit.getSource().toCharArray();
- ASTNode result = runConversion(sourceUnit, true);
- ASTNode node = getASTNode((CompilationUnit) result, 1, 0, 0);
- assertEquals("Wrong number of errors", 0, ((CompilationUnit) result).getProblems().length);
- assertNotNull(node);
- assertTrue("Not a super method invocation", node.getNodeType() == ASTNode.SUPER_CONSTRUCTOR_INVOCATION);
- checkSourceRange(node, "new A().super();", source);
- }
-
- private ASTNode getASTNodeToCompare(org.eclipse.jdt.core.dom.CompilationUnit unit) {
- ExpressionStatement statement = (ExpressionStatement) getASTNode(unit, 0, 0, 0);
- return (ASTNode) ((MethodInvocation) statement.getExpression()).arguments().get(0);
- }
-
- private ASTNode getASTNode(org.eclipse.jdt.core.dom.CompilationUnit unit, int typeIndex, int bodyIndex, int statementIndex) {
- BodyDeclaration bodyDeclaration = (BodyDeclaration)((TypeDeclaration)unit.types().get(typeIndex)).bodyDeclarations().get(bodyIndex);
- if (bodyDeclaration instanceof MethodDeclaration) {
- MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration;
- Block block = methodDeclaration.getBody();
- return (ASTNode) block.statements().get(statementIndex);
- } else if (bodyDeclaration instanceof TypeDeclaration) {
- TypeDeclaration typeDeclaration = (TypeDeclaration) bodyDeclaration;
- return (ASTNode) typeDeclaration.bodyDeclarations().get(statementIndex);
- }
- return null;
- }
-
- private ASTNode getASTNode(org.eclipse.jdt.core.dom.CompilationUnit unit, int typeIndex, int bodyIndex) {
- return (ASTNode) ((TypeDeclaration)unit.types().get(typeIndex)).bodyDeclarations().get(bodyIndex);
- }
-
- private ASTNode getASTNode(org.eclipse.jdt.core.dom.CompilationUnit unit, int typeIndex) {
- return (ASTNode) (TypeDeclaration)unit.types().get(typeIndex);
- }
-
- private void checkSourceRange(ASTNode node, String expectedContents, char[] source) {
- assertNotNull("The node is null", node);
- assertTrue("The node(" + node.getClass() + ").getLength() == 0", node.getLength() != 0);
- assertTrue("The node.getStartPosition() == -1", node.getStartPosition() != -1);
- int length = node.getLength();
- int start = node.getStartPosition();
- char[] actualContents = new char[length];
- System.arraycopy(source, start, actualContents, 0, length);
- String actualContentsString = new String(actualContents);
- assertTrue("The two strings are not equals\n---\nactualContents = >" + actualContentsString + "<\nexpectedContents = >" + expectedContents + "<\n----", expectedContents.equals(actualContentsString));
- }
-
- private boolean isMalformed(ASTNode node) {
- return (node.getFlags() & ASTNode.MALFORMED) != 0;
- }
-}
-
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTMatcherTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTMatcherTest.java
deleted file mode 100644
index 55ccab6..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTMatcherTest.java
+++ /dev/null
@@ -1,837 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial test suite for AST API
- ******************************************************************************/
-
-package org.eclipse.jdt.core.tests.dom;
-
-import java.lang.reflect.Method;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-
-import org.eclipse.jdt.core.dom.*;
-import org.eclipse.jdt.core.dom.ASTNode;
-
-/**
- * Test suite for <code>ASTMatcher</code> and <code>ASTNode.subtreeMatch</code>.
- */
-public class ASTMatcherTest extends TestCase {
-
- public static Test suite() {
- junit.framework.TestSuite suite = new junit.framework.TestSuite(ASTMatcherTest.class.getName());
-
- Class c = ASTMatcherTest.class;
- Method[] methods = c.getMethods();
- for (int i = 0, max = methods.length; i < max; i++) {
- if (methods[i].getName().startsWith("test")) {
- suite.addTest(new ASTMatcherTest(methods[i].getName()));
- }
- }
- return suite;
- }
-
- AST ast;
- SimpleName N1;
- String N1S;
- SimpleName N2;
- String N2S;
- SimpleName N3;
- String N3S;
- Expression E1;
- String E1S;
- Expression E2;
- String E2S;
- Type T1;
- String T1S;
- Statement S1;
- String S1S;
- Statement S2;
- Block B1;
- String B1S;
- String S2S;
- SingleVariableDeclaration V1;
- String V1S;
- SingleVariableDeclaration V2;
- String V2S;
- VariableDeclarationFragment W1;
- String W1S;
- VariableDeclarationFragment W2;
- String W2S;
- FieldDeclaration FD1;
- String FD1S;
- FieldDeclaration FD2;
- String FD2S;
- PackageDeclaration PD1;
- String PD1S;
- ImportDeclaration ID1;
- String ID1S;
- ImportDeclaration ID2;
- String ID2S;
- TypeDeclaration TD1;
- String TD1S;
- TypeDeclaration TD2;
- String TD2S;
- AnonymousClassDeclaration ACD1;
- String ACD1S;
- Javadoc JD1;
- String JD1S;
- Javadoc JD2;
- String JD2S;
-
- final StringBuffer b = new StringBuffer();
-
- public ASTMatcherTest(String name) {
- super(name);
- }
-
- protected void setUp() {
- ast = new AST();
- N1 = ast.newSimpleName("N");
- N1S = "(nSNNnS)";
- N2 = ast.newSimpleName("M");
- N2S = "(nSMMnS)";
- N3 = ast.newSimpleName("O");
- N3S = "(nSOOnS)";
- E1 = ast.newSimpleName("X");
- E1S = "(nSXXnS)";
- E2 = ast.newSimpleName("Y");
- E2S = "(nSYYnS)";
- T1 = ast.newSimpleType(ast.newSimpleName("Z"));
- T1S = "(tS(nSZZnS)tS)";
- S1 = ast.newContinueStatement();
- S1S = "(sCNsCN)";
- S2 = ast.newBreakStatement();
- S2S = "(sBRsBR)";
- B1 = ast.newBlock();
- B1S = "(sBsB)";
- V1 = ast.newSingleVariableDeclaration();
- V1.setType(ast.newPrimitiveType(PrimitiveType.INT));
- V1.setName(ast.newSimpleName("a"));
- V1S = "(VD(tPintinttP)(nSaanS)VD)";
- V2 = ast.newSingleVariableDeclaration();
- V2.setType(ast.newPrimitiveType(PrimitiveType.BYTE));
- V2.setName(ast.newSimpleName("b"));
- V2S = "(VD(tPbytebytetP)(nSbbnS)VD)";
- W1 = ast.newVariableDeclarationFragment();
- W1.setName(ast.newSimpleName("a"));
- W1S = "(VS(nSaanS)VS)";
- W2 = ast.newVariableDeclarationFragment();
- W2.setName(ast.newSimpleName("b"));
- W2S = "(VS(nSbbnS)VS)";
- {
- VariableDeclarationFragment temp = ast.newVariableDeclarationFragment();
- temp.setName(ast.newSimpleName("f"));
- FD1 = ast.newFieldDeclaration(temp);
- FD1.setType(ast.newPrimitiveType(PrimitiveType.INT));
- FD1S = "(FD(tPintinttP)(VS(nSffnS)VS)FD)";
- }
- {
- VariableDeclarationFragment temp = ast.newVariableDeclarationFragment();
- temp.setName(ast.newSimpleName("g"));
- FD2 = ast.newFieldDeclaration(temp);
- FD2.setType(ast.newPrimitiveType(PrimitiveType.CHAR));
- FD2S = "(FD(tPcharchartP)(VS(nSggnS)VS)FD)";
- }
- PD1 = ast.newPackageDeclaration();
- PD1.setName(ast.newSimpleName("p"));
- PD1S = "(PD(nSppnS)PD)";
- ID1 = ast.newImportDeclaration();
- ID1.setName(ast.newSimpleName("i"));
- ID1S = "(ID(nSiinS)ID)";
- ID2 = ast.newImportDeclaration();
- ID2.setName(ast.newSimpleName("j"));
- ID2S = "(ID(nSjjnS)ID)";
- TD1 = ast.newTypeDeclaration();
- TD1.setName(ast.newSimpleName("c"));
- TD1S = "(TD(nSccnS)TD)";
- TD2 = ast.newTypeDeclaration();
- TD2.setName(ast.newSimpleName("d"));
- TD2S = "(TD(nSddnS)TD)";
-
- ACD1 = ast.newAnonymousClassDeclaration();
- ACD1S = "(ACDACD)";
-
- JD1 = ast.newJavadoc();
- JD1.setComment("/**X*/");
- JD1S = "(JD/**X*//**X*/JD)";
- JD2 = ast.newJavadoc();
- JD2.setComment("/**Y*/");
- JD2S = "(JD/**Y*//**Y*/JD)";
-
- }
-
- protected void tearDown() {
- ast = null;
- }
-
-
- /**
- * An ASTMatcher that simply records the arguments it is passed,
- * immediately returns a pre-ordained answer, and counts how many
- * times it is called.
- */
- class TestMatcher extends ASTMatcher {
-
- public Object receiver;
- public Object other;
- public boolean result;
- public boolean superMatch;
- public boolean superMatchResult;
- public int matchCalls = 0;
-
- TestMatcher() {
- }
-
- boolean standardBody(ASTNode receiver, Object other, boolean superMatchResult) {
- matchCalls++;
- this.receiver = receiver;
- this.other = other;
- this.superMatchResult = superMatchResult;
- if (superMatch) {
- return this.superMatchResult;
- } else {
- return this.result;
- }
- }
-
- public boolean match(AnonymousClassDeclaration node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ArrayAccess node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ArrayCreation node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ArrayInitializer node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ArrayType node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(AssertStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(Assignment node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(Block node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(BooleanLiteral node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(BreakStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(CastExpression node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(CatchClause node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(CharacterLiteral node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ClassInstanceCreation node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(CompilationUnit node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ConditionalExpression node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ConstructorInvocation node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ContinueStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(DoStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(EmptyStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ExpressionStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(FieldAccess node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(FieldDeclaration node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ForStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(IfStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ImportDeclaration node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(InfixExpression node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(Initializer node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(Javadoc node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(LabeledStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(MethodDeclaration node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(MethodInvocation node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(NullLiteral node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(NumberLiteral node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(PackageDeclaration node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ParenthesizedExpression node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(PostfixExpression node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(PrefixExpression node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(PrimitiveType node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(QualifiedName node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ReturnStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(SimpleName node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(SimpleType node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(SingleVariableDeclaration node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(StringLiteral node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(SuperConstructorInvocation node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(SuperFieldAccess node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(SuperMethodInvocation node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(SwitchCase node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(SwitchStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(SynchronizedStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ThisExpression node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(ThrowStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(TryStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(TypeDeclaration node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(TypeDeclarationStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(TypeLiteral node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(VariableDeclarationExpression node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(VariableDeclarationFragment node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(VariableDeclarationStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- public boolean match(WhileStatement node, Object other) {
- return standardBody(node, other, superMatch ? super.match(node, other) : false);
- }
- }
-
- /**
- * AST node visitor that counts the nodes visited.
- */
- static class NodeCounter extends ASTVisitor {
- public int count = 0;
-
- /* (no javadoc for this method)
- * Method declared on ASTVisitor.
- */
- public void preVisit(ASTNode node) {
- count++;
- }
-
- }
-
- /**
- * Returns the number of AST nodes in the given subtree.
- *
- * @param node the root of the subtree
- * @return the number of nodes (always positive)
- */
- static int nodeCount(ASTNode node) {
- NodeCounter c = new NodeCounter();
- node.accept(c);
- return c.count;
- }
-
- /**
- * Checks that the ASTNode.subtreeMatch mechanism is working
- * for a node of a given type.
- */
- void basicMatch(ASTNode node) {
- int count = nodeCount(node);
-
- // check that matcher was called with right arguments
- // and that matches succeed
- TestMatcher m1 = new TestMatcher();
- Object o1 = new Object();
- m1.result = true;
- boolean result = node.subtreeMatch(m1, o1);
- assertTrue(m1.matchCalls == 1);
- assertTrue(m1.receiver == node);
- assertTrue(m1.other == o1);
- assertTrue(result == true);
-
- // check that matcher was called with right arguments
- // and that non-matches fail
- m1 = new TestMatcher();
- o1 = new Object();
- m1.result = false;
- result = node.subtreeMatch(m1, o1);
- assertTrue(m1.matchCalls == 1);
- assertTrue(m1.receiver == node);
- assertTrue(m1.other == o1);
- assertTrue(result == false);
-
- // check that ASTMatcher default implementations delegate
- m1 = new TestMatcher();
- m1.superMatch = true;
- result = node.subtreeMatch(m1, node);
- assertTrue(m1.matchCalls == count);
- assertTrue(result == true);
-
- }
-
- // NAMES
- public void testSimpleName() {
- Name x1 = ast.newName(new String[]{"Z"});
- basicMatch(x1);
- }
-
- public void testQualifiedName() {
- Name x1 = ast.newName(new String[]{"X", "Y"});
- basicMatch(x1);
- }
-
-
- // TYPES
- public void testPrimitiveType() {
- Type x1 = ast.newPrimitiveType(PrimitiveType.CHAR);
- basicMatch(x1);
- }
-
- public void testSimpleType() {
- Type x1 = ast.newSimpleType(ast.newName(new String[]{"Z"}));
- basicMatch(x1);
- }
-
- public void testArrayType() {
- Type x0 = ast.newPrimitiveType(PrimitiveType.CHAR);
- Type x1 = ast.newArrayType(x0);
- basicMatch(x1);
- }
-
- // EXPRESSIONS and STATEMENTS
-
- public void testAnonymousClassDeclaration() {
- AnonymousClassDeclaration x1 = ast.newAnonymousClassDeclaration();
- x1.bodyDeclarations().add(FD1);
- x1.bodyDeclarations().add(FD2);
- basicMatch(x1);
- }
- public void testArrayAccess() {
- ArrayAccess x1 = ast.newArrayAccess();
- x1.setArray(E1);
- x1.setIndex(E2);
- basicMatch(x1);
- }
- public void testArrayCreation() {
- ArrayCreation x1 = ast.newArrayCreation();
- x1.setType(ast.newArrayType(T1));
- x1.dimensions().add(E1);
- x1.dimensions().add(E2);
- x1.setInitializer(ast.newArrayInitializer());
- basicMatch(x1);
- }
- public void testArrayInitializer() {
- ArrayInitializer x1 = ast.newArrayInitializer();
- x1.expressions().add(E1);
- x1.expressions().add(E2);
- basicMatch(x1);
- }
- public void testAssertStatement() {
- AssertStatement x1 = ast.newAssertStatement();
- x1.setExpression(E1);
- x1.setMessage(E2);
- basicMatch(x1);
- }
- public void testAssignment() {
- Assignment x1 = ast.newAssignment();
- x1.setLeftHandSide(E1);
- x1.setRightHandSide(E2);
- basicMatch(x1);
- }
- public void testBlock() {
- Block x1 = ast.newBlock();
- x1.statements().add(S1);
- x1.statements().add(S2);
- basicMatch(x1);
- }
- public void testBooleanLiteral() {
- BooleanLiteral x1 = ast.newBooleanLiteral(true);
- basicMatch(x1);
- }
- public void testBreakStatement() {
- BreakStatement x1 = ast.newBreakStatement();
- x1.setLabel(N1);
- basicMatch(x1);
- }
- public void testCastExpression() {
- CastExpression x1 = ast.newCastExpression();
- x1.setType(T1);
- x1.setExpression(E1);
- basicMatch(x1);
- }
- public void testCatchClause() {
- CatchClause x1 = ast.newCatchClause();
- x1.setException(V1);
- x1.setBody(B1);
- basicMatch(x1);
- }
- public void testCharacterLiteral() {
- CharacterLiteral x1 = ast.newCharacterLiteral();
- x1.setCharValue('q');
- basicMatch(x1);
- }
- public void testClassInstanceCreation() {
- ClassInstanceCreation x1 = ast.newClassInstanceCreation();
- x1.setExpression(E1);
- x1.setName(N1);
- x1.setAnonymousClassDeclaration(ACD1);
- basicMatch(x1);
- }
- public void testCompilationUnit() {
- CompilationUnit x1 = ast.newCompilationUnit();
- x1.setPackage(PD1);
- x1.imports().add(ID1);
- x1.imports().add(ID2);
- x1.types().add(TD1);
- x1.types().add(TD2);
- basicMatch(x1);
- }
- public void testConditionalExpression() {
- ConditionalExpression x1 = ast.newConditionalExpression();
- x1.setExpression(E1);
- x1.setThenExpression(E2);
- x1.setElseExpression(N1);
- basicMatch(x1);
- }
- public void testConstructorInvocation() {
- ConstructorInvocation x1 = ast.newConstructorInvocation();
- x1.arguments().add(E1);
- x1.arguments().add(E2);
- basicMatch(x1);
- }
- public void testContinueStatement() {
- ContinueStatement x1 = ast.newContinueStatement();
- x1.setLabel((SimpleName) N1);
- basicMatch(x1);
- }
- public void testDoStatement() {
- DoStatement x1 = ast.newDoStatement();
- x1.setExpression(E1);
- x1.setBody(S1);
- basicMatch(x1);
- }
- public void testEmptyStatement() {
- EmptyStatement x1 = ast.newEmptyStatement();
- basicMatch(x1);
- }
- public void testExpressionStatement() {
- ExpressionStatement x1 = ast.newExpressionStatement(E1);
- basicMatch(x1);
- }
- public void testFieldAccess() {
- FieldAccess x1 = ast.newFieldAccess();
- x1.setExpression(E1);
- x1.setName(N1);
- basicMatch(x1);
- }
- public void testFieldDeclaration() {
- FieldDeclaration x1 = ast.newFieldDeclaration(W1);
- x1.setJavadoc(JD1);
- x1.setType(T1);
- x1.fragments().add(W2);
- basicMatch(x1);
- }
- public void testForStatement() {
- ForStatement x1 = ast.newForStatement();
- x1.initializers().add(E1);
- x1.initializers().add(E2);
- x1.setExpression(N1);
- x1.updaters().add(N2);
- x1.updaters().add(N3);
- x1.setBody(S1);
- basicMatch(x1);
- }
- public void testIfStatement() {
- IfStatement x1 = ast.newIfStatement();
- x1.setExpression(E1);
- x1.setThenStatement(S1);
- x1.setElseStatement(S2);
- basicMatch(x1);
- }
- public void testImportDeclaration() {
- ImportDeclaration x1 = ast.newImportDeclaration();
- x1.setName(N1);
- basicMatch(x1);
- }
- public void testInfixExpression() {
- InfixExpression x1 = ast.newInfixExpression();
- x1.setOperator(InfixExpression.Operator.PLUS);
- x1.setLeftOperand(E1);
- x1.setRightOperand(E2);
- x1.extendedOperands().add(N1);
- x1.extendedOperands().add(N2);
- basicMatch(x1);
- }
- public void testInitializer() {
- Initializer x1 = ast.newInitializer();
- x1.setJavadoc(JD1);
- x1.setBody(B1);
- basicMatch(x1);
- }
- public void testJavadoc() {
- Javadoc x1 = ast.newJavadoc();
- x1.setComment("/**?*/");
- basicMatch(x1);
- }
-
- public void testLabeledStatement() {
- LabeledStatement x1 = ast.newLabeledStatement();
- x1.setLabel(N1);
- x1.setBody(S1);
- basicMatch(x1);
- }
- public void testMethodDeclaration() {
- MethodDeclaration x1 = ast.newMethodDeclaration();
- x1.setJavadoc(JD1);
- x1.setReturnType(T1);
- x1.setName(N1);
- x1.parameters().add(V1);
- x1.parameters().add(V2);
- x1.thrownExceptions().add(N2);
- x1.thrownExceptions().add(N3);
- x1.setBody(B1);
- basicMatch(x1);
- }
- public void testMethodInvocation() {
- MethodInvocation x1 = ast.newMethodInvocation();
- x1.setExpression(N1);
- x1.setName(N2);
- x1.arguments().add(E1);
- x1.arguments().add(E2);
- basicMatch(x1);
- }
- public void testNullLiteral() {
- NullLiteral x1 = ast.newNullLiteral();
- basicMatch(x1);
- }
- public void testNumberLiteral() {
- NumberLiteral x1 = ast.newNumberLiteral("1.0");
- basicMatch(x1);
- }
- public void testPackageDeclaration() {
- PackageDeclaration x1 = ast.newPackageDeclaration();
- basicMatch(x1);
- }
- public void testParenthesizedExpression() {
- ParenthesizedExpression x1 = ast.newParenthesizedExpression();
- basicMatch(x1);
- }
- public void testPostfixExpression() {
- PostfixExpression x1 = ast.newPostfixExpression();
- x1.setOperand(E1);
- x1.setOperator(PostfixExpression.Operator.INCREMENT);
- basicMatch(x1);
- }
- public void testPrefixExpression() {
- PrefixExpression x1 = ast.newPrefixExpression();
- x1.setOperand(E1);
- x1.setOperator(PrefixExpression.Operator.INCREMENT);
- basicMatch(x1);
- }
- public void testReturnStatement() {
- ReturnStatement x1 = ast.newReturnStatement();
- x1.setExpression(E1);
- basicMatch(x1);
- }
- public void testSingleVariableDeclaration() {
- SingleVariableDeclaration x1 = ast.newSingleVariableDeclaration();
- x1.setType(T1);
- x1.setName(N1);
- x1.setInitializer(E1);
- basicMatch(x1);
- }
- public void testStringLiteral() {
- StringLiteral x1 = ast.newStringLiteral();
- x1.setLiteralValue("H");
- basicMatch(x1);
- }
- public void testSuperConstructorInvocation() {
- SuperConstructorInvocation x1 = ast.newSuperConstructorInvocation();
- x1.setExpression(N1);
- x1.arguments().add(E1);
- x1.arguments().add(E2);
- basicMatch(x1);
- }
- public void testSuperFieldAccess() {
- SuperFieldAccess x1 = ast.newSuperFieldAccess();
- x1.setQualifier(N1);
- x1.setName(N2);
- basicMatch(x1);
- }
- public void testSuperMethodInvocation() {
- SuperMethodInvocation x1 = ast.newSuperMethodInvocation();
- x1.setQualifier(N1);
- x1.setName(N2);
- x1.arguments().add(E1);
- x1.arguments().add(E2);
- basicMatch(x1);
- }
- public void testSwitchCase() {
- SwitchCase x1 = ast.newSwitchCase();
- x1.setExpression(E1);
- basicMatch(x1);
- }
- public void testSwitchStatement() {
- SwitchStatement x1 = ast.newSwitchStatement();
- x1.setExpression(E1);
- x1.statements().add(S1);
- x1.statements().add(S2);
- basicMatch(x1);
- }
- public void testSynchronizedStatement() {
- SynchronizedStatement x1 = ast.newSynchronizedStatement();
- x1.setExpression(E1);
- x1.setBody(B1);
- basicMatch(x1);
- }
- public void testThisExpression() {
- ThisExpression x1 = ast.newThisExpression();
- x1.setQualifier(N1);
- basicMatch(x1);
- }
- public void testThrowStatement() {
- ThrowStatement x1 = ast.newThrowStatement();
- x1.setExpression(E1);
- basicMatch(x1);
- }
- public void testTryStatement() {
- TryStatement x1 = ast.newTryStatement();
- x1.setBody(B1);
- CatchClause c1 = ast.newCatchClause();
- c1.setException(V1);
- c1.setBody(ast.newBlock());
- x1.catchClauses().add(c1);
- CatchClause c2 = ast.newCatchClause();
- c2.setException(V2);
- c2.setBody(ast.newBlock());
- x1.catchClauses().add(c2);
- x1.setFinally(ast.newBlock());
- basicMatch(x1);
- }
- public void testTypeDeclaration() {
- TypeDeclaration x1 = ast.newTypeDeclaration();
- x1.setJavadoc(JD1);
- x1.setName(N1);
- x1.setSuperclass(N2);
- x1.superInterfaces().add(N3);
- x1.superInterfaces().add(ast.newSimpleName("J"));
- x1.bodyDeclarations().add(FD1);
- x1.bodyDeclarations().add(FD2);
- basicMatch(x1);
- }
- public void testTypeDeclarationStatement() {
- TypeDeclarationStatement x1 = ast.newTypeDeclarationStatement(TD1);
- basicMatch(x1);
- }
- public void testTypeLiteral() {
- TypeLiteral x1 = ast.newTypeLiteral();
- x1.setType(T1);
- basicMatch(x1);
- }
- public void testVariableDeclarationFragment() {
- VariableDeclarationFragment x1 = ast.newVariableDeclarationFragment();
- x1.setName(N1);
- x1.setInitializer(E1);
- basicMatch(x1);
- }
- public void testVariableDeclarationExpression() {
- VariableDeclarationExpression x1 = ast.newVariableDeclarationExpression(W1);
- x1.setType(T1);
- x1.fragments().add(W2);
- basicMatch(x1);
- }
- public void testVariableDeclarationStatement() {
- VariableDeclarationStatement x1 = ast.newVariableDeclarationStatement(W1);
- x1.setType(T1);
- x1.fragments().add(W2);
- basicMatch(x1);
- }
- public void testWhileStatement() {
- WhileStatement x1 = ast.newWhileStatement();
- x1.setExpression(E1);
- x1.setBody(S1);
- basicMatch(x1);
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTPosterChild.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTPosterChild.java
deleted file mode 100644
index c28e59a..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTPosterChild.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial implementation
- ******************************************************************************/
-/*
- * Syntactically correct Java program containing at least an instance of
- * each different kind of construct in the Java language (1.4).
- */
-// PackageDeclaration
-package org.eclipse.jdt.core.tests.dom;
-
-// ImportDeclaration (single-type)
-import java.io.Serializable;
-// ImportDeclaration (on-demand)
-import java.util.*;
-
-/**
- * TypeDeclaration (class)
- */
-public final class ASTPosterChild extends java.lang.Object
- implements Serializable, ASTPosterInterface {
-
- /**
- * FieldDeclaration
- */
- public transient boolean[] f1 = {true, false};
-
- // Initializer
- {
- f1 = null;
- }
-
- /**
- * MethodDeclaration (constructor)
- */
- ASTPosterChild() {
- // ConstructorInvocation
- this(true);
- }
-
- /**
- * MethodDeclaration (constructor)
- */
- ASTPosterChild(boolean flag) {
- // SuperConstructorInvocation
- super();
- }
-
- /**
- * MethodDeclaration (method)
- */
- public void op() {
-
- // PrimitiveType, NumberLiteral
- byte a = 0;
- // BooleanLiteral
- boolean b = true;
- // CharacterLiteral
- char c = 'x';
- short s = 1;
- long l = 1L;
- float f = 1.0f;
- double d = 1e6;
- // SimpleType, StringLiteral
- String z = "hello";//$NON-NLS-1$
- // NullLiteral
- Vector o1 = null;
- // ArrayType, ArrayInitializer
- int[] t1 = {1};
- int[][] t2 = {{1,2}, {3,4}};
- int[][][] t3 = null;
- // ClassInstanceCreation
- java.lang.Object o = new Object();
- // ArrayCreation (initializer)
- Object[] o2 = new Object[]{"0", "1"};//$NON-NLS-1$//$NON-NLS-2$
- // ArrayCreation (dimensions)
- Object[][] o3 = new Object[3][];
- // Assigment
- o3 = null;
- // ArrayAccess
- Object x1 = o3[0];
- // CastExpression
- Object x2 = (Object) o3;
- // ConditionalExpression
- int x3 = b ? 1 : 2;
- // FieldAccess
- Object x4 = System.out;
- // InfixExpression
- String x5 = "a" + "b";//$NON-NLS-1$//$NON-NLS-2$
- // InfixExpression (extended operands)
- String x6 = "a" + "b" + "c" + "d";//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
- // MethodInvocation
- notifyAll();
- // ParenthesizedExpression
- Object x7 = ((o));
- // PostfixExpression
- l++;
- // PrefixExpression
- --l;
- // ThisExpression
- Object x8 = ASTPosterChild.this;
- // TypeLiteral
- Object x9 = void.class;
-
- // AssertStatement
- // assert true: "unhappy";//$NON-NLS-1$
- // Block
- {}
- // DoStatement
- do {
- } while (false);
- // VariableDeclarationStatement
- int i;
- // ExpressionStatement
- i = 1;
- // LabeledStatement
- looping:
- // ForStatement, VariableDeclarationExpression
- for (int j=0; j<10; j++) {
- // ContinueStatement
- continue looping;
- }
- // IfStatement
- if (false)
- System.exit(0);
- else
- i++;
- // SwitchStatement
- switch (2) {
- // SwitchCase
- case 2:
- // BreakStatement
- break;
- default:
- // EmptyStatement
- ;
- }
- // SynchronizedStatement
- synchronized (this) {
- }
- // TryStatement
- try {
- // ThrowStatement
- throw new RuntimeException();
- } catch (Exception e) // CatchClause
- {
- } finally {
- }
-
- // TypeDeclarationStatement
- abstract class X {
- int f;
- void m() {
- }
- }
- // ClassInstanceCreation (with body declarations)
- Object anon = new X() {
- void m() {
- // SuperMethodInvocation
- super.m();
- // SuperFieldAccess
- super.f = 1;
- }
- };
- // WhileStatement
- boolean b1 = true;
- while (b1);
- // ReturnStatement;
- return;
- }
-
-}
-
-/**
- * TypeDeclaration (interface)
- */
-interface ASTPosterInterface {
-
- String FOO = "hi";//$NON-NLS-1$
- void op();
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
deleted file mode 100644
index c6c910d..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
+++ /dev/null
@@ -1,5419 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial test suite for AST API
- ******************************************************************************/
-
-package org.eclipse.jdt.core.tests.dom;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import java.util.Map;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-
-
-import org.eclipse.jdt.core.dom.*;
-
-// testing
-
-public class ASTTest extends TestCase {
-
-
-
- public static Test suite() {
- junit.framework.TestSuite suite = new junit.framework.TestSuite(ASTTest.class.getName());
-
- Class c = ASTTest.class;
- Method[] methods = c.getMethods();
- for (int i = 0, max = methods.length; i < max; i++) {
- if (methods[i].getName().startsWith("test")) {
- suite.addTest(new ASTTest(methods[i].getName()));
- }
- }
- return suite;
- }
-
- AST ast;
-
- public ASTTest(String name) {
- super(name);
- }
-
- protected void setUp() {
- ast = new AST();
- }
-
- protected void tearDown() {
- ast = null;
- }
-
-
- /**
- * Snippets that show how to...
- */
- public void testExampleSnippets() {
- {
- AST ast = new AST();
- CompilationUnit cu = ast.newCompilationUnit();
-
- // package com.example;
- PackageDeclaration pd = ast.newPackageDeclaration();
- pd.setName(ast.newName(new String[]{"com", "example"}));
- cu.setPackage(pd);
- assertTrue(pd.getRoot() == cu);
-
- // import java.io;*;
- ImportDeclaration im1 = ast.newImportDeclaration();
- im1.setName(ast.newName(new String[]{"java", "io"}));
- im1.setOnDemand(true);
- cu.imports().add(im1);
- assertTrue(im1.getRoot() == cu);
-
- // import java.util.List;
- ImportDeclaration im2 = ast.newImportDeclaration();
- im2.setName(ast.newName(new String[]{"java", "util", "List"}));
- im2.setOnDemand(false);
- cu.imports().add(im2);
- assertTrue(im2.getRoot() == cu);
-
- // public class MyClass {}
- TypeDeclaration td = ast.newTypeDeclaration();
- td.setModifiers(Modifier.PUBLIC);
- td.setInterface(false);
- td.setName(ast.newSimpleName("MyClass"));
- cu.types().add(td);
- assertTrue(td.getRoot() == cu);
-
- // private static boolean DEBUG = true;
- VariableDeclarationFragment f1 = ast.newVariableDeclarationFragment();
- f1.setName(ast.newSimpleName("DEBUG"));
- f1.setInitializer(ast.newBooleanLiteral(true));
- FieldDeclaration fd = ast.newFieldDeclaration(f1);
- fd.setType(ast.newPrimitiveType(PrimitiveType.BOOLEAN));
- fd.setModifiers(Modifier.PRIVATE | Modifier.STATIC);
- td.bodyDeclarations().add(fd);
- assertTrue(fd.getRoot() == cu);
-
- // public static void main();
- MethodDeclaration md = ast.newMethodDeclaration();
- md.setModifiers(Modifier.PUBLIC | Modifier.STATIC);
- md.setConstructor(false);
- md.setName(ast.newSimpleName("main"));
- md.setReturnType(ast.newPrimitiveType(PrimitiveType.VOID));
- td.bodyDeclarations().add(md);
- assertTrue(md.getRoot() == cu);
-
- // String[] args
- SingleVariableDeclaration a1 = ast.newSingleVariableDeclaration();
- a1.setType(ast.newArrayType(
- ast.newSimpleType(ast.newSimpleName("String"))));
- a1.setName(ast.newSimpleName("args"));
- md.parameters().add(a1);
- assertTrue(a1.getRoot() == cu);
-
- // {}
- Block b = ast.newBlock();
- md.setBody(b);
- assertTrue(b.getRoot() == cu);
-
- // System.out.println("hello world");
- MethodInvocation e = ast.newMethodInvocation();
- e.setExpression(ast.newName(new String[] {"System", "out"}));
- e.setName(ast.newSimpleName("println"));
- StringLiteral h = ast.newStringLiteral();
- h.setLiteralValue("hello world");
- e.arguments().add(h);
-
- b.statements().add(ast.newExpressionStatement(e));
- assertTrue(e.getRoot() == cu);
- assertTrue(h.getRoot() == cu);
-
- // new String[len]
- ArrayCreation ac1 = ast.newArrayCreation();
- ac1.setType(
- ast.newArrayType(
- ast.newSimpleType(ast.newSimpleName("String"))));
- ac1.dimensions().add(ast.newSimpleName("len"));
- b.statements().add(ast.newExpressionStatement(ac1));
- assertTrue(ac1.getRoot() == cu);
-
- // new double[7][24][]
- ArrayCreation ac2 = ast.newArrayCreation();
- ac2.setType(
- ast.newArrayType(
- ast.newPrimitiveType(PrimitiveType.DOUBLE), 3));
- ac2.dimensions().add(ast.newNumberLiteral("7"));
- ac2.dimensions().add(ast.newNumberLiteral("24"));
- b.statements().add(ast.newExpressionStatement(ac2));
- assertTrue(ac2.getRoot() == cu);
-
- // new int[] {1, 2}
- ArrayCreation ac3 = ast.newArrayCreation();
- ac3.setType(
- ast.newArrayType(
- ast.newPrimitiveType(PrimitiveType.INT)));
- ArrayInitializer ai = ast.newArrayInitializer();
- ac3.setInitializer(ai);
- ai.expressions().add(ast.newNumberLiteral("1"));
- ai.expressions().add(ast.newNumberLiteral("2"));
- b.statements().add(ast.newExpressionStatement(ac3));
- assertTrue(ac3.getRoot() == cu);
- assertTrue(ai.getRoot() == cu);
-
- // new String(10)
- ClassInstanceCreation cr1 = ast.newClassInstanceCreation();
- cr1.setName(ast.newSimpleName("String"));
- cr1.arguments().add(ast.newNumberLiteral("10"));
- b.statements().add(ast.newExpressionStatement(cr1));
- assertTrue(cr1.getRoot() == cu);
-
- // new Listener() {public void handleEvent() {} }
- ClassInstanceCreation cr2 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration ad1 = ast.newAnonymousClassDeclaration();
- cr2.setAnonymousClassDeclaration(ad1);
- cr2.setName(ast.newSimpleName("Listener"));
- MethodDeclaration md0 = ast.newMethodDeclaration();
- md0.setModifiers(Modifier.PUBLIC);
- md0.setName(ast.newSimpleName("handleEvent"));
- md0.setBody(ast.newBlock());
- ad1.bodyDeclarations().add(md0);
- b.statements().add(ast.newExpressionStatement(cr2));
- assertTrue(cr2.getRoot() == cu);
- assertTrue(md0.getRoot() == cu);
- assertTrue(ad1.getRoot() == cu);
-
- }
- }
-
- abstract class Property {
-
- /**
- * The property name.
- */
- private String propertyName;
-
- /**
- * Indicates whether this property is compulsory, in that every node
- * must have a value at all times.
- */
- private boolean compulsory;
-
- /**
- * The type of node allowed as a child.
- */
- private Class nodeType;
-
- /**
- * Creates a new property with the given name.
- */
- Property(String propertyName, boolean compulsory, Class nodeType) {
- this.propertyName = propertyName;
- this.compulsory = compulsory;
- this.nodeType = nodeType;
- }
-
- /**
- * Returns a sample node of a type suitable for storing
- * in this property.
- *
- * @param ast the target AST
- * @param parented <code>true</code> if the sample should be
- * parented, and <code>false</code> if unparented
- * @return a sample node
- */
- public abstract ASTNode sample(AST ast, boolean parented);
-
- /**
- * Returns a sample node of a type suitable for storing
- * in this property. The sample embeds the node itself.
- * <p>
- * For instance, for an Expression-valued property of a given
- * Statement, this method returns an Expression that embeds
- * this Statement node (as a descendent).
- * </p>
- * <p>
- * Returns <code>null</code> if such an embedding is impossible.
- * For instance, for an Name-valued property of a given
- * Statement, this method returns <code>null</code> because
- * an Expression cannot be embedded in a Name.
- * </p>
- * <p>
- * This implementation returns <code>null</code>. Subclasses
- * should reimplement to specify an embedding.
- * </p>
- *
- * @param ast the target AST
- * @return a sample node that embeds the given node,
- * and <code>null</code> if such an embedding is impossible
- */
- public ASTNode wrap() {
- return null;
- }
-
- /**
- * Undoes the effects of a previous <code>wrap</code>.
- * <p>
- * This implementation does nothing. Subclasses
- * should reimplement if they reimplement <code>wrap</code>.
- * </p>
- *
- * @param ast the target AST
- * @return a sample node that embeds the given node,
- * and <code>null</code> if such an embedding is impossible
- */
- public void unwrap() {
- }
-
- /**
- * Returns whether this property is compulsory, in that every node
- * must have a value at all times.
- *
- * @return <code>true</code> if the property is compulsory,
- * and <code>false</code> if the property may be null
- */
- public final boolean isCompulsory() {
- return compulsory;
- }
-
- /**
- * Returns the value of this property.
- * <p>
- * This implementation throws an unchecked exception. Subclasses
- * should reimplement.
- * </p>
- *
- * @return the property value, or <code>null</code> if no value
- */
- public ASTNode get() {
- throw new RuntimeException("get not implemented");
- }
-
- /**
- * Sets or clears the value of this property.
- * <p>
- * This implementation throws an unchecked exception. Subclasses
- * should reimplement.
- * </p>
- *
- * @param value the property value, or <code>null</code> if no value
- */
- public void set(ASTNode value) {
- throw new RuntimeException("get not implemented");
- }
- }
-
- /**
- * Exercises the given property of the given node.
- *
- * @param node the node to test
- * @param prop the property descriptor
- */
- void genericPropertyTest(ASTNode node, Property prop) {
-
- ASTNode x1 = prop.sample(node.getAST(), false);
- prop.set(x1);
- assertTrue(prop.get() == x1);
- assertTrue(x1.getParent() == node);
-
- // check handling of null
- if (prop.isCompulsory()) {
- try {
- prop.set(null);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
- } else {
- long previousCount = node.getAST().modificationCount();
- prop.set(null);
- assertTrue(prop.get() == null);
- assertTrue(node.getAST().modificationCount() > previousCount);
- }
-
- // check that a child from a different AST is detected
- try {
- prop.set(prop.sample(new AST(), false));
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- // check that a child with a parent is detected
- try {
- ASTNode b1 = prop.sample(node.getAST(), true);
- prop.set(b1); // bogus: already has parent
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- // check that a cycle is detected
- assertTrue(node.getParent() == null);
- ASTNode s1 = null;
- try {
- s1 = prop.wrap();
- if (s1 != null) {
- prop.set(s1); // bogus: creates a cycle
- assertTrue(false);
- }
- } catch (RuntimeException e) {
- // pass
- } finally {
- if (s1 != null) {
- prop.unwrap();
- assertTrue(node.getParent() == null);
- }
- }
- }
-
- /**
- * Exercises the given property of the given node.
- *
- * @param node the node to test
- * @param children the node to test
- * @param prop the property descriptor
- */
- void genericPropertyListTest(ASTNode node, List children, Property prop) {
-
- // wipe the slate clean
- children.clear();
- assertTrue(children.size() == 0);
-
- // add a child
- ASTNode x1 = prop.sample(node.getAST(), false);
- long previousCount = node.getAST().modificationCount();
- children.add(x1);
- assertTrue(node.getAST().modificationCount() > previousCount);
- assertTrue(children.size() == 1);
- assertTrue(children.get(0) == x1);
- assertTrue(x1.getParent() == node);
-
- // add a second child
- ASTNode x2 = prop.sample(node.getAST(), false);
- previousCount = node.getAST().modificationCount();
- children.add(x2);
- assertTrue(node.getAST().modificationCount() > previousCount);
- assertTrue(children.size() == 2);
- assertTrue(children.get(0) == x1);
- assertTrue(children.get(1) == x2);
- assertTrue(x1.getParent() == node);
- assertTrue(x2.getParent() == node);
-
- // remove the first child
- previousCount = node.getAST().modificationCount();
- children.remove(0);
- assertTrue(node.getAST().modificationCount() > previousCount);
- assertTrue(children.size() == 1);
- assertTrue(children.get(0) == x2);
- assertTrue(x1.getParent() == null);
- assertTrue(x2.getParent() == node);
-
- // remove the remaining child
- previousCount = node.getAST().modificationCount();
- children.remove(x2);
- assertTrue(node.getAST().modificationCount() > previousCount);
- assertTrue(children.size() == 0);
- assertTrue(x1.getParent() == null);
- assertTrue(x2.getParent() == null);
-
- // check that null is never allowed
- try {
- children.add(null);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- // check that a child from a different AST is detected
- try {
- children.add(prop.sample(new AST(), false));
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- // check that a child with a parent is detected
- try {
- ASTNode b1 = prop.sample(node.getAST(), true);
- children.add(b1); // bogus: already has parent
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- // check that a cycle is detected
- assertTrue(node.getParent() == null);
- ASTNode s1 = null;
- try {
- s1 = prop.wrap();
- if (s1 != null) {
- children.add(s1); // bogus: creates a cycle
- assertTrue(false);
- }
- } catch (RuntimeException e) {
- // pass
- } finally {
- if (s1 != null) {
- prop.unwrap();
- assertTrue(node.getParent() == null);
- }
- }
-
- }
-
- public void testAST() {
-
- // modification count is always non-negative
- assertTrue(ast.modificationCount() >= 0);
-
- // modification count increases for node creations
- long previousCount = ast.modificationCount();
- SimpleName x = ast.newSimpleName("first");
- assertTrue(ast.modificationCount() > previousCount);
-
- // modification count does not increase for reading node attributes
- previousCount = ast.modificationCount();
- x.getIdentifier();
- x.getParent();
- x.getRoot();
- x.getAST();
- x.getFlags();
- x.getStartPosition();
- x.getLength();
- x.equals(x);
- assertTrue(ast.modificationCount() == previousCount);
-
- // modification count does not increase for reading or writing properties
- previousCount = ast.modificationCount();
- x.getProperty("any");
- x.setProperty("any", "value"); // N.B.
- x.properties();
- assertTrue(ast.modificationCount() == previousCount);
-
- // modification count increases for changing node attributes
- previousCount = ast.modificationCount();
- x.setIdentifier("second");
- assertTrue(ast.modificationCount() > previousCount);
-
- previousCount = ast.modificationCount();
- x.setFlags(0);
- assertTrue(ast.modificationCount() > previousCount);
-
- previousCount = ast.modificationCount();
- x.setSourceRange(-1,0);
- assertTrue(ast.modificationCount() > previousCount);
- }
-
- public void testWellKnownBindings() {
-
- // well known bindings
- String[] wkbs = {
- "byte", "char", "short", "int", "long",
- "boolean", "float", "double", "void",
- "java.lang.Object",
- "java.lang.String",
- "java.lang.StringBuffer",
- "java.lang.Throwable",
- "java.lang.Exception",
- "java.lang.RuntimeException",
- "java.lang.Error",
- };
-
- // no-so-well-known bindings
- String[] nwkbs = {
- "verylong",
- "java.lang.Math",
- "com.example.MyCode",
- };
-
- // none of the well known bindings resolve in a plain AST
- for (int i = 0; i<wkbs.length; i++) {
- assertTrue(ast.resolveWellKnownType(wkbs[i]) == null);
- }
-
- // none of the no so well known bindings resolve either
- for (int i = 0; i<nwkbs.length; i++) {
- assertTrue(ast.resolveWellKnownType(nwkbs[i]) == null);
- }
- }
-
- public void testSimpleName() {
- long previousCount = ast.modificationCount();
- SimpleName x = ast.newSimpleName("foo");
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Name);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue("foo".equals(x.getIdentifier()));
- assertTrue(x.getNodeType() == ASTNode.SIMPLE_NAME);
- assertTrue(x.isDeclaration() == false);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- previousCount = ast.modificationCount();
- x.setIdentifier("bar");
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue("bar".equals(x.getIdentifier()));
-
- // check that property cannot be set to null
- try {
- x.setIdentifier(null);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- // check that property cannot be set to keyword or reserved work
- String[] reserved =
- new String[] {
- "true", "false", "null", // literals
- "abstract", "default", "if", "private", "this",
- "boolean", "do", "implements", "protected", "throw",
- "break", "double", "import", "public", "throws",
- "byte", "else", "instanceof", "return", "transient",
- "case", "extends", "int", "short", "try",
- "catch", "final", "interface", "static", "void",
- "char", "finally", "long", "strictfp", "volatile",
- "class", "float", "native", "super", "while",
- "const", "for", "new", "switch",
- "continue", "goto", "package", "synchronized"};
- for (int i=0; i<reserved.length; i++) {
- try {
- x.setIdentifier(reserved[i]);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
- }
-
- // check that "assert" is not considered a keyword
- x.setIdentifier("assert");
-
- // check that isDeclaration works
- QualifiedName y = ast.newQualifiedName(ast.newSimpleName("a"), x);
- assertTrue(x.isDeclaration() == false);
- y.setName(ast.newSimpleName("b"));
- assertTrue(x.isDeclaration() == false);
-
- TypeDeclaration td = ast.newTypeDeclaration();
- td.setName(x);
- assertTrue(x.isDeclaration() == true);
- td.setName(ast.newSimpleName("b"));
- assertTrue(x.isDeclaration() == false);
-
- MethodDeclaration md = ast.newMethodDeclaration();
- md.setName(x);
- assertTrue(x.isDeclaration() == true);
- md.setName(ast.newSimpleName("b"));
- assertTrue(x.isDeclaration() == false);
-
- SingleVariableDeclaration vd = ast.newSingleVariableDeclaration();
- vd.setName(x);
- assertTrue(x.isDeclaration() == true);
- vd.setName(ast.newSimpleName("b"));
- assertTrue(x.isDeclaration() == false);
-
- VariableDeclarationFragment fd = ast.newVariableDeclarationFragment();
- fd.setName(x);
- assertTrue(x.isDeclaration() == true);
- fd.setName(ast.newSimpleName("b"));
- assertTrue(x.isDeclaration() == false);
-
- }
-
- public void testQualifiedName() {
- long previousCount = ast.modificationCount();
- final QualifiedName x = ast.newQualifiedName(
- ast.newSimpleName("q"),
- ast.newSimpleName("i"));
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Name);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getQualifier().getParent() == x);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getName().isDeclaration() == false);
- assertTrue(x.getNodeType() == ASTNode.QUALIFIED_NAME);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Qualifier", true, Name.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- QualifiedName result = targetAst.newQualifiedName(
- targetAst.newSimpleName("a"),
- targetAst.newSimpleName("b"));
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- QualifiedName s1 = ast.newQualifiedName(x, ast.newSimpleName("z"));
- return s1;
- }
- public void unwrap() {
- QualifiedName s1 = (QualifiedName) x.getParent();
- s1.setQualifier(ast.newSimpleName("z"));
- }
- public ASTNode get() {
- return x.getQualifier();
- }
- public void set(ASTNode value) {
- x.setQualifier((Name) value);
- }
- });
-
- genericPropertyTest(x, new Property("Name", true, SimpleName.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((SimpleName) value);
- }
- });
-
- }
-
- public void testNullLiteral() {
- long previousCount = ast.modificationCount();
- NullLiteral x = ast.newNullLiteral();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getNodeType() == ASTNode.NULL_LITERAL);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- }
-
- public void testBooleanLiteral() {
- long previousCount = ast.modificationCount();
- BooleanLiteral x = ast.newBooleanLiteral(true);
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.booleanValue() == true);
- assertTrue(x.getNodeType() == ASTNode.BOOLEAN_LITERAL);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- previousCount = ast.modificationCount();
- x.setBooleanValue(false);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.booleanValue() == false);
-
- previousCount = ast.modificationCount();
- x.setBooleanValue(true);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.booleanValue() == true);
- }
-
- public void testStringLiteral() {
- long previousCount = ast.modificationCount();
- // check 0-arg factory first
- StringLiteral x = ast.newStringLiteral();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue("\"\"".equals(x.getEscapedValue()));
- assertTrue("".equals(x.getLiteralValue()));
- assertTrue(x.getNodeType() == ASTNode.STRING_LITERAL);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- previousCount = ast.modificationCount();
- x.setEscapedValue("\"bye\"");
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue("\"bye\"".equals(x.getEscapedValue()));
- assertTrue("bye".equals(x.getLiteralValue()));
-
- previousCount = ast.modificationCount();
- x.setLiteralValue("hi");
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue("\"hi\"".equals(x.getEscapedValue()));
- assertTrue("hi".equals(x.getLiteralValue()));
-
- // check that property cannot be set to null
- try {
- x.setEscapedValue(null);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- // check that property cannot be set to null
- try {
- x.setLiteralValue(null);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
- }
-
- public void testStringLiteralUnicode() {
- AST ast = new AST();
- StringLiteral literal = ast.newStringLiteral();
- literal.setEscapedValue("\"hello\\u0026\\u0050worl\\u0064\"");
- assertTrue(literal.getLiteralValue().equals("hello&Pworld"));
-
- ast = new AST();
- literal = ast.newStringLiteral();
- literal.setEscapedValue("\"hello\\nworld\"");
- assertTrue(literal.getLiteralValue().equals("hello\nworld"));
-
- ast = new AST();
- literal = ast.newStringLiteral();
- literal.setLiteralValue("hello\nworld");
- assertTrue(literal.getLiteralValue().equals("hello\nworld"));
-
- ast = new AST();
- literal = ast.newStringLiteral();
- literal.setLiteralValue("\n");
- assertTrue(literal.getEscapedValue().equals("\"\\n\""));
- assertTrue(literal.getLiteralValue().equals("\n"));
-
- ast = new AST();
- literal = ast.newStringLiteral();
- literal.setEscapedValue("\"hello\\\"world\"");
- assertTrue(literal.getLiteralValue().equals("hello\"world"));
-
- ast = new AST();
- literal = ast.newStringLiteral();
- literal.setLiteralValue("hello\\u0026world");
- assertTrue(literal.getLiteralValue().equals("hello\\u0026world"));
-
- ast = new AST();
- literal = ast.newStringLiteral();
- literal.setLiteralValue("hello\\u0026world");
- assertTrue(literal.getEscapedValue().equals("\"hello\\\\u0026world\""));
-
- ast = new AST();
- literal = ast.newStringLiteral();
- literal.setLiteralValue("\\u0001");
- assertTrue(literal.getEscapedValue().equals("\"\\\\u0001\""));
- }
-
- public void testCharacterLiteral() {
- long previousCount = ast.modificationCount();
- CharacterLiteral x = ast.newCharacterLiteral();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getEscapedValue().startsWith("\'"));
- assertTrue(x.getEscapedValue().endsWith("\'"));
- assertTrue(x.getNodeType() == ASTNode.CHARACTER_LITERAL);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- previousCount = ast.modificationCount();
- x.setEscapedValue("\'z\'");
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue("\'z\'".equals(x.getEscapedValue()));
- assertTrue(x.charValue() == 'z');
-
- // test other factory method
- previousCount = ast.modificationCount();
- CharacterLiteral y = ast.newCharacterLiteral();
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(y instanceof Expression);
- assertTrue(y.getAST() == ast);
- assertTrue(y.getParent() == null);
- String v = y.getEscapedValue();
- assertTrue(v.length() >= 3 && v.charAt(0) == '\'' & v.charAt(v.length()-1 ) == '\'');
-
- // check that property cannot be set to null
- try {
- x.setEscapedValue(null);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- // test escaped characters
- // b, t, n, f, r, ", ', \, 0, 1, 2, 3, 4, 5, 6, or 7
- try {
- x.setEscapedValue("\'\\b\'");
- x.setEscapedValue("\'\\t\'");
- x.setEscapedValue("\'\\n\'");
- x.setEscapedValue("\'\\f\'");
- x.setEscapedValue("\'\\\"\'");
- x.setEscapedValue("\'\\'\'");
- x.setEscapedValue("\'\\\\\'");
- x.setEscapedValue("\'\\0\'");
- x.setEscapedValue("\'\\1\'");
- x.setEscapedValue("\'\\2\'");
- x.setEscapedValue("\'\\3\'");
- x.setEscapedValue("\'\\4\'");
- x.setEscapedValue("\'\\5\'");
- x.setEscapedValue("\'\\6\'");
- x.setEscapedValue("\'\\7\'");
- x.setEscapedValue("\'\\u0041\'");
- assertTrue(x.charValue() == 'A');
- } catch(IllegalArgumentException e) {
- assertTrue(false);
- }
-
- x.setCharValue('\u0041');
- assertTrue(x.getEscapedValue().equals("\'A\'"));
- x.setCharValue('\t');
- assertTrue(x.getEscapedValue().equals("\'\\t\'"));
- x.setEscapedValue("\'\\\\\'");
- assertTrue(x.getEscapedValue().equals("\'\\\\\'"));
- assertTrue(x.charValue() == '\\');
- x.setEscapedValue("\'\\\'\'");
- assertTrue(x.getEscapedValue().equals("\'\\\'\'"));
- assertTrue(x.charValue() == '\'');
- x.setCharValue('\'');
- assertTrue(x.getEscapedValue().equals("\'\\\'\'"));
- assertTrue(x.charValue() == '\'');
- x.setCharValue('\\');
- assertTrue(x.getEscapedValue().equals("\'\\\\\'"));
- assertTrue(x.charValue() == '\\');
- }
-
- public void testNumberLiteral() {
- long previousCount = ast.modificationCount();
- NumberLiteral x = ast.newNumberLiteral("1234");
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue("1234".equals(x.getToken()));
- assertTrue(x.getNodeType() == ASTNode.NUMBER_LITERAL);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- // test other factory method
- previousCount = ast.modificationCount();
- NumberLiteral y = ast.newNumberLiteral();
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(y.getAST() == ast);
- assertTrue(y.getParent() == null);
- assertTrue("0".equals(y.getToken()));
-
- final String[] samples =
- { "0", "1", "1234567890",
- "0L", "1L", "1234567890L",
- "0l", "1l", "1234567890l",
- "077", "0177", "012345670",
- "077L", "0177L", "012345670L",
- "077l", "0177l", "012345670l",
- "0x00", "0x1", "0x0123456789ABCDEF",
- "0x00L", "0x1L", "0x0123456789ABCDEFL",
- "0x00l", "0x1l", "0x0123456789ABCDEFl",
- "1e1f", "2.f", ".3f", "0f", "3.14f", "6.022137e+23f",
- "1e1", "2.", ".3", "0.0", "3.14", "1e-9d", "1e137",
- };
- for (int i = 0; i < samples.length; i++) {
- previousCount = ast.modificationCount();
- x.setToken(samples[i]);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(samples[i].equals(x.getToken()));
- }
-
- // check that property cannot be set to null
- try {
- x.setToken(null);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- }
-
- public void testSimpleType() {
- long previousCount = ast.modificationCount();
- final SimpleType x = ast.newSimpleType(ast.newSimpleName("String"));
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Type);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.isSimpleType());
- assertTrue(!x.isArrayType());
- assertTrue(!x.isPrimitiveType());
- assertTrue(x.getNodeType() == ASTNode.SIMPLE_TYPE);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Name", true, Name.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("a");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((Name) value);
- }
- });
- }
-
- public void testPrimitiveType() {
- long previousCount = ast.modificationCount();
- PrimitiveType x = ast.newPrimitiveType(PrimitiveType.INT);
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Type);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getPrimitiveTypeCode().equals(PrimitiveType.INT));
- assertTrue(!x.isSimpleType());
- assertTrue(!x.isArrayType());
- assertTrue(x.isPrimitiveType());
- assertTrue(x.getNodeType() == ASTNode.PRIMITIVE_TYPE);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- // check the names of the primitive type codes
- assertTrue(PrimitiveType.BYTE.toString().equals("byte"));
- assertTrue(PrimitiveType.INT.toString().equals("int"));
- assertTrue(PrimitiveType.BOOLEAN.toString().equals("boolean"));
- assertTrue(PrimitiveType.CHAR.toString().equals("char"));
- assertTrue(PrimitiveType.SHORT.toString().equals("short"));
- assertTrue(PrimitiveType.LONG.toString().equals("long"));
- assertTrue(PrimitiveType.FLOAT.toString().equals("float"));
- assertTrue(PrimitiveType.DOUBLE.toString().equals("double"));
- assertTrue(PrimitiveType.VOID.toString().equals("void"));
-
-
- PrimitiveType.Code[] known = {
- PrimitiveType.BOOLEAN,
- PrimitiveType.BYTE,
- PrimitiveType.CHAR,
- PrimitiveType.INT,
- PrimitiveType.SHORT,
- PrimitiveType.LONG,
- PrimitiveType.FLOAT,
- PrimitiveType.DOUBLE,
- PrimitiveType.VOID,
- };
-
- // check all primitive type codes are distinct
- for (int i = 0; i < known.length; i++) {
- for (int j = 0; j < known.length; j++) {
- assertTrue(i == j || !known[i].equals(known[j]));
- }
- }
-
- // check all primitive type codes work
- for (int i = 0; i < known.length; i++) {
- previousCount = ast.modificationCount();
- x.setPrimitiveTypeCode(known[i]);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getPrimitiveTypeCode().equals(known[i]));
- }
- // ensure null does not work as a primitive type code
- try {
- x.setPrimitiveTypeCode(null);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- // check toCode lookup of primitive type code by name
- for (int i = 0; i < known.length; i++) {
- String name = known[i].toString();
- assertTrue(PrimitiveType.toCode(name).equals(known[i]));
- }
- assertTrue(PrimitiveType.toCode("not-a-type") == null);
- }
-
- public void testArrayType() {
- SimpleName x1 = ast.newSimpleName("String");
- SimpleType x2 = ast.newSimpleType(x1);
- long previousCount = ast.modificationCount();
- final ArrayType x = ast.newArrayType(x2);
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Type);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getComponentType().getParent() == x);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
- assertTrue(!x.isSimpleType());
- assertTrue(x.isArrayType());
- assertTrue(!x.isPrimitiveType());
- assertTrue(x.getNodeType() == ASTNode.ARRAY_TYPE);
-
- assertTrue(x.getDimensions() == 1);
- assertTrue(x.getElementType() == x2);
-
- genericPropertyTest(x, new Property("ComponentType", true, Type.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleType result = targetAst.newSimpleType(
- targetAst.newSimpleName("a"));
- if (parented) {
- targetAst.newArrayType(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ArrayType result = ast.newArrayType(x);
- return result;
- }
- public void unwrap() {
- ArrayType a = (ArrayType) x.getParent();
- a.setComponentType(ast.newPrimitiveType(PrimitiveType.INT));
- }
- public ASTNode get() {
- return x.getComponentType();
- }
- public void set(ASTNode value) {
- x.setComponentType((Type) value);
- }
- });
-
- x.setComponentType(
- ast.newArrayType(ast.newPrimitiveType(PrimitiveType.INT), 4));
-
- assertTrue(x.getDimensions() == 5);
- assertTrue(x.getElementType().isPrimitiveType());
- }
-
- public void testPackageDeclaration() {
- long previousCount = ast.modificationCount();
- final PackageDeclaration x = ast.newPackageDeclaration();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.PACKAGE_DECLARATION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Name", true, Name.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("a");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((Name) value);
- }
- });
- }
-
- public void testImportDeclaration() {
- long previousCount = ast.modificationCount();
- final ImportDeclaration x = ast.newImportDeclaration();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.isOnDemand() == false);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.IMPORT_DECLARATION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Name", true, Name.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("a");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((Name) value);
- }
- });
-
- previousCount = ast.modificationCount();
- x.setOnDemand(false);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.isOnDemand() == false);
- previousCount = ast.modificationCount();
- x.setOnDemand(true);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.isOnDemand() == true);
- }
-
- public void testCompilationUnit() {
- long previousCount = ast.modificationCount();
- final CompilationUnit x = ast.newCompilationUnit();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getPackage() == null);
- assertTrue(x.imports().size() == 0);
- assertTrue(x.types().size() == 0);
- assertTrue(x.getNodeType() == ASTNode.COMPILATION_UNIT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tClientProperties(x);
-
- genericPropertyTest(x, new Property("Package", false, PackageDeclaration.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- PackageDeclaration result = targetAst.newPackageDeclaration();
- if (parented) {
- CompilationUnit cu = targetAst.newCompilationUnit();
- cu.setPackage(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getPackage();
- }
- public void set(ASTNode value) {
- x.setPackage((PackageDeclaration) value);
- }
- });
-
- genericPropertyListTest(x, x.imports(), new Property("Imports", true, ImportDeclaration.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- ImportDeclaration result = targetAst.newImportDeclaration();
- if (parented) {
- CompilationUnit cu = targetAst.newCompilationUnit();
- cu.imports().add(result);
- }
- return result;
- }
- });
-
- genericPropertyListTest(x, x.types(), new Property("Types", true, TypeDeclaration.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- TypeDeclaration result = targetAst.newTypeDeclaration();
- if (parented) {
- CompilationUnit cu = targetAst.newCompilationUnit();
- cu.types().add(result);
- }
- return result;
- }
- });
-
- // check that TypeDeclarations in body are classified correctly
- TypeDeclaration t1 = ast.newTypeDeclaration();
- x.types().add(t1);
- assertTrue(t1.isLocalTypeDeclaration() == false);
- assertTrue(t1.isMemberTypeDeclaration() == false);
- assertTrue(t1.isPackageMemberTypeDeclaration() == true);
-
- }
-
- public void testCompilationUnitLineNumberTable() {
-// TO RUN THIS TEST YOU MUST TEMPORARILY MAKE PUBLIC
-// THE METHOD CompilationUnit.setLineEndTable
-
-// final CompilationUnit x = ast.newCompilationUnit();
-//
-// // table starts off empty
-// for (int i= -10; i < 10; i++) {
-// assertTrue(x.lineNumber(i) == 1);
-// }
-//
-// // supply a simple line table to test
-// String s = "AA\nBBB\nCC\nDDDD\nEEE";
-// assertTrue(s.length() == 18); // cross check
-// int le[] = new int[5];
-// le[0] = s.indexOf('\n');
-// le[1] = s.indexOf('\n', le[0] + 1);
-// le[2] = s.indexOf('\n', le[1] + 1);
-// le[3] = s.indexOf('\n', le[2] + 1);
-// le[4] = s.length() - 1;
-// long previousCount = ast.modificationCount();
-// x.setLineEndTable(le);
-// assertTrue(ast.modificationCount() > previousCount);
-//
-// assertTrue(x.lineNumber(0) == 1);
-// assertTrue(x.lineNumber(1) == 1);
-// assertTrue(x.lineNumber(2) == 1);
-// assertTrue(x.lineNumber(3) == 2);
-// assertTrue(x.lineNumber(4) == 2);
-// assertTrue(x.lineNumber(5) == 2);
-// assertTrue(x.lineNumber(6) == 2);
-// assertTrue(x.lineNumber(7) == 3);
-// assertTrue(x.lineNumber(8) == 3);
-// assertTrue(x.lineNumber(9) == 3);
-// assertTrue(x.lineNumber(10) == 4);
-// assertTrue(x.lineNumber(11) == 4);
-// assertTrue(x.lineNumber(12) == 4);
-// assertTrue(x.lineNumber(13) == 4);
-// assertTrue(x.lineNumber(14) == 4);
-// assertTrue(x.lineNumber(15) == 5);
-// assertTrue(x.lineNumber(16) == 5);
-// assertTrue(x.lineNumber(17) == 5);
-//
-// assertTrue(x.lineNumber(18) == 1);
-// assertTrue(x.lineNumber(100) == 1);
-// assertTrue(x.lineNumber(1000000) == 1);
-// assertTrue(x.lineNumber(-1) == 1);
-// assertTrue(x.lineNumber(-100) == 1);
-// assertTrue(x.lineNumber(-1000000) == 1);
-//
-// // slam table back to none
-// x.setLineEndTable(new int[0]);
-// for (int i= -10; i < 10; i++) {
-// assertTrue(x.lineNumber(i) == 1);
-// }
- }
-
- public void testTypeDeclaration() {
- long previousCount = ast.modificationCount();
- final TypeDeclaration x = ast.newTypeDeclaration();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof BodyDeclaration);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getModifiers() == Modifier.NONE);
- assertTrue(x.isInterface() == false);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getName().isDeclaration() == true);
- assertTrue(x.getSuperclass() == null);
- assertTrue(x.getJavadoc() == null);
- assertTrue(x.superInterfaces().size() == 0);
- assertTrue(x.bodyDeclarations().size()== 0);
- assertTrue(x.getNodeType() == ASTNode.TYPE_DECLARATION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- previousCount = ast.modificationCount();
- x.setInterface(true);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.isInterface() == true);
-
- int legal = Modifier.PUBLIC | Modifier.PROTECTED
- | Modifier.PRIVATE | Modifier.ABSTRACT | Modifier.STATIC
- | Modifier.FINAL | Modifier.STRICTFP;
- previousCount = ast.modificationCount();
- x.setModifiers(legal);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getModifiers() == legal);
-
- previousCount = ast.modificationCount();
- x.setModifiers(Modifier.NONE);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getModifiers() == Modifier.NONE);
-
- tJavadocComment(x);
-
- genericPropertyTest(x, new Property("Name", true, SimpleName.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((SimpleName) value);
- }
- });
-
- genericPropertyTest(x, new Property("Superclass", false, Name.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getSuperclass();
- }
- public void set(ASTNode value) {
- x.setSuperclass((Name) value);
- }
- });
-
- genericPropertyListTest(x, x.superInterfaces(),
- new Property("SuperInterfaces", true, Name.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- });
-
- genericPropertyListTest(x, x.bodyDeclarations(),
- new Property("BodyDeclarations", true, BodyDeclaration.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- TypeDeclaration result = targetAst.newTypeDeclaration();
- if (parented) {
- CompilationUnit cu = targetAst.newCompilationUnit();
- cu.types().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- TypeDeclaration s1 = x.getAST().newTypeDeclaration();
- s1.bodyDeclarations().add(x);
- return s1;
- }
- public void unwrap() {
- TypeDeclaration s1 = (TypeDeclaration) x.getParent();
- s1.bodyDeclarations().remove(x);
- }
- });
-
- // check special bodyDeclaration methods
- x.bodyDeclarations().clear();
- FieldDeclaration f1 = ast.newFieldDeclaration(ast.newVariableDeclarationFragment());
- FieldDeclaration f2 = ast.newFieldDeclaration(ast.newVariableDeclarationFragment());
- MethodDeclaration m1 = ast.newMethodDeclaration();
- MethodDeclaration m2 = ast.newMethodDeclaration();
- TypeDeclaration t1 = ast.newTypeDeclaration();
- TypeDeclaration t2 = ast.newTypeDeclaration();
-
- x.bodyDeclarations().add(ast.newInitializer());
- x.bodyDeclarations().add(f1);
- x.bodyDeclarations().add(ast.newInitializer());
- x.bodyDeclarations().add(f2);
- x.bodyDeclarations().add(ast.newInitializer());
- x.bodyDeclarations().add(t1);
- x.bodyDeclarations().add(ast.newInitializer());
- x.bodyDeclarations().add(m1);
- x.bodyDeclarations().add(ast.newInitializer());
- x.bodyDeclarations().add(m2);
- x.bodyDeclarations().add(ast.newInitializer());
- x.bodyDeclarations().add(t2);
- x.bodyDeclarations().add(ast.newInitializer());
-
- List fs = Arrays.asList(x.getFields());
- assertTrue(fs.size() == 2);
- assertTrue(fs.contains(f1));
- assertTrue(fs.contains(f2));
-
- List ms = Arrays.asList(x.getMethods());
- assertTrue(ms.size() == 2);
- assertTrue(ms.contains(m1));
- assertTrue(ms.contains(m2));
-
- List ts = Arrays.asList(x.getTypes());
- assertTrue(ts.size() == 2);
- assertTrue(ts.contains(t1));
- assertTrue(ts.contains(t2));
-
- // check that TypeDeclarations in body are classified correctly
- assertTrue(t1.isLocalTypeDeclaration() == false);
- assertTrue(t1.isMemberTypeDeclaration() == true);
- assertTrue(t1.isPackageMemberTypeDeclaration() == false);
-
- }
-
- public void testSingleVariableDeclaration() {
- long previousCount = ast.modificationCount();
- final SingleVariableDeclaration x = ast.newSingleVariableDeclaration();
- assertTrue(x instanceof VariableDeclaration);
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getModifiers() == Modifier.NONE);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getName().isDeclaration() == true);
- assertTrue(x.getType().getParent() == x);
- assertTrue(x.getExtraDimensions() == 0);
- assertTrue(x.getInitializer() == null);
- assertTrue(x.getNodeType() == ASTNode.SINGLE_VARIABLE_DECLARATION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- int legal = Modifier.PUBLIC | Modifier.PROTECTED
- | Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL
- | Modifier.TRANSIENT | Modifier.VOLATILE;
- previousCount = ast.modificationCount();
- x.setModifiers(legal);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getModifiers() == legal);
-
- previousCount = ast.modificationCount();
- x.setModifiers(Modifier.NONE);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getModifiers() == Modifier.NONE);
-
- previousCount = ast.modificationCount();
- x.setExtraDimensions(1);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getExtraDimensions() == 1);
-
- previousCount = ast.modificationCount();
- x.setExtraDimensions(0);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getExtraDimensions() == 0);
-
- genericPropertyTest(x, new Property("Name", true, SimpleName.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((SimpleName) value);
- }
- });
-
- genericPropertyTest(x, new Property("Type", true, Type.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleType result = targetAst.newSimpleType(
- targetAst.newSimpleName("foo"));
- if (parented) {
- targetAst.newArrayType(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getType();
- }
- public void set(ASTNode value) {
- x.setType((Type) value);
- }
- });
-
- genericPropertyTest(x, new Property("Initializer", false, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return an Expression that embeds x
- CatchClause s1 = ast.newCatchClause();
- s1.setException(x);
- return s1;
- }
- public void unwrap() {
- CatchClause s1 = (CatchClause) x.getParent();
- s1.setException(ast.newSingleVariableDeclaration());
- }
- public ASTNode get() {
- return x.getInitializer();
- }
- public void set(ASTNode value) {
- x.setInitializer((Expression) value);
- }
- });
- }
-
- public void testVariableDeclarationFragment() {
- long previousCount = ast.modificationCount();
- final VariableDeclarationFragment x = ast.newVariableDeclarationFragment();
- assertTrue(x instanceof VariableDeclaration);
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getName().isDeclaration() == true);
- assertTrue(x.getExtraDimensions() == 0);
- assertTrue(x.getInitializer() == null);
- assertTrue(x.getNodeType() == ASTNode.VARIABLE_DECLARATION_FRAGMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- previousCount = ast.modificationCount();
- x.setExtraDimensions(1);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getExtraDimensions() == 1);
-
- previousCount = ast.modificationCount();
- x.setExtraDimensions(0);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getExtraDimensions() == 0);
-
- // check that property cannot be set negative
- try {
- x.setExtraDimensions(-1);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- genericPropertyTest(x, new Property("Name", true, SimpleName.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((SimpleName) value);
- }
- });
-
- genericPropertyTest(x, new Property("Initializer", false, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return an Expression that embeds x
- VariableDeclarationExpression s1 =
- ast.newVariableDeclarationExpression(x);
- return s1;
- }
- public void unwrap() {
- VariableDeclarationExpression s1 =
- (VariableDeclarationExpression) x.getParent();
- s1.fragments().remove(x);
- }
- public ASTNode get() {
- return x.getInitializer();
- }
- public void set(ASTNode value) {
- x.setInitializer((Expression) value);
- }
- });
- }
-
- public void testMethodDeclaration() {
- long previousCount = ast.modificationCount();
- final MethodDeclaration x = ast.newMethodDeclaration();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof BodyDeclaration);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getModifiers() == Modifier.NONE);
- assertTrue(x.isConstructor() == false);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getName().isDeclaration() == true);
- assertTrue(x.getReturnType().getParent() == x);
- assertTrue(x.getExtraDimensions() == 0);
- assertTrue(x.getJavadoc() == null);
- assertTrue(x.parameters().size() == 0);
- assertTrue(x.thrownExceptions().size() == 0);
- assertTrue(x.getBody() == null);
- assertTrue(x.getNodeType() == ASTNode.METHOD_DECLARATION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- previousCount = ast.modificationCount();
- x.setConstructor(true);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.isConstructor() == true);
- assertTrue(x.getName().isDeclaration() == false);
-
- previousCount = ast.modificationCount();
- x.setConstructor(false);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.isConstructor() == false);
-
- previousCount = ast.modificationCount();
- int legal = Modifier.PUBLIC | Modifier.PROTECTED
- | Modifier.PRIVATE | Modifier.ABSTRACT | Modifier.STATIC
- | Modifier.FINAL | Modifier.SYNCHRONIZED| Modifier.NATIVE
- | Modifier.STRICTFP;
- x.setModifiers(legal);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getModifiers() == legal);
-
- previousCount = ast.modificationCount();
- x.setModifiers(Modifier.NONE);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getModifiers() == Modifier.NONE);
-
- previousCount = ast.modificationCount();
- x.setExtraDimensions(1);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getExtraDimensions() == 1);
-
- previousCount = ast.modificationCount();
- x.setExtraDimensions(0);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getExtraDimensions() == 0);
-
- tJavadocComment(x);
-
- genericPropertyTest(x, new Property("Name", true, SimpleName.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((SimpleName) value);
- }
- });
-
- genericPropertyTest(x, new Property("ReturnType", true, Type.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleType result = targetAst.newSimpleType(
- targetAst.newSimpleName("foo"));
- if (parented) {
- targetAst.newArrayType(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getReturnType();
- }
- public void set(ASTNode value) {
- x.setReturnType((Type) value);
- }
- });
-
- genericPropertyListTest(x, x.parameters(),
- new Property("Parameters", true, SingleVariableDeclaration.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SingleVariableDeclaration result = targetAst.newSingleVariableDeclaration();
- if (parented) {
- targetAst.newCatchClause().setException(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return a SingleVariableDeclaration that embeds x
- SingleVariableDeclaration s1 = ast.newSingleVariableDeclaration();
- ClassInstanceCreation s2 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s2.setAnonymousClassDeclaration(a1);
- s1.setInitializer(s2);
- a1.bodyDeclarations().add(x);
- return s1;
- }
- public void unwrap() {
- AnonymousClassDeclaration a1 = (AnonymousClassDeclaration) x.getParent();
- a1.bodyDeclarations().remove(x);
- }
- });
-
- genericPropertyListTest(x, x.thrownExceptions(),
- new Property("ThrownExceptions", true, Name.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- });
-
- genericPropertyTest(x, new Property("Body", false, Block.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Block result = targetAst.newBlock();
- if (parented) {
- Block b2 = targetAst.newBlock();
- b2.statements().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return a Block that embeds x
- Block s1 = ast.newBlock();
- TypeDeclaration s2 = ast.newTypeDeclaration();
- s1.statements().add(ast.newTypeDeclarationStatement(s2));
- s2.bodyDeclarations().add(x);
- return s1;
- }
- public void unwrap() {
- TypeDeclaration s2 = (TypeDeclaration) x.getParent();
- s2.bodyDeclarations().remove(x);
- }
- public ASTNode get() {
- return x.getBody();
- }
- public void set(ASTNode value) {
- x.setBody((Block) value);
- }
- });
- }
-
- public void testInitializer() {
- long previousCount = ast.modificationCount();
- final Initializer x = ast.newInitializer();
- assertTrue(x instanceof BodyDeclaration);
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getJavadoc() == null);
- assertTrue(x.getModifiers() == Modifier.NONE);
- assertTrue(x.getBody().getParent() == x);
- assertTrue(x.getBody().statements().size() == 0);
- assertTrue(x.getNodeType() == ASTNode.INITIALIZER);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tJavadocComment(x);
-
- int legal = Modifier.STATIC;
- previousCount = ast.modificationCount();
- x.setModifiers(legal);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getModifiers() == legal);
-
- previousCount = ast.modificationCount();
- x.setModifiers(Modifier.NONE);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getModifiers() == Modifier.NONE);
-
- genericPropertyTest(x, new Property("Body", true, Block.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Block result = targetAst.newBlock();
- if (parented) {
- Block b2 = targetAst.newBlock();
- b2.statements().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Block that embeds x
- Block s1 = ast.newBlock();
- TypeDeclaration s2 = ast.newTypeDeclaration();
- s1.statements().add(ast.newTypeDeclarationStatement(s2));
- s2.bodyDeclarations().add(x);
- return s1;
- }
- public void unwrap() {
- TypeDeclaration s2 = (TypeDeclaration) x.getParent();
- s2.bodyDeclarations().remove(x);
- }
- public ASTNode get() {
- return x.getBody();
- }
- public void set(ASTNode value) {
- x.setBody((Block) value);
- }
- });
- }
-
- public void testJavadoc() {
- long previousCount = ast.modificationCount();
- Javadoc x = ast.newJavadoc();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getComment().startsWith("/**"));
- assertTrue(x.getComment().endsWith("*/"));
- assertTrue(x.getNodeType() == ASTNode.JAVADOC);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- final String[] samples =
- {
- "/** Hello there */",
- "/**\n * Line 1\n * Line 2\n */",
- "/***/",
- };
- for (int i = 0; i < samples.length; i++) {
- previousCount = ast.modificationCount();
- x.setComment(samples[i]);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(samples[i].equals(x.getComment()));
- }
-
- final String[] badSamples =
- {
- null,
- "",
- "/* */",
- "/**/",
- "/**",
- "*/",
- };
-
- // check that property cannot be set to clearly illegal things
- for (int i = 0; i < badSamples.length; i++) {
- try {
- x.setComment(badSamples[i]);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
- }
- }
-
- public void testBlock() {
- long previousCount = ast.modificationCount();
- final Block x = ast.newBlock();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.statements().size() == 0);
- assertTrue(x.getNodeType() == ASTNode.BLOCK);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyListTest(x, x.statements(),
- new Property("Statements", true, Statement.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Block result = targetAst.newBlock();
- if (parented) {
- Block b2 = targetAst.newBlock();
- b2.statements().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return a Statement that embeds x
- Block s1 = ast.newBlock();
- s1.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s2 = (Block) x.getParent();
- s2.statements().remove(x);
- }
- });
- }
-
- public void testMethodInvocation() {
- long previousCount = ast.modificationCount();
- final MethodInvocation x = ast.newMethodInvocation();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getExpression() == null);
- assertTrue(x.arguments().size() == 0);
- assertTrue(x.getNodeType() == ASTNode.METHOD_INVOCATION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Expression", false, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("x"));
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
-
- genericPropertyListTest(x, x.arguments(),
- new Property("Arguments", true, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("x"));
- }
- });
- }
-
- public void testExpressionStatement() {
- long previousCount = ast.modificationCount();
- SimpleName x1 = ast.newSimpleName("foo");
- final ExpressionStatement x = ast.newExpressionStatement(x1);
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getExpression() == x1);
- assertTrue(x1.getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.EXPRESSION_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyTest(x, new Property("Expression", true, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
-
- }
-
- public void testVariableDeclarationStatement() {
- VariableDeclarationFragment x1 = ast.newVariableDeclarationFragment();
- long previousCount = ast.modificationCount();
- final VariableDeclarationStatement x =
- ast.newVariableDeclarationStatement(x1);
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getModifiers() == Modifier.NONE);
- assertTrue(x.getType() != null);
- assertTrue(x.getType().getParent() == x);
- assertTrue(x.fragments().size() == 1);
- assertTrue(x.fragments().get(0) == x1);
- assertTrue(x1.getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- int legal = Modifier.FINAL;
- previousCount = ast.modificationCount();
- x.setModifiers(legal);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getModifiers() == legal);
-
- previousCount = ast.modificationCount();
- x.setModifiers(Modifier.NONE);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getModifiers() == Modifier.NONE);
-
- // check that property cannot be set to illegal value
- try {
- x.setModifiers(Modifier.PUBLIC);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- genericPropertyTest(x, new Property("Type", true, Type.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleType result = targetAst.newSimpleType(
- targetAst.newSimpleName("foo"));
- if (parented) {
- targetAst.newArrayType(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getType();
- }
- public void set(ASTNode value) {
- x.setType((Type) value);
- }
- });
-
- genericPropertyListTest(x, x.fragments(),
- new Property("VariableSpecifiers", true, VariableDeclarationFragment.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- VariableDeclarationFragment result = targetAst.newVariableDeclarationFragment();
- if (parented) {
- targetAst.newVariableDeclarationExpression(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return VariableDeclarationFragment that embeds x
- VariableDeclarationFragment s1 = ast.newVariableDeclarationFragment();
- ClassInstanceCreation s0 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s0.setAnonymousClassDeclaration(a1);
- s1.setInitializer(s0);
- Initializer s2 = ast.newInitializer();
- a1.bodyDeclarations().add(s2);
- s2.getBody().statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- });
-
-
- }
-
- public void testTypeDeclarationStatement() {
- TypeDeclaration x1 = ast.newTypeDeclaration();
- long previousCount = ast.modificationCount();
- final TypeDeclarationStatement x =
- ast.newTypeDeclarationStatement(x1);
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getTypeDeclaration() == x1);
- assertTrue(x1.getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.TYPE_DECLARATION_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- // check that TypeDeclaration inside is classified correctly
- assertTrue(x1.isLocalTypeDeclaration() == true);
- assertTrue(x1.isMemberTypeDeclaration() == false);
- assertTrue(x1.isPackageMemberTypeDeclaration() == false);
-
- tLeadingComment(x);
-
- genericPropertyTest(x, new Property("TypeDeclaration", true, TypeDeclaration.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- TypeDeclaration result = targetAst.newTypeDeclaration();
- if (parented) {
- targetAst.newTypeDeclarationStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return TypeDeclaration that embeds x
- TypeDeclaration s1 = ast.newTypeDeclaration();
- MethodDeclaration s2 = ast.newMethodDeclaration();
- s1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- public ASTNode get() {
- return x.getTypeDeclaration();
- }
- public void set(ASTNode value) {
- x.setTypeDeclaration((TypeDeclaration) value);
- }
- });
-
- }
-
- public void testVariableDeclarationExpression() {
- VariableDeclarationFragment x1 = ast.newVariableDeclarationFragment();
- long previousCount = ast.modificationCount();
- final VariableDeclarationExpression x =
- ast.newVariableDeclarationExpression(x1);
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getModifiers() == Modifier.NONE);
- assertTrue(x.getType() != null);
- assertTrue(x.getType().getParent() == x);
- assertTrue(x.fragments().size() == 1);
- assertTrue(x.fragments().get(0) == x1);
- assertTrue(x1.getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.VARIABLE_DECLARATION_EXPRESSION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- int legal = Modifier.FINAL;
- previousCount = ast.modificationCount();
- x.setModifiers(legal);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getModifiers() == legal);
-
- previousCount = ast.modificationCount();
- x.setModifiers(Modifier.NONE);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getModifiers() == Modifier.NONE);
-
- // check that property cannot be set to illegal value
- try {
- x.setModifiers(Modifier.PUBLIC);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- genericPropertyTest(x, new Property("Type", true, Type.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleType result = targetAst.newSimpleType(
- targetAst.newSimpleName("foo"));
- if (parented) {
- targetAst.newArrayType(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getType();
- }
- public void set(ASTNode value) {
- x.setType((Type) value);
- }
- });
-
- genericPropertyListTest(x, x.fragments(),
- new Property("VariableSpecifiers", true, VariableDeclarationFragment.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- VariableDeclarationFragment result = targetAst.newVariableDeclarationFragment();
- if (parented) {
- targetAst.newVariableDeclarationExpression(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return VariableDeclarationFragment that embeds x
- VariableDeclarationFragment s1 = ast.newVariableDeclarationFragment();
- ClassInstanceCreation s0 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s0.setAnonymousClassDeclaration(a1);
- s1.setInitializer(s0);
- ForStatement s2 = ast.newForStatement();
- s2.initializers().add(x);
- Initializer s3 = ast.newInitializer();
- a1.bodyDeclarations().add(s3);
- s3.getBody().statements().add(s2);
- return s1;
- }
- public void unwrap() {
- ForStatement s2 = (ForStatement) x.getParent();
- s2.initializers().remove(x);
- }
- });
- }
-
- public void testFieldDeclaration() {
- VariableDeclarationFragment x1 = ast.newVariableDeclarationFragment();
- long previousCount = ast.modificationCount();
- final FieldDeclaration x = ast.newFieldDeclaration(x1);
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof BodyDeclaration);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getJavadoc() == null);
- assertTrue(x.getModifiers() == Modifier.NONE);
- assertTrue(x.getType() != null);
- assertTrue(x.getType().getParent() == x);
- assertTrue(x.fragments().size() == 1);
- assertTrue(x.fragments().get(0) == x1);
- assertTrue(x1.getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.FIELD_DECLARATION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- int legal = Modifier.PUBLIC | Modifier.PROTECTED
- | Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL
- | Modifier.TRANSIENT | Modifier.VOLATILE;
- previousCount = ast.modificationCount();
- x.setModifiers(legal);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getModifiers() == legal);
-
- previousCount = ast.modificationCount();
- x.setModifiers(Modifier.NONE);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getModifiers() == Modifier.NONE);
-
- // check that property cannot be set to illegal value
- try {
- x.setModifiers(Modifier.SYNCHRONIZED);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- tJavadocComment(x);
-
- genericPropertyTest(x, new Property("Type", true, Type.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleType result = targetAst.newSimpleType(
- targetAst.newSimpleName("foo"));
- if (parented) {
- targetAst.newArrayType(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getType();
- }
- public void set(ASTNode value) {
- x.setType((Type) value);
- }
- });
-
- genericPropertyListTest(x, x.fragments(),
- new Property("VariableSpecifiers", true, VariableDeclarationFragment.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- VariableDeclarationFragment result = targetAst.newVariableDeclarationFragment();
- if (parented) {
- targetAst.newVariableDeclarationStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return VariableDeclarationFragment that embeds x
- VariableDeclarationFragment s1 = ast.newVariableDeclarationFragment();
- ClassInstanceCreation s2 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s2.setAnonymousClassDeclaration(a1);
- s1.setInitializer(s2);
- a1.bodyDeclarations().add(x);
- return s1;
- }
- public void unwrap() {
- AnonymousClassDeclaration a1 = (AnonymousClassDeclaration) x.getParent();
- a1.bodyDeclarations().remove(x);
- }
- });
-
- }
-
- public void testAssignment() {
- long previousCount = ast.modificationCount();
- final Assignment x = ast.newAssignment();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getOperator() == Assignment.Operator.ASSIGN);
- assertTrue(x.getLeftHandSide().getParent() == x);
- assertTrue(x.getRightHandSide().getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.ASSIGNMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- previousCount = ast.modificationCount();
- x.setOperator(Assignment.Operator.PLUS_ASSIGN);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getOperator() == Assignment.Operator.PLUS_ASSIGN);
- assertTrue(Assignment.Operator.PLUS_ASSIGN
- != Assignment.Operator.ASSIGN);
-
- // check the names of the primitive type codes
- assertTrue(Assignment.Operator.ASSIGN.toString().equals("="));
- assertTrue(Assignment.Operator.PLUS_ASSIGN.toString().equals("+="));
- assertTrue(Assignment.Operator.MINUS_ASSIGN.toString().equals("-="));
- assertTrue(Assignment.Operator.TIMES_ASSIGN.toString().equals("*="));
- assertTrue(Assignment.Operator.DIVIDE_ASSIGN.toString().equals("/="));
- assertTrue(Assignment.Operator.REMAINDER_ASSIGN.toString().equals("%="));
- assertTrue(Assignment.Operator.LEFT_SHIFT_ASSIGN.toString().equals("<<="));
- assertTrue(Assignment.Operator.RIGHT_SHIFT_SIGNED_ASSIGN.toString().equals(">>="));
- assertTrue(Assignment.Operator.RIGHT_SHIFT_UNSIGNED_ASSIGN.toString().equals(">>>="));
- assertTrue(Assignment.Operator.BIT_AND_ASSIGN.toString().equals("&="));
- assertTrue(Assignment.Operator.BIT_OR_ASSIGN.toString().equals("|="));
- assertTrue(Assignment.Operator.BIT_XOR_ASSIGN.toString().equals("^="));
-
- Assignment.Operator[] known = {
- Assignment.Operator.ASSIGN,
- Assignment.Operator.PLUS_ASSIGN,
- Assignment.Operator.MINUS_ASSIGN,
- Assignment.Operator.TIMES_ASSIGN,
- Assignment.Operator.DIVIDE_ASSIGN,
- Assignment.Operator.REMAINDER_ASSIGN,
- Assignment.Operator.LEFT_SHIFT_ASSIGN,
- Assignment.Operator.RIGHT_SHIFT_SIGNED_ASSIGN,
- Assignment.Operator.RIGHT_SHIFT_UNSIGNED_ASSIGN,
- Assignment.Operator.BIT_AND_ASSIGN,
- Assignment.Operator.BIT_OR_ASSIGN,
- Assignment.Operator.BIT_XOR_ASSIGN,
- };
-
- // check all operators are distinct
- for (int i = 0; i < known.length; i++) {
- for (int j = 0; j < known.length; j++) {
- assertTrue(i == j || !known[i].equals(known[j]));
- }
- }
-
- // check all operators work
- for (int i = 0; i < known.length; i++) {
- previousCount = ast.modificationCount();
- x.setOperator(known[i]);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getOperator().equals(known[i]));
- }
- // ensure null does not work as a primitive type code
- try {
- x.setOperator(null);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- // check toOperator lookup of operators by name
- for (int i = 0; i < known.length; i++) {
- String name = known[i].toString();
- assertTrue(Assignment.Operator.toOperator(name).equals(known[i]));
- }
- assertTrue(Assignment.Operator.toOperator("not-an-op") == null);
-
- genericPropertyTest(x, new Property("LeftHandSide", true, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("x"));
- }
- public ASTNode get() {
- return x.getLeftHandSide();
- }
- public void set(ASTNode value) {
- x.setLeftHandSide((Expression) value);
- }
- });
-
- genericPropertyTest(x, new Property("RightHandSide", true, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("x"));
- }
- public ASTNode get() {
- return x.getRightHandSide();
- }
- public void set(ASTNode value) {
- x.setRightHandSide((Expression) value);
- }
- });
- }
-
- public void testBreakStatement() {
- long previousCount = ast.modificationCount();
- final BreakStatement x = ast.newBreakStatement();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getLabel() == null);
- assertTrue(x.getLeadingComment() == null);
- assertTrue(x.getNodeType() == ASTNode.BREAK_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyTest(x, new Property("Label", false, SimpleName.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getLabel();
- }
- public void set(ASTNode value) {
- x.setLabel((SimpleName) value);
- }
- });
- }
-
- public void testContinueStatement() {
- long previousCount = ast.modificationCount();
- final ContinueStatement x = ast.newContinueStatement();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getLabel() == null);
- assertTrue(x.getLeadingComment() == null);
- assertTrue(x.getNodeType() == ASTNode.CONTINUE_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyTest(x, new Property("Label", false, SimpleName.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getLabel();
- }
- public void set(ASTNode value) {
- x.setLabel((SimpleName) value);
- }
- });
- }
-
- public void testIfStatement() {
- long previousCount = ast.modificationCount();
- final IfStatement x = ast.newIfStatement();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getLeadingComment() == null);
- assertTrue(x.getExpression().getParent() == x);
- assertTrue(x.getThenStatement().getParent() == x);
- assertTrue(x.getThenStatement() instanceof Block);
- assertTrue(((Block) x.getThenStatement()).statements().isEmpty());
- assertTrue(x.getElseStatement() == null);
- assertTrue(x.getNodeType() == ASTNode.IF_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyTest(x, new Property("Expression", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
-
- genericPropertyTest(x, new Property("ThenStatement", true, Statement.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Block result = targetAst.newBlock();
- if (parented) {
- Block b2 = targetAst.newBlock();
- b2.statements().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return a Statement that embeds x
- Block s1 = ast.newBlock();
- s1.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s2 = (Block) x.getParent();
- s2.statements().remove(x);
- }
- public ASTNode get() {
- return x.getThenStatement();
- }
- public void set(ASTNode value) {
- x.setThenStatement((Statement) value);
- }
- });
-
- genericPropertyTest(x, new Property("ElseStatement", false, Statement.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Block result = targetAst.newBlock();
- if (parented) {
- Block b2 = targetAst.newBlock();
- b2.statements().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return a Statement that embeds x
- Block s1 = ast.newBlock();
- s1.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s2 = (Block) x.getParent();
- s2.statements().remove(x);
- }
- public ASTNode get() {
- return x.getElseStatement();
- }
- public void set(ASTNode value) {
- x.setElseStatement((Statement) value);
- }
- });
- }
-
- public void testWhileStatement() {
- long previousCount = ast.modificationCount();
- final WhileStatement x = ast.newWhileStatement();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getLeadingComment() == null);
- assertTrue(x.getExpression().getParent() == x);
- assertTrue(x.getBody().getParent() == x);
- assertTrue(x.getBody() instanceof Block);
- assertTrue(((Block) x.getBody()).statements().isEmpty());
- assertTrue(x.getNodeType() == ASTNode.WHILE_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyTest(x, new Property("Expression", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
-
- genericPropertyTest(x, new Property("Body", true, Statement.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Block result = targetAst.newBlock();
- if (parented) {
- Block b2 = targetAst.newBlock();
- b2.statements().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return a Statement that embeds x
- Block s1 = ast.newBlock();
- s1.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s2 = (Block) x.getParent();
- s2.statements().remove(x);
- }
- public ASTNode get() {
- return x.getBody();
- }
- public void set(ASTNode value) {
- x.setBody((Statement) value);
- }
- });
- }
-
- public void testDoStatement() {
- long previousCount = ast.modificationCount();
- final DoStatement x = ast.newDoStatement();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getLeadingComment() == null);
- assertTrue(x.getExpression().getParent() == x);
- assertTrue(x.getBody().getParent() == x);
- assertTrue(x.getBody() instanceof Block);
- assertTrue(((Block) x.getBody()).statements().isEmpty());
- assertTrue(x.getNodeType() == ASTNode.DO_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyTest(x, new Property("Expression", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
-
- genericPropertyTest(x, new Property("Body", true, Statement.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Block result = targetAst.newBlock();
- if (parented) {
- Block b2 = targetAst.newBlock();
- b2.statements().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return a Statement that embeds x
- Block s1 = ast.newBlock();
- s1.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s2 = (Block) x.getParent();
- s2.statements().remove(x);
- }
- public ASTNode get() {
- return x.getBody();
- }
- public void set(ASTNode value) {
- x.setBody((Statement) value);
- }
- });
- }
-
- public void testTryStatement() {
- long previousCount = ast.modificationCount();
- final TryStatement x = ast.newTryStatement();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getLeadingComment() == null);
- assertTrue(x.getBody().getParent() == x);
- assertTrue(x.getBody() instanceof Block);
- assertTrue(((Block) x.getBody()).statements().isEmpty());
- assertTrue(x.getFinally() == null);
- assertTrue(x.catchClauses().size() == 0);
- assertTrue(x.getNodeType() == ASTNode.TRY_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyTest(x, new Property("Body", true, Block.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Block result = targetAst.newBlock();
- if (parented) {
- Block b2 = targetAst.newBlock();
- b2.statements().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return a Block that embeds x
- Block s1 = ast.newBlock();
- s1.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s2 = (Block) x.getParent();
- s2.statements().remove(x);
- }
- public ASTNode get() {
- return x.getBody();
- }
- public void set(ASTNode value) {
- x.setBody((Block) value);
- }
- });
-
- genericPropertyListTest(x, x.catchClauses(),
- new Property("CatchClauses", true, CatchClause.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- CatchClause result = targetAst.newCatchClause();
- if (parented) {
- TryStatement s1 = targetAst.newTryStatement();
- s1.catchClauses().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return CatchClause that embeds x
- CatchClause s1 = ast.newCatchClause();
- Block s2 = ast.newBlock();
- s1.setBody(s2);
- s2.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s2 = (Block) x.getParent();
- s2.statements().remove(x);
- }
- });
-
- genericPropertyTest(x, new Property("Finally", false, Block.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Block result = targetAst.newBlock();
- if (parented) {
- Block b2 = targetAst.newBlock();
- b2.statements().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return a Block that embeds x
- Block s1 = ast.newBlock();
- s1.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s2 = (Block) x.getParent();
- s2.statements().remove(x);
- }
- public ASTNode get() {
- return x.getFinally();
- }
- public void set(ASTNode value) {
- x.setFinally((Block) value);
- }
- });
- }
-
- public void testCatchClause() {
- long previousCount = ast.modificationCount();
- final CatchClause x = ast.newCatchClause();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getBody().getParent() == x);
- assertTrue(x.getBody().statements().isEmpty());
- assertTrue(x.getException().getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.CATCH_CLAUSE);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Exception", true, SingleVariableDeclaration.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SingleVariableDeclaration result = targetAst.newSingleVariableDeclaration();
- if (parented) {
- targetAst.newCatchClause().setException(result);
-
- }
- return result;
- }
- public ASTNode wrap() {
- // return SingleVariableDeclaration that embeds x
- SingleVariableDeclaration s1 = ast.newSingleVariableDeclaration();
- ClassInstanceCreation s2 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s2.setAnonymousClassDeclaration(a1);
- s1.setInitializer(s2);
- MethodDeclaration s3 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s3);
- Block s4 = ast.newBlock();
- s3.setBody(s4);
- TryStatement s5 = ast.newTryStatement();
- s4.statements().add(s5);
- s5.catchClauses().add(x);
- return s1;
- }
- public void unwrap() {
- TryStatement s5 = (TryStatement) x.getParent();
- s5.catchClauses().remove(x);
- }
- public ASTNode get() {
- return x.getException();
- }
- public void set(ASTNode value) {
- x.setException((SingleVariableDeclaration) value);
- }
- });
-
- genericPropertyTest(x, new Property("Body", true, Block.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Block result = targetAst.newBlock();
- if (parented) {
- Block b2 = targetAst.newBlock();
- b2.statements().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return a Block that embeds x
- Block s1 = ast.newBlock();
- TryStatement s2 = ast.newTryStatement();
- s1.statements().add(s2);
- s2.catchClauses().add(x);
- return s1;
- }
- public void unwrap() {
- TryStatement s2 = (TryStatement) x.getParent();
- s2.catchClauses().remove(x);
- }
- public ASTNode get() {
- return x.getBody();
- }
- public void set(ASTNode value) {
- x.setBody((Block) value);
- }
- });
- }
-
- public void testEmptyStatement() {
- long previousCount = ast.modificationCount();
- final EmptyStatement x = ast.newEmptyStatement();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getLeadingComment() == null);
- assertTrue(x.getNodeType() == ASTNode.EMPTY_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
- }
-
- /**
- * Exercise the leadingComment property.
- *
- * @param x the statement to test
- */
- void tLeadingComment(Statement x) {
-
- // check that null is allowed
- long previousCount = ast.modificationCount();
- x.setLeadingComment(null);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getLeadingComment() == null);
-
- // check that regular comment is allowed
- previousCount = ast.modificationCount();
- x.setLeadingComment("/* X */");
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getLeadingComment() == "/* X */");
-
- // check that regular comment with line breaks is allowed
- previousCount = ast.modificationCount();
- x.setLeadingComment("/* X\n *Y\n */");
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getLeadingComment() == "/* X\n *Y\n */");
-
- // check that end-of-line comment is allowed
- previousCount = ast.modificationCount();
- x.setLeadingComment("// X");
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getLeadingComment() == "// X");
-
- // check that end-of-line comment with embedded end of line
- // not allowed
- try {
- x.setLeadingComment("// X\n extra");
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- }
-
- /**
- * Exercise the javadoc property.
- *
- * @param x the body declaration to test
- */
- void tJavadocComment(final BodyDeclaration x) {
- genericPropertyTest(x, new Property("Javadoc", false, Javadoc.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Javadoc result = targetAst.newJavadoc();
- if (parented) {
- targetAst.newInitializer().setJavadoc(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getJavadoc();
- }
- public void set(ASTNode value) {
- x.setJavadoc((Javadoc) value);
- }
- });
- }
-
- /**
- * Exercise the client properties of a node.
- *
- * @param x the node to test
- */
- void tClientProperties(ASTNode x) {
-
- long previousCount = ast.modificationCount();
-
- // a node initially has no properties
- assertTrue(x.properties().size() == 0);
- assertTrue(x.getProperty("1") == null);
-
- // clearing an unset property does not add it to list of known ones
- x.setProperty("1", null);
- assertTrue(x.getProperty("1") == null);
- assertTrue(x.properties().size() == 0);
-
- // setting an unset property does add it to the list of known ones
- x.setProperty("1", "a1");
- assertTrue(x.getProperty("1") == "a1");
- assertTrue(x.properties().size() == 1);
- Map.Entry[] m = (Map.Entry[]) x.properties().entrySet().toArray(new Map.Entry[1]);
- assertTrue(m[0].getKey() == "1");
- assertTrue(m[0].getValue() == "a1");
-
- // setting an already set property just changes its value
- x.setProperty("1", "a2");
- assertTrue(x.getProperty("1") == "a2");
- assertTrue(x.properties().size() == 1);
- m = (Map.Entry[]) x.properties().entrySet().toArray(new Map.Entry[1]);
- assertTrue(m[0].getKey() == "1");
- assertTrue(m[0].getValue() == "a2");
-
- // clearing a set property removes it from list of known ones
- x.setProperty("1", null);
- assertTrue(x.getProperty("1") == null);
- assertTrue(x.properties().size() == 0);
-
-
- // ========= test 2 and 3 properties
- x.setProperty("1", "a1");
- x.setProperty("2", "b1");
- x.setProperty("3", "c1");
- assertTrue(x.getProperty("1") == "a1");
- assertTrue(x.getProperty("2") == "b1");
- assertTrue(x.getProperty("3") == "c1");
- assertTrue(x.properties().size() == 3);
- assertTrue(x.properties().get("1") == "a1");
- assertTrue(x.properties().get("2") == "b1");
- assertTrue(x.properties().get("3") == "c1");
- x.setProperty("1", "a2");
- x.setProperty("2", "b2");
- x.setProperty("3", "c2");
- assertTrue(x.getProperty("1") == "a2");
- assertTrue(x.getProperty("2") == "b2");
- assertTrue(x.getProperty("3") == "c2");
- assertTrue(x.properties().size() == 3);
- assertTrue(x.properties().get("1") == "a2");
- assertTrue(x.properties().get("2") == "b2");
- assertTrue(x.properties().get("3") == "c2");
- x.setProperty("2", null);
- assertTrue(x.getProperty("1") == "a2");
- assertTrue(x.getProperty("2") == null);
- assertTrue(x.getProperty("3") == "c2");
- assertTrue(x.properties().size() == 2);
- assertTrue(x.properties().get("1") == "a2");
- assertTrue(x.properties().get("2") == null);
- assertTrue(x.properties().get("3") == "c2");
- x.setProperty("1", null);
- assertTrue(x.getProperty("1") == null);
- assertTrue(x.getProperty("2") == null);
- assertTrue(x.getProperty("3") == "c2");
- assertTrue(x.properties().size() == 1);
- assertTrue(x.properties().get("1") == null);
- assertTrue(x.properties().get("2") == null);
- assertTrue(x.properties().get("3") == "c2");
-
- // none of this is considered to have affected the AST
- assertTrue(ast.modificationCount() == previousCount);
- }
-
- public void testReturnStatement() {
- long previousCount = ast.modificationCount();
- final ReturnStatement x = ast.newReturnStatement();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getExpression() == null);
- assertTrue(x.getNodeType() == ASTNode.RETURN_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyTest(x, new Property("Expression", false, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
- }
-
- public void testThrowStatement() {
- long previousCount = ast.modificationCount();
- final ThrowStatement x = ast.newThrowStatement();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getExpression().getParent() == x);
- assertTrue(x.getLeadingComment() == null);
- assertTrue(x.getNodeType() == ASTNode.THROW_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyTest(x, new Property("Expression", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
- }
-
- public void testAssertStatement() {
- long previousCount = ast.modificationCount();
- final AssertStatement x = ast.newAssertStatement();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getExpression().getParent() == x);
- assertTrue(x.getMessage() == null);
- assertTrue(x.getLeadingComment() == null);
- assertTrue(x.getNodeType() == ASTNode.ASSERT_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyTest(x, new Property("Expression", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
-
- genericPropertyTest(x, new Property("Message", false, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- public ASTNode get() {
- return x.getMessage();
- }
- public void set(ASTNode value) {
- x.setMessage((Expression) value);
- }
- });
- }
-
- public void testSwitchStatement() {
- long previousCount = ast.modificationCount();
- final SwitchStatement x = ast.newSwitchStatement();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getExpression().getParent() == x);
- assertTrue(x.statements().isEmpty());
- assertTrue(x.getLeadingComment() == null);
- assertTrue(x.getNodeType() == ASTNode.SWITCH_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyTest(x, new Property("Expression", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
-
- genericPropertyListTest(x, x.statements(),
- new Property("Statements", true, Statement.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Block result = targetAst.newBlock();
- if (parented) {
- Block b2 = targetAst.newBlock();
- b2.statements().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return a Statement that embeds x
- Block s1 = ast.newBlock();
- s1.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s2 = (Block) x.getParent();
- s2.statements().remove(x);
- }
- });
- }
-
- public void testSwitchCase() {
- long previousCount = ast.modificationCount();
- final SwitchCase x = ast.newSwitchCase();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getExpression().getParent() == x);
- assertTrue(x.getLeadingComment() == null);
- assertTrue(!x.isDefault());
- assertTrue(x.getNodeType() == ASTNode.SWITCH_CASE);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Expression", false, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- SwitchStatement s4 = ast.newSwitchStatement();
- s3.statements().add(s4);
- s4.statements().add(x);
- return s1;
- }
- public void unwrap() {
- SwitchStatement s4 = (SwitchStatement) x.getParent();
- s4.statements().remove(x);
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
- }
-
- public void testSynchronizedStatement() {
- long previousCount = ast.modificationCount();
- final SynchronizedStatement x = ast.newSynchronizedStatement();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getExpression().getParent() == x);
- assertTrue(x.getBody().statements().isEmpty());
- assertTrue(x.getLeadingComment() == null);
- assertTrue(x.getNodeType() == ASTNode.SYNCHRONIZED_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyTest(x, new Property("Expression", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
-
- genericPropertyTest(x, new Property("Body", true, Block.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Block result = targetAst.newBlock();
- if (parented) {
- Block b2 = targetAst.newBlock();
- b2.statements().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return a Block that embeds x
- Block s1 = ast.newBlock();
- s1.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s2 = (Block) x.getParent();
- s2.statements().remove(x);
- }
- public ASTNode get() {
- return x.getBody();
- }
- public void set(ASTNode value) {
- x.setBody((Block) value);
- }
- });
- }
-
- public void testLabeledStatement() {
- long previousCount = ast.modificationCount();
- final LabeledStatement x = ast.newLabeledStatement();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getLabel().getParent() == x);
- assertTrue(x.getBody().getParent() == x);
- assertTrue(x.getLeadingComment() == null);
- assertTrue(x.getNodeType() == ASTNode.LABELED_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyTest(x, new Property("Label", true, SimpleName.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getLabel();
- }
- public void set(ASTNode value) {
- x.setLabel((SimpleName) value);
- }
- });
-
- genericPropertyTest(x, new Property("Body", true, Statement.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Block result = targetAst.newBlock();
- if (parented) {
- Block b2 = targetAst.newBlock();
- b2.statements().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return a Statement that embeds x
- Block s1 = ast.newBlock();
- s1.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s2 = (Block) x.getParent();
- s2.statements().remove(x);
- }
- public ASTNode get() {
- return x.getBody();
- }
- public void set(ASTNode value) {
- x.setBody((Statement) value);
- }
- });
- }
-
-
- /**
- * Returns a subtree of sample of AST nodes. The sample includes
- * one of each kind, but otherwise does not make sense.
- */
- ASTNode oneOfEach(AST target) {
- CompilationUnit cu = target.newCompilationUnit();
-
- PackageDeclaration pd = target.newPackageDeclaration();
- cu.setPackage(pd);
-
- ImportDeclaration im = target.newImportDeclaration();
- cu.imports().add(im);
-
- TypeDeclaration td = target.newTypeDeclaration();
- td.setJavadoc(target.newJavadoc());
- cu.types().add(td);
-
- FieldDeclaration fd =
- target.newFieldDeclaration(target.newVariableDeclarationFragment());
- td.bodyDeclarations().add(fd);
-
- Initializer in = target.newInitializer();
- td.bodyDeclarations().add(in);
-
- MethodDeclaration md = target.newMethodDeclaration();
- md.parameters().add(target.newSingleVariableDeclaration());
- td.bodyDeclarations().add(md);
-
- SimpleName sn1 = target.newSimpleName("one");
- SimpleName sn2 =target.newSimpleName("two");
- QualifiedName qn = target.newQualifiedName(sn1, sn2);
-
- SimpleType st = target.newSimpleType(qn);
- PrimitiveType pt = target.newPrimitiveType(PrimitiveType.INT);
- ArrayType at = target.newArrayType(st);
-
- md.setReturnType(at);
- fd.setType(pt);
-
- Block b = target.newBlock();
- md.setBody(b);
-
- // all statements (in alphabetic order of statement type)
- b.statements().add(target.newAssertStatement());
- b.statements().add(target.newBlock());
- b.statements().add(target.newBreakStatement());
- b.statements().add(target.newContinueStatement());
- b.statements().add(target.newConstructorInvocation());
- b.statements().add(target.newDoStatement());
- b.statements().add(target.newEmptyStatement());
- b.statements().add(target.newExpressionStatement(target.newNullLiteral()));
- b.statements().add(target.newForStatement());
- b.statements().add(target.newIfStatement());
- b.statements().add(target.newLabeledStatement());
- b.statements().add(target.newReturnStatement());
- b.statements().add(target.newSuperConstructorInvocation());
- SwitchStatement ss = target.newSwitchStatement();
- ss.statements().add(target.newSwitchCase());
- b.statements().add(ss);
- b.statements().add(target.newSwitchStatement());
- b.statements().add(target.newSwitchCase());
- b.statements().add(target.newSynchronizedStatement());
- b.statements().add(target.newThrowStatement());
- TryStatement tr = target.newTryStatement();
- tr.catchClauses().add(target.newCatchClause());
- b.statements().add(tr);
- b.statements().add(target.newTypeDeclarationStatement(target.newTypeDeclaration()));
- b.statements().add(target.newVariableDeclarationStatement(target.newVariableDeclarationFragment()));
- b.statements().add(target.newWhileStatement());
-
- // all expressions (in alphabetic order of expressions type)
- MethodInvocation inv = target.newMethodInvocation();
- b.statements().add(target.newExpressionStatement(inv));
- List z = inv.arguments();
- z.add(target.newArrayAccess());
- z.add(target.newArrayCreation());
- z.add(target.newArrayInitializer());
- z.add(target.newAssignment());
- z.add(target.newBooleanLiteral(true));
- z.add(target.newCastExpression());
- z.add(target.newCharacterLiteral());
- ClassInstanceCreation cic = target.newClassInstanceCreation();
- cic.setAnonymousClassDeclaration(target.newAnonymousClassDeclaration());
- z.add(cic);
- z.add(target.newConditionalExpression());
- z.add(target.newFieldAccess());
- z.add(target.newInfixExpression());
- z.add(target.newInstanceofExpression());
- z.add(target.newMethodInvocation());
- z.add(target.newName(new String[]{"a", "b"}));
- z.add(target.newNullLiteral());
- z.add(target.newNumberLiteral("1024"));
- z.add(target.newParenthesizedExpression());
- z.add(target.newPostfixExpression());
- z.add(target.newPrefixExpression());
- z.add(target.newStringLiteral());
- z.add(target.newSuperFieldAccess());
- z.add(target.newSuperMethodInvocation());
- z.add(target.newThisExpression());
- z.add(target.newTypeLiteral());
- z.add(target.newVariableDeclarationExpression(
- target.newVariableDeclarationFragment()));
-
- return cu;
- }
-
- public void testClone() {
- ASTNode x = oneOfEach(ast);
- assertTrue(x.subtreeMatch(new ASTMatcher(), x));
-
- // same AST clone
- ASTNode y = ASTNode.copySubtree(ast, x);
- assertTrue(x.subtreeMatch(new ASTMatcher(), y));
- assertTrue(y.subtreeMatch(new ASTMatcher(), x));
-
- // different AST clone
- ASTNode z = ASTNode.copySubtree(new AST(), x);
- assertTrue(x.subtreeMatch(new ASTMatcher(), z));
- assertTrue(z.subtreeMatch(new ASTMatcher(), x));
- }
-
- public void testNullResolve() {
- ASTNode x = oneOfEach(ast);
-
- ASTVisitor v = new ASTVisitor() {
- // NAMES
-
- public boolean visit(SimpleName node) {
- assertTrue(node.resolveBinding() == null);
- return true;
- }
- public boolean visit(QualifiedName node) {
- assertTrue(node.resolveBinding() == null);
- return true;
- }
-
- // TYPES
-
- public boolean visit(SimpleType node) {
- assertTrue(node.resolveBinding() == null);
- return true;
- }
- public boolean visit(ArrayType node) {
- assertTrue(node.resolveBinding() == null);
- return true;
- }
- public boolean visit(PrimitiveType node) {
- assertTrue(node.resolveBinding() == null);
- return true;
- }
-
- // EXPRESSIONS
-
- public boolean visit(Assignment node) {
- assertTrue(node.resolveTypeBinding() == null);
- return true;
- }
-
- public boolean visit(ClassInstanceCreation node) {
- assertTrue(node.resolveConstructorBinding() == null);
- return true;
- }
-
- public boolean visit(ConstructorInvocation node) {
- assertTrue(node.resolveConstructorBinding() == null);
- return true;
- }
-
- public boolean visit(SuperConstructorInvocation node) {
- assertTrue(node.resolveConstructorBinding() == null);
- return true;
- }
-
- // MAJOR DECLARATIONS
-
- public boolean visit(PackageDeclaration node) {
- assertTrue(node.resolveBinding() == null);
- return true;
- }
- public boolean visit(ImportDeclaration node) {
- assertTrue(node.resolveBinding() == null);
- return true;
- }
- public boolean visit(MethodDeclaration node) {
- assertTrue(node.resolveBinding() == null);
- return true;
- }
- public boolean visit(TypeDeclaration node) {
- assertTrue(node.resolveBinding() == null);
- return true;
- }
- public boolean visit(TypeDeclarationStatement node) {
- assertTrue(node.resolveBinding() == null);
- return true;
- }
- public boolean visit(SingleVariableDeclaration node) {
- assertTrue(node.resolveBinding() == null);
- return true;
- }
- public boolean visit(VariableDeclarationFragment node) {
- assertTrue(node.resolveBinding() == null);
- return true;
- }
- };
-
- x.accept(v);
- }
-
- public void testForStatement() {
- long previousCount = ast.modificationCount();
- final ForStatement x = ast.newForStatement();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.initializers().isEmpty());
- assertTrue(x.getExpression() == null);
- assertTrue(x.updaters().isEmpty());
- assertTrue(x.getBody().getParent() == x);
- assertTrue(x.getBody() instanceof Block);
- assertTrue(((Block) x.getBody()).statements().isEmpty());
- assertTrue(x.getLeadingComment() == null);
- assertTrue(x.getNodeType() == ASTNode.FOR_STATEMENT);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- tLeadingComment(x);
-
- genericPropertyListTest(x, x.initializers(),
- new Property("Initializers", true, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- });
-
- genericPropertyTest(x, new Property("Expression", false, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
-
- genericPropertyListTest(x, x.updaters(),
- new Property("Updaters", true, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- });
-
- genericPropertyTest(x, new Property("Body", true, Statement.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- Block result = targetAst.newBlock();
- if (parented) {
- Block b2 = targetAst.newBlock();
- b2.statements().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return a Statement that embeds x
- Block s1 = ast.newBlock();
- s1.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s2 = (Block) x.getParent();
- s2.statements().remove(x);
- }
- public ASTNode get() {
- return x.getBody();
- }
- public void set(ASTNode value) {
- x.setBody((Statement) value);
- }
- });
- }
-
- public void testConstructorInvocation() {
- long previousCount = ast.modificationCount();
- final ConstructorInvocation x = ast.newConstructorInvocation();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.arguments().isEmpty());
- assertTrue(x.getNodeType() == ASTNode.CONSTRUCTOR_INVOCATION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyListTest(x, x.arguments(),
- new Property("Arguments", true, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- });
- }
-
- public void testSuperConstructorInvocation() {
- long previousCount = ast.modificationCount();
- final SuperConstructorInvocation x = ast.newSuperConstructorInvocation();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Statement);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getExpression() == null);
- assertTrue(x.arguments().isEmpty());
- assertTrue(x.getNodeType() == ASTNode.SUPER_CONSTRUCTOR_INVOCATION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Expression", false, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
-
- genericPropertyListTest(x, x.arguments(),
- new Property("Arguments", true, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ClassInstanceCreation s1 = ast.newClassInstanceCreation();
- AnonymousClassDeclaration a1 = ast.newAnonymousClassDeclaration();
- s1.setAnonymousClassDeclaration(a1);
- MethodDeclaration s2 = ast.newMethodDeclaration();
- a1.bodyDeclarations().add(s2);
- Block s3 = ast.newBlock();
- s2.setBody(s3);
- s3.statements().add(x);
- return s1;
- }
- public void unwrap() {
- Block s3 = (Block) x.getParent();
- s3.statements().remove(x);
- }
- });
- }
-
- public void testThisExpression() {
- long previousCount = ast.modificationCount();
- final ThisExpression x = ast.newThisExpression();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getQualifier() == null);
- assertTrue(x.getNodeType() == ASTNode.THIS_EXPRESSION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Qualifier", false, Name.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- QualifiedName result = targetAst.newQualifiedName(
- targetAst.newSimpleName("a"),
- targetAst.newSimpleName("b"));
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getQualifier();
- }
- public void set(ASTNode value) {
- x.setQualifier((Name) value);
- }
- });
- }
-
- public void testFieldAccess() {
- long previousCount = ast.modificationCount();
- final FieldAccess x = ast.newFieldAccess();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getExpression().getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.FIELD_ACCESS);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Expression", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("fie"));
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
-
- genericPropertyTest(x, new Property("Name", true, SimpleName.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((SimpleName) value);
- }
- });
- }
-
-
- public void testSuperFieldAccess() {
- long previousCount = ast.modificationCount();
- final SuperFieldAccess x = ast.newSuperFieldAccess();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getQualifier() == null);
- assertTrue(x.getNodeType() == ASTNode.SUPER_FIELD_ACCESS);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Qualifier", false, Name.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- QualifiedName result = targetAst.newQualifiedName(
- targetAst.newSimpleName("a"),
- targetAst.newSimpleName("b"));
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getQualifier();
- }
- public void set(ASTNode value) {
- x.setQualifier((Name) value);
- }
- });
-
- genericPropertyTest(x, new Property("Name", true, SimpleName.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((SimpleName) value);
- }
- });
- }
-
- public void testSuperMethodInvocation() {
- long previousCount = ast.modificationCount();
- final SuperMethodInvocation x = ast.newSuperMethodInvocation();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.getQualifier() == null);
- assertTrue(x.arguments().isEmpty());
- assertTrue(x.getNodeType() == ASTNode.SUPER_METHOD_INVOCATION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Qualifier", false, Name.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- QualifiedName result = targetAst.newQualifiedName(
- targetAst.newSimpleName("a"),
- targetAst.newSimpleName("b"));
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getQualifier();
- }
- public void set(ASTNode value) {
- x.setQualifier((Name) value);
- }
- });
-
- genericPropertyTest(x, new Property("Name", true, SimpleName.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((SimpleName) value);
- }
- });
-
- genericPropertyListTest(x, x.arguments(),
- new Property("Arguments", true, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("x"));
- }
- });
- }
-
- public void testTypeLiteral() {
- long previousCount = ast.modificationCount();
- final TypeLiteral x = ast.newTypeLiteral();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getType().getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.TYPE_LITERAL);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Type", true, Type.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleType result = targetAst.newSimpleType(
- targetAst.newSimpleName("a"));
- if (parented) {
- targetAst.newArrayType(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getType();
- }
- public void set(ASTNode value) {
- x.setType((Type) value);
- }
- });
- }
-
- public void testCastExpression() {
- long previousCount = ast.modificationCount();
- final CastExpression x = ast.newCastExpression();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getType().getParent() == x);
- assertTrue(x.getExpression().getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.CAST_EXPRESSION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Type", true, Type.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleType result = targetAst.newSimpleType(
- targetAst.newSimpleName("a"));
- if (parented) {
- targetAst.newArrayType(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getType();
- }
- public void set(ASTNode value) {
- x.setType((Type) value);
- }
- });
-
- genericPropertyTest(x, new Property("Expression", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("fie"));
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
- }
-
- public void testPrefixExpression() {
- long previousCount = ast.modificationCount();
- final PrefixExpression x = ast.newPrefixExpression();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getOperand().getParent() == x);
- assertTrue(x.getOperator() != null);
- assertTrue(x.getNodeType() == ASTNode.PREFIX_EXPRESSION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- // Operator property - mandatory typesafe enumeration
- // check the names of the operators
- assertTrue(PrefixExpression.Operator.INCREMENT.toString().equals("++"));
- assertTrue(PrefixExpression.Operator.DECREMENT.toString().equals("--"));
- assertTrue(PrefixExpression.Operator.PLUS.toString().equals("+"));
- assertTrue(PrefixExpression.Operator.MINUS.toString().equals("-"));
- assertTrue(PrefixExpression.Operator.COMPLEMENT.toString().equals("~"));
- assertTrue(PrefixExpression.Operator.NOT.toString().equals("!"));
-
- PrefixExpression.Operator[] known = {
- PrefixExpression.Operator.INCREMENT,
- PrefixExpression.Operator.DECREMENT,
- PrefixExpression.Operator.PLUS,
- PrefixExpression.Operator.MINUS,
- PrefixExpression.Operator.COMPLEMENT,
- PrefixExpression.Operator.NOT,
- };
-
- // check all operators are distinct
- for (int i = 0; i < known.length; i++) {
- for (int j = 0; j < known.length; j++) {
- assertTrue(i == j || !known[i].equals(known[j]));
- }
- }
-
- // check all operators work
- for (int i = 0; i < known.length; i++) {
- previousCount = ast.modificationCount();
- x.setOperator(known[i]);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getOperator().equals(known[i]));
- }
- // ensure null does not work as an operator
- try {
- x.setOperator(null);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- // check toOperator lookup of operator by name
- for (int i = 0; i < known.length; i++) {
- String name = known[i].toString();
- assertTrue(PrefixExpression.Operator.toOperator(name).equals(known[i]));
- }
- assertTrue(PrefixExpression.Operator.toOperator("huh") == null);
-
- genericPropertyTest(x, new Property("Operand", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("fie"));
- }
- public ASTNode get() {
- return x.getOperand();
- }
- public void set(ASTNode value) {
- x.setOperand((Expression) value);
- }
- });
- }
-
- public void testPostfixExpression() {
- long previousCount = ast.modificationCount();
- final PostfixExpression x = ast.newPostfixExpression();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getOperand().getParent() == x);
- assertTrue(x.getOperator() != null);
- assertTrue(x.getNodeType() == ASTNode.POSTFIX_EXPRESSION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- // Operator property - mandatory typesafe enumeration
- // check the names of the operators
- assertTrue(PostfixExpression.Operator.INCREMENT.toString().equals("++"));
- assertTrue(PostfixExpression.Operator.DECREMENT.toString().equals("--"));
-
- PostfixExpression.Operator[] known = {
- PostfixExpression.Operator.INCREMENT,
- PostfixExpression.Operator.DECREMENT,
- };
-
- // check all operators are distinct
- for (int i = 0; i < known.length; i++) {
- for (int j = 0; j < known.length; j++) {
- assertTrue(i == j || !known[i].equals(known[j]));
- }
- }
-
- // check all operators work
- for (int i = 0; i < known.length; i++) {
- previousCount = ast.modificationCount();
- x.setOperator(known[i]);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getOperator().equals(known[i]));
- }
- // ensure null does not work as an operator
- try {
- x.setOperator(null);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- // check toOperator lookup of operator by name
- for (int i = 0; i < known.length; i++) {
- String name = known[i].toString();
- assertTrue(PostfixExpression.Operator.toOperator(name).equals(known[i]));
- }
- assertTrue(PostfixExpression.Operator.toOperator("huh") == null);
-
- genericPropertyTest(x, new Property("Operand", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("fie"));
- }
- public ASTNode get() {
- return x.getOperand();
- }
- public void set(ASTNode value) {
- x.setOperand((Expression) value);
- }
- });
- }
-
- public void testInfixExpression() {
- long previousCount = ast.modificationCount();
- final InfixExpression x = ast.newInfixExpression();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getLeftOperand().getParent() == x);
- assertTrue(x.getOperator() != null);
- assertTrue(x.getRightOperand().getParent() == x);
- assertTrue(x.extendedOperands().isEmpty());
- assertTrue(x.getNodeType() == ASTNode.INFIX_EXPRESSION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- // Operator property - mandatory typesafe enumeration
- // check the names of the operators
- assertTrue(InfixExpression.Operator.TIMES.toString().equals("*"));
- assertTrue(InfixExpression.Operator.DIVIDE.toString().equals("/"));
- assertTrue(InfixExpression.Operator.REMAINDER.toString().equals("%"));
- assertTrue(InfixExpression.Operator.PLUS.toString().equals("+"));
- assertTrue(InfixExpression.Operator.MINUS.toString().equals("-"));
- assertTrue(InfixExpression.Operator.LEFT_SHIFT.toString().equals("<<"));
- assertTrue(InfixExpression.Operator.RIGHT_SHIFT_SIGNED.toString().equals(">>"));
- assertTrue(InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED.toString().equals(">>>"));
- assertTrue(InfixExpression.Operator.LESS.toString().equals("<"));
- assertTrue(InfixExpression.Operator.GREATER.toString().equals(">"));
- assertTrue(InfixExpression.Operator.LESS_EQUALS.toString().equals("<="));
- assertTrue(InfixExpression.Operator.GREATER_EQUALS.toString().equals(">="));
- assertTrue(InfixExpression.Operator.EQUALS.toString().equals("=="));
- assertTrue(InfixExpression.Operator.NOT_EQUALS.toString().equals("!="));
- assertTrue(InfixExpression.Operator.XOR.toString().equals("^"));
- assertTrue(InfixExpression.Operator.OR.toString().equals("|"));
- assertTrue(InfixExpression.Operator.AND.toString().equals("&"));
- assertTrue(InfixExpression.Operator.CONDITIONAL_OR.toString().equals("||"));
- assertTrue(InfixExpression.Operator.CONDITIONAL_AND.toString().equals("&&"));
-
- InfixExpression.Operator[] known = {
- InfixExpression.Operator.TIMES,
- InfixExpression.Operator.DIVIDE,
- InfixExpression.Operator.REMAINDER,
- InfixExpression.Operator.PLUS,
- InfixExpression.Operator.MINUS,
- InfixExpression.Operator.LEFT_SHIFT,
- InfixExpression.Operator.RIGHT_SHIFT_SIGNED,
- InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED,
- InfixExpression.Operator.LESS,
- InfixExpression.Operator.GREATER,
- InfixExpression.Operator.LESS_EQUALS,
- InfixExpression.Operator.GREATER_EQUALS,
- InfixExpression.Operator.EQUALS,
- InfixExpression.Operator.NOT_EQUALS,
- InfixExpression.Operator.XOR,
- InfixExpression.Operator.OR,
- InfixExpression.Operator.AND,
- InfixExpression.Operator.CONDITIONAL_OR,
- InfixExpression.Operator.CONDITIONAL_AND,
- };
-
- // check all operators are distinct
- for (int i = 0; i < known.length; i++) {
- for (int j = 0; j < known.length; j++) {
- assertTrue(i == j || !known[i].equals(known[j]));
- }
- }
-
- // check all operators work
- for (int i = 0; i < known.length; i++) {
- previousCount = ast.modificationCount();
- x.setOperator(known[i]);
- assertTrue(ast.modificationCount() > previousCount);
- assertTrue(x.getOperator().equals(known[i]));
- }
- // ensure null does not work as an operator
- try {
- x.setOperator(null);
- assertTrue(false);
- } catch (RuntimeException e) {
- // pass
- }
-
- // check toOperator lookup of operator by name
- for (int i = 0; i < known.length; i++) {
- String name = known[i].toString();
- assertTrue(InfixExpression.Operator.toOperator(name).equals(known[i]));
- }
- assertTrue(InfixExpression.Operator.toOperator("huh") == null);
-
- genericPropertyTest(x, new Property("LeftOperand", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("fie"));
- }
- public ASTNode get() {
- return x.getLeftOperand();
- }
- public void set(ASTNode value) {
- x.setLeftOperand((Expression) value);
- }
- });
-
- genericPropertyTest(x, new Property("RightOperand", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("fie"));
- }
- public ASTNode get() {
- return x.getRightOperand();
- }
- public void set(ASTNode value) {
- x.setRightOperand((Expression) value);
- }
- });
-
- genericPropertyListTest(x, x.extendedOperands(),
- new Property("ExtendedOperands", true, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("x"));
- }
- });
- }
-
- public void testInstanceofExpression() {
- long previousCount = ast.modificationCount();
- final InstanceofExpression x = ast.newInstanceofExpression();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getLeftOperand().getParent() == x);
- assertTrue(x.getRightOperand().getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.INSTANCEOF_EXPRESSION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("LeftOperand", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("fie"));
- }
- public ASTNode get() {
- return x.getLeftOperand();
- }
- public void set(ASTNode value) {
- x.setLeftOperand((Expression) value);
- }
- });
-
- genericPropertyTest(x, new Property("RightOperand", true, Type.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Type result = ast.newSimpleType(ast.newSimpleName("Object"));
- if (parented) {
- ast.newArrayType(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("fie"));
- }
- public ASTNode get() {
- return x.getRightOperand();
- }
- public void set(ASTNode value) {
- x.setRightOperand((Type) value);
- }
- });
- }
-
- public void testConditionalExpression() {
- long previousCount = ast.modificationCount();
- final ConditionalExpression x = ast.newConditionalExpression();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getExpression().getParent() == x);
- assertTrue(x.getThenExpression().getParent() == x);
- assertTrue(x.getElseExpression().getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.CONDITIONAL_EXPRESSION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Expression", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("fie"));
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
-
- genericPropertyTest(x, new Property("ThenExpression", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("fie"));
- }
- public ASTNode get() {
- return x.getThenExpression();
- }
- public void set(ASTNode value) {
- x.setThenExpression((Expression) value);
- }
- });
-
- genericPropertyTest(x, new Property("ElseExpression", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("fie"));
- }
- public ASTNode get() {
- return x.getElseExpression();
- }
- public void set(ASTNode value) {
- x.setElseExpression((Expression) value);
- }
- });
- }
-
- public void testArrayAccess() {
- long previousCount = ast.modificationCount();
- final ArrayAccess x = ast.newArrayAccess();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getArray().getParent() == x);
- assertTrue(x.getIndex().getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.ARRAY_ACCESS);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Array", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("fie"));
- }
- public ASTNode get() {
- return x.getArray();
- }
- public void set(ASTNode value) {
- x.setArray((Expression) value);
- }
- });
-
- genericPropertyTest(x, new Property("Index", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("fie"));
- }
- public ASTNode get() {
- return x.getIndex();
- }
- public void set(ASTNode value) {
- x.setIndex((Expression) value);
- }
- });
- }
-
- public void testArrayInitializer() {
- long previousCount = ast.modificationCount();
- final ArrayInitializer x = ast.newArrayInitializer();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.expressions().isEmpty());
- assertTrue(x.getNodeType() == ASTNode.ARRAY_INITIALIZER);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyListTest(x, x.expressions(),
- new Property("Expressions", true, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("x"));
- }
- });
- }
-
- public void testClassInstanceCreation() {
- long previousCount = ast.modificationCount();
- final ClassInstanceCreation x = ast.newClassInstanceCreation();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getExpression() == null);
- assertTrue(x.getName().getParent() == x);
- assertTrue(x.arguments().isEmpty());
- assertTrue(x.getAnonymousClassDeclaration() == null);
- assertTrue(x.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Expression", false, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("x"));
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
-
- genericPropertyTest(x, new Property("Name", true, Name.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("a");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getName();
- }
- public void set(ASTNode value) {
- x.setName((Name) value);
- }
- });
-
- genericPropertyListTest(x, x.arguments(),
- new Property("Arguments", true, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("x"));
- }
- });
-
- genericPropertyTest(x, new Property("AnonymousClassDeclaration", false, AnonymousClassDeclaration.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- AnonymousClassDeclaration result = targetAst.newAnonymousClassDeclaration();
- if (parented) {
- targetAst.newClassInstanceCreation().setAnonymousClassDeclaration(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return AnonymousClassDeclaration that embeds x
- AnonymousClassDeclaration s0 = x.getAST().newAnonymousClassDeclaration();
- VariableDeclarationFragment s1 = x.getAST().newVariableDeclarationFragment();
- FieldDeclaration s2 = x.getAST().newFieldDeclaration(s1);
- s0.bodyDeclarations().add(s2);
- s1.setInitializer(x);
- return s0;
- }
- public void unwrap() {
- VariableDeclarationFragment s1 = (VariableDeclarationFragment) x.getParent();
- s1.setInitializer(null);
- }
- public ASTNode get() {
- return x.getAnonymousClassDeclaration();
- }
- public void set(ASTNode value) {
- x.setAnonymousClassDeclaration((AnonymousClassDeclaration) value);
- }
- });
-
- }
-
- public void testAnonymousClassDeclaration() {
- long previousCount = ast.modificationCount();
- final AnonymousClassDeclaration x = ast.newAnonymousClassDeclaration();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof ASTNode);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.bodyDeclarations().isEmpty());
- assertTrue(x.getNodeType() == ASTNode.ANONYMOUS_CLASS_DECLARATION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyListTest(x, x.bodyDeclarations(),
- new Property("BodyDeclarations", true, BodyDeclaration.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- TypeDeclaration result = targetAst.newTypeDeclaration();
- if (parented) {
- CompilationUnit compilationUnit = targetAst.newCompilationUnit();
- compilationUnit.types().add(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return BodyDeclaration that embeds x
- VariableDeclarationFragment s0 = x.getAST().newVariableDeclarationFragment();
- FieldDeclaration s1 = x.getAST().newFieldDeclaration(s0);
- ClassInstanceCreation s2= x.getAST().newClassInstanceCreation();
- s0.setInitializer(s2);
- s2.setAnonymousClassDeclaration(x);
- return s1;
- }
- public void unwrap() {
- ClassInstanceCreation s2 = (ClassInstanceCreation) x.getParent();
- s2.setAnonymousClassDeclaration(null);
- }
- });
-
- // check that TypeDeclarations in body are classified correctly
- TypeDeclaration t1 = ast.newTypeDeclaration();
- x.bodyDeclarations().add(t1);
- assertTrue(t1.isLocalTypeDeclaration() == false);
- assertTrue(t1.isMemberTypeDeclaration() == true);
- assertTrue(t1.isPackageMemberTypeDeclaration() == false);
- }
-
- public void testArrayCreation() {
- long previousCount = ast.modificationCount();
- final ArrayCreation x = ast.newArrayCreation();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getType().getParent() == x);
- assertTrue(x.dimensions().isEmpty());
- assertTrue(x.getInitializer() == null);
- assertTrue(x.getNodeType() == ASTNode.ARRAY_CREATION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Type", true, ArrayType.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- ArrayType result = targetAst.newArrayType(
- targetAst.newSimpleType(targetAst.newSimpleName("a")));
- if (parented) {
- targetAst.newArrayType(result);
- }
- return result;
- }
- public ASTNode get() {
- return x.getType();
- }
- public void set(ASTNode value) {
- x.setType((ArrayType) value);
- }
- });
-
- genericPropertyListTest(x, x.dimensions(),
- new Property("Dimensions", true, Expression.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- SimpleName result = targetAst.newSimpleName("foo");
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return Expression that embeds x
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("x"));
- }
- });
-
- genericPropertyTest(x, new Property("Initializer", false, ArrayInitializer.class) {
- public ASTNode sample(AST targetAst, boolean parented) {
- ArrayInitializer result = targetAst.newArrayInitializer();
- if (parented) {
- targetAst.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- // return ArrayInitializer that embeds x
- ArrayInitializer s1 = ast.newArrayInitializer();
- s1.expressions().add(x);
- return s1;
- }
- public void unwrap() {
- ArrayInitializer s1 = (ArrayInitializer) x.getParent();
- s1.expressions().remove(x);
- }
- public ASTNode get() {
- return x.getInitializer();
- }
- public void set(ASTNode value) {
- x.setInitializer((ArrayInitializer) value);
- }
- });
- }
-
- public void testParenthesizedExpression() {
- long previousCount = ast.modificationCount();
- final ParenthesizedExpression x = ast.newParenthesizedExpression();
- assertTrue(ast.modificationCount() > previousCount);
- previousCount = ast.modificationCount();
- assertTrue(x instanceof Expression);
- assertTrue(x.getAST() == ast);
- assertTrue(x.getParent() == null);
- assertTrue(x.getExpression().getParent() == x);
- assertTrue(x.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION);
- // make sure that reading did not change modification count
- assertTrue(ast.modificationCount() == previousCount);
-
- genericPropertyTest(x, new Property("Expression", true, Expression.class) {
- public ASTNode sample(AST ast, boolean parented) {
- Expression result = ast.newSimpleName("foo");
- if (parented) {
- ast.newExpressionStatement(result);
- }
- return result;
- }
- public ASTNode wrap() {
- ParenthesizedExpression s1 = ast.newParenthesizedExpression();
- s1.setExpression(x);
- return s1;
- }
- public void unwrap() {
- ParenthesizedExpression s1 = (ParenthesizedExpression) x.getParent();
- s1.setExpression(ast.newSimpleName("fie"));
- }
- public ASTNode get() {
- return x.getExpression();
- }
- public void set(ASTNode value) {
- x.setExpression((Expression) value);
- }
- });
- }
-
- public void testModifiers() {
-
- // check all modifiers match their JVM spec values
- assertTrue(Modifier.ABSTRACT == 0x0400);
- assertTrue(Modifier.FINAL == 0x0010);
- assertTrue(Modifier.NATIVE == 0x0100);
- assertTrue(Modifier.NONE == 0x0000);
- assertTrue(Modifier.PRIVATE == 0x0002);
- assertTrue(Modifier.PROTECTED == 0x0004);
- assertTrue(Modifier.PUBLIC == 0x0001);
- assertTrue(Modifier.STATIC == 0x0008);
- assertTrue(Modifier.STRICTFP == 0x0800);
- assertTrue(Modifier.SYNCHRONIZED == 0x0020);
- assertTrue(Modifier.TRANSIENT == 0x0080);
- assertTrue(Modifier.VOLATILE == 0x0040);
-
- // check that all
- int[] mods =
- {
- Modifier.ABSTRACT,
- Modifier.FINAL,
- Modifier.NATIVE,
- Modifier.PRIVATE,
- Modifier.PROTECTED,
- Modifier.PUBLIC,
- Modifier.STATIC,
- Modifier.STRICTFP,
- Modifier.SYNCHRONIZED,
- Modifier.TRANSIENT,
- Modifier.VOLATILE,
- };
-
- for (int i=0; i< mods.length; i++) {
- int m = mods[i];
- assertTrue(Modifier.isAbstract(m) == (m == Modifier.ABSTRACT));
- assertTrue(Modifier.isFinal(m) == (m == Modifier.FINAL));
- assertTrue(Modifier.isNative(m) == (m == Modifier.NATIVE));
- assertTrue(Modifier.isPrivate(m) == (m == Modifier.PRIVATE));
- assertTrue(Modifier.isProtected(m) == (m == Modifier.PROTECTED));
- assertTrue(Modifier.isPublic(m) == (m == Modifier.PUBLIC));
- assertTrue(Modifier.isStatic(m) == (m == Modifier.STATIC));
- assertTrue(Modifier.isStrictfp(m) == (m == Modifier.STRICTFP));
- assertTrue(Modifier.isSynchronized(m) == (m == Modifier.SYNCHRONIZED));
- assertTrue(Modifier.isTransient(m) == (m == Modifier.TRANSIENT));
- assertTrue(Modifier.isVolatile(m) == (m == Modifier.VOLATILE));
- }
- }
-
- public void testSubtreeBytes() {
-
- ASTNode x = oneOfEach(ast);
-// System.out.println("oneOfEach().subtreeBytes(): " + x.subtreeBytes());
- assertTrue(x.subtreeBytes() > 0);
- }
-
- public void testNodeTypeConstants() {
- // it would be a breaking API change to change the numeric values of
- // public static final ints
- assertTrue(ASTNode.ANONYMOUS_CLASS_DECLARATION == 1);
- assertTrue(ASTNode.ARRAY_ACCESS == 2);
- assertTrue(ASTNode.ARRAY_CREATION == 3);
- assertTrue(ASTNode.ARRAY_INITIALIZER == 4);
- assertTrue(ASTNode.ARRAY_TYPE == 5);
- assertTrue(ASTNode.ASSERT_STATEMENT == 6);
- assertTrue(ASTNode.ASSIGNMENT == 7);
- assertTrue(ASTNode.BLOCK == 8);
- assertTrue(ASTNode.BOOLEAN_LITERAL == 9);
- assertTrue(ASTNode.BREAK_STATEMENT == 10);
- assertTrue(ASTNode.CAST_EXPRESSION == 11);
- assertTrue(ASTNode.CATCH_CLAUSE == 12);
- assertTrue(ASTNode.CHARACTER_LITERAL == 13);
- assertTrue(ASTNode.CLASS_INSTANCE_CREATION == 14);
- assertTrue(ASTNode.COMPILATION_UNIT == 15);
- assertTrue(ASTNode.CONDITIONAL_EXPRESSION == 16);
- assertTrue(ASTNode.CONSTRUCTOR_INVOCATION == 17);
- assertTrue(ASTNode.CONTINUE_STATEMENT == 18);
- assertTrue(ASTNode.DO_STATEMENT == 19);
- assertTrue(ASTNode.EMPTY_STATEMENT == 20);
- assertTrue(ASTNode.EXPRESSION_STATEMENT == 21);
- assertTrue(ASTNode.FIELD_ACCESS == 22);
- assertTrue(ASTNode.FIELD_DECLARATION == 23);
- assertTrue(ASTNode.FOR_STATEMENT == 24);
- assertTrue(ASTNode.IF_STATEMENT == 25);
- assertTrue(ASTNode.IMPORT_DECLARATION == 26);
- assertTrue(ASTNode.INFIX_EXPRESSION == 27);
- assertTrue(ASTNode.INITIALIZER == 28);
- assertTrue(ASTNode.JAVADOC == 29);
- assertTrue(ASTNode.LABELED_STATEMENT == 30);
- assertTrue(ASTNode.METHOD_DECLARATION == 31);
- assertTrue(ASTNode.METHOD_INVOCATION == 32);
- assertTrue(ASTNode.NULL_LITERAL == 33);
- assertTrue(ASTNode.NUMBER_LITERAL == 34);
- assertTrue(ASTNode.PACKAGE_DECLARATION == 35);
- assertTrue(ASTNode.PARENTHESIZED_EXPRESSION == 36);
- assertTrue(ASTNode.POSTFIX_EXPRESSION == 37);
- assertTrue(ASTNode.PREFIX_EXPRESSION == 38);
- assertTrue(ASTNode.PRIMITIVE_TYPE == 39);
- assertTrue(ASTNode.QUALIFIED_NAME == 40);
- assertTrue(ASTNode.RETURN_STATEMENT == 41);
- assertTrue(ASTNode.SIMPLE_NAME == 42);
- assertTrue(ASTNode.SIMPLE_TYPE == 43);
- assertTrue(ASTNode.SINGLE_VARIABLE_DECLARATION == 44);
- assertTrue(ASTNode.STRING_LITERAL == 45);
- assertTrue(ASTNode.SUPER_CONSTRUCTOR_INVOCATION == 46);
- assertTrue(ASTNode.SUPER_FIELD_ACCESS == 47);
- assertTrue(ASTNode.SUPER_METHOD_INVOCATION == 48);
- assertTrue(ASTNode.SWITCH_CASE == 49);
- assertTrue(ASTNode.SWITCH_STATEMENT == 50);
- assertTrue(ASTNode.SYNCHRONIZED_STATEMENT == 51);
- assertTrue(ASTNode.THIS_EXPRESSION == 52);
- assertTrue(ASTNode.THROW_STATEMENT == 53);
- assertTrue(ASTNode.TRY_STATEMENT == 54);
- assertTrue(ASTNode.TYPE_DECLARATION == 55);
- assertTrue(ASTNode.TYPE_DECLARATION_STATEMENT == 56);
- assertTrue(ASTNode.TYPE_LITERAL == 57);
- assertTrue(ASTNode.VARIABLE_DECLARATION_EXPRESSION == 58);
- assertTrue(ASTNode.VARIABLE_DECLARATION_FRAGMENT == 59);
- assertTrue(ASTNode.VARIABLE_DECLARATION_STATEMENT == 60);
- assertTrue(ASTNode.WHILE_STATEMENT == 61);
- assertTrue(ASTNode.INSTANCEOF_EXPRESSION == 62);
-
- // ensure that all constants are distinct, positive, and small
- // (this may seem paranoid, but this test did uncover a stupid bug!)
- int[] all= {
- ASTNode.ANONYMOUS_CLASS_DECLARATION,
- ASTNode.ARRAY_ACCESS,
- ASTNode.ARRAY_CREATION,
- ASTNode.ARRAY_INITIALIZER,
- ASTNode.ARRAY_TYPE,
- ASTNode.ASSERT_STATEMENT,
- ASTNode.ASSIGNMENT,
- ASTNode.BLOCK,
- ASTNode.BOOLEAN_LITERAL,
- ASTNode.BREAK_STATEMENT,
- ASTNode.CAST_EXPRESSION,
- ASTNode.CATCH_CLAUSE,
- ASTNode.CHARACTER_LITERAL,
- ASTNode.CLASS_INSTANCE_CREATION,
- ASTNode.COMPILATION_UNIT,
- ASTNode.CONDITIONAL_EXPRESSION,
- ASTNode.CONSTRUCTOR_INVOCATION,
- ASTNode.CONTINUE_STATEMENT,
- ASTNode.DO_STATEMENT,
- ASTNode.EMPTY_STATEMENT,
- ASTNode.EXPRESSION_STATEMENT,
- ASTNode.FIELD_ACCESS,
- ASTNode.FIELD_DECLARATION,
- ASTNode.FOR_STATEMENT,
- ASTNode.IF_STATEMENT,
- ASTNode.IMPORT_DECLARATION,
- ASTNode.INFIX_EXPRESSION,
- ASTNode.INSTANCEOF_EXPRESSION,
- ASTNode.INITIALIZER,
- ASTNode.JAVADOC,
- ASTNode.LABELED_STATEMENT,
- ASTNode.METHOD_DECLARATION,
- ASTNode.METHOD_INVOCATION,
- ASTNode.NULL_LITERAL,
- ASTNode.NUMBER_LITERAL,
- ASTNode.PACKAGE_DECLARATION,
- ASTNode.PARENTHESIZED_EXPRESSION,
- ASTNode.POSTFIX_EXPRESSION,
- ASTNode.PREFIX_EXPRESSION,
- ASTNode.PRIMITIVE_TYPE,
- ASTNode.QUALIFIED_NAME,
- ASTNode.RETURN_STATEMENT,
- ASTNode.SIMPLE_NAME,
- ASTNode.SIMPLE_TYPE,
- ASTNode.SINGLE_VARIABLE_DECLARATION,
- ASTNode.STRING_LITERAL,
- ASTNode.SUPER_CONSTRUCTOR_INVOCATION,
- ASTNode.SUPER_FIELD_ACCESS,
- ASTNode.SUPER_METHOD_INVOCATION,
- ASTNode.SWITCH_CASE,
- ASTNode.SWITCH_STATEMENT,
- ASTNode.SYNCHRONIZED_STATEMENT,
- ASTNode.THIS_EXPRESSION,
- ASTNode.THROW_STATEMENT,
- ASTNode.TRY_STATEMENT,
- ASTNode.TYPE_DECLARATION,
- ASTNode.TYPE_DECLARATION_STATEMENT,
- ASTNode.TYPE_LITERAL,
- ASTNode.VARIABLE_DECLARATION_EXPRESSION,
- ASTNode.VARIABLE_DECLARATION_FRAGMENT,
- ASTNode.VARIABLE_DECLARATION_STATEMENT,
- ASTNode.WHILE_STATEMENT,
-
- };
- int MIN = 1;
- int MAX = 100;
- Set s = new HashSet();
- for (int i=0; i<all.length; i++) {
- assertTrue(MIN <= all[i] && all[i] <= MAX);
- s.add(new Integer(all[i]));
- }
- assertTrue(s.size() == all.length);
- // ensure that Integers really do compare properly with equals
- assertTrue(new Integer(1).equals(new Integer(1)));
-
- }}
-
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTVisitorTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTVisitorTest.java
deleted file mode 100644
index f8c1fb6..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTVisitorTest.java
+++ /dev/null
@@ -1,1490 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial test suite for AST API
- ******************************************************************************/
-
-package org.eclipse.jdt.core.tests.dom;
-
-import java.lang.reflect.Method;
-import junit.framework.Test;
-import junit.framework.TestCase;
-
-import org.eclipse.jdt.core.dom.*;
-import org.eclipse.jdt.core.dom.ASTNode;
-
-public class ASTVisitorTest extends TestCase {
-
- public static Test suite() {
- junit.framework.TestSuite suite = new junit.framework.TestSuite(ASTVisitorTest.class.getName());
-
- Class c = ASTVisitorTest.class;
- Method[] methods = c.getMethods();
- for (int i = 0, max = methods.length; i < max; i++) {
- if (methods[i].getName().startsWith("test")) {
- suite.addTest(new ASTVisitorTest(methods[i].getName()));
- }
- }
- return suite;
- }
-
- AST ast;
- SimpleName N1;
- String N1S;
- SimpleName N2;
- String N2S;
- SimpleName N3;
- String N3S;
- Expression E1;
- String E1S;
- Expression E2;
- String E2S;
- Type T1;
- String T1S;
- Statement S1;
- String S1S;
- Statement S2;
- Block B1;
- String B1S;
- String S2S;
- SingleVariableDeclaration V1;
- String V1S;
- SingleVariableDeclaration V2;
- String V2S;
- VariableDeclarationFragment W1;
- String W1S;
- VariableDeclarationFragment W2;
- String W2S;
- FieldDeclaration FD1;
- String FD1S;
- FieldDeclaration FD2;
- String FD2S;
- PackageDeclaration PD1;
- String PD1S;
- ImportDeclaration ID1;
- String ID1S;
- ImportDeclaration ID2;
- String ID2S;
- TypeDeclaration TD1;
- String TD1S;
- TypeDeclaration TD2;
- String TD2S;
- Javadoc JD1;
- String JD1S;
- Javadoc JD2;
- String JD2S;
- AnonymousClassDeclaration ACD1;
- String ACD1S;
-
- final StringBuffer b = new StringBuffer();
-
- public ASTVisitorTest(String name) {
- super(name);
- }
-
- protected void setUp() {
- ast = new AST();
- N1 = ast.newSimpleName("N");
- N1S = "[(nSNNnS)]";
- N2 = ast.newSimpleName("M");
- N2S = "[(nSMMnS)]";
- N3 = ast.newSimpleName("O");
- N3S = "[(nSOOnS)]";
- E1 = ast.newSimpleName("X");
- E1S = "[(nSXXnS)]";
- E2 = ast.newSimpleName("Y");
- E2S = "[(nSYYnS)]";
- T1 = ast.newSimpleType(ast.newSimpleName("Z"));
- T1S = "[(tS[(nSZZnS)]tS)]";
- S1 = ast.newContinueStatement();
- S1S = "[(sCNsCN)]";
- S2 = ast.newBreakStatement();
- S2S = "[(sBRsBR)]";
- B1 = ast.newBlock();
- B1S = "[(sBsB)]";
- V1 = ast.newSingleVariableDeclaration();
- V1.setType(ast.newPrimitiveType(PrimitiveType.INT));
- V1.setName(ast.newSimpleName("a"));
- V1S = "[(VD[(tPintinttP)][(nSaanS)]VD)]";
- V2 = ast.newSingleVariableDeclaration();
- V2.setType(ast.newPrimitiveType(PrimitiveType.BYTE));
- V2.setName(ast.newSimpleName("b"));
- V2S = "[(VD[(tPbytebytetP)][(nSbbnS)]VD)]";
- W1 = ast.newVariableDeclarationFragment();
- W1.setName(ast.newSimpleName("a"));
- W1S = "[(VS[(nSaanS)]VS)]";
- W2 = ast.newVariableDeclarationFragment();
- W2.setName(ast.newSimpleName("b"));
- W2S = "[(VS[(nSbbnS)]VS)]";
- {
- VariableDeclarationFragment temp = ast.newVariableDeclarationFragment();
- temp.setName(ast.newSimpleName("f"));
- FD1 = ast.newFieldDeclaration(temp);
- FD1.setType(ast.newPrimitiveType(PrimitiveType.INT));
- FD1S = "[(FD[(tPintinttP)][(VS[(nSffnS)]VS)]FD)]";
- }
- {
- VariableDeclarationFragment temp = ast.newVariableDeclarationFragment();
- temp.setName(ast.newSimpleName("g"));
- FD2 = ast.newFieldDeclaration(temp);
- FD2.setType(ast.newPrimitiveType(PrimitiveType.CHAR));
- FD2S = "[(FD[(tPcharchartP)][(VS[(nSggnS)]VS)]FD)]";
- }
- PD1 = ast.newPackageDeclaration();
- PD1.setName(ast.newSimpleName("p"));
- PD1S = "[(PD[(nSppnS)]PD)]";
- ID1 = ast.newImportDeclaration();
- ID1.setName(ast.newSimpleName("i"));
- ID1S = "[(ID[(nSiinS)]ID)]";
- ID2 = ast.newImportDeclaration();
- ID2.setName(ast.newSimpleName("j"));
- ID2S = "[(ID[(nSjjnS)]ID)]";
- TD1 = ast.newTypeDeclaration();
- TD1.setName(ast.newSimpleName("c"));
- TD1S = "[(TD[(nSccnS)]TD)]";
- TD2 = ast.newTypeDeclaration();
- TD2.setName(ast.newSimpleName("d"));
- TD2S = "[(TD[(nSddnS)]TD)]";
-
- ACD1 = ast.newAnonymousClassDeclaration();
- ACD1S = "[(ACDACD)]";
-
- JD1 = ast.newJavadoc();
- JD1.setComment("/**X*/");
- JD1S = "[(JD/**X*//**X*/JD)]";
- JD2 = ast.newJavadoc();
- JD2.setComment("/**Y*/");
- JD2S = "[(JD/**Y*//**Y*/JD)]";
-
- }
-
- protected void tearDown() {
- ast = null;
- }
-
- class TestVisitor extends ASTVisitor {
-
- boolean visitTheKids = true;
-
- public boolean isVisitingChildren() {
- return visitTheKids;
- }
-
- public void setVisitingChildren(boolean visitChildren) {
- visitTheKids = visitChildren;
- }
-
- // NAMES
-
- public boolean visit(SimpleName node) {
- b.append("(nS");
- b.append(node.getIdentifier());
- return isVisitingChildren();
- }
- public void endVisit(SimpleName node) {
- b.append(node.getIdentifier());
- b.append("nS)");
- }
- public boolean visit(QualifiedName node) {
- b.append("(nQ");
- return isVisitingChildren();
- }
- public void endVisit(QualifiedName node) {
- b.append("nQ)");
- }
-
- // TYPES
-
- public boolean visit(SimpleType node) {
- b.append("(tS");
- return isVisitingChildren();
- }
- public void endVisit(SimpleType node) {
- b.append("tS)");
- }
- public boolean visit(ArrayType node) {
- b.append("(tA");
- return isVisitingChildren();
- }
- public void endVisit(ArrayType node) {
- b.append("tA)");
- }
- public boolean visit(PrimitiveType node) {
- b.append("(tP");
- b.append(node.getPrimitiveTypeCode().toString());
- return isVisitingChildren();
- }
- public void endVisit(PrimitiveType node) {
- b.append(node.getPrimitiveTypeCode().toString());
- b.append("tP)");
- }
-
- // EXPRESSIONS and STATEMENTS
-
-
- public boolean visit(ArrayAccess node) {
- b.append("(eAA");
- return isVisitingChildren();
- }
- public void endVisit(ArrayAccess node) {
- b.append("eAA)");
- }
-
- public boolean visit(ArrayCreation node) {
- b.append("(eAC");
- return isVisitingChildren();
- }
- public void endVisit(ArrayCreation node) {
- b.append("eAC)");
- }
-
- public boolean visit(ArrayInitializer node) {
- b.append("(eAI");
- return isVisitingChildren();
- }
- public void endVisit(ArrayInitializer node) {
- b.append("eAI)");
- }
-
- public boolean visit(AssertStatement node) {
- b.append("(sAS");
- return isVisitingChildren();
- }
- public void endVisit(AssertStatement node) {
- b.append("sAS)");
- }
-
- public boolean visit(Assignment node) {
- b.append("(");
- b.append(node.getOperator().toString());
- return isVisitingChildren();
- }
- public void endVisit(Assignment node) {
- b.append(node.getOperator().toString());
- b.append(")");
- }
-
- public boolean visit(Block node) {
- b.append("(sB");
- return isVisitingChildren();
- }
- public void endVisit(Block node) {
- b.append("sB)");
- }
-
- public boolean visit(BooleanLiteral node) {
- b.append("(eBL");
- b.append(node.booleanValue() ? "true" : "false");
- return isVisitingChildren();
- }
- public void endVisit(BooleanLiteral node) {
- b.append(node.booleanValue() ? "true" : "false");
- b.append("eBL)");
- }
-
- public boolean visit(BreakStatement node) {
- b.append("(sBR");
- return isVisitingChildren();
- }
- public void endVisit(BreakStatement node) {
- b.append("sBR)");
- }
-
- public boolean visit(CastExpression node) {
- b.append("(eCS");
- return isVisitingChildren();
- }
- public void endVisit(CastExpression node) {
- b.append("eCS)");
- }
-
- public boolean visit(CatchClause node) {
- b.append("(cc");
- return isVisitingChildren();
- }
- public void endVisit(CatchClause node) {
- b.append("cc)");
- }
-
- public boolean visit(CharacterLiteral node) {
- b.append("(eCL");
- b.append(node.getEscapedValue());
- return isVisitingChildren();
- }
- public void endVisit(CharacterLiteral node) {
- b.append(node.getEscapedValue());
- b.append("eCL)");
- }
-
- public boolean visit(ClassInstanceCreation node) {
- b.append("(eCI");
- return isVisitingChildren();
- }
- public void endVisit(ClassInstanceCreation node) {
- b.append("eCI)");
- }
-
- public boolean visit(AnonymousClassDeclaration node) {
- b.append("(ACD");
- return isVisitingChildren();
- }
- public void endVisit(AnonymousClassDeclaration node) {
- b.append("ACD)");
- }
-
- public boolean visit(CompilationUnit node) {
- b.append("(CU");
- return isVisitingChildren();
- }
- public void endVisit(CompilationUnit node) {
- b.append("CU)");
- }
-
- public boolean visit(ConditionalExpression node) {
- b.append("(eCO");
- return isVisitingChildren();
- }
- public void endVisit(ConditionalExpression node) {
- b.append("eCO)");
- }
-
- public boolean visit(ConstructorInvocation node) {
- b.append("(sCI");
- return isVisitingChildren();
- }
- public void endVisit(ConstructorInvocation node) {
- b.append("sCI)");
- }
-
- public boolean visit(ContinueStatement node) {
- b.append("(sCN");
- return isVisitingChildren();
- }
- public void endVisit(ContinueStatement node) {
- b.append("sCN)");
- }
-
- public boolean visit(DoStatement node) {
- b.append("(sDO");
- return isVisitingChildren();
- }
- public void endVisit(DoStatement node) {
- b.append("sDO)");
- }
-
- public boolean visit(EmptyStatement node) {
- b.append("(sEM");
- return isVisitingChildren();
- }
- public void endVisit(EmptyStatement node) {
- b.append("sEM)");
- }
-
- public boolean visit(ExpressionStatement node) {
- b.append("(sEX");
- return isVisitingChildren();
- }
- public void endVisit(ExpressionStatement node) {
- b.append("sEX)");
- }
-
- public boolean visit(FieldAccess node) {
- b.append("(eFA");
- return isVisitingChildren();
- }
- public void endVisit(FieldAccess node) {
- b.append("eFA)");
- }
-
- public boolean visit(FieldDeclaration node) {
- b.append("(FD");
- return isVisitingChildren();
- }
- public void endVisit(FieldDeclaration node) {
- b.append("FD)");
- }
-
- public boolean visit(ForStatement node) {
- b.append("(sFR");
- return isVisitingChildren();
- }
- public void endVisit(ForStatement node) {
- b.append("sFR)");
- }
-
- public boolean visit(IfStatement node) {
- b.append("(sIF");
- return isVisitingChildren();
- }
- public void endVisit(IfStatement node) {
- b.append("sIF)");
- }
-
- public boolean visit(ImportDeclaration node) {
- b.append("(ID");
- return isVisitingChildren();
- }
- public void endVisit(ImportDeclaration node) {
- b.append("ID)");
- }
-
- public boolean visit(InfixExpression node) {
- b.append("(eIN");
- b.append(node.getOperator().toString());
- return isVisitingChildren();
- }
- public void endVisit(InfixExpression node) {
- b.append(node.getOperator().toString());
- b.append("eIN)");
- }
-
- public boolean visit(InstanceofExpression node) {
- b.append("(eIO");
- return isVisitingChildren();
- }
- public void endVisit(InstanceofExpression node) {
- b.append("eIO)");
- }
-
- public boolean visit(Initializer node) {
- b.append("(IN");
- return isVisitingChildren();
- }
- public void endVisit(Initializer node) {
- b.append("IN)");
- }
-
- public boolean visit(Javadoc node) {
- b.append("(JD");
- b.append(node.getComment());
- return isVisitingChildren();
- }
- public void endVisit(Javadoc node) {
- b.append(node.getComment());
- b.append("JD)");
- }
-
- public boolean visit(LabeledStatement node) {
- b.append("(sLA");
- return isVisitingChildren();
- }
- public void endVisit(LabeledStatement node) {
- b.append("sLA)");
- }
-
- public boolean visit(MethodDeclaration node) {
- b.append("(MD");
- return isVisitingChildren();
- }
- public void endVisit(MethodDeclaration node) {
- b.append("MD)");
- }
-
- public boolean visit(MethodInvocation node) {
- b.append("(eMI");
- return isVisitingChildren();
- }
- public void endVisit(MethodInvocation node) {
- b.append("eMI)");
- }
-
- public boolean visit(NullLiteral node) {
- b.append("(eNL");
- return isVisitingChildren();
- }
- public void endVisit(NullLiteral node) {
- b.append("eNL)");
- }
-
- public boolean visit(NumberLiteral node) {
- b.append("(eNU");
- b.append(node.getToken());
- return isVisitingChildren();
- }
- public void endVisit(NumberLiteral node) {
- b.append(node.getToken());
- b.append("eNU)");
- }
-
- public boolean visit(PackageDeclaration node) {
- b.append("(PD");
- return isVisitingChildren();
- }
- public void endVisit(PackageDeclaration node) {
- b.append("PD)");
- }
-
- public boolean visit(ParenthesizedExpression node) {
- b.append("(ePA");
- return isVisitingChildren();
- }
- public void endVisit(ParenthesizedExpression node) {
- b.append("ePA)");
- }
-
- public boolean visit(PostfixExpression node) {
- b.append("(ePO");
- b.append(node.getOperator().toString());
- return isVisitingChildren();
- }
- public void endVisit(PostfixExpression node) {
- b.append(node.getOperator().toString());
- b.append("ePO)");
- }
-
- public boolean visit(PrefixExpression node) {
- b.append("(ePR");
- b.append(node.getOperator().toString());
- return isVisitingChildren();
- }
- public void endVisit(PrefixExpression node) {
- b.append(node.getOperator().toString());
- b.append("ePR)");
- }
-
- public boolean visit(ReturnStatement node) {
- b.append("(sRT");
- return isVisitingChildren();
- }
- public void endVisit(ReturnStatement node) {
- b.append("sRT)");
- }
-
- public boolean visit(SingleVariableDeclaration node) {
- b.append("(VD");
- return isVisitingChildren();
- }
- public void endVisit(SingleVariableDeclaration node) {
- b.append("VD)");
- }
-
- public boolean visit(StringLiteral node) {
- b.append("(eSL");
- b.append(node.getLiteralValue());
- return isVisitingChildren();
- }
- public void endVisit(StringLiteral node) {
- b.append(node.getLiteralValue());
- b.append("eSL)");
- }
-
- public boolean visit(SuperConstructorInvocation node) {
- b.append("(sSC");
- return isVisitingChildren();
- }
- public void endVisit(SuperConstructorInvocation node) {
- b.append("sSC)");
- }
-
- public boolean visit(SuperFieldAccess node) {
- b.append("(eSF");
- return isVisitingChildren();
- }
- public void endVisit(SuperFieldAccess node) {
- b.append("eSF)");
- }
-
- public boolean visit(SuperMethodInvocation node) {
- b.append("(eSM");
- return isVisitingChildren();
- }
- public void endVisit(SuperMethodInvocation node) {
- b.append("eSM)");
- }
-
- public boolean visit(SwitchCase node) {
- b.append("(sSC");
- return isVisitingChildren();
- }
- public void endVisit(SwitchCase node) {
- b.append("sSC)");
- }
-
- public boolean visit(SwitchStatement node) {
- b.append("(sSW");
- return isVisitingChildren();
- }
- public void endVisit(SwitchStatement node) {
- b.append("sSW)");
- }
-
- public boolean visit(SynchronizedStatement node) {
- b.append("(sSY");
- return isVisitingChildren();
- }
- public void endVisit(SynchronizedStatement node) {
- b.append("sSY)");
- }
-
- public boolean visit(ThisExpression node) {
- b.append("(eTH");
- return isVisitingChildren();
- }
- public void endVisit(ThisExpression node) {
- b.append("eTH)");
- }
-
- public boolean visit(ThrowStatement node) {
- b.append("(sTR");
- return isVisitingChildren();
- }
- public void endVisit(ThrowStatement node) {
- b.append("sTR)");
- }
-
- public boolean visit(TryStatement node) {
- b.append("(sTY");
- return isVisitingChildren();
- }
- public void endVisit(TryStatement node) {
- b.append("sTY)");
- }
-
- public boolean visit(TypeDeclaration node) {
- b.append("(TD");
- return isVisitingChildren();
- }
- public void endVisit(TypeDeclaration node) {
- b.append("TD)");
- }
-
- public boolean visit(TypeDeclarationStatement node) {
- b.append("(sTD");
- return isVisitingChildren();
- }
- public void endVisit(TypeDeclarationStatement node) {
- b.append("sTD)");
- }
-
- public boolean visit(TypeLiteral node) {
- b.append("(eTL");
- return isVisitingChildren();
- }
- public void endVisit(TypeLiteral node) {
- b.append("eTL)");
- }
-
- public boolean visit(VariableDeclarationExpression node) {
- b.append("(eVD");
- return isVisitingChildren();
- }
- public void endVisit(VariableDeclarationExpression node) {
- b.append("eVD)");
- }
-
- public boolean visit(VariableDeclarationFragment node) {
- b.append("(VS");
- return isVisitingChildren();
- }
- public void endVisit(VariableDeclarationFragment node) {
- b.append("VS)");
- }
-
- public boolean visit(VariableDeclarationStatement node) {
- b.append("(sVD");
- return isVisitingChildren();
- }
- public void endVisit(VariableDeclarationStatement node) {
- b.append("sVD)");
- }
-
- public boolean visit(WhileStatement node) {
- b.append("(sWH");
- return isVisitingChildren();
- }
- public void endVisit(WhileStatement node) {
- b.append("sWH)");
- }
-
- public void preVisit(ASTNode node) {
- b.append("[");
- }
-
- public void postVisit(ASTNode node) {
- b.append("]");
- }
-
- }
- // NAMES
- public void testSimpleName() {
- Name x1 = ast.newName(new String[]{"Z"});
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue("[(nSZZnS)]".equals(result));
- }
-
- public void testQualifiedName() {
- Name x1 = ast.newName(new String[]{"X", "Y"});
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue("[(nQ[(nSXXnS)][(nSYYnS)]nQ)]".equals(result));
- }
-
-
- // TYPES
- public void testPrimitiveType() {
- Type x1 = ast.newPrimitiveType(PrimitiveType.CHAR);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue("[(tPcharchartP)]".equals(result));
- }
-
- public void testSimpleType() {
- Type x1 = ast.newSimpleType(ast.newName(new String[]{"Z"}));
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue("[(tS[(nSZZnS)]tS)]".equals(b.toString()));
- }
-
- public void testArrayType() {
- Type x0 = ast.newPrimitiveType(PrimitiveType.CHAR);
- Type x1 = ast.newArrayType(x0);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue("[(tA[(tPcharchartP)]tA)]".equals(result));
- }
-
- // EXPRESSIONS and STATEMENTS
-
- public void testArrayAccess() {
- ArrayAccess x1 = ast.newArrayAccess();
- x1.setArray(E1);
- x1.setIndex(E2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eAA"+E1S+E2S+"eAA)]"));
- }
-
- public void testArrayCreation() {
- ArrayCreation x1 = ast.newArrayCreation();
- x1.setType(ast.newArrayType(T1));
- x1.dimensions().add(E1);
- x1.dimensions().add(E2);
- x1.setInitializer(ast.newArrayInitializer());
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eAC"+"[(tA"+T1S+"tA)]"+E1S+E2S+"[(eAIeAI)]eAC)]"));
- }
- public void testArrayInitializer() {
- ArrayInitializer x1 = ast.newArrayInitializer();
- x1.expressions().add(E1);
- x1.expressions().add(E2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eAI"+E1S+E2S+"eAI)]"));
- }
- public void testAssertStatement() {
- AssertStatement x1 = ast.newAssertStatement();
- x1.setExpression(E1);
- x1.setMessage(E2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sAS"+E1S+E2S+"sAS)]"));
- }
- public void testAssignment() {
- Assignment x1 = ast.newAssignment();
- x1.setLeftHandSide(E1);
- x1.setRightHandSide(E2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(="+E1S+E2S+"=)]"));
- }
- public void testBlock() {
- Block x1 = ast.newBlock();
- x1.statements().add(S1);
- x1.statements().add(S2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sB"+S1S+S2S+"sB)]"));
-
- // check that visiting children can be cut off
- v1.setVisitingChildren(false);
- b.setLength(0);
- x1.accept(v1);
- result = b.toString();
- assertTrue(result.equals("[(sBsB)]"));
- }
- public void testBooleanLiteral() {
- BooleanLiteral x1 = ast.newBooleanLiteral(true);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eBLtruetrueeBL)]"));
- }
- public void testBreakStatement() {
- BreakStatement x1 = ast.newBreakStatement();
- x1.setLabel(N1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sBR"+N1S+"sBR)]"));
- }
- public void testCastExpression() {
- CastExpression x1 = ast.newCastExpression();
- x1.setType(T1);
- x1.setExpression(E1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eCS"+T1S+E1S+"eCS)]"));
- }
- public void testCatchClause() {
- CatchClause x1 = ast.newCatchClause();
- x1.setException(V1);
- x1.setBody(B1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(cc"+V1S+B1S+"cc)]"));
- }
- public void testCharacterLiteral() {
- CharacterLiteral x1 = ast.newCharacterLiteral();
- x1.setCharValue('q');
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eCL'q''q'eCL)]"));
- }
- public void testClassInstanceCreation() {
- ClassInstanceCreation x1 = ast.newClassInstanceCreation();
- x1.setExpression(E1);
- x1.setName(N1);
- x1.setAnonymousClassDeclaration(ACD1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eCI"+E1S+N1S+ACD1S+"eCI)]"));
- }
- public void testAnonymousClassDeclaration() {
- AnonymousClassDeclaration x1 = ast.newAnonymousClassDeclaration();
- x1.bodyDeclarations().add(FD1);
- x1.bodyDeclarations().add(FD2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(ACD"+FD1S+FD2S+"ACD)]"));
- }
- public void testCompilationUnit() {
- CompilationUnit x1 = ast.newCompilationUnit();
- x1.setPackage(PD1);
- x1.imports().add(ID1);
- x1.imports().add(ID2);
- x1.types().add(TD1);
- x1.types().add(TD2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(CU"+PD1S+ID1S+ID2S+TD1S+TD2S+"CU)]"));
-
- // check that visiting children can be cut off
- v1.setVisitingChildren(false);
- b.setLength(0);
- x1.accept(v1);
- result = b.toString();
- assertTrue(result.equals("[(CUCU)]"));
- }
- public void testConditionalExpression() {
- ConditionalExpression x1 = ast.newConditionalExpression();
- x1.setExpression(E1);
- x1.setThenExpression(E2);
- x1.setElseExpression(N1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eCO"+E1S+E2S+N1S+"eCO)]"));
- }
- public void testConstructorInvocation() {
- ConstructorInvocation x1 = ast.newConstructorInvocation();
- x1.arguments().add(E1);
- x1.arguments().add(E2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sCI"+E1S+E2S+"sCI)]"));
- }
- public void testContinueStatement() {
- ContinueStatement x1 = ast.newContinueStatement();
- x1.setLabel((SimpleName) N1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sCN"+N1S+"sCN)]"));
- }
- public void testDoStatement() {
- DoStatement x1 = ast.newDoStatement();
- x1.setExpression(E1);
- x1.setBody(S1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sDO"+S1S+E1S+"sDO)]"));
- }
- public void testEmptyStatement() {
- EmptyStatement x1 = ast.newEmptyStatement();
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sEMsEM)]"));
- }
- public void testExpressionStatement() {
- ExpressionStatement x1 = ast.newExpressionStatement(E1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sEX"+E1S+"sEX)]"));
- }
- public void testFieldAccess() {
- FieldAccess x1 = ast.newFieldAccess();
- x1.setExpression(E1);
- x1.setName(N1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eFA"+E1S+N1S+"eFA)]"));
- }
- public void testFieldDeclaration() {
- FieldDeclaration x1 = ast.newFieldDeclaration(W1);
- x1.setJavadoc(JD1);
- x1.setType(T1);
- x1.fragments().add(W2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(FD"+JD1S+T1S+W1S+W2S+"FD)]"));
- }
- public void testForStatement() {
- ForStatement x1 = ast.newForStatement();
- x1.initializers().add(E1);
- x1.initializers().add(E2);
- x1.setExpression(N1);
- x1.updaters().add(N2);
- x1.updaters().add(N3);
- x1.setBody(S1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sFR"+E1S+E2S+N1S+N2S+N3S+S1S+"sFR)]"));
- }
- public void testIfStatement() {
- IfStatement x1 = ast.newIfStatement();
- x1.setExpression(E1);
- x1.setThenStatement(S1);
- x1.setElseStatement(S2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sIF"+E1S+S1S+S2S+"sIF)]"));
- }
- public void testImportDeclaration() {
- ImportDeclaration x1 = ast.newImportDeclaration();
- x1.setName(N1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(ID"+N1S+"ID)]"));
- }
- public void testInfixExpression() {
- InfixExpression x1 = ast.newInfixExpression();
- x1.setOperator(InfixExpression.Operator.PLUS);
- x1.setLeftOperand(E1);
- x1.setRightOperand(E2);
- x1.extendedOperands().add(N1);
- x1.extendedOperands().add(N2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eIN+"+E1S+E2S+N1S+N2S+"+eIN)]"));
- }
- public void testInstanceofExpression() {
- InstanceofExpression x1 = ast.newInstanceofExpression();
- x1.setLeftOperand(E1);
- x1.setRightOperand(T1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eIO"+E1S+T1S+"eIO)]"));
- }
- public void testInitializer() {
- Initializer x1 = ast.newInitializer();
- x1.setJavadoc(JD1);
- x1.setBody(B1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(IN"+JD1S+B1S+"IN)]"));
- }
- public void testJavadoc() {
- Javadoc x1 = ast.newJavadoc();
- x1.setComment("/**?*/");
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue("[(JD/**?*//**?*/JD)]".equals(result));
- }
-
- public void testLabeledStatement() {
- LabeledStatement x1 = ast.newLabeledStatement();
- x1.setLabel(N1);
- x1.setBody(S1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sLA"+N1S+S1S+"sLA)]"));
- }
- public void testMethodDeclaration() {
- MethodDeclaration x1 = ast.newMethodDeclaration();
- x1.setJavadoc(JD1);
- x1.setReturnType(T1);
- x1.setName(N1);
- x1.parameters().add(V1);
- x1.parameters().add(V2);
- x1.thrownExceptions().add(N2);
- x1.thrownExceptions().add(N3);
- x1.setBody(B1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(MD"+JD1S+T1S+N1S+V1S+V2S+N2S+N3S+B1S+"MD)]"));
- }
- public void testMethodInvocation() {
- MethodInvocation x1 = ast.newMethodInvocation();
- x1.setExpression(N1);
- x1.setName(N2);
- x1.arguments().add(E1);
- x1.arguments().add(E2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eMI"+N1S+N2S+E1S+E2S+"eMI)]"));
- }
- public void testNullLiteral() {
- NullLiteral x1 = ast.newNullLiteral();
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eNLeNL)]"));
- }
- public void testNumberLiteral() {
- NumberLiteral x1 = ast.newNumberLiteral("1.0");
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eNU1.01.0eNU)]"));
- }
- public void testPackageDeclaration() {
- PackageDeclaration x1 = ast.newPackageDeclaration();
- x1.setName(N1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(PD"+N1S+"PD)]"));
- }
- public void testParenthesizedExpression() {
- ParenthesizedExpression x1 = ast.newParenthesizedExpression();
- x1.setExpression(E1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(ePA"+E1S+"ePA)]"));
- }
- public void testPostfixExpression() {
- PostfixExpression x1 = ast.newPostfixExpression();
- x1.setOperand(E1);
- x1.setOperator(PostfixExpression.Operator.INCREMENT);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(ePO++"+E1S+"++ePO)]"));
- }
- public void testPrefixExpression() {
- PrefixExpression x1 = ast.newPrefixExpression();
- x1.setOperand(E1);
- x1.setOperator(PrefixExpression.Operator.INCREMENT);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(ePR++"+E1S+"++ePR)]"));
- }
- public void testReturnStatement() {
- ReturnStatement x1 = ast.newReturnStatement();
- x1.setExpression(E1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sRT"+E1S+"sRT)]"));
- }
- public void testStringLiteral() {
- StringLiteral x1 = ast.newStringLiteral();
- x1.setLiteralValue("H");
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eSLHHeSL)]"));
- }
- public void testSuperConstructorInvocation() {
- SuperConstructorInvocation x1 = ast.newSuperConstructorInvocation();
- x1.setExpression(N1);
- x1.arguments().add(E1);
- x1.arguments().add(E2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sSC"+N1S+E1S+E2S+"sSC)]"));
- }
- public void testSuperFieldAccess() {
- SuperFieldAccess x1 = ast.newSuperFieldAccess();
- x1.setQualifier(N1);
- x1.setName(N2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eSF"+N1S+N2S+"eSF)]"));
- }
- public void testSuperMethodInvocation() {
- SuperMethodInvocation x1 = ast.newSuperMethodInvocation();
- x1.setQualifier(N1);
- x1.setName(N2);
- x1.arguments().add(E1);
- x1.arguments().add(E2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eSM"+N1S+N2S+E1S+E2S+"eSM)]"));
- }
- public void testSwitchCase() {
- SwitchCase x1 = ast.newSwitchCase();
- x1.setExpression(E1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sSC"+E1S+"sSC)]"));
- }
- public void testSwitchStatement() {
- SwitchStatement x1 = ast.newSwitchStatement();
- x1.setExpression(E1);
- x1.statements().add(S1);
- x1.statements().add(S2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sSW"+E1S+S1S+S2S+"sSW)]"));
- }
- public void testSynchronizedStatement() {
- SynchronizedStatement x1 = ast.newSynchronizedStatement();
- x1.setExpression(E1);
- x1.setBody(B1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sSY"+E1S+B1S+"sSY)]"));
- }
- public void testThisExpression() {
- ThisExpression x1 = ast.newThisExpression();
- x1.setQualifier(N1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eTH"+N1S+"eTH)]"));
- }
- public void testThrowStatement() {
- ThrowStatement x1 = ast.newThrowStatement();
- x1.setExpression(E1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sTR"+E1S+"sTR)]"));
- }
- public void testTryStatement() {
- TryStatement x1 = ast.newTryStatement();
- x1.setBody(B1);
- CatchClause c1 = ast.newCatchClause();
- c1.setException(V1);
- c1.setBody(ast.newBlock());
- x1.catchClauses().add(c1);
- CatchClause c2 = ast.newCatchClause();
- c2.setException(V2);
- c2.setBody(ast.newBlock());
- x1.catchClauses().add(c2);
- x1.setFinally(ast.newBlock());
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sTY"+B1S+"[(cc"+V1S+"[(sBsB)]"+"cc)]"+"[(cc"+V2S+"[(sBsB)]"+"cc)]"+"[(sBsB)]"+"sTY)]"));
- }
- public void testTypeDeclaration() {
- TypeDeclaration x1 = ast.newTypeDeclaration();
- x1.setJavadoc(JD1);
- x1.setName(N1);
- x1.setSuperclass(N2);
- x1.superInterfaces().add(N3);
- x1.superInterfaces().add(ast.newSimpleName("J"));
- x1.bodyDeclarations().add(FD1);
- x1.bodyDeclarations().add(FD2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(TD"+JD1S+N1S+N2S+N3S+"[(nSJJnS)]"+FD1S+FD2S+"TD)]"));
- }
- public void testTypeDeclarationStatement() {
- TypeDeclarationStatement x1 = ast.newTypeDeclarationStatement(TD1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sTD"+TD1S+"sTD)]"));
- }
- public void testTypeLiteral() {
- TypeLiteral x1 = ast.newTypeLiteral();
- x1.setType(T1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eTL"+T1S+"eTL)]"));
- }
- public void testVariableDeclaration() {
- SingleVariableDeclaration x1 = ast.newSingleVariableDeclaration();
- x1.setType(T1);
- x1.setName(N1);
- x1.setInitializer(E1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(VD"+T1S+N1S+E1S+"VD)]"));
- }
- public void testVariableSpecifier() {
- VariableDeclarationFragment x1 = ast.newVariableDeclarationFragment();
- x1.setName(N1);
- x1.setInitializer(E1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(VS"+N1S+E1S+"VS)]"));
- }
- public void testVariableDeclarationExpression() {
- VariableDeclarationExpression x1 = ast.newVariableDeclarationExpression(W1);
- x1.setType(T1);
- x1.fragments().add(W2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(eVD"+T1S+W1S+W2S+"eVD)]"));
- }
- public void testVariableDeclarationStatement() {
- VariableDeclarationStatement x1 = ast.newVariableDeclarationStatement(W1);
- x1.setType(T1);
- x1.fragments().add(W2);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sVD"+T1S+W1S+W2S+"sVD)]"));
- }
- public void testWhileStatement() {
- WhileStatement x1 = ast.newWhileStatement();
- x1.setExpression(E1);
- x1.setBody(S1);
- TestVisitor v1 = new TestVisitor();
- b.setLength(0);
- x1.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[(sWH"+E1S+S1S+"sWH)]"));
- }
-
- public void testPrePost() {
- SimpleName n1 = ast.newSimpleName("a");
- SimpleName n2 = ast.newSimpleName("b");
- QualifiedName q = ast.newQualifiedName(n1, n2);
- TestVisitor v1 = new TestVisitor() {
- public void preVisit(ASTNode node) {
- b.append("[");
- switch (node.getNodeType()) {
- case ASTNode.QUALIFIED_NAME :
- b.append("q");
- break;
- case ASTNode.SIMPLE_NAME :
- b.append(((SimpleName) node).getIdentifier());
- break;
- }
- }
-
- public void postVisit(ASTNode node) {
- switch (node.getNodeType()) {
- case ASTNode.QUALIFIED_NAME :
- b.append("q");
- break;
- case ASTNode.SIMPLE_NAME :
- b.append(((SimpleName) node).getIdentifier());
- break;
- }
- b.append("]");
- }
- };
-
- b.setLength(0);
- q.accept(v1);
- String result = b.toString();
- assertTrue(result.equals("[q(nQ" + "[a(nSaanS)a]" + "[b(nSbbnS)b]" + "nQ)q]"));
- }
- public void testTraverseAndModify() {
- final TypeDeclaration typeDeclaration = ast.newTypeDeclaration();
- typeDeclaration.setName(N1);
- MethodDeclaration methodDeclaration = ast.newMethodDeclaration();
- methodDeclaration.setName(ast.newSimpleName("M1"));
- typeDeclaration.bodyDeclarations().add(0, methodDeclaration);
- final MethodDeclaration methodDeclaration2 = ast.newMethodDeclaration();
- methodDeclaration2.setName(ast.newSimpleName("M2"));
- typeDeclaration.bodyDeclarations().add(1, methodDeclaration2);
- MethodDeclaration methodDeclaration3 = ast.newMethodDeclaration();
- methodDeclaration3.setName(ast.newSimpleName("M3"));
- typeDeclaration.bodyDeclarations().add(2, methodDeclaration3);
- // insert a new before the current node during a traverse
- TestVisitor v1 = new TestVisitor() {
- public boolean visit(MethodDeclaration node) {
- if (node == methodDeclaration2) {
- MethodDeclaration methodDeclaration4 = ast.newMethodDeclaration();
- methodDeclaration4.setName(ast.newSimpleName("M4"));
- typeDeclaration.bodyDeclarations().add(0, methodDeclaration4);
- }
- return super.visit(node);
- }
- };
- b.setLength(0);
- typeDeclaration.accept(v1);
- assertEquals("wrong output", "[(TD[(nSNNnS)][(MD[(tPvoidvoidtP)][(nSM1M1nS)]MD)][(MD[(tPvoidvoidtP)][(nSM2M2nS)]MD)][(MD[(tPvoidvoidtP)][(nSM3M3nS)]MD)]TD)]", b.toString());
- }
-
- public void testTraverseAndModify_2() {
- final TypeDeclaration typeDeclaration = ast.newTypeDeclaration();
- typeDeclaration.setName(N1);
- MethodDeclaration methodDeclaration = ast.newMethodDeclaration();
- methodDeclaration.setName(ast.newSimpleName("M1"));
- typeDeclaration.bodyDeclarations().add(0, methodDeclaration);
- final MethodDeclaration methodDeclaration2 = ast.newMethodDeclaration();
- methodDeclaration2.setName(ast.newSimpleName("M2"));
- typeDeclaration.bodyDeclarations().add(1, methodDeclaration2);
- MethodDeclaration methodDeclaration3 = ast.newMethodDeclaration();
- methodDeclaration3.setName(ast.newSimpleName("M3"));
- typeDeclaration.bodyDeclarations().add(2, methodDeclaration3);
- // insert a new after the current node during a traverse
- TestVisitor v1 = new TestVisitor() {
- public boolean visit(MethodDeclaration node) {
- if (node == methodDeclaration2) {
- MethodDeclaration methodDeclaration4 = ast.newMethodDeclaration();
- methodDeclaration4.setName(ast.newSimpleName("M4"));
- typeDeclaration.bodyDeclarations().add(3, methodDeclaration4);
- }
- return super.visit(node);
- }
- };
- b.setLength(0);
- typeDeclaration.accept(v1);
- assertEquals("wrong output", "[(TD[(nSNNnS)][(MD[(tPvoidvoidtP)][(nSM1M1nS)]MD)][(MD[(tPvoidvoidtP)][(nSM2M2nS)]MD)][(MD[(tPvoidvoidtP)][(nSM3M3nS)]MD)][(MD[(tPvoidvoidtP)][(nSM4M4nS)]MD)]TD)]", b.toString());
- }
- public void testTraverseAndModify_3() {
- final InfixExpression infixExpression = ast.newInfixExpression();
- infixExpression.setLeftOperand(ast.newSimpleName("i"));
- infixExpression.setRightOperand(ast.newNumberLiteral("10"));
- infixExpression.setOperator(InfixExpression.Operator.PLUS);
- // insert a new after the current node during a traverse
- TestVisitor v1 = new TestVisitor() {
- public boolean visit(SimpleName node) {
- infixExpression.setRightOperand(ast.newNumberLiteral("22"));
- return super.visit(node);
- }
- };
- b.setLength(0);
- infixExpression.accept(v1);
- assertEquals("wrong output", "[(eIN+[(nSiinS)][(eNU2222eNU)]+eIN)]", b.toString());
- }
- public void testTraverseAndModify_4() {
- final InfixExpression infixExpression = ast.newInfixExpression();
- infixExpression.setLeftOperand(ast.newSimpleName("i"));
- infixExpression.setRightOperand(ast.newNumberLiteral("10"));
- infixExpression.setOperator(InfixExpression.Operator.PLUS);
- // insert a new before the current node during a traverse
- TestVisitor v1 = new TestVisitor() {
- public boolean visit(NumberLiteral node) {
- infixExpression.setLeftOperand(ast.newSimpleName("j"));
- return super.visit(node);
- }
- };
- b.setLength(0);
- infixExpression.accept(v1);
- assertEquals("wrong output", "[(eIN+[(nSiinS)][(eNU1010eNU)]+eIN)]", b.toString());
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/RunAllTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/RunAllTests.java
deleted file mode 100644
index 3680cba..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/RunAllTests.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial test suite for AST API
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.dom;
-
-import java.lang.reflect.*;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class RunAllTests extends TestCase {
-public RunAllTests(String name) {
- super(name);
-}
-public static Class[] getAllTestClasses() {
- return new Class[] {
- org.eclipse.jdt.core.tests.dom.ASTConverterTest.class,
- org.eclipse.jdt.core.tests.dom.ASTTest.class,
- org.eclipse.jdt.core.tests.dom.ASTVisitorTest.class,
- org.eclipse.jdt.core.tests.dom.ASTMatcherTest.class
- };
-}
-public static Test suite() {
- TestSuite ts = new TestSuite(RunAllTests.class.getName());
-
- Class[] testClasses = getAllTestClasses();
- for (int i = 0; i < testClasses.length; i++) {
- Class testClass = testClasses[i];
-
- // call the suite() method and add the resulting suite to the suite
- try {
- Method suiteMethod = testClass.getDeclaredMethod("suite", new Class[0]);
- Test suite = (Test)suiteMethod.invoke(null, new Object[0]);
- ts.addTest(suite);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.getTargetException().printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
- }
- return ts;
-}
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
deleted file mode 100644
index 59e6614..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
+++ /dev/null
@@ -1,678 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.security.CodeSource;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.ElementChangedEvent;
-import org.eclipse.jdt.core.IClassFile;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IElementChangedListener;
-import org.eclipse.jdt.core.IImportDeclaration;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaElementDelta;
-import org.eclipse.jdt.core.IJavaModel;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IPackageDeclaration;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-
-
-public abstract class AbstractJavaModelTests extends SuiteOfTestCases {
-
- /**
- * The java.io.File path to the directory that contains the external jars.
- */
- protected static String EXTERNAL_JAR_DIR_PATH;
-
- /**
- * Delta listener
- */
- protected class DeltaListener implements IElementChangedListener {
- /**
- * Deltas received from the java model. See
- * <code>#startDeltas</code> and
- * <code>#stopDeltas</code>.
- */
- public IJavaElementDelta[] deltas;
-
- public void elementChanged(ElementChangedEvent ev) {
- IJavaElementDelta[] copy= new IJavaElementDelta[deltas.length + 1];
- System.arraycopy(deltas, 0, copy, 0, deltas.length);
- copy[deltas.length]= ev.getDelta();
- deltas= copy;
- }
- }
- protected DeltaListener deltaListener = new DeltaListener();
-
-
-public AbstractJavaModelTests(String name) {
- super(name);
-}
-protected void addJavaNature(String projectName) throws CoreException {
- IProject project = getWorkspaceRoot().getProject(projectName);
- IProjectDescription description = project.getDescription();
- description.setNatureIds(new String[] {JavaCore.NATURE_ID});
- project.setDescription(description, null);
-}
-/**
- * Ensures the elements are present after creation.
- */
-public void assertCreation(IJavaElement[] newElements) {
- for (int i = 0; i < newElements.length; i++) {
- IJavaElement newElement = newElements[i];
- assertTrue("Element should be present after creation", newElement.exists());
- }
-}
-/**
- * Ensures the element is present after creation.
- */
-public void assertCreation(IJavaElement newElement) {
- assertCreation(new IJavaElement[] {newElement});
-}
-/**
- * Creates an operation to delete the given elements, asserts
- * the operation is successful, and ensures the elements are no
- * longer present in the model.
- */
-public void assertDeletion(IJavaElement[] elementsToDelete) throws JavaModelException {
- IJavaElement elementToDelete = null;
- for (int i = 0; i < elementsToDelete.length; i++) {
- elementToDelete = elementsToDelete[i];
- assertTrue("Element must be present to be deleted", elementToDelete.exists());
- }
-
- getJavaModel().delete(elementsToDelete, false, null);
-
- for (int i = 0; i < elementsToDelete.length; i++) {
- elementToDelete = elementsToDelete[i];
- assertTrue("Element should not be present after deletion: " + elementToDelete, !elementToDelete.exists());
- }
-}
-/**
- * Attaches a source zip to the given jar package fragment root.
- */
-protected void attachSource(IPackageFragmentRoot root, String sourcePath, String sourceRoot) throws JavaModelException {
- IJavaProject javaProject = root.getJavaProject();
- IClasspathEntry[] entries = (IClasspathEntry[])javaProject.getRawClasspath().clone();
- for (int i = 0; i < entries.length; i++){
- IClasspathEntry entry = entries[i];
- if (entry.getPath().toOSString().toLowerCase().equals(root.getPath().toOSString().toLowerCase())) {
- entries[i] = JavaCore.newLibraryEntry(
- root.getPath(),
- sourcePath == null ? null : new Path(sourcePath),
- sourceRoot == null ? null : new Path(sourceRoot),
- false);
- break;
- }
- }
- javaProject.setRawClasspath(entries, null);
-}
-/**
- * Creates an operation to delete the given element, asserts
- * the operation is successfull, and ensures the element is no
- * longer present in the model.
- */
-public void assertDeletion(IJavaElement elementToDelete) throws JavaModelException {
- assertDeletion(new IJavaElement[] {elementToDelete});
-}
-/**
- * Empties the current deltas.
- */
-public void clearDeltas() {
- this.deltaListener.deltas = new IJavaElementDelta[0];
-}
-/**
- * Copy file from src (path to the original file) to dest (path to the destination file).
- */
-public void copy(File src, File dest) throws IOException {
- // read source bytes
- byte[] srcBytes = this.read(src);
-
- // write bytes to dest
- FileOutputStream out = new FileOutputStream(dest);
- out.write(srcBytes);
- out.close();
-}
-/**
- * Copy the given source directory (and all its contents) to the given target directory.
- */
-protected void copyDirectory(File source, File target) throws IOException {
- if (!target.exists()) {
- target.mkdirs();
- }
- File[] files = source.listFiles();
- if (files == null) return;
- for (int i = 0; i < files.length; i++) {
- File sourceChild = files[i];
- String name = sourceChild.getName();
- if (name.equals("CVS")) continue;
- File targetChild = new File(target, name);
- if (sourceChild.isDirectory()) {
- copyDirectory(sourceChild, targetChild);
- } else {
- copy(sourceChild, targetChild);
- }
- }
-}
-/*
- * Creates a Java project with the given source folders an output location.
- * Add those on the project's classpath.
- */
-protected IJavaProject createJavaProject(final String projectName, final String[] sourceFolders, final String output) throws CoreException {
- return this.createJavaProject(projectName, sourceFolders, new String[] {}, output);
-}
-protected IJavaProject createJavaProject(final String projectName, final String[] sourceFolders, final String[] libraries, final String output) throws CoreException {
- return this.createJavaProject(projectName, sourceFolders, libraries, new String[] {}, output);
-}
-protected IJavaProject createJavaProject(final String projectName, final String[] sourceFolders, final String[] libraries, final String[] projects, final String output) throws CoreException {
- final IJavaProject[] result = new IJavaProject[1];
- IWorkspaceRunnable create = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- // create project
- createProject(projectName);
-
- // set java nature
- addJavaNature(projectName);
-
- // create classpath entries
- IProject project = getWorkspaceRoot().getProject(projectName);
- IPath projectPath = project.getFullPath();
- int sourceLength = sourceFolders.length;
- int libLength = libraries.length;
- int projectLength = projects.length;
- IClasspathEntry[] entries = new IClasspathEntry[sourceLength+libLength+projectLength];
- for (int i= 0; i < sourceLength; i++) {
- IPath sourcePath = new Path(sourceFolders[i]);
- int segmentCount = sourcePath.segmentCount();
- if (segmentCount > 0) {
- // create folder and its parents
- IContainer container = project;
- for (int j = 0; j < segmentCount; j++) {
- IFolder folder = container.getFolder(new Path(sourcePath.segment(j)));
- folder.create(true, true, null);
- container = folder;
- }
- }
- entries[i] = JavaCore.newSourceEntry(projectPath.append(sourcePath));
- }
- for (int i= 0; i < libLength; i++) {
- String lib = libraries[i];
- if (JavaCore.getClasspathVariable(lib) != null) {
- entries[sourceLength+i] = JavaCore.newVariableEntry(new Path(lib), null, null);
- } else {
- IPath libPath = new Path(lib);
- if (!libPath.isAbsolute() && libPath.segmentCount() > 0 && libPath.getFileExtension() == null) {
- project.getFolder(libPath).create(true, true, null);
- libPath = projectPath.append(libPath);
- }
- entries[sourceLength+i] = JavaCore.newLibraryEntry(libPath, null, null);
- }
- }
- for (int i= 0; i < projectLength; i++) {
- entries[sourceLength+libLength+i] = JavaCore.newProjectEntry(new Path(projects[i]));
- }
-
- // create output folder
- IPath outputPath = new Path(output);
- if (outputPath.segmentCount() > 0) {
- IFolder output = project.getFolder(outputPath);
- if (!output.exists()) {
- output.create(true, true, null);
- }
- }
-
- // set classpath and output location
- IJavaProject javaProject = JavaCore.create(project);
- javaProject.setRawClasspath(entries, projectPath.append(outputPath), null);
- result[0] = javaProject;
- }
- };
- getWorkspace().run(create, null);
- return result[0];
-}
-/*
- * Create simple project.
- */
-protected void createProject(final String projectName) throws CoreException {
- IWorkspaceRunnable create = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- IProject project = getProject(projectName);
- project.create(null);
- project.open(null);
- }
- };
- getWorkspace().run(create, null);
-}
-public void deleteFile(File file) {
- file = file.getAbsoluteFile();
- if (!file.exists())
- return;
- if (file.isDirectory()) {
- String[] files = file.list();
- //file.list() can return null
- if (files != null) {
- for (int i = 0; i < files.length; ++i) {
- deleteFile(new File(file, files[i]));
- }
- }
- }
- if (!file.delete()) {
- System.out.println("WARNING: deleteFile(File) could not delete: " + file.getPath());
- }
-}
-protected void deleteProject(String projectName) throws CoreException {
- IProject project = this.getProject(projectName);
- CoreException lastException = null;
- try {
- project.delete(true, null);
- } catch (CoreException e) {
- lastException = e;
- }
- int retryCount = 60; // wait 1 minute at most
- while (project.isAccessible() && --retryCount >= 0) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
- try {
- project.delete(true, null);
- } catch (CoreException e) {
- lastException = e;
- }
- }
- if (!project.isAccessible()) return;
- System.err.println("Failed to delete project " + projectName);
- if (lastException != null) {
- throw lastException;
- }
-}
-/**
- * Delete this resource.
- */
-public void deleteResource(IResource resource) throws CoreException {
- resource.delete(false, null);
-}
-/**
- * Returns true if this delta is flagged as having changed children.
- */
-protected boolean deltaChildrenChanged(IJavaElementDelta delta) {
- return delta.getKind() == IJavaElementDelta.CHANGED &&
- (delta.getFlags() & IJavaElementDelta.F_CHILDREN) != 0;
-}
-/**
- * Returns true if this delta is flagged as having had a content change
- */
-protected boolean deltaContentChanged(IJavaElementDelta delta) {
- return delta.getKind() == IJavaElementDelta.CHANGED &&
- (delta.getFlags() & IJavaElementDelta.F_CONTENT) != 0;
-}
-/**
- * Returns true if this delta is flagged as having moved from a location
- */
-protected boolean deltaMovedFrom(IJavaElementDelta delta) {
- return delta.getKind() == IJavaElementDelta.ADDED &&
- (delta.getFlags() & IJavaElementDelta.F_MOVED_FROM) != 0;
-}
-/**
- * Returns true if this delta is flagged as having moved to a location
- */
-protected boolean deltaMovedTo(IJavaElementDelta delta) {
- return delta.getKind() == IJavaElementDelta.REMOVED &&
- (delta.getFlags() & IJavaElementDelta.F_MOVED_TO) != 0;
-}
-/**
- * Returns the specified compilation unit in the given project, root, and
- * package fragment or <code>null</code> if it does not exist.
- */
-public IClassFile getClassFile(String projectName, String rootPath, String packageName, String className) throws JavaModelException {
- IPackageFragment pkg= getPackageFragment(projectName, rootPath, packageName);
- if (pkg == null) {
- return null;
- } else {
- return pkg.getClassFile(className);
- }
-}
-/**
- * Returns the specified compilation unit in the given project, root, and
- * package fragment or <code>null</code> if it does not exist.
- */
-public ICompilationUnit getCompilationUnit(String projectName, String rootPath, String packageName, String cuName) throws JavaModelException {
- IPackageFragment pkg= getPackageFragment(projectName, rootPath, packageName);
- if (pkg == null) {
- return null;
- } else {
- return pkg.getCompilationUnit(cuName);
- }
-}
-protected ICompilationUnit getCompilationUnitFor(IJavaElement element) {
-
- if (element instanceof ICompilationUnit) {
- return (ICompilationUnit)element;
- }
-
- if (element instanceof IMember) {
- return ((IMember)element).getCompilationUnit();
- }
-
- if (element instanceof IPackageDeclaration ||
- element instanceof IImportDeclaration) {
- return (ICompilationUnit)element.getParent();
- }
-
- return null;
-
-}
-/**
- * Returns the last delta for the given element from the cached delta.
- */
-protected IJavaElementDelta getDeltaFor(IJavaElement element) {
- return getDeltaFor(element, false);
-}
-/**
- * Returns the delta for the given element from the cached delta.
- * If the boolean is true returns the first delta found.
- */
-protected IJavaElementDelta getDeltaFor(IJavaElement element, boolean returnFirst) {
- IJavaElementDelta result = null;
- for (int i = 0; i < this.deltaListener.deltas.length; i++) {
- IJavaElementDelta delta = searchForDelta(element, (IJavaElementDelta) this.deltaListener.deltas[i]);
- if (delta != null) {
- if (returnFirst) {
- return delta;
- } else {
- result = delta;
- }
- }
- }
- return result;
-}
-/**
- * Returns the java.io path to the external java class library (e.g. jclMin.jar)
- */
-protected String getExternalJCLPath() {
- return EXTERNAL_JAR_DIR_PATH + File.separator + "jclMin.jar";
-}
-/**
- * Returns the java.io path to the root source of the external java class library (e.g. "src")
- */
-protected String getExternalJCLRootSourcePath() {
- return "";
-}
-/**
- * Returns the java.io path to the source of the external java class library (e.g. jclMinsrc.zip)
- */
-protected String getExternalJCLSourcePath() {
- return EXTERNAL_JAR_DIR_PATH + File.separator + "jclMinsrc.zip";
-}
-/**
- * Returns the Java Model this test suite is running on.
- */
-public IJavaModel getJavaModel() {
- return JavaCore.create(getWorkspaceRoot());
-}
-/**
- * Returns the Java Project with the given name in this test
- * suite's model. This is a convenience method.
- */
-public IJavaProject getJavaProject(String name) {
- IProject project = getProject(name);
- return JavaCore.create(project);
-}
-/**
- * Returns the specified package fragment in the given project and root, or
- * <code>null</code> if it does not exist.
- * The rootPath must be specified as a project relative path. The empty
- * path refers to the default package fragment.
- */
-public IPackageFragment getPackageFragment(String projectName, String rootPath, String packageName) throws JavaModelException {
- IPackageFragmentRoot root= getPackageFragmentRoot(projectName, rootPath);
- if (root == null) {
- return null;
- } else {
- return root.getPackageFragment(packageName);
- }
-}
-/**
- * Returns the specified package fragment root in the given project, or
- * <code>null</code> if it does not exist.
- * The rootPath must be specified as a project relative path. The empty
- * path refers to the package fragment root that is the project
- * folder iteslf.
- */
-public IPackageFragmentRoot getPackageFragmentRoot(
- String projectName,
- String rootPath)
- throws JavaModelException {
-
- IJavaProject project = getJavaProject(projectName);
- if (project == null) {
- return null;
- }
- IPath path = new Path(rootPath);
- if (path.isAbsolute()) {
- IPackageFragmentRoot root = project.getPackageFragmentRoot(rootPath);
- if (root.exists()) {
- return root;
- }
- } else {
- IPackageFragmentRoot[] roots = project.getPackageFragmentRoots();
- if (roots == null || roots.length == 0) {
- return null;
- }
- for (int i = 0; i < roots.length; i++) {
- IPackageFragmentRoot root = roots[i];
- if (!root.isExternal()
- && root.getUnderlyingResource().getProjectRelativePath().equals(path)) {
- return root;
- }
- }
- }
- return null;
-}
-protected IProject getProject(String project) {
- return getWorkspaceRoot().getProject(project);
-}
-/**
- * Returns the OS path to the directory that contains this plugin.
- */
-protected String getPluginDirectoryPath() {
- CodeSource javaCoreCodeSource = JavaCore.class.getProtectionDomain().getCodeSource();
- if (javaCoreCodeSource != null) {
- URL javaCoreUrl = javaCoreCodeSource.getLocation();
- String javaCorePath = javaCoreUrl.getFile();
- int index = javaCorePath.indexOf(JavaCore.PLUGIN_ID);
- if (index != -1) {
- String pluginsPath = javaCorePath.substring(0, index);
- return pluginsPath + "org.eclipse.jdt.core.tests.model";
- }
- }
- return null;
-}
-public String getSourceWorkspacePath() {
- return getPluginDirectoryPath() + java.io.File.separator + "workspace";
-}
-/**
- * Returns the IWorkspace this test suite is running on.
- */
-public IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
-}
-protected IWorkspaceRoot getWorkspaceRoot() {
- return getWorkspace().getRoot();
-}
-public byte[] read(java.io.File file) throws java.io.IOException {
- int fileLength;
- byte[] fileBytes = new byte[fileLength = (int) file.length()];
- java.io.FileInputStream stream = new java.io.FileInputStream(file);
- int bytesRead = 0;
- int lastReadSize = 0;
- while ((lastReadSize != -1) && (bytesRead != fileLength)) {
- lastReadSize = stream.read(fileBytes, bytesRead, fileLength - bytesRead);
- bytesRead += lastReadSize;
- }
- stream.close();
- return fileBytes;
-}
-protected void removeJavaNature(String projectName) throws CoreException {
- IProject project = this.getProject(projectName);
- IProjectDescription description = project.getDescription();
- description.setNatureIds(new String[] {});
- project.setDescription(description, null);
-}
-/**
- * Returns a delta for the given element in the delta tree
- */
-protected IJavaElementDelta searchForDelta(IJavaElement element, IJavaElementDelta delta) {
-
- if (delta == null) {
- return null;
- } else {
- if (delta.getElement().equals(element)) {
- return delta;
- } else {
- for (int i= 0; i < delta.getAffectedChildren().length; i++) {
- IJavaElementDelta child= searchForDelta(element, delta.getAffectedChildren()[i]);
- if (child != null) {
- return child;
- }
- }
- return null;
- }
- }
-}
-/**
- * Sets the class path of the Java project.
- */
-public void setClasspath(IJavaProject javaProject, IClasspathEntry[] classpath) {
- try {
- javaProject.setRawClasspath(classpath, null);
- } catch (JavaModelException e) {
- assertTrue("failed to set classpath", false);
- }
-}
-/**
- * Check locally for the required JCL files, jclMin.jar and jclMinsrc.zip.
- * If not available, copy from the project resources.
- */
-public void setupExternalJCL() throws IOException {
- if (EXTERNAL_JAR_DIR_PATH != null) return;
-
- String separator = java.io.File.separator;
- String resourceJCLDir = getPluginDirectoryPath() + separator + "JCL";
- String localJCLPath = getWorkspaceRoot().getLocation().toFile().getParentFile().getCanonicalPath();
- EXTERNAL_JAR_DIR_PATH = localJCLPath;
- java.io.File jclDir = new java.io.File(localJCLPath);
- java.io.File jclMin =
- new java.io.File(localJCLPath + separator + "jclMin.jar");
- java.io.File jclMinsrc = new java.io.File(localJCLPath + separator + "jclMinsrc.zip");
- if (!jclDir.exists()) {
- if (!jclDir.mkdir()) {
- //mkdir failed
- throw new IOException("Could not create the directory " + jclDir);
- } else {
- //copy the two files to the JCL directory
- java.io.File resourceJCLMin =
- new java.io.File(resourceJCLDir + separator + "jclMin.jar");
- copy(resourceJCLMin, jclMin);
- java.io.File resourceJCLMinsrc =
- new java.io.File(resourceJCLDir + separator + "jclMinsrc.zip");
- copy(resourceJCLMinsrc, jclMinsrc);
- }
- } else {
- //check that the two files, jclMin.jar and jclMinsrc.zip are present
- //copy either file that is missing
- if (!jclMin.exists()) {
- java.io.File resourceJCLMin =
- new java.io.File(resourceJCLDir + separator + "jclMin.jar");
- copy(resourceJCLMin, jclMin);
- }
- if (!jclMinsrc.exists()) {
- java.io.File resourceJCLMinsrc =
- new java.io.File(resourceJCLDir + separator + "jclMinsrc.zip");
- copy(resourceJCLMinsrc, jclMinsrc);
- }
- }
-}
-protected IJavaProject setUpJavaProject(final String projectName) throws CoreException, IOException {
- // copy files in project from source workspace to target workspace
- String sourceWorkspacePath = getSourceWorkspacePath();
- String targetWorkspacePath = getWorkspaceRoot().getLocation().toFile().getCanonicalPath();
- copyDirectory(new File(sourceWorkspacePath, projectName), new File(targetWorkspacePath, projectName));
-
- // ensure variables are set
- if (JavaCore.getClasspathVariable("JCL_LIB") == null) {
- JavaCore.setClasspathVariables(
- new String[] {"JCL_LIB", "JCL_SRC", "JCL_SRCROOT"},
- new Path[] {new Path(getExternalJCLPath()), new Path(getExternalJCLSourcePath()), new Path(getExternalJCLRootSourcePath())},
- null);
- }
-
- // ensure autobuilding is turned off
- IWorkspaceDescription description = getWorkspace().getDescription();
- if (description.isAutoBuilding()) {
- description.setAutoBuilding(false);
- getWorkspace().setDescription(description);
- }
-
- // create project
- final IProject project = getWorkspaceRoot().getProject(projectName);
- IWorkspaceRunnable populate = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- project.create(null);
- project.open(null);
- }
- };
- getWorkspace().run(populate, null);
- return JavaCore.create(project);
-}
-public void setUpSuite() throws Exception {
- super.setUpSuite();
- setupExternalJCL();
-}
-/**
- * Starts listening to element deltas, and queues them in fgDeltas.
- */
-public void startDeltas() {
- clearDeltas();
- JavaCore.addElementChangedListener(this.deltaListener);
-}
-/**
- * Stops listening to element deltas, and clears the current deltas.
- */
-public void stopDeltas() {
- JavaCore.removeElementChangedListener(this.deltaListener);
- clearDeltas();
-}
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java
deleted file mode 100644
index 3650809..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Run all java model tests.
- */
-public class AllJavaModelTests extends TestCase {
-public AllJavaModelTests(String name) {
- super(name);
-}
-public static Test suite() {
- TestSuite suite = new TestSuite(AllJavaModelTests.class.getName());
- // Enter each test here, grouping the tests that are related
-
- // Java Naming convention tests
- suite.addTest(JavaConventionTests.suite());
-
- // Project & Root API unit tests
- suite.addTest(JavaProjectTests.suite());
-
- // Source attachment tests
- suite.addTest(AttachSourceTests.suite());
-
- //Create type source tests
- suite.addTest(CreateTypeSourceExamplesTests.suite());
-
- //Create method source tests
- suite.addTest(CreateMethodSourceExamplesTests.suite());
-
- // Java search tests
- suite.addTest(JavaSearchTests.suite());
- suite.addTest(WorkingCopySearchTests.suite());
-
- // Working copy tests
- suite.addTest(WorkingCopyTests.suite());
- suite.addTest(WorkingCopyNotInClasspathTests.suite());
- suite.addTest(HierarchyOnWorkingCopiesTests.suite());
-
- // test IJavaModel
- suite.addTest(JavaModelTests.suite());
-
- // tests to check the encoding
- suite.addTest(EncodingTests.suite());
-
- // test class name with special names like names containing '$'
- suite.addTest(ClassNameTests.suite());
-
- // IBuffer tests
- suite.addTest(BufferTests.suite());
-
- // Name lookup tests
- suite.addTest(NameLookupTests2.suite());
-
- // Classpath and output location tests
- suite.addTest(ClasspathTests.suite());
-
- // Delta tests
- suite.addTest(JavaElementDeltaTests.suite());
- suite.addTest(ExternalJarDeltaTests.suite());
-
- // Java element existence tests
- suite.addTest(ExistenceTests.suite());
-
- // Support for "open on" feature tests
- suite.addTest(ResolveTests.suite());
-
- return suite;
-}
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java
deleted file mode 100644
index 74dac41..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachSourceTests.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
-
-/**
- * TO DO:
- * - source attachment on external jar.
- * - don't use assertTrue where assertEquals should be used
- * - don't hardcode positions
-*/
-public class AttachSourceTests extends ModifyingResourceTests {
-
-/**
- * Attaches a source zip to the given jar package fragment root.
- */
-protected void attachSource(IPackageFragmentRoot root, String sourcePath, String sourceRoot) throws JavaModelException {
- IJavaProject javaProject = root.getJavaProject();
- IClasspathEntry[] entries = (IClasspathEntry[])javaProject.getRawClasspath().clone();
- for (int i = 0; i < entries.length; i++){
- IClasspathEntry entry = entries[i];
- if (entry.getPath().toOSString().toLowerCase().equals(root.getPath().toOSString().toLowerCase())) {
- entries[i] = JavaCore.newLibraryEntry(
- root.getPath(),
- sourcePath == null ? null : new Path(sourcePath),
- sourceRoot == null ? null : new Path(sourceRoot),
- false);
- break;
- }
- }
- javaProject.setRawClasspath(entries, null);
-}
- private IPackageFragmentRoot jarRoot;
-
-public AttachSourceTests(String name) {
- super(name);
-}
-public static Test suite() {
- TestSuite suite = new Suite(AttachSourceTests.class.getName());
- suite.addTest(new AttachSourceTests("testAttachSource"));
- suite.addTest(new AttachSourceTests("testGetSourceAttachmentPath"));
- suite.addTest(new AttachSourceTests("testAttachSourceRetrievalClass"));
- suite.addTest(new AttachSourceTests("testAttachSourceRetrievalMethod"));
- suite.addTest(new AttachSourceTests("testAttachSourceSourceRange"));
- suite.addTest(new AttachSourceTests("testAttachSourceSourceRangeInnerClass"));
- suite.addTest(new AttachSourceTests("testAttachSourceNameRange"));
- suite.addTest(new AttachSourceTests("testClassFileGetElementAt"));
- suite.addTest(new AttachSourceTests("testAttachSourcePersisted"));
- suite.addTest(new AttachSourceTests("testChangeSourceAttachmentFile"));
- suite.addTest(new AttachSourceTests("testDetachSource"));
- suite.addTest(new AttachSourceTests("testAttachSourceWithRootPath"));
- return suite;
-
-}
-/**
- * Create project and set the jar placeholder.
- */
-public void setUpSuite() throws Exception {
- super.setUpSuite();
-
- IJavaProject project = setUpJavaProject("AttachSourceTests");
- this.jarRoot = project.getPackageFragmentRoot("/AttachSourceTests/attach.jar");
-}
-/**
- * Reset the jar placeholder and delete project.
- */
-public void tearDownSuite() throws Exception {
- this.jarRoot.close();
- this.jarRoot = null;
- this.deleteProject("AttachSourceTests");
-
- super.tearDown();
-}
-
-/**
- * Attaches a source zip to the classes.zip jar.
- */
-public void testAttachSource() {
- try {
- this.attachSource(this.jarRoot, "/AttachSourceTests/attachsrc.zip", null);
- } catch (JavaModelException jme) {
- fail("Attach source operation creation failed");
- }
-}
-
-/**
- * Ensures that name ranges exists for BinaryMembers that have
- * mapped source.
- */
-public void testAttachSourceNameRange() throws JavaModelException {
- IClassFile cf = this.jarRoot.getPackageFragment("x.y").getClassFile("A.class");
- IMethod method = cf.getType().getMethod("foo", null);
- assertTrue("method name range not correct", method.getNameRange().getOffset() != -1 && method.getNameRange().getLength() != 0);
-
- IClassFile objectCF = this.jarRoot.getPackageFragment("x.y").getClassFile("A.class");
- ISourceRange range= objectCF.getType().getNameRange();
- int start, end;
- start= range.getOffset();
- end= start + range.getLength() - 1;
-
- assertTrue("source code does not exist for the entire attached compilation unit", start != -1 && end != -1);
- String source= objectCF.getSource().substring(start, end + 1);
- assertEquals("name should be 'A'", "A", source);
-}
-/**
- * Closes the jar, to ensure when it is re-opened the source
- * attachment still exists.
- */
-public void testAttachSourcePersisted() throws JavaModelException {
- this.jarRoot.close();
- testAttachSourceRetrievalClass();
- testAttachSourceRetrievalMethod();
-}
-/**
- * Retrieves the source code for methods of class A.
- */
-public void testAttachSourceRetrievalMethod() throws JavaModelException {
- IClassFile cf = this.jarRoot.getPackageFragment("x.y").getClassFile("A.class");
- IMethod[] methods = cf.getType().getMethods();
- for (int i = 0; i < methods.length; i++) {
- IMethod method = methods[i];
- assertTrue("source code does not exist for the method " + method, method.getSource() != null);
- assertTrue("method name range not correct", method.getNameRange().getOffset() != -1 && method.getNameRange().getLength() != 0);
- }
-}
-/**
- * Retrieves the source code for "A.class", which is
- * the entire CU for "A.java".
- */
-public void testAttachSourceRetrievalClass() throws JavaModelException {
- IClassFile objectCF = this.jarRoot.getPackageFragment("x.y").getClassFile("A.class");
- assertTrue("source code does not exist for the entire attached compilation unit", objectCF.getSource() != null);
-}
-/**
- * Ensures that a source range exists for the class file that has
- * mapped source.
- */
-public void testAttachSourceSourceRange() throws JavaModelException {
- IClassFile cf = this.jarRoot.getPackageFragment("x.y").getClassFile("A.class");
- assertTrue("Class file source range not correct", cf.getSourceRange().getOffset() == 0 && cf.getSourceRange().getLength() != 0);
-
-}
-/**
- * Ensures that a source range exists for the (inner) class file that has
- * mapped source.
- */
-public void testAttachSourceSourceRangeInnerClass() throws JavaModelException {
- IClassFile cf = this.jarRoot.getPackageFragment("x.y").getClassFile("A$Inner.class");
- assertTrue("Inner Class file source range not correct", cf.getSourceRange().getOffset() == 0 && cf.getSourceRange().getLength() != 0);
-
-}
-/**
- * Attaches a source zip to the Minimal.zip jar. The source zip has
- * a nested root structure and exists as a resource. Tests that
- * the attachment is persisted as a server property for the jar.
- */
-public void testAttachSourceWithRootPath() throws JavaModelException {
- try {
- IJavaProject project = getJavaProject("AttachSourceTests");
- IFile jar = (IFile) project.getProject().findMember("attach2.jar");
- IFile srcZip=(IFile) project.getProject().findMember("attach2src.zip");
- JarPackageFragmentRoot jarRoot = (JarPackageFragmentRoot) project.getPackageFragmentRoot(jar);
- jarRoot.attachSource(srcZip.getFullPath(), new Path("src/nested"), null);
-
- IClassFile cf = jarRoot.getPackageFragment("x.y").getClassFile("B.class");
- assertTrue("source code does not exist for the entire attached compilation unit", cf.getSource() != null);
- jarRoot.close();
- cf = jarRoot.getPackageFragment("x.y").getClassFile("B.class");
- assertTrue("source code does not exist for the entire attached compilation unit", cf.getSource() != null);
-
- IPath rootSAPath= jarRoot.getSourceAttachmentRootPath();
- assertEquals("Unexpected source attachment root path for " + jarRoot.getPath(), "src/nested", rootSAPath.toString());
-
- IPath saPath= jarRoot.getSourceAttachmentPath();
- assertEquals("Unexpected source attachment path for " + jarRoot.getPath(), "/AttachSourceTests/attach2src.zip", saPath.toString());
-
- jarRoot.close();
- } catch (JavaModelException jme) {
- fail("Attach source operation creation failed");
- }
-}
-/**
- * Ensure that a class file with an attached source can retrieve its children given a source index.
- */
-public void testClassFileGetElementAt() throws JavaModelException {
- IClassFile cf = this.jarRoot.getPackageFragment("x.y").getClassFile("A.class");
- IJavaElement elt = null;
-
- elt = cf.getElementAt(15);
- assertTrue("should have found \"A\"",
- elt != null &&
- elt.getElementType() == IJavaElement.TYPE &&
- elt.getElementName().equals("A"));
-
- elt = cf.getElementAt(53);
- assertTrue("should have found \"public A()\"",
- elt != null &&
- elt.getElementType() == IJavaElement.METHOD &&
- elt.getElementName().equals("A"));
-
- elt = cf.getElementAt(72);
- assertTrue("should have found \"public void foo()\"",
- elt != null &&
- elt.getElementType() == IJavaElement.METHOD &&
- elt.getElementName().equals("foo"));
-}
-/**
- * Changing the source attachment file should update the java model.
- * (regression test for bug 23292 Must restart Eclipse after debug of source in .zip is updated)
- */
-public void testChangeSourceAttachmentFile() throws CoreException {
- IClassFile cf = this.jarRoot.getPackageFragment("x.y").getClassFile("A.class");
- IMethod method = cf.getType().getMethod("foo", new String[] {});
- String lineSeparator = System.getProperty("line.separator");
-
- // check initial source
- assertEquals(
- "unexpected initial source for foo()",
- "public void foo() {" + lineSeparator +
- " }",
- method.getSource());
-
- // replace source attachment file
- this.swapFiles("AttachSourceTests/attachsrc.zip", "AttachSourceTests/attachsrc.new.zip");
- assertEquals(
- "unexpected source for foo() after replacement",
- "public void foo() {" + lineSeparator +
- " System.out.println(\"foo\");" + lineSeparator +
- " }",
- method.getSource());
-
- // delete source attachment file
- this.deleteFile("AttachSourceTests/attachsrc.zip");
- assertEquals(
- "unexpected source for foo() after deletion",
- null,
- method.getSource());
-
- // add source attachment file back
- this.moveFile("AttachSourceTests/attachsrc.new.zip", "AttachSourceTests/attachsrc.zip");
- assertEquals(
- "unexpected source for foo() after addition",
- "public void foo() {" + lineSeparator +
- " }",
- method.getSource());
-}
-/**
- * Removes the source attachment from the jar.
- */
-public void testDetachSource() throws JavaModelException {
- try {
- this.attachSource(this.jarRoot, null, null);
- IClassFile cf = this.jarRoot.getPackageFragment("x.y").getClassFile("A.class");
- assertTrue("source code should no longer exist for A", cf.getSource() == null);
- assertTrue("name range should no longer exist for A", cf.getType().getNameRange().getOffset() == -1);
- assertTrue("source range should no longer exist for A", cf.getType().getSourceRange().getOffset() == -1);
- assertTrue("Source attachment path should be null", null == this.jarRoot.getSourceAttachmentPath());
- assertTrue("Source attachment root path should be null", null ==this.jarRoot.getSourceAttachmentRootPath());
- } catch (JavaModelException jme) {
- fail("Source Detach Failed");
- }
-}
-/**
- * Retrieves the source attachment paths for jar root.
- */
-public void testGetSourceAttachmentPath() throws JavaModelException {
- IPath saPath= this.jarRoot.getSourceAttachmentPath();
- assertEquals("Source attachment path not correct for root " + this.jarRoot, "/AttachSourceTests/attachsrc.zip", saPath.toString());
- assertEquals("Source attachment root path should be empty", new Path(""), this.jarRoot.getSourceAttachmentRootPath());
-}
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/BufferTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/BufferTests.java
deleted file mode 100644
index 06d066c..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/BufferTests.java
+++ /dev/null
@@ -1,516 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.core.tests.model.*;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class BufferTests extends ModifyingResourceTests implements IBufferChangedListener {
- protected BufferChangedEvent event= null;
-public BufferTests(String name) {
- super(name);
-}
-/**
- * Cache the event
- */
-public void bufferChanged(BufferChangedEvent event) {
- this.event= event;
-}
-protected IBuffer createBuffer(String path, String content) throws CoreException {
- this.createFile(path, content);
- ICompilationUnit cu = this.getCompilationUnit(path);
- IBuffer buffer = cu.getBuffer();
- buffer.addBufferChangedListener(this);
- this.event = null;
- return buffer;
-}
-protected void deleteBuffer(IBuffer buffer) throws CoreException {
- buffer.removeBufferChangedListener(this);
- IResource resource = buffer.getUnderlyingResource();
- if (resource != null) {
- resource.delete(true, null);
- }
-}
-/**
- * @see RegressionTestSuite#setUpSuite()
- */
-public void setUpSuite() throws Exception {
- super.setUpSuite();
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.createFolder("P/x/y");
- } catch (CoreException e) {
- e.printStackTrace();
- }
-}
-
-/**
- * @see TestCase#tearDownSuite()
- */
-public void tearDownSuite() throws Exception {
- super.tearDownSuite();
- this.deleteProject("P");
-}
-
-
-public static Test suite() {
- TestSuite suite = new Suite(BufferTests.class.getName());
-
- suite.addTest(new BufferTests("testAppend"));
- suite.addTest(new BufferTests("testAppendReadOnly"));
- suite.addTest(new BufferTests("testClose"));
- suite.addTest(new BufferTests("testGetChar"));
- suite.addTest(new BufferTests("testGetLength"));
- suite.addTest(new BufferTests("testGetText"));
- suite.addTest(new BufferTests("testGetUnderlyingResource"));
- suite.addTest(new BufferTests("testInsertBeginning"));
- suite.addTest(new BufferTests("testInsertMiddle"));
- suite.addTest(new BufferTests("testInsertEnd"));
- suite.addTest(new BufferTests("testReplaceBeginning"));
- suite.addTest(new BufferTests("testReplaceMiddle"));
- suite.addTest(new BufferTests("testReplaceEnd"));
- suite.addTest(new BufferTests("testDeleteBeginning"));
- suite.addTest(new BufferTests("testDeleteMiddle"));
- suite.addTest(new BufferTests("testDeleteEnd"));
-
- suite.addTest(new BufferTests("testCreateImport"));
-
- return suite;
-}
-/**
- * Tests appending to a buffer.
- */
-public void testAppend() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- int oldLength= buffer.getLength();
- buffer.append("\nclass B {}");
- assertBufferEvent(oldLength, 0, "\nclass B {}");
- assertEquals(
- "unexpected buffer contents",
- "package x.y;\n" +
- "public class A {\n" +
- "}\n" +
- "class B {}",
- buffer.getContents()
- );
- assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
- } finally {
- this.deleteBuffer(buffer);
- }
-}
-/**
- * Tests appending to a read-only buffer.
- */
-public void testAppendReadOnly() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- buffer.getUnderlyingResource().setReadOnly(true);
- int oldLength= buffer.getLength();
- buffer.append("\nclass B {}");
- assertTrue("unexpected event", this.event == null);
- assertEquals(
- "unexpected buffer contents",
- "package x.y;\n" +
- "public class A {\n" +
- "}",
- buffer.getContents()
- );
- assertTrue("should not have unsaved changes", !buffer.hasUnsavedChanges());
- } finally {
- buffer.getUnderlyingResource().setReadOnly(false);
- this.deleteBuffer(buffer);
- }
-}
-public void testClose() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- buffer.close();
- assertBufferEvent(0, 0, null);
- } finally {
- this.deleteBuffer(buffer);
- }
-}
-
-
-/**
- * Tests getting the underlying resource of a buffer.
- */
-public void testGetUnderlyingResource() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- ICompilationUnit copy = null;
- try {
- IFile file = this.getFile("P/x/y/A.java");
- assertEquals("Unexpected underlying resource", file, buffer.getUnderlyingResource());
-
- copy = (ICompilationUnit)this.getCompilationUnit("P/x/y/A.java").getWorkingCopy();
- assertEquals("Unexpected underlying resource 2", null, copy.getBuffer().getUnderlyingResource());
- } finally {
- this.deleteBuffer(buffer);
- if (copy != null) {
- copy.destroy();
- }
- }
-}
-/**
- * Tests deleting text at the beginning of a buffer.
- */
-public void testDeleteBeginning() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- buffer.replace(0, 13, "");
- assertBufferEvent(0, 13, null);
- assertEquals(
- "unexpected buffer contents",
- "public class A {\n" +
- "}",
- buffer.getContents()
- );
- assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
- } finally {
- this.deleteBuffer(buffer);
- }
-}
-/**
- * Tests deleting text in the middle of a buffer.
- */
-public void testDeleteMiddle() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- // delete "public "
- buffer.replace(13, 7, "");
- assertBufferEvent(13, 7, null);
- assertEquals(
- "unexpected buffer contents",
- "package x.y;\n" +
- "class A {\n" +
- "}",
- buffer.getContents()
- );
- assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
- } finally {
- this.deleteBuffer(buffer);
- }
-}
-/**
- * Tests deleting text at the end of a buffer.
- */
-public void testDeleteEnd() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- // delete "public class A {\n}"
- buffer.replace(13, 18, "");
- assertBufferEvent(13, 18, null);
- assertEquals(
- "unexpected buffer contents",
- "package x.y;\n",
- buffer.getContents()
- );
- assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
- } finally {
- this.deleteBuffer(buffer);
- }
-}
-/**
- * Tests the buffer char retrieval via source position
- */
-public void testGetChar() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- assertEquals("Unexpected char at position 17", 'i', buffer.getChar(17));
- } finally {
- this.deleteBuffer(buffer);
- }
-}
-/**
- * Tests the buffer getLength()
- */
-public void testGetLength() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- assertEquals("Unexpected length", 31, buffer.getLength());
- } finally {
- this.deleteBuffer(buffer);
- }
-}
-/**
- * Tests the buffer text retrieval via source position
- */
-public void testGetText() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- assertEquals("Unexpected text (1)", "p", buffer.getText(0, 1));
- assertEquals("Unexpected text (2)", "public", buffer.getText(13, 6));
- assertEquals("Unexpected text (3)", "", buffer.getText(10, 0));
- } finally {
- this.deleteBuffer(buffer);
- }
-}
-/**
- * Tests inserting text at the beginning of a buffer.
- */
-public void testInsertBeginning() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- buffer.replace(0, 0, "/* copyright mycompany */\n");
- assertBufferEvent(0, 0, "/* copyright mycompany */\n");
- assertEquals(
- "unexpected buffer contents",
- "/* copyright mycompany */\n" +
- "package x.y;\n" +
- "public class A {\n" +
- "}",
- buffer.getContents()
- );
- assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
- } finally {
- this.deleteBuffer(buffer);
- }
-}
-/**
- * Tests replacing text at the beginning of a buffer.
- */
-public void testReplaceBeginning() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- buffer.replace(0, 13, "package other;\n");
- assertBufferEvent(0, 13, "package other;\n");
- assertEquals(
- "unexpected buffer contents",
- "package other;\n" +
- "public class A {\n" +
- "}",
- buffer.getContents()
- );
- assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
- } finally {
- this.deleteBuffer(buffer);
- }
-}
-/**
- * Tests replacing text in the middle of a buffer.
- */
-public void testReplaceMiddle() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- // replace "public class A" after the \n of package statement
- buffer.replace(13, 14, "public class B");
- assertBufferEvent(13, 14, "public class B");
- assertEquals(
- "unexpected buffer contents",
- "package x.y;\n" +
- "public class B {\n" +
- "}",
- buffer.getContents()
- );
- assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
- } finally {
- this.deleteBuffer(buffer);
- }
-}
-/**
- * Tests replacing text at the end of a buffer.
- */
-public void testReplaceEnd() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- // replace "}" at the end of cu with "}\n"
- int end = buffer.getLength();
- buffer.replace(end-1, 1, "}\n");
- assertBufferEvent(end-1, 1, "}\n");
- assertEquals(
- "unexpected buffer contents",
- "package x.y;\n" +
- "public class A {\n" +
- "}\n",
- buffer.getContents()
- );
- assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
- } finally {
- this.deleteBuffer(buffer);
- }
-}
-/**
- * Tests inserting text in the middle of a buffer.
- */
-public void testInsertMiddle() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- // insert after the \n of package statement
- buffer.replace(13, 0, "/* class comment */\n");
- assertBufferEvent(13, 0, "/* class comment */\n");
- assertEquals(
- "unexpected buffer contents",
- "package x.y;\n" +
- "/* class comment */\n" +
- "public class A {\n" +
- "}",
- buffer.getContents()
- );
- assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
- } finally {
- this.deleteBuffer(buffer);
- }
-}
-/**
- * Tests inserting text at the end of a buffer.
- */
-public void testInsertEnd() throws CoreException {
- IBuffer buffer = this.createBuffer(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- try {
- // insert after the \n of package statement
- int end = buffer.getLength();
- buffer.replace(end, 0, "\nclass B {}");
- assertBufferEvent(end, 0, "\nclass B {}");
- assertEquals(
- "unexpected buffer contents",
- "package x.y;\n" +
- "public class A {\n" +
- "}\n" +
- "class B {}",
- buffer.getContents()
- );
- assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
- } finally {
- this.deleteBuffer(buffer);
- }
-}
-
-/**
- * Tests replacing text within a buffer using a create import
- * (regression test for PR #1G7A0WI).
- */
-public void testCreateImport() throws CoreException {
- IFile file = this.createFile(
- "P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}"
- );
- ICompilationUnit copy = null;
- IBuffer buffer = null;
- try {
- copy = (ICompilationUnit)this.getCompilationUnit("P/x/y/A.java").getWorkingCopy();
- buffer = copy.getBuffer();
- buffer.addBufferChangedListener(this);
- copy.createImport("java.io.IOException", null, null);
- assertBufferEvent(13, 0, "import java.io.IOException;" + "\n"); // A.java has a \n line delimiter
- } finally {
- if (buffer != null) {
- buffer.removeBufferChangedListener(this);
- }
- if (copy != null) {
- copy.destroy();
- }
- file.delete(true, null);
- }
-}
-/**
- * Verify the buffer changed event
- */
-protected void assertBufferEvent(int offset, int length, String text) {
- assertTrue("event should not be null", this.event != null);
- assertEquals("unexpected offset", offset, this.event.getOffset());
- assertEquals("unexpected length", length, this.event.getLength());
- if (text == null) {
- assertTrue("text should be null", this.event.getText() == null);
- } else {
- assertEquals("unexpected text", text, this.event.getText());
- }
-}
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassNameTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassNameTests.java
deleted file mode 100644
index 0c2231b..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassNameTests.java
+++ /dev/null
@@ -1,959 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.tests.model.*;
-
-/**
- * Test retrieving types by their name.
- */
-public class ClassNameTests extends ModifyingResourceTests {
-
-
- public ClassNameTests(String name) {
- super(name);
- }
-
- /**
- * Tests that a type in a jar with a name ending with $ can be retrieved.
- */
- public void testClassNameWithDollar() throws JavaModelException, CoreException {
- try {
- byte[] tab = new byte[372];
- tab[0]=80;
- tab[1]=75;
- tab[2]=3;
- tab[3]=4;
- tab[4]=20;
- tab[5]=0;
- tab[6]=8;
- tab[7]=0;
- tab[8]=8;
- tab[9]=0;
- tab[10]=-63;
- tab[11]=88;
- tab[12]=-102;
- tab[13]=44;
- tab[14]=0;
- tab[15]=0;
- tab[16]=0;
- tab[17]=0;
- tab[18]=0;
- tab[19]=0;
- tab[20]=0;
- tab[21]=0;
- tab[22]=0;
- tab[23]=0;
- tab[24]=0;
- tab[25]=0;
- tab[26]=11;
- tab[27]=0;
- tab[28]=0;
- tab[29]=0;
- tab[30]=112;
- tab[31]=49;
- tab[32]=47;
- tab[33]=65;
- tab[34]=36;
- tab[35]=46;
- tab[36]=99;
- tab[37]=108;
- tab[38]=97;
- tab[39]=115;
- tab[40]=115;
- tab[41]=93;
- tab[42]=78;
- tab[43]=-63;
- tab[44]=74;
- tab[45]=-61;
- tab[46]=64;
- tab[47]=16;
- tab[48]=125;
- tab[49]=-45;
- tab[50]=77;
- tab[51]=-78;
- tab[52]=53;
- tab[53]=86;
- tab[54]=91;
- tab[55]=99;
- tab[56]=127;
- tab[57]=64;
- tab[58]=-24;
- tab[59]=-95;
- tab[60]=21;
- tab[61]=106;
- tab[62]=-16;
- tab[63]=-84;
- tab[64]=8;
- tab[65]=-91;
- tab[66]=-48;
- tab[67]=83;
- tab[68]=48;
- tab[69]=-121;
- tab[70]=74;
- tab[71]=-17;
- tab[72]=-101;
- tab[73]=-72;
- tab[74]=-42;
- tab[75]=45;
- tab[76]=49;
- tab[77]=43;
- tab[78]=49;
- tab[79]=-11;
- tab[80]=-69;
- tab[81]=-12;
- tab[82]=84;
- tab[83]=-16;
- tab[84]=-32;
- tab[85]=7;
- tab[86]=-8;
- tab[87]=81;
- tab[88]=-30;
- tab[89]=108;
- tab[90]=12;
- tab[91]=42;
- tab[92]=-50;
- tab[93]=-31;
- tab[94]=61;
- tab[95]=102;
- tab[96]=-26;
- tab[97]=-67;
- tab[98]=121;
- tab[99]=-13;
- tab[100]=-15;
- tab[101]=-7;
- tab[102]=-10;
- tab[103]=14;
- tab[104]=-127;
- tab[105]=41;
- tab[106]=-122;
- tab[107]=4;
- tab[108]=-1;
- tab[109]=-15;
- tab[110]=60;
- tab[111]=-98;
- tab[112]=-115;
- tab[113]=36;
- tab[114]=-120;
- tab[115]=48;
- tab[116]=-40;
- tab[117]=-88;
- tab[118]=103;
- tab[119]=21;
- tab[120]=23;
- tab[121]=-86;
- tab[122]=92;
- tab[123]=-57;
- tab[124]=105;
- tab[125]=-74;
- tab[126]=-47;
- tab[127]=121;
- tab[128]=45;
- tab[129]=33;
- tab[130]=8;
- tab[131]=-63;
- tab[132]=-91;
- tab[133]=41;
- tab[134]=77;
- tab[135]=125;
- tab[136]=69;
- tab[137]=16;
- tab[138]=-29;
- tab[139]=-55;
- tab[140]=-118;
- tab[141]=-32;
- tab[142]=-51;
- tab[143]=-19;
- tab[144]=-83;
- tab[145]=-18;
- tab[146]=-63;
- tab[147]=71;
- tab[148]=16;
- tab[149]=-62;
- tab[150]=67;
- tab[151]=-105;
- tab[152]=-48;
- tab[153]=79;
- tab[154]=76;
- tab[155]=-87;
- tab[156]=-81;
- tab[157]=-73;
- tab[158]=15;
- tab[159]=-103;
- tab[160]=-82;
- tab[161]=110;
- tab[162]=84;
- tab[163]=86;
- tab[164]=104;
- tab[165]=66;
- tab[166]=-108;
- tab[167]=-40;
- tab[168]=92;
- tab[169]=21;
- tab[170]=43;
- tab[171]=85;
- tab[172]=25;
- tab[173]=-41;
- tab[174]=-73;
- tab[175]=67;
- tab[176]=-81;
- tab[177]=-66;
- tab[178]=55;
- tab[179]=79;
- tab[180]=4;
- tab[181]=-103;
- tab[182]=52;
- tab[183]=121;
- tab[184]=23;
- tab[185]=124;
- tab[186]=-18;
- tab[187]=-50;
- tab[188]=90;
- tab[189]=-62;
- tab[190]=112;
- tab[191]=60;
- tab[192]=73;
- tab[193]=126;
- tab[194]=99;
- tab[195]=-105;
- tab[196]=117;
- tab[197]=101;
- tab[198]=-54;
- tab[199]=-75;
- tab[200]=91;
- tab[201]=46;
- tab[202]=-46;
- tab[203]=-76;
- tab[204]=-117;
- tab[205]=1;
- tab[206]=33;
- tab[207]=92;
- tab[208]=-38;
- tab[209]=109;
- tab[210]=-107;
- tab[211]=-21;
- tab[212]=-123;
- tab[213]=113;
- tab[214]=55;
- tab[215]=-28;
- tab[216]=108;
- tab[217]=116;
- tab[218]=-26;
- tab[219]=-60;
- tab[220]=56;
- tab[221]=65;
- tab[222]=-121;
- tab[223]=-61;
- tab[224]=93;
- tab[225]=117;
- tab[226]=64;
- tab[227]=-18;
- tab[228]=23;
- tab[229]=70;
- tab[230]=-55;
- tab[231]=93;
- tab[232]=-52;
- tab[233]=76;
- tab[234]=-52;
- tab[235]=-2;
- tab[236]=-23;
- tab[237]=14;
- tab[238]=123;
- tab[239]=-81;
- tab[240]=-51;
- tab[241]=58;
- tab[242]=100;
- tab[243]=12;
- tab[244]=-102;
- tab[245]=-95;
- tab[246]=-64;
- tab[247]=62;
- tab[248]=99;
- tab[249]=-17;
- tab[250]=91;
- tab[251]=-64;
- tab[252]=124;
- tab[253]=-64;
- tab[254]=76;
- tab[255]=56;
- tab[256]=68;
- tab[257]=-65;
- tab[258]=53;
- tab[259]=79;
- tab[260]=91;
- tab[261]=-77;
- tab[262]=-120;
- tab[263]=-114;
- tab[264]=94;
- tab[265]=-2;
- tab[266]=89;
- tab[267]=-125;
- tab[268]=63;
- tab[269]=86;
- tab[270]=-15;
- tab[271]=99;
- tab[272]=-115;
- tab[273]=26;
- tab[274]=-43;
- tab[275]=-15;
- tab[276]=23;
- tab[277]=80;
- tab[278]=75;
- tab[279]=7;
- tab[280]=8;
- tab[281]=122;
- tab[282]=-92;
- tab[283]=103;
- tab[284]=15;
- tab[285]=-20;
- tab[286]=0;
- tab[287]=0;
- tab[288]=0;
- tab[289]=78;
- tab[290]=1;
- tab[291]=0;
- tab[292]=0;
- tab[293]=80;
- tab[294]=75;
- tab[295]=1;
- tab[296]=2;
- tab[297]=20;
- tab[298]=0;
- tab[299]=20;
- tab[300]=0;
- tab[301]=8;
- tab[302]=0;
- tab[303]=8;
- tab[304]=0;
- tab[305]=-63;
- tab[306]=88;
- tab[307]=-102;
- tab[308]=44;
- tab[309]=122;
- tab[310]=-92;
- tab[311]=103;
- tab[312]=15;
- tab[313]=-20;
- tab[314]=0;
- tab[315]=0;
- tab[316]=0;
- tab[317]=78;
- tab[318]=1;
- tab[319]=0;
- tab[320]=0;
- tab[321]=11;
- tab[322]=0;
- tab[323]=0;
- tab[324]=0;
- tab[325]=0;
- tab[326]=0;
- tab[327]=0;
- tab[328]=0;
- tab[329]=0;
- tab[330]=0;
- tab[331]=0;
- tab[332]=0;
- tab[333]=0;
- tab[334]=0;
- tab[335]=0;
- tab[336]=0;
- tab[337]=0;
- tab[338]=0;
- tab[339]=112;
- tab[340]=49;
- tab[341]=47;
- tab[342]=65;
- tab[343]=36;
- tab[344]=46;
- tab[345]=99;
- tab[346]=108;
- tab[347]=97;
- tab[348]=115;
- tab[349]=115;
- tab[350]=80;
- tab[351]=75;
- tab[352]=5;
- tab[353]=6;
- tab[354]=0;
- tab[355]=0;
- tab[356]=0;
- tab[357]=0;
- tab[358]=1;
- tab[359]=0;
- tab[360]=1;
- tab[361]=0;
- tab[362]=57;
- tab[363]=0;
- tab[364]=0;
- tab[365]=0;
- tab[366]=37;
- tab[367]=1;
- tab[368]=0;
- tab[369]=0;
- tab[370]=0;
- tab[371]=0;
- IJavaProject javaProject = createJavaProject("P", new String[] {"src"}, "bin");
- IFile jarFile = createFile("P/lib.jar", tab);
- javaProject.setRawClasspath(new IClasspathEntry[] {JavaCore.newLibraryEntry(jarFile.getFullPath(), null, null, false)}, new NullProgressMonitor());
- javaProject.findType("p1.A$");
- } catch (CoreException e) {
- e.printStackTrace();
- assertTrue(false);
- } finally {
- deleteProject("P");
- }
- }
- /**
- * Tests that a member type can be retrived using a dot qualified name.
- */
- public void testFindTypeWithDot() throws JavaModelException, CoreException {
- try {
- IJavaProject javaProject = createJavaProject("P", new String[] {""}, "");
- this.createFolder("/P/p");
- this.createFile(
- "/P/p/X.java",
- "package p;\n" +
- "public class X {\n" +
- " public class Y {\n" +
- " }\n" +
- "}"
- );
- IType type = javaProject.findType("p.X.Y");
- assertEquals(
- "Unexpected type found",
- "class Y [in X [in X.java [in p [in [project root] [in P]]]]]",
- type == null ? "null" : type.toString()
- );
- } finally {
- deleteProject("P");
- }
- }
-
- /**
- * Tests that a type in a jar with a name ending with $ can be retrieved.
- */
- public void testSearchTypeNameInJars() throws JavaModelException, CoreException {
- try {
- byte[] tab = new byte[478];
- tab[0]=80;
- tab[1]=75;
- tab[2]=3;
- tab[3]=4;
- tab[4]=20;
- tab[5]=0;
- tab[6]=8;
- tab[7]=0;
- tab[8]=8;
- tab[9]=0;
- tab[10]=19;
- tab[11]=87;
- tab[12]=-95;
- tab[13]=44;
- tab[14]=0;
- tab[15]=0;
- tab[16]=0;
- tab[17]=0;
- tab[18]=0;
- tab[19]=0;
- tab[20]=0;
- tab[21]=0;
- tab[22]=0;
- tab[23]=0;
- tab[24]=0;
- tab[25]=0;
- tab[26]=9;
- tab[27]=0;
- tab[28]=0;
- tab[29]=0;
- tab[30]=112;
- tab[31]=49;
- tab[32]=47;
- tab[33]=112;
- tab[34]=50;
- tab[35]=47;
- tab[36]=112;
- tab[37]=51;
- tab[38]=47;
- tab[39]=3;
- tab[40]=0;
- tab[41]=80;
- tab[42]=75;
- tab[43]=7;
- tab[44]=8;
- tab[45]=0;
- tab[46]=0;
- tab[47]=0;
- tab[48]=0;
- tab[49]=2;
- tab[50]=0;
- tab[51]=0;
- tab[52]=0;
- tab[53]=0;
- tab[54]=0;
- tab[55]=0;
- tab[56]=0;
- tab[57]=80;
- tab[58]=75;
- tab[59]=3;
- tab[60]=4;
- tab[61]=20;
- tab[62]=0;
- tab[63]=8;
- tab[64]=0;
- tab[65]=8;
- tab[66]=0;
- tab[67]=19;
- tab[68]=87;
- tab[69]=-95;
- tab[70]=44;
- tab[71]=0;
- tab[72]=0;
- tab[73]=0;
- tab[74]=0;
- tab[75]=0;
- tab[76]=0;
- tab[77]=0;
- tab[78]=0;
- tab[79]=0;
- tab[80]=0;
- tab[81]=0;
- tab[82]=0;
- tab[83]=16;
- tab[84]=0;
- tab[85]=0;
- tab[86]=0;
- tab[87]=112;
- tab[88]=49;
- tab[89]=47;
- tab[90]=112;
- tab[91]=50;
- tab[92]=47;
- tab[93]=112;
- tab[94]=51;
- tab[95]=47;
- tab[96]=88;
- tab[97]=46;
- tab[98]=99;
- tab[99]=108;
- tab[100]=97;
- tab[101]=115;
- tab[102]=115;
- tab[103]=93;
- tab[104]=79;
- tab[105]=-53;
- tab[106]=78;
- tab[107]=-61;
- tab[108]=64;
- tab[109]=12;
- tab[110]=28;
- tab[111]=55;
- tab[112]=-81;
- tab[113]=-110;
- tab[114]=6;
- tab[115]=8;
- tab[116]=-3;
- tab[117]=3;
- tab[118]=110;
- tab[119]=60;
- tab[120]=-44;
- tab[121]=-82;
- tab[122]=10;
- tab[123]=71;
- tab[124]=16;
- tab[125]=23;
- tab[126]=36;
- tab[127]=78;
- tab[128]=81;
- tab[129]=57;
- tab[130]=20;
- tab[131]=69;
- tab[132]=-67;
- tab[133]=110;
- tab[134]=-62;
- tab[135]=-74;
- tab[136]=108;
- tab[137]=-107;
- tab[138]=102;
- tab[139]=-93;
- tab[140]=52;
- tab[141]=-27;
- tab[142]=-65;
- tab[143]=56;
- tab[144]=33;
- tab[145]=113;
- tab[146]=-32;
- tab[147]=3;
- tab[148]=-8;
- tab[149]=40;
- tab[150]=-124;
- tab[151]=55;
- tab[152]=-115;
- tab[153]=0;
- tab[154]=117;
- tab[155]=37;
- tab[156]=-49;
- tab[157]=-56;
- tab[158]=-10;
- tab[159]=-116;
- tab[160]=-19;
- tab[161]=-3;
- tab[162]=-6;
- tab[163]=-2;
- tab[164]=-8;
- tab[165]=-124;
- tab[166]=-125;
- tab[167]=17;
- tab[168]=78;
- tab[169]=8;
- tab[170]=97;
- tab[171]=53;
- tab[172]=17;
- tab[173]=-43;
- tab[174]=-107;
- tab[175]=-88;
- tab[176]=-82;
- tab[177]=-59;
- tab[178]=60;
- tab[179]=0;
- tab[180]=17;
- tab[181]=-30;
- tab[182]=-107;
- tab[183]=124;
- tab[184]=-107;
- tab[185]=-94;
- tab[186]=-112;
- tab[187]=-27;
- tab[188]=82;
- tab[189]=60;
- tab[190]=102;
- tab[191]=43;
- tab[192]=-107;
- tab[193]=55;
- tab[194]=1;
- tab[195]=28;
- tab[196]=-126;
- tab[197]=127;
- tab[198]=-85;
- tab[199]=75;
- tab[200]=-35;
- tab[201]=-36;
- tab[202]=17;
- tab[203]=-100;
- tab[204]=-77;
- tab[205]=-13;
- tab[206]=-108;
- tab[207]=-32;
- tab[208]=-34;
- tab[209]=-101;
- tab[210]=103;
- tab[211]=21;
- tab[212]=-63;
- tab[213]=-125;
- tab[214]=31;
- tab[215]=-62;
- tab[216]=69;
- tab[217]=-97;
- tab[218]=112;
- tab[219]=-100;
- tab[220]=-24;
- tab[221]=82;
- tab[222]=77;
- tab[223]=-73;
- tab[224]=-21;
- tab[225]=76;
- tab[226]=-43;
- tab[227]=79;
- tab[228]=50;
- tab[229]=43;
- tab[230]=20;
- tab[231]=97;
- tab[232]=-104;
- tab[233]=-104;
- tab[234]=92;
- tab[235]=22;
- tab[236]=-87;
- tab[237]=-84;
- tab[238]=-75;
- tab[239]=-51;
- tab[240]=-69;
- tab[241]=-94;
- tab[242]=-37;
- tab[243]=-68;
- tab[244]=-24;
- tab[245]=13;
- tab[246]=33;
- tab[247]=74;
- tab[248]=-2;
- tab[249]=-106;
- tab[250]=-34;
- tab[251]=-16;
- tab[252]=-52;
- tab[253]=-123;
- tab[254]=49;
- tab[255]=124;
- tab[256]=-56;
- tab[257]=-52;
- tab[258]=108;
- tab[259]=-21;
- tab[260]=92;
- tab[261]=61;
- tab[262]=104;
- tab[263]=43;
- tab[264]=-12;
- tab[265]=-25;
- tab[266]=99;
- tab[267]=123;
- tab[268]=7;
- tab[269]=78;
- tab[270]=-47;
- tab[271]=-29;
- tab[272]=5;
- tab[273]=-10;
- tab[274]=-11;
- tab[275]=64;
- tab[276]=118;
- tab[277]=31;
- tab[278]=99;
- tab[279]=-64;
- tab[280]=-103;
- tab[281]=96;
- tab[282]=38;
- tab[283]=102;
- tab[284]=-17;
- tab[285]=-30;
- tab[286]=29;
- tab[287]=7;
- tab[288]=111;
- tab[289]=109;
- tab[290]=59;
- tab[291]=100;
- tab[292]=-12;
- tab[293]=-37;
- tab[294]=-94;
- tab[295]=-125;
- tab[296]=1;
- tab[297]=99;
- tab[298]=-76;
- tab[299]=19;
- tab[300]=48;
- tab[301]=31;
- tab[302]=-74;
- tab[303]=3;
- tab[304]=-114;
- tab[305]=126;
- tab[306]=-51;
- tab[307]=-105;
- tab[308]=28;
- tab[309]=-74;
- tab[310]=71;
- tab[311]=-5;
- tab[312]=70;
- tab[313]=-9;
- tab[314]=-97;
- tab[315]=-111;
- tab[316]=58;
- tab[317]=35;
- tab[318]=-1;
- tab[319]=-83;
- tab[320]=85;
- tab[321]=-59;
- tab[322]=63;
- tab[323]=80;
- tab[324]=75;
- tab[325]=7;
- tab[326]=8;
- tab[327]=-99;
- tab[328]=105;
- tab[329]=77;
- tab[330]=-38;
- tab[331]=-36;
- tab[332]=0;
- tab[333]=0;
- tab[334]=0;
- tab[335]=53;
- tab[336]=1;
- tab[337]=0;
- tab[338]=0;
- tab[339]=80;
- tab[340]=75;
- tab[341]=1;
- tab[342]=2;
- tab[343]=20;
- tab[344]=0;
- tab[345]=20;
- tab[346]=0;
- tab[347]=8;
- tab[348]=0;
- tab[349]=8;
- tab[350]=0;
- tab[351]=19;
- tab[352]=87;
- tab[353]=-95;
- tab[354]=44;
- tab[355]=0;
- tab[356]=0;
- tab[357]=0;
- tab[358]=0;
- tab[359]=2;
- tab[360]=0;
- tab[361]=0;
- tab[362]=0;
- tab[363]=0;
- tab[364]=0;
- tab[365]=0;
- tab[366]=0;
- tab[367]=9;
- tab[368]=0;
- tab[369]=0;
- tab[370]=0;
- tab[371]=0;
- tab[372]=0;
- tab[373]=0;
- tab[374]=0;
- tab[375]=0;
- tab[376]=0;
- tab[377]=0;
- tab[378]=0;
- tab[379]=0;
- tab[380]=0;
- tab[381]=0;
- tab[382]=0;
- tab[383]=0;
- tab[384]=0;
- tab[385]=112;
- tab[386]=49;
- tab[387]=47;
- tab[388]=112;
- tab[389]=50;
- tab[390]=47;
- tab[391]=112;
- tab[392]=51;
- tab[393]=47;
- tab[394]=80;
- tab[395]=75;
- tab[396]=1;
- tab[397]=2;
- tab[398]=20;
- tab[399]=0;
- tab[400]=20;
- tab[401]=0;
- tab[402]=8;
- tab[403]=0;
- tab[404]=8;
- tab[405]=0;
- tab[406]=19;
- tab[407]=87;
- tab[408]=-95;
- tab[409]=44;
- tab[410]=-99;
- tab[411]=105;
- tab[412]=77;
- tab[413]=-38;
- tab[414]=-36;
- tab[415]=0;
- tab[416]=0;
- tab[417]=0;
- tab[418]=53;
- tab[419]=1;
- tab[420]=0;
- tab[421]=0;
- tab[422]=16;
- tab[423]=0;
- tab[424]=0;
- tab[425]=0;
- tab[426]=0;
- tab[427]=0;
- tab[428]=0;
- tab[429]=0;
- tab[430]=0;
- tab[431]=0;
- tab[432]=0;
- tab[433]=0;
- tab[434]=0;
- tab[435]=0;
- tab[436]=57;
- tab[437]=0;
- tab[438]=0;
- tab[439]=0;
- tab[440]=112;
- tab[441]=49;
- tab[442]=47;
- tab[443]=112;
- tab[444]=50;
- tab[445]=47;
- tab[446]=112;
- tab[447]=51;
- tab[448]=47;
- tab[449]=88;
- tab[450]=46;
- tab[451]=99;
- tab[452]=108;
- tab[453]=97;
- tab[454]=115;
- tab[455]=115;
- tab[456]=80;
- tab[457]=75;
- tab[458]=5;
- tab[459]=6;
- tab[460]=0;
- tab[461]=0;
- tab[462]=0;
- tab[463]=0;
- tab[464]=2;
- tab[465]=0;
- tab[466]=2;
- tab[467]=0;
- tab[468]=117;
- tab[469]=0;
- tab[470]=0;
- tab[471]=0;
- tab[472]=83;
- tab[473]=1;
- tab[474]=0;
- tab[475]=0;
- tab[476]=0;
- tab[477]=0;
- IJavaProject javaProject = createJavaProject("P1", new String[] {"src"}, "bin");
- IFile jarFile = createFile("P1/lib.jar", tab);
- javaProject.setRawClasspath(new IClasspathEntry[] {JavaCore.newLibraryEntry(jarFile.getFullPath(), null, null, false)}, new NullProgressMonitor());
- assertNotNull(javaProject.findType("p1.p2.p3.X"));
- } catch(JavaModelException e) {
- e.printStackTrace();
- assertTrue(false);
- } catch (CoreException e) {
- e.printStackTrace();
- assertTrue(false);
- } finally {
- deleteProject("P1");
- }
- }
-
- public static Test suite() {
- TestSuite suite = new Suite(ClassNameTests.class.getName());
- suite.addTest(new ClassNameTests("testClassNameWithDollar"));
- suite.addTest(new ClassNameTests("testFindTypeWithDot"));
- suite.addTest(new ClassNameTests("testSearchTypeNameInJars"));
- return suite;
- }
-
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java
deleted file mode 100644
index e729e38..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java
+++ /dev/null
@@ -1,1533 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.internal.core.JavaProject;
-
-import java.io.IOException;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class ClasspathTests extends ModifyingResourceTests {
-
- public class TestContainer implements IClasspathContainer {
- IPath path;
- IClasspathEntry[] entries;
- TestContainer(IPath path, IClasspathEntry[] entries){
- this.path = path;
- this.entries = entries;
- }
- public IPath getPath() { return this.path; }
- public IClasspathEntry[] getClasspathEntries() { return this.entries; }
- public String getDescription() { return null; }
- public int getKind() { return 0; }
- };
-
-public ClasspathTests(String name) {
- super(name);
-}
-protected void assertCycleMarkers(IJavaProject project, IJavaProject[] p, int[] expectedCycleParticipants) throws CoreException {
- StringBuffer expected = new StringBuffer("{");
- int expectedCount = 0;
- StringBuffer computed = new StringBuffer("{");
- int computedCount = 0;
- for (int j = 0; j < p.length; j++){
- int markerCount = this.numberOfCycleMarkers(p[j]);
- if (markerCount > 0){
- if (computedCount++ > 0) computed.append(", ");
- computed.append(p[j].getElementName());
- //computed.append(" (" + markerCount + ")");
- }
- markerCount = expectedCycleParticipants[j];
- if (markerCount > 0){
- if (expectedCount++ > 0) expected.append(", ");
- expected.append(p[j].getElementName());
- //expected.append(" (" + markerCount + ")");
- }
- }
- expected.append("}");
- computed.append("}");
- assertEquals("Invalid cycle detection after setting classpath for: "+project.getElementName(), expected.toString(), computed.toString());
-}
-protected void assertMarkers(String message, String expectedMarkers, IJavaProject project) throws CoreException {
- IMarker[] markers = project.getProject().findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ONE);
- StringBuffer buffer = new StringBuffer();
- for (int i = 0, length = markers.length; i < length; i++) {
- IMarker marker = markers[i];
- buffer.append(marker.getAttribute(IMarker.MESSAGE));
- if (i != length-1) {
- buffer.append("\n");
- }
- }
- assertEquals(message, expectedMarkers, buffer.toString());
-}
-protected int numberOfCycleMarkers(IJavaProject javaProject) throws CoreException {
- IMarker[] markers = javaProject.getProject().findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ONE);
- int result = 0;
- for (int i = 0, length = markers.length; i < length; i++) {
- IMarker marker = markers[i];
- String cycleAttr = (String)marker.getAttribute(IJavaModelMarker.CYCLE_DETECTED);
- if (cycleAttr != null && cycleAttr.equals("true")){ //$NON-NLS-1$
- result++;
- }
- }
- return result;
-}
-
-public static Test suite() {
-
- if (false){
- TestSuite suite = new Suite(ClasspathTests.class.getName());
- suite.addTest(new ClasspathTests("testDenseCycleDetection"));
- return suite;
- }
- return new Suite(ClasspathTests.class);
-}
-/**
- * Add an entry to the classpath for a non-existent root. Then create
- * the root and ensure that it comes alive.
- */
-public void testClasspathAddRoot() throws JavaModelException, CoreException, IOException {
- IJavaProject project = this.createJavaProject("P", new String[] {"src"}, "bin");
- IClasspathEntry[] originalCP= project.getRawClasspath();
-
- try {
- IClasspathEntry newEntry= JavaCore.newSourceEntry(project.getProject().getFullPath().append("extra"));
-
- IClasspathEntry[] newCP= new IClasspathEntry[originalCP.length + 1];
- System.arraycopy(originalCP, 0 , newCP, 0, originalCP.length);
- newCP[originalCP.length]= newEntry;
-
- project.setRawClasspath(newCP, null);
-
-
- // now create the actual resource for the root and populate it
- project.getProject().getFolder("extra").create(false, true, null);
-
- IPackageFragmentRoot newRoot= getPackageFragmentRoot("P", "extra");
- assertTrue("New root should now be visible", newRoot != null);
- } finally {
- // cleanup
- this.deleteProject("P");
- }
-}
-/**
- * Ensures that the reordering external resources in the classpath
- * generates the correct deltas.
- */
-public void testClasspathChangeExternalResources() throws CoreException {
- try {
- IJavaProject proj = this.createJavaProject("P", new String[] {"src"}, "bin");
- IClasspathEntry[] originalCP = proj.getRawClasspath();
- IPackageFragmentRoot root = getPackageFragmentRoot("P", "src");
-
- IClasspathEntry[] newEntries = new IClasspathEntry[2];
- newEntries[0] = JavaCore.newLibraryEntry(new Path(getExternalJCLPath()), null, null, false);
- newEntries[1] = JavaCore.newLibraryEntry(new Path(getExternalJCLSourcePath()), null, null, false);
- setClasspath(proj, newEntries);
- startDeltas();
- IClasspathEntry[] swappedEntries = new IClasspathEntry[2];
- swappedEntries[0] = newEntries[1];
- swappedEntries[1] = newEntries[0];
- setClasspath(proj, swappedEntries);
- assertTrue("should be one delta - two jars reordered", this.deltaListener.deltas.length == 1);
- IJavaElementDelta d = getDeltaFor(proj);
- assertTrue("should be a delta for the project", d != null);
- } finally {
- stopDeltas();
- this.deleteProject("P");
- }
-}
-
-/**
- * Ensures that the setting the classpath with a library entry
- * changes the kind of the root from K_SOURCE to K_BINARY.
- */
-public void testClasspathCreateLibraryEntry() throws CoreException {
- try {
- IJavaProject proj = this.createJavaProject("P", new String[] {"src"}, "bin");
- this.createFile("P/src/X.java", "public class X {}");
- this.createFile("P/src/X.class", "");
-
- IFolder rootFolder = proj.getProject().getFolder(new Path("src"));
- IPackageFragmentRoot root = proj.getPackageFragmentRoot(rootFolder);
-
- assertEquals(
- "Unexpected root kind 1",
- IPackageFragmentRoot.K_SOURCE,
- root.getKind());
- IPackageFragment pkg = root.getPackageFragment("");
- assertEquals(
- "Unexpected numbers of compilation units",
- 1,
- pkg.getCompilationUnits().length);
- assertEquals(
- "Unexpected numbers of .class files",
- 0,
- pkg.getClassFiles().length);
-
- this.setClasspath(
- proj,
- new IClasspathEntry[] {
- JavaCore.newLibraryEntry(rootFolder.getFullPath(), null, null, false)
- });
- assertEquals(
- "Unexpected root kind 2",
- IPackageFragmentRoot.K_BINARY,
- root.getKind());
- assertEquals(
- "Unexpected numbers of compilation units",
- 0,
- pkg.getCompilationUnits().length);
- assertEquals(
- "Unexpected numbers of .class files",
- 1,
- pkg.getClassFiles().length);
-
- //ensure that the new kind has been persisted in the classpath file
- proj.close();
- assertEquals(
- "Unexpected root kind 3",
- IPackageFragmentRoot.K_BINARY,
- root.getKind());
-
- } finally {
- this.deleteProject("P");
- }
-}
-/**
- * Ensures that the setting the classpath with a new library entry for a
- * local jar works and generates the correct deltas.
- */
-public void testClasspathCreateLocalJarLibraryEntry() throws CoreException {
- IJavaProject proj = this.createJavaProject("P", new String[] {""}, "");
- IPackageFragmentRoot root = getPackageFragmentRoot("P", "");
- IClasspathEntry[] originalCP= proj.getRawClasspath();
- IClasspathEntry newEntry= JavaCore.newLibraryEntry(new Path(getExternalJCLPath()), null, null, false);
- IClasspathEntry[] newEntries= new IClasspathEntry[]{newEntry};
- IPackageFragmentRoot newRoot= proj.getPackageFragmentRoot(getExternalJCLPath());
-
- startDeltas();
-
- setClasspath(proj,newEntries);
-
- try {
- assertTrue(
- "should be one delta with 2 grand-children - removed & added",
- this.deltaListener.deltas.length == 1 &&
- this.deltaListener.deltas[0].getAffectedChildren().length == 1 &&
- this.deltaListener.deltas[0].getAffectedChildren()[0].getAffectedChildren().length == 2);
- IJavaElementDelta d= null;
- assertTrue("root should be removed from classpath",(d= getDeltaFor(root, true)) != null &&
- (d.getFlags() & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) > 0);
-
-
- assertTrue("root should be added to classpath", (d= getDeltaFor(newRoot, true)) != null &&
- (d.getFlags() & IJavaElementDelta.F_ADDED_TO_CLASSPATH) > 0);
- } finally {
- stopDeltas();
-
- this.deleteProject("P");
- }
-}
-
-/**
- * Tests the cross project classpath setting
- */
-public void testClasspathCrossProject() throws JavaModelException, CoreException {
- IJavaProject project = this.createJavaProject("P1", new String[] {""}, "");
- this.createJavaProject("P2", new String[] {}, "");
- IClasspathEntry[] oldClasspath= project.getRawClasspath();
- try {
- startDeltas();
- IPackageFragmentRoot oldRoot= getPackageFragmentRoot("P1", "");
- IClasspathEntry projectEntry= JavaCore.newProjectEntry(new Path("/P2"), false);
- IClasspathEntry[] newClasspath= new IClasspathEntry[]{projectEntry};
- project.setRawClasspath(newClasspath, null);
- project.getAllPackageFragmentRoots();
- IJavaElementDelta removedDelta= getDeltaFor(oldRoot, true);
- assertTrue("Deltas not correct for crossproject classpath setting",
- this.deltaListener.deltas.length == 1 &&
- this.deltaListener.deltas[0].getAffectedChildren().length == 1 &&
- removedDelta.getElement().equals(oldRoot) &&
- removedDelta.getKind() == IJavaElementDelta.CHANGED &&
- (removedDelta.getFlags() & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) > 0
- );
- } finally {
- stopDeltas();
- this.deleteProject("P1");
- this.deleteProject("P2");
- }
-}
-/**
- * Delete a root and ensure the classpath is not updated (i.e. entry isn't removed).
- */
-public void testClasspathDeleteNestedRoot() throws JavaModelException, CoreException, IOException {
- IJavaProject project = this.createJavaProject("P", new String[] {"nested/src"}, new String[] {getExternalJCLPath()}, "bin");
- IPackageFragmentRoot root= getPackageFragmentRoot("P", "nested/src");
- IClasspathEntry[] originalCP= project.getRawClasspath();
-
- // delete the root
- IFolder folder= (IFolder)root.getUnderlyingResource();
- root.getUnderlyingResource().delete(false, null);
-
- IClasspathEntry[] newCP= project.getRawClasspath();
-
- try {
- // should still be an entry for the "src" folder
- assertTrue("classpath should not have been updated",
- newCP.length == 2 &&
- newCP[0].equals(originalCP[0]) &&
- newCP[1].equals(originalCP[1]));
- } finally {
- this.deleteProject("P");
- }
-}
-/**
- * Delete a nested root's parent folder and ensure the classpath is
- * not updated (i.e. entry isn't removed).
- */
-public void testClasspathDeleteNestedRootParent() throws JavaModelException, CoreException, IOException {
- IJavaProject project = this.createJavaProject("P", new String[] {"nested/src"}, new String[] {getExternalJCLPath()}, "bin");
- IPackageFragmentRoot root= getPackageFragmentRoot("P", "nested/src");
- IClasspathEntry[] originalCP= project.getRawClasspath();
-
- // delete the root's parent folder
- IFolder folder= (IFolder)root.getUnderlyingResource().getParent();
- folder.delete(false, null);
-
- IClasspathEntry[] newCP= project.getRawClasspath();
-
- try {
-
- // should still be an entry for the "src" folder
- assertTrue("classpath should not have been updated",
- newCP.length == 2 &&
- newCP[0].equals(originalCP[0]) &&
- newCP[1].equals(originalCP[1]));
- } finally {
- this.deleteProject("P");
- }
-}
-/**
- * Test that a classpath entry for an external jar is externalized
- * properly.
- */
-public void testClasspathExternalize() throws CoreException {
- try {
- IJavaProject project= this.createJavaProject("P", new String[] {}, new String[] {getExternalJCLPath()}, "");
- IClasspathEntry[] classpath= project.getRawClasspath();
- IClasspathEntry jar= null;
- for (int i= 0; i < classpath.length; i++) {
- if (classpath[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
- jar= classpath[i];
- break;
- }
- }
- project.close();
- project.open(null);
-
- classpath= project.getRawClasspath();
- for (int i= 0; i < classpath.length; i++) {
- if (classpath[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
- assertTrue("Paths must be the same", classpath[i].getPath().equals(jar.getPath()));
- break;
- }
- }
- } finally {
- this.deleteProject("P");
- }
-}
-/**
- * Move a root and ensure the classpath is not updated (i.e. entry not renamed).
- */
-public void testClasspathMoveNestedRoot() throws JavaModelException, CoreException, IOException {
- IJavaProject project = this.createJavaProject("P", new String[] {"nested/src"}, new String[] {getExternalJCLPath()}, "bin");
- IPackageFragmentRoot root= getPackageFragmentRoot("P", "nested/src");
- IClasspathEntry[] originalCP= project.getRawClasspath();
-
- // delete the root
- IFolder folder= (IFolder)root.getUnderlyingResource();
- IPath originalPath= folder.getFullPath();
- IPath newPath= originalPath.removeLastSegments(1);
- newPath= newPath.append(new Path("newsrc"));
-
- startDeltas();
-
- folder.move(newPath, true, null);
-
- IClasspathEntry[] newCP= project.getRawClasspath();
-
- IPackageFragmentRoot newRoot= project.getPackageFragmentRoot(project.getProject().getFolder("nested").getFolder("newsrc"));
-
- try {
- // entry for the "src" folder wasn't replaced
- assertTrue("classpath not automatically updated", newCP.length == 2 &&
- newCP[1].equals(originalCP[1]) &&
- newCP[0].equals(originalCP[0]));
-
- IJavaElementDelta rootDelta = getDeltaFor(root, true);
- IJavaElementDelta projectDelta = getDeltaFor(newRoot.getParent(), true);
- assertTrue("should get delta for moved root", rootDelta != null &&
- rootDelta.getKind() == IJavaElementDelta.REMOVED &&
- rootDelta.getFlags() == 0);
- assertTrue("should get delta indicating content changed for project", this.deltaContentChanged(projectDelta));
-
- } finally {
- stopDeltas();
- this.deleteProject("P");
- }
-}
-/**
- * Move a parent of a nested root and ensure the classpath is not updated (i.e. entry not renamed).
- */
-public void testClasspathMoveNestedRootParent() throws JavaModelException, CoreException, IOException {
- try {
- IJavaProject project =this.createJavaProject("P", new String[] {"nested/src"}, new String[] {getExternalJCLPath()}, "bin");
- IPackageFragmentRoot root= getPackageFragmentRoot("P", "nested/src");
- IClasspathEntry[] originalCP= project.getRawClasspath();
-
- // delete the root
- IFolder folder= (IFolder)root.getUnderlyingResource().getParent();
- IPath originalPath= folder.getFullPath();
- IPath newPath= originalPath.removeLastSegments(1);
- newPath= newPath.append(new Path("newsrc"));
- folder.move(newPath, true, null);
-
- IClasspathEntry[] newCP= project.getRawClasspath();
-
- // entry for the "src" folder wasn't replaced
- // entry for the "src" folder should not be replaced
- assertTrue("classpath should not automatically be updated", newCP.length == 2 &&
- newCP[1].equals(originalCP[1]) &&
- newCP[0].equals(originalCP[0]));
-
- } finally {
- this.deleteProject("P");
- }
-}
-/**
- * Tests that nothing occurs when setting to the same classpath
- */
-public void testClasspathNoChanges() throws JavaModelException, CoreException {
- try {
- IJavaProject classFileProject= this.createJavaProject("P", new String[] {""}, "");
- IClasspathEntry[] oldClasspath= classFileProject.getRawClasspath();
- startDeltas();
- classFileProject.setRawClasspath(oldClasspath, null);
- assertTrue("No deltas should be generated for the same classpath",
- this.deltaListener.deltas.length == 0);
- } finally {
- stopDeltas();
- this.deleteProject("P");
- }
-}
-/**
- * Ensures that the setting the classpath with a reordered classpath generates
- * the correct deltas.
- */
-public void testClasspathReordering() throws CoreException {
- IJavaProject proj = this.createJavaProject("P", new String[] {"src"}, new String[] {getExternalJCLPath()}, "bin");
- IClasspathEntry[] originalCP = proj.getRawClasspath();
- IPackageFragmentRoot root = getPackageFragmentRoot("P", "src");
- try {
- IClasspathEntry[] newEntries = new IClasspathEntry[originalCP.length];
- int index = originalCP.length - 1;
- for (int i = 0; i < originalCP.length; i++) {
- newEntries[index] = originalCP[i];
- index--;
- }
- startDeltas();
- setClasspath(proj, newEntries);
- assertTrue("should be one delta - two roots reordered", this.deltaListener.deltas.length == 1);
- IJavaElementDelta d = null;
- assertTrue("root should be reordered in the classpath", (d = getDeltaFor(root, true)) != null
- && (d.getFlags() & IJavaElementDelta.F_CLASSPATH_REORDER) > 0);
- } finally {
- stopDeltas();
- this.deleteProject("P");
- }
-}
-
-/**
- * Should detect duplicate entries on the classpath
- */
-public void testClasspathValidation1() throws CoreException {
- try {
- IJavaProject proj = this.createJavaProject("P", new String[] {"src"}, "bin");
- IClasspathEntry[] originalCP = proj.getRawClasspath();
-
- IClasspathEntry[] newCP = new IClasspathEntry[originalCP.length+1];
- System.arraycopy(originalCP, 0, newCP, 0, originalCP.length);
- newCP[originalCP.length] = newCP[0];
-
- IJavaModelStatus status = JavaConventions.validateClasspath(proj, newCP, proj.getOutputLocation());
-
- assertTrue("should have detected duplicate entries on the classpath", !status.isOK());
- } finally {
- this.deleteProject("P");
- }
-}
-
-/**
- * Should detect nested source folders on the classpath
- */
-public void testClasspathValidation2() throws CoreException {
- try {
- IJavaProject proj = this.createJavaProject("P", new String[] {"src"}, "bin");
- IClasspathEntry[] originalCP = proj.getRawClasspath();
-
- IClasspathEntry[] newCP = new IClasspathEntry[originalCP.length+1];
- System.arraycopy(originalCP, 0, newCP, 0, originalCP.length);
- newCP[originalCP.length] = JavaCore.newSourceEntry(new Path("/P"));
-
- IJavaModelStatus status = JavaConventions.validateClasspath(proj, newCP, proj.getOutputLocation());
-
- assertTrue("should have detected nested source folders on the classpath", !status.isOK());
- } finally {
- this.deleteProject("P");
- }
-}
-
-/**
- * Should detect library folder nested inside source folder on the classpath
- */
-public void testClasspathValidation3() throws CoreException {
- try {
- IJavaProject proj = this.createJavaProject("P", new String[] {"src"}, "bin");
- IClasspathEntry[] originalCP = proj.getRawClasspath();
-
- IClasspathEntry[] newCP = new IClasspathEntry[originalCP.length+1];
- System.arraycopy(originalCP, 0, newCP, 0, originalCP.length);
- newCP[originalCP.length] = JavaCore.newLibraryEntry(new Path("/P/src/lib"), null, null);
-
- IJavaModelStatus status = JavaConventions.validateClasspath(proj, newCP, proj.getOutputLocation());
-
- assertTrue("should have detected library folder nested inside source folder on the classpath", !status.isOK());
- } finally {
- this.deleteProject("P");
- }
-}
-
-public void testClasspathValidation4() throws CoreException {
-
- IJavaProject[] p = null;
- try {
-
- p = new IJavaProject[]{
- this.createJavaProject("P0", new String[] {"src0"}, "bin0"),
- this.createJavaProject("P1", new String[] {"src1"}, "bin1"),
- };
-
- JavaCore.setClasspathVariable("var", new Path("/P1"), null);
-
- IClasspathEntry[] newClasspath = new IClasspathEntry[]{
- JavaCore.newSourceEntry(new Path("/P0/src0")),
- JavaCore.newVariableEntry(new Path("var/src1"), null, null),
- };
-
- // validate classpath
- IJavaModelStatus status = JavaConventions.validateClasspath(p[0], newClasspath, p[0].getOutputLocation());
- assertTrue("should not detect external source folder through a variable on the classpath", status.isOK());
-
- } finally {
- if (p != null){
- for (int i = 0; i < p.length; i++){
- this.deleteProject(p[i].getElementName());
- }
- }
- }
-}
-
-public void testClasspathValidation5() throws CoreException {
-
- IJavaProject[] p = null;
- try {
-
- p = new IJavaProject[]{
- this.createJavaProject("P0", new String[] {"src0", "src1"}, "bin0"),
- this.createJavaProject("P1", new String[] {"src1"}, "bin1"),
- };
-
- JavaCore.setClasspathContainer(
- new Path("container/default"),
- new IJavaProject[]{ p[0] },
- new IClasspathContainer[] {
- new TestContainer(new Path("container/default"),
- new IClasspathEntry[]{
- JavaCore.newSourceEntry(new Path("/P0/src0")),
- JavaCore.newVariableEntry(new Path("var/src1"), null, null) })
- },
- null);
-
- IClasspathEntry[] newClasspath = new IClasspathEntry[]{
- JavaCore.newSourceEntry(new Path("/P0/src1")),
- JavaCore.newContainerEntry(new Path("container/default")),
- };
-
- // validate classpath
- IJavaModelStatus status = JavaConventions.validateClasspath(p[0], newClasspath, p[0].getOutputLocation());
- assertTrue("should not have detected external source folder through a container on the classpath", status.isOK());
-
- // validate classpath entry
- status = JavaConventions.validateClasspathEntry(p[0], newClasspath[1], true);
- assertTrue("should have detected external source folder through a container on the classpath", !status.isOK());
-
- } finally {
- if (p != null){
- for (int i = 0; i < p.length; i++){
- this.deleteProject(p[i].getElementName());
- }
- }
- }
-}
-
-public void testClasspathValidation6() throws CoreException {
-
- IJavaProject[] p = null;
- try {
-
- p = new IJavaProject[]{
- this.createJavaProject("P0", new String[] {"src"}, "src"),
- };
-
- // validate classpath entry
- IClasspathEntry[] newClasspath = new IClasspathEntry[]{
- JavaCore.newSourceEntry(new Path("/P0")),
- JavaCore.newSourceEntry(new Path("/P0/src")),
- };
-
- IJavaModelStatus status = JavaConventions.validateClasspath(p[0], newClasspath, p[0].getOutputLocation());
- assertTrue("should have detected nested source folder", !status.isOK());
- } finally {
- if (p != null){
- for (int i = 0; i < p.length; i++){
- this.deleteProject(p[i].getElementName());
- }
- }
- }
-}
-/**
- * Setting the classpath with two entries specifying the same path
- * should fail.
- */
-public void testClasspathWithDuplicateEntries() throws CoreException {
- try {
- IJavaProject project = this.createJavaProject("P", new String[] {"src"}, "bin");
- IClasspathEntry[] cp= project.getRawClasspath();
- IClasspathEntry[] newCp= new IClasspathEntry[cp.length *2];
- System.arraycopy(cp, 0, newCp, 0, cp.length);
- System.arraycopy(cp, 0, newCp, cp.length, cp.length);
- try {
- project.setRawClasspath(newCp, null);
- } catch (JavaModelException jme) {
- return;
- }
- assertTrue("Setting the classpath with two entries specifying the same path should fail", false);
- } finally {
- this.deleteProject("P");
- }
-}
-/**
- * Adding an entry to the classpath for a library that does not exist
- * should not break the model. The classpath should contain the
- * entry, but the root should not appear in the children.
- */
-public void testClasspathWithNonExistentLibraryEntry() throws CoreException {
- try {
- IJavaProject project= this.createJavaProject("P", new String[] {"src"}, "bin");
- IClasspathEntry[] originalPath= project.getRawClasspath();
- IPackageFragmentRoot[] originalRoots= project.getPackageFragmentRoots();
-
- IClasspathEntry[] newPath= new IClasspathEntry[originalPath.length + 1];
- System.arraycopy(originalPath, 0, newPath, 0, originalPath.length);
-
- IClasspathEntry newEntry= JavaCore.newLibraryEntry(new Path("c:/nothing/nozip.jar"), null, null, false);
- newPath[originalPath.length]= newEntry;
-
- project.setRawClasspath(newPath, null);
-
- IClasspathEntry[] getPath= project.getRawClasspath();
- assertTrue("should be the same length", getPath.length == newPath.length);
- for (int i= 0; i < getPath.length; i++) {
- assertTrue("entries should be the same", getPath[i].equals(newPath[i]));
- }
-
- IPackageFragmentRoot[] newRoots= project.getPackageFragmentRoots();
- assertTrue("Should be the same number of roots", originalRoots.length == newRoots.length);
- for (int i= 0; i < newRoots.length; i++) {
- assertTrue("roots should be the same", originalRoots[i].equals(newRoots[i]));
- }
- } finally {
- this.deleteProject("P");
- }
-}
-/**
- * Adding an entry to the classpath for a project that does not exist
- * should not break the model. The classpath should contain the
- * entry, but the root should not appear in the children.
- */
-public void testClasspathWithNonExistentProjectEntry() throws CoreException {
- try {
- IJavaProject project= this.createJavaProject("P", new String[] {"src"}, "bin");
- IClasspathEntry[] originalPath= project.getRawClasspath();
- IPackageFragmentRoot[] originalRoots= project.getPackageFragmentRoots();
-
- IClasspathEntry[] newPath= new IClasspathEntry[originalPath.length + 1];
- System.arraycopy(originalPath, 0, newPath, 0, originalPath.length);
-
- IClasspathEntry newEntry= JavaCore.newProjectEntry(new Path("/NoProject"), false);
- newPath[originalPath.length]= newEntry;
-
- project.setRawClasspath(newPath, null);
-
- IClasspathEntry[] getPath= project.getRawClasspath();
- assertTrue("should be the same length", getPath.length == newPath.length);
- for (int i= 0; i < getPath.length; i++) {
- assertTrue("entries should be the same", getPath[i].equals(newPath[i]));
- }
-
- IPackageFragmentRoot[] newRoots= project.getPackageFragmentRoots();
- assertTrue("Should be the same number of roots", originalRoots.length == newRoots.length);
- for (int i= 0; i < newRoots.length; i++) {
- assertTrue("roots should be the same", originalRoots[i].equals(newRoots[i]));
- }
- } finally {
- this.deleteProject("P");
- }
-}
-/**
- * Adding an entry to the classpath for a folder that does not exist
- * should not break the model. The classpath should contain the
- * entry, but the root should not appear in the children.
- */
-public void testClasspathWithNonExistentSourceEntry() throws CoreException {
- try {
- IJavaProject project= this.createJavaProject("P", new String[] {"src"}, "bin");
- IClasspathEntry[] originalPath= project.getRawClasspath();
- IPackageFragmentRoot[] originalRoots= project.getPackageFragmentRoots();
-
- IClasspathEntry[] newPath= new IClasspathEntry[originalPath.length + 1];
- System.arraycopy(originalPath, 0, newPath, 0, originalPath.length);
-
- IClasspathEntry newEntry= JavaCore.newSourceEntry(new Path("/P/moreSource"));
- newPath[originalPath.length]= newEntry;
-
- project.setRawClasspath(newPath, null);
-
- IClasspathEntry[] getPath= project.getRawClasspath();
- assertTrue("should be the same length", getPath.length == newPath.length);
- for (int i= 0; i < getPath.length; i++) {
- assertTrue("entries should be the same", getPath[i].equals(newPath[i]));
- }
-
- IPackageFragmentRoot[] newRoots= project.getPackageFragmentRoots();
- assertTrue("Should be the same number of roots", originalRoots.length == newRoots.length);
- for (int i= 0; i < newRoots.length; i++) {
- assertTrue("roots should be the same", originalRoots[i].equals(newRoots[i]));
- }
- } finally {
- this.deleteProject("P");
- }
-}
-/**
- * Ensure that cycle are properly reported.
- */
-public void testCycleReport() throws JavaModelException, CoreException, IOException {
-
- try {
- IJavaProject p1 = this.createJavaProject("P1", new String[] {""}, "");
- IJavaProject p2 = this.createJavaProject("P2", new String[] {""}, "");
- IJavaProject p3 = this.createJavaProject("P3", new String[] {""}, new String[] {}, new String[] {"/P2"}, "");
-
- // Ensure no cycle reported
- IJavaProject[] projects = { p1, p2, p3 };
- int cycleMarkerCount = 0;
- for (int i = 0; i < projects.length; i++){
- cycleMarkerCount += this.numberOfCycleMarkers(projects[i]);
- }
- assertTrue("Should have no cycle markers", cycleMarkerCount == 0);
-
- // Add cycle
- IClasspathEntry[] originalP1CP= p1.getRawClasspath();
- IClasspathEntry[] originalP2CP= p2.getRawClasspath();
-
- // Add P1 as a prerequesite of P2
- int length = originalP2CP.length;
- IClasspathEntry[] newCP= new IClasspathEntry[length + 1];
- System.arraycopy(originalP2CP, 0 , newCP, 0, length);
- newCP[length]= JavaCore.newProjectEntry(p1.getProject().getFullPath(), false);
- p2.setRawClasspath(newCP, null);
-
- // Add P3 as a prerequesite of P1
- length = originalP1CP.length;
- newCP= new IClasspathEntry[length + 1];
- System.arraycopy(originalP1CP, 0 , newCP, 0, length);
- newCP[length]= JavaCore.newProjectEntry(p3.getProject().getFullPath(), false);
- p1.setRawClasspath(newCP, null);
-
- // Ensure a cycle is reported on one of the projects
- // Ensure no cycle reported
- cycleMarkerCount = 0;
- for (int i = 0; i < projects.length; i++){
- cycleMarkerCount += this.numberOfCycleMarkers(projects[i]);
- }
- assertTrue("Should have 3 projects involved in a classpath cycle", cycleMarkerCount == 3);
-
- } finally {
- // cleanup
- this.deleteProject("P1");
- this.deleteProject("P2");
- this.deleteProject("P3");
- }
-}
-/**
- * Ensures that the default classpath and output locations are correct.
- * The default classpath should be the root of the project.
- * The default output location should be the root of the project.
- */
-public void testDefaultClasspathAndOutputLocation() throws CoreException {
- try {
- IJavaProject project = this.createJavaProject("P", new String[] {""}, "bin");
- IClasspathEntry[] classpath = project.getRawClasspath();
- assertTrue("Incorrect default classpath; to many entries", classpath.length == 1);
- assertTrue("Incorrect default classpath: " + classpath[0], classpath[0].getPath().equals(project.getUnderlyingResource().getFullPath()));
- IPath output = project.getOutputLocation();
- assertTrue("Incorrect default output location: " + output.toOSString(), output.equals(project.getUnderlyingResource().getFullPath().append("bin")));
- } finally {
- this.deleteProject("P");
- }
-}
-/**
- * Setting the classpath to empty should result in no entries,
- * and a delta with removed roots.
- */
-public void testEmptyClasspath() throws CoreException {
- IJavaProject project = this.createJavaProject("P", new String[] {""}, "");
- try {
- IPackageFragmentRoot[] oldRoots= project.getAllPackageFragmentRoots();
-
- startDeltas();
- setClasspath(project, new IClasspathEntry[] {});
- IClasspathEntry[] cp= project.getRawClasspath();
- assertTrue("classpath should have no entries", cp.length == 0);
-
- // ensure the deltas are correct
- assertTrue("there should be a delta", this.deltaListener.deltas != null && this.deltaListener.deltas.length == 1);
- for (int i= 0; i < oldRoots.length; i++) {
- IJavaElementDelta d= null;
- assertTrue("root should be removed", (d= getDeltaFor(oldRoots[i])) != null &&
- (d.getFlags() & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) > 0);
- }
- } finally {
- stopDeltas();
- this.deleteProject("P");
- }
-}
-/**
- * Exporting a container should make it visible to its dependent project.
- * (regression test for bug 21749 Exported libraries and source folders)
- */
-public void testExportContainer() throws CoreException {
- try {
- IJavaProject p1 = this.createJavaProject("P1", new String[] {""}, "");
-
- // create container
- JavaCore.setClasspathContainer(
- new Path("container/default"),
- new IJavaProject[]{ p1 },
- new IClasspathContainer[] {
- new TestContainer(
- new Path("container/default"),
- new IClasspathEntry[] {
- JavaCore.newLibraryEntry(new Path(getExternalJCLPath()), null, null)
- })
- },
- null);
-
- // set P1's classpath with this container
- IClasspathEntry container = JavaCore.newContainerEntry(new Path("container/default"), true);
- p1.setRawClasspath(new IClasspathEntry[] {container}, new Path("/P1"), null);
-
- // create dependent project P2
- IJavaProject p2 = this.createJavaProject("P2", new String[] {}, new String[] {}, new String[] {"/P1"}, "");
- IClasspathEntry[] classpath = ((JavaProject)p2).getExpandedClasspath(true);
-
- // ensure container is exported to P2
- assertEquals("Unexpected number of classpath entries", 2, classpath.length);
- assertEquals("Unexpected first entry", "/P1", classpath[0].getPath().toString());
- assertEquals("Unexpected second entry", getExternalJCLPath(), classpath[1].getPath().toOSString());
- } finally {
- this.deleteProject("P1");
- this.deleteProject("P2");
- }
-}
-/**
- * Test IJavaProject.hasClasspathCycle(IClasspathEntry[]).
- */
-public void testHasClasspathCycle() throws JavaModelException, CoreException, IOException {
- try {
- IJavaProject p1 = this.createJavaProject("P1", new String[] {""}, "");
- IJavaProject p2 = this.createJavaProject("P2", new String[] {""}, "");
- IJavaProject p3 = this.createJavaProject("P3", new String[] {""}, new String[] {}, new String[] {"/P1"}, "");
-
- IClasspathEntry[] originalP1CP= p1.getRawClasspath();
- IClasspathEntry[] originalP2CP= p2.getRawClasspath();
-
- // Ensure no cycle reported
- assertTrue("P1 should not have a cycle", !p1.hasClasspathCycle(originalP1CP));
-
- // Ensure that adding NervousTest as a prerequesite of P2 doesn't report a cycle
- int length = originalP2CP.length;
- IClasspathEntry[] newCP= new IClasspathEntry[length + 1];
- System.arraycopy(originalP2CP, 0 , newCP, 0, length);
- newCP[length]= JavaCore.newProjectEntry(p1.getProject().getFullPath(), false);
- assertTrue("P2 should not have a cycle", !p2.hasClasspathCycle(newCP));
- p2.setRawClasspath(newCP, null);
-
- // Ensure that adding P3 as a prerequesite of P1 reports a cycle
- length = originalP1CP.length;
- newCP= new IClasspathEntry[length + 1];
- System.arraycopy(originalP1CP, 0 , newCP, 0, length);
- newCP[length]= JavaCore.newProjectEntry(p2.getProject().getFullPath(), false);
- assertTrue("P3 should have a cycle", p2.hasClasspathCycle(newCP));
-
- // Ensure a cycle is not reported through markers
- IWorkspace workspace = getJavaModel().getWorkspace();
- IMarker[] markers = workspace.getRoot().findMarkers(IJavaModelMarker.TRANSIENT_PROBLEM, true, 1);
- boolean hasCycleMarker = false;
- for (int i = 0; i < markers.length; i++){
- if (markers[i].getAttribute(IJavaModelMarker.CYCLE_DETECTED) != null) {
- hasCycleMarker = true;
- break;
- }
- }
- assertTrue("Should have no cycle markers", !hasCycleMarker);
-
- } finally {
- // cleanup
- this.deleteProject("P1");
- this.deleteProject("P2");
- this.deleteProject("P3");
- }
-}
-/**
- * Test that a marker is added when a project as a missing project in its classpath.
- */
-public void testMissingPrereq1() throws CoreException {
- try {
- IJavaProject javaProject = this.createJavaProject("A", new String[] {}, "");
- IClasspathEntry[] classpath =
- new IClasspathEntry[] {
- JavaCore.newProjectEntry(new Path("/B"))
- };
- javaProject.setRawClasspath(classpath, null);
- this.assertMarkers(
- "Unexpected markers",
- "Missing required Java project: B.",
- javaProject);
- } finally {
- this.deleteProject("A");
- }
-}
-/**
- * Test that a marker is added when a project as a missing project in its classpath.
- */
-public void testMissingPrereq2() throws CoreException {
- try {
- IJavaProject javaProject =
- this.createJavaProject(
- "A",
- new String[] {}, // source folders
- new String[] {}, // lib folders
- new String[] {"/B"}, // projects
- "");
- this.assertMarkers(
- "Unexpected markers",
- "Missing required Java project: B.",
- javaProject);
- } finally {
- this.deleteProject("A");
- }
-}
-/**
- * Test that a marker indicating a missing project is removed when the project is added.
- */
-public void testMissingPrereq3() throws CoreException {
- try {
- IJavaProject javaProject =
- this.createJavaProject(
- "A",
- new String[] {}, // source folders
- new String[] {}, // lib folders
- new String[] {"/B"}, // projects
- "");
- this.createJavaProject("B", new String[] {}, "");
- this.assertMarkers("Unexpected markers", "", javaProject);
- } finally {
- this.deleteProject("A");
- this.deleteProject("B");
- }
-}
-/**
- * Test that a marker indicating a cycle is removed when a project in the cycle is deleted
- * and replaced with a missing prereq marker.
- * (regression test for bug 15168 circular errors not reported)
- */
-public void testMissingPrereq4() throws CoreException {
- try {
- IJavaProject projectA =
- this.createJavaProject(
- "A",
- new String[] {}, // source folders
- new String[] {}, // lib folders
- new String[] {"/B"}, // projects
- "");
- IJavaProject projectB =
- this.createJavaProject(
- "B",
- new String[] {}, // source folders
- new String[] {}, // lib folders
- new String[] {"/A"}, // projects
- "");
- this.assertMarkers(
- "Unexpected markers for project A",
- "A cycle was detected in the project's classpath.",
- projectA);
- this.assertMarkers(
- "Unexpected markers for project B",
- "A cycle was detected in the project's classpath.",
- projectB);
-
- // delete project B
- this.deleteProject("B");
- this.assertMarkers(
- "Unexpected markers for project A after deleting of project B",
- "Missing required Java project: B.",
- projectA);
-
- // add project B back
- projectB =
- this.createJavaProject(
- "B",
- new String[] {}, // source folders
- new String[] {}, // lib folders
- new String[] {"/A"}, // projects
- "");
- this.assertMarkers(
- "Unexpected markers for project A after adding project B back",
- "A cycle was detected in the project's classpath.",
- projectA);
- this.assertMarkers(
- "Unexpected markers for project B after adding project B back",
- "A cycle was detected in the project's classpath.",
- projectB);
-
- } finally {
- this.deleteProject("A");
- this.deleteProject("B");
- }
-}
-/**
- * Setting the classpath to null should be the same as using the
- * default classpath.
- */
-public void testNullClasspath() throws CoreException {
- try {
- IJavaProject project = this.createJavaProject("P", new String[] {""}, "");
- setClasspath(project, null);
- IClasspathEntry[] cp= project.getRawClasspath();
- assertTrue("classpath should have one root entry", cp.length == 1 && cp[0].getPath().equals(project.getUnderlyingResource().getFullPath()));
- } finally {
- this.deleteProject("P");
- }
-}
-
-
-public void testCycleDetection() throws CoreException {
-
- IJavaProject[] p = null;
- try {
-
- p = new IJavaProject[]{
- this.createJavaProject("P0", new String[] {""}, ""),
- this.createJavaProject("P1", new String[] {""}, ""),
- this.createJavaProject("P2", new String[] {""}, ""),
- this.createJavaProject("P3", new String[] {""}, ""),
- this.createJavaProject("P4", new String[] {""}, ""),
- };
-
- IClasspathEntry[][] extraEntries = new IClasspathEntry[][]{
- { JavaCore.newProjectEntry(p[1].getPath()), JavaCore.newProjectEntry(p[3].getPath()) },
- { JavaCore.newProjectEntry(p[2].getPath()), JavaCore.newProjectEntry(p[3].getPath()) },
- { JavaCore.newProjectEntry(p[1].getPath()) },
- { JavaCore.newProjectEntry(p[4].getPath())},
- { JavaCore.newProjectEntry(p[3].getPath()), JavaCore.newProjectEntry(p[0].getPath()) }
- };
-
- int[][] expectedCycleParticipants = new int[][] {
- { 0, 0, 0, 0, 0 }, // after setting CP p[0]
- { 0, 0, 0, 0, 0 }, // after setting CP p[1]
- { 0, 1, 1, 0, 0 }, // after setting CP p[2]
- { 0, 1, 1, 0, 0 }, // after setting CP p[3]
- { 1, 1, 1, 1, 1 }, // after setting CP p[4]
- };
-
- for (int i = 0; i < p.length; i++){
-
- // append project references
- IClasspathEntry[] oldClasspath = p[i].getRawClasspath();
- IClasspathEntry[] newClasspath = new IClasspathEntry[oldClasspath.length+extraEntries[i].length];
- System.arraycopy(oldClasspath, 0 , newClasspath, 0, oldClasspath.length);
- for (int j = 0; j < extraEntries[i].length; j++){
- newClasspath[oldClasspath.length+j] = extraEntries[i][j];
- }
- // set classpath
- p[i].setRawClasspath(newClasspath, null);
-
- // check cycle markers
- this.assertCycleMarkers(p[i], p, expectedCycleParticipants[i]);
- }
- //this.startDeltas();
-
- } finally {
- //this.stopDeltas();
- if (p != null){
- for (int i = 0; i < p.length; i++){
- this.deleteProject(p[i].getElementName());
- }
- }
- }
-}
-
-
-public void testCycleDetectionThroughVariables() throws CoreException {
-
- IJavaProject[] p = null;
- try {
-
- String[] var = new String[]{ "v0", "v1", "v2"};
-
- p = new IJavaProject[]{
- this.createJavaProject("P0", new String[] {""}, ""),
- this.createJavaProject("P1", new String[] {""}, ""),
- this.createJavaProject("P2", new String[] {""}, ""),
- this.createJavaProject("P3", new String[] {""}, ""),
- this.createJavaProject("P4", new String[] {""}, ""),
- };
-
- IClasspathEntry[][] extraEntries = new IClasspathEntry[][]{
- { JavaCore.newProjectEntry(p[1].getPath()), JavaCore.newVariableEntry(new Path(var[0]), null, null) },
- { JavaCore.newProjectEntry(p[2].getPath()), JavaCore.newProjectEntry(p[3].getPath()) },
- { JavaCore.newVariableEntry(new Path(var[1]), null, null) },
- { JavaCore.newVariableEntry(new Path(var[2]), null, null)},
- { JavaCore.newProjectEntry(p[3].getPath()), JavaCore.newProjectEntry(p[0].getPath()) }
- };
-
- int[][] expectedCycleParticipants = new int[][] {
- { 0, 0, 0, 0, 0 }, // after setting CP p[0]
- { 0, 0, 0, 0, 0 }, // after setting CP p[1]
- { 0, 0, 0, 0, 0 }, // after setting CP p[2]
- { 0, 0, 0, 0, 0 }, // after setting CP p[3]
- { 1, 1, 1, 1, 1 }, // after setting CP p[4]
- };
-
- IPath[][] variableValues = new IPath[][]{
- { null, null, null },
- { null, null, null },
- { null, null, null },
- { null, null, null },
- { p[3].getPath(), p[1].getPath(), p[4].getPath() },
- };
-
- for (int i = 0; i < p.length; i++){
-
- // append project references
- IClasspathEntry[] oldClasspath = p[i].getRawClasspath();
- IClasspathEntry[] newClasspath = new IClasspathEntry[oldClasspath.length+extraEntries[i].length];
- System.arraycopy(oldClasspath, 0 , newClasspath, 0, oldClasspath.length);
- for (int j = 0; j < extraEntries[i].length; j++){
- newClasspath[oldClasspath.length+j] = extraEntries[i][j];
- }
- // set classpath
- p[i].setRawClasspath(newClasspath, null);
-
- // update variable values
- JavaCore.setClasspathVariables(var, variableValues[i], null);
-
- // check cycle markers
- this.assertCycleMarkers(p[i], p, expectedCycleParticipants[i]);
- }
- //this.startDeltas();
-
- } finally {
- //this.stopDeltas();
- if (p != null){
- for (int i = 0; i < p.length; i++){
- this.deleteProject(p[i].getElementName());
- }
- }
- }
-}
-
-public void testCycleDetectionThroughContainers() throws CoreException {
-
- IJavaProject[] p = null;
- try {
-
- p = new IJavaProject[]{
- this.createJavaProject("P0", new String[] {""}, ""),
- this.createJavaProject("P1", new String[] {""}, ""),
- this.createJavaProject("P2", new String[] {""}, ""),
- this.createJavaProject("P3", new String[] {""}, ""),
- this.createJavaProject("P4", new String[] {""}, ""),
- };
-
- IClasspathContainer[] containers = new IClasspathContainer[]{
- new TestContainer(
- new Path("container0/default"),
- new IClasspathEntry[]{ JavaCore.newProjectEntry(p[3].getPath()) }),
- new TestContainer(
- new Path("container1/default"),
- new IClasspathEntry[]{ JavaCore.newProjectEntry(p[1].getPath()) }),
- new TestContainer(
- new Path("container2/default"),
- new IClasspathEntry[]{ JavaCore.newProjectEntry(p[4].getPath()) }),
- };
-
- IClasspathEntry[][] extraEntries = new IClasspathEntry[][]{
- { JavaCore.newProjectEntry(p[1].getPath()), JavaCore.newContainerEntry(containers[0].getPath()) },
- { JavaCore.newProjectEntry(p[2].getPath()), JavaCore.newProjectEntry(p[3].getPath()) },
- { JavaCore.newContainerEntry(containers[1].getPath()) },
- { JavaCore.newContainerEntry(containers[2].getPath())},
- { JavaCore.newProjectEntry(p[3].getPath()), JavaCore.newProjectEntry(p[0].getPath()) }
- };
-
- int[][] expectedCycleParticipants = new int[][] {
- { 0, 0, 0, 0, 0 }, // after setting CP p[0]
- { 0, 0, 0, 0, 0 }, // after setting CP p[1]
- { 0, 0, 0, 0, 0 }, // after setting CP p[2]
- { 0, 0, 0, 0, 0 }, // after setting CP p[3]
- { 1, 1, 1, 1, 1 }, // after setting CP p[4]
- };
-
- for (int i = 0; i < p.length; i++){
-
- // append project references
- IClasspathEntry[] oldClasspath = p[i].getRawClasspath();
- IClasspathEntry[] newClasspath = new IClasspathEntry[oldClasspath.length+extraEntries[i].length];
- System.arraycopy(oldClasspath, 0 , newClasspath, 0, oldClasspath.length);
- for (int j = 0; j < extraEntries[i].length; j++){
- newClasspath[oldClasspath.length+j] = extraEntries[i][j];
- }
- // set classpath
- p[i].setRawClasspath(newClasspath, null);
-
- // update container paths
- if (i == p.length - 1){
- JavaCore.setClasspathContainer(
- containers[0].getPath(),
- new IJavaProject[]{ p[0] },
- new IClasspathContainer[] { containers[0] },
- null);
-
- JavaCore.setClasspathContainer(
- containers[1].getPath(),
- new IJavaProject[]{ p[2] },
- new IClasspathContainer[] { containers[1] },
- null);
-
- JavaCore.setClasspathContainer(
- containers[2].getPath(),
- new IJavaProject[]{ p[3] },
- new IClasspathContainer[] { containers[2] },
- null);
- }
-
- // check cycle markers
- this.assertCycleMarkers(p[i], p, expectedCycleParticipants[i]);
- }
- //this.startDeltas();
-
- } finally {
- //this.stopDeltas();
- if (p != null){
- for (int i = 0; i < p.length; i++){
- this.deleteProject(p[i].getElementName());
- }
- }
- }
-}
-public void testCycleDetectionThroughContainerVariants() throws CoreException {
-
- IJavaProject[] p = null;
- try {
-
- p = new IJavaProject[]{
- this.createJavaProject("P0", new String[] {""}, ""),
- this.createJavaProject("P1", new String[] {""}, ""),
- this.createJavaProject("P2", new String[] {""}, ""),
- this.createJavaProject("P3", new String[] {""}, ""),
- this.createJavaProject("P4", new String[] {""}, ""),
- };
-
- class TestContainer implements IClasspathContainer {
- IPath path;
- IClasspathEntry[] entries;
- TestContainer(IPath path, IClasspathEntry[] entries){
- this.path = path;
- this.entries = entries;
- }
- public IPath getPath() { return this.path; }
- public IClasspathEntry[] getClasspathEntries() { return this.entries; }
- public String getDescription() { return null; }
- public int getKind() { return 0; }
- };
-
- IClasspathContainer[] containers = new IClasspathContainer[]{
- new TestContainer(
- new Path("container0/default"),
- new IClasspathEntry[]{ JavaCore.newProjectEntry(p[3].getPath()) }),
- new TestContainer(
- new Path("container0/default"),
- new IClasspathEntry[]{ JavaCore.newProjectEntry(p[1].getPath()) }),
- new TestContainer(
- new Path("container0/default"),
- new IClasspathEntry[]{ JavaCore.newProjectEntry(p[4].getPath()) }),
- };
-
- IClasspathEntry[][] extraEntries = new IClasspathEntry[][]{
- { JavaCore.newProjectEntry(p[1].getPath()), JavaCore.newContainerEntry(containers[0].getPath()) },
- { JavaCore.newProjectEntry(p[2].getPath()), JavaCore.newProjectEntry(p[3].getPath()) },
- { JavaCore.newContainerEntry(containers[1].getPath()) },
- { JavaCore.newContainerEntry(containers[2].getPath())},
- { JavaCore.newProjectEntry(p[3].getPath()), JavaCore.newProjectEntry(p[0].getPath()) }
- };
-
- int[][] expectedCycleParticipants = new int[][] {
- { 0, 0, 0, 0, 0 }, // after setting CP p[0]
- { 0, 0, 0, 0, 0 }, // after setting CP p[1]
- { 0, 0, 0, 0, 0 }, // after setting CP p[2]
- { 0, 0, 0, 0, 0 }, // after setting CP p[3]
- { 1, 1, 1, 1, 1 }, // after setting CP p[4]
- };
-
- for (int i = 0; i < p.length; i++){
-
- // append project references
- IClasspathEntry[] oldClasspath = p[i].getRawClasspath();
- IClasspathEntry[] newClasspath = new IClasspathEntry[oldClasspath.length+extraEntries[i].length];
- System.arraycopy(oldClasspath, 0 , newClasspath, 0, oldClasspath.length);
- for (int j = 0; j < extraEntries[i].length; j++){
- newClasspath[oldClasspath.length+j] = extraEntries[i][j];
- }
- // set classpath
- p[i].setRawClasspath(newClasspath, null);
-
- // update same container path for multiple projects
- if (i == p.length - 1){
- JavaCore.setClasspathContainer(
- containers[0].getPath(),
- new IJavaProject[]{ p[0], p[2], p[3] },
- new IClasspathContainer[] { containers[0], containers[1], containers[2] },
- null);
- }
-
- // check cycle markers
- this.assertCycleMarkers(p[i], p, expectedCycleParticipants[i]);
- }
- //this.startDeltas();
-
- } finally {
- //this.stopDeltas();
- if (p != null){
- for (int i = 0; i < p.length; i++){
- this.deleteProject(p[i].getElementName());
- }
- }
- }
-}
-public void testCycleDetection2() throws CoreException {
-
- IJavaProject[] p = null;
- try {
-
- p = new IJavaProject[]{
- this.createJavaProject("P0", new String[] {""}, ""),
- this.createJavaProject("P1", new String[] {""}, ""),
- this.createJavaProject("P2", new String[] {""}, ""),
- this.createJavaProject("P3", new String[] {""}, ""),
- this.createJavaProject("P4", new String[] {""}, ""),
- };
-
- IClasspathEntry[][] extraEntries = new IClasspathEntry[][]{
- { JavaCore.newProjectEntry(p[1].getPath()), JavaCore.newProjectEntry(p[3].getPath()) },
- { JavaCore.newProjectEntry(p[2].getPath()) },
- { JavaCore.newProjectEntry(p[0].getPath()) },
- { JavaCore.newProjectEntry(p[4].getPath())},
- { JavaCore.newProjectEntry(p[0].getPath()) }
- };
-
- int[][] expectedCycleParticipants = new int[][] {
- { 0, 0, 0, 0, 0 }, // after setting CP p[0]
- { 0, 0, 0, 0, 0 }, // after setting CP p[1]
- { 1, 1, 1, 0, 0 }, // after setting CP p[2]
- { 1, 1, 1, 0, 0 }, // after setting CP p[3]
- { 1, 1, 1, 1, 1 }, // after setting CP p[4]
- };
-
- for (int i = 0; i < p.length; i++){
-
- // append project references
- IClasspathEntry[] oldClasspath = p[i].getRawClasspath();
- IClasspathEntry[] newClasspath = new IClasspathEntry[oldClasspath.length+extraEntries[i].length];
- System.arraycopy(oldClasspath, 0 , newClasspath, 0, oldClasspath.length);
- for (int j = 0; j < extraEntries[i].length; j++){
- newClasspath[oldClasspath.length+j] = extraEntries[i][j];
- }
- // set classpath
- p[i].setRawClasspath(newClasspath, null);
-
- // check cycle markers
- this.assertCycleMarkers(p[i], p, expectedCycleParticipants[i]);
- }
- //this.startDeltas();
-
- } finally {
- //this.stopDeltas();
- if (p != null){
- for (int i = 0; i < p.length; i++){
- this.deleteProject(p[i].getElementName());
- }
- }
- }
-}
-
-public void testCycleDetection3() throws CoreException {
-
- IJavaProject[] p = null;
- try {
-
- p = new IJavaProject[]{
- this.createJavaProject("P0", new String[] {""}, ""),
- this.createJavaProject("P1", new String[] {""}, ""),
- this.createJavaProject("P2", new String[] {""}, ""),
- this.createJavaProject("P3", new String[] {""}, ""),
- this.createJavaProject("P4", new String[] {""}, ""),
- this.createJavaProject("P5", new String[] {""}, ""),
- };
-
- IClasspathEntry[][] extraEntries = new IClasspathEntry[][]{
- { JavaCore.newProjectEntry(p[2].getPath()), JavaCore.newProjectEntry(p[4].getPath()) },
- { JavaCore.newProjectEntry(p[0].getPath()) },
- { JavaCore.newProjectEntry(p[3].getPath()) },
- { JavaCore.newProjectEntry(p[1].getPath())},
- { JavaCore.newProjectEntry(p[5].getPath()) },
- { JavaCore.newProjectEntry(p[1].getPath()) }
- };
-
- int[][] expectedCycleParticipants = new int[][] {
- { 0, 0, 0, 0, 0, 0 }, // after setting CP p[0]
- { 0, 0, 0, 0, 0, 0 }, // after setting CP p[1]
- { 0, 0, 0, 0, 0, 0 }, // after setting CP p[2]
- { 1, 1, 1, 1, 0, 0 }, // after setting CP p[3]
- { 1, 1, 1, 1, 0, 0 }, // after setting CP p[4]
- { 1, 1, 1, 1, 1 , 1}, // after setting CP p[5]
- };
-
- for (int i = 0; i < p.length; i++){
-
- // append project references
- IClasspathEntry[] oldClasspath = p[i].getRawClasspath();
- IClasspathEntry[] newClasspath = new IClasspathEntry[oldClasspath.length+extraEntries[i].length];
- System.arraycopy(oldClasspath, 0 , newClasspath, 0, oldClasspath.length);
- for (int j = 0; j < extraEntries[i].length; j++){
- newClasspath[oldClasspath.length+j] = extraEntries[i][j];
- }
- // set classpath
- p[i].setRawClasspath(newClasspath, null);
-
- // check cycle markers
- this.assertCycleMarkers(p[i], p, expectedCycleParticipants[i]);
- }
- //this.startDeltas();
-
- } finally {
- //this.stopDeltas();
- if (p != null){
- for (int i = 0; i < p.length; i++){
- this.deleteProject(p[i].getElementName());
- }
- }
- }
-}
-public void testDenseCycleDetection() throws CoreException {
- denseCycleDetection(5);
- denseCycleDetection(10);
- denseCycleDetection(20);
- //denseCycleDetection(100);
-}
-
-private void denseCycleDetection(int numberOfParticipants) throws CoreException {
-
- long start = System.currentTimeMillis();
- IJavaProject[] projects = new IJavaProject[numberOfParticipants];
- int[] allProjectsInCycle = new int[numberOfParticipants];
- try {
- for (int i = 0; i < numberOfParticipants; i++){
- projects[i] = this.createJavaProject("P"+i, new String[]{""}, "");
- allProjectsInCycle[i] = 1;
- }
- for (int i = 0; i < numberOfParticipants; i++){
- IClasspathEntry[] extraEntries = new IClasspathEntry[numberOfParticipants-1];
- int index = 0;
- for (int j = 0; j < numberOfParticipants; j++){
- if (i == j) continue;
- extraEntries[index++] = JavaCore.newProjectEntry(projects[j].getPath());
- }
- // append project references
- IClasspathEntry[] oldClasspath = projects[i].getRawClasspath();
- IClasspathEntry[] newClasspath = new IClasspathEntry[oldClasspath.length+extraEntries.length];
- System.arraycopy(oldClasspath, 0 , newClasspath, 0, oldClasspath.length);
- for (int j = 0; j < extraEntries.length; j++){
- newClasspath[oldClasspath.length+j] = extraEntries[j];
- }
- // set classpath
- projects[i].setRawClasspath(newClasspath, null);
- };
-
- System.out.println("Dense cycle check ("+numberOfParticipants+" participants) : "+ (System.currentTimeMillis()-start)+" ms");
- for (int i = 0; i < numberOfParticipants; i++){
- // check cycle markers
- this.assertCycleMarkers(projects[i], projects, allProjectsInCycle);
- }
-
- } finally {
- if (projects != null){
- for (int i = 0; i < numberOfParticipants; i++){
- if (projects[i] != null)
- this.deleteProject(projects[i].getElementName());
- }
- }
- }
-}
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateMethodSourceExamplesTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateMethodSourceExamplesTests.java
deleted file mode 100644
index 983e7ea..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateMethodSourceExamplesTests.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import org.eclipse.jdt.internal.compiler.env.IConstants;
-import org.eclipse.jdt.core.jdom.*;
-
-import junit.framework.Test;
-
-public class CreateMethodSourceExamplesTests extends AbstractJavaModelTests {
-
- IDOMFactory domFactory;
-
- static final String LINE_SEPARATOR = System.getProperty("line.separator");
-
-
-public CreateMethodSourceExamplesTests(String name) {
- super(name);
-}
-public void setUpSuite() throws Exception {
- super.setUpSuite();
- this.domFactory = new DOMFactory();
-}
-
-public static Test suite() {
- return new Suite(CreateMethodSourceExamplesTests.class);
-}
-/**
- * Example of creating source for a method in an interface.
- */
-public void testCreateEmptyInterfaceMethod() {
- IDOMMethod method= this.domFactory.createMethod();
- method.setName("foo");
- method.setBody(";" + LINE_SEPARATOR);
- assertEquals(
- "source code incorrect",
- "public void foo();" + LINE_SEPARATOR,
- method.getContents());
-}
-/**
- * Example of creating a default empty method.
- */
-public void testCreateEmptyMethod() {
- IDOMMethod method= this.domFactory.createMethod();
- method.setName("foo");
- assertEquals(
- "source code incorrect",
- "public void foo() {" + LINE_SEPARATOR +
- "}" + LINE_SEPARATOR,
- method.getContents());
-}
-/**
- * Example of creating an abstract method.
- */
-public void testCreateMethodWithAbstractModifier() {
-
- IDOMMethod method= this.domFactory.createMethod();
- method.setName("foo");
- method.setFlags(IConstants.AccPublic| IConstants.AccAbstract);
- assertEquals(
- "source code incorrect",
- "public abstract void foo() {" + LINE_SEPARATOR +
- "}" + LINE_SEPARATOR,
- method.getContents());
-
-}
-/**
- * Example of creating a method body.
- */
-public void testCreateMethodWithBody() {
-
- IDOMMethod method= this.domFactory.createMethod();
- method.setName("foo");
- method.setBody(
- " {" + LINE_SEPARATOR +
- "\t...method body..." + LINE_SEPARATOR +
- "}" + LINE_SEPARATOR);
- assertEquals(
- "source code incorrect",
- "public void foo() {" + LINE_SEPARATOR +
- "\t...method body..." + LINE_SEPARATOR +
- "}" + LINE_SEPARATOR,
- method.getContents());
-
-}
-/**
- * Example of creating a method with public and static modifiers.
- */
-public void testCreateMethodWithModifiers() {
-
- IDOMMethod method= this.domFactory.createMethod();
- method.setName("foo");
- method.setFlags(IConstants.AccPublic| IConstants.AccStatic);
- assertEquals(
- "source code incorrect",
- "public static void foo() {" + LINE_SEPARATOR +
- "}" + LINE_SEPARATOR,
- method.getContents());
-
-}
-/**
- * Example of creating a method with modifiers and exceptions
- */
-public void testCreateMethodWithModifiersAndExceptions() {
-
- IDOMMethod method= this.domFactory.createMethod();
- method.setName("foo");
- method.setFlags(IConstants.AccPrivate);
- method.setExceptions(new String[]
- {"java.lang.IllegalArgumentException",
- "java.io.FileNotFoundExcpetion"});
- assertEquals(
- "source code incorrect",
- "private void foo() throws java.lang.IllegalArgumentException, java.io.FileNotFoundExcpetion {" + LINE_SEPARATOR +
- "}" + LINE_SEPARATOR,
- method.getContents());
-
-}
-/**
- * Example of creating a method with parameters
- */
-public void testCreateMethodWithParameters() {
-
- IDOMMethod method= this.domFactory.createMethod();
- method.setName("foo");
- method.setParameters(
- new String[] {"String", "int", "char[]"},
- new String[] {"name", "number", "buffer"});
- assertEquals(
- "source code incorrect",
- "public void foo(String name, int number, char[] buffer) {" + LINE_SEPARATOR +
- "}" + LINE_SEPARATOR,
- method.getContents());
-}
-/**
- * Example of creating a method with a return type
- */
-public void testCreateMethodWithReturnType() {
-
- IDOMMethod method= this.domFactory.createMethod();
- method.setName("foo");
- method.setReturnType("String");
- assertEquals(
- "source code incorrect",
- "public String foo() {" + LINE_SEPARATOR +
- "}" + LINE_SEPARATOR,
- method.getContents());
-}
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateTypeSourceExamplesTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateTypeSourceExamplesTests.java
deleted file mode 100644
index 48ce151..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateTypeSourceExamplesTests.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import org.eclipse.jdt.internal.compiler.env.IConstants;
-import org.eclipse.jdt.core.jdom.*;
-
-import junit.framework.Test;
-
-public class CreateTypeSourceExamplesTests extends AbstractJavaModelTests {
- IDOMFactory domFactory;
-
- static final String LINE_SEPARATOR = System.getProperty("line.separator");
-
-public CreateTypeSourceExamplesTests(String name) {
- super(name);
-}
-public static Test suite() {
- return new Suite(CreateTypeSourceExamplesTests.class);
-}
-public void setUpSuite() throws Exception {
- super.setUpSuite();
- this.domFactory = new DOMFactory();
-}
-/**
- * Example of creating a class with an extends clause
- */
-public void testCreateClassWithExtends() {
- IDOMType type= this.domFactory.createType();
- type.setName("Foo");
- type.setSuperclass("Bar");
- assertEquals(
- "source code incorrect",
- "public class Foo extends Bar {" + LINE_SEPARATOR +
- "}" + LINE_SEPARATOR,
- type.getContents());
-}
-/**
- * Example of creating a class with an implements clause.
- */
-public void testCreateClassWithImplements() {
- IDOMType type= this.domFactory.createType();
- type.setName("Foo");
- type.setSuperInterfaces(new String[] {"ISomething", "IOtherwise"});
- assertEquals(
- "source code incorrect",
- "public class Foo implements ISomething, IOtherwise {" + LINE_SEPARATOR +
- "}" + LINE_SEPARATOR,
- type.getContents());
-}
-
-/**
- * Example of creating a class with an implements clause.
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10979
- */
-public void testCreateClassWithImplements2() {
- IDOMType type= this.domFactory.createType("class A implements I1 {\n}");
- type.addSuperInterface("I2");
- assertEquals(
- "source code incorrect",
- "class A implements I1, I2 {\n}",
- type.getContents());
-}
-
-/**
- * Example of creating a class with an implements clause.
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10979
- */
-public void testCreateClassWithImplements3() {
- IDOMType type= this.domFactory.createType("class A {\n}");
- type.setSuperInterfaces(new String[] {"I1", "I2"});
- assertEquals(
- "source code incorrect",
- "class A implements I1, I2 {\n}",
- type.getContents());
-}
-
-/**
- * Example of creating a class with an implements clause.
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=10979
- */
-public void testCreateClassWithImplements4() {
- IDOMType type= this.domFactory.createType("class A implements I1{\n}");
- type.addSuperInterface("I2");
- assertEquals(
- "source code incorrect",
- "class A implements I1, I2{\n}",
- type.getContents());
-}
-
-/**
- * Example of creating a class with modifiers
- */
-public void testCreateClassWithModifiers() {
- IDOMType type= this.domFactory.createType();
- type.setName("Foo");
- type.setFlags(IConstants.AccPublic | IConstants.AccFinal);
- assertEquals(
- "source code incorrect",
- "public final class Foo {" + LINE_SEPARATOR +
- "}" + LINE_SEPARATOR,
- type.getContents());
-}
-/**
- * Example of creating a default class
- */
-public void testCreateEmptyClass() {
- IDOMType type= this.domFactory.createType();
- type.setName("Foo");
- assertEquals(
- "source code incorrect",
- "public class Foo {" + LINE_SEPARATOR +
- "}" + LINE_SEPARATOR,
- type.getContents());
-}
-/**
- * Ensures that an interface is created using
- * <code>CreateTypeSourceOperation</code> and that the source
- * of the created interface is correct.
- */
-public void testCreateEmptyInterface() {
- IDOMType type= this.domFactory.createType();
- type.setName("Foo");
- type.setClass(false);
- assertEquals(
- "source code incorrect",
- "public interface Foo {" + LINE_SEPARATOR +
- "}" + LINE_SEPARATOR,
- type.getContents());
-}
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/EncodingTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/EncodingTests.java
deleted file mode 100644
index 847e3e0..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/EncodingTests.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.tests.model.*;
-import org.eclipse.jdt.internal.core.Util;
-
-/**
- * @author oliviert
- */
-public class EncodingTests extends ModifyingResourceTests {
-
-
- public EncodingTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new Suite(EncodingTests.class.getName());
- suite.addTest(new EncodingTests("testCreateCompilationUnitAndImportContainer"));
- return suite;
- }
-
-
-
- /**
- * Check that the compilation unit is saved with the proper encoding.
- */
- public void testCreateCompilationUnitAndImportContainer() throws JavaModelException, CoreException {
- String savedEncoding = null;
- try {
- Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences();
-
- savedEncoding = preferences.getString(ResourcesPlugin.PREF_ENCODING);
- preferences.setValue(ResourcesPlugin.PREF_ENCODING, "UTF-8");
-
- ResourcesPlugin.getPlugin().savePluginPreferences();
-
- IJavaProject javaProject = createJavaProject("P", new String[] { "" }, "");
- IPackageFragment pkg = getPackageFragment("P", "", "");
- ICompilationUnit cu= pkg.createCompilationUnit("A.java",
- ("public class A {\r\n" +
- " public static main(String[] args) {\r\n" +
- " System.out.println(\"é\");\r\n" +
- " }\r\n" +
- "}"), false, new NullProgressMonitor());
- assertCreation(cu);
- cu.rename("B.java", true, new NullProgressMonitor());
- cu = pkg.getCompilationUnit("B.java");
- cu.rename("A.java", true, new NullProgressMonitor());
- cu = pkg.getCompilationUnit("A.java");
- byte[] tab = new byte[90];
- tab[0]=112;
- tab[1]=117;
- tab[2]=98;
- tab[3]=108;
- tab[4]=105;
- tab[5]=99;
- tab[6]=32;
- tab[7]=99;
- tab[8]=108;
- tab[9]=97;
- tab[10]=115;
- tab[11]=115;
- tab[12]=32;
- tab[13]=65;
- tab[14]=32;
- tab[15]=123;
- tab[16]=13;
- tab[17]=10;
- tab[18]=9;
- tab[19]=112;
- tab[20]=117;
- tab[21]=98;
- tab[22]=108;
- tab[23]=105;
- tab[24]=99;
- tab[25]=32;
- tab[26]=115;
- tab[27]=116;
- tab[28]=97;
- tab[29]=116;
- tab[30]=105;
- tab[31]=99;
- tab[32]=32;
- tab[33]=109;
- tab[34]=97;
- tab[35]=105;
- tab[36]=110;
- tab[37]=40;
- tab[38]=83;
- tab[39]=116;
- tab[40]=114;
- tab[41]=105;
- tab[42]=110;
- tab[43]=103;
- tab[44]=91;
- tab[45]=93;
- tab[46]=32;
- tab[47]=97;
- tab[48]=114;
- tab[49]=103;
- tab[50]=115;
- tab[51]=41;
- tab[52]=32;
- tab[53]=123;
- tab[54]=13;
- tab[55]=10;
- tab[56]=9;
- tab[57]=9;
- tab[58]=83;
- tab[59]=121;
- tab[60]=115;
- tab[61]=116;
- tab[62]=101;
- tab[63]=109;
- tab[64]=46;
- tab[65]=111;
- tab[66]=117;
- tab[67]=116;
- tab[68]=46;
- tab[69]=112;
- tab[70]=114;
- tab[71]=105;
- tab[72]=110;
- tab[73]=116;
- tab[74]=108;
- tab[75]=110;
- tab[76]=40;
- tab[77]=34;
- tab[78]=-61;
- tab[79]=-87;
- tab[80]=34;
- tab[81]=41;
- tab[82]=59;
- tab[83]=13;
- tab[84]=10;
- tab[85]=9;
- tab[86]=125;
- tab[87]=13;
- tab[88]=10;
- tab[89]=125;
- byte[] encodedContents = Util.getResourceContentsAsByteArray(javaProject.getProject().getWorkspace().getRoot().getFile(cu.getPath()));
- assertTrue("wrong size of encoded string", tab.length == encodedContents.length);
- for (int i = 0, max = tab.length; i < max; i++) {
- assertTrue("wrong size of encoded character at" + i, tab[i] == encodedContents[i]);
- }
- } finally {
- deleteProject("P");
-
- Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences();
-
- preferences.setValue(ResourcesPlugin.PREF_ENCODING, savedEncoding);
-
- ResourcesPlugin.getPlugin().savePluginPreferences();
- }
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExistenceTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExistenceTests.java
deleted file mode 100644
index 40b1c04..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExistenceTests.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.IClassFile;
-import org.eclipse.jdt.core.tests.model.*;
-
-public class ExistenceTests extends ModifyingResourceTests {
-public ExistenceTests(String name) {
- super(name);
-}
-
-
-
-public static Test suite() {
- TestSuite suite = new Suite(ExistenceTests.class.getName());
-
- suite.addTest(new ExistenceTests("testClassFileInSource"));
- suite.addTest(new ExistenceTests("testClassFileInLibrary"));
- suite.addTest(new ExistenceTests("testClassFileInBinary"));
-
- return suite;
-}
-
-public void testClassFileInBinary() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {"src"}, "bin");
- this.createFile("P/bin/X.class", "");
- IClassFile classFile = this.getClassFile("P/bin/X.class");
- assertTrue(!classFile.exists());
- } finally {
- this.deleteProject("P");
- }
-}
-public void testClassFileInLibrary() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {}, new String[] {"lib"}, "bin");
- this.createFile("P/lib/X.class", "");
- IClassFile classFile = this.getClassFile("P/lib/X.class");
- assertTrue(classFile.exists());
- } finally {
- this.deleteProject("P");
- }
-}
-public void testClassFileInSource() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {"src"}, "bin");
- this.createFile("P/src/X.class", "");
- IClassFile classFile = this.getClassFile("P/src/X.class");
- // for now, we don't check the kind (source or library),
- // so class file can exist in source folder
- assertTrue(classFile.exists());
- } finally {
- this.deleteProject("P");
- }
-}
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java
deleted file mode 100644
index 8aedca0..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java
+++ /dev/null
@@ -1,523 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import java.io.File;
-import java.io.IOException;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.tests.model.*;
-
-/**
- * These test ensure that modifications in external jar are correctly reported as
- * IJavaEllementDeltas after a JavaModel#refreshExternalArchives().
- */
-public class ExternalJarDeltaTests extends ModifyingResourceTests {
-
-public ExternalJarDeltaTests(String name) {
- super(name);
-}
-
-
-
-public static Test suite() {
- TestSuite suite = new Suite(ExternalJarDeltaTests.class.getName());
-
- suite.addTest(new ExternalJarDeltaTests("testExternalJar0"));
-
- suite.addTest(new ExternalJarDeltaTests("testExternalJarChanged1"));
- suite.addTest(new ExternalJarDeltaTests("testExternalJarChanged2"));
- suite.addTest(new ExternalJarDeltaTests("testExternalJarChanged3"));
- suite.addTest(new ExternalJarDeltaTests("testExternalJarAdded1"));
- suite.addTest(new ExternalJarDeltaTests("testExternalJarAdded2"));
- suite.addTest(new ExternalJarDeltaTests("testExternalJarAdded3"));
- suite.addTest(new ExternalJarDeltaTests("testExternalJarRemoved1"));
- suite.addTest(new ExternalJarDeltaTests("testExternalJarRemoved2"));
- suite.addTest(new ExternalJarDeltaTests("testExternalJarRemoved3"));
-
- suite.addTest(new ExternalJarDeltaTests("testExternalJarInternalExternalJar"));
-
- return suite;
-}
-
-private String getExternalPath() {
- return EXTERNAL_JAR_DIR_PATH;
-}
-
-private String getLibraryPath() {
- return getPluginDirectoryPath().substring(1).replace(File.separatorChar,'/')+"/LIB";
-}
-
-/**
- * Test if a modification is detected without doing a refresh.
- * Currently no modification are detected.
- */
-public void testExternalJar0() throws CoreException {
- File f = null;
- try {
- IJavaProject project = this.createJavaProject("P", new String[] {""}, "");
- String libPath = getLibraryPath();
- String pPath = getExternalPath()+"/p.jar";
- String p1Path = libPath+"/p1.jar";
- String p2Path = libPath+"/p2.jar";
-
- setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(new Path(pPath), null, null)});
-
- f = new File(pPath);
- File f1 = new File(p1Path);
- File f2 = new File(p2Path);
-
- copy(f1, f);
- this.getJavaModel().refreshExternalArchives(null,null);
- this.startDeltas();
-
- copy(f2, f);
-
- assertEquals(
- "Unexpected delta",
- "",
- this.getDeltas());
- } catch (IOException e) {
- } finally {
- if(f != null) {
- deleteFile(f);
- }
- this.deleteProject("P");
- this.stopDeltas();
- }
-}
-
-/**
- * Refresh the JavaModel after a modification of an external jar.
- */
-public void testExternalJarChanged1() throws CoreException {
- File f = null;
- try {
- IJavaProject project = this.createJavaProject("P", new String[] {""}, "");
-
- String libPath = getLibraryPath();
- String pPath = getExternalPath()+"/p.jar";
- String p1Path = libPath+"/p1.jar";
- String p2Path = libPath+"/p2.jar";
-
- setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(new Path(pPath), null, null)});
-
- f = new File(pPath);
- File f1 = new File(p1Path);
- File f2 = new File(p2Path);
-
- copy(f1, f);
- this.getJavaModel().refreshExternalArchives(null,null);
- this.startDeltas();
-
- copy(f2, f);
- this.getJavaModel().refreshExternalArchives(null,null);
-
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n"+
- " "+pPath+"[*]: {CONTENT | ARCHIVE CONTENT CHANGED}",
- this.getDeltas());
- } catch (IOException e) {
- } finally {
- if(f != null) {
- deleteFile(f);
- }
- this.deleteProject("P");
- this.stopDeltas();
- }
-}
-/**
- * Refresh a JavaProject after a modification of an external jar.
- */
-public void testExternalJarChanged2() throws CoreException {
- File f = null;
- try {
- IJavaProject project = this.createJavaProject("P", new String[] {""}, "");
-
- String libPath = getLibraryPath();
- String pPath = getExternalPath()+"/p.jar";
- String p1Path = libPath+"/p1.jar";
- String p2Path = libPath+"/p2.jar";
-
- setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(new Path(pPath), null, null)});
-
- f = new File(pPath);
- File f1 = new File(p1Path);
- File f2 = new File(p2Path);
-
- copy(f1, f);
- this.getJavaModel().refreshExternalArchives(null,null);
- this.startDeltas();
-
- copy(f2, f);
- this.getJavaModel().refreshExternalArchives(new IJavaElement[]{project},null);
-
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n"+
- " "+pPath+"[*]: {CONTENT | ARCHIVE CONTENT CHANGED}",
- this.getDeltas());
- } catch (IOException e) {
- } finally {
- if(f != null) {
- deleteFile(f);
- }
- this.deleteProject("P");
- this.stopDeltas();
- }
-}
-/**
- * Refresh an external jar after a modification of this jar.
- */
-public void testExternalJarChanged3() throws CoreException {
- File f = null;
- try {
- IJavaProject project = this.createJavaProject("P", new String[] {""}, "");
-
- String libPath = getLibraryPath();
- String pPath = getExternalPath()+"/p.jar";
- String p1Path = libPath+"/p1.jar";
- String p2Path = libPath+"/p2.jar";
-
- setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(new Path(pPath), null, null)});
-
- f = new File(pPath);
- File f1 = new File(p1Path);
- File f2 = new File(p2Path);
-
- copy(f1, f);
- this.getJavaModel().refreshExternalArchives(null,null);
- this.startDeltas();
-
- copy(f2, f);
-
- IPackageFragmentRoot root = project.getPackageFragmentRoot(pPath);
- this.getJavaModel().refreshExternalArchives(new IJavaElement[]{root},null);
-
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n"+
- " "+pPath+"[*]: {CONTENT | ARCHIVE CONTENT CHANGED}",
- this.getDeltas());
- } catch (IOException e) {
- } finally {
- if(f != null) {
- deleteFile(f);
- }
- this.deleteProject("P");
- this.stopDeltas();
- }
-}
-/**
- * Refresh the JavaModel after an addition of an external jar.
- */
-public void testExternalJarAdded1() throws CoreException {
- File f = null;
- try {
- IJavaProject project = this.createJavaProject("P", new String[] {""}, "");
-
- String libPath = getLibraryPath();
- String pPath = getExternalPath()+"/pAdded1.jar";
- String p1Path = libPath+"/p1.jar";
- String p2Path = libPath+"/p2.jar";
-
- setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(new Path(pPath), null, null)});
-
- f = new File(pPath);
- File f1 = new File(p1Path);
- File f2 = new File(p2Path);
-
- this.getJavaModel().refreshExternalArchives(null,null);
- this.startDeltas();
-
- copy(f2, f);
- this.getJavaModel().refreshExternalArchives(null,null);
-
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n"+
- " "+pPath+"[+]: {}",
- this.getDeltas());
- } catch (IOException e) {
- } finally {
- if(f != null) {
- deleteFile(f);
- }
- this.deleteProject("P");
- this.stopDeltas();
- }
-}
-/**
- * Refresh a JavaProject after an addition of an external jar.
- */
-public void testExternalJarAdded2() throws CoreException {
- File f = null;
- try {
- IJavaProject project = this.createJavaProject("P", new String[] {""}, "");
-
- String libPath = getLibraryPath();
- String pPath = getExternalPath()+"/pAdded2.jar";
- String p1Path = libPath+"/p1.jar";
- String p2Path = libPath+"/p2.jar";
-
- setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(new Path(pPath), null, null)});
-
- f = new File(pPath);
- File f1 = new File(p1Path);
- File f2 = new File(p2Path);
-
- this.getJavaModel().refreshExternalArchives(null,null);
- this.startDeltas();
-
- copy(f2, f);
- this.getJavaModel().refreshExternalArchives(new IJavaElement[]{project},null);
-
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n"+
- " "+pPath+"[+]: {}",
- this.getDeltas());
- } catch (IOException e) {
- } finally {
- if(f != null) {
- deleteFile(f);
- }
- this.deleteProject("P");
- this.stopDeltas();
- }
-}
-/**
- * Refresh an external jar after an addition of this jar.
- */
-public void testExternalJarAdded3() throws CoreException {
- File f = null;
- try {
- IJavaProject project = this.createJavaProject("P", new String[] {""}, "");
-
- String libPath =getLibraryPath();
- String pPath = getExternalPath()+"/pAdded3.jar";
- String p1Path = libPath+"/p1.jar";
- String p2Path = libPath+"/p2.jar";
-
- setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(new Path(pPath), null, null)});
-
- f = new File(pPath);
- File f1 = new File(p1Path);
- File f2 = new File(p2Path);
-
- this.getJavaModel().refreshExternalArchives(null,null);
- this.startDeltas();
-
- copy(f2, f);
- IPackageFragmentRoot root = project.getPackageFragmentRoot(pPath);
- this.getJavaModel().refreshExternalArchives(new IJavaElement[]{root},null);
-
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n"+
- " "+pPath+"[+]: {}",
- this.getDeltas());
- } catch (IOException e) {
- } finally {
- if(f != null) {
- deleteFile(f);
- }
- this.deleteProject("P");
- this.stopDeltas();
- }
-}
-/**
- * Refresh the JavaModel after a removal of an external jar.
- */
-public void testExternalJarRemoved1() throws CoreException {
- File f = null;
- try {
- IJavaProject project = this.createJavaProject("P", new String[] {""}, "");
-
- String libPath = getLibraryPath();
- String pPath = getExternalPath()+"/p.jar";
- String p1Path = libPath+"/p1.jar";
- String p2Path = libPath+"/p2.jar";
-
- setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(new Path(pPath), null, null)});
-
- f = new File(pPath);
- File f1 = new File(p1Path);
- File f2 = new File(p2Path);
-
- copy(f2, f);
- this.getJavaModel().refreshExternalArchives(null,null);
- this.startDeltas();
-
- deleteFile(f);
- this.getJavaModel().refreshExternalArchives(null,null);
-
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n"+
- " "+pPath+"[-]: {}",
- this.getDeltas());
- } catch (IOException e) {
- } finally {
- if(f != null) {
- deleteFile(f);
- }
- this.deleteProject("P");
- this.stopDeltas();
- }
-}
-/**
- * Refresh a JavaProject after a removal of an external jar.
- */
-public void testExternalJarRemoved2() throws CoreException {
- File f = null;
- try {
- IJavaProject project = this.createJavaProject("P", new String[] {""}, "");
-
- String libPath = getLibraryPath();
- String pPath = getExternalPath()+"/p.jar";
- String p1Path = libPath+"/p1.jar";
- String p2Path = libPath+"/p2.jar";
-
- setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(new Path(pPath), null, null)});
-
- f = new File(pPath);
- File f1 = new File(p1Path);
- File f2 = new File(p2Path);
-
- copy(f2, f);
- this.getJavaModel().refreshExternalArchives(null,null);
- this.startDeltas();
-
- deleteFile(f);
- this.getJavaModel().refreshExternalArchives(new IJavaElement[]{project},null);
-
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n"+
- " "+pPath+"[-]: {}",
- this.getDeltas());
- } catch (IOException e) {
- } finally {
- if(f != null) {
- deleteFile(f);
- }
- this.deleteProject("P");
- this.stopDeltas();
- }
-}
-/**
- * Refresh an external jar after a removal of this jar.
- */
-public void testExternalJarRemoved3() throws CoreException {
- File f = null;
- try {
- IJavaProject project = this.createJavaProject("P", new String[] {""}, "");
-
- String libPath = getLibraryPath();
- String pPath = getExternalPath()+"/p.jar";
- String p1Path = libPath+"/p1.jar";
- String p2Path = libPath+"/p2.jar";
-
- setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(new Path(pPath), null, null)});
-
- f = new File(pPath);
- File f1 = new File(p1Path);
- File f2 = new File(p2Path);
-
- copy(f2, f);
- this.getJavaModel().refreshExternalArchives(null,null);
- this.startDeltas();
-
- deleteFile(f);
- IPackageFragmentRoot root = project.getPackageFragmentRoot(pPath);
- this.getJavaModel().refreshExternalArchives(new IJavaElement[]{root},null);
-
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n"+
- " "+pPath+"[-]: {}",
- this.getDeltas());
- } catch (IOException e) {
- } finally {
- if(f != null) {
- deleteFile(f);
- }
- this.deleteProject("P");
- this.stopDeltas();
- }
-}
-/**
- * - add an internal jar to claspath
- * - remove internal jar and the same jar as external jar
- * - refresh the JavaModel
- */
-public void testExternalJarInternalExternalJar() throws CoreException {
- File f = null;
- try {
- IJavaProject project = this.createJavaProject("P", new String[] {""}, "");
-
- String libPath = getLibraryPath();
- String p1Path = libPath+"/p1.jar";
- String p2Path = libPath+"/p2.jar";
- File f1= new File(p1Path);
- File f2 = new File(p2Path);
-
- String internalFooPath = "/P/foo.jar";
- IFile fooIFile = this.createFile(internalFooPath, read(f1));
-
- setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(new Path(internalFooPath), null, null)});
- this.getJavaModel().refreshExternalArchives(null,null);
- this.startDeltas();
-
- IPath externalFooPath = fooIFile.getLocation();
- setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(externalFooPath, null, null)});
-
- f = new File(externalFooPath.toString());
- copy(f2, f);
-
- this.getJavaModel().refreshExternalArchives(null,null);
-
- String deltaPath = externalFooPath.toString();
- deltaPath = Character.toUpperCase(deltaPath.charAt(0)) + deltaPath.substring(1);
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n"+
- " foo.jar[*]: {REMOVED FROM CLASSPATH}\n"+
- " "+deltaPath.replace('/', File.separatorChar)+"[*]: {ADDED TO CLASSPATH}\n"+
- " ResourceDelta(/P/.classpath)[*]\n"+
- "\n"+
- "P[*]: {CHILDREN}\n"+
- " "+deltaPath+"[*]: {CONTENT | ARCHIVE CONTENT CHANGED}",
- this.getDeltas());
- } catch (IOException e) {
- } finally {
- if(f != null) {
- deleteFile(f);
- }
- this.deleteProject("P");
- this.stopDeltas();
- }
-}
-}
-
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/HierarchyOnWorkingCopiesTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/HierarchyOnWorkingCopiesTests.java
deleted file mode 100644
index 9aff556..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/HierarchyOnWorkingCopiesTests.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.ITypeHierarchy;
-import org.eclipse.jdt.core.IWorkingCopy;
-import org.eclipse.jdt.core.tests.model.*;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class HierarchyOnWorkingCopiesTests extends WorkingCopyTests {
-
-public HierarchyOnWorkingCopiesTests(String name) {
- super(name);
-}
-
-public static Test suite() {
- TestSuite suite = new Suite(HierarchyOnWorkingCopiesTests.class.getName());
-
- suite.addTest(new HierarchyOnWorkingCopiesTests("testSimpleSuperTypeHierarchy"));
- suite.addTest(new HierarchyOnWorkingCopiesTests("testSimpleSubTypeHierarchy"));
-
- return suite;
-}
-/**
- */
-public void testSimpleSubTypeHierarchy() throws CoreException {
- String newContents =
- "package x.y;\n" +
- "public class A extends B {\n" +
- "}";
- this.copy.getBuffer().setContents(newContents);
- this.copy.reconcile();
-
- IFile file = null;
- try {
- file = this.createFile(
- "P/src/x/y/B.java",
- "package x.y;\n" +
- "public class B {\n" +
- "}");
-
- IType type = this.getCompilationUnit("P/src/x/y/B.java").getType("B");
- ITypeHierarchy h = type.newTypeHierarchy(new IWorkingCopy[] {this.copy}, null);
-
- assertEquals(
- "Unexpected hierarchy",
- "Focus: x.y.B\n" +
- "Super types:\n" +
- " B [in B.java [in x.y [in src [in P]]]]\n" +
- " Object [in Object.class [in java.lang [in " + this.getExternalJCLPath() + " [in P]]]]\n" +
- "Sub types:\n" +
- " B [in B.java [in x.y [in src [in P]]]]\n" +
- " A [in [Working copy] A.java [in x.y [in src [in P]]]]\n",
- h.toString());
- } finally {
- if (file != null) {
- this.deleteResource(file);
- }
- }
-}
-/**
- */
-public void testSimpleSuperTypeHierarchy() throws CoreException {
- String newContents =
- "package x.y;\n" +
- "public class A {\n" +
- "}\n" +
- "class B {\n" +
- "}";
- this.copy.getBuffer().setContents(newContents);
- this.copy.reconcile();
-
- IFile file = null;
- try {
- file = this.createFile(
- "P/src/x/y/C.java",
- "package x.y;\n" +
- "public class C extends B {\n" +
- "}");
-
- IType type = this.getCompilationUnit("P/src/x/y/C.java").getType("C");
- ITypeHierarchy h = type.newSupertypeHierarchy(new IWorkingCopy[] {this.copy}, null);
-
- assertEquals(
- "Unexpected hierarchy",
- "Focus: x.y.C\n" +
- "Super types:\n" +
- " C [in C.java [in x.y [in src [in P]]]]\n" +
- " B [in [Working copy] A.java [in x.y [in src [in P]]]]\n" +
- " Object [in Object.class [in java.lang [in " + this.getExternalJCLPath() + " [in P]]]]\n" +
- "Sub types:\n" +
- " C [in C.java [in x.y [in src [in P]]]]\n",
- h.toString());
- } finally {
- if (file != null) {
- this.deleteResource(file);
- }
- }
-}
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaConventionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaConventionTests.java
deleted file mode 100644
index a1b6bd7..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaConventionTests.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.jdt.core.*;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JavaConventionTests extends AbstractJavaModelTests {
-public JavaConventionTests(String name) {
- super(name);
-}
-
-public static Test suite() {
- TestSuite suite = new Suite(JavaConventionTests.class.getName());
-
- suite.addTest(new JavaConventionTests("testInvalidImportDeclaration1"));
- suite.addTest(new JavaConventionTests("testInvalidImportDeclaration2"));
- suite.addTest(new JavaConventionTests("testInvalidImportDeclaration3"));
- suite.addTest(new JavaConventionTests("testPackageFragmentRootOverlap"));
- suite.addTest(new JavaConventionTests("testValidCompilationUnitName"));
- suite.addTest(new JavaConventionTests("testValidIdentifier"));
- suite.addTest(new JavaConventionTests("testInvalidIdentifier"));
- suite.addTest(new JavaConventionTests("testValidFieldName"));
- suite.addTest(new JavaConventionTests("testValidImportDeclaration"));
- suite.addTest(new JavaConventionTests("testValidMethodName"));
- suite.addTest(new JavaConventionTests("testValidPackageName"));
- suite.addTest(new JavaConventionTests("testValidTypeName"));
- suite.addTest(new JavaConventionTests("testValidUnicodeImportDeclaration"));
- suite.addTest(new JavaConventionTests("testValidUnicodePackageName"));
-
- return suite;
-}
-/**
- * @see JavaConventions
- */
-public void testInvalidIdentifier() {
- String[] invalidIds = new String[] {"", "1java", "Foo Bar", "#@$!", "Foo-Bar", "if", "InvalidEscapeSequence\\g", "true", "false", "null", null, " untrimmmed "};
- for (int i = 0; i < invalidIds.length; i++) {
- assertTrue("identifier not recognized as invalid: " + invalidIds[i], !JavaConventions.validateIdentifier(invalidIds[i]).isOK());
- }
-}
-/**
- * @see JavaNamingConventions
- */
-public void testInvalidImportDeclaration1() {
- assertTrue("import not reconized as invalid; java.math.", !JavaConventions.validateImportDeclaration("java.math.").isOK());
-}
-/**
- * @see JavaNamingConventions
- */
-public void testInvalidImportDeclaration2() {
- assertTrue("import not reconized as invalid; java.math*", !JavaConventions.validateImportDeclaration("java.math*").isOK());
-}
-/**
- * @see JavaNamingConventions
- */
-public void testInvalidImportDeclaration3() {
- assertTrue("import not reconized as invalid; empty string", !JavaConventions.validateImportDeclaration("").isOK());
-}
-/**
- * Test for package fragment root overlap
- */
-public void testPackageFragmentRootOverlap() throws Exception {
- try {
- IJavaProject project = this.createJavaProject("P1", new String[] {"src"}, new String[] {"/P1/jclMin.jar"}, "bin");
- this.copy(new java.io.File(getExternalJCLPath()), new java.io.File(getWorkspaceRoot().getLocation().toOSString() + java.io.File.separator + "P1" + java.io.File.separator + "jclMin.jar"));
- project.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
-
- IPackageFragmentRoot p1Zip= getPackageFragmentRoot("P1", "jclMin.jar");
- IPackageFragmentRoot p1Src= getPackageFragmentRoot("P1", "src");
-
- assertTrue("zip should not overlap source root",
- !JavaConventions.isOverlappingRoots(p1Zip.getUnderlyingResource().getFullPath(), p1Src.getUnderlyingResource().getFullPath()));
-
- this.createJavaProject("P2", new String[] {"src"}, "bin");
-
- IPackageFragmentRoot p2Src= getPackageFragmentRoot("P2", "src");
- assertTrue("source roots in different projects should not overlap ",
- !JavaConventions.isOverlappingRoots(p1Src.getUnderlyingResource().getFullPath(), p2Src.getUnderlyingResource().getFullPath()));
-
- assertTrue("The same root should overlap", JavaConventions.isOverlappingRoots(p2Src.getUnderlyingResource().getFullPath(), p2Src.getUnderlyingResource().getFullPath()));
-
- assertTrue("isOverLappingRoot does not handle null arguments", !JavaConventions.isOverlappingRoots(p2Src.getUnderlyingResource().getFullPath(), null));
- assertTrue("isOverLappingRoot does not handle null arguments", !JavaConventions.isOverlappingRoots(null, null));
- } finally {
- this.deleteProject("P1");
- this.deleteProject("P2");
- }
-}
-/**
- * @see JavaConventions
- */
-public void testValidCompilationUnitName() {
- String[] invalidNames = new String[] {"java/lang/Object.java", "Object.class", ".java", "Object.javaaa", "A.B.java"};
- for (int i = 0; i < invalidNames.length; i++) {
- assertTrue("compilation unit name not recognized as invalid: " + invalidNames[i], !JavaConventions.validateCompilationUnitName(invalidNames[i]).isOK());
- }
- String[] validNames = new String[] {"Object.JaVa"};
- for (int i = 0; i < validNames.length; i++) {
- assertTrue("compilation unit name not recognized as valid: " + validNames[i], JavaConventions.validateCompilationUnitName(validNames[i]).isOK());
- }
-}
-/**
- * @see JavaNamingConventions
- */
-public void testValidFieldName() {
- assertTrue("unicode field name not handled", JavaConventions.validateFieldName("s\\u0069ze").isOK());
-}
-/**
- * @see JavaConventions
- */
-public void testValidIdentifier() {
- String[] validIds = new String[] {"s\\u0069ze", "Object", "An_Extremly_Long_Class_Name_With_Words_Separated_By_Undescores"};
- for (int i = 0; i < validIds.length; i++) {
- assertTrue("identifier not recognized as valid: " + validIds[i], JavaConventions.validateIdentifier(validIds[i]).isOK());
- }
-}
-/**
- * @see JavaConventions
- */
-public void testValidImportDeclaration() {
- assertTrue("import not reconized as valid", JavaConventions.validateImportDeclaration("java.math.*").isOK());
-}
-/**
- * @see JavaNamingConventions
- */
-public void testValidMethodName() {
- assertTrue("unicode method name not handled", JavaConventions.validateMethodName("getSiz\\u0065").isOK());
-}
-/**
- * @see JavaNamingConventions
- */
-public void testValidPackageName() {
-
- String pkgName= "org.eclipse.jdt.core.t\\u0065sts.MyPackage";
- assertTrue("unicode package name not handled", JavaConventions.validatePackageName(pkgName).isOK());
-
- assertTrue("package name not recognized as invalid1", !JavaConventions.validatePackageName("").isOK());
- assertTrue("package name not recognized as valid1", JavaConventions.validatePackageName("java . lang").isOK());
- assertTrue("package name not recognized as invalid2", !JavaConventions.validatePackageName(" java . lang").isOK());
- assertTrue("package name not recognized as invalid3", !JavaConventions.validatePackageName("java . lang ").isOK());
- assertTrue("package name not recognized as invalid4", !JavaConventions.validatePackageName(null).isOK());
- assertTrue("package name not recognized as unconventional1", JavaConventions.validatePackageName("Java.lang").getSeverity() == IStatus.WARNING);
- assertTrue("package name not recognized as valid2", JavaConventions.validatePackageName("java.Lang").isOK());
-}
-/**
- * @see JavaNamingConventions
- */
-public void testValidTypeName() {
- // regression tests for 1G5HVPB: ITPJCORE:WINNT - validateJavaTypeName accepts type names ending with \
- assertTrue("type name should not contain slashes (1)", JavaConventions.validateJavaTypeName("Object\\").getSeverity() == IStatus.ERROR);
- assertTrue("type name should not contain slashes (2)", JavaConventions.validateJavaTypeName("Object/").getSeverity() == IStatus.ERROR);
- assertTrue("type name should not contain slashes (3)", JavaConventions.validateJavaTypeName("\\Object").getSeverity() == IStatus.ERROR);
- assertTrue("type name should not contain slashes (4)", JavaConventions.validateJavaTypeName("java\\lang\\Object").getSeverity() == IStatus.ERROR);
-
- // regression test for 1G52ZIF: ITPJUI:WINNT - Wizards should strongly discourage the use of non-standard names
- assertTrue("discouraged type names not handled", JavaConventions.validateJavaTypeName("alowercasetypename").getSeverity() == IStatus.WARNING);
-
- // other tests
- assertTrue("unicode type name not handled", JavaConventions.validateJavaTypeName("P\\u0065a").getSeverity() == IStatus.OK);
- assertTrue("qualified type names not handled", JavaConventions.validateJavaTypeName("java . lang\t.Object").getSeverity() == IStatus.OK);
- assertTrue("simple qualified type names not handled", JavaConventions.validateJavaTypeName("java.lang.Object").getSeverity() == IStatus.OK);
- assertTrue("simple type names not handled", JavaConventions.validateJavaTypeName("Object").getSeverity() == IStatus.OK);
- assertTrue("discouraged type names not handled", JavaConventions.validateJavaTypeName("Object$SubType").getSeverity() == IStatus.WARNING);
- assertTrue("invalid type name not recognized", JavaConventions.validateJavaTypeName("==?==").getSeverity() == IStatus.ERROR);
-}
-/**
- * @see JavaNamingConventions
- */
-public void testValidUnicodeImportDeclaration() {
-
- String pkgName= "com.\\u0069bm.jdt.core.tests.MyPackag\\u0065";
- assertTrue("import not reconized as valid", JavaConventions.validateImportDeclaration(pkgName).isOK());
-
-}
-/**
- * @see JavaNamingConventions
- */
-public void testValidUnicodePackageName() {
-
- String pkgName= "com.\\u0069bm.jdt.core.tests.MyPackag\\u0065";
- assertTrue("unicode package name not handled", JavaConventions.validatePackageName(pkgName).isOK());
- assertTrue("Parameter modified", pkgName.equals("com.\\u0069bm.jdt.core.tests.MyPackag\\u0065"));
-
-}
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java
deleted file mode 100644
index d8ea80b..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java
+++ /dev/null
@@ -1,1327 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.ElementChangedEvent;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IElementChangedListener;
-import org.eclipse.jdt.core.IJavaElementDelta;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IWorkingCopy;
-import org.eclipse.jdt.core.JavaCore;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * These test ensure that modifications in Java projects are correctly reported as
- * IJavaElementDeltas.
- */
-public class JavaElementDeltaTests extends ModifyingResourceTests {
-
- public class DeltaListener implements IElementChangedListener {
- ArrayList deltas;
- int eventType;
-
- public DeltaListener() {
- DeltaListener.this.deltas = new ArrayList();
- DeltaListener.this.eventType = -1;
- }
- public DeltaListener(int eventType) {
- DeltaListener.this.deltas = new ArrayList();
- DeltaListener.this.eventType = eventType;
- }
- public void elementChanged(ElementChangedEvent event) {
- if (DeltaListener.this.eventType == -1 || event.getType() == DeltaListener.this.eventType) {
- DeltaListener.this.deltas.add(event.getDelta());
- }
- }
- public void flush() {
- DeltaListener.this.deltas = new ArrayList();
- }
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0, length = DeltaListener.this.deltas.size(); i < length; i++) {
- IJavaElementDelta[] projects = ((IJavaElementDelta)this.deltas.get(i)).getAffectedChildren();
- for (int j=0, projectsLength=projects.length; j<projectsLength; j++) {
- buffer.append(projects[j]);
- if (j != projectsLength-1) {
- buffer.append("\n");
- }
- }
- if (i != length-1) {
- buffer.append("\n\n");
- }
- }
- return buffer.toString();
- }
- }
-
-public JavaElementDeltaTests(String name) {
- super(name);
-}
-
-
-
-public static Test suite() {
- TestSuite suite = new Suite(JavaElementDeltaTests.class.getName());
-
- // add/remove/open/close projects
- suite.addTest(new JavaElementDeltaTests("testAddJavaProject"));
- suite.addTest(new JavaElementDeltaTests("testRemoveJavaProject"));
- suite.addTest(new JavaElementDeltaTests("testRemoveAddJavaProject"));
- suite.addTest(new JavaElementDeltaTests("testAddJavaNature"));
- suite.addTest(new JavaElementDeltaTests("testRemoveJavaNature"));
- suite.addTest(new JavaElementDeltaTests("testOpenJavaProject"));
- suite.addTest(new JavaElementDeltaTests("testCloseJavaProject"));
- suite.addTest(new JavaElementDeltaTests("testAddTwoJavaProjects"));
- suite.addTest(new JavaElementDeltaTests("testAddTwoJavaProjectsWithExtraSetClasspath"));
-
- suite.addTest(new JavaElementDeltaTests("testRenameJavaProject"));
-
- // non-java projects
- suite.addTest(new JavaElementDeltaTests("testAddNonJavaProject"));
- suite.addTest(new JavaElementDeltaTests("testRemoveNonJavaProject"));
- suite.addTest(new JavaElementDeltaTests("testRemoveNonJavaProjectUpdateDependent"));
- suite.addTest(new JavaElementDeltaTests("testRemoveNonJavaProjectUpdateDependent2"));
- suite.addTest(new JavaElementDeltaTests("testOpenNonJavaProject"));
- suite.addTest(new JavaElementDeltaTests("testCloseNonJavaProject"));
- suite.addTest(new JavaElementDeltaTests("testCloseNonJavaProjectUpdateDependent"));
- suite.addTest(new JavaElementDeltaTests("testRenameProject"));
- // TO DO: suite.addTest(new JavaElementDeltaTests("testChangeNonJavaProject"));
-
- // packages
- suite.addTest(new JavaElementDeltaTests("testAddPackageSourceIsBin"));
-
- // compilation units
- suite.addTest(new JavaElementDeltaTests("testAddCuInDefaultPkg1"));
- suite.addTest(new JavaElementDeltaTests("testAddCuInDefaultPkg2"));
- suite.addTest(new JavaElementDeltaTests("testMoveCuInEnclosingPkg"));
-
- // commit/save working copies
- suite.addTest(new JavaElementDeltaTests("testModifyMethodBodyAndSave"));
- suite.addTest(new JavaElementDeltaTests("testRenameMethodAndSave"));
- suite.addTest(new JavaElementDeltaTests("testSaveWorkingCopy"));
- suite.addTest(new JavaElementDeltaTests("testWorkingCopyCommit"));
-
- // managed working copies
- suite.addTest(new JavaElementDeltaTests("testCreateSharedWorkingCopy"));
- suite.addTest(new JavaElementDeltaTests("testDestroySharedWorkingCopy"));
-
- // non-java resources
- suite.addTest(new JavaElementDeltaTests("testMoveResInDotNamedFolder"));
- suite.addTest(new JavaElementDeltaTests("testMergeResourceDeltas"));
- suite.addTest(new JavaElementDeltaTests("testAddFileToNonJavaProject"));
-
- // listeners
- suite.addTest(new JavaElementDeltaTests("testListenerAutoBuild"));
- suite.addTest(new JavaElementDeltaTests("testListenerReconcile"));
- suite.addTest(new JavaElementDeltaTests("testListenerPostChange"));
-
- // classpath
- suite.addTest(new JavaElementDeltaTests("testSetClasspathVariable1"));
- suite.addTest(new JavaElementDeltaTests("testSetClasspathVariable2"));
- suite.addTest(new JavaElementDeltaTests("testChangeRootKind"));
- suite.addTest(new JavaElementDeltaTests("testOverwriteClasspath"));
-
- return suite;
-}
-
-/*
- * Add cu in default package test (proj=src=bin).
- */
-public void testAddCuInDefaultPkg1() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.startDeltas();
- this.createFile("P/X.java",
- "public class X {\n" +
- "}");
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " X.java[+]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-/*
- * Move a cu from a package to its enclosing package.
- * (regression test for bug 7033 Stale packages view after moving compilation units)
- */
-public void testMoveCuInEnclosingPkg() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.createFolder("P/x/y");
- this.createFile("P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}");
- ICompilationUnit cu = this.getCompilationUnit("P/x/y/A.java");
- IPackageFragment pkg = this.getPackage("P/x");
-
- this.startDeltas();
- cu.move(pkg, null, null, true, null);
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " x.y[*]: {CHILDREN}\n" +
- " A.java[-]: {MOVED_TO(A.java [in x [in [project root] [in P]]])}\n" +
- " x[*]: {CHILDREN}\n" +
- " A.java[+]: {MOVED_FROM(A.java [in x.y [in [project root] [in P]]])}",
- this.getDeltas());
- assertEquals(
- "Unexpected children for package x",
- "x\n" +
- " A.java\n" +
- " package x\n" +
- " class A",
- this.expandAll(pkg));
- assertEquals(
- "Unexpected children for package x.y",
- "x.y",
- this.expandAll(this.getPackage("P/x/y")));
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-public void testModifyMethodBodyAndSave() throws CoreException {
- ICompilationUnit workingCopy = null;
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.createFolder("P/x/y");
- this.createFile("P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- " public void foo() {\n" +
- " }\n" +
- "}");
- ICompilationUnit cu = this.getCompilationUnit("P/x/y/A.java");
- workingCopy = (ICompilationUnit)cu.getWorkingCopy();
- workingCopy.getBuffer().setContents(
- "package x.y;\n" +
- "public class A {\n" +
- " public void foo() {\n" +
- " // method body change \n" +
- " }\n" +
- "}");
-
- this.startDeltas();
- workingCopy.commit(true, null);
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " x.y[*]: {CHILDREN}\n" +
- " A.java[*]: {CONTENT | FINE GRAINED}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- if (workingCopy != null) {
- workingCopy.destroy();
- }
- this.deleteProject("P");
- }
-}
-
-
-/*
- * Add cu in default package test (proj!=src!=bin).
- */
-public void testAddCuInDefaultPkg2() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {"src"}, "bin");
- this.startDeltas();
- this.createFile("P/src/X.java",
- "public class X {\n" +
- "}");
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n" +
- " src[*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " X.java[+]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-/*
- * Ensure that a delta is not fired when a file is added to a non-java project.
- * (regression test for bug 18698 Seeing non-java projects in package view)
- */
-public void testAddFileToNonJavaProject() throws CoreException {
- try {
- this.createProject("P");
- this.startDeltas();
- this.createFile("/P/toto.txt", "");
- assertEquals(
- "Unexpected delta",
- "",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-
-/*
- * Add a non-java project.
- */
-public void testAddNonJavaProject() throws CoreException {
- try {
- this.startDeltas();
- this.createProject("P");
- assertEquals("Should get no delta", "", this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-public void testAddPackageSourceIsBin() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {"src"}, "src");
- this.startDeltas();
- this.createFolder("P/src/x");
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n" +
- " src[*]: {CHILDREN}\n" +
- " x[+]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-/*
- * Add 2 java projects in an IWorkspaceRunnable.
- */
-public void testAddTwoJavaProjects() throws CoreException {
- try {
- this.startDeltas();
- ResourcesPlugin.getWorkspace().run(
- new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- createJavaProject("P1", new String[] {""}, "");
- createJavaProject("P2", new String[] {"src"}, "bin");
- }
- },
- null);
- assertEquals(
- "Unexpected delta",
- "P1[+]: {}\n" +
- "P2[+]: {}",
- this.getSortedByProjectDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P1");
- this.deleteProject("P2");
- }
-}
-
-/*
- * Add 2 java projects in an IWorkspaceRunnable.
- */
-public void testAddTwoJavaProjectsWithExtraSetClasspath() throws CoreException {
- try {
- this.startDeltas();
- ResourcesPlugin.getWorkspace().run(
- new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- IJavaProject p1 = createJavaProject("P1", new String[] {""}, "");
- // should be a no-op and no extra delta volley should be fired
- p1.setRawClasspath(p1.getRawClasspath(), p1.getOutputLocation(), null);
- createJavaProject("P2", new String[] {"src"}, "bin");
- }
- },
- null);
- assertEquals(
- "Unexpected delta",
- "P1[+]: {}\n" +
- "P2[+]: {}",
- this.getSortedByProjectDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P1");
- this.deleteProject("P2");
- }
-}
-/**
- * Ensures that the setting the classpath with a library entry
- * triggers a F_REMOVED_FROM_CLASSPATH and F_ADDED_TO_CLASSPATH delta.
- */
-public void testChangeRootKind() throws CoreException {
- try {
- IJavaProject proj = this.createJavaProject("P", new String[] {"src"}, "bin");
- this.startDeltas();
- this.setClasspath(
- proj,
- new IClasspathEntry[] {
- JavaCore.newLibraryEntry(new Path("/P/src"), null, null, false)
- });
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n" +
- " src[*]: {ADDED TO CLASSPATH | REMOVED FROM CLASSPATH}\n" +
- " ResourceDelta(/P/.classpath)[*]",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-
-public void testCreateSharedWorkingCopy() throws CoreException {
- IWorkingCopy copy = null;
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.createFile("P/X.java",
- "public class X {\n" +
- "}");
- ICompilationUnit unit = this.getCompilationUnit("P", "", "", "X.java");
- this.startDeltas();
- copy = (IWorkingCopy)unit.getSharedWorkingCopy(null, null, null);
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " [Working copy] X.java[+]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- if (copy != null) copy.destroy();
- this.deleteProject("P");
- }
-}
-/*
- * Closing a non-java project that contains a jar referenced in another project should produce
- * a delta on this other project.
- * (regression test for bug 19058 Closing non-java project doesn't remove root from java project)
- */
-public void testCloseNonJavaProjectUpdateDependent() throws CoreException {
- try {
- this.createProject("SP");
- this.createFile("/SP/x.jar", "");
- this.createJavaProject("JP", new String[] {""}, new String[] {"/SP/x.jar"}, "");
- IProject project = this.getProject("SP");
- this.startDeltas();
- project.close(null);
- assertEquals(
- "Unexpected delta",
- "JP[*]: {CHILDREN}\n" +
- " x.jar[-]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("SP");
- this.deleteProject("JP");
- }
-}
-public void testDestroySharedWorkingCopy() throws CoreException {
- IWorkingCopy copy = null;
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.createFile("P/X.java",
- "public class X {\n" +
- "}");
- ICompilationUnit unit = this.getCompilationUnit("P", "", "", "X.java");
- copy = (IWorkingCopy)unit.getSharedWorkingCopy(null, null, null);
- this.startDeltas();
- copy.destroy();
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " [Working copy] X.java[-]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-/*
- * Ensures that a delta listener that asks for PRE_AUTO_BUILD events gets those events
- * and no others.
- */
-public void testListenerAutoBuild() throws CoreException {
- DeltaListener listener = new DeltaListener(ElementChangedEvent.PRE_AUTO_BUILD);
- ICompilationUnit wc = null;
- try {
- this.createJavaProject("P", new String[] {""}, "");
- JavaCore.addElementChangedListener(listener, ElementChangedEvent.PRE_AUTO_BUILD);
-
- // cu creation
- IPackageFragment pkg = this.getPackage("P");
- ICompilationUnit cu = pkg.createCompilationUnit(
- "X.java",
- "public class X {\n" +
- "}",
- false,
- null);
- assertEquals(
- "Unexpected delta after creating CU",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " X.java[+]: {}",
- listener.toString());
- listener.flush();
-
- // type creation
- cu.createType(
- "class A {\n" +
- "}",
- cu.getType("X"),
- false,
- null);
- assertEquals(
- "Unexpected delta after creating type",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " X.java[*]: {CHILDREN | FINE GRAINED}\n" +
- " A[+]: {}",
- listener.toString());
- listener.flush();
-
- // non-java resource creation
- this.createFile("P/readme.txt", "");
- assertEquals(
- "Unexpected delta after creating non-java resource",
- "",
- listener.toString());
- listener.flush();
-
- // shared working copy creation
- wc = (ICompilationUnit)cu.getSharedWorkingCopy(null, null, null);
- assertEquals(
- "Unexpected delta after creating shared working copy",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " [Working copy] X.java[+]: {}",
- listener.toString());
- listener.flush();
-
- // reconcile
- wc.getBuffer().setContents(
- "public class X {\n" +
- " public void foo() {\n" +
- " }\n" +
- "}");
- wc.reconcile();
- assertEquals(
- "Unexpected delta after reconciling working copy",
- "",
- listener.toString());
- listener.flush();
-
- // commit
- wc.commit(false, null);
- assertEquals(
- "Unexpected delta after committing working copy",
- "X[*]: {CHILDREN | FINE GRAINED}\n" +
- " foo[+]: {}\n" +
- "A[-]: {}",
- listener.toString());
- listener.flush();
-
- // shared working copy destruction
- wc.destroy();
- assertEquals(
- "Unexpected delta after destroying shared working copy",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " [Working copy] X.java[-]: {}",
- listener.toString());
- listener.flush();
- wc = null;
-
-
- } finally {
- if (wc != null) wc.destroy();
- JavaCore.removeElementChangedListener(listener);
- this.deleteProject("P");
- }
-}
-/*
- * Ensures that a delta listener that asks for POST_CHANGE events gets those events
- * and no others.
- */
-public void testListenerPostChange() throws CoreException {
- DeltaListener listener = new DeltaListener(ElementChangedEvent.POST_CHANGE);
- ICompilationUnit wc = null;
- try {
- this.createJavaProject("P", new String[] {""}, "");
- JavaCore.addElementChangedListener(listener, ElementChangedEvent.POST_CHANGE);
-
- // cu creation
- IPackageFragment pkg = this.getPackage("P");
- ICompilationUnit cu = pkg.createCompilationUnit(
- "X.java",
- "public class X {\n" +
- "}",
- false,
- null);
- assertEquals(
- "Unexpected delta after creating CU",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " X.java[+]: {}",
- listener.toString());
- listener.flush();
-
- // type creation
- cu.createType(
- "class A {\n" +
- "}",
- cu.getType("X"),
- false,
- null);
- assertEquals(
- "Unexpected delta after creating type",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " X.java[*]: {CHILDREN | FINE GRAINED}\n" +
- " A[+]: {}",
- listener.toString());
- listener.flush();
-
- // non-java resource creation
- this.createFile("P/readme.txt", "");
- assertEquals(
- "Unexpected delta after creating non-java resource",
- "P[*]: {CONTENT}\n" +
- " ResourceDelta(/P/readme.txt)[+]",
- listener.toString());
- listener.flush();
-
- // shared working copy creation
- wc = (ICompilationUnit)cu.getSharedWorkingCopy(null, null, null);
- assertEquals(
- "Unexpected delta after creating shared working copy",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " [Working copy] X.java[+]: {}",
- listener.toString());
- listener.flush();
-
- // reconcile
- wc.getBuffer().setContents(
- "public class X {\n" +
- " public void foo() {\n" +
- " }\n" +
- "}");
- wc.reconcile();
- assertEquals(
- "Unexpected delta after reconciling working copy",
- "",
- listener.toString());
- listener.flush();
-
- // commit
- wc.commit(false, null);
- assertEquals(
- "Unexpected delta after committing working copy",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " X.java[*]: {CHILDREN | FINE GRAINED}\n" +
- " X[*]: {CHILDREN | FINE GRAINED}\n" +
- " foo[+]: {}\n" +
- " A[-]: {}",
- listener.toString());
- listener.flush();
-
- // shared working copy destruction
- wc.destroy();
- assertEquals(
- "Unexpected delta after destroying shared working copy",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " [Working copy] X.java[-]: {}",
- listener.toString());
- listener.flush();
- wc = null;
-
-
- } finally {
- if (wc != null) wc.destroy();
- JavaCore.removeElementChangedListener(listener);
- this.deleteProject("P");
- }
-}
-/*
- * Ensures that a delta listener that asks for POST_RECONCILE events gets those events
- * and no others.
- */
-public void testListenerReconcile() throws CoreException {
- DeltaListener listener = new DeltaListener(ElementChangedEvent.POST_RECONCILE);
- ICompilationUnit wc = null;
- try {
- this.createJavaProject("P", new String[] {""}, "");
- JavaCore.addElementChangedListener(listener, ElementChangedEvent.POST_RECONCILE);
-
- // cu creation
- IPackageFragment pkg = this.getPackage("P");
- ICompilationUnit cu = pkg.createCompilationUnit(
- "X.java",
- "public class X {\n" +
- "}",
- false,
- null);
- assertEquals(
- "Unexpected delta after creating CU",
- "",
- listener.toString());
- listener.flush();
-
- // type creation
- cu.createType(
- "class A {\n" +
- "}",
- cu.getType("X"),
- false,
- null);
- assertEquals(
- "Unexpected delta after creating type",
- "",
- listener.toString());
- listener.flush();
-
- // non-java resource creation
- this.createFile("P/readme.txt", "");
- assertEquals(
- "Unexpected delta after creating non-java resource",
- "",
- listener.toString());
- listener.flush();
-
- // shared working copy creation
- wc = (ICompilationUnit)cu.getSharedWorkingCopy(null, null, null);
- assertEquals(
- "Unexpected delta after creating shared working copy",
- "",
- listener.toString());
- listener.flush();
-
- // reconcile
- wc.getBuffer().setContents(
- "public class X {\n" +
- " public void foo() {\n" +
- " }\n" +
- "}");
- wc.reconcile();
- assertEquals(
- "Unexpected delta after reconciling working copy",
- "X[*]: {CHILDREN | FINE GRAINED}\n" +
- " foo[+]: {}\n" +
- "A[-]: {}",
- listener.toString());
- listener.flush();
-
- // commit
- wc.commit(false, null);
- assertEquals(
- "Unexpected delta after committing working copy",
- "",
- listener.toString());
- listener.flush();
-
- // shared working copy destruction
- wc.destroy();
- assertEquals(
- "Unexpected delta after destroying shared working copy",
- "",
- listener.toString());
- listener.flush();
- wc = null;
-
-
- } finally {
- if (wc != null) wc.destroy();
- JavaCore.removeElementChangedListener(listener);
- this.deleteProject("P");
- }
-}
-/**
- * Ensures that merging a java delta with another one that contains a resource delta
- * results in a java delta with the resource delta.
- * (regression test for 11210 ResourceDeltas are lost when merging deltas)
- */
-public void testMergeResourceDeltas() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.startDeltas();
- ResourcesPlugin.getWorkspace().run(
- new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- // an operation that creates a java delta without firing it
- IPackageFragment pkg = getPackageFragment("P", "", "");
- pkg.createCompilationUnit(
- "X.java",
- "public class X {\n" +
- "}",
- true,
- null);
-
- // an operation that generates a non java resource delta
- createFile("P/Y.txt", "");
- }
- },
- null
- );
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " X.java[+]: {}\n" +
- " ResourceDelta(/P/Y.txt)[+]",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-
-
-}
-
-/*
- * Close a java project.
- */
-public void testCloseJavaProject() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {""}, "");
- IProject project = this.getProject("P");
- this.startDeltas();
- project.close(null);
- assertEquals(
- "Unexpected delta",
- "P[-]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-
-/*
- * Close a non-java project.
- */
-public void testCloseNonJavaProject() throws CoreException {
- try {
- this.createProject("P");
- IProject project = this.getProject("P");
- this.startDeltas();
- project.close(null);
- assertEquals(
- "Unexpected delta",
- "",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-
-/*
- * Move a non-java resources that is under a dot-named folder.
- * (regression test for bug 6687 Wrong JavaModel refresh after drag and drop outside folder with dot in name)
- */
-public void testMoveResInDotNamedFolder() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {}, "");
- IProject project = this.getProject("P");
- this.createFolder("P/x.y");
- IFile file = this.createFile("P/x.y/test.txt", "");
-
- this.startDeltas();
- file.move(project.getFullPath().append("test.txt"), true, null);
- assertEquals(
- "Unexpected delta",
- "P[*]: {CONTENT}\n" +
- " ResourceDelta(/P/test.txt)[+]\n" +
- " ResourceDelta(/P/x.y)[*]",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-
-
-/*
- * Open a java project.
- */
-public void testOpenJavaProject() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {""}, "");
- IProject project = this.getProject("P");
- project.close(null);
- this.startDeltas();
- project.open(null);
- assertEquals(
- "Unexpected delta",
- "P[+]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-
-/*
- * Open a non-java project.
- */
-public void testOpenNonJavaProject() throws CoreException {
- try {
- this.createProject("P");
- IProject project = this.getProject("P");
- project.close(null);
- this.startDeltas();
- project.open(null);
- assertEquals(
- "Unexpected delta",
- "",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-/**
- * Ensures that .classpath overwrite is taken into account.
- * (regression test for bug 21420 Changing .classpath doesn't update JDT)
- */
-public void testOverwriteClasspath() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.createFolder("P/src");
- this.createFolder("P/bin");
- final IFile newCP = this.createFile(
- "P/.classpath2",
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<classpath>\n" +
- " <classpathentry kind=\"src\" path=\"src\"/>\n" +
- " <classpathentry kind=\"output\" path=\"bin\"/>\n" +
- "</classpath>");
- this.startDeltas();
- IWorkspaceRunnable run = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- IFile oldCP = newCP.getParent().getFile(new Path(".classpath"));
- oldCP.delete(true, null);
- newCP.move(new Path("/P/.classpath"), true, null);
- }
- };
- this.getWorkspace().run(run, null);
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {REMOVED FROM CLASSPATH}\n" +
- " src[*]: {ADDED TO CLASSPATH}\n" +
- " ResourceDelta(/P/.classpath)[*]\n" +
- " ResourceDelta(/P/.classpath2)[-]",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-
-
-/*
- * Add the java nature to an existing project.
- */
-public void testAddJavaNature() throws CoreException {
- try {
- this.createProject("P");
- this.startDeltas();
- this.addJavaNature("P");
- assertEquals(
- "Unexpected delta",
- "P[+]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-
-/*
- * Add a java project.
- */
-public void testAddJavaProject() throws CoreException {
- try {
- this.startDeltas();
- this.createJavaProject("P", new String[] {""}, "");
- assertEquals(
- "Unexpected delta",
- "P[+]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-
-/*
- * Remove the java nature of an existing java project.
- */
-public void testRemoveJavaNature() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.startDeltas();
- this.removeJavaNature("P");
- assertEquals(
- "Unexpected delta",
- "P[-]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-
-/*
- * Remove then add a java project (in a workspace runnable).
- */
-public void testRemoveAddJavaProject() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.startDeltas();
- getWorkspace().run(
- new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- deleteProject("P");
- createJavaProject("P", new String[] {""}, "");
- }
- },
- null);
- assertEquals(
- "Unexpected delta",
- "P[*]: {CONTENT}\n" +
- " ResourceDelta(/P/.classpath)[*]\n" +
- " ResourceDelta(/P/.project)[*]",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-public void testRemoveJavaProject() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.startDeltas();
- this.deleteProject("P");
- assertEquals(
- "Unexpected delta",
- "P[-]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- }
-}
-/*
- * Rename a java project.
- * (regression test for bug 7030 IllegalArgumentException renaming project)
- */
-public void testRenameJavaProject() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.startDeltas();
- this.renameProject("P", "P1");
- assertEquals(
- "Unexpected delta",
- "P[-]: {MOVED_TO(P1)}\n" +
- "P1[+]: {MOVED_FROM(P)}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- this.deleteProject("P1");
- }
-}
-public void testRenameMethodAndSave() throws CoreException {
- ICompilationUnit workingCopy = null;
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.createFolder("P/x/y");
- this.createFile("P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- " public void foo1() {\n" +
- " }\n" +
- "}");
- ICompilationUnit cu = this.getCompilationUnit("P/x/y/A.java");
- workingCopy = (ICompilationUnit)cu.getWorkingCopy();
- workingCopy.getBuffer().setContents(
- "package x.y;\n" +
- "public class A {\n" +
- " public void foo2() {\n" +
- " }\n" +
- "}");
-
- this.startDeltas();
- workingCopy.commit(true, null);
- assertEquals(
- "Unexpected delta",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " x.y[*]: {CHILDREN}\n" +
- " A.java[*]: {CHILDREN | FINE GRAINED}\n" +
- " A[*]: {CHILDREN | FINE GRAINED}\n" +
- " foo2[+]: {}\n" +
- " foo1[-]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- if (workingCopy != null) {
- workingCopy.destroy();
- }
- this.deleteProject("P");
- }
-}
-/*
- * Rename a non-java project.
- */
-public void testRenameProject() throws CoreException {
- try {
- this.createProject("P");
- this.startDeltas();
- this.renameProject("P", "P1");
- assertEquals(
- "Unexpected delta",
- "",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- this.deleteProject("P1");
- }
-}
-/**
- * Ensures that saving a working copy doesn't change the underlying resource.
- * (only commit should do so)
- */
-public void testSaveWorkingCopy() throws CoreException {
- ICompilationUnit copy = null;
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.createFile("P/X.java",
- "public class X {\n" +
- "}");
- ICompilationUnit unit = this.getCompilationUnit("P", "", "", "X.java");
- copy = (ICompilationUnit)unit.getWorkingCopy(null, null, null);
- copy.getType("X").createMethod("void foo() {}", null, true, null);
- this.startDeltas();
- copy.save(null, true);
- assertEquals(
- "Unexpected delta after saving working copy",
- "",
- this.getDeltas());
- copy.commit(true, null);
- assertEquals(
- "Unexpected delta after committing working copy",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " [default][*]: {CHILDREN}\n" +
- " X.java[*]: {CHILDREN | FINE GRAINED}\n" +
- " X[*]: {CHILDREN | FINE GRAINED}\n" +
- " foo[+]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- if (copy != null) copy.destroy();
- this.deleteProject("P");
- }
-}
-/**
- * Ensures that setting a classpath variable when there is exactly one project
- * triggers a java element delta.
- */
-public void testSetClasspathVariable1() throws CoreException {
- try {
- this.createProject("LibProj");
- this.createFile("LibProj/mylib.jar", "");
- this.createFile("LibProj/otherlib.jar", "");
- JavaCore.setClasspathVariables(new String[] {"LIB"}, new IPath[] {new Path("/LibProj/mylib.jar")}, null);
- this.createJavaProject("P", new String[] {""}, new String[] {"LIB"}, "");
- this.startDeltas();
- JavaCore.setClasspathVariables(new String[] {"LIB"}, new IPath[] {new Path("/LibProj/otherlib.jar")}, null);
- assertEquals(
- "Unexpected delta after setting classpath variable",
- "P[*]: {CHILDREN}\n" +
- " mylib.jar[*]: {REMOVED FROM CLASSPATH}\n" +
- " otherlib.jar[*]: {ADDED TO CLASSPATH}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- this.deleteProject("LibProj");
- }
-}
-/**
- * Ensures that setting a classpath variable when there are more than one project
- * triggers a java element delta.
- */
-public void testSetClasspathVariable2() throws CoreException {
- try {
- this.createProject("LibProj");
- this.createFile("LibProj/mylib.jar", "");
- this.createFile("LibProj/otherlib.jar", "");
- JavaCore.setClasspathVariables(new String[] {"LIB"}, new IPath[] {new Path("/LibProj/mylib.jar")}, null);
- this.createJavaProject("P1", new String[] {""}, new String[] {"LIB"}, "");
- this.createJavaProject("P2", new String[] {""}, new String[] {"LIB"}, "");
- this.startDeltas();
- JavaCore.setClasspathVariables(new String[] {"LIB"}, new IPath[] {new Path("/LibProj/otherlib.jar")}, null);
- assertEquals(
- "Unexpected delta after setting classpath variable",
- "P1[*]: {CHILDREN}\n" +
- " mylib.jar[*]: {REMOVED FROM CLASSPATH}\n" +
- " otherlib.jar[*]: {ADDED TO CLASSPATH}\n" +
- "P2[*]: {CHILDREN}\n" +
- " mylib.jar[*]: {REMOVED FROM CLASSPATH}\n" +
- " otherlib.jar[*]: {ADDED TO CLASSPATH}",
- this.getSortedByProjectDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P1");
- this.deleteProject("P2");
- this.deleteProject("LibProj");
- }
-}
-
-/**
- * Ensures that committing a working copy fires a fine grained delta.
- */
-public void testWorkingCopyCommit() throws CoreException {
- try {
- this.createJavaProject("P", new String[] {""}, "");
- this.createFolder("P/x/y");
- this.createFile("P/x/y/A.java",
- "package x.y;\n" +
- "public class A {\n" +
- "}");
- ICompilationUnit cu = this.getCompilationUnit("P/x/y/A.java");
- ICompilationUnit copy = (ICompilationUnit) cu.getWorkingCopy();
- copy.getBuffer().setContents(
- "package x.y;\n" +
- "public class A {\n" +
- " public void foo() {\n" +
- " }\n" +
- "}");
- copy.save(null, false);
- this.startDeltas();
- copy.commit(true, null);
- assertEquals(
- "Unexpected delta after commit",
- "P[*]: {CHILDREN}\n" +
- " [project root][*]: {CHILDREN}\n" +
- " x.y[*]: {CHILDREN}\n" +
- " A.java[*]: {CHILDREN | FINE GRAINED}\n" +
- " A[*]: {CHILDREN | FINE GRAINED}\n" +
- " foo[+]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("P");
- }
-}
-
-/*
- * Remove a non-java project.
- */
-public void testRemoveNonJavaProject() throws CoreException {
- try {
- this.createProject("P");
- this.startDeltas();
- this.deleteProject("P");
- assertEquals(
- "Should get no delta",
- "",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- }
-}
-/*
- * Removing a non-java project that contains a jar referenced in another project should produce
- * a delta on this other project.
- * (regression test for bug 19058 Closing non-java project doesn't remove root from java project)
- */
-public void testRemoveNonJavaProjectUpdateDependent() throws CoreException {
- try {
- this.createProject("SP");
- this.createFile("/SP/x.jar", "");
- this.createJavaProject("JP", new String[] {""}, new String[] {"/SP/x.jar"}, "");
- this.startDeltas();
- this.deleteProject("SP");
- assertEquals(
- "Unexpected delta",
- "JP[*]: {CHILDREN}\n" +
- " x.jar[-]: {}",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("SP");
- this.deleteProject("JP");
- }
-}
-/*
- * Removing a non-java project and another project reference a non exiting folder in the deleted project
- * should not produce a delta on this other project (and no null pointer exception)
- * (regression test for bug 19131 NPE when removing a project containing missing classfile folder)
- */
-public void testRemoveNonJavaProjectUpdateDependent2() throws CoreException {
- try {
- this.createProject("SP");
- this.createJavaProject("JP", new String[] {""}, new String[] {"/SP/missing"}, "");
- this.startDeltas();
- this.deleteProject("SP");
- assertEquals(
- "Unexpected delta",
- "",
- this.getDeltas());
- } finally {
- this.stopDeltas();
- this.deleteProject("SP");
- this.deleteProject("JP");
- }
-}
-}
-
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaModelTests.java
deleted file mode 100644
index 3c35374..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaModelTests.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.IJavaModel;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.tests.model.*;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Tests IJavaModel API.
- */
-public class JavaModelTests extends ModifyingResourceTests {
-
-public static Test suite() {
- TestSuite suite = new Suite(JavaModelTests.class.getName());
- suite.addTest(new JavaModelTests("testGetJavaProject"));
- suite.addTest(new JavaModelTests("testGetJavaProjects1"));
- suite.addTest(new JavaModelTests("testGetJavaProjects2"));
- suite.addTest(new JavaModelTests("testAddFileToNonJavaProject"));
- return suite;
-}
-public JavaModelTests(String name) {
- super(name);
-}
-protected int indexOf(String projectName, IJavaProject[] projects) {
- for (int i = 0, length = projects.length; i < length; i++) {
- if (projects[i].getElementName().equals(projectName)) {
- return i;
- }
- }
- return -1;
-}
-/*
- * Ensure that a java project is not added to the list of known java project
- * when a file is added to a non-java project.
- * (regression test for bug 18698 Seeing non-java projects in package view)
- */
-public void testAddFileToNonJavaProject() throws CoreException {
- IJavaModel model = this.getJavaModel();
- IJavaProject[] projects = model.getJavaProjects();
- assertTrue(
- "Project P should not be present already",
- this.indexOf("P", projects) == -1
- );
- try {
- this.createProject("P");
- this.createFile("/P/toto.txt", "");
- projects = model.getJavaProjects();
- assertTrue(
- "Project P should not be present",
- this.indexOf("P", projects) == -1
- );
- } finally {
- this.deleteProject("P");
- }
-}
-/**
- * Test that a model has no project.
- */
-public void testGetJavaProject() throws JavaModelException {
- IJavaModel model= getJavaModel();
- assertTrue("project should be null", model.getJavaProject() == null);
-}
-/*
- * Ensure that a java project that is added appears in the list of known java project,
- * and that it is removed from this list when deleted.
- */
-public void testGetJavaProjects1() throws CoreException {
- IJavaModel model = this.getJavaModel();
- IJavaProject[] projects = model.getJavaProjects();
- assertTrue(
- "Project P should not be present already",
- this.indexOf("P", projects) == -1
- );
- try {
- this.createJavaProject("P", new String[] {}, "");
- projects = model.getJavaProjects();
- assertTrue(
- "Project P should be present",
- this.indexOf("P", projects) != -1
- );
- this.deleteProject("P");
- projects = model.getJavaProjects();
- assertTrue(
- "Project P should not be present any longer",
- this.indexOf("P", projects) == -1
- );
- } finally {
- this.deleteProject("P");
- }
-}
-/*
- * Ensure that a non-java project that is added does not appears in the list of known java project.
- */
-public void testGetJavaProjects2() throws CoreException {
- IJavaModel model = this.getJavaModel();
- IJavaProject[] projects = model.getJavaProjects();
- assertTrue(
- "Project P should not be present already",
- this.indexOf("P", projects) == -1
- );
- try {
- this.createProject("P");
- projects = model.getJavaProjects();
- assertTrue(
- "Project P should not be present",
- this.indexOf("P", projects) == -1
- );
- } finally {
- this.deleteProject("P");
- }
-}
-
-}
-
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
deleted file mode 100644
index 0ab8df6..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java
+++ /dev/null
@@ -1,592 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-import org.eclipse.jdt.core.*;
-
-import java.io.IOException;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JavaProjectTests extends AbstractJavaModelTests {
-public JavaProjectTests(String name) {
- super(name);
-}
-
-public static Test suite() {
- TestSuite suite = new Suite(JavaProjectTests.class.getName());
- suite.addTest(new JavaProjectTests("testProjectGetChildren"));
- suite.addTest(new JavaProjectTests("testProjectGetPackageFragments"));
- suite.addTest(new JavaProjectTests("testRootGetPackageFragments"));
- suite.addTest(new JavaProjectTests("testInternalArchiveCorrespondingResource"));
- suite.addTest(new JavaProjectTests("testExternalArchiveCorrespondingResource"));
- suite.addTest(new JavaProjectTests("testProjectCorrespondingResource"));
- suite.addTest(new JavaProjectTests("testPackageFragmentCorrespondingResource"));
- suite.addTest(new JavaProjectTests("testPackageFragmentHasSubpackages"));
- suite.addTest(new JavaProjectTests("testIsDefaultPackage"));
- suite.addTest(new JavaProjectTests("testPackageFragmentRootCorrespondingResource"));
- suite.addTest(new JavaProjectTests("testJarPackageFragmentCorrespondingResource"));
- suite.addTest(new JavaProjectTests("testCompilationUnitCorrespondingResource"));
- suite.addTest(new JavaProjectTests("testClassFileCorrespondingResource"));
- suite.addTest(new JavaProjectTests("testArchiveClassFileCorrespondingResource"));
- suite.addTest(new JavaProjectTests("testBinaryTypeCorrespondingResource"));
- suite.addTest(new JavaProjectTests("testSourceMethodCorrespondingResource"));
- suite.addTest(new JavaProjectTests("testOutputLocationNotAddedAsPackageFragment"));
- suite.addTest(new JavaProjectTests("testOutputLocationNestedInRoot"));
- suite.addTest(new JavaProjectTests("testChangeOutputLocation"));
- suite.addTest(new JavaProjectTests("testFindElementPackage"));
- suite.addTest(new JavaProjectTests("testFindElementClassFile"));
- suite.addTest(new JavaProjectTests("testFindElementCompilationUnit"));
- suite.addTest(new JavaProjectTests("testFindElementCompilationUnitDefaultPackage"));
- suite.addTest(new JavaProjectTests("testFindElementInvalidPath"));
- suite.addTest(new JavaProjectTests("testProjectClose"));
- suite.addTest(new JavaProjectTests("testPackageFragmentRenameAndCreate"));
- suite.addTest(new JavaProjectTests("testFolderWithDotName"));
- suite.addTest(new JavaProjectTests("testPackageFragmentNonJavaResources"));
- suite.addTest(new JavaProjectTests("testPackageFragmentRootNonJavaResources"));
- suite.addTest(new JavaProjectTests("testAddNonJavaResourcePackageFragmentRoot"));
- suite.addTest(new JavaProjectTests("testDeletePackageWithAutobuild"));
- return suite;
-}
-public void setUpSuite() throws Exception {
- super.setUpSuite();
- setUpJavaProject("JavaProjectTests");
- setUpJavaProject("JavaProjectSrcTests");
-}
-public void tearDownSuite() throws Exception {
- deleteProject("JavaProjectTests");
- deleteProject("JavaProjectSrcTests");
- super.tearDownSuite();
-}
-
-
-/**
- * Test adding a non-java resource in a package fragment root that correspond to
- * the project.
- * (Regression test for PR #1G58NB8)
- */
-public void testAddNonJavaResourcePackageFragmentRoot() throws JavaModelException, CoreException {
- // get resources of source package fragment root at project level
- IPackageFragmentRoot root = getPackageFragmentRoot("JavaProjectTests", "");
- Object[] resources = root.getNonJavaResources();
- assertEquals("incorrect number of non java resources", 2, resources.length); // .classpath and .project files
- assertTrue("resource should be an IFile", resources[0] instanceof IFile);
- IFile resource = (IFile)resources[0];
- IPath newPath = root.getUnderlyingResource().getFullPath().append("TestNonJavaResource.abc");
- try {
- // copy and rename resource
- resource.copy(
- newPath,
- true,
- null);
-
- // ensure the new resource is present
- root.getParent().getUnderlyingResource().refreshLocal(1, null);
- resources = root.getNonJavaResources();
- assertEquals("incorrect number of non java resources", 2, resources.length);
- } finally {
- // clean up
- resource.getWorkspace().getRoot().getFile(newPath).delete(true, null);
- }
-}
-/**
- * Test that a class file in a jar has no corresponding resource.
- */
-public void testArchiveClassFileCorrespondingResource() throws JavaModelException {
- IPackageFragmentRoot root = getPackageFragmentRoot("JavaProjectTests", "lib.jar");
- IPackageFragment element = root.getPackageFragment("p");
- IClassFile cf= element.getClassFile("X.class");
- IResource corr = cf.getCorrespondingResource();
- assertTrue("incorrect corresponding resource", corr == null);
-}
-/**
- * Test that a binary type
- * has a corresponding resource.
- */
-public void testBinaryTypeCorrespondingResource() throws JavaModelException {
- IClassFile element= getClassFile("JavaProjectTests", "", "p", "Y.class");
- IType type= element.getType();
- IResource corr= type.getCorrespondingResource();
- assertTrue("incorrect corresponding resource", corr == null);
-}
-/**
- * When the output location is changed, package fragments can be added/removed
- */
-public void testChangeOutputLocation() throws JavaModelException, CoreException {
- IJavaProject project= getJavaProject("JavaProjectTests");
- IPackageFragmentRoot root= getPackageFragmentRoot("JavaProjectTests", "");
- IContainer underLyingResource = (IContainer)project.getUnderlyingResource();
- IFolder folder= underLyingResource.getFolder(new Path("output"));
-
- try {
- startDeltas();
- project.setOutputLocation(folder.getFullPath(), null);
- IPackageFragment fragment= root.getPackageFragment("bin");
- assertTrue("bin package fragment should appear", getDeltaFor(fragment).getKind() == IJavaElementDelta.ADDED);
- } finally {
- stopDeltas();
- try {
- startDeltas();
- folder= underLyingResource.getFolder(new Path("bin"));
- project.setOutputLocation(folder.getFullPath(), null);
- IPackageFragment fragment= root.getPackageFragment("bin");
- assertTrue("bin package fragment should be removed", getDeltaFor(fragment).getKind() == IJavaElementDelta.REMOVED);
- } finally {
- stopDeltas();
- }
- }
-}
-/**
- * Test that a class file
- * has a corresponding resource.
- */
-public void testClassFileCorrespondingResource() throws JavaModelException {
- IClassFile element= getClassFile("JavaProjectTests", "", "p", "Y.class");
- IResource corr= element.getCorrespondingResource();
- IResource res= getWorkspace().getRoot().getProject("JavaProjectTests").getFolder("p").getFile("Y.class");
- assertTrue("incorrect corresponding resource", corr.equals(res));
-}
-/**
- * Test that a compilation unit
- * has a corresponding resource.
- */
-public void testCompilationUnitCorrespondingResource() throws JavaModelException {
- ICompilationUnit element= getCompilationUnit("JavaProjectTests", "", "q", "A.java");
- IResource corr= element.getCorrespondingResource();
- IResource res= getWorkspace().getRoot().getProject("JavaProjectTests").getFolder("q").getFile("A.java");
- assertTrue("incorrect corresponding resource", corr.equals(res));
- assertEquals("Project is incorrect for the compilation unit", "JavaProjectTests", corr.getProject().getName());
-}
-/**
- * Tests the fix for "1FWNMKD: ITPJCORE:ALL - Package Fragment Removal not reported correctly"
- */
-public void testDeletePackageWithAutobuild() throws JavaModelException, CoreException, IOException {
- // close all project except JavaProjectTests so as to avoid side effects while autobuilding
- IProject[] projects = getWorkspaceRoot().getProjects();
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- if (project.getName().equals("JavaProjectTests")) continue;
- project.close(null);
- }
-
- // turn autobuilding on
- IWorkspace workspace = getWorkspace();
- boolean autoBuild = workspace.isAutoBuilding();
- IWorkspaceDescription description = workspace.getDescription();
- description.setAutoBuilding(true);
- workspace.setDescription(description);
-
- startDeltas();
- IPackageFragment frag = getPackageFragment("JavaProjectTests", "", "x.y");
- IFolder folder = (IFolder) frag.getUnderlyingResource();
- try {
- folder.delete(true, null);
- assertTrue("should have been notified of package removal", getDeltaFor(frag) != null);
- } finally {
- stopDeltas();
-
- // turn autobuild off
- description.setAutoBuilding(autoBuild);
- workspace.setDescription(description);
-
- // reopen projects
- projects = getWorkspaceRoot().getProjects();
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
- if (project.getName().equals("JavaProjectTests")) continue;
- project.open(null);
- }
- }
-}
-/**
- * Test that an (external) jar
- * has no corresponding resource.
- */
-public void testExternalArchiveCorrespondingResource() throws JavaModelException {
- IJavaProject project= getJavaProject("JavaProjectTests");
- IPackageFragmentRoot element= project.getPackageFragmentRoot(getExternalJCLPath());
- IResource corr= element.getCorrespondingResource();
- assertTrue("incorrect corresponding resource", corr == null);
-}
-/**
- * Test that a compilation unit can be found for a binary type
- */
-public void testFindElementClassFile() throws JavaModelException {
- IJavaProject project= getJavaProject("JavaProjectTests");
- IJavaElement element= project.findElement(new Path("java/lang/Object.java"));
- assertTrue("CU not found" , element != null && element.getElementType() == IJavaElement.CLASS_FILE
- && element.getElementName().equals("Object.class"));
-}
-/**
- * Test that a compilation unit can be found
- */
-public void testFindElementCompilationUnit() throws JavaModelException {
- IJavaProject project= getJavaProject("JavaProjectTests");
- IJavaElement element= project.findElement(new Path("x/y/Main.java"));
- assertTrue("CU not found" , element != null && element.getElementType() == IJavaElement.COMPILATION_UNIT
- && element.getElementName().equals("Main.java"));
-}
-/**
- * Test that a compilation unit can be found in a default package
- */
-public void testFindElementCompilationUnitDefaultPackage() throws JavaModelException {
- IJavaProject project= getJavaProject("JavaProjectTests");
- IJavaElement element= project.findElement(new Path("B.java"));
- assertTrue("CU not found" , element != null && element.getElementType() == IJavaElement.COMPILATION_UNIT
- && element.getElementName().equals("B.java"));
-}
-/**
- * Test that an invlaid path throws an exception
- */
-public void testFindElementInvalidPath() throws JavaModelException {
- IJavaProject project= getJavaProject("JavaProjectTests");
- boolean failed= false;
- try {
- project.findElement(null);
- } catch (JavaModelException e) {
- failed= true;
- assertTrue("wrong status code" , e.getStatus().getCode() == IJavaModelStatusConstants.INVALID_PATH);
- }
- assertTrue("Shold have failed", failed);
-
- failed = false;
- try {
- project.findElement(new Path("/something/absolute"));
- } catch (JavaModelException e) {
- failed= true;
- assertTrue("wrong status code" , e.getStatus().getCode() == IJavaModelStatusConstants.INVALID_PATH);
- }
- assertTrue("Shold have failed", failed);
-
- IJavaElement element= project.findElement(new Path("does/not/exist/HelloWorld.java"));
- assertTrue("should get no element", element == null);
-}
-/**
- * Test that a package can be found
- */
-public void testFindElementPackage() throws JavaModelException {
- IJavaProject project= getJavaProject("JavaProjectTests");
- IJavaElement element= project.findElement(new Path("x/y"));
- assertTrue("package not found" , element != null && element.getElementType() == IJavaElement.PACKAGE_FRAGMENT
- && element.getElementName().equals("x.y"));
-}
-/**
- * Test that a folder with a dot name does not relate to a package fragment
- */
-public void testFolderWithDotName() throws JavaModelException, CoreException {
- IPackageFragmentRoot root= getPackageFragmentRoot("JavaProjectTests", "");
- IContainer folder= (IContainer)root.getCorrespondingResource();
- try {
- startDeltas();
- folder.getFolder(new Path("org.eclipse")).create(false, true, null);
- assertTrue("should be one Java Delta", this.deltaListener.deltas.length == 1);
-
- stopDeltas();
- IJavaElement[] children = root.getChildren();
- IPackageFragment bogus = root.getPackageFragment("org.eclipse");
- for (int i = 0; i < children.length; i++) {
- assertTrue("org.eclipse should not be present as child", !children[i].equals(bogus));
- }
- assertTrue("org.eclipse should not exist", !bogus.exists());
- } finally {
- folder.getFolder(new Path("org.eclipse")).delete(true, null);
- }
-}
-/**
- * Test that an (internal) jar
- * has a corresponding resource.
- */
-public void testInternalArchiveCorrespondingResource() throws JavaModelException {
- IPackageFragmentRoot element= getPackageFragmentRoot("JavaProjectTests", "lib.jar");
- IResource corr= element.getCorrespondingResource();
- IResource res= getWorkspace().getRoot().getProject("JavaProjectTests").getFile("lib.jar");
- assertTrue("incorrect corresponding resource", corr.equals(res));
-}
-/**
- * Test IJavaPackageFragment.isDefaultPackage().
- */
-public void testIsDefaultPackage() throws JavaModelException {
- IPackageFragment def = getPackageFragment("JavaProjectTests", "", "");
- assertTrue("should be default package", def.isDefaultPackage());
- IPackageFragment y =
- getPackageFragment("JavaProjectTests", "", "x.y");
- assertTrue("x.y should not be default pakackage", !y.isDefaultPackage());
-
- IPackageFragment def2 = getPackageFragment("JavaProjectTests", "lib.jar", "");
- assertTrue("lib.jar should have default package", def2.isDefaultPackage());
- IPackageFragment p =
- getPackageFragment("JavaProjectTests", "lib.jar", "p");
- assertTrue("p should not be default package", !p.isDefaultPackage());
-}
-/**
- * Test that a package fragment in a jar has no corresponding resource.
- */
-public void testJarPackageFragmentCorrespondingResource() throws JavaModelException {
- IPackageFragmentRoot root = getPackageFragmentRoot("JavaProjectTests", "lib.jar");
- IPackageFragment element = root.getPackageFragment("p");
- IResource corr = element.getCorrespondingResource();
- assertTrue("incorrect corresponding resource", corr == null);
-}
-/**
- * Test that an output location can't be set to a location inside a package fragment
- * root, except the root project folder.
- */
-public void testOutputLocationNestedInRoot() throws JavaModelException, CoreException {
- IPackageFragmentRoot root= getPackageFragmentRoot("JavaProjectSrcTests", "src");
- IFolder folder= (IFolder) root.getUnderlyingResource();
- IJavaProject project= getJavaProject("JavaProjectSrcTests");
- folder= folder.getFolder("x");
- boolean failed= false;
- try {
- project.setOutputLocation(folder.getFullPath(), null);
- } catch (JavaModelException e) {
- assertTrue("should be an invalid classpath", e.getStatus().getCode() == IJavaModelStatusConstants.INVALID_CLASSPATH);
- failed= true;
- }
- assertTrue("should have failed", failed);
-
-}
-/**
- * Test that an output location folder is not created as a package fragment.
- */
-public void testOutputLocationNotAddedAsPackageFragment() throws JavaModelException, CoreException {
- IPackageFragmentRoot root= getPackageFragmentRoot("JavaProjectTests", "");
- IJavaElement[] packages= root.getChildren();
- assertEquals("unepected number of packages", 5, packages.length);
- assertTrue("should be default", packages[0].getElementName().equals(""));
-
-
- // create a nested folder in the output location and make sure it does not appear
- // as a package fragment
- IContainer underLyingResource = (IContainer)root.getUnderlyingResource();
- IFolder newFolder= underLyingResource.getFolder(new Path("bin")).getFolder(new Path("nested"));
- try {
- startDeltas();
- newFolder.create(false, true, null);
- assertTrue("should be one delta (resource deltas)", this.deltaListener.deltas != null || this.deltaListener.deltas.length == 1);
- } finally {
- stopDeltas();
- newFolder.delete(true, null);
- }
-}
-/**
- * Test that a package fragment (non-external, non-jar, non-default)
- * has a corresponding resource.
- */
-public void testPackageFragmentCorrespondingResource() throws JavaModelException {
- IPackageFragment element= getPackageFragment("JavaProjectTests", "", "x.y");
- IResource corr= element.getCorrespondingResource();
- IResource res= getWorkspace().getRoot().getProject("JavaProjectTests").getFolder("x").getFolder("y");
- assertTrue("incorrect corresponding resource", corr.equals(res));
-}
-/**
- * Test that a package fragment (non-external, non-jar, non-default)
- * has a corresponding resource.
- */
-public void testPackageFragmentHasSubpackages() throws JavaModelException {
- IPackageFragment def= getPackageFragment("JavaProjectTests", "", "");
- IPackageFragment x= getPackageFragment("JavaProjectTests", "", "x");
- IPackageFragment y= getPackageFragment("JavaProjectTests", "", "x.y");
- assertTrue("default should have subpackages", def.hasSubpackages());
- assertTrue("x should have subpackages", x.hasSubpackages());
- assertTrue("x.y should NOT have subpackages", !y.hasSubpackages());
-
- IPackageFragment java = getPackageFragment("JavaProjectTests", getExternalJCLPath(), "java");
- IPackageFragment lang= getPackageFragment("JavaProjectTests", getExternalJCLPath(), "java.lang");
-
- assertTrue("java should have subpackages", java.hasSubpackages());
- assertTrue("java.lang should NOT have subpackages", !lang.hasSubpackages());
-}
-/**
- * Test getting the non-java resources from a package fragment.
- */
-public void testPackageFragmentNonJavaResources() throws JavaModelException {
- // regular source package with resources
- IPackageFragment pkg = getPackageFragment("JavaProjectTests", "", "x");
- Object[] resources = pkg.getNonJavaResources();
- assertEquals("incorrect number of non java resources (test case 1)", 2, resources.length);
-
- // regular source package without resources
- pkg = getPackageFragment("JavaProjectTests", "", "x.y");
- resources = pkg.getNonJavaResources();
- assertEquals("incorrect number of non java resources (test case 2)", 0, resources.length);
-
- // source default package with potentialy resources
- pkg = getPackageFragment("JavaProjectTests", "", "");
- resources = pkg.getNonJavaResources();
- assertEquals("incorrect number of non java resources (test case 3)", 0, resources.length);
-
- // regular zip package with resources
- // TO DO
-
- // regular zip package without resources
- pkg = getPackageFragment("JavaProjectTests", "lib.jar", "p");
- resources = pkg.getNonJavaResources();
- assertEquals("incorrect number of non java resources (test case 5)", 0, resources.length);
-
- // zip default package with potentialy resources
- // TO DO
-
- // zip default package with potentialy no resources
- pkg = getPackageFragment("JavaProjectTests", "lib.jar", "");
- resources = pkg.getNonJavaResources();
- assertEquals("incorrect number of non java resources (test case 7)", 0, resources.length);
-
-}
-/**
- * Tests that after a package "foo" has been renamed into "bar", it is possible to recreate
- * a "foo" package.
- * @see 1FWX0HY: ITPCORE:WIN98 - Problem after renaming a Java package
- */
-public void testPackageFragmentRenameAndCreate() throws JavaModelException, CoreException {
- IPackageFragment y = getPackageFragment("JavaProjectTests", "", "x.y");
- IFolder yFolder = (IFolder) y.getUnderlyingResource();
- IPath yPath = yFolder.getFullPath();
- IPath fooPath = yPath.removeLastSegments(1).append("foo");
-
- yFolder.move(fooPath, true, null);
- try {
- yFolder.create(true, true, null);
- } catch (Throwable e) {
- e.printStackTrace();
- assertTrue("should be able to recreate the y folder", false);
- }
- // restore the original state
- yFolder.delete(true, null);
- IPackageFragment foo = getPackageFragment("JavaProjectTests", "", "x.foo");
- IFolder fooFolder = (IFolder) foo.getUnderlyingResource();
- fooFolder.move(yPath, true, null);
-}
-/**
- * Test that a package fragment root (non-external, non-jar, non-default root)
- * has a corresponding resource.
- */
-public void testPackageFragmentRootCorrespondingResource() throws JavaModelException {
- IPackageFragmentRoot element= getPackageFragmentRoot("JavaProjectTests", "");
- IResource corr= element.getCorrespondingResource();
- IResource res= getWorkspace().getRoot().getProject("JavaProjectTests");
- assertTrue("incorrect corresponding resource", corr.equals(res));
- assertEquals("Project incorrect for folder resource", "JavaProjectTests", corr.getProject().getName());
-}
-/**
- * Test getting the non-java resources from a package fragment root.
- */
-public void testPackageFragmentRootNonJavaResources() throws JavaModelException {
- // source package fragment root with resources
- IPackageFragmentRoot root = getPackageFragmentRoot("JavaProjectTests", "");
- Object[] resources = root.getNonJavaResources();
- assertEquals("incorrect number of non java resources (test case 1)", 2, resources.length);
-
- // source package fragment root without resources
- root = getPackageFragmentRoot("JavaProjectSrcTests", "src");
- resources = root.getNonJavaResources();
- assertEquals("incorrect number of non java resources (test case 2)", 0, resources.length);
-
- // zip package fragment root with resources
- // TO DO
-
- // zip package fragment root without resources
- root = getPackageFragmentRoot("JavaProjectTests", "lib.jar");
- resources = root.getNonJavaResources();
- assertEquals("incorrect number of non java resources (test case 4)", 0, resources.length);
-}
-/**
- * Tests that closing and opening a project triggers the correct deltas.
- */
-public void testProjectClose() throws JavaModelException, CoreException {
- IJavaProject jproject= getJavaProject("JavaProjectTests");
- IPackageFragmentRoot[] originalRoots = jproject.getPackageFragmentRoots();
- IProject project= jproject.getProject();
-
- try {
- startDeltas();
- project.close(null);
- IJavaElementDelta delta= getDeltaFor(jproject);
- assertTrue("should be a removed delta", delta != null && delta.getKind() == IJavaElementDelta.REMOVED);
- } finally {
- try {
- clearDeltas();
-
- project.open(null);
- IJavaElementDelta delta= getDeltaFor(jproject);
- assertTrue("should be an added delta", delta != null && delta.getKind() == IJavaElementDelta.ADDED);
-
- IPackageFragmentRoot[] openRoots = jproject.getPackageFragmentRoots();
- assertTrue("should have same number of roots", openRoots.length == originalRoots.length);
- for (int i = 0; i < openRoots.length; i++) {
- assertTrue("root not the same", openRoots[i].equals(originalRoots[i]));
- }
- } finally {
- stopDeltas();
- }
- }
-}
-/**
- * Test that a project has a corresponding resource.
- */
-public void testProjectCorrespondingResource() throws JavaModelException {
- IJavaProject project= getJavaProject("JavaProjectTests");
- IResource corr= project.getCorrespondingResource();
- IResource res= getWorkspace().getRoot().getProject("JavaProjectTests");
- assertTrue("incorrect corresponding resource", corr.equals(res));
-}
-/**
- * Test that the correct children exist in a project
- */
-public void testProjectGetChildren() throws JavaModelException {
- IJavaProject project = getJavaProject("JavaProjectTests");
- IJavaElement[] roots= project.getChildren();
- assertTrue("should be package 3 package fragment root children in 'JavaProjectTests', were " + roots.length , roots.length == 3);
-}
-/**
- * Test that the correct package fragments exist in the project.
- */
-public void testProjectGetPackageFragments() throws JavaModelException {
- IJavaProject project= getJavaProject("JavaProjectTests");
- IPackageFragment[] fragments= project.getPackageFragments();
- assertTrue("should be package 12 package fragments in 'JavaProjectTests', were " + fragments.length , fragments.length == 12);
-}
-/**
- * Test that the correct package fragments exist in the project.
- */
-public void testRootGetPackageFragments() throws JavaModelException {
- IPackageFragmentRoot root= getPackageFragmentRoot("JavaProjectTests", "");
- IJavaElement[] fragments= root.getChildren();
- assertTrue("should be package 5 package fragments in source root, were " + fragments.length , fragments.length == 5);
-
- root= getPackageFragmentRoot("JavaProjectTests", "lib.jar");
- fragments= root.getChildren();
- assertTrue("should be package 3 package fragments in lib.jar, were " + fragments.length , fragments.length == 3);
-}
-/**
- * Test that a method
- * has no corresponding resource.
- */
-public void testSourceMethodCorrespondingResource() throws JavaModelException {
- ICompilationUnit element= getCompilationUnit("JavaProjectTests", "", "q", "A.java");
- IMethod[] methods = element.getType("A").getMethods();
- assertTrue("missing methods", methods.length > 0);
- IResource corr= methods[0].getCorrespondingResource();
- assertTrue("incorrect corresponding resource", corr == null);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java
deleted file mode 100644
index 58014ab..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java
+++ /dev/null
@@ -1,2419 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Hashtable;
-
-import org.eclipse.jdt.internal.core.JavaModelStatus;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-
-import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.search.*;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
-
-import junit.framework.*;
-
-/**
- * Tests the Java search engine where results are JavaElements and source positions.
- */
-public class JavaSearchTests extends AbstractJavaModelTests implements IJavaSearchConstants {
-
-/**
- * Collects results as a string.
- */
-public class JavaSearchResultCollector implements IJavaSearchResultCollector {
- public StringBuffer results = new StringBuffer();
- public boolean showAccuracy = false;
- public void aboutToStart() {
- }
- public void accept(IResource resource, int start, int end, IJavaElement element, int accuracy) {
- try {
- if (results.length() > 0) results.append("\n");
- IPath path = resource.getProjectRelativePath();
- if (path.segmentCount() == 0) {
- IJavaElement root = element;
- while (root != null && !(root instanceof IPackageFragmentRoot)) {
- root = root.getParent();
- }
- if (root != null) {
- IPackageFragmentRoot pkgFragmentRoot = (IPackageFragmentRoot)root;
- if (pkgFragmentRoot.isExternal()) {
- results.append(pkgFragmentRoot.getPath().toOSString());
- } else {
- results.append(pkgFragmentRoot.getPath());
- }
- }
- } else {
- results.append(path);
- }
- ICompilationUnit unit = null;
- if (element instanceof IMethod) {
- results.append(" ");
- IMethod method = (IMethod)element;
- results.append(method.getDeclaringType().getFullyQualifiedName());
- if (!method.isConstructor()) {
- results.append(".");
- results.append(method.getElementName());
- }
- results.append("(");
- String[] parameters = method.getParameterTypes();
- for (int i = 0; i < parameters.length; i++) {
- results.append(Signature.toString(parameters[i]));
- if (i < parameters.length-1) {
- results.append(", ");
- }
- }
- results.append(")");
- if (!method.isConstructor()) {
- results.append(" -> ");
- results.append(Signature.toString(method.getReturnType()));
- }
- unit = method.getCompilationUnit();
- } else if (element instanceof IType) {
- results.append(" ");
- IType type = (IType)element;
- results.append(type.getFullyQualifiedName());
- unit = type.getCompilationUnit();
- } else if (element instanceof IField) {
- results.append(" ");
- IField field = (IField)element;
- results.append(field.getDeclaringType().getFullyQualifiedName());
- results.append(".");
- results.append(field.getElementName());
- unit = field.getCompilationUnit();
- } else if (element instanceof IInitializer) {
- results.append(" ");
- IInitializer initializer = (IInitializer)element;
- results.append(initializer.getDeclaringType().getFullyQualifiedName());
- results.append(".");
- if (Flags.isStatic(initializer.getFlags())) {
- results.append("static ");
- }
- results.append("{}");
- unit = initializer.getCompilationUnit();
- } else if (element instanceof IPackageFragment) {
- results.append(" ");
- results.append(element.getElementName());
- }
- if (resource instanceof IFile) {
- char[] contents = null;
- if ("java".equals(resource.getFileExtension())) {
- if (!resource.equals(element.getUnderlyingResource())) {
- // working copy
- contents = unit.getBuffer().getCharacters();
- } else {
- contents = new org.eclipse.jdt.internal.compiler.batch.CompilationUnit(
- null,
- ((IFile) resource).getLocation().toFile().getPath(),
- null).getContents();
- }
- }
- if (start == -1 || contents != null) { // retrieving attached source not implemented here
- results.append(" [");
- if (start > -1) {
- results.append(CharOperation.subarray(contents, start, end));
- } else {
- results.append("No source");
- }
- results.append("]");
- }
- }
- if (showAccuracy) {
- results.append(" ");
- switch (accuracy) {
- case EXACT_MATCH:
- results.append("EXACT_MATCH");
- break;
- case POTENTIAL_MATCH:
- results.append("POTENTIAL_MATCH");
- break;
- }
- }
- } catch (JavaModelException e) {
- results.append("\n");
- results.append(e.toString());
- }
- }
- public void done() {
- }
- public IProgressMonitor getProgressMonitor() {
- return null;
- }
- public String toString() {
- return results.toString();
- }
-}
-public JavaSearchTests(String name) {
- super(name);
-}
-private IJavaSearchScope getJavaSearchScope() {
- return SearchEngine.createJavaSearchScope(new IJavaProject[] {getJavaProject("JavaSearch")});
-}
-public void setUpSuite() throws Exception {
- super.setUpSuite();
-
- setUpJavaProject("JavaSearch");
-}
-public void tearDownSuite() throws Exception {
- deleteProject("JavaSearch");
-
- super.tearDownSuite();
-}
-
-
-public static Test suite() {
- TestSuite suite = new Suite(JavaSearchTests.class.getName());
-
- // package declaration
- suite.addTest(new JavaSearchTests("testSimplePackageDeclaration"));
- suite.addTest(new JavaSearchTests("testVariousPackageDeclarations"));
-
- // package reference
- suite.addTest(new JavaSearchTests("testSimplePackageReference"));
- suite.addTest(new JavaSearchTests("testPackageReference1"));
- suite.addTest(new JavaSearchTests("testPackageReference2"));
- suite.addTest(new JavaSearchTests("testVariousPackageReference"));
- suite.addTest(new JavaSearchTests("testAccuratePackageReference"));
- suite.addTest(new JavaSearchTests("testPatternMatchPackageReference"));
-
- // type declaration
- suite.addTest(new JavaSearchTests("testSimpleTypeDeclaration"));
- suite.addTest(new JavaSearchTests("testTypeDeclarationInJar"));
- suite.addTest(new JavaSearchTests("testTypeDeclarationInJar2"));
- suite.addTest(new JavaSearchTests("testTypeDeclarationInPackageScope"));
- suite.addTest(new JavaSearchTests("testTypeDeclarationInPackageScope2"));
- suite.addTest(new JavaSearchTests("testMemberTypeDeclaration"));
- suite.addTest(new JavaSearchTests("testPatternMatchTypeDeclaration"));
-
- // type reference
- suite.addTest(new JavaSearchTests("testSimpleTypeReference"));
- suite.addTest(new JavaSearchTests("testTypeReference"));
- suite.addTest(new JavaSearchTests("testTypeReferenceInInitializer"));
- suite.addTest(new JavaSearchTests("testTypeReferenceAsSingleNameReference"));
- suite.addTest(new JavaSearchTests("testMemberTypeReference"));
- suite.addTest(new JavaSearchTests("testMemberTypeReference2"));
- suite.addTest(new JavaSearchTests("testObjectMemberTypeReference"));
- suite.addTest(new JavaSearchTests("testTypeReferenceInQualifiedNameReference"));
- suite.addTest(new JavaSearchTests("testTypeReferenceInQualifiedNameReference2"));
- suite.addTest(new JavaSearchTests("testTypeReferenceInQualifiedNameReference3"));
- suite.addTest(new JavaSearchTests("testTypeReferenceInQualifiedNameReference4"));
- suite.addTest(new JavaSearchTests("testTypeReferenceNotInClasspath"));
- suite.addTest(new JavaSearchTests("testVariousTypeReferences"));
- suite.addTest(new JavaSearchTests("testTypeReferenceInImport"));
- suite.addTest(new JavaSearchTests("testTypeReferenceInImport2"));
- suite.addTest(new JavaSearchTests("testTypeReferenceInArray"));
- suite.addTest(new JavaSearchTests("testTypeReferenceInArray2"));
- suite.addTest(new JavaSearchTests("testNegativeTypeReference"));
- suite.addTest(new JavaSearchTests("testTypeReferenceInThrows"));
- suite.addTest(new JavaSearchTests("testInnacurateTypeReference1"));
- suite.addTest(new JavaSearchTests("testInnacurateTypeReference2"));
- suite.addTest(new JavaSearchTests("testInnacurateTypeReference3"));
- suite.addTest(new JavaSearchTests("testTypeReferenceInCast"));
-
- // type occurences
- suite.addTest(new JavaSearchTests("testTypeOccurence"));
- suite.addTest(new JavaSearchTests("testTypeOccurenceWithDollar"));
-
- // interface implementor
- suite.addTest(new JavaSearchTests("testInterfaceImplementors"));
- suite.addTest(new JavaSearchTests("testInterfaceImplementors2"));
-
- // method declaration
- suite.addTest(new JavaSearchTests("testSimpleMethodDeclaration"));
- suite.addTest(new JavaSearchTests("testSimpleConstructorDeclaration"));
- suite.addTest(new JavaSearchTests("testInnerMethodDeclaration"));
- suite.addTest(new JavaSearchTests("testMethodDeclarationInHierarchyScope1"));
- suite.addTest(new JavaSearchTests("testMethodDeclarationInHierarchyScope2"));
- suite.addTest(new JavaSearchTests("testMethodDeclarationInPackageScope"));
- suite.addTest(new JavaSearchTests("testMethodDeclarationInJar"));
- suite.addTest(new JavaSearchTests("testConstructorDeclarationInJar"));
-
- // method reference
- suite.addTest(new JavaSearchTests("testSimpleMethodReference"));
- suite.addTest(new JavaSearchTests("testSimpleConstructorReference1"));
- suite.addTest(new JavaSearchTests("testSimpleConstructorReference2"));
- suite.addTest(new JavaSearchTests("testStaticMethodReference1"));
- suite.addTest(new JavaSearchTests("testStaticMethodReference2"));
- suite.addTest(new JavaSearchTests("testConstructorReferenceExplicitConstructorCall1"));
- suite.addTest(new JavaSearchTests("testConstructorReferenceExplicitConstructorCall2"));
- suite.addTest(new JavaSearchTests("testInnerMethodReference"));
- suite.addTest(new JavaSearchTests("testConstructorReferenceInFieldInitializer"));
- suite.addTest(new JavaSearchTests("testMethodReferenceThroughSuper"));
- suite.addTest(new JavaSearchTests("testMethodReferenceInInnerClass"));
- suite.addTest(new JavaSearchTests("testMethodReferenceInAnonymousClass"));
- suite.addTest(new JavaSearchTests("testMethodReferenceThroughArray"));
- suite.addTest(new JavaSearchTests("testMethodReference1"));
- suite.addTest(new JavaSearchTests("testMethodReference2"));
- suite.addTest(new JavaSearchTests("testMethodReference3"));
- suite.addTest(new JavaSearchTests("testMethodReference4"));
-
- // field declaration
- suite.addTest(new JavaSearchTests("testSimpleFieldDeclaration"));
- suite.addTest(new JavaSearchTests("testFieldDeclarationInJar"));
- suite.addTest(new JavaSearchTests("testFieldDeclarationArrayType"));
-
- // field reference
- suite.addTest(new JavaSearchTests("testSimpleFieldReference"));
- suite.addTest(new JavaSearchTests("testSimpleReadFieldReference"));
- suite.addTest(new JavaSearchTests("testSimpleWriteFieldReference"));
- suite.addTest(new JavaSearchTests("testMultipleFieldReference"));
- suite.addTest(new JavaSearchTests("testStaticFieldReference"));
- suite.addTest(new JavaSearchTests("testFieldReference"));
- suite.addTest(new JavaSearchTests("testFieldReference2"));
- suite.addTest(new JavaSearchTests("testFieldReference3"));
- suite.addTest(new JavaSearchTests("testFieldReference4"));
- suite.addTest(new JavaSearchTests("testFieldReference5"));
- suite.addTest(new JavaSearchTests("testFieldReference6"));
- suite.addTest(new JavaSearchTests("testFieldReferenceInInnerClass"));
- suite.addTest(new JavaSearchTests("testFieldReferenceInAnonymousClass"));
- suite.addTest(new JavaSearchTests("testFieldReferenceThroughSubclass"));
- suite.addTest(new JavaSearchTests("testReadWriteFieldReferenceInCompoundExpression"));
- suite.addTest(new JavaSearchTests("testReadWriteAccessInQualifiedNameReference"));
- suite.addTest(new JavaSearchTests("testFieldReferenceInBrackets"));
-
- // or pattern
- suite.addTest(new JavaSearchTests("testOrPattern"));
-
- // declarations of accessed fields
- suite.addTest(new JavaSearchTests("testDeclarationOfAccessedFields1"));
- suite.addTest(new JavaSearchTests("testDeclarationOfAccessedFields2"));
- suite.addTest(new JavaSearchTests("testDeclarationOfAccessedFields3"));
-
- // declarations of referenced types
- suite.addTest(new JavaSearchTests("testDeclarationOfReferencedTypes1"));
- suite.addTest(new JavaSearchTests("testDeclarationOfReferencedTypes2"));
- suite.addTest(new JavaSearchTests("testDeclarationOfReferencedTypes3"));
- suite.addTest(new JavaSearchTests("testDeclarationOfReferencedTypes4"));
- suite.addTest(new JavaSearchTests("testDeclarationOfReferencedTypes5"));
-
- // declarations of sent messages
- suite.addTest(new JavaSearchTests("testSimpleDeclarationsOfSentMessages"));
- suite.addTest(new JavaSearchTests("testDeclarationOfSentMessages"));
-
- // potential match in binary
- suite.addTest(new JavaSearchTests("testPotentialMatchInBinary"));
-
- // core exception
- suite.addTest(new JavaSearchTests("testCoreException"));
-
- // search scopes
- suite.addTest(new JavaSearchTests("testHierarchyScope"));
- suite.addTest(new JavaSearchTests("testSubCUSearchScope1"));
- suite.addTest(new JavaSearchTests("testSubCUSearchScope2"));
- suite.addTest(new JavaSearchTests("testSubCUSearchScope3"));
- suite.addTest(new JavaSearchTests("testExternalJarScope"));
-
- return suite;
-}
-/**
- * Regression test for 1GBK7B2: ITPJCORE:WINNT - package references: could be more precise
- */
-public void testAccuratePackageReference() throws JavaModelException, CoreException {
- IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "p3.p2");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- pkg,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/PackageReference/K.java [p3.p2]",
- resultCollector.toString());
-}
-/**
- * Constructor declaration in jar file test.
- */
-public void testConstructorDeclarationInJar() throws JavaModelException, CoreException {
- IType type = getClassFile("JavaSearch", "MyJar.jar", "p1", "A.class").getType();
- IMethod method = type.getMethod("A", new String[] {"Ljava.lang.String;"});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "MyJar.jar p1.A(java.lang.String) [No source]",
- resultCollector.toString());
-}
-/**
- * Constructor reference using an explicit constructor call.
- */
-public void testConstructorReferenceExplicitConstructorCall1() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "Y.java").getType("Y");
- IMethod method = type.getMethod("Y", new String[] {"I"});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p/Z.java p.Z(int) [super(i)]",
- resultCollector.toString());
-}
-/**
- * Constructor reference using an explicit constructor call.
- */
-public void testConstructorReferenceExplicitConstructorCall2() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
- IMethod method = type.getMethod("X", new String[] {"I"});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p/Y.java p.Y(int) [super(i)]\n" +
- "src/p/Y.java p.Y(boolean) [super(1)]",
- resultCollector.toString());
-}
-/**
- * Constructor reference in a field initializer.
- * (regression test for PR 1GKZ8VZ: ITPJCORE:WINNT - Search - did not find references to member constructor)
- */
-public void testConstructorReferenceInFieldInitializer() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "", "A.java").getType("A").getType("Inner");
- IMethod method = type.getMethod("Inner", new String[] {"I"});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/A.java A.field [new Inner(1)]\n" +
- "src/A.java A.field [new Inner(2)]",
- resultCollector.toString());
-}
-/**
- * CoreException thrown during accept.
- * (regression test for PR #1G3UI7A)
- */
-public void testCoreException() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
- IJavaSearchResultCollector resultCollector = new IJavaSearchResultCollector() {
- public void accept(IResource resource, int start, int end, IJavaElement enclosingElement, int accuracy) throws CoreException {
- throw new CoreException(new JavaModelStatus(-1, "test"));
- }
- public void aboutToStart() {}
- public void done() {}
- public IProgressMonitor getProgressMonitor() {
- return null;
- }
- };
- try {
- new SearchEngine().search(
- getWorkspace(),
- type,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- } catch (JavaModelException e) {
- Throwable wrappedException = e.getException();
- assertTrue("Unexpected wrapped exception", wrappedException instanceof CoreException);
- assertEquals("Unexpected CoreException has been thrown", "test", ((CoreException)wrappedException).getStatus().getMessage());
- return;
- }
- assertTrue("CoreException should have been thrown", false);
-}
-/**
- * Declaration of accessed fields test.
- * (regression test for bug 6538 searchDeclarationsOf* incorrect)
- */
-public void testDeclarationOfAccessedFields1() throws JavaModelException, CoreException {
- IMethod method =
- getCompilationUnit("JavaSearch", "src", "a5", "B.java").
- getType("C").getMethod("i", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().searchDeclarationsOfAccessedFields(
- getWorkspace(),
- method,
- resultCollector
- );
- assertEquals(
- "",
- resultCollector.toString());
-}
-/**
- * Declaration of accessed fields test.
- * (regression test for bug 6538 searchDeclarationsOf* incorrect)
- */
-public void testDeclarationOfAccessedFields2() throws JavaModelException, CoreException {
- IMethod method =
- getCompilationUnit("JavaSearch", "src", "a6", "A.java").
- getType("B").getMethod("m", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().searchDeclarationsOfAccessedFields(
- getWorkspace(),
- method,
- resultCollector
- );
- assertEquals(
- "src/a6/A.java a6.B.f [f]",
- resultCollector.toString());
-}
-/**
- * Declaration of accessed fields test.
- * (regression test for bug 10386 NPE in MatchLocator.lookupType)
- */
-public void testDeclarationOfAccessedFields3() throws JavaModelException, CoreException {
- IMethod method =
- getCompilationUnit("JavaSearch", "src", "b6", "A.java").
- getType("A").getMethod("foo", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().searchDeclarationsOfAccessedFields(
- getWorkspace(),
- method,
- resultCollector
- );
- assertEquals(
- "src/b6/A.java b6.A.field [field]",
- resultCollector.toString());
-}
-/**
- * Declaration of referenced types test.
- */
-public void testDeclarationOfReferencedTypes1() throws JavaModelException, CoreException {
- IMethod method =
- getCompilationUnit("JavaSearch", "src", "a3", "References.java").
- getType("References").getMethod("foo", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().searchDeclarationsOfReferencedTypes(
- getWorkspace(),
- method,
- resultCollector
- );
- assertEquals(
- "src/a3/b/B.java a3.b.B [B]\n" +
- "src/a3/X.java a3.X [X]\n" +
- "src/a3/Z.java a3.Z [Z]\n" +
- "src/a3/b/A.java a3.b.A [A]\n" +
- "src/a3/b/A.java a3.b.A$B$C [C]\n" +
- "src/a3/b/A.java a3.b.A$B [B]\n" +
- getExternalJCLPath() + " java.lang.Object\n" +
- "src/a3/Y.java a3.Y [Y]",
- resultCollector.toString());
-}
-/**
- * Declaration of referenced types test.
- * (Regression test for bug 6779 searchDeclarationsOfReferencedTyped - missing exception types)
- */
-public void testDeclarationOfReferencedTypes2() throws CoreException {
- IMethod method =
- getCompilationUnit("JavaSearch", "src", "a7", "X.java").
- getType("X").getMethod("foo", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().searchDeclarationsOfReferencedTypes(
- getWorkspace(),
- method,
- resultCollector
- );
- assertEquals(
- "src/a7/X.java a7.MyException [MyException]",
- resultCollector.toString());
-}
-/**
- * Declaration of referenced types test.
- * (Regression test for bug 12649 Missing import after move )
- */
-public void testDeclarationOfReferencedTypes3() throws CoreException {
- ICompilationUnit unit = getCompilationUnit("JavaSearch", "src", "c1", "A.java");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().searchDeclarationsOfReferencedTypes(
- getWorkspace(),
- unit,
- resultCollector
- );
- assertEquals(
- "src/c1/I.java c1.I [I]",
- resultCollector.toString());
-}
-/**
- * Declaration of referenced types test.
- * (Regression test for bug 12649 Missing import after move )
- */
-public void testDeclarationOfReferencedTypes4() throws CoreException {
- ICompilationUnit unit = getCompilationUnit("JavaSearch", "src", "c1", "B.java");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().searchDeclarationsOfReferencedTypes(
- getWorkspace(),
- unit,
- resultCollector
- );
- assertEquals(
- "src/c1/I.java c1.I [I]",
- resultCollector.toString());
-}
-/**
- * Declaration of referenced types test.
- * (Regression test for bug 18418 search: searchDeclarationsOfReferencedTypes reports import declarations)
- */
-public void testDeclarationOfReferencedTypes5() throws CoreException {
- ICompilationUnit unit = getCompilationUnit("JavaSearch", "src", "c2", "A.java");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().searchDeclarationsOfReferencedTypes(
- getWorkspace(),
- unit,
- resultCollector
- );
- assertEquals(
- "src/c3/C.java c3.C [C]",
- resultCollector.toString());
-}
-/**
- * Declaration of sent messages test.
- * (regression test for bug 6538 searchDeclarationsOf* incorrect)
- */
-public void testDeclarationOfSentMessages() throws JavaModelException, CoreException {
- IMethod method =
- getCompilationUnit("JavaSearch", "src", "a5", "B.java").
- getType("C").getMethod("i", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().searchDeclarationsOfSentMessages(
- getWorkspace(),
- method,
- resultCollector
- );
- assertEquals(
- "",
- resultCollector.toString());
-}
-/**
- * Java search scope on java element in external jar test.
- */
-public void testExternalJarScope() throws CoreException, IOException {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- File workspaceLocation = new File(workspace.getRoot().getLocation().toOSString());
- File minimalJar = new File(workspaceLocation, "JavaSearch/MyJar.jar");
- File externalJar = new File(workspaceLocation.getParentFile(), "MyJar.jar");
- IJavaProject project = this.getJavaProject("JavaSearch");
- IClasspathEntry[] classpath = project.getRawClasspath();
- try {
- copy(minimalJar, externalJar);
- int length = classpath.length;
- IClasspathEntry[] newClasspath = new IClasspathEntry[length];
- System.arraycopy(classpath, 0, newClasspath, 0, length-1);
- String externalPath = externalJar.getAbsolutePath();
- newClasspath[length-1] = JavaCore.newLibraryEntry(new Path(externalPath), new Path(externalPath), null, false);
- project.setRawClasspath(newClasspath, null);
-
- IPackageFragment pkg = this.getPackageFragment("JavaSearch", externalPath, "p0");
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {pkg});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- workspace,
- "X",
- TYPE,
- DECLARATIONS,
- scope,
- resultCollector);
- assertEquals(
- externalJar.getCanonicalPath()+ " p0.X",
- resultCollector.toString());
-
- IClassFile classFile = pkg.getClassFile("X.class");
- scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {classFile});
- resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- workspace,
- classFile.getType(),
- DECLARATIONS,
- scope,
- resultCollector);
- assertEquals(
- externalJar.getCanonicalPath()+ " p0.X",
- resultCollector.toString());
-
- } finally {
- externalJar.delete();
- project.setRawClasspath(classpath, null);
- }
-
-}
-
-/**
- * Field declaration with array type test.
- * (regression test for PR 1GKEG73: ITPJCORE:WIN2000 - search (136): missing field declaration)
- */
-public void testFieldDeclarationArrayType() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "", "B.java").getType("B");
- IField field = type.getField("open");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/B.java B.open [open]",
- resultCollector.toString());
-}
-/**
- * Field declaration in jar file test.
- */
-public void testFieldDeclarationInJar() throws JavaModelException, CoreException {
- IType type = getClassFile("JavaSearch", "MyJar.jar", "p1", "A.class").getType();
- IField field = type.getField("field");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "MyJar.jar p1.A.field [No source]",
- resultCollector.toString());
-}
-/**
- * Multiple field references in one ast test.
- * (regression test for PR 1GD79XM: ITPJCORE:WINNT - Search - search for field references - not all found)
- */
-public void testMultipleFieldReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p5", "A.java").getType("A");
- IField field = type.getField("x");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p5/A.java p5.A.k() -> void [x]\n" +
- "src/p5/A.java p5.A.k() -> void [x]\n" +
- "src/p5/A.java p5.A.k() -> void [x]",
- resultCollector.toString());
-}
-/**
- * Field reference in inner class test.
- * (regression test for PR 1GL11J6: ITPJCORE:WIN2000 - search: missing field references (nested types))
- */
-public void testFieldReferenceInInnerClass() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "", "O.java").getType("O");
- IField field = type.getField("y");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/O.java O$I.y() -> void [y]",
- resultCollector.toString());
-}
-/**
- * Field reference test.
- * (regression test for bug #3433 search: missing field occurrecnces (1GKZ8J6))
- */
-public void testFieldReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p8", "A.java").getType("A");
- IField field = type.getField("g");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p8/A.java p8.A.m() -> void [g]\n" +
- "src/p8/A.java p8.B.m() -> void [g]",
- resultCollector.toString());
-}
-/**
- * Field reference test.
- * (regression test for PR 1GK8TXE: ITPJCORE:WIN2000 - search: missing field reference)
- */
-public void testFieldReference2() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p9", "X.java").getType("X");
- IField field = type.getField("f");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p9/X.java p9.X.m() -> void [f]",
- resultCollector.toString());
-}
-/**
- * Field reference test.
- * (regression test for bug 5821 Refactor > Rename renames local variable instead of member in case of name clash )
- */
-public void testFieldReference3() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "q8", "EclipseTest.java").getType("EclipseTest");
- IField field = type.getField("test");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/q8/EclipseTest.java q8.EclipseTest.main(String[]) -> void [test]",
- resultCollector.toString());
-}
-/**
- * Field reference test.
- * (regression test for bug 5923 Search for "length" field refs finds [].length)
- */
-public void testFieldReference4() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "a2", "X.java").getType("X");
- IField field = type.getField("length");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/a2/X.java a2.X.foo() -> void [length]",
- resultCollector.toString());
-}
-/**
- * Field reference test.
- * (regression test for bug 7987 Field reference search should do lookup in 1.4 mode)
- */
-public void testFieldReference5() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "b1", "A.java").getType("A");
- IField field = type.getField("x");
-
- // Set 1.4 compliance level (no constant yet)
- Hashtable options = JavaCore.getOptions();
- String currentOption = (String)options.get("org.eclipse.jdt.core.compiler.compliance");
- options.put("org.eclipse.jdt.core.compiler.compliance", "1.4");
- JavaCore.setOptions(options);
-
- try {
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/b1/B.java b1.B.foo() -> void [x]",
- resultCollector.toString());
- } finally {
- // Restore compliance level
- options.put("org.eclipse.jdt.core.compiler.compliance", currentOption);
- JavaCore.setOptions(options);
- }
-}
-/**
- * Field reference test.
- * (regression test for bug 20693 Finding references to variables does not find all occurances)
- */
-public void testFieldReference6() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "c4", "X.java").getType("X");
- IField field = type.getField("x");
-
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/c4/X.java c4.X.foo() -> int [x]",
- resultCollector.toString());
-}
-/**
- * Field reference in anonymous class test.
- * (regression test for PR 1GL12XE: ITPJCORE:WIN2000 - search: missing field references in inner class)
- */
-public void testFieldReferenceInAnonymousClass() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "", "D.java").getType("D");
- IField field = type.getField("h");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/D.java D.g() -> void [h]",
- resultCollector.toString());
-}
-/**
- * Field reference in brackets test.
- * (regression test for bug 23329 search: incorrect range for type references in brackets)
- */
-public void testFieldReferenceInBrackets() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "s3", "A.java").getType("A");
- IField field = type.getField("field");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/s3/A.java s3.A.bar() -> int [field]",
- resultCollector.toString());
-}
-/**
- * Field reference through subclass test.
- * (regression test for PR 1GKB9YH: ITPJCORE:WIN2000 - search for field refs - incorrect results)
- */
-public void testFieldReferenceThroughSubclass() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p6", "A.java").getType("A");
- IField field = type.getField("f");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p6/A.java p6.A.m() -> void [f]\n" +
- "src/p6/A.java p6.B.m() -> void [f]\n" +
- "src/p6/A.java p6.B.m() -> void [f]",
- resultCollector.toString());
-
- type = getCompilationUnit("JavaSearch", "src", "p6", "A.java").getType("AA");
- field = type.getField("f");
- resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p6/A.java p6.B.m() -> void [f]",
- resultCollector.toString());
-
-}
-/**
- * Hierarchy scope test.
- * (regression test for bug 3445 search: type hierarchy scope incorrect (1GLC8VS))
- */
-public void testHierarchyScope() throws JavaModelException, CoreException {
- ICompilationUnit cu = this. getCompilationUnit("JavaSearch", "src", "a9", "A.java");
- IType type = cu.getType("C");
- IJavaSearchScope scope = SearchEngine.createHierarchyScope(type);
- assertTrue("a9.C should be included in hierarchy scope", scope.encloses(type));
- assertTrue("a9.A should be included in hierarchy scope", scope.encloses(cu.getType("A")));
- assertTrue("a9.B should be included in hierarchy scope", scope.encloses(cu.getType("B")));
- assertTrue("a9/A.java should be included in hierarchy scope", scope.encloses(cu.getUnderlyingResource().getFullPath().toString()));
-}
-/**
- * Type reference test.
- * (Regression test for bug 9642 Search - missing inaccurate type matches)
- */
-public void testInnacurateTypeReference1() throws JavaModelException, CoreException {
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- "Zork",
- TYPE,
- REFERENCES,
- SearchEngine.createJavaSearchScope(new IJavaElement[] {
- getPackageFragment("JavaSearch", "src", "b5")
- }),
- resultCollector);
- assertEquals(
- "src/b5/A.java [Zork]\n" +
- "src/b5/A.java b5.A.{} [Zork]\n" +
- "src/b5/A.java b5.A.{} [Zork]\n" +
- "src/b5/A.java b5.A.{} [Zork]",
- resultCollector.toString());
-}
-/**
- * Type reference test.
- * (Regression test for bug 9642 Search - missing inaccurate type matches)
- */
-public void testInnacurateTypeReference2() throws JavaModelException, CoreException {
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- "p.Zork",
- TYPE,
- REFERENCES,
- SearchEngine.createJavaSearchScope(new IJavaElement[] {
- getPackageFragment("JavaSearch", "src", "b5")
- }),
- resultCollector);
- assertEquals(
- "src/b5/A.java b5.A.{} [Zork]\n" +
- "src/b5/A.java b5.A.{} [Zork]\n" +
- "src/b5/A.java b5.A.{} [Zork]",
- resultCollector.toString());
-}
-/**
- * Type reference test.
- * (Regression test for bug 21485 NPE when doing a reference search to a package)
- */
-public void testInnacurateTypeReference3() throws CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "r3", "A21485.java").getType("A21485");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- resultCollector.showAccuracy = true;
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/r4/B21485.java [A21485] POTENTIAL_MATCH\n" +
- "src/r4/B21485.java r4.B21485 [A21485] POTENTIAL_MATCH",
- resultCollector.toString());
-}
-
-
-/**
- * Inner method declaration test.
- */
-public void testInnerMethodDeclaration() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X").getType("Inner");
- IMethod method = type.getMethod("foo", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p/X.java p.X$Inner.foo() -> String [foo]",
- resultCollector.toString());
-}
-/**
- * Inner method reference test.
- */
-public void testInnerMethodReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X").getType("Inner");
- IMethod method = type.getMethod("foo", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p/A.java p.A.foo(int, String, X) -> void [foo()]",
- resultCollector.toString());
-}
-/**
- * Interface implementors test.
- */
-public void testInterfaceImplementors() throws JavaModelException, CoreException {
- // implementors of an interface
- IType type = getCompilationUnit("JavaSearch", "src", "p", "I.java").getType("I");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- IMPLEMENTORS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/InterfaceImplementors.java InterfaceImplementors [p.I]\n" +
- "src/p/X.java p.X [I]",
- resultCollector.toString());
-
- // implementors of a class should give no match
- // (regression test for 1G5HBQA: ITPJUI:WINNT - Search - search for implementors of a class finds subclasses)
- type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
- resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- IMPLEMENTORS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "",
- resultCollector.toString());
-}
-/**
- * Interface implementors test.
- * (regression test for bug 22102 Not all implementors found for IPartListener)
- */
-public void testInterfaceImplementors2() throws JavaModelException, CoreException {
- // implementors of an interface
- IType type = getCompilationUnit("JavaSearch", "src", "r2", "I.java").getType("I");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- IMPLEMENTORS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/r2/X.java r2.X.field [I]",
- resultCollector.toString());
-}
-/**
- * Memeber type declaration test.
- * (regression test for bug 9992 Member class declaration not found)
- */
-public void testMemberTypeDeclaration() throws JavaModelException, CoreException {
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[]{
- this.getPackageFragment("JavaSearch", "src", "b4")
- });
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- "*.A.B",
- TYPE,
- DECLARATIONS,
- scope,
- resultCollector);
- assertEquals(
- "src/b4/A.java b4.A$B [B]",
- resultCollector.toString());
-}
-/**
- * Member type reference test.
- */
-public void testMemberTypeReference() throws JavaModelException, CoreException {
- // references to second level member type
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- resultCollector.showAccuracy = true;
- new SearchEngine().search(
- getWorkspace(),
- "BMember",
- TYPE,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "References to type BMember",
- "src/MemberTypeReference/Azz.java MemberTypeReference.Azz$AzzMember [BMember] EXACT_MATCH\n" +
- "src/MemberTypeReference/Azz.java MemberTypeReference.Azz.poo() -> void [B.BMember] EXACT_MATCH\n" +
- "src/MemberTypeReference/Azz.java MemberTypeReference.X.val [Azz.AzzMember.BMember] EXACT_MATCH\n" +
- "src/MemberTypeReference/B.java MemberTypeReference.B.foo() -> void [Azz.AzzMember.BMember] EXACT_MATCH",
- resultCollector.toString());
-
- // references to first level member type
- resultCollector = new JavaSearchResultCollector();
- resultCollector.showAccuracy = true;
- new SearchEngine().search(
- getWorkspace(),
- "AzzMember",
- TYPE,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "References to type AzzMember",
- "src/MemberTypeReference/Azz.java MemberTypeReference.X.val [Azz.AzzMember] EXACT_MATCH\n" +
- "src/MemberTypeReference/B.java MemberTypeReference.B.foo() -> void [Azz.AzzMember] EXACT_MATCH",
- resultCollector.toString());
-
- // no reference to a field with same name as member type
- resultCollector = new JavaSearchResultCollector();
- resultCollector.showAccuracy = true;
- new SearchEngine().search(
- getWorkspace(),
- "BMember",
- FIELD,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "References to field BMember",
- "",
- resultCollector.toString());
-}
-/**
- * Member type reference test.
- * (regression test for PR 1GL0MN9: ITPJCORE:WIN2000 - search: not consistent results for nested types)
- */
-public void testMemberTypeReference2() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "a", "A.java").getType("A").getType("X");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/a/A.java a.B.ax [A.X]\n" +
- "src/a/A.java a.B.sx [S.X]",
- resultCollector.toString());
-}
-/**
- * Method declaration in hierarchy test.
- */
-public void testMethodDeclarationInHierarchyScope1() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- "foo",
- METHOD,
- DECLARATIONS,
- SearchEngine.createHierarchyScope(type),
- resultCollector);
- assertEquals(
- "src/p/X.java p.X.foo(int, String, X) -> void [foo]\n" +
- "src/p/Z.java p.Z.foo(int, String, X) -> void [foo]",
- resultCollector.toString());
-}
-/**
- * Method declaration in hierarchy that contains elements in external jar.
- * (regression test for PR #1G2E4F1)
- */
-public void testMethodDeclarationInHierarchyScope2() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
- IMethod method = type.getMethod("foo", new String[] {"I", "QString;", "QX;"});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- DECLARATIONS,
- SearchEngine.createHierarchyScope(type), // java.lang.Object is in external jcl
- resultCollector);
- assertEquals(
- "src/p/X.java p.X.foo(int, String, X) -> void [foo]\n" +
- "src/p/Z.java p.Z.foo(int, String, X) -> void [foo]",
- resultCollector.toString());
-}
-/**
- * Method declaration in jar file test.
- */
-public void testMethodDeclarationInJar() throws JavaModelException, CoreException {
- IType type = getClassFile("JavaSearch", "MyJar.jar", "p1", "A.class").getType();
- IMethod method = type.getMethod("foo", new String[] {"Ljava.lang.String;"});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- // System.out.println(displayString(resultCollector.toString(), 2));
- assertEquals(
- "MyJar.jar p1.A.foo(java.lang.String) -> boolean [No source]",
- resultCollector.toString());
-}
-/**
- * Method declaration in package test.
- * (regression tets for PR #1G2KA97)
- */
-public void testMethodDeclarationInPackageScope() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type.getPackageFragment()});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- "main(String[])",
- METHOD,
- DECLARATIONS,
- scope,
- resultCollector);
- assertEquals(
- "src/p/A.java p.A.main(String[]) -> void [main]",
- resultCollector.toString());
-}
-/**
- * Type declaration using a package scope test.
- * (check that subpackages are not included)
- */
-public void testTypeDeclarationInPackageScope() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p3", "X.java").getType("X");
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type.getPackageFragment()});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- "X",
- TYPE,
- DECLARATIONS,
- scope,
- resultCollector);
- assertEquals(
- "src/p3/X.java p3.X [X]",
- resultCollector.toString());
-}
-/**
- * Type declaration using a binary package scope test.
- * (check that subpackages are not included)
- */
-public void testTypeDeclarationInPackageScope2() throws JavaModelException, CoreException {
- IType type = getClassFile("JavaSearch", "MyJar.jar", "p0", "X.class").getType();
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type.getPackageFragment()});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getJavaProject("JavaSearch").getProject().getWorkspace(),
- "X",
- TYPE,
- DECLARATIONS,
- scope,
- resultCollector);
- assertEquals(
- "MyJar.jar p0.X [No source]",
- resultCollector.toString());
-}
-/**
- * Method reference through super test.
- */
-public void testMethodReferenceThroughSuper() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "sd", "AQ.java").getType("AQ");
- IMethod method = type.getMethod("k", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/sd/AQ.java sd.AQE.k() -> void [k()]",
- resultCollector.toString());
-}
-/**
- * Method reference test.
- * (regression test for bug 5068 search: missing method reference)
- */
-public void testMethodReference1() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "q5", "AQ.java").getType("I");
- IMethod method = type.getMethod("k", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/q5/AQ.java q5.T.m() -> void [k()]",
- resultCollector.toString());
-}
-/**
- * Method reference test.
- * (regression test for bug 5069 search: method reference in super missing)
- */
-public void testMethodReference2() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "q6", "CD.java").getType("AQ");
- IMethod method = type.getMethod("k", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/q6/CD.java q6.AQE.k() -> void [k()]",
- resultCollector.toString());
-}
-/**
- * Method reference test.
- * (regression test for bug 5070 search: missing interface method reference )
- */
-public void testMethodReference3() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "q7", "AQ.java").getType("I");
- IMethod method = type.getMethod("k", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/q7/AQ.java q7.D.h() -> void [k()]",
- resultCollector.toString());
-}
-/**
- * Method reference test.
- * (regression test for bug 8928 Unable to find references or declarations of methods that use static inner classes in the signature)
- */
-public void testMethodReference4() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "b2", "Y.java").getType("Y");
- IMethod method = type.getMethod("foo", new String[] {"QX.Inner;"});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/b2/Z.java b2.Z.bar() -> void [foo(inner)]",
- resultCollector.toString());
-}
-/**
- * Method reference through array test.
- * (regression test for 1GHDA2V: ITPJCORE:WINNT - ClassCastException when doing a search)
- */
-public void testMethodReferenceThroughArray() throws JavaModelException, CoreException {
- IType type = getClassFile("JavaSearch", getExternalJCLPath(), "java.lang", "Object.class").getType();
- IMethod method = type.getMethod("clone", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/E.java E.foo() -> Object [clone()]",
- resultCollector.toString());
-}
-/**
- * Method reference in inner class test.
- */
-public void testMethodReferenceInInnerClass() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "", "CA.java").getType("CA");
- IMethod method = type.getMethod("m", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/CA.java CA$CB.f() -> void [m()]\n" +
- "src/CA.java CA$CB$CC.f() -> void [m()]",
- resultCollector.toString());
-}
-/**
- * Method reference in anonymous class test.
- * (regression test for PR 1GGNOTF: ITPJCORE:WINNT - Search doesn't find method referenced in anonymous inner class)
- */
-public void testMethodReferenceInAnonymousClass() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "", "PR_1GGNOTF.java").getType("PR_1GGNOTF");
- IMethod method = type.getMethod("method", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/PR_1GGNOTF.java PR_1GGNOTF.method2() -> void [method()]",
- resultCollector.toString());
-}
-/**
- * Member type named "Object" reference test.
- * (regression test for 1G4GHPS: ITPJUI:WINNT - Strange error message in search)
- */
-public void testObjectMemberTypeReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "ObjectMemberTypeReference", "A.java")
- .getType("A")
- .getType("Object");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- resultCollector.showAccuracy = true;
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/ObjectMemberTypeReference/A.java ObjectMemberTypeReference.A.foo() -> void [Object] EXACT_MATCH",
- resultCollector.toString());
-}
-/**
- * OrPattern test.
- * (regression test for bug 5862 search : too many matches on search with OrPattern)
- */
-public void testOrPattern() throws CoreException {
- IMethod leftMethod = getCompilationUnit("JavaSearch", "src", "q9", "I.java")
- .getType("I").getMethod("m", new String[] {});
- ISearchPattern leftPattern = SearchEngine.createSearchPattern(leftMethod, ALL_OCCURRENCES);
- IMethod rightMethod = getCompilationUnit("JavaSearch", "src", "q9", "I.java")
- .getType("A1").getMethod("m", new String[] {});
- ISearchPattern rightPattern = SearchEngine.createSearchPattern(rightMethod, ALL_OCCURRENCES);
- ISearchPattern orPattern = SearchEngine.createOrSearchPattern(leftPattern, rightPattern);
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- resultCollector.showAccuracy = true;
- new SearchEngine().search(
- getWorkspace(),
- orPattern,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/q9/I.java q9.I.m() -> void [m] EXACT_MATCH\n" +
- "src/q9/I.java q9.A1.m() -> void [m] EXACT_MATCH",
- resultCollector.toString());
-}
-/**
- * Package reference test.
- * (regression test for PR 1GK90H4: ITPJCORE:WIN2000 - search: missing package reference)
- */
-public void testPackageReference1() throws JavaModelException, CoreException {
- IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "q2");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- pkg,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/q1/B.java q1.B.m(AA) -> void [q2]",
- resultCollector.toString());
-}
-/**
- * Package reference test.
- * (regression test for bug 17906 Rename package fails when inner classes are imported)
- */
-public void testPackageReference2() throws JavaModelException, CoreException {
- IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "b8");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- pkg,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/b9/Foo.java [b8]",
- resultCollector.toString());
-}
-
-/**
- * Test pattern match package references
- */
-public void testPatternMatchPackageReference() throws JavaModelException, CoreException {
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- "*p2.*",
- PACKAGE,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/PackageReference/A.java [p3.p2.p]\n" +
- "src/PackageReference/B.java [p3.p2.p]\n" +
- "src/PackageReference/C.java PackageReference.C [p3.p2.p]\n" +
- "src/PackageReference/D.java PackageReference.D.x [p3.p2.p]\n" +
- "src/PackageReference/E.java PackageReference.E.x [p3.p2.p]\n" +
- "src/PackageReference/F.java PackageReference.F.foo() -> p3.p2.p.X [p3.p2.p]\n" +
- "src/PackageReference/G.java PackageReference.G.foo(p3.p2.p.X) -> void [p3.p2.p]\n" +
- "src/PackageReference/H.java PackageReference.H.foo() -> void [p3.p2.p]\n" +
- "src/PackageReference/I.java PackageReference.I.foo() -> void [p3.p2.p]\n" +
- "src/PackageReference/J.java PackageReference.J.foo() -> void [p3.p2.p]",
- resultCollector.toString());
-}
-/**
- * Test pattern match type declaration
- * (regression test for bug 17210 No match found when query contains '?')
- */
-public void testPatternMatchTypeDeclaration() throws CoreException {
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- "X?Z",
- TYPE,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals("src/r5/XYZ.java r5.XYZ [XYZ]", resultCollector.toString());
-}
-/**
- * Test that we find potential matches in binaries even if we can't resolve the entire
- * class file.
- * (Regression test for 1G4IN3E: ITPJCORE:WINNT - AbortCompilation using J9 to search for class declaration)
- */
-public void testPotentialMatchInBinary() throws JavaModelException, CoreException {
- // potential match for a field declaration
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- resultCollector.showAccuracy = true;
- new SearchEngine().search(
- getWorkspace(),
- "MissingFieldType.*",
- FIELD,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "AbortCompilation.jar AbortCompilation.MissingFieldType.field [No source] POTENTIAL_MATCH\n" +
- "AbortCompilation.jar AbortCompilation.MissingFieldType.missing [No source] POTENTIAL_MATCH\n" +
- "AbortCompilation.jar AbortCompilation.MissingFieldType.otherField [No source] POTENTIAL_MATCH",
- resultCollector.toString());
-
- // potential match for a method declaration
- resultCollector = new JavaSearchResultCollector();
- resultCollector.showAccuracy = true;
- new SearchEngine().search(
- getWorkspace(),
- "MissingArgumentType.foo*",
- METHOD,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "AbortCompilation.jar AbortCompilation.MissingArgumentType.foo() -> void [No source] POTENTIAL_MATCH\n" +
- "AbortCompilation.jar AbortCompilation.MissingArgumentType.foo(java.util.EventListener) -> void [No source] POTENTIAL_MATCH\n" +
- "AbortCompilation.jar AbortCompilation.MissingArgumentType.foo2() -> void [No source] POTENTIAL_MATCH",
- resultCollector.toString());
-
- // potential match for a type declaration
- resultCollector = new JavaSearchResultCollector();
- resultCollector.showAccuracy = true;
- new SearchEngine().search(
- getWorkspace(),
- "Missing*",
- TYPE,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "AbortCompilation.jar AbortCompilation.EnclosingType$MissingEnclosingType [No source] EXACT_MATCH\n" +
- "AbortCompilation.jar AbortCompilation.MissingArgumentType [No source] EXACT_MATCH\n" +
- "AbortCompilation.jar AbortCompilation.MissingFieldType [No source] EXACT_MATCH",
- resultCollector.toString());
-}
-/**
- * Read and write access reference in compound expression test.
- * (regression test for bug 6158 Search - Prefix and postfix expression not found as write reference)
- */
-public void testReadWriteFieldReferenceInCompoundExpression() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "a4", "X.java").getType("X");
- IField field = type.getField("field");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
-
- // Read reference
- new SearchEngine().search(
- getWorkspace(),
- field,
- READ_ACCESSES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/a4/X.java a4.X.foo() -> void [field]",
- resultCollector.toString());
-
- // Write reference
- resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- WRITE_ACCESSES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/a4/X.java a4.X.foo() -> void [field]",
- resultCollector.toString());
-
-}
-/**
- * Simple constructor declaration test.
- */
-public void testSimpleConstructorDeclaration() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
- IMethod constructor = type.getMethod("A", new String[] {"QX;"});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- constructor,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals("src/p/A.java p.A(X) [A]", resultCollector.toString());
-}
-/**
- * Simple constructor reference test.
- */
-public void testSimpleConstructorReference1() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
- IMethod constructor = type.getMethod("A", new String[] {"QX;"});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- constructor,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals("src/Test.java Test.main(String[]) -> void [new p.A(y)]", resultCollector.toString());
-}
-/**
- * Simple constructor reference test.
- */
-public void testSimpleConstructorReference2() throws JavaModelException, CoreException {
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- "p.A(X)",
- CONSTRUCTOR,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals("src/Test.java Test.main(String[]) -> void [new p.A(y)]", resultCollector.toString());
-}
-/**
- * Simple declarations of sent messages test.
- */
-public void testSimpleDeclarationsOfSentMessages() throws JavaModelException, CoreException {
- ICompilationUnit cu = getCompilationUnit("JavaSearch", "src", "", "Test.java");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().searchDeclarationsOfSentMessages(
- getWorkspace(),
- cu,
- resultCollector);
- assertEquals(
- "src/p/X.java p.X.foo(int, String, X) -> void [foo(int i, String s, X x)]\n" +
- "src/p/Y.java p.Y.bar() -> void [bar()]\n" +
- "src/p/Z.java p.Z.foo(int, String, X) -> void [foo(int i, String s, X x)]\n" +
- "src/p/A.java p.A.foo(int, String, X) -> void [foo()]",
- resultCollector.toString());
-}
-/**
- * Simple field declaration test.
- */
-public void testSimpleFieldDeclaration() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
- IField field = type.getField("x");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p/A.java p.A.x [x]",
- resultCollector.toString());
-}
-/**
- * Simple field reference test.
- */
-public void testSimpleFieldReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
- IField field = type.getField("x");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/Test.java Test.main(String[]) -> void [x]\n" +
- "src/p/A.java p.A(X) [x]",
- resultCollector.toString());
-}
-/**
- * Simple write field access reference test.
- */
-public void testSimpleWriteFieldReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
- IField field = type.getField("x");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- WRITE_ACCESSES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p/A.java p.A(X) [x]",
- resultCollector.toString());
-}
-/**
- * Sub-cu java search scope test.
- * (regression test for bug 9041 search: cannot create a sub-cu scope)
- */
-public void testSubCUSearchScope1() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "b3", "X.java").getType("X");
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- scope,
- resultCollector);
- assertEquals(
- "src/b3/X.java b3.X.field [X]\n" +
- "src/b3/X.java b3.X.foo() -> Object [X]\n" +
- "src/b3/X.java b3.X$Y.field2 [X]\n" +
- "src/b3/X.java b3.X$Y.foo2() -> Object [X]",
- resultCollector.toString());
-}
-/**
- * Sub-cu java search scope test.
- * (regression test for bug 9041 search: cannot create a sub-cu scope)
- */
-public void testSubCUSearchScope2() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "b3", "X.java").getType("X");
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type.getField("field")});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- scope,
- resultCollector);
- assertEquals(
- "src/b3/X.java b3.X.field [X]",
- resultCollector.toString());
-}
-/**
- * Sub-cu java search scope test.
- * (regression test for bug 9041 search: cannot create a sub-cu scope)
- */
-public void testSubCUSearchScope3() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "b3", "X.java").getType("X");
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {type.getType("Y")});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- scope,
- resultCollector);
- assertEquals(
- "src/b3/X.java b3.X$Y.field2 [X]\n" +
- "src/b3/X.java b3.X$Y.foo2() -> Object [X]",
- resultCollector.toString());
-}
-/**
- * Simple method declaration test.
- */
-public void testSimpleMethodDeclaration() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
- IMethod method = type.getMethod("foo", new String[] {"I", "QString;", "QX;"});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p/X.java p.X.foo(int, String, X) -> void [foo]\n" +
- "src/p/Z.java p.Z.foo(int, String, X) -> void [foo]",
- resultCollector.toString());
-}
-/**
- * Simple method reference test.
- */
-public void testSimpleMethodReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
- IMethod method = type.getMethod("foo", new String[] {"I", "QString;", "QX;"});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/Test.java Test.main(String[]) -> void [foo(1, \"a\", y)]\n" +
- "src/Test.java Test.main(String[]) -> void [foo(1, \"a\", z)]\n" +
- "src/p/Z.java p.Z.foo(int, String, X) -> void [foo(i, s, new Y(true))]",
- resultCollector.toString());
-}
-/**
- * Simple package declaration test.
- */
-public void testSimplePackageDeclaration() throws JavaModelException, CoreException {
- IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "p");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- pkg,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p p",
- resultCollector.toString());
-}
-/**
- * Simple package reference test.
- */
-public void testSimplePackageReference() throws JavaModelException, CoreException {
- IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "p");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- pkg,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/InterfaceImplementors.java InterfaceImplementors [p]\n" +
- "src/Test.java Test.main(String[]) -> void [p]\n" +
- "src/Test.java Test.main(String[]) -> void [p]\n" +
- "src/Test.java Test.main(String[]) -> void [p]\n" +
- "src/Test.java Test.main(String[]) -> void [p]\n" +
- "src/Test.java Test.main(String[]) -> void [p]\n" +
- "src/Test.java Test.main(String[]) -> void [p]\n" +
- "src/TypeReferenceInImport/X.java [p]",
- resultCollector.toString());
-}
-/**
- * Simple field read access reference test.
- */
-public void testSimpleReadFieldReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
- IField field = type.getField("x");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- READ_ACCESSES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/Test.java Test.main(String[]) -> void [x]",
- resultCollector.toString());
-}
-/**
- * Simple type declaration test.
- */
-public void testSimpleTypeDeclaration() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals("src/p/X.java p.X [X]", resultCollector.toString());
-}
-/**
- * Simple type reference test.
- */
-public void testSimpleTypeReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p/A.java p.A.x [X]\n" +
- "src/p/A.java p.A(X) [X]\n" +
- "src/p/A.java p.A.foo(int, String, X) -> void [X]\n" +
- "src/p/X.java p.X() [X]\n" +
- "src/p/X.java p.X.foo(int, String, X) -> void [X]\n" +
- "src/p/Y.java p.Y [X]\n" +
- "src/p/Z.java p.Z.foo(int, String, X) -> void [X]",
- resultCollector.toString());
-}
-/**
- * Static field reference test.
- * (regression test for PR #1G2P5EP)
- */
-public void testStaticFieldReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
- IField field = type.getField("DEBUG");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p/A.java p.A.foo() -> void [DEBUG]",
- resultCollector.toString());
-}
-/**
- * Static method reference test.
- */
-public void testStaticMethodReference1() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "Y.java").getType("Y");
- IMethod method = type.getMethod("bar", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/Test.java Test.main(String[]) -> void [bar()]",
- resultCollector.toString());
-}
-/**
- * Static method reference test.
- */
-public void testStaticMethodReference2() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
- IMethod method = type.getMethod("bar", new String[] {});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- method,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "",
- resultCollector.toString());
-}
-/**
- * Type declaration in jar file test.
- */
-public void testTypeDeclarationInJar() throws JavaModelException, CoreException {
- IType type = getClassFile("JavaSearch", "MyJar.jar", "p1", "A.class").getType();
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "MyJar.jar p1.A [No source]",
- resultCollector.toString());
-}
-/**
- * Type declaration in jar file and in anonymous class test.
- * (regression test for 20631 Declaration of local binary type not found)
- */
-public void testTypeDeclarationInJar2() throws JavaModelException, CoreException {
- IPackageFragmentRoot root = getPackageFragmentRoot("JavaSearch", "test20631.jar");
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {root});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- "Y",
- TYPE,
- DECLARATIONS,
- scope,
- resultCollector);
- assertEquals(
- "test20631.jar X$1$Y",
- resultCollector.toString());
-}
-/**
- * Type ocurrence test.
- * (regression test for PR 1GKAQJS: ITPJCORE:WIN2000 - search: incorrect results for nested types)
- */
-public void testTypeOccurence() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "r", "A.java").getType("A").getType("X");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- ALL_OCCURRENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/r/A.java r.A.m() -> A [X]\n" +
- "src/r/A.java r.A$X [X]\n" +
- "src/r/A.java r.A$X(X) [X]\n" +
- "src/r/A.java r.A$X(X) [X]\n" +
- "src/r/A.java r.B.ax [A.X]\n" +
- "src/r/A.java r.B.ax [X]",
- resultCollector.toString());
-}
-/**
- * Type name with $ ocurrence test.
- * (regression test for bug 3310 Smoke 124: Compile errors introduced with rename refactoring (1GFBK2G))
- */
-public void testTypeOccurenceWithDollar() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "q3", "A$B.java").getType("A$B");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- ALL_OCCURRENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/q3/A$B.java q3.A$B [A$B]\n" +
- "src/q4/C.java q4.C.foo() -> Object [q3.A$B]",
- resultCollector.toString());
-}
-/**
- * Type reference test.
- * (Regression test for PR 1GK7K17: ITPJCORE:WIN2000 - search: missing type reference)
- */
-public void testTypeReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "", "X.java").getType("X");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/X.java AA() [X]",
- resultCollector.toString());
-}
-/**
- * Type reference as a single name reference test.
- */
-public void testTypeReferenceAsSingleNameReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "", "TypeReferenceAsSingleNameReference.java").getType("TypeReferenceAsSingleNameReference");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/TypeReferenceAsSingleNameReference.java TypeReferenceAsSingleNameReference.hasReference() -> void [TypeReferenceAsSingleNameReference]",
- resultCollector.toString());
-}
-/**
- * Type reference in array test.
- * (regression test for PR #1GAL424)
- */
-public void testTypeReferenceInArray() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "TypeReferenceInArray", "A.java").getType("A");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/TypeReferenceInArray/A.java TypeReferenceInArray.A.a [A]\n" +
- "src/TypeReferenceInArray/A.java TypeReferenceInArray.A.b [TypeReferenceInArray.A]",
- resultCollector.toString());
-}
-/**
- * Type reference in array test.
- * (regression test for bug 3230 Search - Too many type references for query ending with * (1GAZVGI) )
- */
-public void testTypeReferenceInArray2() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "s1", "X.java").getType("X");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/s1/Y.java s1.Y.f [X]",
- resultCollector.toString());
-}
-/**
- * Type reference in cast test.
- * (regression test for bug 23329 search: incorrect range for type references in brackets)
- */
-public void testTypeReferenceInCast() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "s3", "A.java").getType("B");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/s3/A.java s3.A.foo() -> Object [B]",
- resultCollector.toString());
-}
-/**
- * Type reference in import test.
- * (regression test for PR #1GA7PAS)
- */
-public void testTypeReferenceInImport() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p2", "Z.java").getType("Z");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/TypeReferenceInImport/X.java [p2.Z]",
- resultCollector.toString());
-}
-/**
- * Type reference in import test.
- * (regression test for bug 23077 search: does not find type references in some imports)
- */
-public void testTypeReferenceInImport2() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "r6", "A.java").getType("A");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/r6/B.java [r6.A]\n" +
- "src/r6/B.java [r6.A]\n" +
- "src/r6/B.java [r6.A]\n" +
- "src/r6/B.java [r6.A]\n" +
- "src/r6/B.java [r6.A]\n" +
- "src/r6/B.java [r6.A]",
- resultCollector.toString());
-}
-/**
- * Type reference in initializer test.
- * (regression test for PR #1G4GO4O)
- */
-public void testTypeReferenceInInitializer() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "", "Test.java").getType("Test");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/Test.java Test.static {} [Test]\n" +
- "src/Test.java Test.static {} [Test]\n" +
- "src/Test.java Test.{} [Test]",
- resultCollector.toString());
-}
-/**
- * Type reference inside a qualified name reference test.
- * (Regression test for PR #1G4TSC0)
- */
-public void testTypeReferenceInQualifiedNameReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "A.java").getType("A");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/Test.java Test.main(String[]) -> void [p.A]\n" +
- "src/Test.java Test.main(String[]) -> void [p.A]\n" +
- "src/p/A.java p.A.foo() -> void [A]",
- resultCollector.toString());
-}
-/**
- * Type reference inside a qualified name reference test.
- * (Regression test for PR #1GLBP65)
- */
-public void testTypeReferenceInQualifiedNameReference2() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p4", "A.java").getType("A");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p4/A.java p4.A.A [A]\n" +
- "src/p4/A.java p4.X.x() -> void [p4.A]\n" +
- "src/p4/A.java p4.X [p4.A]",
- resultCollector.toString());
-}
-/**
- * Type reference inside a qualified name reference test.
- * (Regression test for PR 1GL9UMH: ITPJCORE:WIN2000 - search: missing type occurrences)
- */
-public void testTypeReferenceInQualifiedNameReference3() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "", "W.java").getType("W");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/W.java W.m() -> int [W]",
- resultCollector.toString());
-}
-/**
- * Type reference inside a qualified name reference test.
- * (Regression test for bug 16751 Renaming a class doesn't update all references )
- */
-public void testTypeReferenceInQualifiedNameReference4() throws CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "b7", "X.java").getType("SubClass");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/b7/X.java b7.Test.main(String[]) -> void [SubClass]",
- resultCollector.toString());
-}
-/**
- * Type reference in a throw clause test.
- * (Regression test for bug 6779 searchDeclarationsOfReferencedTyped - missing exception types)
- */
-public void testTypeReferenceInThrows() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "a7", "X.java").getType("MyException");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- resultCollector.showAccuracy = true;
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/a7/X.java a7.X.foo() -> void [MyException] EXACT_MATCH",
- resultCollector.toString());
-}
-/**
- * Type reference in a folder that is not in the classpath.
- * (regression test for PR #1G5N8KS)
- */
-public void testTypeReferenceNotInClasspath() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p/A.java p.A.x [X]\n" +
- "src/p/A.java p.A(X) [X]\n" +
- "src/p/A.java p.A.foo(int, String, X) -> void [X]\n" +
- "src/p/X.java p.X() [X]\n" +
- "src/p/X.java p.X.foo(int, String, X) -> void [X]\n" +
- "src/p/Y.java p.Y [X]\n" +
- "src/p/Z.java p.Z.foo(int, String, X) -> void [X]",
- resultCollector.toString());
-}
-/**
- * Negative type reference test.
- * (regression test for 1G52F7P: ITPJCORE:WINNT - Search - finds bogus references to class)
- */
-public void testNegativeTypeReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "p7", "A.java").getType("A");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "",
- resultCollector.toString());
-}
-
-/**
- * Various package declarations test.
- */
-public void testVariousPackageDeclarations() throws JavaModelException, CoreException {
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- "p3*",
- PACKAGE,
- DECLARATIONS,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/p3 p3\n" +
- "src/p3/p2/p p3.p2.p",
- resultCollector.toString());
-}
-/**
- * Various package reference test.
- */
-public void testVariousPackageReference() throws JavaModelException, CoreException {
- IPackageFragment pkg = getPackageFragment("JavaSearch", "src", "p3.p2.p");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- pkg,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "src/PackageReference/A.java [p3.p2.p]\n" +
- "src/PackageReference/B.java [p3.p2.p]\n" +
- "src/PackageReference/C.java PackageReference.C [p3.p2.p]\n" +
- "src/PackageReference/D.java PackageReference.D.x [p3.p2.p]\n" +
- "src/PackageReference/E.java PackageReference.E.x [p3.p2.p]\n" +
- "src/PackageReference/F.java PackageReference.F.foo() -> p3.p2.p.X [p3.p2.p]\n" +
- "src/PackageReference/G.java PackageReference.G.foo(p3.p2.p.X) -> void [p3.p2.p]\n" +
- "src/PackageReference/H.java PackageReference.H.foo() -> void [p3.p2.p]\n" +
- "src/PackageReference/I.java PackageReference.I.foo() -> void [p3.p2.p]\n" +
- "src/PackageReference/J.java PackageReference.J.foo() -> void [p3.p2.p]",
- resultCollector.toString());
-}
-/**
- * Type reference inside an argument, a return type or a field type.
- * (Regression test for PR #1GA7QA1)
- */
-public void testVariousTypeReferences() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "NoReference", "A.java").getType("A");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- type,
- REFERENCES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "", // no reference should be found
- resultCollector.toString());
-}
-/**
- * Write access reference in a qualified name reference test.
- * (regression test for bug 7344 Search - write acces give wrong result)
- */
-public void testReadWriteAccessInQualifiedNameReference() throws JavaModelException, CoreException {
- IType type = getCompilationUnit("JavaSearch", "src", "a8", "A.java").getType("A");
- IField field = type.getField("a");
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
-
- resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- field,
- WRITE_ACCESSES,
- getJavaSearchScope(),
- resultCollector);
- assertEquals(
- "",
- resultCollector.toString());
-
-}
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java
deleted file mode 100644
index 0315430..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModifyingResourceTests.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.core.resources.*;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClassFile;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaElementDelta;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IParent;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.internal.compiler.batch.Main;
-import org.eclipse.jdt.internal.core.JavaElement;
-
-/*
- * Tests that modify resources in the workspace.
- */
-public class ModifyingResourceTests extends AbstractJavaModelTests {
-
-public ModifyingResourceTests(String name) {
- super(name);
-}
-/**
- * E.g. <code>
- * org.eclipse.jdt.tests.core.ModifyingResourceTests.generateClassFile(
- * "A",
- * "public class A {\n" +
- * "}")
- */
-public static void generateClassFile(String className, String javaSource) throws IOException {
- String cu = "d:/temp/" + className + ".java";
- FileOutputStream output = new FileOutputStream(cu);
- try {
- output.write(javaSource.getBytes());
- } finally {
- output.close();
- }
- Main.compile(cu + " -d d:/temp -classpath " + System.getProperty("java.home") + "/lib/rt.jar");
- FileInputStream input = new FileInputStream("d:/temp/" + className + ".class");
- try {
- System.out.println("{");
- byte[] buffer = new byte[80];
- int read = 0;
- while (read != -1) {
- read = input.read(buffer);
- if (read != -1) System.out.print("\t");
- for (int i = 0; i < read; i++) {
- System.out.print(buffer[i]);
- System.out.print(", ");
- }
- if (read != -1) System.out.println();
- }
- System.out.print("}");
- } finally {
- input.close();
- }
-}
-
-protected IFile createFile(String path, byte[] content) throws CoreException {
- IFile file = this.getFile(path);
- InputStream input = new ByteArrayInputStream(content);
- file.create(input, true, null);
- return file;
-}
-
-protected IFile createFile(String path, String content) throws CoreException {
- IFile file = this.getFile(path);
- InputStream input = new ByteArrayInputStream(content.getBytes());
- file.create(input, true, null);
- return file;
-}
-protected IFolder createFolder(String path) throws CoreException {
- IFolder folder = this.getFolder(path);
- IContainer parent = folder.getParent();
- if (parent instanceof IFolder && !parent.exists()) {
- this.createFolder(parent.getFullPath().toString());
- }
- folder.create(true, true, null);
- return folder;
-}
-protected void deleteFile(String filePath) throws CoreException {
- this.getFile(filePath).delete(true, null);
-}
-protected void deleteFolder(String folderPath) throws CoreException {
- this.getFolder(folderPath).delete(true, null);
-}
-/*
- * Expands (i.e. open) the given element and returns a toString() representation
- * of the tree.
- */
-protected String expandAll(IJavaElement element) throws CoreException {
- StringBuffer buffer = new StringBuffer();
- this.expandAll(element, 0, buffer);
- return buffer.toString();
-}
-private void expandAll(IJavaElement element, int tab, StringBuffer buffer) throws CoreException {
- IJavaElement[] children = null;
- // force opening of element by getting its children
- if (element instanceof IParent) {
- IParent parent = (IParent)element;
- children = parent.getChildren();
- }
- ((JavaElement)element).toStringInfo(tab, buffer);
- if (children != null) {
- for (int i = 0, length = children.length; i < length; i++) {
- buffer.append("\n");
- this.expandAll(children[i], tab+1, buffer);
- }
- }
-}
-protected void renameProject(String project, String newName) throws CoreException {
- this.getProject(project).move(new Path(newName), true, null);
-}
-protected ICompilationUnit getCompilationUnit(String path) {
- return (ICompilationUnit)JavaCore.create(this.getFile(path));
-}
-protected IClassFile getClassFile(String path) {
- return (IClassFile)JavaCore.create(this.getFile(path));
-}
-
-protected String getDeltas() {
- StringBuffer buffer = new StringBuffer();
- IJavaElementDelta[] deltas = this.deltaListener.deltas;
- for (int i=0, length= deltas.length; i<length; i++) {
- IJavaElementDelta[] projects = deltas[i].getAffectedChildren();
- for (int j=0, projectsLength=projects.length; j<projectsLength; j++) {
- buffer.append(projects[j]);
- if (j != projectsLength-1) {
- buffer.append("\n");
- }
- }
- if (i != length-1) {
- buffer.append("\n\n");
- }
- }
- return buffer.toString();
-}
-protected IFile getFile(String path) {
- return getWorkspaceRoot().getFile(new Path(path));
-}
-protected IFolder getFolder(String path) {
- return getWorkspaceRoot().getFolder(new Path(path));
-}
-protected IPackageFragment getPackage(String path) {
- if (path.indexOf('/') != -1) {
- return (IPackageFragment)JavaCore.create(this.getFolder(path));
- } else {
- IProject project = this.getProject(path);
- return JavaCore.create(project).getPackageFragmentRoot(project).getPackageFragment("");
- }
-}
-protected String getSortedByProjectDeltas() {
- StringBuffer buffer = new StringBuffer();
- for (int i=0, length = this.deltaListener.deltas.length; i<length; i++) {
- IJavaElementDelta[] projects = this.deltaListener.deltas[i].getAffectedChildren();
- int projectsLength = projects.length;
-
- // sort by project
- IJavaElementDelta[] sorted = new IJavaElementDelta[projectsLength];
- System.arraycopy(projects, 0, sorted, 0, projectsLength);
- org.eclipse.jdt.internal.core.Util.sort(
- sorted,
- new org.eclipse.jdt.internal.core.Util.Comparer() {
- public int compare(Object a, Object b) {
- return a.toString().compareTo(b.toString());
- }
- });
-
- for (int j=0; j<projectsLength; j++) {
- buffer.append(sorted[j]);
- if (j != projectsLength-1) {
- buffer.append("\n");
- }
- }
- if (i != length-1) {
- buffer.append("\n\n");
- }
- }
- return buffer.toString();
-}
-protected void moveFile(String sourcePath, String destPath) throws CoreException {
- this.getFile(sourcePath).move(this.getFile(destPath).getFullPath(), false, null);
-}
-protected void swapFiles(String firstPath, String secondPath) throws CoreException {
- final IFile first = this.getFile(firstPath);
- final IFile second = this.getFile(secondPath);
- IWorkspaceRunnable runnable = new IWorkspaceRunnable( ) {
- public void run(IProgressMonitor monitor) throws CoreException {
- IPath tempPath = first.getParent().getFullPath().append("swappingFile.temp");
- first.move(tempPath, false, monitor);
- second.move(first.getFullPath(), false, monitor);
- getWorkspaceRoot().getFile(tempPath).move(second.getFullPath(), false, monitor);
- }
- };
- getWorkspace().run(runnable, null);
-}
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NameLookupTests2.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NameLookupTests2.java
deleted file mode 100644
index acc48d5..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NameLookupTests2.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.tests.model.*;
-import org.eclipse.jdt.internal.core.JavaProject;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * These test ensure that modifications in Java projects are correctly reported as
- * IJavaEllementDeltas.
- */
-public class NameLookupTests2 extends ModifyingResourceTests {
-
-public NameLookupTests2(String name) {
- super(name);
-}
-
-
-
-public static Test suite() {
- TestSuite suite = new Suite(NameLookupTests2.class.getName());
- suite.addTest(new NameLookupTests2("testAddPackageFragmentRootAndPackageFrament"));
- suite.addTest(new NameLookupTests2("testAddPackageFrament"));
-
- return suite;
-}
-
-public void testAddPackageFragmentRootAndPackageFrament() throws CoreException {
- try {
- IJavaProject p1 = this.createJavaProject("P1", new String[] {"src1"}, "bin");
- IJavaProject p2 = this.createJavaProject("P2", new String[] {}, "");
- IClasspathEntry[] classpath =
- new IClasspathEntry[] {
- JavaCore.newProjectEntry(new Path("/P1"))
- };
- p2.setRawClasspath(classpath, null);
-
- IPackageFragment[] res = ((JavaProject)p2).getNameLookup().findPackageFragments("p1", false);
- assertTrue("Should get no package fragment", res == null);
-
- IClasspathEntry[] classpath2 =
- new IClasspathEntry[] {
- JavaCore.newSourceEntry(new Path("/P1/src1")),
- JavaCore.newSourceEntry(new Path("/P1/src2"))
- };
- p1.setRawClasspath(classpath2, null);
- this.createFolder("/P1/src2/p1");
-
- res = ((JavaProject)p2).getNameLookup().findPackageFragments("p1", false);
- assertTrue(
- "Should get 'p1' package fragment",
- res != null &&
- res.length == 1 &&
- res[0].getElementName().equals("p1"));
-
- } finally {
- this.deleteProject("P1");
- this.deleteProject("P2");
- }
-}
-public void testAddPackageFrament() throws CoreException {
- try {
- IJavaProject p1 = this.createJavaProject("P1", new String[] {"src1"}, "bin");
- IJavaProject p2 = this.createJavaProject("P2", new String[] {}, "");
- IClasspathEntry[] classpath =
- new IClasspathEntry[] {
- JavaCore.newProjectEntry(new Path("/P1"))
- };
- p2.setRawClasspath(classpath, null);
-
- IPackageFragment[] res = ((JavaProject)p2).getNameLookup().findPackageFragments("p1", false);
- assertTrue("Should get no package fragment", res == null);
-
- this.createFolder("/P1/src1/p1");
-
- res = ((JavaProject)p2).getNameLookup().findPackageFragments("p1", false);
- assertTrue(
- "Should get 'p1' package fragment",
- res != null &&
- res.length == 1 &&
- res[0].getElementName().equals("p1"));
-
- } finally {
- this.deleteProject("P1");
- this.deleteProject("P2");
- }
-}
-}
-
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java
deleted file mode 100644
index dceb261..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SuiteOfTestCases.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SuiteOfTestCases.java
deleted file mode 100644
index 043b37a..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SuiteOfTestCases.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-
-import junit.framework.Protectable;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-import junit.framework.TestSuite;
-
-/**
- * A test case class that can be set up (using the setUpSuite() method) and tore down (using the teardDownSuite() method)
- * once for all test cases of this class.
- */
-public class SuiteOfTestCases extends TestCase {
-
- /*
- * A test suite that initialize the test case's fields once, then that copies the values
- * of these fields intto each subsequent test case.
- */
- protected static class Suite extends TestSuite {
- public SuiteOfTestCases currentTestCase;
-
- /*
- * Creates a new suite on the given class. This class must be a subclass of SetupableTestSuite.
- */
- public Suite(Class theClass) {
- super(theClass);
- }
- public Suite(String name) {
- super(name);
- }
- private void initialize(SuiteOfTestCases test) {
- Class currentClass = test.getClass();
- while (currentClass != null && !currentClass.equals(SuiteOfTestCases.class)) {
- Field[] fields = currentClass.getDeclaredFields();
- for (int i = 0, length = fields.length; i < length; i++) {
- Field field = fields[i];
-
- // skip static fields
- if (Modifier.isStatic(field.getModifiers())) continue;
-
- // make the field accessible
- field.setAccessible(true);
-
- try {
- Object value = field.get(this.currentTestCase);
- field.set(test, value);
- } catch (IllegalAccessException e) {
- }
- }
- currentClass = currentClass.getSuperclass();
- }
- }
- public void run(final TestResult result) {
- Protectable p= new Protectable() {
- public void protect() throws Exception {
- try {
- // run suite (first test run will setup the suite)
- Suite.super.run(result);
- } finally {
- // tear down the suite
- if (Suite.this.currentTestCase != null) { // protect against empty test suite
- Suite.this.currentTestCase.tearDownSuite();
- }
- }
- }
- };
- result.runProtected(this, p);
- }
- public void runTest(Test test, TestResult result) {
- SuiteOfTestCases current = (SuiteOfTestCases)test;
- if (this.currentTestCase == null) {
- // setup suite
- try {
- current.setUpSuite();
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else {
- // copy the values of the previous current test case's fields into the current one
- this.initialize(current);
- }
- try {
- super.runTest(test, result);
- } finally {
- // make current
- this.currentTestCase = current;
- }
- }
- }
-
- public SuiteOfTestCases(String name) {
- super(name);
- }
-
- /**
- * Setup the test suite once before all test cases run.
- */
- public void setUpSuite() throws Exception {
- }
-
- /**
- * Tear down the test suite once after all test cases have run.
- */
- public void tearDownSuite() throws Exception {
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyNotInClasspathTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyNotInClasspathTests.java
deleted file mode 100644
index c27a33f..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyNotInClasspathTests.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import junit.framework.Test;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.tests.model.*;
-
-public class WorkingCopyNotInClasspathTests extends ModifyingResourceTests {
-
- private ICompilationUnit workingCopy;
-
-public WorkingCopyNotInClasspathTests(String name) {
- super(name);
-}
-
-
-
-public static Test suite() {
- return new Suite(WorkingCopyNotInClasspathTests.class);
-}
-
-public void setUp() throws Exception {
- super.setUp();
- try {
- this.createJavaProject("P", new String[] {"src"}, "bin");
- this.createFolder("P/txt");
- IFile file = this.createFile("P/txt/X.java",
- "public class X {\n" +
- "}");
- ICompilationUnit cu = (ICompilationUnit)JavaCore.create(file);
- this.workingCopy = (ICompilationUnit)cu.getWorkingCopy();
- } catch (CoreException e) {
- e.printStackTrace();
- }
-}
-
-public void tearDown() throws Exception {
- try {
- if (this.workingCopy != null) {
- this.workingCopy.destroy();
- this.workingCopy = null;
- }
- this.deleteProject("P");
- } catch (CoreException e) {
- e.printStackTrace();
- }
- super.tearDown();
-}
-
-public void testCommit() throws CoreException {
- ICompilationUnit original = (ICompilationUnit)this.workingCopy.getOriginalElement();
- assertTrue("Original element should not be null", original != null);
-
- IBuffer workingCopyBuffer = this.workingCopy.getBuffer();
- assertTrue("Working copy buffer should not be null", workingCopyBuffer != null);
-
- String newContents =
- "public class X {\n" +
- " public void foo() {\n" +
- " }\n" +
- "}";
- workingCopyBuffer.setContents(newContents);
- this.workingCopy.commit(false, null);
-
- IBuffer originalBuffer = original.getBuffer();
- assertTrue("Original buffer should not be null", originalBuffer != null);
-
- assertEquals(
- "Unexpected contents",
- newContents,
- new String(originalBuffer.getCharacters()));
-}
-
-/*
- * Ensure that a working copy outside the classpath does not exist
- * (but can still be opened).
- */
-public void testExistence() throws CoreException {
- assertTrue("Working copy should exist", this.workingCopy.exists());
-}
-public void testParentExistence() throws CoreException {
- assertTrue("Working copy's parent should not exist", !this.workingCopy.getParent().exists());
-}
-
-/*
- * Ensure that a original cu (which is outside the classpath) does not exist
- * (but can still be opened).
- */
-public void testOriginalExistence() throws CoreException {
- ICompilationUnit original = (ICompilationUnit)this.workingCopy.getOriginalElement();
- assertTrue(
- "Original compilation unit should exist",
- original.exists());
-}
-public void testOriginalParentExistence() throws CoreException {
- assertTrue(
- "Original compilation unit's parent should not exist",
- !this.workingCopy.getOriginalElement().getParent().exists());
-}
-
-public void testIsOpen() throws CoreException {
- assertTrue("Working copy should be open", this.workingCopy.isOpen());
-}
-public void testOriginalIsOpen() throws CoreException {
- ICompilationUnit original = (ICompilationUnit)this.workingCopy.getOriginalElement();
- assertTrue(
- "Original compilation should be open",
- original.isOpen());
-}
-
-
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopySearchTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopySearchTests.java
deleted file mode 100644
index 8780919..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopySearchTests.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.IWorkingCopy;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.search.IJavaSearchScope;
-import org.eclipse.jdt.core.search.SearchEngine;
-import org.eclipse.jdt.core.tests.model.*;
-
-public class WorkingCopySearchTests extends JavaSearchTests {
- ICompilationUnit workingCopy;
-
-public WorkingCopySearchTests(String name) {
- super(name);
-}
-
-public static Test suite() {
- TestSuite suite = new Suite(WorkingCopySearchTests.class.getName());
-
- suite.addTest(new WorkingCopySearchTests("testAddNewType"));
- suite.addTest(new WorkingCopySearchTests("testRemoveType"));
- suite.addTest(new WorkingCopySearchTests("testMoveType"));
- suite.addTest(new WorkingCopySearchTests("testHierarchyScopeOnWorkingCopy"));
- suite.addTest(new WorkingCopySearchTests("testDeclarationOfReferencedTypes"));
-
- return suite;
-}
-/**
- * Get a new working copy.
- */
-protected void setUp() {
- try {
- this.workingCopy = (ICompilationUnit)this.getCompilationUnit("JavaSearch", "src", "wc", "X.java").getWorkingCopy();
- } catch (JavaModelException e) {
- e.printStackTrace();
- }
-}
-/**
- * Destroy the working copy.
- */
-protected void tearDown() throws Exception {
- this.workingCopy.destroy();
- this.workingCopy = null;
-}
-
-
-/**
- * Hierarchy scope on a working copy test.
- */
-public void testHierarchyScopeOnWorkingCopy() throws JavaModelException, CoreException {
- ICompilationUnit unit = this. getCompilationUnit("JavaSearch", "src", "a9", "A.java");
- ICompilationUnit workingCopy = (ICompilationUnit)unit.getWorkingCopy();
- try {
- IType type = workingCopy.getType("A");
- IJavaSearchScope scope = SearchEngine.createHierarchyScope(type);
- assertTrue("a9.A should be included in hierarchy scope", scope.encloses(type));
- assertTrue("a9.C should be included in hierarchy scope", scope.encloses(workingCopy.getType("C")));
- assertTrue("a9.B should be included in hierarchy scope", scope.encloses(workingCopy.getType("B")));
- IPath path = unit.getUnderlyingResource().getFullPath();
- assertTrue("a9/A.java should not be included in hierarchy scope", !scope.encloses(path.toString()));
- } finally {
- workingCopy.destroy();
- }
-}
-
-
-/**
- * Type declaration in a working copy test.
- * A new type is added in the working copy only.
- */
-public void testAddNewType() throws JavaModelException, CoreException {
- this.workingCopy.createType(
- "class NewType {\n" +
- "}",
- null,
- false,
- null);
-
- IJavaSearchScope scope =
- SearchEngine.createJavaSearchScope(
- new IJavaElement[] {this.workingCopy.getParent()});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine(new IWorkingCopy[] {this.workingCopy}).search(
- getWorkspace(),
- "NewType",
- TYPE,
- DECLARATIONS,
- scope,
- resultCollector);
- assertEquals(
- "src/wc/X.java wc.NewType [NewType]",
- resultCollector.toString());
-}
-/**
- * Declaration of referenced types test.
- * (Regression test for bug 5355 search: NPE in searchDeclarationsOfReferencedTypes )
- */
-public void testDeclarationOfReferencedTypes() throws JavaModelException, CoreException {
- IMethod method = this.workingCopy.getType("X").createMethod(
- "public void foo() {\n" +
- " X x = new X();\n" +
- "}",
- null,
- true,
- null);
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine().searchDeclarationsOfReferencedTypes(
- getWorkspace(),
- method,
- resultCollector
- );
- assertEquals(
- "src/wc/X.java wc.X [X]",
- resultCollector.toString());
-}
-
-
-/**
- * Type declaration in a working copy test.
- * A type is removed from the working copy only.
- */
-public void testRemoveType() throws JavaModelException, CoreException {
- this.workingCopy.getType("X").delete(true, null);
-
- IJavaSearchScope scope =
- SearchEngine.createJavaSearchScope(
- new IJavaElement[] {this.workingCopy.getParent()});
-
- // type X should not be visible when working copy hides it
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- new SearchEngine(new IWorkingCopy[] {this.workingCopy}).search(
- getWorkspace(),
- "X",
- TYPE,
- DECLARATIONS,
- scope,
- resultCollector);
- assertEquals(
- "",
- resultCollector.toString());
-
- // ensure the type is still present in the compilation unit
- resultCollector = new JavaSearchResultCollector();
- new SearchEngine().search(
- getWorkspace(),
- "X",
- TYPE,
- DECLARATIONS,
- scope,
- resultCollector);
- assertEquals(
- "src/wc/X.java wc.X [X]",
- resultCollector.toString());
-
-}
-/**
- * Type declaration in a working copy test.
- * A type is moved from one working copy to another.
- */
-public void testMoveType() throws JavaModelException, CoreException {
-
- // move type X from working copy in one package to a working copy in another package
- IJavaElement element1 = getCompilationUnit("JavaSearch", "src", "wc1", "X.java").getWorkingCopy();
- ICompilationUnit workingCopy1 = (ICompilationUnit)element1;
- IJavaElement element2 = getCompilationUnit("JavaSearch", "src", "wc2", "Y.java").getWorkingCopy();
- ICompilationUnit workingCopy2 = (ICompilationUnit)element2;
-
- try {
- workingCopy1.getType("X").move(workingCopy2, null, null, true, null);
-
- SearchEngine searchEngine = new SearchEngine(new IWorkingCopy[] {workingCopy1, workingCopy2});
-
- // type X should not be visible in old package
- IJavaSearchScope scope1 = SearchEngine.createJavaSearchScope(new IJavaElement[] {workingCopy1.getParent()});
- JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
- searchEngine.search(
- getWorkspace(),
- "X",
- TYPE,
- DECLARATIONS,
- scope1,
- resultCollector);
- assertEquals(
- "",
- resultCollector.toString());
-
- // type X should be visible in new package
- IJavaSearchScope scope2 = SearchEngine.createJavaSearchScope(new IJavaElement[] {workingCopy2.getParent()});
- resultCollector = new JavaSearchResultCollector();
- searchEngine.search(
- getWorkspace(),
- "X",
- TYPE,
- DECLARATIONS,
- scope2,
- resultCollector);
- assertEquals(
- "src/wc2/Y.java wc2.X [X]",
- resultCollector.toString());
- } finally {
- workingCopy1.destroy();
- workingCopy2.destroy();
- }
-}
-
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java
deleted file mode 100644
index 44ecf5c..0000000
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java
+++ /dev/null
@@ -1,859 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.core.tests.model;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Vector;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.*;
-
-
-
-public class WorkingCopyTests extends ModifyingResourceTests {
- ICompilationUnit cu = null;
- ICompilationUnit copy = null;
-
- public class BufferFactory implements IBufferFactory {
- /*
- * @see IBufferFactory#createBuffer(IOpenable)
- */
- public IBuffer createBuffer(IOpenable owner) {
- return new Buffer(owner);
- }
-
- }
- public class Buffer implements IBuffer {
- IOpenable owner;
- ArrayList changeListeners;
- char[] contents = null;
- public Buffer(IOpenable owner) {
- this.owner = owner;
- }
- /*
- * @see IBuffer#addBufferChangedListener(IBufferChangedListener)
- */
- public void addBufferChangedListener(IBufferChangedListener listener) {
- if (this.changeListeners == null) {
- this.changeListeners = new ArrayList(5);
- }
- if (!this.changeListeners.contains(listener)) {
- this.changeListeners.add(listener);
- }
- }
-
- /*
- * @see IBuffer#append(char[])
- */
- public void append(char[] text) {
- }
-
- /*
- * @see IBuffer#append(String)
- */
- public void append(String text) {
- }
-
- /*
- * @see IBuffer#close()
- */
- public void close() {
- this.contents = null; // mark as closed
- if (this.changeListeners != null) {
- BufferChangedEvent event = null;
- event = new BufferChangedEvent(this, 0, 0, null);
- for (int i = 0, size = this.changeListeners.size(); i < size; ++i) {
- IBufferChangedListener listener = (IBufferChangedListener) this.changeListeners.get(i);
- listener.bufferChanged(event);
- }
- this.changeListeners = null;
- }
- }
-
- /*
- * @see IBuffer#getChar(int)
- */
- public char getChar(int position) {
- return 0;
- }
-
- /*
- * @see IBuffer#getCharacters()
- */
- public char[] getCharacters() {
- return contents;
- }
-
- /*
- * @see IBuffer#getContents()
- */
- public String getContents() {
- return new String(contents);
- }
-
- /*
- * @see IBuffer#getLength()
- */
- public int getLength() {
- return contents.length;
- }
-
- /*
- * @see IBuffer#getOwner()
- */
- public IOpenable getOwner() {
- return this.owner;
- }
-
- /*
- * @see IBuffer#getText(int, int)
- */
- public String getText(int offset, int length) {
- return null;
- }
-
- /*
- * @see IBuffer#getUnderlyingResource()
- */
- public IResource getUnderlyingResource() {
- return null;
- }
-
- /*
- * @see IBuffer#hasUnsavedChanges()
- */
- public boolean hasUnsavedChanges() {
- return false;
- }
-
- /*
- * @see IBuffer#isClosed()
- */
- public boolean isClosed() {
- return this.contents == null;
- }
-
- /*
- * @see IBuffer#isReadOnly()
- */
- public boolean isReadOnly() {
- return false;
- }
-
- /*
- * @see IBuffer#removeBufferChangedListener(IBufferChangedListener)
- */
- public void removeBufferChangedListener(IBufferChangedListener listener) {
- if (this.changeListeners != null) {
- this.changeListeners.remove(listener);
- if (this.changeListeners.size() == 0) {
- this.changeListeners = null;
- }
- }
- }
-
- /*
- * @see IBuffer#replace(int, int, char[])
- */
- public void replace(int position, int length, char[] text) {
- }
-
- /*
- * @see IBuffer#replace(int, int, String)
- */
- public void replace(int position, int length, String text) {
- }
-
- /*
- * @see IBuffer#save(IProgressMonitor, boolean)
- */
- public void save(IProgressMonitor progress, boolean force)
- throws JavaModelException {
- }
-
- /*
- * @see IBuffer#setContents(char[])
- */
- public void setContents(char[] characters) {
- contents = characters;
- }
-
- /*
- * @see IBuffer#setContents(String)
- */
- public void setContents(String characters) {
- contents = characters.toCharArray();
- }
-
-}
-
-public WorkingCopyTests(String name) {
- super(name);
-}
-
-public static Test suite() {
- TestSuite suite = new Suite(WorkingCopyTests.class.getName());
- suite.addTest(new WorkingCopyTests("testCreation"));
-
- suite.addTest(new WorkingCopyTests("testContents"));
- suite.addTest(new WorkingCopyTests("testGeneral"));
- suite.addTest(new WorkingCopyTests("testOperations"));
- suite.addTest(new WorkingCopyTests("testMultipleCommit"));
- suite.addTest(new WorkingCopyTests("testCustomizedBuffer"));
- suite.addTest(new WorkingCopyTests("testCustomizedBuffer2"));
- suite.addTest(new WorkingCopyTests("testShared1"));
- suite.addTest(new WorkingCopyTests("testShared2"));
- suite.addTest(new WorkingCopyTests("testOnClassFile"));
- suite.addTest(new WorkingCopyTests("testMoveTypeToAnotherWorkingCopy"));
-
- suite.addTest(new WorkingCopyTests("testGetOriginalBinaryElement"));
- suite.addTest(new WorkingCopyTests("testGetOriginalCU"));
- suite.addTest(new WorkingCopyTests("testGetOriginalElementNotInWorkingCopy"));
- suite.addTest(new WorkingCopyTests("testGetOriginalField"));
- suite.addTest(new WorkingCopyTests("testGetOriginalImportDeclaration"));
- suite.addTest(new WorkingCopyTests("testGetOriginalImportContainer"));
- suite.addTest(new WorkingCopyTests("testGetOriginalInitializer"));
- suite.addTest(new WorkingCopyTests("testGetOriginalInnerType"));
- suite.addTest(new WorkingCopyTests("testGetOriginalInnerField"));
- suite.addTest(new WorkingCopyTests("testGetOriginalInnerMethod"));
- suite.addTest(new WorkingCopyTests("testGetOriginalMethod"));
- suite.addTest(new WorkingCopyTests("testGetOriginalPackageDeclaration"));
- suite.addTest(new WorkingCopyTests("testGetOriginalType"));
- suite.addTest(new WorkingCopyTests("testRenameMethod"));
- suite.addTest(new WorkingCopyTests("testChangeContent"));
- suite.addTest(new WorkingCopyTests("testChangeContentOfReadOnlyCU"));
-
- suite.addTest(new WorkingCopyTests("testNonExistingCU"));
-
- return suite;
-}
-protected void setUp() {
- try {
- this.createJavaProject(
- "P",
- new String[] {"src"},
- new String[] {this.getExternalJCLPath(), "lib"},
- "bin");
- this.createFolder("P/src/x/y");
- this.createFile("P/src/x/y/A.java",
- "package x.y;\n" +
- "import java.io.File;\n" +
- "public class A {\n" +
- " public class Inner {\n" +
- " public class InnerInner {\n" +
- " }\n" +
- " int innerField;\n" +
- " void innerMethod() {\n" +
- " }\n" +
- " }\n" +
- " static String FIELD;\n" +
- " {\n" +
- " FIELD = File.pathSeparator;\n" +
- " }\n" +
- " public void foo() {\n" +
- " }\n" +
- "}");
- this.cu = this.getCompilationUnit("P/src/x/y/A.java");
- this.copy = (ICompilationUnit) cu.getWorkingCopy();
- } catch (CoreException e) {
- e.printStackTrace();
- throw new RuntimeException(e.getMessage());
- }
-}
-protected void tearDown() throws Exception {
- if (this.copy != null) this.copy.destroy();
- this.deleteProject("P");
-}
-/**
- */
-public void testChangeContent() throws CoreException {
- String newContents =
- "package x.y;\n" +
- "public class A {\n" +
- " public void bar() {\n" +
- " }\n" +
- "}";
- this.copy.getBuffer().setContents(newContents);
- this.copy.reconcile();
- assertEquals(
- "Unexpected working copy contents",
- newContents,
- this.copy.getBuffer().getContents());
-
- this.copy.commit(true, null);
- assertEquals(
- "Unexpected original cu contents",
- newContents,
- this.cu.getBuffer().getContents());
-}
-/**
- */
-public void testChangeContentOfReadOnlyCU() throws CoreException {
- IResource resource = this.cu.getUnderlyingResource();
- boolean readOnlyFlag = resource.isReadOnly();
- boolean didComplain = false;
- try {
- resource.setReadOnly(true);
- this.copy.getBuffer().setContents("invalid");
- this.copy.commit(true, null);
- } catch(JavaModelException e){
- didComplain = true;
- } finally {
- resource.setReadOnly(readOnlyFlag);
- }
- assertTrue("Should have complained about modifying a read-only unit:", didComplain);
- assertTrue("ReadOnly buffer got modified:", !this.cu.getBuffer().getContents().equals("invalid"));
-}
-
-/**
- * Ensures that the source contents of a working copy are
- * not altered by changes to the source of the original compilation
- * unit.
- */
-public void testContents() throws CoreException {
- String originalSource = this.cu.getSource();
- IType type = this.cu.getType("A");
- assertDeletion(type);
- assertTrue("source code of copy should still be original", this.copy.getSource().equals(originalSource));
-}
-
-/**
- * Test creating a working copy on a class file with a customized buffer.
- */
-public void testOnClassFile() throws JavaModelException {
- this.attachSource(this.getPackageFragmentRoot("P", this.getExternalJCLPath()), this.getExternalJCLSourcePath(), "src");
- IClassFile classFile = this.getClassFile("P", this.getExternalJCLPath(), "java.lang", "Object.class");
- IBufferFactory factory = new BufferFactory();
- IJavaElement customizedCopy = classFile.getWorkingCopy(null, factory);
- try {
- assertTrue("Should be an IOpenable", customizedCopy instanceof ICompilationUnit);
- IBuffer buffer = ((ICompilationUnit)customizedCopy).getBuffer();
- assertTrue("Unexpected buffer", buffer instanceof Buffer);
- assertTrue("Buffer should be initialized with source", buffer.getCharacters().length > 0);
- } finally {
- if (customizedCopy instanceof IWorkingCopy) {
- ((IWorkingCopy)customizedCopy).destroy();
- }
- }
-}
-/**
- * Create the compilation unit place holder for the working copy tests.
- */
-public void testCreation() throws JavaModelException {
- assertTrue("Failed to create X.java compilation unit", this.cu != null && this.cu.exists());
- assertTrue("Failed to create working copy on X.java", this.copy != null && this.copy.exists());
-}
-
-/**
- * Test creating a working copy with a customized buffer.
- */
-public void testCustomizedBuffer() throws JavaModelException {
- IBufferFactory factory = new BufferFactory();
- IWorkingCopy customizedCopy = (IWorkingCopy)this.cu.getWorkingCopy(null, factory, null);
- try {
- assertTrue("Should be an IOpenable", customizedCopy instanceof IOpenable);
- assertTrue("Unexpected buffer", ((IOpenable)customizedCopy).getBuffer() instanceof Buffer);
- } finally {
- customizedCopy.destroy();
- }
-}
-/**
- * Test closing then reopening a working copy with a customized buffer.
- */
-public void testCustomizedBuffer2() throws JavaModelException {
- IBufferFactory factory = new BufferFactory();
- IWorkingCopy customizedCopy = (IWorkingCopy)this.cu.getWorkingCopy(null, factory, null);
- try {
- assertTrue("Should be an IOpenable", customizedCopy instanceof IOpenable);
- IOpenable openableCopy = (IOpenable)customizedCopy;
- openableCopy.close();
- openableCopy.open(null);
- assertTrue("Unexpected buffer", openableCopy.getBuffer() instanceof Buffer);
- } finally {
- customizedCopy.destroy();
- }
-}
-/**
- * Tests the general functionality of a working copy:<ul>
- * <li>ensures that the copy and original compilation unit are not equal</li>
- * <li>ensures the correct retrieval of the original element</li>
- * <li>closing the package of the compilation unit does not close the copy</li>
- * <li>ensures that working copies are unique
- * <li>ensures committing changes from working copies
- */
-public void testGeneral() throws JavaModelException, CoreException, IOException {
-
- assertTrue("copy and actual should not be equal", !this.copy.equals(this.cu));
-
- IType copyType= this.copy.getType("A");
-
- assertTrue("can't get original from original", this.cu.getOriginalElement() == null);
-
- assertTrue("getting working copy from a copy should yield original copy", this.copy.getWorkingCopy() == this.copy);
-
- boolean ex= false;
- assertDeletion(copyType);
-
- // closing the package should not close the copy
- ((IOpenable)this.cu.getParent()).close();
- assertTrue("copy should still be open", this.copy.isOpen());
-
- // verify original still present
- assertTrue("actual type should still be present", this.cu.getType("A").exists());
-
- // getAnother working copy
- ICompilationUnit copy2= (ICompilationUnit)this.cu.getWorkingCopy();
- try {
- assertTrue("working copies should be unique ", !(this.copy.equals(copy2)));
-
- // delete a method from the 2nd working copy.
- IMethod method= copy2.getType("A").getMethod("foo", null);
-
- assertDeletion(method);
- IMethod originalMethod= this.cu.getType("A").getMethod("foo", null);
- assertTrue("method should still be present in original", originalMethod.exists());
-
- // commit the changes from the 2nd copy.
- copy2.commit(false, null);
-
- assertTrue("copy always has unsaved changes", copy2.hasUnsavedChanges());
-
- // original method should now be gone
- assertTrue("method should no longer be present in original after commit", !originalMethod.exists());
-
- // commit the changes from the 1st copy - should fail
- try {
- this.copy.commit(false, null);
- assertTrue("commit should have failed", ex);
- } catch (JavaModelException jme) {
- }
-
-
- // now force the update
- try {
- this.copy.commit(true, null);
- } catch (JavaModelException jme) {
- assertTrue("commit should work", false);
- }
-
- // now the type should be gone.
- assertTrue("original type should no longer be present", !this.cu.getType("A").exists());
-
-
- this.copy.close();
- ex= false;
- try {
- this.copy.open(null);
- } catch (JavaModelException e) {
- ex= true;
- }
- assertTrue("should be able to open working copy a 2nd time", !ex);
-
- // now destroy the handle
- this.copy.destroy();
- ex= false;
- try {
- this.copy.open(null);
- } catch (JavaModelException e) {
- ex= true;
- }
- assertTrue("should not be able to open working copy again", ex);
- } finally {
- copy2.destroy();
- }
-}
-/**
- * Ensures that no original element can be retrieved on a binary element.
- * unit.
- */
-public void testGetOriginalBinaryElement() throws CoreException {
- /* Evaluate the following in a scrapbook:
- org.eclipse.jdt.tests.core.ModifyingResourceTests.generateClassFile(
- "A",
- "public class A {\n" +
- "}")
- */
- byte[] bytes = new byte[] {
- -54, -2, -70, -66, 0, 3, 0, 45, 0, 10, 1, 0, 1, 65, 7, 0, 1, 1, 0, 16, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 79, 98, 106, 101, 99, 116, 7, 0, 3, 1, 0, 6, 60, 105, 110, 105, 116, 62, 1, 0, 3, 40, 41, 86, 1, 0, 4, 67, 111, 100, 101, 12, 0, 5, 0, 6, 10, 0, 4, 0, 8, 0, 33, 0, 2, 0, 4, 0, 0, 0,
- 0, 0, 1, 0, 1, 0, 5, 0, 6, 0, 1, 0, 7, 0, 0, 0, 17, 0, 1, 0, 1, 0, 0, 0, 5, 42, -73, 0, 9, -79, 0, 0, 0, 0, 0, 0,
- };
- this.createFile("P/lib/A.class", new String(bytes));
- IClassFile cf = this.getClassFile("P/lib/A.class");
- IJavaElement original= this.copy.getOriginal(cf);
- assertTrue("Element should not be found", original == null);
-}
-/**
- * Ensures that the original cu can be retrieved.
- */
-public void testGetOriginalCU() throws JavaModelException {
- IJavaElement original= this.copy.getOriginal(copy);
- assertTrue("Element is not a cu", original instanceof ICompilationUnit && !((ICompilationUnit)original).isWorkingCopy());
- assertTrue("Element should exist", original.exists());
-}
-/**
- * Ensures that getting the original element from a different compilation unit returns null.
- */
-public void testGetOriginalElementNotInWorkingCopy() throws CoreException {
- ICompilationUnit copy2 = null;
- try {
- this.createFile(
- "P/src/x/y/B.java",
- "package x.y;\n" +
- "public class B {\n" +
- "}");
- ICompilationUnit cu2 = this.getCompilationUnit("P/src/x/y/B.java");
- copy2 = (ICompilationUnit)cu2.getWorkingCopy();
-
- IPackageDeclaration pkg= copy2.getPackageDeclaration("x.y");
- IJavaElement original= this.copy.getOriginal(pkg);
- assertTrue("Element should not be found as from a different working copy", original == null);
- } finally {
- if (copy2 != null) copy2.destroy();
- }
-}
-/**
- * Ensures that the original field can be retrieved.
- */
-public void testGetOriginalField() throws JavaModelException {
- IType type = this.copy.getType("A");
- IJavaElement original = this.copy.getOriginal(type.getField("FIELD"));
- assertTrue("Element is not a method", original instanceof IField && !((ICompilationUnit)original.getParent().getParent()).isWorkingCopy());
- assertTrue("Element should exist", original.exists());
-}
-/**
- * Ensures that the original import declaration can be retrieved.
- */
-public void testGetOriginalImportDeclaration() throws JavaModelException {
- IImportDeclaration imprt = copy.getImport("java.io.File");
- IJavaElement original= this.copy.getOriginal(imprt);
- assertTrue("Element should exist", original.exists());
-}
-/**
- * Ensures that the original import container can be retrieved.
- */
-public void testGetOriginalImportContainer() throws JavaModelException {
- IImportContainer container = this.copy.getImportContainer();
- IJavaElement original = this.copy.getOriginal(container);
- assertTrue("Element should not be null", original != null);
- assertTrue("Element should exist", original.exists());
-}
-/**
- * Ensures that the original initializer can be retrieved.
- */
-public void testGetOriginalInitializer() throws JavaModelException {
- IType type= copy.getType("A");
- IJavaElement original= copy.getOriginal(type.getInitializer(1));
- assertTrue("Element should exist", original.exists());
-}
-/**
- */
-public void testGetOriginalInnerField() throws JavaModelException {
- IType innerType = this.copy.getType("A").getType("Inner");
- IJavaElement original = this.copy.getOriginal(innerType.getField("innerField"));
- assertTrue("Element is not a field", original instanceof IField);
- assertTrue("Element should exist", original.exists());
-}
-/**
- */
-public void testGetOriginalInnerMethod() throws JavaModelException {
- IType innerType = this.copy.getType("A").getType("Inner");
- IJavaElement original = copy.getOriginal(innerType.getMethods()[0]);
- assertTrue("Element is not a method", original instanceof IMethod);
- assertTrue("Element should exist", original.exists());
-}
-/**
- */
-public void testGetOriginalInnerType() throws JavaModelException {
- IType innerInnerType = this.copy.getType("A").getType("Inner").getType("InnerInner");
- IJavaElement original = this.copy.getOriginal(innerInnerType);
- assertTrue("Element is not a method", original instanceof IType);
- assertTrue("Element should exist", original.exists());
-
- Vector hierarchy = new Vector(5);
- IJavaElement parent= original.getParent();
- while (parent.getElementType() > IJavaElement.COMPILATION_UNIT) {
- hierarchy.addElement(parent);
- parent = parent.getParent();
- }
- hierarchy.addElement(parent);
- assertTrue("Compilation Unit should not be a working copy", !((ICompilationUnit)hierarchy.lastElement()).isWorkingCopy());
-}
-/**
- * Ensures that the original method can be retrieved.
- */
-public void testGetOriginalMethod() throws JavaModelException {
- IType type = this.copy.getType("A");
- IJavaElement original= copy.getOriginal(type.getMethods()[0]);
- assertTrue("Element is not a method", original instanceof IMethod);
- assertTrue("Element should exist", original.exists());
-}
-/**
- * Ensures that renaming a method of a working copy does
- * not alter the source of the original compilation
- * unit.
- */
-public void testRenameMethod() throws JavaModelException {
- IType type = this.copy.getType("A");
- IMethod method = type.getMethods()[0];
- IJavaElement original= copy.getOriginal(method);
- method.rename("bar", false, null);
- assertEquals("Invalid name of working copy method", "bar", type.getMethods()[0].getElementName());
- assertEquals("Invalid name of original method", "foo", original.getElementName());
-}
-/**
- * Ensures that the original package declaration can be retrieved.
- */
-public void testGetOriginalPackageDeclaration() throws JavaModelException {
- IPackageDeclaration pkg = this.copy.getPackageDeclaration("x.y");
- IJavaElement original = this.copy.getOriginal(pkg);
- assertTrue("Element should exist", original.exists());
-}
-/**
- * Ensures that the original type can be retrieved.
- */
-public void testGetOriginalType() throws JavaModelException {
- IType type = this.copy.getType("A");
- IJavaElement original= copy.getOriginal(type);
- assertTrue("Element should exist", original.exists());
-}
-/**
- * Ensures that a type can be moved to another working copy.
- * (regression test for bug 7881 IType.move() clobbers editing buffer of destination element)
- */
-public void testMoveTypeToAnotherWorkingCopy() throws CoreException {
- this.createFile(
- "P/src/x/y/B.java",
- "package x.y;\n" +
- "public class B {\n" +
- "}");
- ICompilationUnit cu2 = this.getCompilationUnit("P/src/x/y/B.java");
- ICompilationUnit copy2 = (ICompilationUnit)cu2.getWorkingCopy();
- try {
- IType classA = this.copy.getType("A");
- IType classB = copy2.getType("B");
- classA.move(classB, null, null, false, null);
- assertTrue("A should not exist", !classA.exists());
- assertTrue("B.A should exist", classB.getType("A").exists());
- assertTrue("Buffer for A should not be null", this.copy.getBuffer() != null);
- assertEquals("Invalid content for A",
- "package x.y;\n" +
- "import java.io.File;\n",
- this.copy.getBuffer().getContents());
- assertTrue("Buffer for B should not be null", copy2.getBuffer() != null);
- assertEquals("Invalid content for B",
- "package x.y;\n" +
- "public class B {\n" +
- "public class A {\n" +
- " public class Inner {\n" +
- " public class InnerInner {\n" +
- " }\n" +
- " int innerField;\n" +
- " void innerMethod() {\n" +
- " }\n" +
- " }\n" +
- " static String FIELD;\n" +
- " {\n" +
- " FIELD = File.pathSeparator;\n" +
- " }\n" +
- " public void foo() {\n" +
- " }\n" +
- "}\n" +
- "}",
- copy2.getBuffer().getContents());
- } finally {
- copy2.destroy();
- }
-}
-/**
- * Test creating a shared working copy.
- */
-public void testShared1() throws JavaModelException {
- IJavaElement shared = this.cu.getSharedWorkingCopy(null, null, null);
- try {
- assertTrue("Should be an IWorkingCopy", shared instanceof IWorkingCopy);
- assertTrue("Original element should have shared working copy", this.cu.findSharedWorkingCopy(null) == shared);
- } finally {
- if (shared instanceof IWorkingCopy) {
- ((IWorkingCopy)shared).destroy();
- }
- }
- assertTrue("Original element should not have shared working copy", this.cu.findSharedWorkingCopy(null) == null);
-}
-/**
- * Test several call to creating shared working copy.
- */
-public void testShared2() throws JavaModelException {
- IWorkingCopy shared = (IWorkingCopy)this.cu.getSharedWorkingCopy(null, null, null);
- try {
- IWorkingCopy shared2 = (IWorkingCopy)this.cu.getSharedWorkingCopy(null, null, null);
- assertTrue("Second working copy should be identical to first one", shared2 == shared);
- } finally {
- shared.destroy();
- try {
- assertTrue("Original element should still have shared working copy", this.cu.findSharedWorkingCopy(null) == shared);
- } finally {
- shared.destroy();
- }
- }
- assertTrue("Original element should not have shared working copy", this.cu.findSharedWorkingCopy(null) == null);
-}
-/**
- * Tests that multiple commits are possible with the same working copy.
- */
-public void testMultipleCommit() throws JavaModelException, CoreException, IOException {
-
- // Add a method to the working copy
- IType gp = this.copy.getType("A");
- try {
- gp.createMethod("public void anotherMethod() {}\n",null, false, null);
- } catch (JavaModelException jme) {
- assertTrue("creation failed", false);
- }
-
- // commit the changes from the copy.
- try {
- this.copy.commit(false, null);
- } catch (JavaModelException t) {
- assertTrue("commit failed", false);
- }
-
- // new method added
- assertTrue("method should exist after commit",
- this.cu.getType("A").getMethod("anotherMethod", new String[]{}).exists());
-
- //add another method
- try {
- gp.createMethod("public void anotherAnotherMethod() {}\n", null, false, null);
- } catch (JavaModelException x) {
- assertTrue("Creation failed 2", false);
- }
-
- //commit the new method
- try {
- this.copy.commit(false, null);
- } catch (JavaModelException t) {
- assertTrue("commit2 failed", false);
- }
-
- // new method added
- assertTrue("second method added should exist after commit",
- this.cu.getType("A").getMethod("anotherAnotherMethod", new String[]{}).exists());
-}
-/**
- * Creates a working copy on a non-existing compilation unit.
- * (regression test for bug 8921 DCR - Need a way to create a working copy ignoring existing files)
- */
-public void testNonExistingCU() throws JavaModelException {
- ICompilationUnit cu = this.getCompilationUnit("P/src/x/y/NonExisting.java");
- IWorkingCopy copy = null;
- try {
- // getBuffer()
- copy = (IWorkingCopy)cu.getWorkingCopy();
- assertEquals("Buffer should be empty", "", ((IOpenable)copy).getBuffer().getContents());
-
- // exists()
- assertTrue("Working copy should exists", ((IJavaElement)copy).exists());
-
- // getCorrespondingResource()
- assertEquals("Corresponding resource should be null", null, ((IJavaElement)copy).getCorrespondingResource());
-
- // getOriginalElement()
- assertEquals("Unexpected orginal element", cu, copy.getOriginalElement());
-
- // getPath()
- assertEquals("Unexpected path", new Path("/P/src/x/y/NonExisting.java"), ((IJavaElement)copy).getPath());
-
- // getResource()
- assertEquals("Unexpected resource", null, ((IJavaElement)copy).getResource());
-
- // isBasedOn()
- assertTrue("Working copy should not be based on original resource", !copy.isBasedOn(cu.getResource()));
-
- // isConsistent()
- assertTrue("Working copy should be consistent", ((IOpenable)copy).isConsistent());
-
- // restore()
- boolean exception = false;
- try {
- copy.restore();
- } catch (JavaModelException e) {
- exception = true;
- }
- assertTrue("Should not be able to restore from original element", exception);
-
- // makeConsistent()
- ((IOpenable)copy).getBuffer().setContents(
- "public class X {\n" +
- "}");
- assertTrue("Working copy should not be consistent", !((IOpenable)copy).isConsistent());
- ((IOpenable)copy).makeConsistent(null);
- assertTrue("Working copy should be consistent", ((IOpenable)copy).isConsistent());
-
- // save()
- ((IOpenable)copy).getBuffer().setContents(
- "public class Y {\n" +
- "}");
- ((IOpenable)copy).save(null, false);
- assertTrue("Working copy should be consistent after save", ((IOpenable)copy).isConsistent());
- assertTrue("Original cu should not exist", !cu.exists());
-
- // commit()
- copy.commit(false, null);
- assertTrue("Original cu should exist", cu.exists());
- } finally {
- if (copy != null) {
- copy.destroy();
- }
- if (cu.exists()) {
- cu.delete(true, null);
- }
- }
-}
-/**
- * Tests the general functionality of a operations working with working copies:<ul>
- * <li>ensures that the copy cannot be renamed</li>
- * <li>ensures that the copy cannot be moved to the same location as the original cu</li>
- * <li>ensures that the copy can be copied to a different location as the original cu</li>
- */
-public void testOperations() throws JavaModelException {
- // rename working copy
- boolean ex= false;
- try {
- this.copy.rename("someName.java", false, null);
- } catch (JavaModelException jme) {
- assertTrue("Incorrect status code for attempting to rename working copy", jme.getStatus().getCode() == IJavaModelStatusConstants.INVALID_ELEMENT_TYPES);
- ex= true;
- }
- assertTrue("renaming a working copy should fail", ex);
-
- // move to same location as original cu
- ex= false;
- try {
- this.copy.move((IPackageFragment)this.cu.getParent(), null, "someName.java", false, null);
- } catch (JavaModelException jme) {
- assertTrue("Incorrect status code for attempting to move working copy", jme.getStatus().getCode() == IJavaModelStatusConstants.INVALID_ELEMENT_TYPES);
- ex= true;
- }
- assertTrue("moving a working copy should fail", ex);
-
- // copy working copy to default package
- IPackageFragment pkg= getPackageFragment("P", "src", "");
- this.copy.copy(pkg, null, "someName.java", false, null);
- assertCreation(this.copy);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.model/test.xml b/org.eclipse.jdt.core.tests.model/test.xml
deleted file mode 100644
index 9658944..0000000
--- a/org.eclipse.jdt.core.tests.model/test.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0"?>
-
-<project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <property name="eclipse-home" value="${basedir}\..\.."/>
-
- <!-- sets the properties eclipse-home, and library-file -->
- <property name="plugin-name" value="org.eclipse.jdt.core.tests.model"/>
- <property name="library-file"
- value="${eclipse-home}/plugins/org.eclipse.test/library.xml"/>
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- <delete>
- <fileset dir="${eclipse-home}" includes="org*.xml"/>
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <!-- Java Model tests -->
- <property name="jdt-model-folder"
- value="${eclipse-home}/jdt_model_folder"/>
- <delete dir="${jdt-model-folder}" quiet="true"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${jdt-model-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.jdt.core.tests.model.AllJavaModelTests"/>
- </ant>
-
- <!-- DOM tests -->
- <property name="jdt-dom-folder"
- value="${eclipse-home}/jdt_dom_folder"/>
- <delete dir="${jdt-dom-folder}" quiet="true"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${jdt-dom-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.jdt.core.tests.dom.RunAllTests"/>
- </ant>
- </target>
-
- <!-- This target holds code to cleanup the testing environment after -->
- <!-- after all of the tests have been run. You can use this target to -->
- <!-- delete temporary files that have been created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen -->
- <!-- after all the tests have been run should go here. -->
- <target name="run" depends="init,suite,cleanup">
- <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
- <property name="includes" value="org*.xml"/>
- <property name="output-file" value="${plugin-name}.xml"/>
- </ant>
- </target>
-
-</project>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/.classpath b/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/.classpath
deleted file mode 100644
index c47ceba..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="lib" path="attach.jar"/>
- <classpathentry kind="lib" path="attach2.jar"/>
- <classpathentry kind="src" path=""/>
- <classpathentry kind="var" path="JCL_LIB" sourcepath="JCL_SRC" rootpath="JCL_SRCROOT"/>
- <classpathentry kind="output" path=""/>
-</classpath>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/.project b/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/.project
deleted file mode 100644
index c05ce73..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.core</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attach.jar b/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attach.jar
deleted file mode 100644
index 2a34147..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attach.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attach2.jar b/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attach2.jar
deleted file mode 100644
index de4b989..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attach2.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attach2src.zip b/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attach2src.zip
deleted file mode 100644
index 56cc73c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attach2src.zip
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attachsrc.new.zip b/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attachsrc.new.zip
deleted file mode 100644
index 8b17f5a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attachsrc.new.zip
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attachsrc.zip b/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attachsrc.zip
deleted file mode 100644
index 02f0d58..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/AttachSourceTests/attachsrc.zip
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/.classpath b/org.eclipse.jdt.core.tests.model/workspace/Converter/.classpath
deleted file mode 100644
index 553236c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path=""/>
- <classpathentry kind="var" path="JCL_LIB" sourcepath="JCL_SRC" rootpath="JCL_SRCROOT"/>
- <classpathentry kind="var" path="CONVERTER_JCL_LIB" sourcepath="CONVERTER_JCL_SRC" rootpath="CONVERTER_JCL_SRCROOT"/>
- <classpathentry kind="output" path=""/>
-</classpath>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/.project b/org.eclipse.jdt.core.tests.model/workspace/Converter/.project
deleted file mode 100644
index c05ce73..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.core</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/Hello.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/Hello.java
deleted file mode 100644
index 2a1ad07..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/Hello.java
+++ /dev/null
@@ -1,23 +0,0 @@
-void ___eval() {
- new Runnable() {
- void ___run() throws Throwable {
- return blah;
- }
- private String blarg;
- public void run() {
- }
- };
-}
-public class Hello {
- private static int x;
- private String blah;
- public static void main(String[] args) {
- }
- public void hello() {
- }
- public boolean blah() {
- return false;
- }
- public void foo() {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/Test0157.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/Test0157.java
deleted file mode 100644
index cb5a1d2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/Test0157.java
+++ /dev/null
@@ -1,6 +0,0 @@
-import java.util.*;
-class Test0157 {
- int[] tab;
- String[] t;
- Test0157[] t2;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/Test0158.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/Test0158.java
deleted file mode 100644
index 8e72131..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/Test0158.java
+++ /dev/null
@@ -1,4 +0,0 @@
-import java.util.*;
-class Test0158 {
- Test0158[] t2;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/Test0170.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/Test0170.java
deleted file mode 100644
index 3101283..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/Test0170.java
+++ /dev/null
@@ -1,3 +0,0 @@
-import java.util.*;
-class Test0170 {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/AboutDialog.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/AboutDialog.java
deleted file mode 100644
index 79e4410..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/AboutDialog.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package junit.awtui;
-
-import java.awt.*;
-import java.awt.event.*;
-
-import junit.runner.Version;
-
-class AboutDialog extends Dialog {
- public AboutDialog(Frame parent) {
- super(parent);
-
- setResizable(false);
- setLayout(new GridBagLayout());
- setSize(330, 138);
- setTitle("About");
-
- Button button= new Button("Close");
- button.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- dispose();
- }
- }
- );
-
- Label label1= new Label("JUnit");
- label1.setFont(new Font("dialog", Font.PLAIN, 36));
-
- Label label2= new Label("JUnit "+Version.id()+ " by Kent Beck and Erich Gamma");
- label2.setFont(new Font("dialog", Font.PLAIN, 14));
-
- Logo logo= new Logo();
-
- GridBagConstraints constraintsLabel1= new GridBagConstraints();
- constraintsLabel1.gridx = 3; constraintsLabel1.gridy = 0;
- constraintsLabel1.gridwidth = 1; constraintsLabel1.gridheight = 1;
- constraintsLabel1.anchor = GridBagConstraints.CENTER;
- add(label1, constraintsLabel1);
-
- GridBagConstraints constraintsLabel2= new GridBagConstraints();
- constraintsLabel2.gridx = 2; constraintsLabel2.gridy = 1;
- constraintsLabel2.gridwidth = 2; constraintsLabel2.gridheight = 1;
- constraintsLabel2.anchor = GridBagConstraints.CENTER;
- add(label2, constraintsLabel2);
-
- GridBagConstraints constraintsButton1= new GridBagConstraints();
- constraintsButton1.gridx = 2; constraintsButton1.gridy = 2;
- constraintsButton1.gridwidth = 2; constraintsButton1.gridheight = 1;
- constraintsButton1.anchor = GridBagConstraints.CENTER;
- constraintsButton1.insets= new Insets(8, 0, 8, 0);
- add(button, constraintsButton1);
-
- GridBagConstraints constraintsLogo1= new GridBagConstraints();
- constraintsLogo1.gridx = 2; constraintsLogo1.gridy = 0;
- constraintsLogo1.gridwidth = 1; constraintsLogo1.gridheight = 1;
- constraintsLogo1.anchor = GridBagConstraints.CENTER;
- add(logo, constraintsLogo1);
-
- addWindowListener(
- new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- dispose();
- }
- }
- );
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/Logo.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/Logo.java
deleted file mode 100644
index a5cafc8..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/Logo.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package junit.awtui;
-
-import java.awt.*;
-import java.awt.image.*;
-import java.net.URL;
-
-import junit.runner.BaseTestRunner;
-
-public class Logo extends Canvas {
- private Image fImage;
- private int fWidth;
- private int fHeight;
-
- public Logo() {
- fImage= loadImage("logo.gif");
- MediaTracker tracker= new MediaTracker(this);
- tracker.addImage(fImage, 0);
- try {
- tracker.waitForAll();
- } catch (Exception e) {
- }
-
- if (fImage != null) {
- fWidth= fImage.getWidth(this);
- fHeight= fImage.getHeight(this);
- } else {
- fWidth= 20;
- fHeight= 20;
- }
- setSize(fWidth, fHeight);
- }
-
- public Image loadImage(String name) {
- Toolkit toolkit= Toolkit.getDefaultToolkit();
- try {
- URL url= BaseTestRunner.class.getResource(name);
- return toolkit.createImage((ImageProducer) url.getContent());
- } catch (Exception ex) {
- }
- return null;
- }
-
- public void paint(Graphics g) {
- paintBackground(g);
- if (fImage != null)
- g.drawImage(fImage, 0, 0, fWidth, fHeight, this);
- }
-
- public void paintBackground( java.awt.Graphics g) {
- g.setColor(SystemColor.control);
- g.fillRect(0, 0, getBounds().width, getBounds().height);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/ProgressBar.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/ProgressBar.java
deleted file mode 100644
index 5374298..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/ProgressBar.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package junit.awtui;
-
-import java.awt.*;
-
-public class ProgressBar extends Canvas {
- public boolean fError= false;
- public int fTotal= 0;
- public int fProgress= 0;
- public int fProgressX= 0;
-
- public ProgressBar() {
- super();
- setSize(20, 30);
- }
-
- private Color getStatusColor() {
- if (fError)
- return Color.red;
- return Color.green;
- }
-
- public void paint(Graphics g) {
- paintBackground(g);
- paintStatus(g);
- }
-
- public void paintBackground(Graphics g) {
- g.setColor(SystemColor.control);
- Rectangle r= getBounds();
- g.fillRect(0, 0, r.width, r.height);
- g.setColor(Color.darkGray);
- g.drawLine(0, 0, r.width-1, 0);
- g.drawLine(0, 0, 0, r.height-1);
- g.setColor(Color.white);
- g.drawLine(r.width-1, 0, r.width-1, r.height-1);
- g.drawLine(0, r.height-1, r.width-1, r.height-1);
- }
-
- public void paintStatus(Graphics g) {
- g.setColor(getStatusColor());
- Rectangle r= new Rectangle(0, 0, fProgressX, getBounds().height);
- g.fillRect(1, 1, r.width-1, r.height-2);
- }
-
- private void paintStep(int startX, int endX) {
- repaint(startX, 1, endX-startX, getBounds().height-2);
- }
-
- public void reset() {
- fProgressX= 1;
- fProgress= 0;
- fError= false;
- paint(getGraphics());
- }
-
- public int scale(int value) {
- if (fTotal > 0)
- return Math.max(1, value*(getBounds().width-1)/fTotal);
- return value;
- }
-
- public void setBounds(int x, int y, int w, int h) {
- super.setBounds(x, y, w, h);
- fProgressX= scale(fProgress);
- }
-
- public void start(int total) {
- fTotal= total;
- reset();
- }
-
- public void step(boolean successful) {
- fProgress++;
- int x= fProgressX;
-
- fProgressX= scale(fProgress);
-
- if (!fError && !successful) {
- fError= true;
- x= 1;
- }
- paintStep(x, fProgressX);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/TestRunner.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/TestRunner.java
deleted file mode 100644
index d1b9499..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/awtui/TestRunner.java
+++ /dev/null
@@ -1,481 +0,0 @@
-package junit.awtui;
-
-import junit.framework.*;
-import junit.runner.*;
-
-import java.util.Vector;
-import java.lang.reflect.*;
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.image.*;
-import java.io.*;
-
-/**
- * An AWT based user interface to run tests.
- * Enter the name of a class which either provides a static
- * suite method or is a subclass of TestCase.
- * <pre>
- * Synopsis: java junit.awtui.TestRunner [-noloading] [TestCase]
- * </pre>
- * TestRunner takes as an optional argument the name of the testcase class to be run.
- */
- public class TestRunner extends BaseTestRunner {
- protected Frame fFrame;
- protected Vector fExceptions;
- protected Vector fFailedTests;
- protected Thread fRunner;
- protected TestResult fTestResult;
-
- protected TextArea fTraceArea;
- protected TextField fSuiteField;
- protected Button fRun;
- protected ProgressBar fProgressIndicator;
- protected List fFailureList;
- protected Logo fLogo;
- protected Label fNumberOfErrors;
- protected Label fNumberOfFailures;
- protected Label fNumberOfRuns;
- protected Button fQuitButton;
- protected Button fRerunButton;
- protected TextField fStatusLine;
- protected Checkbox fUseLoadingRunner;
-
- protected static Font PLAIN_FONT= new Font("dialog", Font.PLAIN, 12);
- private static final int GAP= 4;
- private static final String SUITE_METHODNAME= "suite";
-
- public TestRunner() {
- }
-
- private void about() {
- AboutDialog about= new AboutDialog(fFrame);
- about.setModal(true);
- about.setLocation(300, 300);
- about.setVisible(true);
- }
-
- public void addError(Test test, Throwable t) {
- fNumberOfErrors.setText(Integer.toString(fTestResult.errorCount()));
- appendFailure("Error", test, t);
- }
-
- public void addFailure(Test test, AssertionFailedError t) {
- fNumberOfFailures.setText(Integer.toString(fTestResult.failureCount()));
- appendFailure("Failure", test, t);
- }
-
- protected void addGrid(Panel p, Component co, int x, int y, int w, int fill, double wx, int anchor) {
- GridBagConstraints c= new GridBagConstraints();
- c.gridx= x; c.gridy= y;
- c.gridwidth= w;
- c.anchor= anchor;
- c.weightx= wx;
- c.fill= fill;
- if (fill == GridBagConstraints.BOTH || fill == GridBagConstraints.VERTICAL)
- c.weighty= 1.0;
- c.insets= new Insets(y == 0 ? GAP : 0, x == 0 ? GAP : 0, GAP, GAP);
- p.add(co, c);
- }
-
- private void appendFailure(String kind, Test test, Throwable t) {
- kind+= ": " + test;
- String msg= t.getMessage();
- if (msg != null) {
- kind+= ":" + truncate(msg);
- }
- fFailureList.add(kind);
- fExceptions.addElement(t);
- fFailedTests.addElement(test);
- if (fFailureList.getItemCount() == 1) {
- fFailureList.select(0);
- failureSelected();
- }
- }
- /**
- * Creates the JUnit menu. Clients override this
- * method to add additional menu items.
- */
- protected Menu createJUnitMenu() {
- Menu menu= new Menu("JUnit");
- MenuItem mi= new MenuItem("About...");
- mi.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- about();
- }
- }
- );
- menu.add(mi);
-
- menu.addSeparator();
- mi= new MenuItem("Exit");
- mi.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- System.exit(0);
- }
- }
- );
- menu.add(mi);
- return menu;
- }
-
- protected void createMenus(MenuBar mb) {
- mb.add(createJUnitMenu());
- }
- protected TestResult createTestResult() {
- return new TestResult();
- }
-
- protected Frame createUI(String suiteName) {
- Frame frame= new Frame("JUnit");
- Image icon= loadFrameIcon();
- if (icon != null)
- frame.setIconImage(icon);
-
- frame.setLayout(new BorderLayout(0, 0));
- frame.setBackground(SystemColor.control);
- final Frame finalFrame= frame;
-
- frame.addWindowListener(
- new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- finalFrame.dispose();
- System.exit(0);
- }
- }
- );
-
- MenuBar mb = new MenuBar();
- createMenus(mb);
- frame.setMenuBar(mb);
-
- //---- first section
- Label suiteLabel= new Label("Test class name:");
-
- fSuiteField= new TextField(suiteName != null ? suiteName : "");
- fSuiteField.selectAll();
- fSuiteField.requestFocus();
- fSuiteField.setFont(PLAIN_FONT);
- fSuiteField.setColumns(40);
- fSuiteField.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- runSuite();
- }
- }
- );
- fSuiteField.addTextListener(
- new TextListener() {
- public void textValueChanged(TextEvent e) {
- fRun.setEnabled(fSuiteField.getText().length() > 0);
- fStatusLine.setText("");
- }
- }
- );
- fRun= new Button("Run");
- fRun.setEnabled(false);
- fRun.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- runSuite();
- }
- }
- );
- boolean useLoader= useReloadingTestSuiteLoader();
- fUseLoadingRunner= new Checkbox("Reload classes every run", useLoader);
- if (inVAJava())
- fUseLoadingRunner.setVisible(false);
-
- //---- second section
- fProgressIndicator= new ProgressBar();
-
- //---- third section
- fNumberOfErrors= new Label("0000", Label.RIGHT);
- fNumberOfErrors.setText("0");
- fNumberOfErrors.setFont(PLAIN_FONT);
-
- fNumberOfFailures= new Label("0000", Label.RIGHT);
- fNumberOfFailures.setText("0");
- fNumberOfFailures.setFont(PLAIN_FONT);
-
- fNumberOfRuns= new Label("0000", Label.RIGHT);
- fNumberOfRuns.setText("0");
- fNumberOfRuns.setFont(PLAIN_FONT);
-
- Panel numbersPanel= new Panel(new FlowLayout());
- numbersPanel.add(new Label("Runs:")); numbersPanel.add(fNumberOfRuns);
- numbersPanel.add(new Label(" Errors:")); numbersPanel.add(fNumberOfErrors);
- numbersPanel.add(new Label(" Failures:")); numbersPanel.add(fNumberOfFailures);
-
-
- //---- fourth section
- Label failureLabel= new Label("Errors and Failures:");
-
- fFailureList= new List(5);
- fFailureList.addItemListener(
- new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- failureSelected();
- }
- }
- );
- fRerunButton= new Button("Run");
- fRerunButton.setEnabled(false);
- fRerunButton.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- rerun();
- }
- }
- );
-
- Panel failedPanel= new Panel(new GridLayout(0, 1, 0, 2));
- failedPanel.add(fRerunButton);
-
- fTraceArea= new TextArea();
- fTraceArea.setRows(5);
- fTraceArea.setColumns(60);
-
- //---- fifth section
- fStatusLine= new TextField();
- fStatusLine.setFont(PLAIN_FONT);
- fStatusLine.setEditable(false);
- fStatusLine.setForeground(Color.red);
-
- fQuitButton= new Button("Exit");
- fQuitButton.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- System.exit(0);
- }
- }
- );
-
- // ---------
- fLogo= new Logo();
-
- //---- overall layout
- Panel panel= new Panel(new GridBagLayout());
-
- addGrid(panel, suiteLabel, 0, 0, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST);
-
- addGrid(panel, fSuiteField, 0, 1, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST);
- addGrid(panel, fRun, 2, 1, 1, GridBagConstraints.HORIZONTAL, 0.0, GridBagConstraints.CENTER);
- addGrid(panel, fUseLoadingRunner, 0, 2, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST);
- addGrid(panel, fProgressIndicator, 0, 3, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST);
- addGrid(panel, fLogo, 2, 3, 1, GridBagConstraints.NONE, 0.0, GridBagConstraints.NORTH);
-
- addGrid(panel, numbersPanel, 0, 4, 2, GridBagConstraints.NONE, 0.0, GridBagConstraints.CENTER);
-
- addGrid(panel, failureLabel, 0, 5, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST);
- addGrid(panel, fFailureList, 0, 6, 2, GridBagConstraints.BOTH, 1.0, GridBagConstraints.WEST);
- addGrid(panel, failedPanel, 2, 6, 1, GridBagConstraints.HORIZONTAL, 0.0, GridBagConstraints.CENTER);
- addGrid(panel, fTraceArea, 0, 7, 2, GridBagConstraints.BOTH, 1.0, GridBagConstraints.WEST);
-
- addGrid(panel, fStatusLine, 0, 8, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.CENTER);
- addGrid(panel, fQuitButton, 2, 8, 1, GridBagConstraints.HORIZONTAL, 0.0, GridBagConstraints.CENTER);
-
- frame.add(panel, BorderLayout.CENTER);
- frame.pack();
- return frame;
- }
-
- public void failureSelected() {
- fRerunButton.setEnabled(isErrorSelected());
- showErrorTrace();
- }
-
- public void endTest(Test test) {
- setLabelValue(fNumberOfRuns, fTestResult.runCount());
- synchronized(this) {
- fProgressIndicator.step(fTestResult.wasSuccessful());
- }
- }
-
- private boolean isErrorSelected() {
- return fFailureList.getSelectedIndex() != -1;
- }
-
- private Image loadFrameIcon() {
- Toolkit toolkit= Toolkit.getDefaultToolkit();
- try {
- java.net.URL url= BaseTestRunner.class.getResource("smalllogo.gif");
- return toolkit.createImage((ImageProducer) url.getContent());
- } catch (Exception ex) {
- }
- return null;
- }
-
- public Thread getRunner() {
- return fRunner;
- }
-
- public static void main(String[] args) {
- new TestRunner().start(args);
- }
-
- public static void run(Class test) {
- String args[]= { test.getName() };
- main(args);
- }
-
- public void rerun() {
- int index= fFailureList.getSelectedIndex();
- if (index == -1)
- return;
-
- Test test= (Test)fFailedTests.elementAt(index);
- if (!(test instanceof TestCase)) {
- showInfo("Could not reload "+ test.toString());
- return;
- }
- Test reloadedTest= null;
- try {
- Class reloadedTestClass= getLoader().reload(test.getClass());
- Class[] classArgs= { String.class };
- Constructor constructor= reloadedTestClass.getConstructor(classArgs);
- Object[] args= new Object[]{((TestCase)test).getName()};
- reloadedTest=(Test)constructor.newInstance(args);
- } catch(Exception e) {
- showInfo("Could not reload "+ test.toString());
- return;
- }
- TestResult result= new TestResult();
- reloadedTest.run(result);
-
- String message= reloadedTest.toString();
- if(result.wasSuccessful())
- showInfo(message+" was successful");
- else if (result.errorCount() == 1)
- showStatus(message+" had an error");
- else
- showStatus(message+" had a failure");
- }
-
- protected void reset() {
- setLabelValue(fNumberOfErrors, 0);
- setLabelValue(fNumberOfFailures, 0);
- setLabelValue(fNumberOfRuns, 0);
- fProgressIndicator.reset();
- fRerunButton.setEnabled(false);
- fFailureList.removeAll();
- fExceptions= new Vector(10);
- fFailedTests= new Vector(10);
- fTraceArea.setText("");
-
- }
- /**
- * runs a suite.
- * @deprecated use runSuite() instead
- */
- public void run() {
- runSuite();
- }
-
- protected void runFailed(String message) {
- showStatus(message);
- fRun.setLabel("Run");
- fRunner= null;
- }
-
- synchronized public void runSuite() {
- if (fRunner != null) {
- fTestResult.stop();
- } else {
- setLoading(shouldReload());
- fRun.setLabel("Stop");
- showInfo("Initializing...");
- reset();
-
- showInfo("Load Test Case...");
-
- final Test testSuite= getTest(fSuiteField.getText());
- if (testSuite != null) {
- fRunner= new Thread() {
- public void run() {
- fTestResult= createTestResult();
- fTestResult.addListener(TestRunner.this);
- fProgressIndicator.start(testSuite.countTestCases());
- showInfo("Running...");
-
- long startTime= System.currentTimeMillis();
- testSuite.run(fTestResult);
-
- if (fTestResult.shouldStop()) {
- showStatus("Stopped");
- } else {
- long endTime= System.currentTimeMillis();
- long runTime= endTime-startTime;
- showInfo("Finished: " + elapsedTimeAsString(runTime) + " seconds");
- }
- fTestResult= null;
- fRun.setLabel("Run");
- fRunner= null;
- System.gc();
- }
- };
- fRunner.start();
- }
- }
- }
-
- private boolean shouldReload() {
- return !inVAJava() && fUseLoadingRunner.getState();
- }
-
- private void setLabelValue(Label label, int value) {
- label.setText(Integer.toString(value));
- label.invalidate();
- label.getParent().validate();
-
- }
-
- public void setSuiteName(String suite) {
- fSuiteField.setText(suite);
- }
-
- private void showErrorTrace() {
- int index= fFailureList.getSelectedIndex();
- if (index == -1)
- return;
-
- Throwable t= (Throwable) fExceptions.elementAt(index);
- fTraceArea.setText(getFilteredTrace(t));
- }
-
-
- private void showInfo(String message) {
- fStatusLine.setFont(PLAIN_FONT);
- fStatusLine.setForeground(Color.black);
- fStatusLine.setText(message);
- }
-
- protected void clearStatus() {
- showStatus("");
- }
-
- private void showStatus(String status) {
- fStatusLine.setFont(PLAIN_FONT);
- fStatusLine.setForeground(Color.red);
- fStatusLine.setText(status);
- }
- /**
- * Starts the TestRunner
- */
- public void start(String[] args) {
- String suiteName= processArguments(args);
- fFrame= createUI(suiteName);
- fFrame.setLocation(200, 200);
- fFrame.setVisible(true);
-
- if (suiteName != null) {
- setSuiteName(suiteName);
- runSuite();
- }
- }
-
- public void startTest(Test test) {
- showInfo("Running: "+test);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/ActiveTestSuite.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/ActiveTestSuite.java
deleted file mode 100644
index 52b5918..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/ActiveTestSuite.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package junit.extensions;
-
-import junit.framework.*;
-
-/**
- * A TestSuite for active Tests. It runs each
- * test in a separate thread and waits until all
- * threads have terminated.
- * -- Aarhus Radisson Scandinavian Center 11th floor
- */
-public class ActiveTestSuite extends TestSuite {
- private volatile int fActiveTestDeathCount;
-
- public void run(TestResult result) {
- fActiveTestDeathCount= 0;
- super.run(result);
- waitUntilFinished();
- }
-
- public void runTest(final Test test, final TestResult result) {
- Thread t= new Thread() {
- public void run() {
- try {
- // inlined due to limitation in VA/Java
- //ActiveTestSuite.super.runTest(test, result);
- test.run(result);
- } finally {
- ActiveTestSuite.this.runFinished(test);
- }
- }
- };
- t.start();
- }
-
- synchronized void waitUntilFinished() {
- while (fActiveTestDeathCount < testCount()) {
- try {
- wait();
- } catch (InterruptedException e) {
- return; // ignore
- }
- }
- }
-
- synchronized public void runFinished(Test test) {
- fActiveTestDeathCount++;
- notifyAll();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/ExceptionTestCase.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/ExceptionTestCase.java
deleted file mode 100644
index fe71424..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/ExceptionTestCase.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package junit.extensions;
-
-import junit.framework.*;
-
-/**
- * A TestCase that expects an Exception of class fExpected to be thrown.
- * The other way to check that an expected exception is thrown is:
- * <pre>
- * try {
- * shouldThrow();
- * }
- * catch (SpecialException e) {
- * return;
- * }
- * fail("Expected SpecialException");
- * </pre>
- *
- * To use ExceptionTestCase, create a TestCase like:
- * <pre>
- * new ExceptionTestCase("testShouldThrow", SpecialException.class);
- * </pre>
- */
-public class ExceptionTestCase extends TestCase {
- Class fExpected;
-
- public ExceptionTestCase(String name, Class exception) {
- super(name);
- fExpected= exception;
- }
- /**
- * Execute the test method expecting that an Exception of
- * class fExpected or one of its subclasses will be thrown
- */
- protected void runTest() throws Throwable {
- try {
- super.runTest();
- }
- catch (Exception e) {
- if (fExpected.isAssignableFrom(e.getClass()))
- return;
- else
- throw e;
- }
- fail("Expected exception " + fExpected);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/RepeatedTest.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/RepeatedTest.java
deleted file mode 100644
index e16e350..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/RepeatedTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package junit.extensions;
-
-import junit.framework.*;
-
-/**
- * A Decorator that runs a test repeatedly.
- *
- */
-public class RepeatedTest extends TestDecorator {
- private int fTimesRepeat;
-
- public RepeatedTest(Test test, int repeat) {
- super(test);
- if (repeat < 0)
- throw new IllegalArgumentException("Repetition count must be > 0");
- fTimesRepeat= repeat;
- }
- public int countTestCases() {
- return super.countTestCases()*fTimesRepeat;
- }
- public void run(TestResult result) {
- for (int i= 0; i < fTimesRepeat; i++) {
- if (result.shouldStop())
- break;
- super.run(result);
- }
- }
- public String toString() {
- return super.toString()+"(repeated)";
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/TestDecorator.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/TestDecorator.java
deleted file mode 100644
index 4b98c4f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/TestDecorator.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package junit.extensions;
-
-import junit.framework.*;
-
-/**
- * A Decorator for Tests. Use TestDecorator as the base class
- * for defining new test decorators. Test decorator subclasses
- * can be introduced to add behaviour before or after a test
- * is run.
- *
- */
-public class TestDecorator extends Assert implements Test {
- protected Test fTest;
-
- public TestDecorator(Test test) {
- fTest= test;
- }
- /**
- * The basic run behaviour.
- */
- public void basicRun(TestResult result) {
- fTest.run(result);
- }
- public int countTestCases() {
- return fTest.countTestCases();
- }
- public void run(TestResult result) {
- basicRun(result);
- }
-
- public String toString() {
- return fTest.toString();
- }
-
- public Test getTest() {
- return fTest;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/TestSetup.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/TestSetup.java
deleted file mode 100644
index 137e1a2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/extensions/TestSetup.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package junit.extensions;
-
-import junit.framework.*;
-
-/**
- * A Decorator to set up and tear down additional fixture state.
- * Subclass TestSetup and insert it into your tests when you want
- * to set up additional state once before the tests are run.
- */
-public class TestSetup extends TestDecorator {
-
- public TestSetup(Test test) {
- super(test);
- }
- public void run(final TestResult result) {
- Protectable p= new Protectable() {
- public void protect() throws Exception {
- setUp();
- basicRun(result);
- tearDown();
- }
- };
- result.runProtected(this, p);
- }
- /**
- * Sets up the fixture. Override to set up additional fixture
- * state.
- */
- protected void setUp() throws Exception {
- }
- /**
- * Tears down the fixture. Override to tear down the additional
- * fixture state.
- */
- protected void tearDown() throws Exception {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/Assert.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/Assert.java
deleted file mode 100644
index a038fdb..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/Assert.java
+++ /dev/null
@@ -1,243 +0,0 @@
-package junit.framework;
-
-/**
- * A set of assert methods.
- */
-
-public class Assert {
- /**
- * Protect constructor since it is a static only class
- */
- protected Assert() {
- }
- /**
- * Asserts that a condition is true. If it isn't it throws
- * an AssertionFailedError with the given message.
- * @deprecated use assertTrue
- */
- static public void assert(String message, boolean condition) {
- if (!condition)
- fail(message);
- }
- /**
- * Asserts that a condition is true. If it isn't it throws
- * an AssertionFailedError.
- * @deprecated use assertTrue
- *
- */
- static public void assert(boolean condition) {
- assert(null, condition);
- }
-
- /**
- * Asserts that a condition is true. If it isn't it throws
- * an AssertionFailedError with the given message.
- */
- static public void assertTrue(String message, boolean condition) {
- if (!condition)
- fail(message);
- }
- /**
- * Asserts that a condition is true. If it isn't it throws
- * an AssertionFailedError.
- */
- static public void assertTrue(boolean condition) {
- assertTrue(null, condition);
- }
- /**
- * Fails a test with the given message.
- */
- static public void fail(String message) {
- throw new AssertionFailedError(message);
- }
- /**
- * Fails a test with no message.
- */
- static public void fail() {
- fail(null);
- }
- /**
- * Asserts that two objects are equal. If they are not
- * an AssertionFailedError is thrown.
- */
- static public void assertEquals(String message, Object expected, Object actual) {
- if (expected == null && actual == null)
- return;
- if (expected != null && expected.equals(actual))
- return;
- failNotEquals(message, expected, actual);
- }
- /**
- * Asserts that two objects are equal. If they are not
- * an AssertionFailedError is thrown.
- */
- static public void assertEquals(Object expected, Object actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that two doubles are equal concerning a delta. If the expected
- * value is infinity then the delta value is ignored.
- */
- static public void assertEquals(String message, double expected, double actual, double delta) {
- // handle infinity specially since subtracting to infinite values gives NaN and the
- // the following test fails
- if (Double.isInfinite(expected)) {
- if (!(expected == actual))
- failNotEquals(message, new Double(expected), new Double(actual));
- } else if (!(Math.abs(expected-actual) <= delta)) // Because comparison with NaN always returns false
- failNotEquals(message, new Double(expected), new Double(actual));
- }
- /**
- * Asserts that two doubles are equal concerning a delta. If the expected
- * value is infinity then the delta value is ignored.
- */
- static public void assertEquals(double expected, double actual, double delta) {
- assertEquals(null, expected, actual, delta);
- }
- /**
- * Asserts that two floats are equal concerning a delta. If the expected
- * value is infinity then the delta value is ignored.
- */
- static public void assertEquals(String message, float expected, float actual, float delta) {
- // handle infinity specially since subtracting to infinite values gives NaN and the
- // the following test fails
- if (Float.isInfinite(expected)) {
- if (!(expected == actual))
- failNotEquals(message, new Float(expected), new Float(actual));
- } else if (!(Math.abs(expected-actual) <= delta))
- failNotEquals(message, new Float(expected), new Float(actual));
- }
- /**
- * Asserts that two floats are equal concerning a delta. If the expected
- * value is infinity then the delta value is ignored.
- */
- static public void assertEquals(float expected, float actual, float delta) {
- assertEquals(null, expected, actual, delta);
- }
- /**
- * Asserts that two longs are equal.
- */
- static public void assertEquals(String message, long expected, long actual) {
- assertEquals(message, new Long(expected), new Long(actual));
- }
- /**
- * Asserts that two longs are equal.
- */
- static public void assertEquals(long expected, long actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that two booleans are equal.
- */
- static public void assertEquals(String message, boolean expected, boolean actual) {
- assertEquals(message, new Boolean(expected), new Boolean(actual));
- }
- /**
- * Asserts that two booleans are equal.
- */
- static public void assertEquals(boolean expected, boolean actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that two bytes are equal.
- */
- static public void assertEquals(String message, byte expected, byte actual) {
- assertEquals(message, new Byte(expected), new Byte(actual));
- }
- /**
- * Asserts that two bytes are equal.
- */
- static public void assertEquals(byte expected, byte actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that two chars are equal.
- */
- static public void assertEquals(String message, char expected, char actual) {
- assertEquals(message, new Character(expected), new Character(actual));
- }
- /**
- * Asserts that two chars are equal.
- */
- static public void assertEquals(char expected, char actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that two shorts are equal.
- */
- static public void assertEquals(String message, short expected, short actual) {
- assertEquals(message, new Short(expected), new Short(actual));
- }
- /**
- * Asserts that two shorts are equal.
- */
- static public void assertEquals(short expected, short actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that two ints are equal.
- */
- static public void assertEquals(String message, int expected, int actual) {
- assertEquals(message, new Integer(expected), new Integer(actual));
- }
- /**
- * Asserts that two ints are equal.
- */
- static public void assertEquals(int expected, int actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that an object isn't null.
- */
- static public void assertNotNull(Object object) {
- assertNotNull(null, object);
- }
- /**
- * Asserts that an object isn't null.
- */
- static public void assertNotNull(String message, Object object) {
- assertTrue(message, object != null);
- }
- /**
- * Asserts that an object is null.
- */
- static public void assertNull(Object object) {
- assertNull(null, object);
- }
- /**
- * Asserts that an object is null.
- */
- static public void assertNull(String message, Object object) {
- assertTrue(message, object == null);
- }
- /**
- * Asserts that two objects refer to the same object. If they are not
- * an AssertionFailedError is thrown.
- */
- static public void assertSame(String message, Object expected, Object actual) {
- if (expected == actual)
- return;
- failNotSame(message, expected, actual);
- }
- /**
- * Asserts that two objects refer to the same object. If they are not
- * the same an AssertionFailedError is thrown.
- */
- static public void assertSame(Object expected, Object actual) {
- assertSame(null, expected, actual);
- }
-
- static private void failNotEquals(String message, Object expected, Object actual) {
- String formatted= "";
- if (message != null)
- formatted= message+" ";
- fail(formatted+"expected:<"+expected+"> but was:<"+actual+">");
- }
-
- static private void failNotSame(String message, Object expected, Object actual) {
- String formatted= "";
- if (message != null)
- formatted= message+" ";
- fail(formatted+"expected same");
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/AssertionFailedError.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/AssertionFailedError.java
deleted file mode 100644
index 6679a89..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/AssertionFailedError.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package junit.framework;
-
-/**
- * Thrown when an assertion failed.
- */
-public class AssertionFailedError extends Error {
-
- public AssertionFailedError () {
- }
- public AssertionFailedError (String message) {
- super (message);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/Protectable.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/Protectable.java
deleted file mode 100644
index e143237..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/Protectable.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package junit.framework;
-
-/**
- * A <em>Protectable</em> can be run and can throw a Throwable.
- *
- * @see TestResult
- */
-public interface Protectable {
-
- /**
- * Run the the following method protected.
- */
- public abstract void protect() throws Throwable;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/Test.java
deleted file mode 100644
index a016ee8..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/Test.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package junit.framework;
-
-/**
- * A <em>Test</em> can be run and collect its results.
- *
- * @see TestResult
- */
-public interface Test {
- /**
- * Counts the number of test cases that will be run by this test.
- */
- public abstract int countTestCases();
- /**
- * Runs a test and collects its result in a TestResult instance.
- */
- public abstract void run(TestResult result);
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestCase.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestCase.java
deleted file mode 100644
index c8d68e7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestCase.java
+++ /dev/null
@@ -1,211 +0,0 @@
-package junit.framework;
-
-import java.lang.reflect.*;
-
-/**
- * A test case defines the fixture to run multiple tests. To define a test case<br>
- * 1) implement a subclass of TestCase<br>
- * 2) define instance variables that store the state of the fixture<br>
- * 3) initialize the fixture state by overriding <code>setUp</code><br>
- * 4) clean-up after a test by overriding <code>tearDown</code>.<br>
- * Each test runs in its own fixture so there
- * can be no side effects among test runs.
- * Here is an example:
- * <pre>
- * public class MathTest extends TestCase {
- * protected double fValue1;
- * protected double fValue2;
- *
- * public MathTest(String name) {
- * super(name);
- * }
- *
- * protected void setUp() {
- * fValue1= 2.0;
- * fValue2= 3.0;
- * }
- * }
- * </pre>
- *
- * For each test implement a method which interacts
- * with the fixture. Verify the expected results with assertions specified
- * by calling <code>assert</code> with a boolean.
- * <pre>
- * protected void testAdd() {
- * double result= fValue1 + fValue2;
- * assert(result == 5.0);
- * }
- * </pre>
- * Once the methods are defined you can run them. The framework supports
- * both a static type safe and more dynamic way to run a test.
- * In the static way you override the runTest method and define the method to
- * be invoked. A convenient way to do so is with an anonymous inner class.
- * <pre>
- * Test test= new MathTest("add") {
- * public void runTest() {
- * testAdd();
- * }
- * };
- * test.run();
- * </pre>
- * The dynamic way uses reflection to implement <code>runTest</code>. It dynamically finds
- * and invokes a method.
- * In this case the name of the test case has to correspond to the test method
- * to be run.
- * <pre>
- * Test= new MathTest("testAdd");
- * test.run();
- * </pre>
- * The tests to be run can be collected into a TestSuite. JUnit provides
- * different <i>test runners</i> which can run a test suite and collect the results.
- * A test runner either expects a static method <code>suite</code> as the entry
- * point to get a test to run or it will extract the suite automatically.
- * <pre>
- * public static Test suite() {
- * suite.addTest(new MathTest("testAdd"));
- * suite.addTest(new MathTest("testDivideByZero"));
- * return suite;
- * }
- * </pre>
- * @see TestResult
- * @see TestSuite
- */
-
-public abstract class TestCase extends Assert implements Test {
- /**
- * the name of the test case
- */
- private String fName;
-
- /**
- * No-arg constructor to enable serialization. This method
- * is not intended to be used by mere mortals.
- */
- TestCase() {
- fName= null;
- }
-
- /**
- * Constructs a test case with the given name.
- */
- public TestCase(String name) {
- fName= name;
- }
-
- /**
- * Counts the number of test cases executed by run(TestResult result).
- */
- public int countTestCases() {
- return 1;
- }
- /**
- * Creates a default TestResult object
- *
- * @see TestResult
- */
- protected TestResult createResult() {
- return new TestResult();
- }
- /**
- * Gets the name of the test case.
- * @deprecated use getName()
- */
- public String name() {
- return fName;
- }
- /**
- * A convenience method to run this test, collecting the results with a
- * default TestResult object.
- *
- * @see TestResult
- */
- public TestResult run() {
- TestResult result= createResult();
- run(result);
- return result;
- }
- /**
- * Runs the test case and collects the results in TestResult.
- */
- public void run(TestResult result) {
- result.run(this);
- }
- /**
- * Runs the bare test sequence.
- * @exception Throwable if any exception is thrown
- */
- public void runBare() throws Throwable {
- setUp();
- try {
- runTest();
- }
- finally {
- tearDown();
- }
- }
- /**
- * Override to run the test and assert its state.
- * @exception Throwable if any exception is thrown
- */
- protected void runTest() throws Throwable {
- Method runMethod= null;
- try {
- // use getMethod to get all public inherited
- // methods. getDeclaredMethods returns all
- // methods of this class but excludes the
- // inherited ones.
- runMethod= getClass().getMethod(fName, null);
- } catch (NoSuchMethodException e) {
- fail("Method \""+fName+"\" not found");
- }
- if (!Modifier.isPublic(runMethod.getModifiers())) {
- fail("Method \""+fName+"\" should be public");
- }
-
- try {
- runMethod.invoke(this, new Class[0]);
- }
- catch (InvocationTargetException e) {
- e.fillInStackTrace();
- throw e.getTargetException();
- }
- catch (IllegalAccessException e) {
- e.fillInStackTrace();
- throw e;
- }
- }
- /**
- * Sets up the fixture, for example, open a network connection.
- * This method is called before a test is executed.
- */
- protected void setUp() throws Exception {
- }
- /**
- * Tears down the fixture, for example, close a network connection.
- * This method is called after a test is executed.
- */
- protected void tearDown() throws Exception {
- }
- /**
- * Returns a string representation of the test case
- */
- public String toString() {
- return name()+"("+getClass().getName()+")";
- }
- /**
- * Gets the name of a TestCase
- * @return returns a String
- */
- public String getName() {
- return fName;
- }
-
- /**
- * Sets the name of a TestCase
- * @param name The name to set
- */
- public void setName(String name) {
- fName= name;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestFailure.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestFailure.java
deleted file mode 100644
index aa75dc7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestFailure.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package junit.framework;
-
-/**
- * A <code>TestFailure</code> collects a failed test together with
- * the caught exception.
- * @see TestResult
- */
-public class TestFailure extends Object {
- protected Test fFailedTest;
- protected Throwable fThrownException;
-
- /**
- * Constructs a TestFailure with the given test and exception.
- */
- public TestFailure(Test failedTest, Throwable thrownException) {
- fFailedTest= failedTest;
- fThrownException= thrownException;
- }
- /**
- * Gets the failed test.
- */
- public Test failedTest() {
- return fFailedTest;
- }
- /**
- * Gets the thrown exception.
- */
- public Throwable thrownException() {
- return fThrownException;
- }
- /**
- * Returns a short description of the failure.
- */
- public String toString() {
- StringBuffer buffer= new StringBuffer();
- buffer.append(fFailedTest+": "+fThrownException.getMessage());
- return buffer.toString();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestListener.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestListener.java
deleted file mode 100644
index 9b69443..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestListener.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package junit.framework;
-
-/**
- * A Listener for test progress
- */
-public interface TestListener {
- /**
- * An error occurred.
- */
- public void addError(Test test, Throwable t);
- /**
- * A failure occurred.
- */
- public void addFailure(Test test, AssertionFailedError t);
- /**
- * A test ended.
- */
- public void endTest(Test test);
- /**
- * A test started.
- */
- public void startTest(Test test);
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestResult.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestResult.java
deleted file mode 100644
index f8625c7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestResult.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package junit.framework;
-
-import java.util.Vector;
-import java.util.Enumeration;
-
-/**
- * A <code>TestResult</code> collects the results of executing
- * a test case. It is an instance of the Collecting Parameter pattern.
- * The test framework distinguishes between <i>failures</i> and <i>errors</i>.
- * A failure is anticipated and checked for with assertions. Errors are
- * unanticipated problems like an <code>ArrayIndexOutOfBoundsException</code>.
- *
- * @see Test
- */
-public class TestResult extends Object {
- protected Vector fFailures;
- protected Vector fErrors;
- protected Vector fListeners;
- protected int fRunTests;
- private boolean fStop;
-
- public TestResult() {
- fFailures= new Vector();
- fErrors= new Vector();
- fListeners= new Vector();
- fRunTests= 0;
- fStop= false;
- }
- /**
- * Adds an error to the list of errors. The passed in exception
- * caused the error.
- */
- public synchronized void addError(Test test, Throwable t) {
- fErrors.addElement(new TestFailure(test, t));
- for (Enumeration e= cloneListeners().elements(); e.hasMoreElements(); ) {
- ((TestListener)e.nextElement()).addError(test, t);
- }
- }
- /**
- * Adds a failure to the list of failures. The passed in exception
- * caused the failure.
- */
- public synchronized void addFailure(Test test, AssertionFailedError t) {
- fFailures.addElement(new TestFailure(test, t));
- for (Enumeration e= cloneListeners().elements(); e.hasMoreElements(); ) {
- ((TestListener)e.nextElement()).addFailure(test, t);
- }
- }
- /**
- * Registers a TestListener
- */
- public synchronized void addListener(TestListener listener) {
- fListeners.addElement(listener);
- }
- /**
- * Unregisters a TestListener
- */
- public synchronized void removeListener(TestListener listener) {
- fListeners.removeElement(listener);
- }
- /**
- * Returns a copy of the listeners.
- */
- private synchronized Vector cloneListeners() {
- return (Vector)fListeners.clone();
- }
- /**
- * Informs the result that a test was completed.
- */
- public void endTest(Test test) {
- for (Enumeration e= cloneListeners().elements(); e.hasMoreElements(); ) {
- ((TestListener)e.nextElement()).endTest(test);
- }
- }
- /**
- * Gets the number of detected errors.
- */
- public synchronized int errorCount() {
- return fErrors.size();
- }
- /**
- * Returns an Enumeration for the errors
- */
- public synchronized Enumeration errors() {
- return fErrors.elements();
- }
- /**
- * Gets the number of detected failures.
- */
- public synchronized int failureCount() {
- return fFailures.size();
- }
- /**
- * Returns an Enumeration for the failures
- */
- public synchronized Enumeration failures() {
- return fFailures.elements();
- }
- /**
- * Runs a TestCase.
- */
- protected void run(final TestCase test) {
- startTest(test);
- Protectable p= new Protectable() {
- public void protect() throws Throwable {
- test.runBare();
- }
- };
- runProtected(test, p);
-
- endTest(test);
- }
- /**
- * Gets the number of run tests.
- */
- public synchronized int runCount() {
- return fRunTests;
- }
- /**
- * Runs a TestCase.
- */
- public void runProtected(final Test test, Protectable p) {
- try {
- p.protect();
- }
- catch (AssertionFailedError e) {
- addFailure(test, e);
- }
- catch (ThreadDeath e) { // don't catch ThreadDeath by accident
- throw e;
- }
- catch (Throwable e) {
- addError(test, e);
- }
- }
- /**
- * Gets the number of run tests.
- * @deprecated use <code>runCount</code> instead
- */
- public synchronized int runTests() {
- return runCount();
- }
- /**
- * Checks whether the test run should stop
- */
- public synchronized boolean shouldStop() {
- return fStop;
- }
- /**
- * Informs the result that a test will be started.
- */
- public void startTest(Test test) {
- final int count= test.countTestCases();
- synchronized(this) {
- fRunTests+= count;
- }
- for (Enumeration e= cloneListeners().elements(); e.hasMoreElements(); ) {
- ((TestListener)e.nextElement()).startTest(test);
- }
- }
- /**
- * Marks that the test run should stop.
- */
- public synchronized void stop() {
- fStop= true;
- }
- /**
- * Gets the number of detected errors.
- * @deprecated use <code>errorCount</code> instead
- */
- public synchronized int testErrors() {
- return errorCount();
- }
- /**
- * Gets the number of detected failures.
- * @deprecated use <code>failureCount</code> instead
- */
- public synchronized int testFailures() {
- return failureCount();
- }
- /**
- * Returns whether the entire test was successful or not.
- */
- public synchronized boolean wasSuccessful() {
- return testFailures() == 0 && testErrors() == 0;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestSuite.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestSuite.java
deleted file mode 100644
index b8937c0..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/framework/TestSuite.java
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/BaseTestRunner.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/BaseTestRunner.java
deleted file mode 100644
index 018021b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/BaseTestRunner.java
+++ /dev/null
@@ -1,268 +0,0 @@
-package junit.runner;
-
-import junit.framework.*;
-import java.lang.reflect.*;
-import java.text.NumberFormat;
-import java.io.*;
-import java.util.*;
-
-/**
- * Base class for all test runners.
- * This class was born live on stage in Sardinia during XP2000.
- */
-public abstract class BaseTestRunner implements TestListener {
- public static final String SUITE_METHODNAME= "suite";
-
- static Properties fPreferences;
- static int fgMaxMessageLength= 500;
- static boolean fgFilterStack= true;
- boolean fLoading= true;
-
- /**
- * Returns the Test corresponding to the given suite. This is
- * a template method, subclasses override runFailed(), clearStatus().
- */
- public Test getTest(String suiteClassName) {
- if (suiteClassName.length() <= 0) {
- clearStatus();
- return null;
- }
- Class testClass= null;
- try {
- testClass= loadSuiteClass(suiteClassName);
- } catch (ClassNotFoundException e) {
- String clazz= e.getMessage();
- if (clazz == null)
- clazz= suiteClassName;
- runFailed("Class not found \""+clazz+"\"");
- return null;
- } catch(Exception e) {
- runFailed("Error: "+e.toString());
- return null;
- }
- Method suiteMethod= null;
- try {
- suiteMethod= testClass.getMethod(SUITE_METHODNAME, new Class[0]);
- } catch(Exception e) {
- // try to extract a test suite automatically
- clearStatus();
- return new TestSuite(testClass);
- }
- Test test= null;
- try {
- test= (Test)suiteMethod.invoke(null, new Class[0]); // static method
- if (test == null)
- return test;
- }
- catch (InvocationTargetException e) {
- runFailed("Failed to invoke suite():" + e.getTargetException().toString());
- return null;
- }
- catch (IllegalAccessException e) {
- runFailed("Failed to invoke suite():" + e.toString());
- return null;
- }
-
- clearStatus();
- return test;
- }
-
- /**
- * Returns the formatted string of the elapsed time.
- */
- public String elapsedTimeAsString(long runTime) {
- return NumberFormat.getInstance().format((double)runTime/1000);
- }
-
- /**
- * Processes the command line arguments and
- * returns the name of the suite class to run or null
- */
- protected String processArguments(String[] args) {
- String suiteName= null;
- for (int i= 0; i < args.length; i++) {
- if (args[i].equals("-noloading")) {
- setLoading(false);
- } else if (args[i].equals("-nofilterstack")) {
- fgFilterStack= false;
- } else if (args[i].equals("-c")) {
- if (args.length > i+1)
- suiteName= extractClassName(args[i+1]);
- else
- System.out.println("Missing Test class name");
- i++;
- } else {
- suiteName= args[i];
- }
- }
- return suiteName;
- }
-
- /**
- * Sets the loading behaviour of the test runner
- */
- public void setLoading(boolean enable) {
- fLoading= enable;
- }
- /**
- * Extract the class name from a String in VA/Java style
- */
- public String extractClassName(String className) {
- if(className.startsWith("Default package for"))
- return className.substring(className.lastIndexOf(".")+1);
- return className;
- }
-
- /**
- * Truncates a String to the maximum length.
- */
- public static String truncate(String s) {
- if (fgMaxMessageLength != -1 && s.length() > fgMaxMessageLength)
- s= s.substring(0, fgMaxMessageLength)+"...";
- return s;
- }
-
- /**
- * Override to define how to handle a failed loading of
- * a test suite.
- */
- protected abstract void runFailed(String message);
-
- /**
- * Returns the loaded Class for a suite name.
- */
- protected Class loadSuiteClass(String suiteClassName) throws ClassNotFoundException {
- return getLoader().load(suiteClassName);
- }
-
- /**
- * Clears the status message.
- */
- protected void clearStatus() { // Belongs in the GUI TestRunner class
- }
-
- /**
- * Returns the loader to be used.
- */
- public TestSuiteLoader getLoader() {
- if (useReloadingTestSuiteLoader())
- return new ReloadingTestSuiteLoader();
- return new StandardTestSuiteLoader();
- }
-
- protected boolean useReloadingTestSuiteLoader() {
- return getPreference("loading").equals("true") && !inVAJava() && fLoading;
- }
-
- private static File getPreferencesFile() {
- String home= System.getProperty("user.home");
- return new File(home, "junit.properties");
- }
-
- private static void readPreferences() {
- InputStream is= null;
- try {
- is= new FileInputStream(getPreferencesFile());
- fPreferences= new Properties(fPreferences);
- fPreferences.load(is);
- } catch (IOException e) {
- try {
- if (is != null)
- is.close();
- } catch (IOException e1) {
- }
- }
- }
-
- public static String getPreference(String key) {
- return fPreferences.getProperty(key);
- }
-
- public static int getPreference(String key, int dflt) {
- String value= getPreference(key);
- int intValue= dflt;
- if (value == null)
- return intValue;
- try {
- intValue= Integer.parseInt(value);
- } catch (NumberFormatException ne) {
- }
- return intValue;
- }
-
- public static boolean inVAJava() {
- try {
- Class.forName("com.ibm.uvm.tools.DebugSupport");
- }
- catch (Exception e) {
- return false;
- }
- return true;
- }
-
-
- /**
- * Returns a filtered stack trace
- */
- public static String getFilteredTrace(Throwable t) {
- StringWriter stringWriter= new StringWriter();
- PrintWriter writer= new PrintWriter(stringWriter);
- t.printStackTrace(writer);
- StringBuffer buffer= stringWriter.getBuffer();
- String trace= buffer.toString();
- return BaseTestRunner.filterStack(trace);
- }
-
- /**
- * Filters stack frames from internal JUnit classes
- */
- public static String filterStack(String stack) {
- if (!getPreference("filterstack").equals("true") || fgFilterStack == false)
- return stack;
-
- StringWriter sw= new StringWriter();
- PrintWriter pw= new PrintWriter(sw);
- StringReader sr= new StringReader(stack);
- BufferedReader br= new BufferedReader(sr);
-
- String line;
- try {
- while ((line= br.readLine()) != null) {
- if (!filterLine(line))
- pw.println(line);
- }
- } catch (Exception IOException) {
- return stack; // return the stack unfiltered
- }
- return sw.toString();
- }
-
- static boolean filterLine(String line) {
- String[] patterns= new String[] {
- "junit.framework.TestCase",
- "junit.framework.TestResult",
- "junit.framework.TestSuite",
- "junit.framework.Assert.", // don't filter AssertionFailure
- "junit.swingui.TestRunner",
- "junit.awtui.TestRunner",
- "junit.textui.TestRunner",
- "java.lang.reflect.Method.invoke("
- };
- for (int i= 0; i < patterns.length; i++) {
- if (line.indexOf(patterns[i]) > 0)
- return true;
- }
- return false;
- }
-
- {
- fPreferences= new Properties();
- //JDK 1.2 feature
- //fPreferences.setProperty("loading", "true");
- fPreferences.put("loading", "true");
- fPreferences.put("filterstack", "true");
- readPreferences();
- fgMaxMessageLength= getPreference("maxmessage", fgMaxMessageLength);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/ClassPathTestCollector.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/ClassPathTestCollector.java
deleted file mode 100644
index f2614a8..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/ClassPathTestCollector.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package junit.runner;
-
-import java.util.*;
-import java.io.*;
-
-/**
- * An implementation of a TestCollector that consults the
- * class path. It considers all classes on the class path
- * excluding classes in JARs. It leaves it up to subclasses
- * to decide whether a class is a runnable Test.
- *
- * @see TestCollector
- */
-public abstract class ClassPathTestCollector implements TestCollector {
-
- static final int SUFFIX_LENGTH= ".class".length();
-
- public ClassPathTestCollector() {
- }
-
- public Enumeration collectTests() {
- String classPath= System.getProperty("java.class.path");
- String separator= System.getProperty("path.separator");
- Hashtable result= new Hashtable(100);
- collectFilesInRoots(splitClassPath(classPath, separator), result);
- return result.elements();
- }
-
- void collectFilesInRoots(Vector roots, Hashtable result) {
- Enumeration e= roots.elements();
- while (e.hasMoreElements())
- gatherFiles(new File((String)e.nextElement()), "", result);
- }
-
- void gatherFiles(File classRoot, String classFileName, Hashtable result) {
- File thisRoot= new File(classRoot, classFileName);
- if (thisRoot.isFile()) {
- if (isTestClass(classFileName)) {
- String className= classNameFromFile(classFileName);
- result.put(className, className);
- }
- return;
- }
- String[] contents= thisRoot.list();
- if (contents != null) {
- for (int i= 0; i < contents.length; i++)
- gatherFiles(classRoot, classFileName+File.separatorChar+contents[i], result);
- }
- }
-
- Vector splitClassPath(String classPath, String separator) {
- Vector result= new Vector();
- StringTokenizer tokenizer= new StringTokenizer(classPath, separator);
- while (tokenizer.hasMoreTokens())
- result.addElement(tokenizer.nextToken());
- return result;
- }
-
- protected boolean isTestClass(String classFileName) {
- return
- classFileName.endsWith(".class") &&
- classFileName.indexOf('$') < 0 &&
- classFileName.indexOf("Test") > 0;
- }
-
- protected String classNameFromFile(String classFileName) {
- // convert /a/b.class to a.b
- String s= classFileName.substring(0, classFileName.length()-SUFFIX_LENGTH);
- String s2= s.replace(File.separatorChar, '.');
- if (s2.startsWith("."))
- return s2.substring(1);
- return s2;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/FailureDetailView.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/FailureDetailView.java
deleted file mode 100644
index f4562af..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/FailureDetailView.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package junit.runner;
-
-import java.awt.Component;
-
-import junit.framework.*;
-
-/**
- * A view to show a details about a failure
- */
-public interface FailureDetailView {
- /**
- * Returns the component used to present the TraceView
- */
- public Component getComponent();
- /**
- * Shows details of a TestFailure
- */
- public void showFailure(TestFailure failure);
- /**
- * Clears the view
- */
- public void clear();
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/LoadingTestCollector.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/LoadingTestCollector.java
deleted file mode 100644
index b9b7ae4..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/LoadingTestCollector.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package junit.runner;
-
-import java.lang.reflect.*;
-import junit.runner.*;
-import junit.framework.*;
-
-/**
- * An implementation of a TestCollector that loads
- * all classes on the class path and tests whether
- * it is assignable from Test or provides a static suite method.
- * @see TestCollector
- */
-public class LoadingTestCollector extends ClassPathTestCollector {
-
- TestCaseClassLoader fLoader;
-
- public LoadingTestCollector() {
- fLoader= new TestCaseClassLoader();
- }
-
- protected boolean isTestClass(String classFileName) {
- try {
- if (classFileName.endsWith(".class")) {
- Class testClass= classFromFile(classFileName);
- return (testClass != null) && isTestClass(testClass);
- }
- }
- catch (ClassNotFoundException expected) {
- }
- catch (NoClassDefFoundError notFatal) {
- }
- return false;
- }
-
- Class classFromFile(String classFileName) throws ClassNotFoundException {
- String className= classNameFromFile(classFileName);
- if (!fLoader.isExcluded(className))
- return fLoader.loadClass(className, false);
- return null;
- }
-
- boolean isTestClass(Class testClass) {
- if (hasSuiteMethod(testClass))
- return true;
- if (Test.class.isAssignableFrom(testClass) &&
- Modifier.isPublic(testClass.getModifiers()) &&
- hasPublicConstructor(testClass))
- return true;
- return false;
- }
-
- boolean hasSuiteMethod(Class testClass) {
- try {
- Method suiteMethod= testClass.getMethod(BaseTestRunner.SUITE_METHODNAME, new Class[0]);
- } catch(Exception e) {
- return false;
- }
- return true;
- }
-
- boolean hasPublicConstructor(Class testClass) {
- Class[] args= { String.class };
- Constructor c= null;
- try {
- c= testClass.getConstructor(args);
- } catch(Exception e) {
- return false;
- }
- return true;
- }
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/ReloadingTestSuiteLoader.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/ReloadingTestSuiteLoader.java
deleted file mode 100644
index 6c33bfa..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/ReloadingTestSuiteLoader.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package junit.runner;
-
-/**
- * A TestSuite loader that can reload classes.
- */
-public class ReloadingTestSuiteLoader implements TestSuiteLoader {
- public Class load(String suiteClassName) throws ClassNotFoundException {
- TestCaseClassLoader loader= new TestCaseClassLoader();
- return loader.loadClass(suiteClassName, true);
- }
- public Class reload(Class aClass) throws ClassNotFoundException {
- TestCaseClassLoader loader= new TestCaseClassLoader();
- return loader.loadClass(aClass.getName(), true);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/SimpleTestCollector.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/SimpleTestCollector.java
deleted file mode 100644
index 9d1956a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/SimpleTestCollector.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package junit.runner;
-
-/**
- * An implementation of a TestCollector that considers
- * a class to be a test class when it contains the
- * pattern "Test" in its name
- * @see TestCollector
- */
-public class SimpleTestCollector extends ClassPathTestCollector {
-
- public SimpleTestCollector() {
- }
-
- protected boolean isTestClass(String classFileName) {
- return
- classFileName.endsWith(".class") &&
- classFileName.indexOf('$') < 0 &&
- classFileName.indexOf("Test") > 0;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/Sorter.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/Sorter.java
deleted file mode 100644
index 3829699..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/Sorter.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package junit.runner;
-
-import java.util.*;
-
-import junit.framework.*;
-import junit.runner.*;
-
-/**
- * A custom quick sort with support to customize the swap behaviour.
- * NOTICE: We can't use the the sorting support from the JDK 1.2 collection
- * classes because of the JDK 1.1.7 compatibility.
- */
-public class Sorter {
- public static interface Swapper {
- public void swap(Vector values, int left, int right);
- }
-
- public static void sortStrings(Vector values , int left, int right, Swapper swapper) {
- int oleft= left;
- int oright= right;
- String mid= (String)values.elementAt((left + right) / 2);
- do {
- while (((String)(values.elementAt(left))).compareTo(mid) < 0)
- left++;
- while (mid.compareTo((String)(values.elementAt(right))) < 0)
- right--;
- if (left <= right) {
- swapper.swap(values, left, right);
- left++;
- right--;
- }
- } while (left <= right);
-
- if (oleft < right)
- sortStrings(values, oleft, right, swapper);
- if (left < oright)
- sortStrings(values, left, oright, swapper);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/StandardTestSuiteLoader.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/StandardTestSuiteLoader.java
deleted file mode 100644
index 54f29c1..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/StandardTestSuiteLoader.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package junit.runner;
-
-/**
- * The standard test suite loader. It can only load the same class once.
- */
-public class StandardTestSuiteLoader implements TestSuiteLoader {
- /**
- * Uses the system class loader to load the test class
- */
- public Class load(String suiteClassName) throws ClassNotFoundException {
- return Class.forName(suiteClassName);
- }
- /**
- * Uses the system class loader to load the test class
- */
- public Class reload(Class aClass) throws ClassNotFoundException {
- return aClass;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/TestCaseClassLoader.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/TestCaseClassLoader.java
deleted file mode 100644
index 531d695..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/TestCaseClassLoader.java
+++ /dev/null
@@ -1,224 +0,0 @@
-package junit.runner;
-
-import java.util.*;
-import java.io.*;
-import java.net.URL;
-import java.util.zip.*;
-
-/**
- * A custom class loader which enables the reloading
- * of classes for each test run. The class loader
- * can be configured with a list of package paths that
- * should be excluded from loading. The loading
- * of these packages is delegated to the system class
- * loader. They will be shared across test runs.
- * <p>
- * The list of excluded package paths is specified in
- * a properties file "excluded.properties" that is located in
- * the same place as the TestCaseClassLoader class.
- * <p>
- * <b>Known limitation:</b> the TestCaseClassLoader cannot load classes
- * from jar files.
- */
-
-
-public class TestCaseClassLoader extends ClassLoader {
- /** scanned class path */
- private Vector fPathItems;
- /** default excluded paths */
- private String[] defaultExclusions= {
- "junit.framework.",
- "junit.extensions.",
- "junit.runner."
- };
- /** name of excluded properties file */
- static final String EXCLUDED_FILE= "excluded.properties";
- /** excluded paths */
- private Vector fExcluded;
-
- /**
- * Constructs a TestCaseLoader. It scans the class path
- * and the excluded package paths
- */
- public TestCaseClassLoader() {
- this(System.getProperty("java.class.path"));
- }
-
- /**
- * Constructs a TestCaseLoader. It scans the class path
- * and the excluded package paths
- */
- public TestCaseClassLoader(String classPath) {
- scanPath(classPath);
- readExcludedPackages();
- }
-
- private void scanPath(String classPath) {
- String separator= System.getProperty("path.separator");
- fPathItems= new Vector(10);
- StringTokenizer st= new StringTokenizer(classPath, separator);
- while (st.hasMoreTokens()) {
- fPathItems.addElement(st.nextToken());
- }
- }
-
- public URL getResource(String name) {
- return ClassLoader.getSystemResource(name);
- }
-
- public InputStream getResourceAsStream(String name) {
- return ClassLoader.getSystemResourceAsStream(name);
- }
-
- public boolean isExcluded(String name) {
- for (int i= 0; i < fExcluded.size(); i++) {
- if (name.startsWith((String) fExcluded.elementAt(i))) {
- return true;
- }
- }
- return false;
- }
-
- public synchronized Class loadClass(String name, boolean resolve)
- throws ClassNotFoundException {
-
- Class c= findLoadedClass(name);
- if (c != null)
- return c;
- //
- // Delegate the loading of excluded classes to the
- // standard class loader.
- //
- if (isExcluded(name)) {
- try {
- c= findSystemClass(name);
- return c;
- } catch (ClassNotFoundException e) {
- // keep searching
- }
- }
- if (c == null) {
- byte[] data= lookupClassData(name);
- if (data == null)
- throw new ClassNotFoundException();
- c= defineClass(name, data, 0, data.length);
- }
- if (resolve)
- resolveClass(c);
- return c;
- }
-
- private byte[] lookupClassData(String className) throws ClassNotFoundException {
- byte[] data= null;
- for (int i= 0; i < fPathItems.size(); i++) {
- String path= (String) fPathItems.elementAt(i);
- String fileName= className.replace('.', '/')+".class";
- if (isJar(path)) {
- data= loadJarData(path, fileName);
- } else {
- data= loadFileData(path, fileName);
- }
- if (data != null)
- return data;
- }
- throw new ClassNotFoundException(className);
- }
-
- boolean isJar(String pathEntry) {
- return pathEntry.endsWith(".jar") || pathEntry.endsWith(".zip");
- }
-
- private byte[] loadFileData(String path, String fileName) {
- File file= new File(path, fileName);
- if (file.exists()) {
- return getClassData(file);
- }
- return null;
- }
-
- private byte[] getClassData(File f) {
- try {
- FileInputStream stream= new FileInputStream(f);
- ByteArrayOutputStream out= new ByteArrayOutputStream(1000);
- byte[] b= new byte[1000];
- int n;
- while ((n= stream.read(b)) != -1)
- out.write(b, 0, n);
- stream.close();
- out.close();
- return out.toByteArray();
-
- } catch (IOException e) {
- }
- return null;
- }
-
- private byte[] loadJarData(String path, String fileName) {
- ZipFile zipFile= null;
- InputStream stream= null;
- File archive= new File(path);
- if (!archive.exists())
- return null;
- try {
- zipFile= new ZipFile(archive);
- } catch(IOException io) {
- return null;
- }
- ZipEntry entry= zipFile.getEntry(fileName);
- if (entry == null)
- return null;
- int size= (int) entry.getSize();
- try {
- stream= zipFile.getInputStream(entry);
- byte[] data= new byte[size];
- int pos= 0;
- while (pos < size) {
- int n= stream.read(data, pos, data.length - pos);
- pos += n;
- }
- zipFile.close();
- return data;
- } catch (IOException e) {
- } finally {
- try {
- if (stream != null)
- stream.close();
- } catch (IOException e) {
- }
- }
- return null;
- }
-
- private void readExcludedPackages() {
- fExcluded= new Vector(10);
- for (int i= 0; i < defaultExclusions.length; i++)
- fExcluded.addElement(defaultExclusions[i]);
-
- InputStream is= getClass().getResourceAsStream(EXCLUDED_FILE);
- if (is == null)
- return;
- Properties p= new Properties();
- try {
- p.load(is);
- }
- catch (IOException e) {
- return;
- } finally {
- try {
- is.close();
- } catch (IOException e) {
- }
- }
- for (Enumeration e= p.propertyNames(); e.hasMoreElements(); ) {
- String key= (String)e.nextElement();
- if (key.startsWith("excluded.")) {
- String path= p.getProperty(key);
- path= path.trim();
- if (path.endsWith("*"))
- path= path.substring(0, path.length()-1);
- if (path.length() > 0)
- fExcluded.addElement(path);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/TestCollector.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/TestCollector.java
deleted file mode 100644
index 180d460..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/TestCollector.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package junit.runner;
-
-import java.util.*;
-
-import junit.framework.*;
-
-/**
- * Collects Test class names to be presented
- * by the TestSelector.
- * @see TestSelector
- */
-public interface TestCollector {
- /**
- * Returns an enumeration of Strings with qualified class names
- */
- public Enumeration collectTests();
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/TestSuiteLoader.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/TestSuiteLoader.java
deleted file mode 100644
index 2db589e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/TestSuiteLoader.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package junit.runner;
-
-/**
- * An interface to define how a test suite should be loaded.
- */
-public interface TestSuiteLoader {
- abstract public Class load(String suiteClassName) throws ClassNotFoundException;
- abstract public Class reload(Class aClass) throws ClassNotFoundException;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/Version.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/Version.java
deleted file mode 100644
index 0002080..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/runner/Version.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package junit.runner;
-
-/**
- * This class defines the current version of JUnit
- */
-public class Version {
- private Version() {
- // don't instantiate
- }
-
- public static String id() {
- return "3.7";
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/AboutDialog.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/AboutDialog.java
deleted file mode 100644
index 4d6b02c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/AboutDialog.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package junit.swingui;
-
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-
-import junit.runner.*;
-
-/**
- * The AboutDialog.
- */
-class AboutDialog extends JDialog {
- public AboutDialog(JFrame parent) {
- super(parent, true);
-
- setResizable(false);
- getContentPane().setLayout(new GridBagLayout());
- setSize(330, 138);
- setTitle("About");
- setLocationRelativeTo(parent);
-
- JButton button= new JButton("Close");
- button.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- dispose();
- }
- }
- );
-
- JLabel label1= new JLabel("JUnit");
- label1.setFont(new Font("dialog", Font.PLAIN, 36));
-
- JLabel label2= new JLabel("JUnit "+Version.id()+" by Kent Beck and Erich Gamma");
- label2.setFont(new Font("dialog", Font.PLAIN, 14));
-
- JLabel logo= createLogo();
-
- GridBagConstraints constraintsLabel1= new GridBagConstraints();
- constraintsLabel1.gridx = 3; constraintsLabel1.gridy = 0;
- constraintsLabel1.gridwidth = 1; constraintsLabel1.gridheight = 1;
- constraintsLabel1.anchor = GridBagConstraints.CENTER;
- getContentPane().add(label1, constraintsLabel1);
-
- GridBagConstraints constraintsLabel2= new GridBagConstraints();
- constraintsLabel2.gridx = 2; constraintsLabel2.gridy = 1;
- constraintsLabel2.gridwidth = 2; constraintsLabel2.gridheight = 1;
- constraintsLabel2.anchor = GridBagConstraints.CENTER;
- getContentPane().add(label2, constraintsLabel2);
-
- GridBagConstraints constraintsButton1= new GridBagConstraints();
- constraintsButton1.gridx = 2; constraintsButton1.gridy = 2;
- constraintsButton1.gridwidth = 2; constraintsButton1.gridheight = 1;
- constraintsButton1.anchor = GridBagConstraints.CENTER;
- constraintsButton1.insets= new Insets(8, 0, 8, 0);
- getContentPane().add(button, constraintsButton1);
-
- GridBagConstraints constraintsLogo1= new GridBagConstraints();
- constraintsLogo1.gridx = 2; constraintsLogo1.gridy = 0;
- constraintsLogo1.gridwidth = 1; constraintsLogo1.gridheight = 1;
- constraintsLogo1.anchor = GridBagConstraints.CENTER;
- getContentPane().add(logo, constraintsLogo1);
-
- addWindowListener(
- new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- dispose();
- }
- }
- );
- }
- protected JLabel createLogo() {
- Icon icon= TestRunner.getIconResource(BaseTestRunner.class, "logo.gif");
- return new JLabel(icon);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/CounterPanel.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/CounterPanel.java
deleted file mode 100644
index 2088eb7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/CounterPanel.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package junit.swingui;
-
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.border.*;
-import java.awt.*;
-
-/**
- * A panel with test run counters
- */
-public class CounterPanel extends Panel {
- private JTextField fNumberOfErrors;
- private JTextField fNumberOfFailures;
- private JTextField fNumberOfRuns;
- private int fTotal;
-
- public CounterPanel() {
- super(new GridLayout(2, 3));
- add(new JLabel("Runs:"));
- add(new JLabel("Errors:"));
- add(new JLabel("Failures: "));
- fNumberOfErrors= createOutputField();
- fNumberOfFailures= createOutputField();
- fNumberOfRuns= createOutputField();
- add(fNumberOfRuns);
- add(fNumberOfErrors);
- add(fNumberOfFailures);
- }
-
- private JTextField createOutputField() {
- JTextField field= new JTextField("0", 4);
- field.setHorizontalAlignment(JTextField.LEFT);
- field.setFont(StatusLine.BOLD_FONT);
- field.setEditable(false);
- field.setBorder(BorderFactory.createEmptyBorder());
- return field;
- }
-
- public void reset() {
- setLabelValue(fNumberOfErrors, 0);
- setLabelValue(fNumberOfFailures, 0);
- setLabelValue(fNumberOfRuns, 0);
- fTotal= 0;
- }
-
- public void setTotal(int value) {
- fTotal= value;
- }
-
- public void setRunValue(int value) {
- fNumberOfRuns.setText(Integer.toString(value) + "/" + fTotal);
- }
-
- public void setErrorValue(int value) {
- setLabelValue(fNumberOfErrors, value);
- }
-
- public void setFailureValue(int value) {
- setLabelValue(fNumberOfFailures, value);
- }
-
- private String asString(int value) {
- return Integer.toString(value);
- }
-
- private void setLabelValue(JTextField label, int value) {
- label.setText(Integer.toString(value));
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/DefaultFailureDetailView.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/DefaultFailureDetailView.java
deleted file mode 100644
index 9081706..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/DefaultFailureDetailView.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package junit.swingui;
-
-import java.awt.Component;
-import javax.swing.JTextArea;
-import java.io.*;
-
-import junit.runner.*;
-import junit.framework.*;
-
-/**
- * A view that shows a stack trace of a failure
- */
-class DefaultFailureDetailView implements FailureDetailView {
- JTextArea fTextArea;
-
- /**
- * Returns the component used to present the trace
- */
- public Component getComponent() {
- if (fTextArea == null) {
- fTextArea= new JTextArea();
- fTextArea.setRows(5);
- fTextArea.setTabSize(0);
- fTextArea.setEditable(false);
- }
- return fTextArea;
- }
-
- /**
- * Shows a TestFailure
- */
- public void showFailure(TestFailure failure) {
- fTextArea.setText(BaseTestRunner.getFilteredTrace(failure.thrownException()));
- fTextArea.select(0, 0);
- }
-
- public void clear() {
- fTextArea.setText("");
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/FailureRunView.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/FailureRunView.java
deleted file mode 100644
index ad954c6..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/FailureRunView.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package junit.swingui;
-
-import javax.swing.*;
-import javax.swing.event.*;
-import java.awt.Component;
-
-import junit.framework.*;
-import junit.runner.BaseTestRunner;
-
-/**
- * A view presenting the test failures as a list.
- */
-class FailureRunView implements TestRunView {
- JList fFailureList;
- TestRunContext fRunContext;
-
- /**
- * Renders TestFailures in a JList
- */
- static class FailureListCellRenderer extends DefaultListCellRenderer {
- private Icon fFailureIcon;
- private Icon fErrorIcon;
-
- FailureListCellRenderer() {
- super();
- loadIcons();
- }
-
- void loadIcons() {
- fFailureIcon= TestRunner.getIconResource(getClass(), "icons/failure.gif");
- fErrorIcon= TestRunner.getIconResource(getClass(), "icons/error.gif");
- }
-
- public Component getListCellRendererComponent(
- JList list, Object value, int modelIndex,
- boolean isSelected, boolean cellHasFocus) {
-
- TestFailure failure= (TestFailure)value;
- String text= failure.failedTest().toString();
- String msg= failure.thrownException().getMessage();
- if (msg != null)
- text+= ":" + BaseTestRunner.truncate(msg);
-
- if (failure.thrownException() instanceof AssertionFailedError) {
- if (fFailureIcon != null)
- setIcon(fFailureIcon);
- } else {
- if (fErrorIcon != null)
- setIcon(fErrorIcon);
- }
- Component c= super.getListCellRendererComponent(list, text, modelIndex, isSelected, cellHasFocus);
- setText(text);
- setToolTipText(text);
- return c;
- }
- }
-
- public FailureRunView(TestRunContext context) {
- fRunContext= context;
- fFailureList= new JList(fRunContext.getFailures());
- fFailureList.setPrototypeCellValue(
- new TestFailure(new TestCase("dummy") {
- protected void runTest() {}
- },
- new AssertionFailedError("message"))
- );
- fFailureList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- fFailureList.setCellRenderer(new FailureListCellRenderer());
- fFailureList.setToolTipText("Failure - grey X; Error - red X");
- fFailureList.setVisibleRowCount(5);
-
- fFailureList.addListSelectionListener(
- new ListSelectionListener() {
- public void valueChanged(ListSelectionEvent e) {
- testSelected();
- }
- }
- );
- }
-
- public Test getSelectedTest() {
- int index= fFailureList.getSelectedIndex();
- if (index == -1)
- return null;
-
- ListModel model= fFailureList.getModel();
- TestFailure failure= (TestFailure)model.getElementAt(index);
- return failure.failedTest();
- }
-
- public void activate() {
- testSelected();
- }
-
- public void addTab(JTabbedPane pane) {
- JScrollPane sl= new JScrollPane(fFailureList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
- Icon errorIcon= TestRunner.getIconResource(getClass(), "icons/error.gif");
- pane.addTab("Failures", errorIcon, sl, "The list of failed tests");
- }
-
- public void revealFailure(Test failure) {
- fFailureList.setSelectedIndex(0);
- }
-
- public void aboutToStart(Test suite, TestResult result) {
- }
-
- public void runFinished(Test suite, TestResult result) {
- }
-
- protected void testSelected() {
- fRunContext.handleTestSelected(getSelectedTest());
- }
-}
-
-
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/ProgressBar.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/ProgressBar.java
deleted file mode 100644
index d96f43d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/ProgressBar.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package junit.swingui;
-
-import javax.swing.*;
-import javax.swing.border.*;
-import java.awt.*;
-
-/**
- * A simple progress bar showing the green/red status
- */
-class ProgressBar extends JPanel {
- boolean fError= false;
- int fTotal= 0;
- int fProgress= 0;
- int fProgressX= 0;
-
- public ProgressBar() {
- super();
- setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
- }
-
- private Color getStatusColor() {
- if (fError)
- return Color.red;
- return Color.green;
- }
-
- public void paintBackground(Graphics g) {
- g.setColor(getBackground());
- g.fillRect(0,0,getWidth(),getHeight());
- }
-
- public void paintComponent(Graphics g) {
- paintBackground(g);
- paintStatus(g);
- }
-
- public void paintStatus(Graphics g) {
- g.setColor(getStatusColor());
- Rectangle r= new Rectangle(0, 0, fProgressX, getBounds().height);
- g.fillRect(1, 1, r.width-1, r.height-2);
- }
-
- private void paintStep(int startX, int endX) {
- repaint(startX, 1, endX-startX, getBounds().height-2);
- }
-
- public void reset() {
- fProgressX= 1;
- fProgress= 0;
- fError= false;
- repaint();
- }
-
- public int scale(int value) {
- if (fTotal > 0)
- return Math.max(1, value*(getBounds().width-1)/fTotal);
- return value;
- }
-
- public void setBounds(int x, int y, int w, int h) {
- super.setBounds(x, y, w, h);
- fProgressX= scale(fProgress);
- }
-
- public void start(int total) {
- fTotal= total;
- reset();
- }
-
- public void step(boolean successful) {
- fProgress++;
- int x= fProgressX;
-
- fProgressX= scale(fProgress);
-
- if (!fError && !successful) {
- fError= true;
- x= 1;
- }
- paintStep(x, fProgressX);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/StatusLine.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/StatusLine.java
deleted file mode 100644
index fdb201c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/StatusLine.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package junit.swingui;
-
-import java.awt.*;
-import javax.swing.*;
-import javax.swing.border.*;
-
-/**
- * A status line component.
- */
-public class StatusLine extends JTextField {
- public static final Font PLAIN_FONT= new Font("dialog", Font.PLAIN, 12);
- public static final Font BOLD_FONT= new Font("dialog", Font.BOLD, 12);
-
- public StatusLine(int preferredWidth) {
- super();
- setFont(BOLD_FONT);
- setEditable(false);
- setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
- Dimension d= getPreferredSize();
- d.width= preferredWidth;
- setPreferredSize(d);
- }
-
- public void showInfo(String message) {
- setFont(PLAIN_FONT);
- setForeground(Color.black);
- setText(message);
- }
-
- public void showError(String status) {
- setFont(BOLD_FONT);
- setForeground(Color.red);
- setText(status);
- setToolTipText(status);
- }
-
- public void clear() {
- setText("");
- setToolTipText(null);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestHierarchyRunView.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestHierarchyRunView.java
deleted file mode 100644
index 547bf99..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestHierarchyRunView.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package junit.swingui;
-
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.tree.TreePath;
-import java.util.Vector;
-
-import junit.framework.*;
-
-/**
- * A hierarchical view of a test run.
- * The contents of a test suite is shown
- * as a tree.
- */
-class TestHierarchyRunView implements TestRunView {
- TestSuitePanel fTreeBrowser;
- TestRunContext fTestContext;
-
- public TestHierarchyRunView(TestRunContext context) {
- fTestContext= context;
- fTreeBrowser= new TestSuitePanel();
- fTreeBrowser.getTree().addTreeSelectionListener(
- new TreeSelectionListener() {
- public void valueChanged(TreeSelectionEvent e) {
- testSelected();
- }
- }
- );
- }
-
- public void addTab(JTabbedPane pane) {
- Icon treeIcon= TestRunner.getIconResource(getClass(), "icons/hierarchy.gif");
- pane.addTab("Test Hierarchy", treeIcon, fTreeBrowser, "The test hierarchy");
- }
-
- public Test getSelectedTest() {
- return fTreeBrowser.getSelectedTest();
- }
-
- public void activate() {
- testSelected();
- }
-
- public void revealFailure(Test failure) {
- JTree tree= fTreeBrowser.getTree();
- TestTreeModel model= (TestTreeModel)tree.getModel();
- Vector vpath= new Vector();
- int index= model.findTest(failure, (Test)model.getRoot(), vpath);
- if (index >= 0) {
- Object[] path= new Object[vpath.size()+1];
- vpath.copyInto(path);
- Object last= path[vpath.size()-1];
- path[vpath.size()]= model.getChild(last, index);
- TreePath selectionPath= new TreePath(path);
- tree.setSelectionPath(selectionPath);
- tree.makeVisible(selectionPath);
- }
- }
-
- public void aboutToStart(Test suite, TestResult result) {
- fTreeBrowser.showTestTree(suite);
- result.addListener(fTreeBrowser);
- }
-
- public void runFinished(Test suite, TestResult result) {
- result.removeListener(fTreeBrowser);
- }
-
- protected void testSelected() {
- fTestContext.handleTestSelected(getSelectedTest());
- }
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestRunContext.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestRunContext.java
deleted file mode 100644
index 038e3c4..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestRunContext.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package junit.swingui;
-
-import javax.swing.ListModel;
-
-import junit.framework.Test;
-
-/**
- * The interface for accessing the Test run context. Test run views
- * should use this interface rather than accessing the TestRunner
- * directly.
- */
-public interface TestRunContext {
- /**
- * Handles the selection of a Test.
- */
- public void handleTestSelected(Test test);
- /**
- * Returns the failure model
- */
- public ListModel getFailures();
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestRunView.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestRunView.java
deleted file mode 100644
index dfe7048..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestRunView.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package junit.swingui;
-
-import javax.swing.*;
-
-import junit.framework.*;
-
-/**
- * A TestRunView is shown as a page in a tabbed folder.
- * It contributes the page contents and can return
- * the currently selected tests. A TestRunView is
- * notified about the start and finish of a run.
- */
-interface TestRunView {
- /**
- * Returns the currently selected Test in the View
- */
- public Test getSelectedTest();
- /**
- * Activates the TestRunView
- */
- public void activate();
- /**
- * Reveals the given failure
- */
- public void revealFailure(Test failure);
- /**
- * Adds the TestRunView to the test run views tab
- */
- public void addTab(JTabbedPane pane);
- /**
- * Informs that the suite is about to start
- */
- public void aboutToStart(Test suite, TestResult result);
- /**
- * Informs that the run of the test suite has finished
- */
- public void runFinished(Test suite, TestResult result);
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestRunner.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestRunner.java
deleted file mode 100644
index e79b51b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestRunner.java
+++ /dev/null
@@ -1,807 +0,0 @@
-package junit.swingui;
-
-import junit.framework.*;
-import junit.runner.*;
-
-import java.util.*;
-import java.lang.reflect.*;
-import java.text.NumberFormat;
-import java.net.URL;
-import java.io.*;
-
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.text.*;
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.image.*;
-
-/**
- * A Swing based user interface to run tests.
- * Enter the name of a class which either provides a static
- * suite method or is a subclass of TestCase.
- * <pre>
- * Synopsis: java junit.swingui.TestRunner [-noloading] [TestCase]
- * </pre>
- * TestRunner takes as an optional argument the name of the testcase class to be run.
- */
-public class TestRunner extends BaseTestRunner implements TestRunContext {
- protected JFrame fFrame;
- private Thread fRunner;
- private TestResult fTestResult;
-
- private JComboBox fSuiteCombo;
- private ProgressBar fProgressIndicator;
- private DefaultListModel fFailures;
- private JLabel fLogo;
- private CounterPanel fCounterPanel;
- private JButton fRun;
- private JButton fQuitButton;
- private JButton fRerunButton;
- private StatusLine fStatusLine;
- private FailureDetailView fFailureView;
- private JTabbedPane fTestViewTab;
- private JCheckBox fUseLoadingRunner;
- private Vector fTestRunViews= new Vector(); // view associated with tab in tabbed pane
- private static Font PLAIN_FONT= StatusLine.PLAIN_FONT;
- private static Font BOLD_FONT= StatusLine.BOLD_FONT;
- private static final int GAP= 4;
- private static final int HISTORY_LENGTH= 5;
-
- private static final String TESTCOLLECTOR_KEY= "TestCollectorClass";
- private static final String FAILUREDETAILVIEW_KEY= "FailureViewClass";
-
- public TestRunner() {
- }
-
- public static void main(String[] args) {
- new TestRunner().start(args);
- }
-
- public static void run(Class test) {
- String args[]= { test.getName() };
- main(args);
- }
-
- public void addError(final Test test, final Throwable t) {
- SwingUtilities.invokeLater(
- new Runnable() {
- public void run() {
- fCounterPanel.setErrorValue(fTestResult.errorCount());
- appendFailure("Error", test, t);
- }
- }
- );
- }
-
- public void addFailure(final Test test, final AssertionFailedError t) {
- SwingUtilities.invokeLater(
- new Runnable() {
- public void run() {
- fCounterPanel.setFailureValue(fTestResult.failureCount());
- appendFailure("Failure", test, t);
- }
- }
- );
- }
-
- public void startTest(Test test) {
- postInfo("Running: "+test);
- }
-
- public void endTest(Test test) {
- postEndTest(test);
- }
-
- private void postEndTest(final Test test) {
- synchUI();
- SwingUtilities.invokeLater(
- new Runnable() {
- public void run() {
- if (fTestResult != null) {
- fCounterPanel.setRunValue(fTestResult.runCount());
- fProgressIndicator.step(fTestResult.wasSuccessful());
- }
- }
- }
- );
- }
-
- public void setSuite(String suiteName) {
- fSuiteCombo.getEditor().setItem(suiteName);
- }
-
- private void addToHistory(final String suite) {
- for (int i= 0; i < fSuiteCombo.getItemCount(); i++) {
- if (suite.equals(fSuiteCombo.getItemAt(i))) {
- fSuiteCombo.removeItemAt(i);
- fSuiteCombo.insertItemAt(suite, 0);
- fSuiteCombo.setSelectedIndex(0);
- return;
- }
- }
- fSuiteCombo.insertItemAt(suite, 0);
- fSuiteCombo.setSelectedIndex(0);
- pruneHistory();
- }
-
- private void pruneHistory() {
- int historyLength= getPreference("maxhistory", HISTORY_LENGTH);
- if (historyLength < 1)
- historyLength= 1;
- for (int i= fSuiteCombo.getItemCount()-1; i > historyLength-1; i--)
- fSuiteCombo.removeItemAt(i);
- }
-
- private void appendFailure(String kind, Test test, Throwable t) {
- fFailures.addElement(new TestFailure(test, t));
- if (fFailures.size() == 1)
- revealFailure(test);
- }
-
- private void revealFailure(Test test) {
- for (Enumeration e= fTestRunViews.elements(); e.hasMoreElements(); ) {
- TestRunView v= (TestRunView) e.nextElement();
- v.revealFailure(test);
- }
- }
-
- protected void aboutToStart(final Test testSuite) {
- for (Enumeration e= fTestRunViews.elements(); e.hasMoreElements(); ) {
- TestRunView v= (TestRunView) e.nextElement();
- v.aboutToStart(testSuite, fTestResult);
- }
- }
-
- protected void runFinished(final Test testSuite) {
- SwingUtilities.invokeLater(
- new Runnable() {
- public void run() {
- for (Enumeration e= fTestRunViews.elements(); e.hasMoreElements(); ) {
- TestRunView v= (TestRunView) e.nextElement();
- v.runFinished(testSuite, fTestResult);
- }
- }
- }
- );
- }
-
- protected CounterPanel createCounterPanel() {
- return new CounterPanel();
- }
-
- protected JPanel createFailedPanel() {
- JPanel failedPanel= new JPanel(new GridLayout(0, 1, 0, 2));
- fRerunButton= new JButton("Run");
- fRerunButton.setEnabled(false);
- fRerunButton.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- rerun();
- }
- }
- );
- failedPanel.add(fRerunButton);
- return failedPanel;
- }
-
- protected FailureDetailView createFailureDetailView() {
- String className= BaseTestRunner.getPreference(FAILUREDETAILVIEW_KEY);
- if (className != null) {
- Class viewClass= null;
- try {
- viewClass= Class.forName(className);
- return (FailureDetailView)viewClass.newInstance();
- } catch(Exception e) {
- JOptionPane.showMessageDialog(fFrame, "Could not create Failure DetailView - using default view");
- }
- }
- return new DefaultFailureDetailView();
- }
-
- /**
- * Creates the JUnit menu. Clients override this
- * method to add additional menu items.
- */
- protected JMenu createJUnitMenu() {
- JMenu menu= new JMenu("JUnit");
- menu.setMnemonic('J');
- JMenuItem mi1= new JMenuItem("About...");
- mi1.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- about();
- }
- }
- );
- mi1.setMnemonic('A');
- menu.add(mi1);
-
- menu.addSeparator();
- JMenuItem mi2= new JMenuItem(" Exit ");
- mi2.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- terminate();
- }
- }
- );
- mi2.setMnemonic('x');
- menu.add(mi2);
-
- return menu;
- }
-
- protected JFrame createFrame(String title) {
- JFrame frame= new JFrame("JUnit");
- Image icon= loadFrameIcon();
- if (icon != null)
- frame.setIconImage(icon);
- frame.getContentPane().setLayout(new BorderLayout(0, 0));
-
- frame.addWindowListener(
- new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- terminate();
- }
- }
- );
- return frame;
- }
-
- protected JLabel createLogo() {
- JLabel label;
- Icon icon= getIconResource(BaseTestRunner.class, "logo.gif");
- if (icon != null)
- label= new JLabel(icon);
- else
- label= new JLabel("JV");
- label.setToolTipText("JUnit Version "+Version.id());
- return label;
- }
-
- protected void createMenus(JMenuBar mb) {
- mb.add(createJUnitMenu());
- }
-
- protected JCheckBox createUseLoaderCheckBox() {
- boolean useLoader= useReloadingTestSuiteLoader();
- JCheckBox box= new JCheckBox("Reload classes every run", useLoader);
- box.setToolTipText("Use a custom class loader to reload the classes for every run");
- if (inVAJava())
- box.setVisible(false);
- return box;
- }
-
- protected JButton createQuitButton() {
- // spaces required to avoid layout flicker
- // Exit is shorter than Stop that shows in the same column
- JButton quit= new JButton(" Exit ");
- quit.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- terminate();
- }
- }
- );
- return quit;
- }
-
- protected JButton createRunButton() {
- JButton run= new JButton("Run");
- run.setEnabled(true);
- run.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- runSuite();
- }
- }
- );
- return run;
- }
-
- protected Component createBrowseButton() {
- JButton browse= new JButton("...");
- browse.setToolTipText("Select a Test class");
- browse.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- browseTestClasses();
- }
- }
- );
- return browse;
- }
-
- protected StatusLine createStatusLine() {
- return new StatusLine(420);
- }
-
- protected JComboBox createSuiteCombo() {
- JComboBox combo= new JComboBox();
- combo.setEditable(true);
- combo.setLightWeightPopupEnabled(false);
-
- combo.getEditor().getEditorComponent().addKeyListener(
- new KeyAdapter() {
- public void keyTyped(KeyEvent e) {
- textChanged();
- if (e.getKeyChar() == KeyEvent.VK_ENTER)
- runSuite();
- }
- }
- );
- try {
- loadHistory(combo);
- } catch (IOException e) {
- // fails the first time
- }
- combo.addItemListener(
- new ItemListener() {
- public void itemStateChanged(ItemEvent event) {
- if (event.getStateChange() == ItemEvent.SELECTED) {
- textChanged();
- }
- }
- }
- );
- return combo;
- }
-
- protected JTabbedPane createTestRunViews() {
- JTabbedPane pane= new JTabbedPane(JTabbedPane.BOTTOM);
-
- FailureRunView lv= new FailureRunView(this);
- fTestRunViews.addElement(lv);
- lv.addTab(pane);
-
- TestHierarchyRunView tv= new TestHierarchyRunView(this);
- fTestRunViews.addElement(tv);
- tv.addTab(pane);
-
- pane.addChangeListener(
- new ChangeListener() {
- public void stateChanged(ChangeEvent e) {
- testViewChanged();
- }
- }
- );
- return pane;
- }
-
- public void testViewChanged() {
- TestRunView view= (TestRunView)fTestRunViews.elementAt(fTestViewTab.getSelectedIndex());
- view.activate();
- }
-
- protected TestResult createTestResult() {
- return new TestResult();
- }
-
- protected JFrame createUI(String suiteName) {
- JFrame frame= createFrame("JUnit");
- JMenuBar mb= new JMenuBar();
- createMenus(mb);
- frame.setJMenuBar(mb);
-
- JLabel suiteLabel= new JLabel("Test class name:");
- fSuiteCombo= createSuiteCombo();
- fRun= createRunButton();
- frame.getRootPane().setDefaultButton(fRun);
- Component browseButton= createBrowseButton();
-
- fUseLoadingRunner= createUseLoaderCheckBox();
- fProgressIndicator= new ProgressBar();
- fCounterPanel= createCounterPanel();
-
- JLabel failureLabel= new JLabel("Errors and Failures:");
- fFailures= new DefaultListModel();
-
- fTestViewTab= createTestRunViews();
- JPanel failedPanel= createFailedPanel();
-
- fFailureView= createFailureDetailView();
- JScrollPane tracePane= new JScrollPane(fFailureView.getComponent(), JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
-
- fStatusLine= createStatusLine();
- fQuitButton= createQuitButton();
- fLogo= createLogo();
-
- JPanel panel= new JPanel(new GridBagLayout());
-
- addGrid(panel, suiteLabel, 0, 0, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST);
- addGrid(panel, fSuiteCombo, 0, 1, 1, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST);
- addGrid(panel, browseButton, 1, 1, 1, GridBagConstraints.NONE, 0.0, GridBagConstraints.WEST);
- addGrid(panel, fRun, 2, 1, 1, GridBagConstraints.HORIZONTAL, 0.0, GridBagConstraints.CENTER);
-
- addGrid(panel, fUseLoadingRunner, 0, 2, 3, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST);
- addGrid(panel, new JSeparator(), 0, 3, 3, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST);
-
-
- addGrid(panel, fProgressIndicator, 0, 4, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST);
- addGrid(panel, fLogo, 2, 4, 1, GridBagConstraints.NONE, 0.0, GridBagConstraints.NORTH);
-
- addGrid(panel, fCounterPanel, 0, 5, 2, GridBagConstraints.NONE, 0.0, GridBagConstraints.CENTER);
-
- JSplitPane splitter= new JSplitPane(JSplitPane.VERTICAL_SPLIT, fTestViewTab, tracePane);
- addGrid(panel, splitter, 0, 6, 2, GridBagConstraints.BOTH, 1.0, GridBagConstraints.WEST);
-
- addGrid(panel, failedPanel, 2, 6, 1, GridBagConstraints.HORIZONTAL, 0.0, GridBagConstraints.NORTH/*CENTER*/);
-
- addGrid(panel, fStatusLine, 0, 8, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.CENTER);
- addGrid(panel, fQuitButton, 2, 8, 1, GridBagConstraints.HORIZONTAL, 0.0, GridBagConstraints.CENTER);
-
- frame.setContentPane(panel);
- frame.pack();
- frame.setLocation(200, 200);
- return frame;
- }
-
- private void addGrid(JPanel p, Component co, int x, int y, int w, int fill, double wx, int anchor) {
- GridBagConstraints c= new GridBagConstraints();
- c.gridx= x; c.gridy= y;
- c.gridwidth= w;
- c.anchor= anchor;
- c.weightx= wx;
- c.fill= fill;
- if (fill == GridBagConstraints.BOTH || fill == GridBagConstraints.VERTICAL)
- c.weighty= 1.0;
- c.insets= new Insets(y == 0 ? GAP : 0, x == 0 ? GAP : 0, GAP, GAP);
- p.add(co, c);
- }
-
- protected String getSuiteText() {
- if (fSuiteCombo == null)
- return "";
- return (String)fSuiteCombo.getEditor().getItem();
- }
-
- public ListModel getFailures() {
- return fFailures;
- }
-
- public void insertUpdate(DocumentEvent event) {
- textChanged();
- }
-
- public void browseTestClasses() {
- TestCollector collector= createTestCollector();
- TestSelector selector= new TestSelector(fFrame, collector);
- if (selector.isEmpty()) {
- JOptionPane.showMessageDialog(fFrame, "No Test Cases found.\nCheck that the configured \'TestCollector\' is supported on this platform.");
- return;
- }
- selector.show();
- String className= selector.getSelectedItem();
- if (className != null)
- setSuite(className);
- }
-
- TestCollector createTestCollector() {
- String className= BaseTestRunner.getPreference(TESTCOLLECTOR_KEY);
- if (className != null) {
- Class collectorClass= null;
- try {
- collectorClass= Class.forName(className);
- return (TestCollector)collectorClass.newInstance();
- } catch(Exception e) {
- JOptionPane.showMessageDialog(fFrame, "Could not create TestCollector - using default collector");
- }
- }
- return new SimpleTestCollector();
- }
-
- private Image loadFrameIcon() {
- ImageIcon icon= (ImageIcon)getIconResource(BaseTestRunner.class, "smalllogo.gif");
- if (icon != null)
- return icon.getImage();
- return null;
- }
-
- private void loadHistory(JComboBox combo) throws IOException {
- BufferedReader br= new BufferedReader(new FileReader(getSettingsFile()));
- int itemCount= 0;
- try {
- String line;
- while ((line= br.readLine()) != null) {
- combo.addItem(line);
- itemCount++;
- }
- if (itemCount > 0)
- combo.setSelectedIndex(0);
-
- } finally {
- br.close();
- }
- }
-
- private File getSettingsFile() {
- String home= System.getProperty("user.home");
- return new File(home,".junitsession");
- }
-
- private void postInfo(final String message) {
- SwingUtilities.invokeLater(
- new Runnable() {
- public void run() {
- showInfo(message);
- }
- }
- );
- }
-
- private void postStatus(final String status) {
- SwingUtilities.invokeLater(
- new Runnable() {
- public void run() {
- showStatus(status);
- }
- }
- );
- }
-
- public void removeUpdate(DocumentEvent event) {
- textChanged();
- }
-
- private void rerun() {
- TestRunView view= (TestRunView)fTestRunViews.elementAt(fTestViewTab.getSelectedIndex());
- Test rerunTest= view.getSelectedTest();
- if (rerunTest != null)
- rerunTest(rerunTest);
- }
-
- private void rerunTest(Test test) {
- if (!(test instanceof TestCase)) {
- showInfo("Could not reload "+ test.toString());
- return;
- }
- Test reloadedTest= null;
- try {
- Class reloadedTestClass= getLoader().reload(test.getClass());
- Class[] classArgs= { String.class };
- Object[] args= new Object[]{((TestCase)test).getName()};
- Constructor constructor= reloadedTestClass.getConstructor(classArgs);
- reloadedTest=(Test)constructor.newInstance(args);
- } catch(Exception e) {
- showInfo("Could not reload "+ test.toString());
- return;
- }
- TestResult result= new TestResult();
- reloadedTest.run(result);
-
- String message= reloadedTest.toString();
- if(result.wasSuccessful())
- showInfo(message+" was successful");
- else if (result.errorCount() == 1)
- showStatus(message+" had an error");
- else
- showStatus(message+" had a failure");
- }
-
- protected void reset() {
- fCounterPanel.reset();
- fProgressIndicator.reset();
- fRerunButton.setEnabled(false);
- fFailureView.clear();
- fFailures.clear();
- }
-
- /**
- * runs a suite.
- * @deprecated use runSuite() instead
- */
- public void run() {
- runSuite();
- }
-
- protected void runFailed(String message) {
- showStatus(message);
- fRun.setText("Run");
- fRunner= null;
- }
-
- synchronized public void runSuite() {
- if (fRunner != null) {
- fTestResult.stop();
- } else {
- setLoading(shouldReload());
- reset();
- showInfo("Load Test Case...");
- final String suiteName= getSuiteText();
- final Test testSuite= getTest(suiteName);
- if (testSuite != null) {
- addToHistory(suiteName);
- doRunTest(testSuite);
- }
- }
- }
-
- private boolean shouldReload() {
- return !inVAJava() && fUseLoadingRunner.isSelected();
- }
-
-
- synchronized protected void runTest(final Test testSuite) {
- if (fRunner != null) {
- fTestResult.stop();
- } else {
- reset();
- if (testSuite != null) {
- doRunTest(testSuite);
- }
- }
- }
-
- private void doRunTest(final Test testSuite) {
- setButtonLabel(fRun, "Stop");
- fRunner= new Thread("TestRunner-Thread") {
- public void run() {
- TestRunner.this.start(testSuite);
- postInfo("Running...");
-
- long startTime= System.currentTimeMillis();
- testSuite.run(fTestResult);
-
- if (fTestResult.shouldStop()) {
- postStatus("Stopped");
- } else {
- long endTime= System.currentTimeMillis();
- long runTime= endTime-startTime;
- postInfo("Finished: " + elapsedTimeAsString(runTime) + " seconds");
- }
- runFinished(testSuite);
- setButtonLabel(fRun, "Run");
- fRunner= null;
- System.gc();
- }
- };
- // make sure that the test result is created before we start the
- // test runner thread so that listeners can register for it.
- fTestResult= createTestResult();
- fTestResult.addListener(TestRunner.this);
- aboutToStart(testSuite);
-
- fRunner.start();
- }
-
- private void saveHistory() throws IOException {
- BufferedWriter bw= new BufferedWriter(new FileWriter(getSettingsFile()));
- try {
- for (int i= 0; i < fSuiteCombo.getItemCount(); i++) {
- String testsuite= fSuiteCombo.getItemAt(i).toString();
- bw.write(testsuite, 0, testsuite.length());
- bw.newLine();
- }
- } finally {
- bw.close();
- }
- }
-
- private void setButtonLabel(final JButton button, final String label) {
- SwingUtilities.invokeLater(
- new Runnable() {
- public void run() {
- button.setText(label);
- }
- }
- );
- }
-
- private void setLabelValue(final JTextField label, final int value) {
- SwingUtilities.invokeLater(
- new Runnable() {
- public void run() {
- label.setText(Integer.toString(value));
- }
- }
- );
- }
-
- public void handleTestSelected(Test test) {
- fRerunButton.setEnabled(test != null && (test instanceof TestCase));
- showFailureDetail(test);
- }
-
- private void showFailureDetail(Test test) {
- if (test != null) {
- ListModel failures= getFailures();
- for (int i= 0; i < failures.getSize(); i++) {
- TestFailure failure= (TestFailure)failures.getElementAt(i);
- if (failure.failedTest() == test) {
- fFailureView.showFailure(failure);
- return;
- }
- }
- }
- fFailureView.clear();
- }
-
- private void showInfo(String message) {
- fStatusLine.showInfo(message);
- }
-
- private void showStatus(String status) {
- fStatusLine.showError(status);
- }
-
- /**
- * Starts the TestRunner
- */
- public void start(String[] args) {
- String suiteName= processArguments(args);
- fFrame= createUI(suiteName);
- fFrame.pack();
- fFrame.setVisible(true);
-
- if (suiteName != null) {
- setSuite(suiteName);
- runSuite();
- }
- }
-
- private void start(final Test test) {
- SwingUtilities.invokeLater(
- new Runnable() {
- public void run() {
- int total= test.countTestCases();
- fProgressIndicator.start(total);
- fCounterPanel.setTotal(total);
- }
- }
- );
- }
-
- /**
- * Wait until all the events are processed in the event thread
- */
- private void synchUI() {
- try {
- SwingUtilities.invokeAndWait(
- new Runnable() {
- public void run() {}
- }
- );
- }
- catch (Exception e) {
- }
- }
-
- /**
- * Terminates the TestRunner
- */
- public void terminate() {
- fFrame.dispose();
- try {
- saveHistory();
- } catch (IOException e) {
- System.out.println("Couldn't save test run history");
- }
- System.exit(0);
- }
-
- public void textChanged() {
- fRun.setEnabled(getSuiteText().length() > 0);
- clearStatus();
- }
-
- protected void clearStatus() {
- fStatusLine.clear();
- }
-
- public static Icon getIconResource(Class clazz, String name) {
- URL url= clazz.getResource(name);
- if (url == null) {
- System.err.println("Warning: could not load \""+name+"\" icon");
- return null;
- }
- return new ImageIcon(url);
- }
-
- private void about() {
- AboutDialog about= new AboutDialog(fFrame);
- about.show();
- }
-
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestSelector.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestSelector.java
deleted file mode 100644
index 27adde4..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestSelector.java
+++ /dev/null
@@ -1,248 +0,0 @@
-package junit.swingui;
-
-import java.util.*;
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.event.*;
-
-import junit.framework.*;
-import junit.runner.*;
-
-/**
- * A test class selector. A simple dialog to pick the name of a test suite.
- */
-class TestSelector extends JDialog {
- private JButton fCancel;
- private JButton fOk;
- private JList fList;
- private JScrollPane fScrolledList;
- private JLabel fDescription;
- private String fSelectedItem;
-
- /**
- * Renders TestFailures in a JList
- */
- static class TestCellRenderer extends DefaultListCellRenderer {
- Icon fLeafIcon;
- Icon fSuiteIcon;
-
- public TestCellRenderer() {
- fLeafIcon= UIManager.getIcon("Tree.leafIcon");
- fSuiteIcon= UIManager.getIcon("Tree.closedIcon");
- }
-
- public Component getListCellRendererComponent(
- JList list, Object value, int modelIndex,
- boolean isSelected, boolean cellHasFocus) {
- Component c= super.getListCellRendererComponent(list, value, modelIndex, isSelected, cellHasFocus);
- String displayString= displayString((String)value);
-
- if (displayString.startsWith("AllTests"))
- setIcon(fSuiteIcon);
- else
- setIcon(fLeafIcon);
-
- setText(displayString);
- return c;
- }
-
- public static String displayString(String className) {
- int typeIndex= className.lastIndexOf('.');
- if (typeIndex < 0)
- return className;
- return className.substring(typeIndex+1) + " - " + className.substring(0, typeIndex);
- }
-
- public static boolean matchesKey(String s, char ch) {
- return ch == Character.toUpperCase(s.charAt(typeIndex(s)));
- }
-
- private static int typeIndex(String s) {
- int typeIndex= s.lastIndexOf('.');
- int i= 0;
- if (typeIndex > 0)
- i= typeIndex+1;
- return i;
- }
- }
-
- protected class DoubleClickListener extends MouseAdapter {
- public void mouseClicked(MouseEvent e) {
- if (e.getClickCount() == 2) {
- okSelected();
- }
- }
- }
-
- protected class KeySelectListener extends KeyAdapter {
- public void keyTyped(KeyEvent e) {
- keySelectTestClass(e.getKeyChar());
- }
- }
-
- public TestSelector(Frame parent, TestCollector testCollector) {
- super(parent, true);
- setSize(350, 300);
- setResizable(false);
- setLocationRelativeTo(parent);
- setTitle("Test Selector");
-
- Vector list= null;
- try {
- parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- list= createTestList(testCollector);
- } finally {
- parent.setCursor(Cursor.getDefaultCursor());
- }
- fList= new JList(list);
- fList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- fList.setCellRenderer(new TestCellRenderer());
- fScrolledList= new JScrollPane(fList);
-
- fCancel= new JButton("Cancel");
- fDescription= new JLabel("Select the Test class:");
- fOk= new JButton("OK");
- fOk.setEnabled(false);
- getRootPane().setDefaultButton(fOk);
-
- defineLayout();
- addListeners();
- }
-
- private void addListeners() {
- fCancel.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- dispose();
- }
- }
- );
-
- fOk.addActionListener(
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- okSelected();
- }
- }
- );
-
- fList.addMouseListener(new DoubleClickListener());
- fList.addKeyListener(new KeySelectListener());
- fList.addListSelectionListener(
- new ListSelectionListener() {
- public void valueChanged(ListSelectionEvent e) {
- checkEnableOK(e);
- }
- }
- );
-
- addWindowListener(
- new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- dispose();
- }
- }
- );
- }
-
- private void defineLayout() {
- getContentPane().setLayout(new GridBagLayout());
- GridBagConstraints labelConstraints = new GridBagConstraints();
- labelConstraints.gridx= 0; labelConstraints.gridy= 0;
- labelConstraints.gridwidth= 1; labelConstraints.gridheight= 1;
- labelConstraints.fill= GridBagConstraints.BOTH;
- labelConstraints.anchor= GridBagConstraints.WEST;
- labelConstraints.weightx= 1.0;
- labelConstraints.weighty= 0.0;
- labelConstraints.insets= new Insets(8, 8, 0, 8);
- getContentPane().add(fDescription, labelConstraints);
-
- GridBagConstraints listConstraints = new GridBagConstraints();
- listConstraints.gridx= 0; listConstraints.gridy= 1;
- listConstraints.gridwidth= 4; listConstraints.gridheight= 1;
- listConstraints.fill= GridBagConstraints.BOTH;
- listConstraints.anchor= GridBagConstraints.CENTER;
- listConstraints.weightx= 1.0;
- listConstraints.weighty= 1.0;
- listConstraints.insets= new Insets(8, 8, 8, 8);
- getContentPane().add(fScrolledList, listConstraints);
-
- GridBagConstraints okConstraints= new GridBagConstraints();
- okConstraints.gridx= 2; okConstraints.gridy= 2;
- okConstraints.gridwidth= 1; okConstraints.gridheight= 1;
- okConstraints.anchor= java.awt.GridBagConstraints.EAST;
- okConstraints.insets= new Insets(0, 8, 8, 8);
- getContentPane().add(fOk, okConstraints);
-
-
- GridBagConstraints cancelConstraints = new GridBagConstraints();
- cancelConstraints.gridx= 3; cancelConstraints.gridy= 2;
- cancelConstraints.gridwidth= 1; cancelConstraints.gridheight= 1;
- cancelConstraints.anchor= java.awt.GridBagConstraints.EAST;
- cancelConstraints.insets= new Insets(0, 8, 8, 8);
- getContentPane().add(fCancel, cancelConstraints);
- }
-
- public void checkEnableOK(ListSelectionEvent e) {
- fOk.setEnabled(fList.getSelectedIndex() != -1);
- }
-
- public void okSelected() {
- fSelectedItem= (String)fList.getSelectedValue();
- dispose();
- }
-
- public boolean isEmpty() {
- return fList.getModel().getSize() == 0;
- }
-
- public void keySelectTestClass(char ch) {
- ListModel model= fList.getModel();
- if (!Character.isJavaIdentifierStart(ch))
- return;
- for (int i= 0; i < model.getSize(); i++) {
- String s= (String)model.getElementAt(i);
- if (TestCellRenderer.matchesKey(s, Character.toUpperCase(ch))) {
- fList.setSelectedIndex(i);
- fList.ensureIndexIsVisible(i);
- return;
- }
- }
- Toolkit.getDefaultToolkit().beep();
- }
-
- public String getSelectedItem() {
- return fSelectedItem;
- }
-
- private Vector createTestList(TestCollector collector) {
- Enumeration each= collector.collectTests();
- Vector v= new Vector(200);
- Vector displayVector= new Vector(v.size());
- while(each.hasMoreElements()) {
- String s= (String)each.nextElement();
- v.addElement(s);
- displayVector.addElement(TestCellRenderer.displayString(s));
- }
- if (v.size() > 0)
- Sorter.sortStrings(displayVector, 0, displayVector.size()-1, new ParallelSwapper(v));
- return v;
- }
-
- private class ParallelSwapper implements Sorter.Swapper {
- Vector fOther;
-
- ParallelSwapper(Vector other) {
- fOther= other;
- }
- public void swap(Vector values, int left, int right) {
- Object tmp= values.elementAt(left);
- values.setElementAt(values.elementAt(right), left);
- values.setElementAt(tmp, right);
- Object tmp2= fOther.elementAt(left);
- fOther.setElementAt(fOther.elementAt(right), left);
- fOther.setElementAt(tmp2, right);
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestSuitePanel.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestSuitePanel.java
deleted file mode 100644
index 0818bc3..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestSuitePanel.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package junit.swingui;
-
-import java.util.Vector;
-import java.awt.*;
-import javax.swing.*;
-import javax.swing.tree.*;
-
-import junit.framework.*;
-import junit.runner.*;
-
-/**
- * A Panel showing a test suite as a tree.
- */
-class TestSuitePanel extends JPanel implements TestListener {
- private JTree fTree;
- private JScrollPane fScrollTree;
- private TestTreeModel fModel;
-
- static class TestTreeCellRenderer extends DefaultTreeCellRenderer {
- private Icon fErrorIcon;
- private Icon fOkIcon;
- private Icon fFailureIcon;
-
- TestTreeCellRenderer() {
- super();
- loadIcons();
- }
-
- void loadIcons() {
- fErrorIcon= TestRunner.getIconResource(getClass(), "icons/error.gif");
- fOkIcon= TestRunner.getIconResource(getClass(), "icons/ok.gif");
- fFailureIcon= TestRunner.getIconResource(getClass(), "icons/failure.gif");
- }
-
- String stripParenthesis(Object o) {
- String text= o.toString ();
- int pos= text.indexOf('(');
- if (pos < 1)
- return text;
- return text.substring (0, pos);
- }
-
- public Component getTreeCellRendererComponent(JTree tree, Object value,
- boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
-
- Component c= super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
- TreeModel model= tree.getModel();
- if (model instanceof TestTreeModel) {
- TestTreeModel testModel= (TestTreeModel)model;
- Test t= (Test)value;
- String s= "";
- if (testModel.isFailure(t)) {
- if (fFailureIcon != null)
- setIcon(fFailureIcon);
- s= " - Failed";
- }
- else if (testModel.isError(t)) {
- if (fErrorIcon != null)
- setIcon(fErrorIcon);
- s= " - Error";
- }
- else if (testModel.wasRun(t)) {
- if (fOkIcon != null)
- setIcon(fOkIcon);
- s= " - Passed";
- }
- if (c instanceof JComponent)
- ((JComponent)c).setToolTipText(getText()+s);
- }
- setText(stripParenthesis(value));
- return c;
- }
- }
-
- public TestSuitePanel() {
- super(new BorderLayout());
- setPreferredSize(new Dimension(300, 100));
- fTree= new JTree();
- fTree.setModel(null);
- fTree.setRowHeight(20);
- ToolTipManager.sharedInstance().registerComponent(fTree);
- fTree.putClientProperty("JTree.lineStyle", "Angled");
- fScrollTree= new JScrollPane(fTree);
- add(fScrollTree, BorderLayout.CENTER);
- }
-
- public void addError(final Test test, final Throwable t) {
- fModel.addError(test);
- fireTestChanged(test, true);
- }
-
- public void addFailure(final Test test, final AssertionFailedError t) {
- fModel.addFailure(test);
- fireTestChanged(test, true);
- }
-
- /**
- * A test ended.
- */
- public void endTest(Test test) {
- fModel.addRunTest(test);
- fireTestChanged(test, false);
- }
-
- /**
- * A test started.
- */
- public void startTest(Test test) {
- }
-
- /**
- * Returns the selected test or null if multiple or none is selected
- */
- public Test getSelectedTest() {
- TreePath[] paths= fTree.getSelectionPaths();
- if (paths != null && paths.length == 1)
- return (Test)paths[0].getLastPathComponent();
- return null;
- }
-
- /**
- * Returns the Tree
- */
- public JTree getTree() {
- return fTree;
- }
-
- /**
- * Shows the test hierarchy starting at the given test
- */
- public void showTestTree(Test root) {
- fModel= new TestTreeModel(root);
- fTree.setModel(fModel);
- fTree.setCellRenderer(new TestTreeCellRenderer());
- }
-
- private void fireTestChanged(final Test test, final boolean expand) {
- SwingUtilities.invokeLater(
- new Runnable() {
- public void run() {
- Vector vpath= new Vector();
- int index= fModel.findTest(test, (Test)fModel.getRoot(), vpath);
- if (index >= 0) {
- Object[] path= new Object[vpath.size()];
- vpath.copyInto(path);
- TreePath treePath= new TreePath(path);
- fModel.fireNodeChanged(treePath, index);
- if (expand) {
- Object[] fullPath= new Object[vpath.size()+1];
- vpath.copyInto(fullPath);
- fullPath[vpath.size()]= fModel.getChild(treePath.getLastPathComponent(), index);;
- TreePath fullTreePath= new TreePath(fullPath);
- fTree.scrollPathToVisible(fullTreePath);
- }
- }
- }
- }
- );
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestTreeModel.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestTreeModel.java
deleted file mode 100644
index d0c8504..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/swingui/TestTreeModel.java
+++ /dev/null
@@ -1,184 +0,0 @@
-package junit.swingui;
-
-import java.util.*;
-import javax.swing.event.*;
-import javax.swing.tree.*;
-
-import junit.extensions.*;
-import junit.framework.*;
-
-/**
- * A tree model for a Test.
- */
-class TestTreeModel implements TreeModel {
- private Test fRoot;
- private Vector fModelListeners= new Vector();
- private Hashtable fFailures= new Hashtable();
- private Hashtable fErrors= new Hashtable();
- private Hashtable fRunTests= new Hashtable();
-
- /**
- * Constructs a tree model with the given test as its root.
- */
- public TestTreeModel(Test root) {
- super();
- fRoot= root;
- }
-
- /**
- * adds a TreeModelListener
- */
- public void addTreeModelListener(TreeModelListener l) {
- if (!fModelListeners.contains(l))
- fModelListeners.addElement(l);
- }
- /**
- * Removes a TestModelListener
- */
- public void removeTreeModelListener(TreeModelListener l) {
- fModelListeners.removeElement(l);
- }
- /**
- * Finds the path to a test. Returns the index of the test in its
- * parent test suite.
- */
- public int findTest(Test target, Test node, Vector path) {
- if (target.equals(node))
- return 0;
-
- TestSuite suite= isTestSuite(node);
- for (int i= 0; i < getChildCount(node); i++) {
- Test t= suite.testAt(i);
- int index= findTest(target, t, path);
- if (index >= 0) {
- path.insertElementAt(node, 0);
- if (path.size() == 1)
- return i;
- return index;
- }
- }
- return -1;
- }
- /**
- * Fires a node changed event
- */
- public void fireNodeChanged(TreePath path, int index) {
- int[] indices= {index};
- Object[] changedChildren= {getChild(path.getLastPathComponent(), index)};
- TreeModelEvent event= new TreeModelEvent(this, path, indices, changedChildren);
-
- Enumeration e= fModelListeners.elements();
- while (e.hasMoreElements()) {
- TreeModelListener l= (TreeModelListener) e.nextElement();
- l.treeNodesChanged(event);
- }
- }
- /**
- * Gets the test at the given index
- */
- public Object getChild(Object parent, int index) {
- TestSuite suite= isTestSuite(parent);
- if (suite != null)
- return suite.testAt(index);
- return null;
- }
- /**
- * Gets the number of tests.
- */
- public int getChildCount(Object parent) {
- TestSuite suite= isTestSuite(parent);
- if (suite != null)
- return suite.testCount();
- return 0;
- }
- /**
- * Gets the index of a test in a test suite
- */
- public int getIndexOfChild(Object parent, Object child) {
- TestSuite suite= isTestSuite(parent);
- if (suite != null) {
- int i= 0;
- for (Enumeration e= suite.tests(); e.hasMoreElements(); i++) {
- if (child.equals((Test)e.nextElement()))
- return i;
- }
- }
- return -1;
- }
- /**
- * Returns the root of the tree
- */
- public Object getRoot() {
- return fRoot;
- }
- /**
- * Tests if the test is a leaf.
- */
- public boolean isLeaf(Object node) {
- return isTestSuite(node) == null;
- }
- /**
- * Tests if the node is a TestSuite.
- */
- TestSuite isTestSuite(Object node) {
- if (node instanceof TestSuite)
- return (TestSuite)node;
- if (node instanceof TestDecorator) {
- Test baseTest= ((TestDecorator)node).getTest();
- return isTestSuite(baseTest);
- }
- return null;
- }
-
- /**
- * Called when the value of the model object was changed in the view
- */
- public void valueForPathChanged(TreePath path, Object newValue) {
- // we don't support direct editing of the model
- System.out.println("TreeModel.valueForPathChanged: not implemented");
- }
- /**
- * Remembers a test failure
- */
- void addFailure(Test t) {
- fFailures.put(t, t);
- }
- /**
- * Remembers a test error
- */
- void addError(Test t) {
- fErrors.put(t, t);
- }
- /**
- * Remembers that a test was run
- */
- void addRunTest(Test t) {
- fRunTests.put(t, t);
- }
- /**
- * Returns whether a test was run
- */
- boolean wasRun(Test t) {
- return fRunTests.get(t) != null;
- }
- /**
- * Tests whether a test was an error
- */
- boolean isError(Test t) {
- return (fErrors != null) && fErrors.get(t) != null;
- }
- /**
- * Tests whether a test was a failure
- */
- boolean isFailure(Test t) {
- return (fFailures != null) && fFailures.get(t) != null;
- }
- /**
- * Resets the test results
- */
- void resetResults() {
- fFailures= new Hashtable();
- fRunTests= new Hashtable();
- fErrors= new Hashtable();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/textui/TestRunner.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/textui/TestRunner.java
deleted file mode 100644
index 7ee9597..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/textui/TestRunner.java
+++ /dev/null
@@ -1,249 +0,0 @@
-package junit.textui;
-
-
-import java.lang.reflect.*;
-import java.text.NumberFormat;
-import java.util.*;
-import java.io.PrintStream;
-
-import junit.framework.*;
-import junit.runner.*;
-
-/**
- * A command line based tool to run tests.
- * <pre>
- * java junit.textui.TestRunner [-wait] TestCaseClass
- * </pre>
- * TestRunner expects the name of a TestCase class as argument.
- * If this class defines a static <code>suite</code> method it
- * will be invoked and the returned test is run. Otherwise all
- * the methods starting with "test" having no arguments are run.
- * <p>
- * When the wait command line argument is given TestRunner
- * waits until the users types RETURN.
- * <p>
- * TestRunner prints a trace as the tests are executed followed by a
- * summary at the end.
- */
-public class TestRunner extends BaseTestRunner {
- PrintStream fWriter= System.out;
- int fColumn= 0;
-
- /**
- * Constructs a TestRunner.
- */
- public TestRunner() {
- }
- /**
- * Constructs a TestRunner using the given stream for all the output
- */
- public TestRunner(PrintStream writer) {
- this();
- if (writer == null)
- throw new IllegalArgumentException("Writer can't be null");
- fWriter= writer;
- }
-
- /**
- * Always use the StandardTestSuiteLoader. Overridden from
- * BaseTestRunner.
- */
- public TestSuiteLoader getLoader() {
- return new StandardTestSuiteLoader();
- }
-
- public synchronized void addError(Test test, Throwable t) {
- writer().print("E");
- }
-
- public synchronized void addFailure(Test test, AssertionFailedError t) {
- writer().print("F");
- }
-
- /**
- * Creates the TestResult to be used for the test run.
- */
- protected TestResult createTestResult() {
- return new TestResult();
- }
-
- public TestResult doRun(Test suite, boolean wait) {
- TestResult result= createTestResult();
- result.addListener(this);
- long startTime= System.currentTimeMillis();
- suite.run(result);
- long endTime= System.currentTimeMillis();
- long runTime= endTime-startTime;
- writer().println();
- writer().println("Time: "+elapsedTimeAsString(runTime));
- print(result);
-
- writer().println();
-
- pause(wait);
- return result;
- }
-
- protected void pause(boolean wait) {
- if (wait) {
- writer().println("<RETURN> to continue");
- try {
- System.in.read();
- }
- catch(Exception e) {
- }
- }
- }
-
- public synchronized void startTest(Test test) {
- writer().print(".");
- if (fColumn++ >= 40) {
- writer().println();
- fColumn= 0;
- }
- }
-
- public void endTest(Test test) {
- }
-
- public static void main(String args[]) {
- TestRunner aTestRunner= new TestRunner();
- try {
- TestResult r= aTestRunner.start(args);
- if (!r.wasSuccessful())
- System.exit(-1);
- System.exit(0);
- } catch(Exception e) {
- System.err.println(e.getMessage());
- System.exit(-2);
- }
- }
- /**
- * Prints failures to the standard output
- */
- public synchronized void print(TestResult result) {
- printErrors(result);
- printFailures(result);
- printHeader(result);
- }
- /**
- * Prints the errors to the standard output
- */
- public void printErrors(TestResult result) {
- if (result.errorCount() != 0) {
- if (result.errorCount() == 1)
- writer().println("There was "+result.errorCount()+" error:");
- else
- writer().println("There were "+result.errorCount()+" errors:");
-
- int i= 1;
- for (Enumeration e= result.errors(); e.hasMoreElements(); i++) {
- TestFailure failure= (TestFailure)e.nextElement();
- writer().println(i+") "+failure.failedTest());
- writer().print(getFilteredTrace(failure.thrownException()));
- }
- }
- }
- /**
- * Prints failures to the standard output
- */
- public void printFailures(TestResult result) {
- if (result.failureCount() != 0) {
- if (result.failureCount() == 1)
- writer().println("There was " + result.failureCount() + " failure:");
- else
- writer().println("There were " + result.failureCount() + " failures:");
- int i = 1;
- for (Enumeration e= result.failures(); e.hasMoreElements(); i++) {
- TestFailure failure= (TestFailure) e.nextElement();
- writer().print(i + ") " + failure.failedTest());
- Throwable t= failure.thrownException();
- writer().print(getFilteredTrace(failure.thrownException()));
- }
- }
- }
- /**
- * Prints the header of the report
- */
- public void printHeader(TestResult result) {
- if (result.wasSuccessful()) {
- writer().println();
- writer().print("OK");
- writer().println (" (" + result.runCount() + " tests)");
-
- } else {
- writer().println();
- writer().println("FAILURES!!!");
- writer().println("Tests run: "+result.runCount()+
- ", Failures: "+result.failureCount()+
- ", Errors: "+result.errorCount());
- }
- }
- /**
- * Runs a suite extracted from a TestCase subclass.
- */
- static public void run(Class testClass) {
- run(new TestSuite(testClass));
- }
- /**
- * Runs a single test and collects its results.
- * This method can be used to start a test run
- * from your program.
- * <pre>
- * public static void main (String[] args) {
- * test.textui.TestRunner.run(suite());
- * }
- * </pre>
- */
- static public void run(Test suite) {
- TestRunner aTestRunner= new TestRunner();
- aTestRunner.doRun(suite, false);
- }
- /**
- * Runs a single test and waits until the user
- * types RETURN.
- */
- static public void runAndWait(Test suite) {
- TestRunner aTestRunner= new TestRunner();
- aTestRunner.doRun(suite, true);
- }
- /**
- * Starts a test run. Analyzes the command line arguments
- * and runs the given test suite.
- */
- protected TestResult start(String args[]) throws Exception {
- String testCase= "";
- boolean wait= false;
-
- for (int i= 0; i < args.length; i++) {
- if (args[i].equals("-wait"))
- wait= true;
- else if (args[i].equals("-c"))
- testCase= extractClassName(args[++i]);
- else if (args[i].equals("-v"))
- System.err.println("JUnit "+Version.id()+" by Kent Beck and Erich Gamma");
- else
- testCase= args[i];
- }
-
- if (testCase.equals(""))
- throw new Exception("Usage: TestRunner [-wait] testCaseName, where name is the name of the TestCase class");
-
- try {
- Test suite= getTest(testCase);
- return doRun(suite, wait);
- }
- catch(Exception e) {
- throw new Exception("Could not create and run test suite: "+e);
- }
- }
-
- protected void runFailed(String message) {
- System.err.println(message);
- System.exit(-1);
- }
-
- protected PrintStream writer() {
- return fWriter;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/ui/TestRunner.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/ui/TestRunner.java
deleted file mode 100644
index 5ca5c91..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/junit/ui/TestRunner.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package junit.ui;
-
-import junit.framework.*;
-import junit.runner.*;
-
-/**
- * @deprecated use junit.awtui.TestRunner.
- */
- public class TestRunner extends junit.awtui.TestRunner {
- public static void main(String[] args) {
- new TestRunner().start(args);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/p1/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/p1/A.java
deleted file mode 100644
index a484e0f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/p1/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package p1;
-
-public class A {
-
- public static void foo() {
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/p2/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/p2/A.java
deleted file mode 100644
index e107ae3..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/p2/A.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package p2;
-
-public class A {
- public static void foo() {
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/p3/B.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/p3/B.java
deleted file mode 100644
index 661768f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/p3/B.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package p3;
-
-import p1.*;
-
-public class B {
-
- public static void bar() {
- p2.A.foo();
- }
- public static void main(String[] args) {
- A.foo();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0001/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0001/Test.java
deleted file mode 100644
index a087fdf..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0001/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0001;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println("Hello" + " world");
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0002/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0002/Test.java
deleted file mode 100644
index b87dd49..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0002/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0002;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(new Object());
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0003/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0003/Test.java
deleted file mode 100644
index 354d803..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0003/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0003;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(new java.lang.Object());
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0004/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0004/Test.java
deleted file mode 100644
index d4df7d5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0004/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0004;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(new java.lang.Exception("ERROR"));
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0005/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0005/Test.java
deleted file mode 100644
index b6b4fe4..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0005/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0005;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(new java.lang.Object() {});
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0006/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0006/Test.java
deleted file mode 100644
index ee5adfe..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0006/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0006;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(new java.lang.Runnable() { public void run() {}});
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0007/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0007/Test.java
deleted file mode 100644
index 1acdc39..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0007/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0007;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- System.out.println(new Test().new D());
- }
- class D {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0008/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0008/Test.java
deleted file mode 100644
index 4a8a6d2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0008/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0008;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- System.out.println(new int[] {1, 2, 3, 4});
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0009/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0009/Test.java
deleted file mode 100644
index 9ea2a18..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0009/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0009;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- System.out.println(new int[][] {{1}, {2}});
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0010/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0010/Test.java
deleted file mode 100644
index 719353d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0010/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0010;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- System.out.println(new int[3]);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0011/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0011/Test.java
deleted file mode 100644
index d9a64c7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0011/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0011;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- System.out.println(new int[3][]);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0012/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0012/Test.java
deleted file mode 100644
index 99a66be..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0012/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0012;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- System.out.println(new int[][] {{}, {}});
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0013/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0013/Test.java
deleted file mode 100644
index 0c41843..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0013/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0013;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0014/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0014/Test.java
deleted file mode 100644
index 5524559..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0014/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0014;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0015/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0015/Test.java
deleted file mode 100644
index 478cf01..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0015/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0015;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- i = 1;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0016/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0016/Test.java
deleted file mode 100644
index 6d529ba..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0016/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0016;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- i += 2;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0017/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0017/Test.java
deleted file mode 100644
index 60329f3..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0017/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0017;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- i -= 2;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0018/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0018/Test.java
deleted file mode 100644
index 616c277..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0018/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0018;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- i *= 2;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0019/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0019/Test.java
deleted file mode 100644
index 3c44a04..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0019/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0019;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- i /= 2;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0020/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0020/Test.java
deleted file mode 100644
index c434b3c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0020/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0020;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- i &= 2;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0021/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0021/Test.java
deleted file mode 100644
index 76d0b3c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0021/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0021;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- i |= 2;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0022/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0022/Test.java
deleted file mode 100644
index 1907336..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0022/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0022;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- i ^= 2;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0023/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0023/Test.java
deleted file mode 100644
index 09062ee..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0023/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0023;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- i %= 2;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0024/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0024/Test.java
deleted file mode 100644
index 2e7b2a9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0024/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0024;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- i <<= 2;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0025/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0025/Test.java
deleted file mode 100644
index 91a7acc..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0025/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0025;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- i >>= 2;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0026/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0026/Test.java
deleted file mode 100644
index f3db0cf..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0026/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0026;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- i >>>= 2;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0027/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0027/Test.java
deleted file mode 100644
index 3853293..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0027/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0027;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- --i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0028/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0028/Test.java
deleted file mode 100644
index 2b821a5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0028/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0028;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- ++i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0029/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0029/Test.java
deleted file mode 100644
index 56d9f81..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0029/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0029;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- i--;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0030/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0030/Test.java
deleted file mode 100644
index 185124b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0030/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0030;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 0;
- i++;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0031/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0031/Test.java
deleted file mode 100644
index 18ad631..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0031/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0031;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- Object o = "Hello";
- String s = (String) o;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0032/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0032/Test.java
deleted file mode 100644
index 82a2df7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0032/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0032;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- double d = 1.0;
- int i = (int) d;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0033/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0033/Test.java
deleted file mode 100644
index 9efe21b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0033/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0033;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- double d = 1.0;
- float f = (float) d;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0034/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0034/Test.java
deleted file mode 100644
index 18fbb8d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0034/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0034;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- double d = 1.0;
- byte b = (byte) d;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0035/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0035/Test.java
deleted file mode 100644
index 3d66c10..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0035/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0035;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- double d = 1.0;
- short s = (short) d;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0036/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0036/Test.java
deleted file mode 100644
index 5fcf783..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0036/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0036;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- double d = 1.0;
- long l = (long) d;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0037/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0037/Test.java
deleted file mode 100644
index a436457..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0037/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0037;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 1;
- char c = (char) i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0038/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0038/Test.java
deleted file mode 100644
index ca3d681..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0038/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0038;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- Class c = int.class;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0039/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0039/Test.java
deleted file mode 100644
index 55d920a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0039/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0039;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- Class c = void.class;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0040/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0040/Test.java
deleted file mode 100644
index d9c8173..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0040/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0040;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- Class c = double.class;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0041/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0041/Test.java
deleted file mode 100644
index ff449c6..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0041/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0041;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- Class c = long.class;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0042/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0042/Test.java
deleted file mode 100644
index 60f2854..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0042/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0042;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- System.out.println(false);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0043/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0043/Test.java
deleted file mode 100644
index 8c5c76b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0043/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0043;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- System.out.println(true);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0044/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0044/Test.java
deleted file mode 100644
index d8f93de..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0044/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0044;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- System.out.println(null);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0045/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0045/Test.java
deleted file mode 100644
index 6c5fbdd..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0045/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0045;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- System.out.println('c');
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0046/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0046/Test.java
deleted file mode 100644
index ce66833..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0046/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0046;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- System.out.println(1.00001);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0047/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0047/Test.java
deleted file mode 100644
index 3ae22da..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0047/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0047;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- System.out.println(1.00001f);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0048/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0048/Test.java
deleted file mode 100644
index 6a57b10..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0048/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0048;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- System.out.println(30000);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0049/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0049/Test.java
deleted file mode 100644
index 3a8cb25..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0049/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0049;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(-2147483648);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0050/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0050/Test.java
deleted file mode 100644
index 7981a22..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0050/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0050;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(2147483648L);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0051/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0051/Test.java
deleted file mode 100644
index 2e6ceab..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0051/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0051;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(-2147483648L);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0052/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0052/Test.java
deleted file mode 100644
index 68c13d0..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0052/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0052;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(-9223372036854775808L);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0053/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0053/Test.java
deleted file mode 100644
index bbf359b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0053/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0053;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println("Hello" + " World");
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0054/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0054/Test.java
deleted file mode 100644
index 627ec4d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0054/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0054;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- boolean b = true;
- boolean b2 = true;
- boolean b3 = b && b2;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0055/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0055/Test.java
deleted file mode 100644
index 5f6e324..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0055/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0055;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- boolean b = true;
- boolean b2 = true;
- boolean b3 = b || b2;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0056/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0056/Test.java
deleted file mode 100644
index 67d9fd5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0056/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0056;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- boolean b = true;
- boolean b2 = true;
- boolean b3 = b == b2;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0057/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0057/Test.java
deleted file mode 100644
index 4ca3969..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0057/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0057;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- int i = 2;
- int j = 3;
- int n = i + j;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0058/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0058/Test.java
deleted file mode 100644
index b6f8e07..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0058/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0058;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- int i = 2;
- int j = 3;
- int n = i - j;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0059/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0059/Test.java
deleted file mode 100644
index 492718d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0059/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0059;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- int i = 2;
- int j = 3;
- int n = i * j;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0060/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0060/Test.java
deleted file mode 100644
index 6c34d4b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0060/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0060;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 2;
- int j = 3;
- int n = i / j;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0061/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0061/Test.java
deleted file mode 100644
index e473e46..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0061/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0061;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- int i = 2;
- int j = 3;
- int n = i % j;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0062/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0062/Test.java
deleted file mode 100644
index b1f1d29..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0062/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0062;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- int i = 2;
- int j = 3;
- int n = i ^ j;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0063/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0063/Test.java
deleted file mode 100644
index 7bd52bf..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0063/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0063;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 2;
- int j = 3;
- int n = i & j;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0064/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0064/Test.java
deleted file mode 100644
index f37e4aa..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0064/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0064;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- int i = 2;
- int j = 3;
- int n = i | j;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0065/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0065/Test.java
deleted file mode 100644
index bcb8119..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0065/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0065;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- boolean b = true;
- boolean b1 = true;
- boolean b2 = b < b1;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0066/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0066/Test.java
deleted file mode 100644
index 78220f5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0066/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0066;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- boolean b = true;
- boolean b1 = true;
- boolean b2 = b <= b1;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0067/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0067/Test.java
deleted file mode 100644
index b6c8711..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0067/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0067;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- boolean b = true;
- boolean b1 = true;
- boolean b2 = b > b1;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0068/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0068/Test.java
deleted file mode 100644
index 04e2793..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0068/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0068;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- boolean b = true;
- boolean b1 = true;
- boolean b2 = b >= b1;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0069/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0069/Test.java
deleted file mode 100644
index e99484d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0069/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0069;
-import java.util.*;
-public class Test {
-
- public static void main(String[] args) {
- boolean b = true;
- boolean b1 = true;
- boolean b2 = b != b1;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0070/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0070/Test.java
deleted file mode 100644
index 5f94bce..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0070/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0070;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- Object o = new Object();
- boolean b = o instanceof Integer;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0071/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0071/Test.java
deleted file mode 100644
index 9ebf251..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0071/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0071;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- Object o = new Object();
- boolean b = o instanceof java.lang.Integer;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0072/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0072/Test.java
deleted file mode 100644
index 564d415..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0072/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0072;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- boolean b = true;
- boolean b1 = !b;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0073/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0073/Test.java
deleted file mode 100644
index ae29385..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0073/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0073;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- int i = 2;
- int n = ~i;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0074/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0074/Test.java
deleted file mode 100644
index 9bd1ad6..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0074/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0074;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- int i = +2;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0075/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0075/Test.java
deleted file mode 100644
index 4300b82..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0075/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0075;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- int i = -2;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0076/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0076/Test.java
deleted file mode 100644
index 34b3ec9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0076/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0076;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- boolean b = args != null ? true : false;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0077/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0077/Test.java
deleted file mode 100644
index ea621bf..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0077/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0077;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- int i = true ? args.length: 0;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0078/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0078/Test.java
deleted file mode 100644
index e97db33..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0078/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0078;
-import java.util.*;
-public class Test {
- public void foo() {
- super.bar();
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0079/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0079/Test.java
deleted file mode 100644
index a9b72ee..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0079/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0079;
-import java.util.*;
-public class Test {
- public void foo() {
- super.bar(4);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0080/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0080/Test.java
deleted file mode 100644
index 5dda70a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0080/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0080;
-import java.util.*;
-public class Test {
- public void foo() {
- bar(4);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0081/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0081/Test.java
deleted file mode 100644
index 308b27a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0081/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0081;
-import java.util.*;
-public class Test {
- public void foo() {
- this.bar(4);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0082/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0082/Test.java
deleted file mode 100644
index 6a21ccd..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0082/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0082;
-import java.util.*;
-public class Test {
- public void foo() {
- for (;;);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0083/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0083/Test.java
deleted file mode 100644
index 5cedbc2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0083/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0083;
-import java.util.*;
-public class Test {
- public void foo() {
- for (int i = 0; i < 10; i++) {}
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0084/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0084/Test.java
deleted file mode 100644
index dfa3842..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0084/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0084;
-import java.util.*;
-public class Test {
- public void foo() {
- for (int i = 0; i < 10; i++);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0085/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0085/Test.java
deleted file mode 100644
index 3b82d16..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0085/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0085;
-import java.util.*;
-public class Test {
- public void foo() {
- for (int i = 0;; i++);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0086/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0086/Test.java
deleted file mode 100644
index af60814..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0086/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0086;
-import java.util.*;
-public class Test {
- public void foo() {
- for (; i < 10; i++);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0087/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0087/Test.java
deleted file mode 100644
index 3d6fe98..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0087/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0087;
-import java.util.*;
-public class Test {
- public void foo() {
- for (;;i++);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0088/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0088/Test.java
deleted file mode 100644
index 9f056b6..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0088/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0088;
-import java.util.*;
-public class Test {
- public void foo() {
- int i;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0089/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0089/Test.java
deleted file mode 100644
index 45cff9b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0089/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0089;
-import java.util.*;
-public class Test {
- public void foo() {
- java.lang.String s;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0090/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0090/Test.java
deleted file mode 100644
index 1d54855..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0090/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0090;
-import java.util.*;
-public class Test {
- public void foo() {
- int[] tab = {1, 2};
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0091/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0091/Test.java
deleted file mode 100644
index e88d975..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0091/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0091;
-import java.util.*;
-public class Test {
- public void foo(String s) {
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0092/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0092/Test.java
deleted file mode 100644
index 68b8917..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0092/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0092;
-
-public class Test {
- public void foo(final String s) {
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0093/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0093/Test.java
deleted file mode 100644
index 9cdca44..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0093/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0093;
-import java.util.*;
-public class Test {
- public void foo(String s) {
- for (int i = 0; i < 10; i++) {
- break;
- }
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0094/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0094/Test.java
deleted file mode 100644
index 1bf5ca5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0094/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0094;
-import java.util.*;
-public class Test {
- public void foo(String s) {
- for (int i = 0; i < 10; i++) {
- continue;
- }
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0095/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0095/Test.java
deleted file mode 100644
index 9dd82d4..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0095/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0095;
-import java.util.*;
-public class Test {
- public void foo(String s) {
- label: for (int i = 0; i < 10; i++) {
- continue label;
- }
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0096/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0096/Test.java
deleted file mode 100644
index f1b7f2f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0096/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0096;
-import java.util.*;
-public class Test {
-
- public void foo(String s) {
- label: for (int i = 0; i < 10; i++) {
- break label;
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0097/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0097/Test.java
deleted file mode 100644
index 87064bb..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0097/Test.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package test0097;
-import java.util.*;
-public class Test {
- public void foo(int i ) {
- switch(i) {
- case 1:
- break;
- case 2:
- System.out.println(2);
- break;
- default:
- System.out.println("default");
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0098/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0098/Test.java
deleted file mode 100644
index 0adc36d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0098/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0098;
-import java.util.*;
-public class Test {
- public void foo(int i ) {
- ;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0099/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0099/Test.java
deleted file mode 100644
index 9d7b6c7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0099/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0099;
-import java.util.*;
-public class Test {
- public void foo(int i ) {
- do {;
- } while(true);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0100/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0100/Test.java
deleted file mode 100644
index ad427d7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0100/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0100;
-import java.util.*;
-public class Test {
- public void foo(int i ) {
- while(true);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0101/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0101/Test.java
deleted file mode 100644
index 16173a8..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0101/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0101;
-import java.util.*;
-public class Test {
- public void foo(int i ) {
- while(true) {}
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0102/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0102/Test.java
deleted file mode 100644
index be26b9d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0102/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0102;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println("Hello" + " World" + "!");
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0103/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0103/Test.java
deleted file mode 100644
index 6b4d931..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0103/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0103;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println("Hello" + " World" + "!" + "!");
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0104/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0104/Test.java
deleted file mode 100644
index fa807d1..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0104/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0104;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println("Hello" + " World" + "!" + 4);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0105/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0105/Test.java
deleted file mode 100644
index c6b4ebd..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0105/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0105;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(4 + 5 + 6 + 4);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0106/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0106/Test.java
deleted file mode 100644
index 24dff63..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0106/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0106;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(4 - 5 + 6 + 4);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0107/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0107/Test.java
deleted file mode 100644
index 9584136..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0107/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0107;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(4 - 5 - 6 - 4);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0108/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0108/Test.java
deleted file mode 100644
index 96745f7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0108/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0108;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println("4" + 5 + 6 + 4);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0109/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0109/Test.java
deleted file mode 100644
index 4756ee7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0109/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0109;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println("4" - 5 + 6 + 4);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0110/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0110/Test.java
deleted file mode 100644
index c269111..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0110/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0110;
-import java.util.*;
-public class Test {
- public int foo(int i ) {
- return 2;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0111/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0111/Test.java
deleted file mode 100644
index 6925e43..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0111/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0111;
-import java.util.*;
-public class Test {
- public int foo(int i ) {
- return 2\u003B
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0112/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0112/Test.java
deleted file mode 100644
index 448fe59..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0112/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0112;
-import java.util.*;
-public class Test {
- public int foo(int i ) {
- synchronized(this) {
- }
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0113/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0113/Test.java
deleted file mode 100644
index fb64e29..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0113/Test.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package test0113;
-import java.util.*;
-public class Test {
- public int foo(int i ) {
- try {
- } catch(Exception e) {
- } finally {
- }
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0114/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0114/Test.java
deleted file mode 100644
index ffd6874..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0114/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0114;
-import java.util.*;
-public class Test {
- public int foo(int i ) {
- try {
- } catch(Exception e) {
- }
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0115/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0115/Test.java
deleted file mode 100644
index cad1f88..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0115/Test.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package test0115;
-import java.util.*;
-public class Test {
- public int foo(int i ) {
- try {
- return 2;
- } catch(Exception e) {
- }
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0116/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0116/Test.java
deleted file mode 100644
index cd6aaaa..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0116/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0116;
-import java.util.*;
-public class Test {
- public int foo(Exception e) {
- throw e \u003B
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0117/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0117/Test.java
deleted file mode 100644
index 75ebfb6..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0117/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0117;
-import java.util.*;
-public class Test {
- public int foo(Exception e) {
- throw e /* comment in the middle of a throw */ \u003B
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0118/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0118/Test.java
deleted file mode 100644
index ab04328..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0118/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0118;
-import java.util.*;
-public class Test {
- public int foo(Exception e) {
- throw e /* comment in the middle of a throw */ \u003B/** */
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0119/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0119/Test.java
deleted file mode 100644
index 0d50971..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0119/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0119;
-import java.util.*;
-public class Test {
- public int foo(Exception e) {
- if (true)\u003B
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0120/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0120/Test.java
deleted file mode 100644
index 6676d64..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0120/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0120;
-import java.util.*;
-public class Test {
- public int foo(Exception e) {
- if (true)\u003B
- else ;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0121/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0121/Test.java
deleted file mode 100644
index c0c00be..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0121/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0121;
-import java.util.*;
-public class Test {
- public int foo(Exception e) {
- if (true) {}
- else ;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0122/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0122/Test.java
deleted file mode 100644
index 3024d7a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0122/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0122;
-import java.util.*;
-public class Test {
- public int foo(Exception e) {
- if (true) return 2\u003B
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0123/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0123/Test.java
deleted file mode 100644
index 2b2d130..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0123/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0123;
-import java.util.*;
-public class Test {
- public int foo(Exception e) {
- if (true) return 2;
- else return 3;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0124/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0124/Test.java
deleted file mode 100644
index b2666a9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0124/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0124;
-import java.util.*;
-public class Test {
- public int foo(Exception e) {
- int x= 10, z[] = null, i, j[][];
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0125/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0125/Test.java
deleted file mode 100644
index f440fc1..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0125/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0125;
-import java.util.*;
-public class Test {
- public int foo(Exception e) {
- int[] x= 10, z[] = null, i, j[][];
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0126/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0126/Test.java
deleted file mode 100644
index 0a9c520..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0126/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0126;
-import java.util.*;
-public class Test {
- public void foo(int i) {
- for (String[] tab[] = null;; ++i) {}
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0127/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0127/Test.java
deleted file mode 100644
index af5a7e9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0127/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0127;
-import java.util.*;
-public class Test {
- public void foo(int i) {
- for (String tab[] = null;; ++i) {}
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0128/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0128/Test.java
deleted file mode 100644
index 5b6cf3a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0128/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0128;
-import java.util.*;
-public class Test {
- public void foo(int i) {
- for (String tab[] = null;; i++/**/) {}
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0129/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0129/Test.java
deleted file mode 100644
index 7b43ff5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0129/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0129;
-import java.util.*;
-public class Test {
- int i;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0130/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0130/Test.java
deleted file mode 100644
index 884c867..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0130/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0130;
-import java.util.*;
-public class Test {
- public int x= 10, y[] = null, i, j[][];
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0131/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0131/Test.java
deleted file mode 100644
index be3a7ef..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0131/Test.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package test0131;
-import java.util.*;
-public class Test {
- void foo(final int i) {}
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0132/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0132/Test.java
deleted file mode 100644
index 069369b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0132/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0132;
-import java.util.*;
-public class Test {
- /** JavaDoc Comment
- */
- void foo(final int i) {}
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0133/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0133/Test.java
deleted file mode 100644
index 834da2e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0133/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0133;
-import java.util.*;
-public class Test {
- /* Multiple line Comment
- */
- void foo(final int i) {}
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0134/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0134/Test.java
deleted file mode 100644
index 96cfe99..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0134/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0134;
-import java.util.*;
-public class Test {
- // Line comment
- void foo(final int i) {}
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0135/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0135/Test.java
deleted file mode 100644
index 61d5ea9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0135/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0135;
-import java.util.*;
-public class Test {
- /** JavaDoc Comment
- */
- int i;
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0136/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0136/Test.java
deleted file mode 100644
index a1215f5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0136/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0136;
-import java.util.*;
-public class Test {
- /* Multiple lines comment
- */
- int i;
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0137/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0137/Test.java
deleted file mode 100644
index 48d5328..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0137/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0137;
-import java.util.*;
-public class Test {
- // Line comment
- int i;
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0138/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0138/Test.java
deleted file mode 100644
index 2e86377..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0138/Test.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package test0138;
-import java.util.*;
- // Line comment
-public class Test {
- int i;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0139/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0139/Test.java
deleted file mode 100644
index 0e15fc0..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0139/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0139;
-import java.util.*;
-/* Line comment
- */
-public class Test {
- int i;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0140/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0140/Test.java
deleted file mode 100644
index 1aa8cb9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0140/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0140;
-import java.util.*;
-/** JavaDoc Comment
- */
-public class Test {
- int i;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0141/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0141/Test.java
deleted file mode 100644
index 51d1b9a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0141/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0141;
-import java.util.*;
-public class Test {
- /** JavaDoc Comment
- */
- class B {}
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0142/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0142/Test.java
deleted file mode 100644
index 026de1b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0142/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0142;
-import java.util.*;
-public class Test {
- /* Multiple lines comment
- */
- class B {}
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0143/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0143/Test.java
deleted file mode 100644
index b553dd2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0143/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0143;
-import java.util.*;
-public class Test {
- // Line comment
- public static class B {}
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0144/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0144/Test.java
deleted file mode 100644
index 7d41b35..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0144/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0144;
-import java.util.*;
-public class Test {
- public static class B {}
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0145/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0145/Test.java
deleted file mode 100644
index c9ad484..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0145/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0145;
-import java.util.*;
-public class Test {
- {}
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0146/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0146/Test.java
deleted file mode 100644
index 3f6d1ef..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0146/Test.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package test0146;
-import java.util.*;
-public class Test {
- static {}
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0147/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0147/Test.java
deleted file mode 100644
index d2b119f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0147/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0147;
-import java.util.*;
-public class Test {
-
- /** JavaDoc Comment
- */
- static {}
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0148/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0148/Test.java
deleted file mode 100644
index 6aa588c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0148/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0148;
-import java.util.*;
-public class Test {
-
- /** JavaDoc Comment
- */
- {}
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0149/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0149/Test.java
deleted file mode 100644
index 4ce9863..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0149/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0149;
-import java.util.*;
-public class Test {
-
- /* JavaDoc Comment
- */
- {}
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0150/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0150/Test.java
deleted file mode 100644
index 0fce3ca..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0150/Test.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package test0150
-import java.util.*;
-public class Test {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0151/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0151/Test.java
deleted file mode 100644
index a72f397..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0151/Test.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package test0151;
-import java.util.*;
-public class Test {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0152/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0152/Test.java
deleted file mode 100644
index 7cb20d3..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0152/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0152;
-import java.util.*;
-public class Test {
- publicccc voidd foo(() {}
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0153/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0153/Test.java
deleted file mode 100644
index 9485877..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0153/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0153;
-import java.util.*;
-public class Test {
- public void foo() {
- int i
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0154/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0154/Test.java
deleted file mode 100644
index 95a52c7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0154/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0154;
-import java.util.*;
-class Test {
- int[] tab;
- String[] t;
- Test[] t2;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0155/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0155/Test.java
deleted file mode 100644
index 119bf75..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0155/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0155;
-import java.util.*;
-public class Test {
- public void m(int i, final boolean b){}
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0156/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0156/Test.java
deleted file mode 100644
index c05399a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0156/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0156;
-import java.util.*;
-public class Test {
- int foo(int i) {
- i++;
- return i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0159/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0159/Test.java
deleted file mode 100644
index b5ba6c5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0159/Test.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package test0159;
-import java.util.*;
-public class Test {
- Test(int i){
- }
- void n(){
- final int y= 0;
- new Test(y){
- void f(){
- int y= 9;
- }
- };
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0160/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0160/Test.java
deleted file mode 100644
index 1137d11..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0160/Test.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package test0160;
-import java.util.*;
-public class Test {
-
- Test[] t, g[] = null;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0161/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0161/Test.java
deleted file mode 100644
index a874eb7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0161/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0161;
-import java.util.*;
-
-public class Test implements Cloneable {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0162/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0162/Test.java
deleted file mode 100644
index 291a4c8..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0162/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0162;
-import java.util.*;
-public interface Test {
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0163/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0163/Test.java
deleted file mode 100644
index e4ab40a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0163/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0163;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(new java.lang.Object() {});
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0164/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0164/Test.java
deleted file mode 100644
index ebd01ad..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0164/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0164;
-import java.util.*;
-public class Test {
- private class B {}
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0165/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0165/Test.java
deleted file mode 100644
index aad7e80..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0165/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0165;
-import java.util.*;
-public class Test {
- void foo() {
- class C {
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0166/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0166/Test.java
deleted file mode 100644
index 960aa83..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0166/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0166;
-import java.util.*;
-public class Test {
- public int foo(Exception e) {
- int x= 10, z[] = null, i, j[][];
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0167/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0167/Test.java
deleted file mode 100644
index 9bf278d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0167/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0167;
-import java.util.*;
-public class Test {
- void f() {
- int f = new Test[1+2].length;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0168/test1/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0168/test1/Test.java
deleted file mode 100644
index 9af8e82..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0168/test1/Test.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package test0168.test1;
-import java.util.*;
-public class Test {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0169/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0169/Test.java
deleted file mode 100644
index 8299945..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0169/Test.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package test0169;
-import java.util.*;
-public class Test {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0171/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0171/Test.java
deleted file mode 100644
index c11c898..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0171/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0171;
-import java.util.*;
-
-class A {
-}
-
-public class Test {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0172/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0172/Test.java
deleted file mode 100644
index a55c8f2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0172/Test.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package test0172;
-import java.util.*;
-import java.io.IOException;
-
-public class Test {
-
- void foo(int[] i) throws IOException {
- }
-
- public static void main(String[] args) {
- }
-
- private String bar(String s) throws NullPointerException {
- return s;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0173/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0173/Test.java
deleted file mode 100644
index afdbc79..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0173/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0173;
-import java.util.*;
-public class Test {
- int foo() {
- int i = 0;
- i++;
- return i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0174/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0174/Test.java
deleted file mode 100644
index 00da130..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0174/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0174;
-import java.util.*;
-public class Test {
- int i;
- int foo() {
- i++;
- return i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0175/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0175/Test.java
deleted file mode 100644
index d401ea1..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0175/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0175;
-import java.util.*;
-public class Test {
- int i = 0;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0176/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0176/Test.java
deleted file mode 100644
index 5ee3d63..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0176/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0176;
-import java.util.*;
-public class Test {
- int i = 0;
- int foo() {
- return this.i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0177/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0177/Test.java
deleted file mode 100644
index dfadfd3..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0177/Test.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package test0177;
-import java.util.*;
-public class Test {
- void bar() {
- double i = 1.0;
- System.out.println(i);
- }
-
- int foo() {
- int i = 0;
- i++;
- return i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0178/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0178/Test.java
deleted file mode 100644
index d229d81..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0178/Test.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package test0178;
-import java.util.*;
-
-class Top {
- int j;
-}
-
-public class Test extends Top {
- int foo() {
- return super.j;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0179/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0179/Test.java
deleted file mode 100644
index 1271fe5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0179/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0179;
-import java.util.*;
-public class Test {
- public void foo() {
- Test t = new Test();
- System.out.println(t);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0180/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0180/Test.java
deleted file mode 100644
index c8608ad..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0180/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0180;
-import java.util.*;
-public class Test {
- public void foo() {
- Test[] t = new Test[0];
- System.out.println(t);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0181/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0181/Test.java
deleted file mode 100644
index e426d83..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0181/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0181;
-import java.util.*;
-public class Test {
- public void foo() {
- Test[] t = {};
- System.out.println(t);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0182/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0182/Test.java
deleted file mode 100644
index fce1212..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0182/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0182;
-import java.util.*;
-public class Test {
- public void foo() {
- int i= 10;
- if (/*]*/i < 10/*[*/)
- foo();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0183/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0183/Test.java
deleted file mode 100644
index eca6d67..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0183/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0183;
-import java.util.*;
-public class Test {
- public void foo() {
- int i= 10;
- if (/*]*/i < 10 && i < 20/*[*/)
- foo();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0184/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0184/Test.java
deleted file mode 100644
index 502089e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0184/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0184;
-import java.util.*;
-public class Test {
- public void foo() {
- int i= 10;
- if (/*]*/i < 10 || i < 20/*[*/)
- foo();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0185/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0185/Test.java
deleted file mode 100644
index ca876b7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0185/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0185;
-import java.util.*;
-public class Test {
- public void foo() {
- int i= 10;
- if (/*]*/i == 10/*[*/)
- foo();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0186/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0186/Test.java
deleted file mode 100644
index 587f6a4..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0186/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0186;
-import java.util.*;
-public class Test {
- public void foo() {
- Object o= null;
- if (/*]*/o == o/*[*/)
- foo();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0187/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0187/Test.java
deleted file mode 100644
index 224c61a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0187/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0187;
-import java.util.*;
-public class Test {
- public void foo() {
- int i= 0;
- while (/*]*/i <= 10/*[*/)
- foo();
- foo();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0188/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0188/Test.java
deleted file mode 100644
index e4075fd..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0188/Test.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package test0188;
-import java.util.*;
-public class Test {
- public void foo() {
- int i= 0;
- foo();
- do {
- foo();
- } while (/*]*/i <= 10/*[*/);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0189/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0189/Test.java
deleted file mode 100644
index e1de33c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0189/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0189;
-import java.util.*;
-public class Test {
- public void foo() {
- for (int i= 0;/*[*/ i < 10/*]*/; i++)
- foo();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0190/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0190/Test.java
deleted file mode 100644
index 4df1c09..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0190/Test.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package test0190;
-import java.util.*;
-public class Test {
- public static class Scanner {
- public int x;
- public int y;
- }
- public static class Selection {
- public int start;
- public int end;
- }
-
- public void foo(Selection selection) {
- Scanner scanner= new Scanner();
-
- if (/*]*/scanner.x < selection.start && selection.start < scanner.y/*[*/) {
- g();
- }
- }
-
- public void g() {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0191/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0191/Test.java
deleted file mode 100644
index 613039f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0191/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0191;
-import java.util.*;
-public class Test {
- public void foo() {
- boolean b;
- b= 1 < 10 && /*]*/2 < 20/*[*/;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0192/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0192/Test.java
deleted file mode 100644
index 35a84cf..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0192/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0192;
-import java.util.*;
-public class Test {
- public void foo() {
- int i= /*]*/0/*[*/;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0193/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0193/Test.java
deleted file mode 100644
index 97b1c68..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0193/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0193;
-import java.util.*;
-public class Test {
- class Inner {
- }
- public void foo() {
- Inner inner= /*]*/new Inner();/*[*/
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0194/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0194/Test.java
deleted file mode 100644
index bd5b327..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0194/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0194;
-import java.util.*;
-public class Test {
- class Inner {
- }
- public void foo() {
- Inner[] inner= /*]*/new Inner[10];/*[*/
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0195/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0195/Test.java
deleted file mode 100644
index 813e3e3..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0195/Test.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package test0195;
-import java.util.*;
-import java.io.File;
-
-class A {
- public File getFile() {
- return null;
- }
- public void useFile(File file) {
- }
-}
-
-public class Test {
- public void foo() {
- A a= null;
- a.useFile(/*]*/a.getFile()/*[*/);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0196/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0196/Test.java
deleted file mode 100644
index 7c78625..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0196/Test.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package test0196;
-import java.util.*;
-public class Test {
- class Inner {
- }
- public void foo() {
- Inner inner= null;
- boolean b;
- b= /*]*/inner instanceof Inner/*[*/;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0197/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0197/Test.java
deleted file mode 100644
index 35a3f64..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0197/Test.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package test0197;
-import java.util.*;
-import java.io.File;
-class A {
- public File getFile() {
- return null;
- }
- public void useFile(File file) {
- }
-}
-
-public class Test {
- public void foo() {
- A a= null;
- /*]*/a.getFile()/*[*/.getName();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0198/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0198/Test.java
deleted file mode 100644
index 28c874f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0198/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0198;
-import java.util.*;
-public class Test {
- public int foo() {
- return 10 + /*]*/20 * 30/*[*/ + 10;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0199/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0199/Test.java
deleted file mode 100644
index a3cff3a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0199/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0199;
-import java.util.*;
-public class Test {
- public void foo() {
- int i= 20 + /*]*/10 * 30/*[*/ + 10;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0200/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0200/Test.java
deleted file mode 100644
index 19ca6b8..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0200/Test.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package test0200;
-import java.util.*;
-import java.io.File;
-
-class A {
- public File getFile() {
- return null;
- }
- public void useFile(File file) {
- }
-}
-
-public class Test {
- public void foo() {
- int f= new A[/*]*/1 + 2/*[*/].length;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0201/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0201/Test.java
deleted file mode 100644
index a4fe798..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0201/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0201;
-import java.util.*;
-public class Test {
- public void foo() {
- /*]*/foo();/*[*/
-
- for (int i= 0; i < 10; i++)
- foo();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0202/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0202/Test.java
deleted file mode 100644
index 97eaa91..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0202/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0202;
-import java.util.*;
-public class Test {
- int f= (2);
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0203/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0203/Test.java
deleted file mode 100644
index 256ca9a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0203/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0203;
-import java.util.*;
-public class Test {
- int f= (2);
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0204/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0204/Test.java
deleted file mode 100644
index facf21d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0204/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0204;
-import java.util.*;
-public class Test {
- int f= ((2));
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0205/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0205/Test.java
deleted file mode 100644
index e3c9511..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0205/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0205;
-import java.util.*;
-public class Test {
- void f(){
- /*[*/class AA extends Test {}/*]*/
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0206/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0206/Test.java
deleted file mode 100644
index 065de3c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0206/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0206;
-import java.util.*;
-public class Test {
- public Test field;
- public int i;
-
- public int foo() {
- return field.field.field.field.i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0207/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0207/Test.java
deleted file mode 100644
index 725ba87..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0207/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0207;
-import java.util.*;
-public class Test {
- /** JavaDoc Comment
- */
- void foo(final int i) {}/**/
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0208/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0208/Test.java
deleted file mode 100644
index c6e142a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0208/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0208;
-import java.util.*;
-public class Test {
- /* Multiple line Comment
- */
- void foo(final int i) {}/**/
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0209/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0209/Test.java
deleted file mode 100644
index d2d1dd4..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0209/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0209;
-import java.util.*;
-public class Test {
- // Line comment
- void foo(final int i) {}/**/
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0210/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0210/Test.java
deleted file mode 100644
index 695b8e2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0210/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0210;
-import java.util.*;
-public class Test {
- /** JavaDoc Comment
- */
- int i;/**/
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0211/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0211/Test.java
deleted file mode 100644
index 0a883a5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0211/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0211;
-import java.util.*;
-public class Test {
- /* Multiple lines comment
- */
- int i;/**/
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0212/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0212/Test.java
deleted file mode 100644
index 421ca11..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0212/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0212;
-import java.util.*;
-public class Test {
- // Line comment
- int i;/**/
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0213/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0213/Test.java
deleted file mode 100644
index 4c68332..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0213/Test.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package test0213;
-import java.util.*;
- // Line comment
-public class Test {
- int i;
-}/**/
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0214/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0214/Test.java
deleted file mode 100644
index 2f34954..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0214/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0214;
-import java.util.*;
-/* Line comment
- */
-public class Test {
- int i;
-}/**/
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0215/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0215/Test.java
deleted file mode 100644
index 4491b87..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0215/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0215;
-import java.util.*;
-/** JavaDoc Comment
- */
-public class Test {
- int i;
-}/**/
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0216/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0216/Test.java
deleted file mode 100644
index 669a4ce..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0216/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0216;
-import java.util.*;
-public class Test {
- /** JavaDoc Comment
- */
- class B {}/**/
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0217/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0217/Test.java
deleted file mode 100644
index 248e034..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0217/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0217;
-import java.util.*;
-public class Test {
- /* Multiple lines comment
- */
- class B {}/**/
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0218/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0218/Test.java
deleted file mode 100644
index 612f423..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0218/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0218;
-import java.util.*;
-public class Test {
- // Line comment
- public static class B {}/**/
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0219/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0219/Test.java
deleted file mode 100644
index 596ea6c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0219/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0219;
-import java.util.*;
-public class Test {
- public static class B {}/**/
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0220/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0220/Test.java
deleted file mode 100644
index badc9f9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0220/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0220;
-import java.util.*;
-public class Test {
- {}/**/
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0221/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0221/Test.java
deleted file mode 100644
index a12ea17..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0221/Test.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package test0221;
-import java.util.*;
-public class Test {
- static {}/**/
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0222/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0222/Test.java
deleted file mode 100644
index b060116..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0222/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0222;
-import java.util.*;
-public class Test {
-
- /** JavaDoc Comment
- */
- static {}/**/
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0223/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0223/Test.java
deleted file mode 100644
index c1acfa8..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0223/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0223;
-import java.util.*;
-public class Test {
-
- /** JavaDoc Comment
- */
- {}/**/
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0224/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0224/Test.java
deleted file mode 100644
index 62261b1..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0224/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0224;
-import java.util.*;
-public class Test {
-
- /* JavaDoc Comment
- */
- {}/**/
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0225/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0225/Test.java
deleted file mode 100644
index 337910e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0225/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0225;
-import java.util.*;
-public class Test {
- public void foo(String s) {
- label: for (int i = 0; i < 10; i++) {
- continue label;
- }
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0226/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0226/Test.java
deleted file mode 100644
index 84301f7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0226/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0226;
-import java.util.*;
-public class Test {
-
- public void foo(String s) {
- label: for (int i = 0; i < 10; i++) {
- break label;
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0227/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0227/Test.java
deleted file mode 100644
index 13c07af..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0227/Test.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package test0227;
-import java.util.*;
-class A {
- long j;
-}
-class B {
- A fA;
-}
-class C {
- B fB;
-}
-public class Test {
- public C field;
- public int i;
-
- public int foo() {
- return field.fB.fA.j;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0228/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0228/Test.java
deleted file mode 100644
index 21df485..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0228/Test.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package test0228;
-import java.util.*;
-public class Test {
- public static int foo() {
- return 4;
- }
-
- public int bar() {
- return test0228.Test.foo();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0229/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0229/Test.java
deleted file mode 100644
index 89db110..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0229/Test.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package test0229;
-public class Test {
- public void foo() {
- System.err.println();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0230/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0230/Test.java
deleted file mode 100644
index 237afaa..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0230/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0230;
-import java.io.PrintStream;
-public class Test {
- PrintStream err = System.err;
- public void foo() {
- err.println();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0231/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0231/Test.java
deleted file mode 100644
index 776f39c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0231/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0231;
-import java.util.*;
-public class Test {
- public void foo() {
- System.err.println();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0232/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0232/Test.java
deleted file mode 100644
index e8b86c1..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0232/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0232;
-import java.util.*;
-public class Test {
- void foo(String[] array) {
- int i = array.length;
- System.out.println(i);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0233/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0233/Test.java
deleted file mode 100644
index da9293e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0233/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0233;
-
-public class Test {
- Toto t;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0234/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0234/Test.java
deleted file mode 100644
index 9b64e89..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0234/Test.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package test0234;
-public class Test {
- List field;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0235/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0235/Test.java
deleted file mode 100644
index 1248c24..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0235/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0235;
-
-import java.awt.List;
-
-public class Test {
- List field;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0236/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0236/Test.java
deleted file mode 100644
index da3f69f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0236/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0236;
-import java.util.*;
-public class Test {
- int i= 0, k = 1;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0238/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0238/Test.java
deleted file mode 100644
index 92303fe..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0238/Test.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package test0238;
-import java.util.*;
-
-public class Test {
- public int foo() {
- class X {
- int foo() {
- return Test.this.bar();
- }
- }
- return new X().foo();
- }
-
- public int bar() {
- return 0;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0239/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0239/Test.java
deleted file mode 100644
index ce548ff..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0239/Test.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package test0239;
-
-import java.util.*;
-class T {
- int bar() {
- return 0;
- }
-}
-
-public class Test extends T {
- public int foo() {
- class X {
- int foo() {
- return Test.super.bar();
- }
- }
- return new X().foo();
- }
-
- public int bar() {
- return 0;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0240/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0240/Test.java
deleted file mode 100644
index 08f32b3..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0240/Test.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package test0240;
-import java.util.*;
-public class Test {
- public int foo() {
- class X {
- int foo() {
- return Test.this.f;
- }
- }
- return new X().foo();
- }
-
- public int f = 0;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0241/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0241/Test.java
deleted file mode 100644
index e229c61..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0241/Test.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package test0241;
-import java.util.*;
-public class Test {
-
- public int i;
-
- public void foo() {}
-
- class B {
- }
-
- class D {
- }
-
- public void bar() {
- }
-
- int j;
-
- public static int foo3() {
- return 3;
- }
- public static int k = foo3();
-
- Object l, n, m;
-
- public void foo2() {
- }
-
- class D {
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0242/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0242/Test.java
deleted file mode 100644
index 193f200..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0242/Test.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package test0242;
-import java.util.*;
-class T {
- public int f = 0;
-}
-
-public class Test extends T {
- public int foo() {
- class X {
- int foo() {
- return Test.super.f;
- }
- }
- return new X().foo();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0243/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0243/Test.java
deleted file mode 100644
index 00bfd26..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0243/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0243;
-import java.util.*;
-public class Test {
- void m(){
- try{
- } catch (Exception e){m();}
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0244/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0244/Test.java
deleted file mode 100644
index 9e54f24..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0244/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0244;
-import java.util.*;
-public class Test {
- void m(){
- try{
- } catch (RuntimeException e){m();}
- catch(Exception e) {}
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0245/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0245/Test.java
deleted file mode 100644
index 2dd2dbf..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0245/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0245;
-import java.util.*;
-public class Test {
- public int a() {
- int i= 0;
- return i;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0246/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0246/Test.java
deleted file mode 100644
index 3fb5726..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0246/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0246;
-
-import java.util.*;
-import java.io.IOException;
-
-public class Test {
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0247/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0247/Test.java
deleted file mode 100644
index 0ce7333..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0247/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0247;
-import java.util.*;
-public class Test {
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0248/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0248/Test.java
deleted file mode 100644
index 0996352..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0248/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0248;
-import java.util.*;
-public class Test {
- native void m(int i);
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0249/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0249/Test.java
deleted file mode 100644
index 877022e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0249/Test.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package test0249;
-import java.util.*;
-public class Test {
- int k;
- static class j{
- static int k;
- }
- void m(){
- int y= 0;
- j.k= 0;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0250/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0250/Test.java
deleted file mode 100644
index 6f6ad11..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0250/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0250;
-import java.util.*;
-interface Test {
- void m(int i, int j);
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0251/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0251/Test.java
deleted file mode 100644
index 323fc5b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0251/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0251;
-import java.util.*;
-public class Test {
- void foo() {
- java.lang.System.out.println();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0252/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0252/Test.java
deleted file mode 100644
index 7aedb36..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0252/Test.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package test0252;
-import java.util.*;
-public class Test {
- Object foo() {
- final int j = 4;
-
- return new Object() {
- int bar() {
- return j;
- }
- };
- }
-}
-
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0253/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0253/Test.java
deleted file mode 100644
index de8b589..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0253/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0253;
-import java.util.*;
-public class Test {
- public StringBuffer foo() {
- return new StringBuffer("");
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0254/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0254/Test.java
deleted file mode 100644
index 2b49bb2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0254/Test.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package test0254;
-import java.util.*;
-public class Test {
-
- class C {
- }
-
- Object foo() {
- return new Test().new C();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0255/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0255/Test.java
deleted file mode 100644
index e1e61f2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0255/Test.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package test0255;
-import java.util.*;
-public class Test {
- public void bar() {
- foo((String[]) null);
- }
-
- void foo(String[] arg) {
- }
-
- void foo(Object arg) {
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0256/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0256/Test.java
deleted file mode 100644
index 59a8caa..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0256/Test.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package test0256;
-import java.util.*;
-public class Test {
- public void bar() {
- foo((Object) null);
- }
-
- void foo(String[] arg) {
- }
-
- void foo(Object arg) {
- }
-}
-
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0257/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0257/Test.java
deleted file mode 100644
index 32c102c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0257/Test.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package test0257;
-import java.util.*;
-public class Test {
- public void bar() {
- foo((int) 0);
- }
-
- void foo(int arg) {
- }
-
- void foo(long arg) {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0258/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0258/Test.java
deleted file mode 100644
index 41cecc1..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0258/Test.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package test0256;
-import java.util.*;
-public class Test {
- public void bar() {
- foo((java.lang.Object) null);
- }
-
- void foo(String[] arg) {
- }
-
- void foo(Object arg) {
- }
-}
-
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0259/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0259/Test.java
deleted file mode 100644
index 786971f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0259/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-//cannot rename to i, i
-package test0259;
-public class Test {
- int m(){
- int i, /*[*/int j/*]*/;
- return 0;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0260/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0260/Test.java
deleted file mode 100644
index f031d4c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0260/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0260;
-import java.util.*;
-public interface Test {
- void m(int i, int j);
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0261/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0261/Test.java
deleted file mode 100644
index 4a6b989..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0261/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0261;
-import java.util.*;
-public class Test {
- public int foo(int variable) {
- return varble; // <-- Unable to resolve binding here
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0262/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0262/Test.java
deleted file mode 100644
index 02349d2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0262/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0262;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(new java.lang.Exception("ERROR"));
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0263/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0263/Test.java
deleted file mode 100644
index b75929b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0263/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0263;
-import java.util.*;
-public class Test {
- void m(int i){
- m(i);
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0264/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0264/Test.java
deleted file mode 100644
index a0f8c0d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0264/Test.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package test0264;
-import java.util.*;
-public class Test {
- void m(final int i){
- Test a= new Test(){
- void m(int k){
- k= i;
- }
- };
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0265/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0265/Test.java
deleted file mode 100644
index f3e7463..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0265/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0265;
-import java.util.*;
-public class Test {
- public int foo() {
- return 10 + /*]*/20 * 30/*[*/ + 10;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0266/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0266/Test.java
deleted file mode 100644
index 85fdd52..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0266/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0266;
-import java.util.*;
-public class Test {
- public static class Inner{}
- public static void m(){
- Inner\u005b] i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0267/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0267/Test.java
deleted file mode 100644
index a2fd880..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0267/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0267;
-import java.util.*;
-public class Test {
- public static class Inner{}
- public static void m(){
- Inner[] i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0268/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0268/Test.java
deleted file mode 100644
index d7753c5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0268/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0268;
-import java.util.*;
-public class Test {
- public static class Inner{}
- public static void m(){
- test0268.Test.Inner[] i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0269/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0269/Test.java
deleted file mode 100644
index b1cae34..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0269/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0269;
-import java.util.*;
-public class Test {
- public static class Inner{}
- public static void m(){
- test0269.Test.Inner[/**/] i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0270/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0270/Test.java
deleted file mode 100644
index 2959bc9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0270/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0270;
-import java.util.*;
-public class Test {
- public static class Inner{}
- public static void m(){
- test0270.Test.Inner i[];
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0271/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0271/Test.java
deleted file mode 100644
index 5ea10fb..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0271/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0271;
-import java.util.*;
-public class Test {
- public static class Inner{}
- public static void m(){
- test0271.Test.Inner[] i[];
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0272/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0272/Test.java
deleted file mode 100644
index bfb126a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0272/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0272;
-
-public class Test {
- public void foo() {
- for (int i= 0; i < 10; i++) foo();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0273/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0273/Test.java
deleted file mode 100644
index 5212a42..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0273/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0273;
-
-public class Test {
- public void foo() {
- for (int i= 0; i < 10; i++) { foo(); }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0274/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0274/Test.java
deleted file mode 100644
index f0bd3ca..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0274/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0274;
-
-public class Test {
- public void foo(int j) {
- int i = 0;
- while (i < 10) { foo(i++); }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0275/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0275/Test.java
deleted file mode 100644
index baab661..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0275/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0275;
-public class Test {
- public void foo(int j) {
- int i = 0;
- while (i < 10) foo(i++);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0276/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0276/Test.java
deleted file mode 100644
index 92b037b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0276/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0276;
-
-public class Test {
- public void foo() {
- foo();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0277/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0277/Test.java
deleted file mode 100644
index c96ffa6..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0277/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0277;
-
-public class Test {
- public void foo() {
- }
-}
-
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0278/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0278/Test.java
deleted file mode 100644
index d886793..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0278/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0278;
-
-public class Test {
- Class c = java.lang.String.class;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0279/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0279/Test.java
deleted file mode 100644
index c31a26d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0279/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0279;
-
-public class Test {
- void foo() {
- Class c = java.lang.String.class;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0280/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0280/Test.java
deleted file mode 100644
index 37817a0..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0280/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0280;
-import java.util.*;
-public class Test {
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0281/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0281/Test.java
deleted file mode 100644
index 41cf840..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0281/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0281;
-
-public class Test {
- Object o= /*]*/new Object()/*[*/;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0282/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0282/Test.java
deleted file mode 100644
index 6093411..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0282/Test.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package test0282;
-public class Test {
- boolean b = /*]*/true/*[*/;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0283/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0283/Test.java
deleted file mode 100644
index c0f0b29..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0283/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0283;
-
-public class Test {
- char c = /*]*/'c'/*[*/;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0284/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0284/Test.java
deleted file mode 100644
index b6add78..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0284/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0284;
-
-public class Test {
- Object o = /*]*/null/*[*/;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0285/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0285/Test.java
deleted file mode 100644
index 3129968..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0285/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0285;
-
-public class Test {
- Object o = /*]*/Object.class/*[*/;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0286/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0286/Test.java
deleted file mode 100644
index d9b3531..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0286/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0286;
-
-public class Test {
- int i = /**/(2)/**/;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0287/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0287/Test.java
deleted file mode 100644
index 3eb5a11..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0287/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0287;
-
-public class Test {
- String[] tab = /**/new String[3]/**/;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0288/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0288/Test.java
deleted file mode 100644
index c13bf70..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0288/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0288;
-
-public class Test {
- String[] tab = /**/{ }/**/;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0289/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0289/Test.java
deleted file mode 100644
index 69fd582..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0289/Test.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package test0289;
-import java.util.*;
-public class Test {
- String[] tab1 = new String[] { null} ;
- String s = /**/tab1[0]/**/;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0290/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0290/Test.java
deleted file mode 100644
index 7ca9337..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0290/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0290;
-
-public class Test {
- Object o = /*]*/new java.lang.Object()/*[*/;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0291/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0291/Test.java
deleted file mode 100644
index b31ab01..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0291/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0291;
-
-public class Test {
- bar() {}
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0292/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0292/Test.java
deleted file mode 100644
index 54a4631..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0292/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0292;
-
-public class Test {
- int bar() throws Throwable {
- return Test.x;
- }
- static int x;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0293/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0293/Test.java
deleted file mode 100644
index d2dff62..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0293/Test.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package test0293;
-
-public class Test {
- public void foo() {
- Runnable run= new Runnable() {
- public void run() {
- /*]*/foo();/*[*/
- }
- };
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0294/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0294/Test.java
deleted file mode 100644
index f42f634..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0294/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0294;
-
-public class Test {
- public void fails() {
- foo()
- }
- public void foo() {
- foo();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0295/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0295/Test.java
deleted file mode 100644
index 9f013db..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0295/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0295;
-
-public class Test {
- public List g() {
- return null;
- }
- public void foo() {
- g();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0296/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0296/Test.java
deleted file mode 100644
index a95fc8f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0296/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0296;
-
-public class Test {
- public void fails() {
- foo()
- }
- public void foo() {
- foo();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0297/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0297/Test.java
deleted file mode 100644
index 3e27816..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0297/Test.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package test0297;
-
-import java.util.List;
-
-public class Test {
- public List fList;
-
- public void foo() {
- int i= 10;
- switch (i) {
- case 1:
- List l= null;
- break;
- default:
- }
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0298/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0298/Test.java
deleted file mode 100644
index 14e6d13..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0298/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0298;
-import java.util.*;
-public class Test {
- boolean m(){
- return /*[*/a().length != 3/*]*/;
- }
- int[] a(){
- return null;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0299/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0299/Test.java
deleted file mode 100644
index 9b02a0c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0299/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0299;
-
-public class Test {
- int i = (/**/2/**/);
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0300/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0300/Test.java
deleted file mode 100644
index 53bba47..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0300/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0300;
-
-public class Test {
- boolean b = /**/true/**/;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0301/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0301/Test.java
deleted file mode 100644
index dbadd4b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0301/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0301;
-
-public class Test {
- Object o = /**/null/**/;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0302/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0302/Test.java
deleted file mode 100644
index 63195d5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0302/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0302;
-import java.util.*;
-public class Test {
- public void foo() {
- /*]*/do
- foo();
- while(1 < 10);/*[*/
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0303/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0303/Test.java
deleted file mode 100644
index 4b656d6..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0303/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0303;
-import java.util.*;
-public class Test {
- void foo() {
- char x;
- x = (char)3;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0304/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0304/Test.java
deleted file mode 100644
index 10665f3..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0304/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0304;
-
-interface Test {
- public void foo(int arg);
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0307/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0307/Test.java
deleted file mode 100644
index 9e8e7d9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0307/Test.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package test0307;
-
-import java.net.MalformedURLException;
-
-public class Test {
- static class A {
- public A(int i) throws MalformedURLException {
- }
- }
-
- static class B extends A {
- public B() throws MalformedURLException {
- super(10);
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0308/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0308/Test.java
deleted file mode 100644
index 6c40cfa..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0308/Test.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package test0308;
-
-import java.net.MalformedURLException;
-
-public class Test {
- static class A {
- public A(int i) throws MalformedURLException {
- }
- }
-
- static class B extends A {
- public B() {
- super(10);
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0309/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0309/Test.java
deleted file mode 100644
index 2a7ba82..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0309/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0309;
-
-public class Test {
- void f(int y){
- int i= (y==7) ? 1 : 2 ;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0310/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0310/Test.java
deleted file mode 100644
index 6c9894e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0310/Test.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package test0310;
-
-class Test {
- private static final String G = I.GR;
-
- public static void c(){
- Object cp = null;
- }
-}
-
-interface I {
- String GR= "l";
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0311/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0311/Test.java
deleted file mode 100644
index e039de2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0311/Test.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package test0311;
-
-public class Test {
- void m(){
- final int j= 0;
- Test a= new Test(){
- void m(int j){
- int u= j;
- }
- };
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0312/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0312/Test.java
deleted file mode 100644
index e070720..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0312/Test.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package test0312;
-
-public class Test {
- void m(){
- final int j= 0;
- A a= new A(){
- void m(int j){
- int u= j;
- }
- };
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0313/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0313/Test.java
deleted file mode 100644
index f40e98b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0313/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0313;
-
-public class Test {
- void m(int i, int j){
- int u= i+j;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0314/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0314/Test.java
deleted file mode 100644
index b83330f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0314/Test.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package test0314;
-public class Test {
-public static void main(String args[]) { int x= 3;}}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0315/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0315/Test.java
deleted file mode 100644
index 0f2d077..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0315/Test.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package test0315;
-public class Test {
- boolean foo() {
- return "abc" instanceof java.io.Serializable;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0317/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0317/Test.java
deleted file mode 100644
index 1efa1dd..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0317/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0317;
-
-import java.util.Vector;
-
-public class Test {
- public boolean foo(Object x) {
- return x instanceof Vector;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0318/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0318/Test.java
deleted file mode 100644
index 74cb5f5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0318/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0318;
-
-public class Test {
- static void ___run(java.lang.String[] args) throws Throwable {
- private int x;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0319/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0319/Test.java
deleted file mode 100644
index 92d549e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0319/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0319;
-
-public class Test {
- static void ___run(java.lang.String[] args) throws Throwable {
- java.lang.Object[] obj= new Object[10];
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0320/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0320/Test.java
deleted file mode 100644
index 1792e33..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0320/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0320;
-
-public class Test {
- static void ___run(java.lang.String[] args) throws Throwable {
- int[] tab = new int[10];
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0321/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0321/Test.java
deleted file mode 100644
index d5a8830..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0321/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0321;
-
-public class Test {
- static void ___run(java.lang.String[] args) throws Throwable {
- java.lang.Object[][] obj= new Object[10][0];
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0322/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0322/Test.java
deleted file mode 100644
index 3c8dc79..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0322/Test.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package test0322;
-
-public class Test {
- Object fField= null;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0323/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0323/Test.java
deleted file mode 100644
index d4e2c5b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0323/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0323;
-
-public class Test {
- void foo() {
- String x;
- x = (java.lang.Object) "s";
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0324/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0324/Test.java
deleted file mode 100644
index 6f73e57..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0324/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0324;
-
-public class Test {
- void foo() {
- Object x;
- x = (java.lang.Object[]) null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0325/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0325/Test.java
deleted file mode 100644
index 30fb377..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0325/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0325;
-
-public class Test {
- void foo() {
- Object x;
- x = (int[]) null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0326/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0326/A.java
deleted file mode 100644
index 4df7ab0..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0326/A.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0326;
-
-public class A {
- A f;
- public A a() {
- a().f= a();
- return null;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0327/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0327/Test.java
deleted file mode 100644
index 24fe09a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0327/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0327;
-
-import java.util.Vector;
-
-public class Test {
- public static void goo(Object o) {
- Vector s= (String) ooo;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0328/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0328/Test.java
deleted file mode 100644
index 3d9b203..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0328/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0328;
-
-public class Test {
- static void ___run(java.lang.String[] args) throws Throwable {
- java.lang.Object[] obj= new Object[] {null, new Object()};
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0329/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0329/Test.java
deleted file mode 100644
index b558a28..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0329/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0329;
-
-public class Test {
- static void ___run(java.lang.String[] args) throws Throwable {
- java.lang.Object[] obj= new Object[] {};
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0330/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0330/Test.java
deleted file mode 100644
index f084196..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0330/Test.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package test0330;
-
-public class Test {
- public foo() {
- return 0;
- }
-}
-
-class A {
- void bar() {
- new Test().foo();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0331/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0331/Test.java
deleted file mode 100644
index 3114c30..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0331/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0331;
-
-public class Test {
- public static void main(String[] args) {
- int i = args.length;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0332/LocalSelectionTransfer.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0332/LocalSelectionTransfer.java
deleted file mode 100644
index 2847c24..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0332/LocalSelectionTransfer.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package test0332;
-
-import org.eclipse.swt.dnd.ByteArrayTransfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jdt.internal.ui.JavaUIMessages;
-
-public class LocalSelectionTransfer extends ByteArrayTransfer {
-
- // First attempt to create a UUID for the type name to make sure that
- // different Eclipse applications use different "types" of
- // <code>LocalSelectionTransfer</code>
- private static final String TYPE_NAME= "local-selection-transfer-format" + (new Long(System.currentTimeMillis())).toString(); //$NON-NLS-1$;
- private static final int TYPEID= registerType(TYPE_NAME);
-
- private static final LocalSelectionTransfer INSTANCE= new LocalSelectionTransfer();
-
- private ISelection fSelection;
- private int fTime;
-
- private LocalSelectionTransfer() {
- }
-
- /**
- * Returns the singleton.
- */
- public static LocalSelectionTransfer getInstance() {
- return INSTANCE;
- }
-
- /**
- * Sets the transfer data for local use.
- */
- public void setSelection(ISelection s) {
- fSelection= s;
- }
-
- /**
- * Returns the local transfer data.
- */
- public ISelection getSelection() {
- return fSelection;
- }
-
- public void javaToNative(Object object, TransferData transferData) {
- byte[] check= TYPE_NAME.getBytes();
- super.javaToNative(check, transferData);
- }
-
- public Object nativeToJava(TransferData transferData) {
- Object result= super.nativeToJava(transferData);
- if (isInvalidNativeType(result)) {
- JavaPlugin.logErrorMessage(JavaUIMessages.getString("LocalSelectionTransfer.errorMessage")); //$NON-NLS-1$
- }
- return fSelection;
- }
-
- private boolean isInvalidNativeType(Object result) {
- return !(result instanceof byte[]) || !TYPE_NAME.equals(new String((byte[])result));
- }
-
- /**
- * The type id used to identify this transfer.
- */
- protected int[] getTypeIds() {
- return new int[] {TYPEID};
- }
-
- protected String[] getTypeNames(){
- return new String[] {TYPE_NAME};
- }
-
- public int getTime() {
- return fTime;
- }
-
- public void setTime(int time) {
- fTime= time;
- }
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0333/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0333/Test.java
deleted file mode 100644
index a2a9032..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0333/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0333;
-
-public class Test {
- static void ___run(java.lang.String[] args) throws Throwable {
- java.lang.Object[][] obj= new Object[10][];
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0334/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0334/Test.java
deleted file mode 100644
index 92e6861..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0334/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0334;
-
-public class Test {
- static void ___run(java.lang.String[] args) throws Throwable {
- java.lang.Object[][][] obj= new Object[10][][];
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0335/ExceptionTestCaseTest.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0335/ExceptionTestCaseTest.java
deleted file mode 100644
index 825858e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0335/ExceptionTestCaseTest.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0335;
-
-public class ExceptionTestCaseTest extends junit.framework.TestCase {
-
- public ExceptionTestCaseTest(String s) {
- super(s);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0336/SorterTest.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0336/SorterTest.java
deleted file mode 100644
index 498bdc9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0336/SorterTest.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package test0336;
-
-import junit.runner.Sorter;
-import java.util.Vector;
-
-public class SorterTest {
- static class Swapper implements Sorter.Swapper {
- public void swap(Vector values, int left, int right) {
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0337/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0337/Test.java
deleted file mode 100644
index 827f7ac..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0337/Test.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0337;
-
-public class Test {
- String message= Test.m("s", new String[]{"g"});
-
- static String m(String g, String[] s){
- return null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0338/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0338/Test.java
deleted file mode 100644
index 53227c5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0338/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0338;
-
-import java.io.IOException;
-
-public class Test {
- public void foo() throws IOException {
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0339/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0339/Test.java
deleted file mode 100644
index efe8c40..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0339/Test.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package test0339;
-
-public class Test {
- public static interface X {
- int doQuery(boolean x);
- }
-
- public void setX(boolean x) {
- {
- z
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0341/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0341/A.java
deleted file mode 100644
index f5b9806..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0341/A.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package test0341;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.util.Vector;
-
-public class A {
-
- private Vector field;
-
- public void l()
- throws
- IOException,
- MalformedURLException,
- InterruptedIOException,
- UnsupportedEncodingException {
- if (field != null) {
- throw new IOException();
- } else if (field == null) {
- throw new MalformedURLException();
- } else if (field == null) {
- throw new InterruptedIOException();
- } else {
- throw new UnsupportedEncodingException();
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0342/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0342/Test.java
deleted file mode 100644
index 6d9a354..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0342/Test.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package test0342;
-
-public class Test {
-
- public int junk1(int i) {
- return 0;
- }
-
- public long junk2() {
- return 0;
- }
-
- public Object junk3() {
- return null;
- }
-
- Test(int i) {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0343/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0343/Test.java
deleted file mode 100644
index 82db57d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0343/Test.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package test0343;
-
-public class Test {
-
- public volatile boolean flag;
-
- public void foo() {
- int i= 5;
- /*]*/if (flag)
- i= 10;/*[*/
- i--;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0344/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0344/Test.java
deleted file mode 100644
index b099362..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0344/Test.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package test0344;
-
-public class Test {
-
- public void bugTest() {
- System.out.println("bla");
- System.out.println("blubb");
- }
-
- private void containsAssert() {
- assert true;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0345/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0345/A.java
deleted file mode 100644
index 8c869d7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0345/A.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package test0345;
-
-public class A {
- Bar.B[] field= new Bar.B[]{
- new Bar.B()
- };
- void f(){
- int temp;
- }
-}
-
-class Bar{
- static class B{}
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0346/Test2.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0346/Test2.java
deleted file mode 100644
index 33c8e40..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0346/Test2.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0346;
-
-import java.util.Vector;
-
-public class Test2 {
- public static void main(String[] arguments) {
- Vector editors[]= null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0347/Test2.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0347/Test2.java
deleted file mode 100644
index 7a77389..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0347/Test2.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0347;
-
-import java.util.Vector;
-
-public class Test2 {
- public static void main(String[] arguments) {
- Vector[] editors[]= null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0348/Test2.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0348/Test2.java
deleted file mode 100644
index 0afb916..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0348/Test2.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0348;
-
-import java.util.Vector;
-
-public class Test2 {
- public static void main(String[] arguments) {
- Vector[][] editors[]= null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0349/Test2.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0349/Test2.java
deleted file mode 100644
index 0a5a715..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0349/Test2.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0349;
-
-import java.util.Vector;
-
-public class Test2 {
- Vector[][] editors[]= null;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0350/Test2.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0350/Test2.java
deleted file mode 100644
index a38d20f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0350/Test2.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0350;
-
-import java.util.Vector;
-
-public class Test2 {
- Vector editors[]= null;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0351/Test2.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0351/Test2.java
deleted file mode 100644
index bdcdd53..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0351/Test2.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package test0351;
-
-public class Test2 {
- void m1(int a, int[] b){}
- void m(int a, int b[]){}
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0352/Test2.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0352/Test2.java
deleted file mode 100644
index bd69890..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0352/Test2.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package test0352;
-
-public class Test2 {
- void m1(final int a, final int[] b){}
- void m(final int a, final int b[]){}
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0353/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0353/Test.java
deleted file mode 100644
index 98be0c1..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0353/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0353;
-
-import java.io.InputStream;
-
-public class Test {
- void foo() {
- InputStream i = null;
- while (true);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0354/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0354/Test.java
deleted file mode 100644
index c0cea6a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0354/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-public class Test {
-
- protected void primExecute() {
- this.toString();
- }
-
- if (image != null) {
- Object loc = null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0355/Foo.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0355/Foo.java
deleted file mode 100644
index d3be497..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0355/Foo.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0355;
-
-public class Foo {
- public Object bar() {
- if ( ((Object)null).toString() == null ) {
- return (Object)null;
- }
- return null;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0356/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0356/A.java
deleted file mode 100644
index 07e05a2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0356/A.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0356;
-
-public class A {
-
-}
-
-class ActionFactory {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0356/X.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0356/X.java
deleted file mode 100644
index 50363bd..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0356/X.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0356;
-
-public class X {
- public void foo() {
- ActionFactory af=new MyActionFactory();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0357/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0357/A.java
deleted file mode 100644
index 57410b5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0357/A.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package test0357;
-class A{
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0358/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0358/A.java
deleted file mode 100644
index 76e0803..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0358/A.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package test0358;
-
-class A {
- public void mdd(int y){
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0359/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0359/A.java
deleted file mode 100644
index f1800c1..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0359/A.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package test0359;
-
-class A {
- public void mdd(int y) throws Exception{
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0360/X.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0360/X.java
deleted file mode 100644
index 8202064..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0360/X.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0360;
-
-public class X {
- public void foo() {
- for (int i=0, j=0, k=0; i<10 ; i++,j++,k++) {
- System.out.println("L");
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0361/X.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0361/X.java
deleted file mode 100644
index 171ae69..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0361/X.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0361;
-
-public class X {
- public void foo() {
- for (int i=0; i<10 ; i++) {
- System.out.println("L");
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0362/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0362/Test.java
deleted file mode 100644
index eb1a242..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0362/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0362;
-/* Regression test for bug 21916 */
-public class Test {
- public void foo(int i) {
- for (int i=0, j=0, k=0; i<10 ; i++, j++, k++) {}
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0363/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0363/A.java
deleted file mode 100644
index 8d13a1d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0363/A.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0363;
-/* Regression test for bug 22939 */
-public class A {
- void f(){
- String xxxx= "xx";
- String y= ( xxxx );
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0364/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0364/A.java
deleted file mode 100644
index 4577f24..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0364/A.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0364;
-/* Regression test for bug 11529 */
-public class A {
- void theMethod() {
- int local;
-/* for (int i = 0; i < 5; ++i) {
- }*/
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0365/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0365/A.java
deleted file mode 100644
index f5da97d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0365/A.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0365
-;
-/* Regression test for bug 11529 */
-public class A {
- void theMethod() {
- for (int i = 0; i < 5; ++i) {
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0366/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0366/A.java
deleted file mode 100644
index b4bf025..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0366/A.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0366;
-
-/* Regression test for bug 23048 */
-
-public class A {
- void theMethod() {
- for (int i = 0; i < 5; ++i);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0367/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0367/A.java
deleted file mode 100644
index 34be725..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0367/A.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0367;
-
-/* Regression test for bug 23048 */
-
-public class A {
- void theMethod(int i) {
- while(i == 2);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0368/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0368/A.java
deleted file mode 100644
index 1cfc21d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0368/A.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0368;
-
-/* Regression test for bug 23048 */
-
-public class A {
- void foo() {
- test:;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0369/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0369/A.java
deleted file mode 100644
index 0e6a417..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0369/A.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0369;
-
-/* Regression test for bug 23048 */
-
-public class A {
- void foo() {
- test:\u003B
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0370/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0370/Test.java
deleted file mode 100644
index c75b1fb..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0370/Test.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0370;
-
-public class Test {
- public void foo() {
- do ; while(true);
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0371/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0371/A.java
deleted file mode 100644
index 7b31660..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0371/A.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0371;
-
-/* Regression test for bug 23048 */
-
-public class A {
- void foo(int i) {
- if (i == 6);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0372/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0372/A.java
deleted file mode 100644
index 19736a9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0372/A.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package test0372;
-
-/* Regression test for bug 23048 */
-
-public class A {
- void foo(int i) {
- if (i == 6) {} else ;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0373/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0373/A.java
deleted file mode 100644
index cc9aaf9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0373/A.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package test0373;
-
-/* Regression test for bug 23118 */
-
-public class A {
- void foo() {
- for (int i = 0; i < 10; i++) {
- break;
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0374/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0374/A.java
deleted file mode 100644
index 072393c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0374/A.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package test0374;
-
-/* Regression test for bug 23118 */
-
-public class A {
- void foo() {
- for (int i = 0; i < 10; i++) {
- continue;
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0375/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0375/A.java
deleted file mode 100644
index 521300d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0375/A.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0375;
-
-import test0375.A.*;
-
-/* Regression test for bug 23052 */
-
-public class A {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0376/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0376/A.java
deleted file mode 100644
index 1a8aeb5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0376/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0376;
-
-class A {
- void f() {
- A a = ( A ) this;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0377/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0377/A.java
deleted file mode 100644
index f33de36..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0377/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0377;
-
-class A {
- void f() {
- final int i;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0378/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0378/A.java
deleted file mode 100644
index 172d316..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0378/A.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0378;
-
-public class A {
- public static class B {
- public void foo() {
- }
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0379/Test.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0379/Test.java
deleted file mode 100644
index 61c397d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0379/Test.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0005;
-import java.util.*;
-public class Test {
- public static void main(String[] args) {
- System.out.println(new Object() {});
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0380/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0380/A.java
deleted file mode 100644
index 23a832b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0380/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0380;
-
-public class A {
- public String toString() {
- return super.toString();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0381/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0381/A.java
deleted file mode 100644
index 32cad02..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0381/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0381;
-
-public class A {
- /** Method theMethod.*/
- void theMethod() {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0382/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0382/A.java
deleted file mode 100644
index b62f395..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0382/A.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package test0382;
-
-public class A {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0383/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0383/A.java
deleted file mode 100644
index 3e2b834..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0383/A.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0383;
-
-public class A {
- public static class B {
- public void foo() {
- }
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0384/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0384/A.java
deleted file mode 100644
index 8cfde5e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0384/A.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0384;
-
-public class A {
- public static class B {
- public class D {
- }
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0385/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0385/A.java
deleted file mode 100644
index e76572a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0385/A.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0385;
-
-public class A {
-
- int getClass() {
- return 0;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0386/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0386/A.java
deleted file mode 100644
index e16ef2f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0386/A.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package test0386;
-
-public class A {
-
- void foo(int i) {
- switch(i) {
- case 1:
- System.out.println();
- break;
- default :
- return;
- }
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0387/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0387/A.java
deleted file mode 100644
index 88c205c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0387/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0387;
-
-class A {
- void f() {
- A a = (\u0020A\u0020) this;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0388/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0388/A.java
deleted file mode 100644
index 0572d3c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0388/A.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package test0388;
-
-class A {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0389/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0389/A.java
deleted file mode 100644
index 5ed8eb9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0389/A.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package test0389;
-
-class A {
- class B {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0390/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0390/A.java
deleted file mode 100644
index 0773346..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0390/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0390;
-
-class A {
- int foo() {
- return 0;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0391/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0391/A.java
deleted file mode 100644
index 1a8f5d8..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0391/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0391;
-
-class A {
- int[] foo() {
- return null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0392/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0392/A.java
deleted file mode 100644
index 7590cb1..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0392/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0392;
-
-class A {
- String[] foo() {
- return null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0393/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0393/A.java
deleted file mode 100644
index 833f0ee..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0393/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0393;
-
-class A {
- String foo()[] {
- return null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0394/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0394/A.java
deleted file mode 100644
index 5209c7c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0394/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0394;
-
-class A {
- String foo() {
- return null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0395/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0395/A.java
deleted file mode 100644
index 7ac5525..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0395/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0395;
-
-class A {
- String[] foo()[] {
- return null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0396/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0396/A.java
deleted file mode 100644
index f414ff5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0396/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0396;
-
-public class A {
- public void foo(final String s[]) {
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0397/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0397/A.java
deleted file mode 100644
index ad05b6b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0397/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0397;
-
-public class A {
- public void foo(final String[] \u0073\u005B][]) {
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0398/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0398/A.java
deleted file mode 100644
index 07c565a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0398/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0397;
-
-public class A {
- public void foo() {
- int i= (1 + 2) * 3;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0399/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0399/A.java
deleted file mode 100644
index 5210904..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0399/A.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package test0399;
-
-public class A {
- public A() {
- int i;
- int k;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0400/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0400/A.java
deleted file mode 100644
index d1a5a6c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0400/A.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package test0400;
-
-public class A {
- public A() {
- super();
- int i;
- int k;
-
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0401/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0401/A.java
deleted file mode 100644
index 36a193a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0401/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package test0401;
-
-public class A {
- correctThis() {
- return 1;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0402/A.java b/org.eclipse.jdt.core.tests.model/workspace/Converter/test0402/A.java
deleted file mode 100644
index 09395cc..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Converter/test0402/A.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package test0402;
-
-class A{
- class Inner{
- Inner(){
- }
- }
-}
-
-class I2 extends A.Inner{
- I2(){
- new A().super();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectSrcTests/.classpath b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectSrcTests/.classpath
deleted file mode 100644
index 49cabdd..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectSrcTests/.classpath
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="var" path="JCL_LIB" sourcepath="JCL_SRC" rootpath="JCL_SRCROOT"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectSrcTests/.project b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectSrcTests/.project
deleted file mode 100644
index c05ce73..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectSrcTests/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.core</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectSrcTests/src/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectSrcTests/src/A.java
deleted file mode 100644
index b987fb2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectSrcTests/src/A.java
+++ /dev/null
@@ -1,5 +0,0 @@
-public class A {
-
- public void foo(){
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/.classpath b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/.classpath
deleted file mode 100644
index 068e118..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path=""/>
- <classpathentry kind="var" path="JCL_LIB" sourcepath="JCL_SRC" rootpath="JCL_SRCROOT"/>
- <classpathentry kind="lib" path="lib.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/.project b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/.project
deleted file mode 100644
index c05ce73..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.core</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/B.java b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/B.java
deleted file mode 100644
index ebbe4dc..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/B.java
+++ /dev/null
@@ -1,2 +0,0 @@
-public class B {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/bin/dummy b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/bin/dummy
deleted file mode 100644
index e69de29..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/bin/dummy
+++ /dev/null
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/lib.jar b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/lib.jar
deleted file mode 100644
index e2aadfd..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/lib.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/p/Y.class b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/p/Y.class
deleted file mode 100644
index 8408385..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/p/Y.class
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/q/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/q/A.java
deleted file mode 100644
index b987fb2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/q/A.java
+++ /dev/null
@@ -1,5 +0,0 @@
-public class A {
-
- public void foo(){
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/q/readme.txt b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/q/readme.txt
deleted file mode 100644
index e69de29..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/q/readme.txt
+++ /dev/null
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/x/readme.txt b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/x/readme.txt
deleted file mode 100644
index e69de29..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/x/readme.txt
+++ /dev/null
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/x/readme2.txt b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/x/readme2.txt
deleted file mode 100644
index e69de29..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/x/readme2.txt
+++ /dev/null
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/x/y/Main.java b/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/x/y/Main.java
deleted file mode 100644
index 7159036..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaProjectTests/x/y/Main.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package x.y;
-
-import java.io.Serializable;
-/**
- * A class that uses the minimal library.
- */
-public class Main {
- public static void main(String[] args) {
- new Main().toString();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/.classpath b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/.classpath
deleted file mode 100644
index f85acd9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="lib" path="AbortCompilation.jar"/>
- <classpathentry kind="var" path="JCL_LIB" sourcepath="JCL_SRC" rootpath="JCL_SRCROOT"/>
- <classpathentry kind="lib" path="MyJar.jar"/>
- <classpathentry kind="lib" path="test20631.jar" sourcepath="/JavaSearch/test20631.zip" rootpath=""/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/.project b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/.project
deleted file mode 100644
index c05ce73..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.core</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/AbortCompilation.jar b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/AbortCompilation.jar
deleted file mode 100644
index 2d827f8..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/AbortCompilation.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/MyJar.jar b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/MyJar.jar
deleted file mode 100644
index 9b07c50..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/MyJar.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/NotInClasspath/p/Y.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/NotInClasspath/p/Y.java
deleted file mode 100644
index 0823bc4..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/NotInClasspath/p/Y.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package p;
-public class Y extends X {
- public Y() {
- }
- public Y(int i) {
- super(i);
- }
- public Y(boolean b) {
- super(1);
- }
- public static void bar() {
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/A.java
deleted file mode 100644
index 42c079c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/A.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Test case for 1GKZ8VZ: ITPJCORE:WINNT - Search - did not find references to member constructor */
-public class A {
- public class Inner {
- public Inner(int i) {
- }
- }
- Inner[] field = new Inner[] {new Inner(1), new Inner(2)};
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/B.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/B.java
deleted file mode 100644
index eeb6cda..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/B.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/* Test case for PR 1GKEG73: ITPJCORE:WIN2000 - search (136): missing field declaration */
-public class B {
- private Object[] open;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/CA.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/CA.java
deleted file mode 100644
index 2f88187..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/CA.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Test case for 1GIIBC3: ITPJCORE:WINNT - search for method references - missing matches */
-public class CA {
- class CB {
- void f() {
- m();
- }
- class CC {
- void f() {
- m();
- }
- }
- }
- void m() {
- System.out.println("a");
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/D.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/D.java
deleted file mode 100644
index 5ee43fe..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/D.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Regression test for 1GL12XE: ITPJCORE:WIN2000 - search: missing field references in inner class */
-public class D {
- int h;
- void g() {
- new Object() {
- public void run() {
- int y = 0;
- h = y;
- }
- };
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/E.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/E.java
deleted file mode 100644
index 27506f2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/E.java
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Test case for 1GHDA2V: ITPJCORE:WINNT - ClassCastException when doing a search */
-public class E {
- public Object foo() {
- int[] result = new int[0];
- return result.clone();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/InterfaceImplementors.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/InterfaceImplementors.java
deleted file mode 100644
index 70be9c3..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/InterfaceImplementors.java
+++ /dev/null
@@ -1,5 +0,0 @@
-public class InterfaceImplementors extends I implements p.I {
-}
-
-class I {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/MemberTypeReference/Azz.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/MemberTypeReference/Azz.java
deleted file mode 100644
index 2c79e85..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/MemberTypeReference/Azz.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package MemberTypeReference;
-public class Azz extends B {
- class AzzMember extends BMember {
- class BMember{
- }
- }
- static int fHello;
- void poo() {
- B.BMember someVar;
- super.poo();
- fHello= 9;
- }
-}
-
-class BMember extends B {}
-
-class X {
- Azz.AzzMember.BMember val;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/MemberTypeReference/B.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/MemberTypeReference/B.java
deleted file mode 100644
index cda9a67..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/MemberTypeReference/B.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package MemberTypeReference;
-public class B {
- protected class BMember{}
-
- void foo() {
- Azz.fHello= 1;
- Object someVar = null;
- Object o = (Azz.AzzMember.BMember) someVar;
- }
- void poo() {}
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/NoReference/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/NoReference/A.java
deleted file mode 100644
index b110454..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/NoReference/A.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package NoReference;
-public class A {
- // This class should not be referenced
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/O.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/O.java
deleted file mode 100644
index a6a8e02..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/O.java
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Regression test for 1GL11J6: ITPJCORE:WIN2000 - search: missing field references (nested types) */
-public class O {
- int y;
- class I {
- void y() {
- y = 0;
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/ObjectMemberTypeReference/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/ObjectMemberTypeReference/A.java
deleted file mode 100644
index a0d232b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/ObjectMemberTypeReference/A.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package ObjectMemberTypeReference;
-public class A {
- class Object {
- }
- public void foo() {
- new Object();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PR_1GGNOTF.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PR_1GGNOTF.java
deleted file mode 100644
index 95bd4bd..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PR_1GGNOTF.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Test case for PR 1GGNOTF: ITPJCORE:WINNT - Search doesn't find method referenced in anonymous inner class */
-public class PR_1GGNOTF {
- void method() {
- }
- void method2() {
- Runnable r = new Runnable() {
- public void run() {
- method();
- }
- };
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/A.java
deleted file mode 100644
index 88d389e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/A.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package PackageReference;
-import p3.p2.p.*;
-public class A {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/B.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/B.java
deleted file mode 100644
index d8a7d28..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/B.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package PackageReference;
-import p3.p2.p.X;
-public class B extends X {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/C.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/C.java
deleted file mode 100644
index bcb90e7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/C.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package PackageReference;
-public class C extends p3.p2.p.X {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/D.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/D.java
deleted file mode 100644
index 2b35d56..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/D.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package PackageReference;
-public class D {
- p3.p2.p.X x;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/E.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/E.java
deleted file mode 100644
index e3decc0..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/E.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package PackageReference;
-public class E {
- Object x = new p3.p2.p.X();
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/F.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/F.java
deleted file mode 100644
index f776133..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/F.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package PackageReference;
-public class F {
- p3.p2.p.X foo() {
- return null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/G.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/G.java
deleted file mode 100644
index e255a62..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/G.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package PackageReference;
-public class G {
- void foo(p3.p2.p.X x) {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/H.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/H.java
deleted file mode 100644
index bfc0a74..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/H.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package PackageReference;
-public class H {
- void foo() {
- p3.p2.p.X x;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/I.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/I.java
deleted file mode 100644
index 3515f2c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/I.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package PackageReference;
-public class I {
- void foo() {
- Object x = new p3.p2.p.X();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/J.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/J.java
deleted file mode 100644
index 6c9d539..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/J.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package PackageReference;
-public class J {
- void foo() {
- int i = p3.p2.p.X.count;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/K.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/K.java
deleted file mode 100644
index 0e0c147..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/K.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package PackageReference;
-import p3.p2.*;
-public class K {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceA.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceA.java
deleted file mode 100644
index e6ef802..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceA.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package PackageReference;
-import p3.*;
-public class NoReferenceA {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceB.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceB.java
deleted file mode 100644
index 479cb5e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceB.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package PackageReference;
-import p3.X;
-public class NoReferenceB extends X {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceC.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceC.java
deleted file mode 100644
index 6a82bdd..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceC.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package PackageReference;
-public class NoReferenceC extends p3.X {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceD.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceD.java
deleted file mode 100644
index 30d5801..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceD.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package PackageReference;
-public class NoReferenceD {
- p3.X x;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceE.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceE.java
deleted file mode 100644
index 3f252ca..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceE.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package PackageReference;
-public class NoReferenceE {
- Object x = new p3.X();
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceF.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceF.java
deleted file mode 100644
index b7007f4..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceF.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package PackageReference;
-public class NoReferenceF {
- p3.X foo() {
- return null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceG.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceG.java
deleted file mode 100644
index 70a99ef..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceG.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package PackageReference;
-public class NoReferenceG {
- void foo(p3.X x) {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceH.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceH.java
deleted file mode 100644
index 6ca1c57..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceH.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package PackageReference;
-public class NoReferenceH {
- void foo() {
- p3.X x;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceI.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceI.java
deleted file mode 100644
index 3b6d5dd..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceI.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package PackageReference;
-public class NoReferenceI {
- void foo() {
- Object x = new p3.X();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceJ.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceJ.java
deleted file mode 100644
index c28e9cf..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/PackageReference/NoReferenceJ.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package PackageReference;
-public class NoReferenceJ {
- void foo() {
- int i = p3.X.count;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/Test.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/Test.java
deleted file mode 100644
index 9aa1333..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/Test.java
+++ /dev/null
@@ -1,22 +0,0 @@
-public class Test {
-
-static {
- Test var = new Test();
-}
-
-{
- Test t = null;
-}
-
-public static void main(String[] args) {
- p.Y y = new p.Y();
- y.foo(1, "a", y);
- y.bar();
-
- p.Z z = new p.Z();
- z.foo(1, "a", z);
-
- p.A a = new p.A(y);
- a.foo(1, "a", a.x);
-}
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/TypeReferenceAsSingleNameReference.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/TypeReferenceAsSingleNameReference.java
deleted file mode 100644
index 4d517ad..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/TypeReferenceAsSingleNameReference.java
+++ /dev/null
@@ -1,12 +0,0 @@
-public class TypeReferenceAsSingleNameReference {
-
-void hasReference() {
- TypeReferenceAsSingleNameReference x = null;
-}
-
-void hasNoReference() {
- Object TypeReferenceAsSingleNameReference = null;
- TypeReferenceAsSingleNameReference = new Object();
-}
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/TypeReferenceInArray/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/TypeReferenceInArray/A.java
deleted file mode 100644
index 198612a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/TypeReferenceInArray/A.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package TypeReferenceInArray;
-public class A {
- A[] a;
- TypeReferenceInArray.A[] b;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/TypeReferenceInImport/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/TypeReferenceInImport/X.java
deleted file mode 100644
index a6602a6..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/TypeReferenceInImport/X.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package TypeReferenceInImport;
-import p.Y;
-import p2.Z;
-public class X {
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/A.java
deleted file mode 100644
index f190793..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/A.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package VariousTypeReferences;
-public class A {
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/B.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/B.java
deleted file mode 100644
index 0fb10b9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/B.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package VariousTypeReferences;
-public class B {
- void foo(A a) {
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/C.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/C.java
deleted file mode 100644
index cc9c5fb..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/C.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package VariousTypeReferences;
-public class C {
- A foo() {
- return null;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/D.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/D.java
deleted file mode 100644
index c40bc3f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/VariousTypeReferences/D.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package VariousTypeReferences;
-public class D {
- A foo;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/W.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/W.java
deleted file mode 100644
index efb90d3..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/W.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Regression test for 1GL9UMH: ITPJCORE:WIN2000 - search: missing type occurrences */
-public class W {
- static int length = 17;
- int m() {
- int[] R = new int[1];
- return W.length; /*1*/
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/X.java
deleted file mode 100644
index fe4e580..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/X.java
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Test case for PR 1GK7K17: ITPJCORE:WIN2000 - search: missing type reference */
-public class X{
- static void s(){};
-}
-class AA{
- AA(){
- X.s(); //<<
- };
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a/A.java
deleted file mode 100644
index 126f06d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a/A.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package a;
-/* Test case for 1GL0MN9: ITPJCORE:WIN2000 - search: not consistent results for nested types */
-public class A {
- class X {
- }
-
-};
-class S extends A {
-}
-class B {
- A.X ax; /*1*/
- S.X sx; /*2*/
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a2/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a2/X.java
deleted file mode 100644
index b52adb7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a2/X.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package a2;
-/* Test case for bug 5923 Search for "length" field refs finds [].length */
-public class X {
- int length = 1;
- public void foo() {
- int[] array = new int[length];
- for (int i = 0, length = array.length; i < length; i++) {
- }
- }
-}
-
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/References.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/References.java
deleted file mode 100644
index be9c4ba..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/References.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package a3;
-import a3.b.B;
-public class References {
- public void foo() {
- X x1 = new Z(); // single type references
- a3.b.A a = null; // qualified type reference
- a3.b.A.B.C inner = null; // qualified type references with inner type
- Object o = a3.Y.field; // binary reference + qualified name reference
- X x2 = (B)x1; // single name reference
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/X.java
deleted file mode 100644
index bfb9b88..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/X.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package a3;
-public class X {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/Y.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/Y.java
deleted file mode 100644
index 4d03dac..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/Y.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package a3;
-public class Y extends X {
- public static Object field = null;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/Z.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/Z.java
deleted file mode 100644
index 2e75950..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/Z.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package a3;
-public class Z extends Y {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/b/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/b/A.java
deleted file mode 100644
index cf16215..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/b/A.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package a3.b;
-public class A {
- public class B {
- public class C {
- }
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/b/B.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/b/B.java
deleted file mode 100644
index 4c4422e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a3/b/B.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package a3.b;
-public class B extends a3.X {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a4/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a4/X.java
deleted file mode 100644
index b71e890..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a4/X.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package a4;
-/* Test case for bug 6158 Search - Prefix and postfix expression not found as write reference */
-public class X {
- int field;
- void foo() {
- field++;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a5/B.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a5/B.java
deleted file mode 100644
index d28748b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a5/B.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package a5;
-/* Test case for bug 6538 searchDeclarationsOf* incorrect */
-
-class A{
- int i(){
- return 0;
- }
-}
-
-class B {
- int f;
- void i(){
- y();
- Object l= new byte[f];
- }
- private void y(){
- }
-
-}
-
-class C extends A{
- public int i(){
- return 0;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a6/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a6/A.java
deleted file mode 100644
index 35291c0..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a6/A.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package a6;
-
-class A {
-}
-
-class B extends A {
- private int f;
- private class P{}
- private void a(){}
- void m() {
- f++;
- P p= new P();
- a();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a7/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a7/X.java
deleted file mode 100644
index 5a8dbb4..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a7/X.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package a7;
-/* Test case for bug 6779 searchDeclarationsOfReferencedTyped - missing exception types */
-public class X {
- public void foo() throws MyException {
- }
-}
-class MyException extends Exception {
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a8/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a8/A.java
deleted file mode 100644
index 4eb5f03..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a8/A.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package a8;
-/* Test case for bug 7344 Search - write acces give wrong result */
-public class A {
- public A a;
- public int i;
- public void foo(){
- a.i = 25;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a9/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a9/A.java
deleted file mode 100644
index 4be44ae..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/a9/A.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package a9;
-class B{
- private void m(){
- }
-}
-class A extends B{
- void m(){
- }
-}
-class C extends A{
- void m(){
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b1/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b1/A.java
deleted file mode 100644
index ad331c6..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b1/A.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package b1;
-/* Test case for bug 7987 Field reference search should do lookup in 1.4 mode */
-public class A {
- int x;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b1/B.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b1/B.java
deleted file mode 100644
index 5db6138..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b1/B.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package b1;
-/* Test case for bug 7987 Field reference search should do lookup in 1.4 mode */
-public class B extends A {
- void foo() {
- this.x++;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b2/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b2/X.java
deleted file mode 100644
index 430b923..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b2/X.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package b2;
-/* Test case for bug 8928 Unable to find references or declarations of methods that use static inner classes in the signature */
-public class X {
- public static class Inner {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b2/Y.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b2/Y.java
deleted file mode 100644
index bb6dade..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b2/Y.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package b2;
-/* Test case for bug 8928 Unable to find references or declarations of methods that use static inner classes in the signature */
-public class Y {
- public void foo(X.Inner inner) {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b2/Z.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b2/Z.java
deleted file mode 100644
index 4587f12..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b2/Z.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package b2;
-/* Test case for bug 8928 Unable to find references or declarations of methods that use static inner classes in the signature */
-public class Z {
- void bar() {
- X.Inner inner = new X.Inner();
- new Y().foo(inner);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b3/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b3/X.java
deleted file mode 100644
index b432f6c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b3/X.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package b3;
-/* Test case for bug 9041 search: cannot create a sub-cu scope */
-public class X {
- Object field = new X();
- Object foo() {
- return new X();
- }
- class Y {
- Object field2 = new X();
- Object foo2() {
- return new X();
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b4/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b4/A.java
deleted file mode 100644
index f43c463..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b4/A.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package b4;
-/* Test case for bug 9992 Member class declaration not found */
-public class A {
- public class B {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b5/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b5/A.java
deleted file mode 100644
index 32a5a62..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b5/A.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package b5;
-/* Test case for bug 9642 Search - missing inaccurate type matches */
-import x.y.Zork;
-public class A {
- {
- Zork[] zork = new Zork[0];
- int i = Zork.foo;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b6/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b6/A.java
deleted file mode 100644
index c319b04..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b6/A.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package b6;
-/* Test case for bug 10386 NPE in MatchLocator.lookupType */
-public class A {
- int[] field;
- int foo() {
- return this.field.length;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b7/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b7/X.java
deleted file mode 100644
index ac81a01..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b7/X.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package b7;
-/* Test case for bug 16751 Renaming a class doesn't update all references */
-class SuperClass {
- public static final String CONSTANT = "value";
-}
-
-class SubClass extends SuperClass {
-}
-
-class Test {
- public static void main(String[] arguments) {
- System.out.println(SubClass.CONSTANT);
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b8/Test.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b8/Test.java
deleted file mode 100644
index 5e3352a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b8/Test.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package b8;
-/* Test case for bug 17906 Rename package fails when inner classes are imported */
-public class Test {
- public static class InnerTest {
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b9/Foo.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b9/Foo.java
deleted file mode 100644
index 8f564a7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/b9/Foo.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package b9;
-/* Test case for bug 17906 Rename package fails when inner classes are imported */
-import b8.Test.InnerTest;
-public class Foo {
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c1/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c1/A.java
deleted file mode 100644
index 119a72c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c1/A.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package c1;
-/* Test case for bug 12649 Missing import after move */
-class A{
- int i= I.II;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c1/B.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c1/B.java
deleted file mode 100644
index 03de05e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c1/B.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package c1;
-/* Test case for bug 12649 Missing import after move */
-class B{
- int i= I.i;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c1/I.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c1/I.java
deleted file mode 100644
index 3959603..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c1/I.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package c1;
-/* Test case for bug 12649 Missing import after move */
-interface I{
- int i= 0;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c2/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c2/A.java
deleted file mode 100644
index e841cf8..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c2/A.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package c2;
-/* Test case for bug 18418 search: searchDeclarationsOfReferencedTypes reports import declarations */
-import c3.C;
-public class A{
- C c;
- c3.C c3c;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c2/B.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c2/B.java
deleted file mode 100644
index 09e4440..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c2/B.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package c2;
-/* Test case for bug 18418 search: searchDeclarationsOfReferencedTypes reports import declarations */
-import c3.C;
-public class B{
- C c;
- c3.C m(C C, A A){
- return C;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c3/C.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c3/C.java
deleted file mode 100644
index 231a5f5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c3/C.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package c3;
-/* Test case for bug 18418 search: searchDeclarationsOfReferencedTypes reports import declarations */
-import c2.A;
-import c2.*;
-import c2.B;
-public class C{
- A a;
- c2.A c2a;
- B b;
- c2.B c2B;
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c4/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c4/X.java
deleted file mode 100644
index 4db5cdd..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/c4/X.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package c4;
-/* Test case for bug 20693 Finding references to variables does not find all occurances */
-public class X {
- int x;
- int foo() {
- return (this.x);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/A.java
deleted file mode 100644
index bd7561a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/A.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package p;
-public class A {
- public static boolean DEBUG = false;
- public X x;
- public A(X x) {
- this.x = x;
- }
- void foo() {
- A.DEBUG = true;
- }
- public void foo(int i, String s, X x) {
- x.new Inner().foo();
- }
- public static void main(String[] args) {
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/I.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/I.java
deleted file mode 100644
index de67757..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/I.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package p;
-public interface I {
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/X.java
deleted file mode 100644
index 59db2d5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/X.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package p;
-public class X implements I {
- public static boolean DEBUG = false;
- public I field;
- public class Inner {
- public String foo() {
- return "foo";
- }
- }
- public X() {
- X.DEBUG = true;
- }
- public X(int i) {
- }
- public static void bar() {
- }
- public void foo(int i, String s, X x) {
- Inner inner = new Inner();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/Y.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/Y.java
deleted file mode 100644
index 0823bc4..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/Y.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package p;
-public class Y extends X {
- public Y() {
- }
- public Y(int i) {
- super(i);
- }
- public Y(boolean b) {
- super(1);
- }
- public static void bar() {
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/Z.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/Z.java
deleted file mode 100644
index 91b3114..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p/Z.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package p;
-public class Z extends Y {
- public Z() {
- }
- public Z(int i) {
- super(i);
- }
- public void foo(int i, String s, X x) {
- super.foo(i, s, new Y(true));
- }
-
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p2/Z.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p2/Z.java
deleted file mode 100644
index 3e45aa2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p2/Z.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package p2;
-public class Z {
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p3/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p3/X.java
deleted file mode 100644
index d78ec96..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p3/X.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package p3;
-public class X {
- public static int count;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p3/p2/p/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p3/p2/p/X.java
deleted file mode 100644
index e3ad8ee..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p3/p2/p/X.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package p3.p2.p;
-public class X {
- public static int count;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p4/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p4/A.java
deleted file mode 100644
index 3823325..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p4/A.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package p4;
-/* Regression test for 1GLBP65: ITPJCORE:WIN2000 - search: type refs - incorrect match */
-public class A {
- static A A;
-}
-class X extends p4.A{
- void x(){
- p4.A.A= A.A; /*1*/
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p5/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p5/A.java
deleted file mode 100644
index 44aeaa6..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p5/A.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package p5;
-/* Regression test for 1GD79XM: ITPJCORE:WINNT - Search - search for field references - not all found */
-public class A{
- int f;
- A x;
- void k(){
- x.x.x.f= 0;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p6/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p6/A.java
deleted file mode 100644
index 5e3c9f3..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p6/A.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package p6;
-/* Test case for PR 1GKB9YH: ITPJCORE:WIN2000 - search for field refs - incorrect results */
-public class A {
- protected int f;
- void m() {
- f++;
- }
-}
-class AA extends A {
- protected int f;
-}
-class B {
- A a;
- AA b;
- A ab = new AA();
- void m() {
- a.f = 0; /*1*/
- b.f = 0; /*2*/
- ab.f = 0; /*3*/
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p7/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p7/A.java
deleted file mode 100644
index 7a29e63..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p7/A.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package p7;
-/* Test case for 1G52F7P: ITPJCORE:WINNT - Search - finds bogus references to class */
-public class A {
-}
-
-class C {
- void m() {
- class A {
- }
- new A();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p8/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p8/A.java
deleted file mode 100644
index a6cb544..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p8/A.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package p8;
-/* Test case for bug #3433 search: missing field occurrecnces (1GKZ8J6) */
-public class A{
- protected int g;
- void m(){
- g++;
- }
-}
-class B extends A{
- void m(){
- g= 0;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p9/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p9/X.java
deleted file mode 100644
index 57bdded..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/p9/X.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package p9;
-/* Test case for PR 1GK8TXE: ITPJCORE:WIN2000 - search: missing field reference */
-public class X {
- public X f;
- public int k;
- void m() {
- for (int g = 0; g < 10; g++) {
- }
- f.k = 0; //<<
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q1/B.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q1/B.java
deleted file mode 100644
index 7755eeb..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q1/B.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package q1;
-/* Test case for PR 1GK90H4: ITPJCORE:WIN2000 - search: missing package reference */
-public class B{
- void m(AA fred){
- q2.A.length(); //<<<
- }
-}
-class AA{
- static String A;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q2/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q2/A.java
deleted file mode 100644
index 8e95a5d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q2/A.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package q2;
-/* Test case for 1GK90H4: ITPJCORE:WIN2000 - search: missing package reference */
-public class A{
- public static int length(){return 42;};
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q3/A$B.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q3/A$B.java
deleted file mode 100644
index 78061de..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q3/A$B.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package q3;
-/* Test case for bug 3310 Smoke 124: Compile errors introduced with rename refactoring (1GFBK2G) */
-public class A$B {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q4/C.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q4/C.java
deleted file mode 100644
index d64f127..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q4/C.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package q4;
-/* Test case for 3310 Smoke 124: Compile errors introduced with rename refactoring (1GFBK2G) */
-public class C {
- Object foo() {
- return new q3.A$B();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q5/AQ.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q5/AQ.java
deleted file mode 100644
index a24f866..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q5/AQ.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package q5;
-/* Test case for bug 5068 search: missing method reference */
-interface I{
-void k();
-}
-class T{
- void m(){
- class X implements I{
- public void k(){}
- };
- X x= new X();
- x.k(); /**/
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q6/CD.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q6/CD.java
deleted file mode 100644
index d33e8c9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q6/CD.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package q6;
-/* Test case for bug 5069 search: method reference in super missing */
-class AQ {
- public void k(){}
-}
-
-class AQE extends AQ{
- public void k(){
- super.k();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q7/AQ.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q7/AQ.java
deleted file mode 100644
index 7270246..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q7/AQ.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package q7;
-/* Test case for bug 5070 search: missing interface method reference */
-interface I {
-void k();
-}
-class C1 implements I{
- public void k(){};
-}
-class D{
- void h(){
- I a= new C1();
- a.k();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q8/EclipseTest.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q8/EclipseTest.java
deleted file mode 100644
index fde6be1..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q8/EclipseTest.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package q8;
-/* Test case for bug 5821 Refactor > Rename renames local variable instead of member in case of name clash */
-public class EclipseTest {
- public int test = 0;
-
- public static void main(String[] args) {
- EclipseTest test = new EclipseTest();
-
- test.test = 1;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q9/I.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q9/I.java
deleted file mode 100644
index 4af1c82..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/q9/I.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package q9;
-/* Test case for bug 5862 search : too many matches on search with OrPattern */
-interface I{
-void m();
-}
-
-class A1 implements I{
-public void m(){}
-}
-interface I1{
-void m();
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r/A.java
deleted file mode 100644
index f71bfe7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r/A.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package r;
-/* Test case for PR 1GKAQJS: ITPJCORE:WIN2000 - search: incorrect results for nested types */
-public class A {
- class X {
- X(X X) {
- new X(null);
- }
- }
- A() {
- }
- A(A A) {
- }
- A m() {
- new X(null);
- return (A) new A();
- }
-};
-class B {
- A.X ax = new A().new X(null);
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r2/I.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r2/I.java
deleted file mode 100644
index 39d9529..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r2/I.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package r2;
-/* Regression test for bug 22102 Not all implementors found for IPartListener */
-public interface I {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r2/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r2/X.java
deleted file mode 100644
index fc11293..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r2/X.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package r2;
-/* Regression test for bug 22102 Not all implementors found for IPartListener */
-public class X {
- I field = new I() {
- };
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r3/A21485.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r3/A21485.java
deleted file mode 100644
index 0307f2d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r3/A21485.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package r3;
-/* Test case for bug 21485 NPE when doing a reference search to a package */
-class A21485 {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r4/B21485.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r4/B21485.java
deleted file mode 100644
index b8df93a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r4/B21485.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package r4;
-/* Test case for bug 21485 NPE when doing a reference search to a package */
-import r3.A21485;
-public class B21485 extends A21485 {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r5/XYZ.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r5/XYZ.java
deleted file mode 100644
index 129d7f9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r5/XYZ.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package r5;
-/* Test case for bug 17210 No match found when query contains '?' */
-public class XYZ {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r6/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r6/A.java
deleted file mode 100644
index 2b128eb..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r6/A.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package r6;
-/* Test case for bug 23077 search: does not find type references in some imports */
-public class A {
- public class Inner{
- public class InnerInner{
- }
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r6/B.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r6/B.java
deleted file mode 100644
index 7022a8d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/r6/B.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package r6;
-/* Test case for bug 23077 search: does not find type references in some imports */
-import r6.A;
-import r6.A.Inner;
-import r6.A.Inner.InnerInner;
-import r6.A.*;
-import r6.A.Inner.*;
-import r6.A.Inner.InnerInner.*;
-public class B {
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s1/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s1/X.java
deleted file mode 100644
index edca6a5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s1/X.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package s1;
-/* Test case for bug 3230 Search - Too many type references for query ending with * (1GAZVGI) */
-public class X {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s1/Y.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s1/Y.java
deleted file mode 100644
index d44cbdb..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s1/Y.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package s1;
-/* Test case for bug 3230 Search - Too many type references for query ending with * (1GAZVGI) */
-public class Y {
- X f[];
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s2/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s2/X.java
deleted file mode 100644
index 4959038..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s2/X.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package s2;
-/* Test case for bug 3230 Search - Too many type references for query ending with * (1GAZVGI) */
-public class X {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s2/Z.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s2/Z.java
deleted file mode 100644
index 092ddcc..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s2/Z.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package s2;
-/* Test case for bug 3230 Search - Too many type references for query ending with * (1GAZVGI) */
-public class Z {
- X f[];
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s3/A.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s3/A.java
deleted file mode 100644
index 7979877..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/s3/A.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package s3;
-/* Regression test for bug 23329 search: incorrect range for type references in brackets */
-public class A {
- int field;
- Object foo() {
- return ( B )this;
- }
- int bar() {
- return ( field );
- }
-}
-class B {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/sd/AQ.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/sd/AQ.java
deleted file mode 100644
index ff6ae08..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/sd/AQ.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package sd;
-
-/* Test case for PR 1GKCH3N: ITPJCORE:WIN2000 - search: method refs - super call not found */
-public class AQ{
- public void k(){}
-}
-
-class AQE extends AQ{
- public void k(){
- super.k();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/wc/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/wc/X.java
deleted file mode 100644
index 208050a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/wc/X.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package wc;
-public class X {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/wc1/X.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/wc1/X.java
deleted file mode 100644
index 7bc0d09..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/wc1/X.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package wc1;
-public class X {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/wc2/Y.java b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/wc2/Y.java
deleted file mode 100644
index 7a5fb73..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/src/wc2/Y.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package wc2;
-public class Y {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/test20631.jar b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/test20631.jar
deleted file mode 100644
index 743164e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/test20631.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/test20631.zip b/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/test20631.zip
deleted file mode 100644
index a820f3d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/JavaSearch/test20631.zip
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/.classpath b/org.eclipse.jdt.core.tests.model/workspace/Resolve/.classpath
deleted file mode 100644
index d789621..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/.classpath
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="var" path="JCL_LIB" sourcepath="JCL_SRC" rootpath="JCL_SRCROOT"/>
- <classpathentry kind="lib" path="zzz.jar" sourcepath="/Resolve/zzzsrc.zip"/>
- <classpathentry kind="lib" path="p3.jar" sourcepath="/Resolve/p3src.zip"/>
- <classpathentry kind="lib" path="p4.jar"/>
- <classpathentry kind="lib" path="class-folder"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/.project b/org.eclipse.jdt.core.tests.model/workspace/Resolve/.project
deleted file mode 100644
index c05ce73..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jdt.core</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/class-folder/ResolveConstructorCallOfMemberType$Inner.class b/org.eclipse.jdt.core.tests.model/workspace/Resolve/class-folder/ResolveConstructorCallOfMemberType$Inner.class
deleted file mode 100644
index e5c9d5e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/class-folder/ResolveConstructorCallOfMemberType$Inner.class
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/class-folder/ResolveConstructorCallOfMemberType.class b/org.eclipse.jdt.core.tests.model/workspace/Resolve/class-folder/ResolveConstructorCallOfMemberType.class
deleted file mode 100644
index 0f9edac..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/class-folder/ResolveConstructorCallOfMemberType.class
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/class-folder/ResolveConstructorCallOfMemberType.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/class-folder/ResolveConstructorCallOfMemberType.java
deleted file mode 100644
index 8b72b53..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/class-folder/ResolveConstructorCallOfMemberType.java
+++ /dev/null
@@ -1,6 +0,0 @@
-public class ResolveConstructorCallOfMemberType {
- class Inner {}
- void foo(){
- new Inner();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/p3.jar b/org.eclipse.jdt.core.tests.model/workspace/Resolve/p3.jar
deleted file mode 100644
index efd52bf..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/p3.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/p3src.zip b/org.eclipse.jdt.core.tests.model/workspace/Resolve/p3src.zip
deleted file mode 100644
index e87e2c7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/p3src.zip
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/p4.jar b/org.eclipse.jdt.core.tests.model/workspace/Resolve/p4.jar
deleted file mode 100644
index 32f474a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/p4.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/p4src.zip b/org.eclipse.jdt.core.tests.model/workspace/Resolve/p4src.zip
deleted file mode 100644
index 2f112c0..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/p4src.zip
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveArgumentName.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveArgumentName.java
deleted file mode 100644
index c32664c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveArgumentName.java
+++ /dev/null
@@ -1,5 +0,0 @@
-public class ResolveArgumentName {
- public void foo(Object var1, int var2){
-
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveArrayLength.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveArrayLength.java
deleted file mode 100644
index 9ed313b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveArrayLength.java
+++ /dev/null
@@ -1,6 +0,0 @@
-public class ResolveArrayLength {
- public int foo() {
- Object[] array = new Object[0];
- return array.length;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveCatchArgumentName.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveCatchArgumentName.java
deleted file mode 100644
index be1544c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveCatchArgumentName.java
+++ /dev/null
@@ -1,8 +0,0 @@
-public class ResolveCatchArgumentName {
- public void foo(){
- try{
- } catch(Object var1){
- } catch(int var2){
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass1.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass1.java
deleted file mode 100644
index d08d84c..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass1.java
+++ /dev/null
@@ -1,5 +0,0 @@
-import p1.*;
-
-public class ResolveClass1{
- private X[] x;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass2.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass2.java
deleted file mode 100644
index 944316f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass2.java
+++ /dev/null
@@ -1,7 +0,0 @@
-import p1.*;
-
-public class ResolveClass2{
- public void foo() {
- X x = null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass3.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass3.java
deleted file mode 100644
index f8d2bac..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass3.java
+++ /dev/null
@@ -1,5 +0,0 @@
-import p1.*;
-
-public class ResolveClass3{
- X[] x = new X[]{};
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass4.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass4.java
deleted file mode 100644
index 983ec3e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass4.java
+++ /dev/null
@@ -1,7 +0,0 @@
-import p1.*;
-
-public class ResolveClass4{
- public X foo() {
- return null;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass5.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass5.java
deleted file mode 100644
index 990de28..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass5.java
+++ /dev/null
@@ -1,6 +0,0 @@
-import p1.*;
-
-public class ResolveClass5{
- public void foo(X x) {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass6.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass6.java
deleted file mode 100644
index 7489e0a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveClass6.java
+++ /dev/null
@@ -1,3 +0,0 @@
-public class ResolveClass6 extends p1.X {
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveConstructor.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveConstructor.java
deleted file mode 100644
index ea12fa5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveConstructor.java
+++ /dev/null
@@ -1,9 +0,0 @@
-public class ResolveConstructor {
- public ResolveConstructor(int i) {
- }
- public ResolveConstructor(String s) {
- }
- public void foo() {
- ResolveConstructor c = new ResolveConstructor("");
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveConstructorDeclaration.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveConstructorDeclaration.java
deleted file mode 100644
index 921b8ff..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveConstructorDeclaration.java
+++ /dev/null
@@ -1,6 +0,0 @@
-public class ResolveConstructorDeclaration {
- public ResolveConstructorDeclaration(int i) {
- }
- public ResolveConstructorDeclaration(String s) {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveEmptySelectionOnMethod.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveEmptySelectionOnMethod.java
deleted file mode 100644
index 0d49da9..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveEmptySelectionOnMethod.java
+++ /dev/null
@@ -1,7 +0,0 @@
-public class ResolveEmptySelectionOnMethod {
- void foo(){
- }
- void bar(){
- foo();
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveExplicitSuperConstructorCall.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveExplicitSuperConstructorCall.java
deleted file mode 100644
index 621bb3a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveExplicitSuperConstructorCall.java
+++ /dev/null
@@ -1,5 +0,0 @@
-public class ResolveExplicitSuperConstructorCall extends SuperClass {
- public ResolveExplicitSuperConstructorCall(int x){
- super(x);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveExplicitThisConstructorCall.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveExplicitThisConstructorCall.java
deleted file mode 100644
index 68d82fd..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveExplicitThisConstructorCall.java
+++ /dev/null
@@ -1,9 +0,0 @@
-public class ResolveExplicitThisConstructorCall {
- public ResolveExplicitThisConstructorCall(){
-
- }
-
- public ResolveExplicitThisConstructorCall(int x){
- this();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveField.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveField.java
deleted file mode 100644
index 4672288..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveField.java
+++ /dev/null
@@ -1,6 +0,0 @@
-public class ResolveField {
- public int foo;
- public void bar() {
- this.foo = 0;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveFieldDeclaration.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveFieldDeclaration.java
deleted file mode 100644
index 20bd1f2..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveFieldDeclaration.java
+++ /dev/null
@@ -1,3 +0,0 @@
-public class ResolveFieldDeclaration {
- public int foo;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveImport.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveImport.java
deleted file mode 100644
index 579780e..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveImport.java
+++ /dev/null
@@ -1,5 +0,0 @@
-import a.b.ImportedClass;
-
-public class ResolveImport {
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveInterface.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveInterface.java
deleted file mode 100644
index fb56395..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveInterface.java
+++ /dev/null
@@ -1,3 +0,0 @@
-public class ResolveInterface implements p1.Y {
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveLocalName.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveLocalName.java
deleted file mode 100644
index 325d44f..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveLocalName.java
+++ /dev/null
@@ -1,6 +0,0 @@
-public class ResolveLocalName {
- public void foo(){
- Object var1;
- int var2;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMemberTypeDeclaration1.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMemberTypeDeclaration1.java
deleted file mode 100644
index 80fa739..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMemberTypeDeclaration1.java
+++ /dev/null
@@ -1,4 +0,0 @@
-public class ResolveMemberTypeDeclaration1 {
- public interface MemberInterface {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMemberTypeDeclaration2.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMemberTypeDeclaration2.java
deleted file mode 100644
index b681984..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMemberTypeDeclaration2.java
+++ /dev/null
@@ -1,6 +0,0 @@
-public class ResolveMemberTypeDeclaration2 {
- class Member {
- class MemberOfMember {
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMessageSendOnBaseType.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMessageSendOnBaseType.java
deleted file mode 100644
index 32e51ee..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMessageSendOnBaseType.java
+++ /dev/null
@@ -1,6 +0,0 @@
-public class ResolveMessageSendOnBaseType {
- boolean foo;
- public int boo() {
- foo.hello();
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMethod.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMethod.java
deleted file mode 100644
index 1400e69..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMethod.java
+++ /dev/null
@@ -1,9 +0,0 @@
-public class ResolveMethod {
- public void foo(int i) {
- }
- public void foo(String s) {
- }
- public void bar() {
- new ResolveMethod().foo("");
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMethodDeclaration.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMethodDeclaration.java
deleted file mode 100644
index 1616574..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMethodDeclaration.java
+++ /dev/null
@@ -1,6 +0,0 @@
-public class ResolveMethodDeclaration {
- public void foo(int i) {
- }
- public void foo(String s) {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMethodWithIncorrectParameter.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMethodWithIncorrectParameter.java
deleted file mode 100644
index 9476627..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveMethodWithIncorrectParameter.java
+++ /dev/null
@@ -1,7 +0,0 @@
-public class ResolveMethodWithIncorrectParameter {
- public void foo(int x) {
- }
- public void bar() {
- foo("String");
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolvePackage.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolvePackage.java
deleted file mode 100644
index 4de0ab1..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolvePackage.java
+++ /dev/null
@@ -1,4 +0,0 @@
-import java.lang.*;
-
-public class ResolvePackage {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolvePartiallyQualifiedType.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolvePartiallyQualifiedType.java
deleted file mode 100644
index 8dfa649..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolvePartiallyQualifiedType.java
+++ /dev/null
@@ -1,5 +0,0 @@
-public class ResolvePartiallyQualifiedType {
- void foo() {
- java.lang.Object o;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveQualifiedType.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveQualifiedType.java
deleted file mode 100644
index 74274e1..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveQualifiedType.java
+++ /dev/null
@@ -1,5 +0,0 @@
-public class ResolveQualifiedType {
- void foo() {
- java.lang.Object o;
- }
-}
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeDeclaration.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeDeclaration.java
deleted file mode 100644
index 76bde4d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeDeclaration.java
+++ /dev/null
@@ -1,5 +0,0 @@
-public class ResolveTypeDeclaration {
-
-}
-class OtherType {
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeEmptySelection.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeEmptySelection.java
deleted file mode 100644
index f66046d..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeEmptySelection.java
+++ /dev/null
@@ -1,3 +0,0 @@
-public class ResolveTypeEmptySelection {
- Object o;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeEmptySelection2.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeEmptySelection2.java
deleted file mode 100644
index e2732ff..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeEmptySelection2.java
+++ /dev/null
@@ -1,3 +0,0 @@
-public class ResolveTypeEmptySelection2 {
- Object o;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeInComment.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeInComment.java
deleted file mode 100644
index c2be2b4..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveTypeInComment.java
+++ /dev/null
@@ -1,4 +0,0 @@
-import p2.X;
-public class ResolveTypeInComment{
- /* return X */
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveUnicode.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveUnicode.java
deleted file mode 100644
index 37b662a..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/ResolveUnicode.java
+++ /dev/null
@@ -1,3 +0,0 @@
-public class ResolveUnicode {
- public java.lang.\u0053tring s;
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/SuperClass.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/SuperClass.java
deleted file mode 100644
index 5e44433..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/SuperClass.java
+++ /dev/null
@@ -1,5 +0,0 @@
-public class SuperClass {
- public SuperClass(int x){
-
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/a/b/ImportedClass.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/a/b/ImportedClass.java
deleted file mode 100644
index 79386e7..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/a/b/ImportedClass.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package a.b;
-
-public class ImportedClass {
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/p1/X.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/p1/X.java
deleted file mode 100644
index 70db433..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/p1/X.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package p1;
-
-public class X {
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/p1/Y.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/p1/Y.java
deleted file mode 100644
index 1af1c8b..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/p1/Y.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package p1;
-
-public interface Y {
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/p2/X.java b/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/p2/X.java
deleted file mode 100644
index f214936..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/src/p2/X.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package p2;
-
-public class X {
-
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/zzz.jar b/org.eclipse.jdt.core.tests.model/workspace/Resolve/zzz.jar
deleted file mode 100644
index 06138a5..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/zzz.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core.tests.model/workspace/Resolve/zzzsrc.zip b/org.eclipse.jdt.core.tests.model/workspace/Resolve/zzzsrc.zip
deleted file mode 100644
index 53d9993..0000000
--- a/org.eclipse.jdt.core.tests.model/workspace/Resolve/zzzsrc.zip
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index e323512..a886059 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -33,6 +33,24 @@
<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 19th September 2002 - 2.1 MILESTONE-1
+<br>Project org.eclipse.jdt.core v_273a
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23558">23558</a>
+Extremly slow startup
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23788">23788</a>
+Java compiler doesn't properly flag invalid protected access (for javac 1.4 compatibility)
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
Eclipse SDK 2.1 Build - 16th September 2002
<br>Project org.eclipse.jdt.core v_273
<h2>
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
index 515f038..30d6b89 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
Binary files differ
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
index fc41c0e..f69faae 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
@@ -273,6 +273,14 @@
((JarPackageFragmentRoot) roots[i]).setSourceAttachmentProperty(null);
}
}
+
+ // forget cached classpath
+ JavaModelManager.PerProjectInfo perProjectInfo = getJavaModelManager().getPerProjectInfo(fProject, false /*no need to create*/);
+ if (perProjectInfo != null) {
+ perProjectInfo.classpath = null;
+ perProjectInfo.lastResolvedClasspath = null;
+ }
+
super.closing(info);
}
@@ -1294,19 +1302,9 @@
*/
public IClasspathEntry[] getRawClasspath() throws JavaModelException {
- IClasspathEntry[] classpath = null;
- if (this.isOpen()) {
- JavaProjectElementInfo info = getJavaProjectElementInfo();
- classpath = info.getRawClasspath();
- if (classpath != null) {
- return classpath;
- }
- return defaultClasspath();
- }
- // if not already opened, then read from file (avoid populating the model for CP question)
- if (!this.getProject().exists()){
- throw newNotPresentException();
- }
+ JavaModelManager.PerProjectInfo info = getJavaModelManager().getPerProjectInfoCheckExistence(fProject);
+ IClasspathEntry[] classpath = info.classpath;
+ if (classpath != null) return classpath;
try {
String sharedClasspath = loadClasspath();
if (sharedClasspath != null) {
@@ -1335,6 +1333,7 @@
}
}
if (classpath != null) {
+ info.classpath = classpath;
return classpath;
}
return defaultClasspath();
@@ -1368,26 +1367,18 @@
boolean generateMarkerOnError)
throws JavaModelException {
- JavaProjectElementInfo projectInfo;
- if (this.isOpen()){
- projectInfo = getJavaProjectElementInfo();
- } else {
- // avoid populating the model for only retrieving the resolved classpath (13395)
- projectInfo = null;
- }
+ JavaModelManager.PerProjectInfo info = getJavaModelManager().getPerProjectInfoCheckExistence(fProject);
// reuse cache if not needing to refresh markers or checking bound variables
- if (ignoreUnresolvedEntry && !generateMarkerOnError && projectInfo != null){
+ if (ignoreUnresolvedEntry && !generateMarkerOnError){
// resolved path is cached on its info
- IClasspathEntry[] infoPath = projectInfo.lastResolvedClasspath;
+ IClasspathEntry[] infoPath = info.lastResolvedClasspath;
if (infoPath != null) return infoPath;
}
IClasspathEntry[] resolvedPath = getResolvedClasspath(getRawClasspath(), ignoreUnresolvedEntry, generateMarkerOnError);
- if (projectInfo != null){
- projectInfo.lastResolvedClasspath = resolvedPath;
- }
+ info.lastResolvedClasspath = resolvedPath;
return resolvedPath;
}
@@ -2106,8 +2097,7 @@
protected void setRawClasspath0(IClasspathEntry[] rawEntries)
throws JavaModelException {
- // if not open, will cause opening with default path
- JavaProjectElementInfo info = getJavaProjectElementInfo();
+ JavaModelManager.PerProjectInfo info = getJavaModelManager().getPerProjectInfoCheckExistence(fProject);
synchronized (info) {
if (rawEntries == null) {
@@ -2116,7 +2106,7 @@
// clear cache of resolved classpath
info.lastResolvedClasspath = null;
- info.setRawClasspath(rawEntries);
+ info.classpath = rawEntries;
// compute the new roots
updatePackageFragmentRoots();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java
index b46e96f..c22f872 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java
@@ -31,11 +31,6 @@
class JavaProjectElementInfo extends OpenableElementInfo {
/**
- * The classpath for this project
- */
- protected IClasspathEntry[] fClasspath;
-
- /**
* The name lookup facility to use with this project.
*/
protected NameLookup fNameLookup = null;
@@ -56,8 +51,6 @@
*/
private Object[] fNonJavaResources;
- public IClasspathEntry[] lastResolvedClasspath = null;
-
/**
* Create and initialize a new instance of the receiver
*/
@@ -183,13 +176,7 @@
return fOutputLocation;
}
- /**
- * Returns the classpath for this project
- */
- protected IClasspathEntry[] getRawClasspath() {
- return fClasspath;
- }
/**
* @see IJavaProject
@@ -220,14 +207,7 @@
fOutputLocation = newOutputLocation;
}
- /**
- * Sets the classpath for this project
- */
- protected void setRawClasspath(IClasspathEntry[] newClasspath) {
-
- this.fClasspath = newClasspath;
- }
protected void setSearchableEnvironment(SearchableEnvironment newSearchableEnvironment) {