Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoopur Gupta2020-06-16 09:26:04 +0000
committerNoopur Gupta2020-06-16 09:26:04 +0000
commit8dc6d4e69f0d9a0351ca6fa54dd9054327212159 (patch)
tree2b07d1bc2a6e5bd0304e4504f2e0a4724e952957
parentac8db45a7649316b6adc88c48a7a849848349cc3 (diff)
parent2c5a1e0fca990ff5495369d15c0a32ce4a148de6 (diff)
downloadeclipse.jdt.ui-8dc6d4e69f0d9a0351ca6fa54dd9054327212159.tar.gz
eclipse.jdt.ui-8dc6d4e69f0d9a0351ca6fa54dd9054327212159.tar.xz
eclipse.jdt.ui-8dc6d4e69f0d9a0351ca6fa54dd9054327212159.zip
Bug 564325: [15] Merge master to BETA_JAVA15 branchY20200617-0510Y20200617-0320
Merge remote-tracking branch 'origin/master' into BETA_JAVA15 Conflicts: org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/JavadocQuickFixTest14.java org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest14.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/FastJavaPartitionScanner.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickFixProcessor.java Change-Id: Icb0b143b40a92d2a61796e38d44000cd1eacf6b2
-rw-r--r--org.eclipse.jdt.astview.feature/feature.xml4
-rw-r--r--org.eclipse.jdt.astview.feature/pom.xml4
-rw-r--r--org.eclipse.jdt.astview/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jdt.astview/pom.xml6
-rw-r--r--org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/ASTViewImages.java3
-rw-r--r--org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewContentProvider.java3
-rw-r--r--org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/Binding.java3
-rw-r--r--org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ProblemNode.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/BindingLabelProviderCore.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/CodeTemplateContextType.java67
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/JavaManipulationPlugin.java9
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/Messages.java2
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/StubUtility.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/JdtViewerDropAdapterConstants.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.java2
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties4
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingsCore.java2
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/preferences/JavaPreferencesSettings.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/JavaBreakIterator.java4
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/JavaWordIterator.java4
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.java2
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties2
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessorCore.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessorCore.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/SerialVersionHashOperationCore.java2
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/ASTResolving.java7
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/NecessaryParenthesesChecker.java20
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/OperatorPrecedence.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/CorextCore.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/SourceRangeFactory.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/CodeGenerationSettingsConstants.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/CustomBuilderGenerator.java2
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodeFactory.java91
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java94
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/DimensionRewrite.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/InterruptibleVisitor.java4
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/LinkedNodeFinder.java39
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/TypeRules.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/VariableDeclarationRewrite.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/ASTFragmentFactory.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/Util.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java37
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertForLoopOperation.java15
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertIterableLoopOperation.java256
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopFixCore.java14
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopOperation.java49
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/LambdaExpressionsFixCore.java165
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/Messages.java4
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/UnusedCodeFixCore.java26
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/UnwrapNewArrayOperation.java22
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/RefactoringAvailabilityTesterCore.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/changes/TextChangeCompatibility.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/code/ConstantChecks.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/code/Invocations.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/nls/NLSUtil.java2
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/participants/JavaProcessors.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/participants/ResourceProcessors.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/rename/RenamingNameSuggestor.java2
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInnerToTopRefactoring.java2
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextEditUtil.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitContext.java4
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitContextType.java12
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/ICompilationUnitContext.java36
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/JavaContextCore.java5
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/CodeFormatterUtil.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaConventionsUtil.java16
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/Messages.java2
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/SearchUtils.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/SuperTypeHierarchyCache.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/pom.xml4
-rw-r--r--org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/core/refactoring/descriptors/JavaRefactoringDescriptor.java2
-rw-r--r--org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/core/refactoring/descriptors/JavaRefactoringDescriptorUtil.java3
-rw-r--r--org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/core/refactoring/descriptors/RefactoringSignatureDescriptorFactory.java3
-rw-r--r--org.eclipse.jdt.jeview.feature/feature.xml6
-rw-r--r--org.eclipse.jdt.jeview.feature/pom.xml4
-rw-r--r--org.eclipse.jdt.jeview/pom.xml2
-rw-r--r--org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/JEPluginImages.java3
-rw-r--r--org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/properties/MarkerProperties.java4
-rw-r--r--org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/properties/MemberValuePairProperties.java4
-rw-r--r--org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/views/JavaElementView.java8
-rw-r--r--org.eclipse.jdt.junit.core/pom.xml2
-rw-r--r--org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/buildpath/BuildPathSupport.java3
-rw-r--r--org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/buildpath/P2Utils.java3
-rw-r--r--org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfigurationConstants.java3
-rw-r--r--org.eclipse.jdt.junit.runtime/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jdt.junit.runtime/pom.xml4
-rw-r--r--org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/MessageIds.java3
-rw-r--r--org.eclipse.jdt.junit/pom.xml2
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/buildpath/JUnitContainerWizardPage.java6
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/AssertionVMArg.java3
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/OpenTestAction.java2
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java5
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/CheckedTableSelectionDialog.java2
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/JUnitStubUtility.java3
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/LayoutUtil.java3
-rw-r--r--org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationTab.java2
-rw-r--r--org.eclipse.jdt.junit4.runtime/pom.xml2
-rw-r--r--org.eclipse.jdt.junit5.runtime/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jdt.junit5.runtime/pom.xml6
-rw-r--r--org.eclipse.jdt.junit5.runtime/src/org/eclipse/jdt/internal/junit5/runner/JUnit5TestListener.java53
-rw-r--r--org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.jdt.text.tests/pom.xml2
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BracketInserterTest.java72
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BreakContinueTargetFinderTest.java60
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BreakIteratorTest.java2
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/IndentActionTest.java97
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaAutoIndentStrategyTest.java45
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaColoringTest.java41
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaDoc2HTMLTextReaderTester.java75
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaDoubleClickSelectorTest.java43
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaElementPrefixPatternMatcherTest.java43
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaHeuristicScannerTest.java118
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaModelOpCompundUndoTest.java48
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaParameterListValidatorTest.java58
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaPartitionerExtensionTest.java69
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaPartitionerTest.java115
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JdtTextTestSuite.java4
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest1d7.java (renamed from org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest17.java)60
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest1d8.java (renamed from org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest18.java)55
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PartitionTokenScannerTest.java31
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PluginsNotLoadedTest.java8
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PropertiesFileAutoEditStrategyTest.java63
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PropertiesFilePartitionerTest.java61
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/SmartSemicolonAutoEditStrategyTest.java52
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/codemining/CodeMiningTriggerTest.java20
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/codemining/ParameterNamesCodeMiningTest.java38
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/AbstractCompletionTest.java32
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CamelCaseCompletionTest.java21
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ChainCompletionTest.java111
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CodeCompletionTest.java91
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CodeCompletionTest1d8.java (renamed from org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CodeCompletionTest18.java)57
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CompletionTestSetup.java13
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistAndThreadsTest.java7
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistHistoryTest.java47
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistTestSuite.java53
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContinuousTypingCompletionTest.java25
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/Java1d7CompletionTestSetup.java (renamed from org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/Java17CompletionTestSetup.java)15
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/JavadocCompletionTest.java80
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodInsertCompletionTest.java51
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodInsertionFormattedCompletionTest.java27
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodOverwriteCompletionTest.java26
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodParameterGuessingCompletionTest.java26
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodParamsCompletionTest.java39
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MissingTypeCompletionTest.java80
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/PostFixCompletionTest.java151
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/SpecialMethodsCompletionTest.java26
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/TypeCompletionTest.java55
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/TypeCompletionTest1d7.java (renamed from org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/TypeCompletionTest17.java)34
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/EditorTestHelper.java3
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/InvocationCountExampleTest.java4
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/InvocationCountPerformanceMeter.java4
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/OpenJavaEditorInvocationCountTest.java2
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/PerfTestSuite.java2
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/PerformanceTestCase2.java2
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/SWTEventHelper.java3
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/ScrollAnnotatedJavaEditorInvocationCountTest.java2
-rw-r--r--org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/TypingInvocationCountTest.java2
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jsp/launching/TomcatLaunchDelegate.java2
-rw-r--r--org.eclipse.jdt.ui.examples.projects/examples/org/eclipse/jdt/internal/ui/exampleprojects/ExampleProjectCreationWizard.java2
-rw-r--r--org.eclipse.jdt.ui.examples.projects/pom.xml2
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/pom.xml4
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test111/in/A.java5
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test111/out/A.java5
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test111/out/I.java6
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test112/in/A.java5
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test112/out/A.java5
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test112/out/I.java6
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_in/A_test628.java2
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_in/A_test629.java4
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test627.java4
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test628.java2
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test629.java6
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/IntroduceParameter/simple/out/Expression5.java2
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/A.java14
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/B.java8
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/C.java8
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/D.java19
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/A.java14
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/B.java8
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/C.java8
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/D.java19
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AbstractJunit4SelectionTestCase.java6
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AbstractSelectionTestCase.java214
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AllRefactoringTests.java40
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AllTests.java4
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/BinaryReferencesTests.java20
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeSignatureTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeSignatureTests18.java)14
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeTypeRefactoringTests1d7.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeTypeRefactoringTests17.java)9
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests18.java)9
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractClassTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractClassTests18.java)15
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests.java107
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests13.java30
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests1d7.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests17.java)37
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java10
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests18.java)9
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTestSetup1d7.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTestSetup17.java)7
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTestSetup1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTestSetup18.java)8
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests.java16
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests10.java9
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests13.java10
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests1d7.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests17.java)11
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests18.java)15
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests9.java9
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractTempTests1d7.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractTempTests17.java)9
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractTempTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractTempTests18.java)9
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/GenericRefactoringTest.java3
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InferTypeArgumentsTests.java106
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests.java89
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests17.java45
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests1d7.java47
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests18.java)42
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup.java13
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup13.java14
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup18.java)18
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests.java265
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests13.java28
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests18.java)32
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests.java4
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests1d7.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests17.java)9
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests18.java)9
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceIndirectionTests1d7.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceIndirectionTests17.java)9
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceIndirectionTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceIndirectionTests18.java)9
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceParameterObjectTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceParameterObjectTests18.java)16
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceParameterTests1d7.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceParameterTests17.java)9
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java10Setup.java35
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java12Setup.java35
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java13Setup.java38
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java14Setup.java38
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java15Setup.java31
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java16Setup.java38
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java17Setup.java38
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java18Setup.java38
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java9Setup.java35
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInitializerTests.java40
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInnerToTopLevelTests.java156
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests.java122
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests18.java)50
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests.java125
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests18.java)42
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveRenameResourceChangeTests.java89
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/NoSuperTestsSuite.java62
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PathTransformationTests.java37
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PromoteTempToFieldTests.java96
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PromoteTempToFieldTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PromoteTempToFieldTests18.java)39
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests.java237
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests18.java)53
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PushDownTests.java153
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringScannerTests.java37
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringTest.java636
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringTestSetup.java99
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameRecordElementsTests.java78
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameTempTests.java4
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameTests18.java14
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenamingNameSuggestorTests.java43
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ReplaceInvocationsTests.java37
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RewriteMethodInvocationsTestSetup.java14
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RippleMethodFinderTests.java41
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SefTestSetup.java13
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SefTests.java72
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithResourcesTestSetup1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithResourcesTestSetup18.java)29
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithResourcesTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithResourcesTests18.java)58
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup.java25
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup17.java28
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup18.java)30
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests.java66
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests1d7.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests17.java)41
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests1d8.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests18.java)47
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UndoManagerTests.java45
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UseSupertypeWherePossibleTests.java150
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ValidateEditTests.java53
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/actions/StructureSelectionActionTests.java214
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyTest.java437
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyToClipboardActionTest.java162
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/DeleteTest.java226
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MoveTest.java292
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MultiMoveTest.java68
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/PasteActionTest.java62
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/AbstractCUTestCase.java101
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/RefactoringHeapTestCase.java8
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/RefactoringPerformanceTestCase.java8
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/ZipTools.java15
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSHintHelperTest.java4
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NlsRefactoringCreateChangeTest.java20
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/PropertyFileDocumentModellTest.java22
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java16Setup.java2
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java1d7Setup.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java17Setup.java)5
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java1d8Setup.java (renamed from org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java18Setup.java)5
-rw-r--r--org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/typeconstraints/TypeEnvironmentTests.java58
-rw-r--r--org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ChkpiiTests.java42
-rw-r--r--org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/ASTRewriteSnippet.java13
-rw-r--r--org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/CheckBoxExample.java6
-rw-r--r--org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyRenameTypeParticipant.java5
-rw-r--r--org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/LeakTestSetup.java52
-rw-r--r--org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/FileTool.java6
-rw-r--r--org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/PerformanceTestSuite.java15
-rw-r--r--org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java10
-rw-r--r--org.eclipse.jdt.ui.tests/pom.xml4
-rw-r--r--org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java3
-rw-r--r--org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java3
-rw-r--r--org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/HelloWorld.java41
-rw-r--r--org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/JavaTestCase.java43
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/JUnitWorkspaceTestSetup.java88
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestPriorization.java6
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/UIInteractiveSuite.java30
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests.java185
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests2.java40
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewDeltaTests.java176
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/callhierarchy/CallHierarchyContentProviderTest.java45
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/AbstractBindingLabelsTest.java19
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/BindingLabels18Test.java10
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ClassPathDetectorTest.java18
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CoreTestSuite.java6
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/HierarchicalASTVisitorTest.java10
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest.java23
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest1d8.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest18.java)13
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JDTFlagsTest18.java25
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java10ProjectTestSetup.java65
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java12ProjectTestSetup.java68
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java13ProjectTestSetup.java68
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java14ProjectTestSetup.java68
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java18ProjectTestSetup.java79
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java1d5ProjectTestSetup.java62
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java1d7ProjectTestSetup.java61
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java9ProjectTestSetup.java65
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementLabelsTest1d8.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementLabelsTest18.java)14
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementPropertyTesterTest.java3
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaModelUtilTest.java6
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/MethodOverrideTest1d8.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/MethodOverrideTest18.java)13
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/NoSuperTestsSuite.java61
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java6
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d8ProjectTestSetup.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java18ProjectTestSetup.java)6
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/AddUnimplementedMethodsTest1d8.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/AddUnimplementedMethodsTest18.java)14
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/dialogs/DialogsTest.java2
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/hover/PackageJavadocTests.java125
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/FatJarExportTests.java19
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/PlainJarExportTests.java21
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests1.java144
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests2.java20
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests3.java29
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests4.java22
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/preferences/OptionsConfigurationBlockTest.java5
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d7.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest17.java)5
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d8.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest18.java)15
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d8.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest18.java)23
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java145
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest17.java)5
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d8.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest18.java)24
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java346
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest18.java1034
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d5.java82
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d8.java1124
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java8
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertForLoopQuickFixTest.java90
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertIterableLoopQuickFixTest.java45
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/JarUtil.java3
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/JavadocQuickFixTest14.java272
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java348
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest1d7.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest17.java)5
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest1d8.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest18.java)13
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest1d7.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest17.java)5
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsCleanUpTest1d8.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsCleanUpTest18.java)13
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsQuickFixTest1d8.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsQuickFixTest18.java)13
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsQuickFixTest1d8Mix.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsQuickFixTest18Mix.java)15
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest.java60
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest14.java612
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest1d8.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest18.java)42
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ReorgQuickFixTest.java10
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/TypeAnnotationQuickFixTest.java10
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/UnresolvedMethodsQuickFixTest1d8.java (renamed from org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/UnresolvedMethodsQuickFixTest18.java)17
-rw-r--r--org.eclipse.jdt.ui/.settings/.api_filters85
-rw-r--r--org.eclipse.jdt.ui/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/Corext.java3
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/TypeAnnotationRewrite.java3
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstantsOptions.java4
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpPreferenceUtil.java3
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopFix.java8
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ExternalNullAnnotationChangeProposals.java6
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/Java50Fix.java26
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/NullAnnotationsRewriteOperations.java3
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/TypeAnnotationRewriteOperations.java3
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/UnnecessaryArrayCreationFix.java58
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/UnusedCodeFix.java13
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/javadoc/JavaDocLocations.java8
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/ActualTypeResolver.java4
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaDocContext.java6
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaPostfixContext.java58
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/CollectionsUtil.java3
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/IOCloser.java3
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/InfoFilesUtil.java3
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringAvailabilityTester.java35
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/TypeContextChecker.java3
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractConstantRefactoring.java14
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodAnalyzer.java2
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java37
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java18
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceFactoryRefactoring.java10
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceIndirectionRefactoring.java4
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceParameterRefactoring.java11
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ReplaceInvocationsRefactoring.java4
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/generics/InferTypeArgumentsRefactoring.java8
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSPropertyFileModifier.java3
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/participants/RefactoringProcessors.java3
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameEnumConstProcessor.java4
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameFieldProcessor.java15
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameJavaProjectProcessor.java2
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameLocalVariableProcessor.java6
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodProcessor.java6
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenamePackageProcessor.java8
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeParameterProcessor.java2
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeProcessor.java10
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RippleMethodFinder2.java2
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/DeleteChangeCreator.java7
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/JavaDeleteProcessor.java12
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgDestinationFactory.java3
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgPolicyFactory.java24
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/scripting/InlineMethodRefactoringContribution.java4
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/sef/SelfEncapsulateFieldRefactoring.java12
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeSignatureProcessor.java20
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeTypeRefactoring.java6
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceProcessor.java12
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractSupertypeProcessor.java20
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoringProcessor.java18
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/UseSuperTypeProcessor.java2
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeRefactoringProcessor.java17
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeSet.java3
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/SurroundWithTryWithResourcesAnalyzer.java10
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/SurroundWithTryWithResourcesRefactoring.java9
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/typeconstraints/ConstraintOperator.java2
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/Changes.java3
-rw-r--r--org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/QualifiedNameFinder.java2
-rw-r--r--org.eclipse.jdt.ui/dictionaries/en_GB.dictionary1
-rw-r--r--org.eclipse.jdt.ui/dictionaries/en_US.dictionary1
-rw-r--r--org.eclipse.jdt.ui/forceQualifierUpdate.txt3
-rw-r--r--org.eclipse.jdt.ui/internal compatibility/org/eclipse/jdt/internal/ui/dialogs/TypeSelectionDialog2.java2
-rw-r--r--org.eclipse.jdt.ui/jar in jar loader/org/eclipse/jdt/internal/jarinjarloader/JIJConstants.java3
-rw-r--r--org.eclipse.jdt.ui/jar in jar loader/org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader.java4
-rw-r--r--org.eclipse.jdt.ui/plugin.properties5
-rw-r--r--org.eclipse.jdt.ui/plugin.xml32
-rw-r--r--org.eclipse.jdt.ui/pom.xml4
-rw-r--r--org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/DelegateUIHelper.java2
-rw-r--r--org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ExtractClassWizard.java2
-rw-r--r--org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ExtractConstantWizard.java26
-rw-r--r--org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/IntroduceParameterObjectWizard.java6
-rw-r--r--org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/MoveMembersWizard.java2
-rw-r--r--org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/RefactoringSavePreferences.java3
-rw-r--r--org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/UserInterfaceManager.java4
-rw-r--r--org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/actions/RefactoringActions.java3
-rw-r--r--org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/contentassist/ControlContentAssistHelper.java3
-rw-r--r--org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/contentassist/JavaTypeCompletionProcessor.java3
-rw-r--r--org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/search/SearchBrokenNLSKeysUtil.java3
-rw-r--r--org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/DeleteAction.java7
-rw-r--r--org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/RenameInputWizardPage.java2
-rw-r--r--org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/ReorgQueries.java11
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/InterfaceIndicatorLabelDecorator.java8
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java4
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CleanUpAction.java7
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/EnablePreviewFeaturesAction.java164
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/FindBrokenNLSKeysAction.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/OpenBrowserUtil.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/PackagesViewFlatContentProvider.java40
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/PackagesViewHierarchicalContentProvider.java38
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsConfigurationBlock.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchUtil.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SelectFieldModeAction.java31
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/TreeTermination.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/compare/JavaCompareUtilities.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java6
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/GenerateToStringDialog.java20
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/MultiElementListSelectionDialog.java29
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/SourceActionDialog.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/StatusUtil.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/TextFieldNavigationHandler.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/filters/FilterDescriptor.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/AutoboxingCleanUp.java10
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/ConvertLoopCleanUp.java29
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/LambdaExpressionAndMethodRefCleanUp.java1
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/LazyLogicalCleanUp.java1
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/MapMethodCleanUp.java1
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/MergeConditionalBlocksCleanUp.java237
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/NumberSuffixCleanUp.java1
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/PushDownNegationCleanUp.java9
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantModifiersCleanUp.java1
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantSemicolonsCleanUp.java1
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/SortMembersCleanUp.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnboxingCleanUp.java1
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnimplementedCodeCleanUp.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnnecessaryArrayCreationCleanUp.java14
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/VarCleanUp.java10
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarFileExportOperation.java8
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarManifestWizardPage.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackagerfat/JIJConstants.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocTreeWizardPage.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocWizard.java14
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClipboardOperationAction.java33
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java57
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/EditorUtility.java7
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java135
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementDeclaredTypeHyperlink.java42
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSourceViewer.java18
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDetails.java6
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDropDown.java12
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/navigator/PackageExplorerOpenActionProvider.java52
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/HierarchicalDecorationContext.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/WorkingSetAwareContentProvider.java18
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java7
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistFavoritesConfigurationBlock.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeTemplateBlock.java178
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilteredPreferenceTree.java6
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ImportOrganizeConfigurationBlock.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ImportOrganizeInputDialog.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorCodeMiningConfigurationBlock.java9
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferenceCache.java20
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferencePage.java10
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/NameConventionConfigurationBlock.java1
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/NewJavaProjectPreferencePage.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/OptionsConfigurationBlock.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java1
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties1
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/SmartTypingConfigurationBlock.java20
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/TodoTaskConfigurationBlock.java17
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/UserLibraryPreferencePage.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/AbstractCleanUpTabPage.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties5
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeStyleTabPage.java7
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/UnnecessaryCodeTabPage.java7
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileEscapes.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileSourceViewerConfiguration.java18
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesQuickAssistProcessor.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/MatchLocations.java25
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/PatternStrings.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchUtil.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/ContentAssistPreference.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaHeuristicScanner.java105
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java20
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaWordFinder.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java4
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AdvancedQuickAssistProcessor.java28
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ConfigureProblemSeveritySubProcessor.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/DefaultClasspathFixProcessor.java4
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/DefaultModulepathFixProcessor.java9
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/GetterSetterCorrectionSubProcessor.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessor.java102
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java26
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java7
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModuleCorrectionsSubProcessor.java7
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/NameMatcher.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/NullAnnotationsCorrectionProcessor.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/PreviewFeaturesSubProcessor.java22
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java162
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickFixProcessor.java4
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ReorgCorrectionsSubProcessor.java6
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ReturnTypeSubProcessor.java48
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SerialVersionSubProcessor.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java8
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeAnnotationSubProcessor.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeArgumentMismatchSubProcessor.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java62
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnInitializedFinalFieldSubProcessor.java10
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java15
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/VarargsWarningsSubProcessor.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/InitializeFinalFieldProposal.java290
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/NewCUUsingWizardProposal.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/RemoveDeclarationCorrectionProposal.java61
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java6
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ChainCompletionTemplateBuilder.java4
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalComputerDescriptor.java4
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaDoubleClickSelector.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/LazyGenericTypeProposal.java13
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ParameterGuessingProposal.java103
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/PostfixCompletionProposalComputer.java8
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/RelevanceComputer.java6
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/ConfigureProblemSeverityAction.java19
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDoc2HTMLTextReader.java124
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java160
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/WordQuickFixProcessor.java4
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/contentassist/PostfixTemplateProposal.java4
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/contentassist/TemplateProposal.java8
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/ClasspathVMUtil.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/CoreUtility.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/JavaUIHelp.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/SWTUtil.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/SelectionUtil.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderWizardPage.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/AccessRulesDialog.java23
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildpathProblemMarkerResolutionGenerator.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java64
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/ClasspathModifierQueries.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/dialogfields/LayoutUtil.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/Mementos.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetModel.java4
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaUI.java4
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/ProblemsLabelDecorator.java22
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/AddGetterSetterAction.java3
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/CustomFiltersActionGroup.java2
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindAction.java6
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java55
-rwxr-xr-xorg.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java7
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalLabelProvider.java6
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewRecordWizardPage.java87
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewTypeWizardPage.java4
-rw-r--r--org.eclipse.ltk.core.refactoring.tests/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.ltk.core.refactoring.tests/pom.xml4
-rw-r--r--org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/AllTests.java28
-rw-r--r--org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/history/RefactoringHistoryTests.java20
-rw-r--r--org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/participants/ParticipantTests.java22
-rw-r--r--org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/resource/ResourceRefactoringTests.java67
-rw-r--r--org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/resource/ResourceRefactoringUndoTests.java42
-rw-r--r--org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/scripting/RefactoringScriptingTests.java18
-rw-r--r--org.eclipse.ltk.core.refactoring/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.ltk.core.refactoring/pom.xml6
-rw-r--r--org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/participants/IRenameResourceProcessor.java67
-rw-r--r--org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/Changes.java3
-rw-r--r--org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/ContentStamps.java3
-rw-r--r--org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/Messages.java2
-rw-r--r--org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringSessionTransformer.java3
-rw-r--r--org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringHistoryService.java3
-rw-r--r--org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/resource/RenameResourceProcessor.java11
-rw-r--r--org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/resource/ResourceProcessors.java3
-rw-r--r--org.eclipse.ltk.ui.refactoring.tests/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.ltk.ui.refactoring.tests/pom.xml4
-rw-r--r--org.eclipse.ltk.ui.refactoring.tests/src/org/eclipse/ltk/ui/refactoring/examples/DeleteResourcesRefactoringAction.java3
-rw-r--r--org.eclipse.ltk.ui.refactoring.tests/src/org/eclipse/ltk/ui/refactoring/tests/AllTests.java17
-rw-r--r--org.eclipse.ltk.ui.refactoring/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.ltk.ui.refactoring/pom.xml6
-rw-r--r--org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/Messages.java2
-rw-r--r--org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/PreviewWizardPage.java3
-rw-r--r--org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/RefactoringPluginImages.java3
-rw-r--r--org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/actions/RenameResourceHandler.java4
-rw-r--r--org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/RefactoringWizard.java4
-rw-r--r--org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/history/RefactoringHistoryLabelProvider.java5
-rw-r--r--org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/history/RefactoringHistoryWizard.java3
-rw-r--r--org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/resource/RenameResourceWizard.java48
-rw-r--r--pom.xml4
-rw-r--r--tests-pom/pom.xml4
644 files changed, 12384 insertions, 8741 deletions
diff --git a/org.eclipse.jdt.astview.feature/feature.xml b/org.eclipse.jdt.astview.feature/feature.xml
index 83b41661ad..d32d974f7e 100644
--- a/org.eclipse.jdt.astview.feature/feature.xml
+++ b/org.eclipse.jdt.astview.feature/feature.xml
@@ -2,13 +2,13 @@
<feature
id="org.eclipse.jdt.astview.feature"
label="AST View"
- version="1.1.11.qualifier"
+ version="1.1.12.qualifier"
provider-name="Eclipse.org"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
<description>
- AST View for Eclipse 2019-12 and later (jdt.core 3.20)
+ AST View for Eclipse 2020-06 and later (jdt.core 3.22)
</description>
<license url="%licenseURL">
diff --git a/org.eclipse.jdt.astview.feature/pom.xml b/org.eclipse.jdt.astview.feature/pom.xml
index e30b2b71c2..f9c439124d 100644
--- a/org.eclipse.jdt.astview.feature/pom.xml
+++ b/org.eclipse.jdt.astview.feature/pom.xml
@@ -14,10 +14,10 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt.feature</groupId>
<artifactId>org.eclipse.jdt.astview.feature</artifactId>
- <version>1.1.11-SNAPSHOT</version>
+ <version>1.1.12-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
</project>
diff --git a/org.eclipse.jdt.astview/META-INF/MANIFEST.MF b/org.eclipse.jdt.astview/META-INF/MANIFEST.MF
index b3345ae09c..3971f2707d 100644
--- a/org.eclipse.jdt.astview/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.astview/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.astview
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.astview; singleton:=true
-Bundle-Version: 1.4.300.qualifier
+Bundle-Version: 1.4.400.qualifier
Eclipse-SourceReferences: scm:git:git://git.eclipse.org/gitroot/jdt/eclipse.jdt.ui.git;path="org.eclipse.jdt.astview";tag=R4_4
Bundle-Activator: org.eclipse.jdt.astview.ASTViewPlugin
Bundle-Vendor: %providerName
diff --git a/org.eclipse.jdt.astview/pom.xml b/org.eclipse.jdt.astview/pom.xml
index e0cf67c3ea..ce48c7014c 100644
--- a/org.eclipse.jdt.astview/pom.xml
+++ b/org.eclipse.jdt.astview/pom.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (c) 2012, 2019 Eclipse Foundation and others.
+ Copyright (c) 2012, 2020 Eclipse Foundation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
@@ -14,10 +14,10 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.astview</artifactId>
- <version>1.4.300-SNAPSHOT</version>
+ <version>1.4.400-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/ASTViewImages.java b/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/ASTViewImages.java
index e214266d11..b0b64d7ad6 100644
--- a/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/ASTViewImages.java
+++ b/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/ASTViewImages.java
@@ -69,4 +69,7 @@ public class ASTViewImages {
}
return null;
}
+
+ private ASTViewImages() {
+ }
}
diff --git a/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewContentProvider.java b/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewContentProvider.java
index 4190bfac5b..dc360fa2ba 100644
--- a/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewContentProvider.java
+++ b/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewContentProvider.java
@@ -213,8 +213,7 @@ public class ASTViewContentProvider implements ITreeContentProvider {
List<StructuralPropertyDescriptor> list= node.structuralPropertiesForType();
- for (int i= 0; i < list.size(); i++) {
- StructuralPropertyDescriptor curr= list.get(i);
+ for (StructuralPropertyDescriptor curr : list) {
res.add(new NodeProperty(node, curr));
}
diff --git a/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/Binding.java b/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/Binding.java
index 878525fb03..b1384aec04 100644
--- a/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/Binding.java
+++ b/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/Binding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -96,6 +96,7 @@ public class Binding extends ASTAttribute {
res.add(new BindingProperty(this, "IS FIELD", variableBinding.isField(), true)); //$NON-NLS-1$
res.add(new BindingProperty(this, "IS ENUM CONSTANT", variableBinding.isEnumConstant(), true)); //$NON-NLS-1$
res.add(new BindingProperty(this, "IS PARAMETER", variableBinding.isParameter(), true)); //$NON-NLS-1$
+ res.add(new BindingProperty(this, "IS RECORD COMPONENT", variableBinding.isRecordComponent(), true)); //$NON-NLS-1$
res.add(new BindingProperty(this, "VARIABLE ID", variableBinding.getVariableId(), true)); //$NON-NLS-1$
res.add(new BindingProperty(this, "MODIFIERS", getModifiersString(fBinding.getModifiers(), false), true)); //$NON-NLS-1$
res.add(new Binding(this, "TYPE", variableBinding.getType(), true)); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ProblemNode.java b/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ProblemNode.java
index a704a8b6dd..87d43d07bb 100644
--- a/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ProblemNode.java
+++ b/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ProblemNode.java
@@ -118,8 +118,7 @@ public class ProblemNode extends ASTAttribute {
if (f.getType() == int.class && f.getInt(f) == id) {
return "IProblem." + f.getName();
}
- } catch (IllegalArgumentException e) {
- } catch (IllegalAccessException e) {
+ } catch (IllegalArgumentException | IllegalAccessException e) {
}
}
return "<UNKNOWN CONSTANT>";
diff --git a/org.eclipse.jdt.core.manipulation/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.manipulation/META-INF/MANIFEST.MF
index 411747707f..c95568b57e 100644
--- a/org.eclipse.jdt.core.manipulation/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core.manipulation/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.core.manipulation
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core.manipulation; singleton:=true
-Bundle-Version: 1.14.0.qualifier
+Bundle-Version: 1.14.100.qualifier
Bundle-Vendor: %providerName
Bundle-Activator: org.eclipse.jdt.internal.core.manipulation.JavaManipulationPlugin
Bundle-Localization: plugin
@@ -60,5 +60,4 @@ Export-Package: org.eclipse.jdt.core.manipulation,
org.eclipse.jdt.internal.ui.text.correction.proposals;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.ui.text.template.contentassist;x-friends:="org.eclipse.jdt.ui",
org.eclipse.jdt.internal.ui.util;x-friends:="org.eclipse.jdt.ui"
-Import-Package: com.ibm.icu.text;version="60.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/BindingLabelProviderCore.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/BindingLabelProviderCore.java
index 690e4cdfa7..d4185f5af7 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/BindingLabelProviderCore.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/BindingLabelProviderCore.java
@@ -332,4 +332,7 @@ public class BindingLabelProviderCore {
public static final long DEFAULT_TEXTFLAGS= JavaElementLabelsCore.ALL_DEFAULT;
+
+ private BindingLabelProviderCore() {
+ }
}
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/CodeTemplateContextType.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/CodeTemplateContextType.java
index 3d30e5d3ab..d2ab0ccefa 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/CodeTemplateContextType.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/CodeTemplateContextType.java
@@ -183,89 +183,108 @@ public class CodeTemplateContextType extends TemplateContextType {
addResolver(new GlobalTemplateVariables.User());
addResolver(new Todo());
- if (CATCHBLOCK_CONTEXTTYPE.equals(contextName)) {
+ if (contextName == null) {
+ return;
+ }
+
+ switch (contextName) {
+ case CATCHBLOCK_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingtype));
addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingmethod));
-
addResolver(new CodeTemplateVariableResolver(EXCEPTION_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_exceptiontype));
addResolver(new CodeTemplateVariableResolver(EXCEPTION_VAR, JavaManipulationMessages.CodeTemplateContextType_variable_description_exceptionvar));
- } else if (METHODBODY_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case METHODBODY_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingtype));
addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingmethod));
addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT, JavaManipulationMessages.CodeTemplateContextType_variable_description_bodystatement));
- } else if (CONSTRUCTORBODY_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case CONSTRUCTORBODY_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingtype));
addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT, JavaManipulationMessages.CodeTemplateContextType_variable_description_bodystatement));
- } else if (GETTERBODY_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case GETTERBODY_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingtype));
addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingmethod));
addResolver(new CodeTemplateVariableResolver(FIELD, JavaManipulationMessages.CodeTemplateContextType_variable_description_getterfieldname));
- } else if (SETTERBODY_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case SETTERBODY_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingtype));
addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingmethod));
addResolver(new CodeTemplateVariableResolver(FIELD, JavaManipulationMessages.CodeTemplateContextType_variable_description_getterfieldname));
addResolver(new CodeTemplateVariableResolver(PARAM, JavaManipulationMessages.CodeTemplateContextType_variable_description_param));
- } else if (NEWTYPE_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case NEWTYPE_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(TYPENAME, JavaManipulationMessages.CodeTemplateContextType_variable_description_typename));
addResolver(new CodeTemplateVariableResolver(PACKAGE_DECLARATION, JavaManipulationMessages.CodeTemplateContextType_variable_description_packdeclaration));
addResolver(new CodeTemplateVariableResolver(TYPE_DECLARATION, JavaManipulationMessages.CodeTemplateContextType_variable_description_typedeclaration));
addResolver(new CodeTemplateVariableResolver(TYPE_COMMENT, JavaManipulationMessages.CodeTemplateContextType_variable_description_typecomment));
addResolver(new CodeTemplateVariableResolver(FILE_COMMENT, JavaManipulationMessages.CodeTemplateContextType_variable_description_filecomment));
addCompilationUnitVariables();
- } else if (CLASSBODY_CONTEXTTYPE.equals(contextName) ||
- INTERFACEBODY_CONTEXTTYPE.equals(contextName) ||
- ENUMBODY_CONTEXTTYPE.equals(contextName) ||
- ANNOTATIONBODY_CONTEXTTYPE.equals(contextName) ||
- RECORDBODY_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case CLASSBODY_CONTEXTTYPE:
+ case INTERFACEBODY_CONTEXTTYPE:
+ case ENUMBODY_CONTEXTTYPE:
+ case ANNOTATIONBODY_CONTEXTTYPE:
+ case RECORDBODY_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(TYPENAME, JavaManipulationMessages.CodeTemplateContextType_variable_description_typename));
addCompilationUnitVariables();
- } else if (TYPECOMMENT_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case TYPECOMMENT_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(TYPENAME, JavaManipulationMessages.CodeTemplateContextType_variable_description_typename));
addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingtype));
addResolver(new TagsVariableResolver());
addCompilationUnitVariables();
fIsComment= true;
- } else if (FILECOMMENT_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case FILECOMMENT_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(TYPENAME, JavaManipulationMessages.CodeTemplateContextType_variable_description_typename));
addCompilationUnitVariables();
fIsComment= true;
- } else if (FIELDCOMMENT_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case FIELDCOMMENT_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(FIELD_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_fieldtype));
addResolver(new CodeTemplateVariableResolver(FIELD, JavaManipulationMessages.CodeTemplateContextType_variable_description_fieldname));
addCompilationUnitVariables();
fIsComment= true;
- } else if (METHODCOMMENT_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case METHODCOMMENT_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingtype));
addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingmethod));
addResolver(new CodeTemplateVariableResolver(RETURN_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_returntype));
addResolver(new TagsVariableResolver());
addCompilationUnitVariables();
fIsComment= true;
- } else if (MODULECOMMENT_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case MODULECOMMENT_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(ENCLOSING_MODULE, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingmodule));
addResolver(new TagsVariableResolver());
addCompilationUnitVariables();
fIsComment= true;
- } else if (OVERRIDECOMMENT_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case OVERRIDECOMMENT_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingtype));
addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingmethod));
addResolver(new CodeTemplateVariableResolver(SEE_TO_OVERRIDDEN_TAG, JavaManipulationMessages.CodeTemplateContextType_variable_description_see_overridden_tag));
addResolver(new TagsVariableResolver());
addCompilationUnitVariables();
fIsComment= true;
- } else if (DELEGATECOMMENT_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case DELEGATECOMMENT_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingtype));
addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingmethod));
addResolver(new CodeTemplateVariableResolver(SEE_TO_TARGET_TAG, JavaManipulationMessages.CodeTemplateContextType_variable_description_see_target_tag));
addResolver(new TagsVariableResolver());
addCompilationUnitVariables();
fIsComment= true;
- } else if (CONSTRUCTORCOMMENT_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case CONSTRUCTORCOMMENT_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingtype));
addResolver(new TagsVariableResolver());
addCompilationUnitVariables();
fIsComment= true;
- } else if (GETTERCOMMENT_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case GETTERCOMMENT_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingtype));
addResolver(new CodeTemplateVariableResolver(FIELD_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_getterfieldtype));
addResolver(new CodeTemplateVariableResolver(FIELD, JavaManipulationMessages.CodeTemplateContextType_variable_description_getterfieldname));
@@ -273,7 +292,8 @@ public class CodeTemplateContextType extends TemplateContextType {
addResolver(new CodeTemplateVariableResolver(BARE_FIELD_NAME, JavaManipulationMessages.CodeTemplateContextType_variable_description_barefieldname));
addCompilationUnitVariables();
fIsComment= true;
- } else if (SETTERCOMMENT_CONTEXTTYPE.equals(contextName)) {
+ break;
+ case SETTERCOMMENT_CONTEXTTYPE:
addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_enclosingtype));
addResolver(new CodeTemplateVariableResolver(FIELD_TYPE, JavaManipulationMessages.CodeTemplateContextType_variable_description_getterfieldtype));
addResolver(new CodeTemplateVariableResolver(FIELD, JavaManipulationMessages.CodeTemplateContextType_variable_description_getterfieldname));
@@ -282,6 +302,9 @@ public class CodeTemplateContextType extends TemplateContextType {
addResolver(new CodeTemplateVariableResolver(BARE_FIELD_NAME, JavaManipulationMessages.CodeTemplateContextType_variable_description_barefieldname));
addCompilationUnitVariables();
fIsComment= true;
+ break;
+ default:
+ break;
}
}
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/JavaManipulationPlugin.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/JavaManipulationPlugin.java
index 3bdb56ec28..0d1a677f87 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/JavaManipulationPlugin.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/JavaManipulationPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -30,6 +30,9 @@ import org.eclipse.jdt.core.manipulation.JavaManipulation;
*/
public class JavaManipulationPlugin extends Plugin implements DebugOptionsListener {
+ public static final boolean CODEASSIST_SUBSTRING_MATCH_ENABLED= //
+ Boolean.parseBoolean(System.getProperty("jdt.codeCompleteSubstringMatch", "true")); //$NON-NLS-1$//$NON-NLS-2$
+
public static boolean DEBUG_AST_PROVIDER;
//The shared instance.
@@ -41,7 +44,7 @@ public class JavaManipulationPlugin extends Plugin implements DebugOptionsListen
* The constructor.
*/
public JavaManipulationPlugin() {
- fgDefault = this;
+ fgDefault= this;
}
@Override
@@ -52,7 +55,7 @@ public class JavaManipulationPlugin extends Plugin implements DebugOptionsListen
@Override
public void stop(BundleContext context) throws Exception {
super.stop(context);
- fgDefault = null;
+ fgDefault= null;
}
/**
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/Messages.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/Messages.java
index e02744a4fb..5d4732b955 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/Messages.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/Messages.java
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.core.manipulation;
-import com.ibm.icu.text.MessageFormat;
+import java.text.MessageFormat;
/**
* Helper class to format message strings.
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/StubUtility.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/StubUtility.java
index a45252c184..832c1ea450 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/StubUtility.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/core/manipulation/StubUtility.java
@@ -1578,4 +1578,7 @@ public class StubUtility {
return rewrite;
}
+ private StubUtility() {
+ }
+
}
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/JdtViewerDropAdapterConstants.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/JdtViewerDropAdapterConstants.java
index 7c944a861c..577efa887e 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/JdtViewerDropAdapterConstants.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/JdtViewerDropAdapterConstants.java
@@ -44,4 +44,7 @@ public class JdtViewerDropAdapterConstants {
*/
public static final int LOCATION_NONE = 4;
+ private JdtViewerDropAdapterConstants() {
+ }
+
}
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.java
index b5057b18db..88897598a3 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.java
@@ -79,6 +79,7 @@ public class MultiFixMessages extends NLS {
public static String Java50MultiFix_AddMissingDeprecated_description;
public static String Java50MultiFix_AddMissingOverride_description;
public static String Java50MultiFix_AddMissingOverride_description2;
+ public static String Java50CleanUp_ConvertLoopOnlyIfLoopVarUsed_description;
public static String Java50CleanUp_ConvertToEnhancedForLoop_description;
public static String Java50CleanUp_AddTypeParameters_description;
@@ -121,6 +122,7 @@ public class MultiFixMessages extends NLS {
public static String AutoboxingCleanup_description;
public static String UnboxingCleanup_description;
public static String PushDownNegationCleanup_description;
+ public static String MergeConditionalBlocksCleanup_description;
public static String UseDirectlyMapMethodCleanup_description;
public static String RedundantSemicolonsCleanup_description;
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties
index 5a38f34558..07c1160716 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/fix/MultiFixMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2005, 2019 IBM Corporation and others.
+# Copyright (c) 2005, 2020 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
@@ -49,6 +49,7 @@ CodeStyleMultiFix_ConvertSingleStatementInControlBodeyToBlock_description=Conver
Java50MultiFix_AddMissingDeprecated_description=Add missing '@Deprecated' annotations
Java50CleanUp_ConvertToEnhancedForLoop_description=Convert 'for' loops to enhanced 'for' loops
+Java50CleanUp_ConvertLoopOnlyIfLoopVarUsed_description=Convert to enhanced 'for' loops only if the loop variable is used
Java50CleanUp_AddTypeParameters_description=Add type arguments to raw type references
Java50MultiFix_AddMissingOverride_description=Add missing '@Override' annotations
Java50MultiFix_AddMissingOverride_description2=Add missing '@Override' annotations to implementations of interface methods
@@ -102,6 +103,7 @@ RedundantModifiersCleanup_description = Remove redundant modifiers
AutoboxingCleanup_description = Use Autoboxing
UnboxingCleanup_description = Use Unboxing
PushDownNegationCleanup_description = Push down negation
+MergeConditionalBlocksCleanup_description=Merge conditions of if/else if/else that have the same blocks
UseDirectlyMapMethodCleanup_description = Operate on Maps directly
RedundantSemicolonsCleanup_description= Remove redundant semicolons
UnnecessaryArrayCreationCleanup_description=Remove unnecessary array creation for varargs
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingsCore.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingsCore.java
index 9c204179d1..cfaf8bba11 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingsCore.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingsCore.java
@@ -178,6 +178,6 @@ public class SemanticHighlightingsCore {
/**
* Do not instantiate
*/
- protected SemanticHighlightingsCore() {
+ private SemanticHighlightingsCore() {
}
}
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/preferences/JavaPreferencesSettings.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/preferences/JavaPreferencesSettings.java
index 5a21e89ba8..27c0c15d8c 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/preferences/JavaPreferencesSettings.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/preferences/JavaPreferencesSettings.java
@@ -34,5 +34,8 @@ public class JavaPreferencesSettings {
return res;
}
+ private JavaPreferencesSettings() {
+ }
+
}
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/JavaBreakIterator.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/JavaBreakIterator.java
index c9e571837c..93d481cf3f 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/JavaBreakIterator.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/JavaBreakIterator.java
@@ -13,10 +13,9 @@
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text;
+import java.text.BreakIterator;
import java.text.CharacterIterator;
-import com.ibm.icu.text.BreakIterator;
-
import org.eclipse.core.runtime.Assert;
@@ -422,7 +421,6 @@ public class JavaBreakIterator extends BreakIterator {
* Creates a break iterator given a char sequence.
* @param newText the new text
*/
- @Override
public void setText(CharSequence newText) {
fText= newText;
fIterator.setText(new SequenceCharacterIterator(newText));
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/JavaWordIterator.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/JavaWordIterator.java
index 4e2ca38b70..48d2609516 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/JavaWordIterator.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/JavaWordIterator.java
@@ -13,10 +13,9 @@
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text;
+import java.text.BreakIterator;
import java.text.CharacterIterator;
-import com.ibm.icu.text.BreakIterator;
-
import org.eclipse.core.runtime.Assert;
@@ -212,7 +211,6 @@ public class JavaWordIterator extends BreakIterator {
* Sets the text as <code>CharSequence</code>.
* @param newText the new text
*/
- @Override
public void setText(CharSequence newText) {
fIterator.setText(newText);
first();
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.java
index 1b81a942c6..2a5095c38b 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.java
@@ -178,12 +178,14 @@ public final class CorrectionMessages extends NLS {
public static String ReturnTypeSubProcessor_missingreturntype_description;
public static String ReturnTypeSubProcessor_wrongconstructorname_description;
public static String ReturnTypeSubProcessor_changetovoid_description;
+ public static String ReturnTypeSubProcessor_changeReturnToYield_description;
public static String MissingReturnTypeCorrectionProposal_addreturnstatement_description;
public static String MissingReturnTypeCorrectionProposal_changereturnstatement_description;
public static String TypeArgumentMismatchSubProcessor_removeTypeArguments;
public static String InitializeFieldAtDeclarationCorrectionProposal_description;
public static String InitializeFieldInConstructorCorrectionProposal_description;
+ public static String InitializeFieldWithConstructorParameterCorrectionProposal_description;
public static String UnimplementedMethodsCorrectionProposal_description;
public static String UnimplementedMethodsCorrectionProposal_enum_info;
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties
index a8fcce6f91..7602ca2005 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/CorrectionMessages.properties
@@ -198,6 +198,7 @@ ReturnTypeSubProcessor_voidmethodreturns_description=Change method return type t
ReturnTypeSubProcessor_removereturn_description=Change to 'return;'
ReturnTypeSubProcessor_missingreturntype_description=Set method return type to ''{0}''
ReturnTypeSubProcessor_wrongconstructorname_description=Change to constructor
+ReturnTypeSubProcessor_changeReturnToYield_description=Change to 'yield' statement
ReturnTypeSubProcessor_changetovoid_description=Change return type to 'void'
@@ -322,6 +323,7 @@ NewCUCompletionUsingWizardProposal_createannotation_info=Opens the new annotatio
InitializeFieldAtDeclarationCorrectionProposal_description=Initialize final field ''{0}'' at declaration.
InitializeFieldInConstructorCorrectionProposal_description=Initialize final field ''{0}'' in constructor.
+InitializeFieldWithConstructorParameterCorrectionProposal_description=Initialize final field ''{0}'' to new constructor parameter.
UnimplementedMethodsCorrectionProposal_description=Add unimplemented methods
UnimplementedMethodsCorrectionProposal_enum_info=Adding all method required in enum constant declarations.
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessorCore.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessorCore.java
index 353f0c86b3..67f66d793d 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessorCore.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessorCore.java
@@ -182,4 +182,7 @@ public class JavadocTagsSubProcessorCore {
return null;
}
+ private JavadocTagsSubProcessorCore() {
+ }
+
}
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessorCore.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessorCore.java
index 3ebbabe95e..503db55061 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessorCore.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessorCore.java
@@ -137,4 +137,7 @@ public class ModifierCorrectionSubProcessorCore {
}
return null;
}
+
+ private ModifierCorrectionSubProcessorCore() {
+ }
}
diff --git a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/SerialVersionHashOperationCore.java b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/SerialVersionHashOperationCore.java
index bac2506006..a97a685e6d 100644
--- a/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/SerialVersionHashOperationCore.java
+++ b/org.eclipse.jdt.core.manipulation/common/org/eclipse/jdt/internal/ui/text/correction/SerialVersionHashOperationCore.java
@@ -185,7 +185,7 @@ public final class SerialVersionHashOperationCore extends AbstractSerialVersionO
private static char[][] getSortedInterfacesNames(IClassFileReader cfReader) {
char[][] interfaceNames= cfReader.getInterfaceNames();
- Arrays.sort(interfaceNames, (o1, o2) -> CharOperation.compareTo(o1, o2));
+ Arrays.sort(interfaceNames, CharOperation::compareTo);
return interfaceNames;
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/ASTResolving.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/ASTResolving.java
index ae2db506fd..ba595df352 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/ASTResolving.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/ASTResolving.java
@@ -61,7 +61,6 @@ import org.eclipse.jdt.core.dom.ParameterizedType;
import org.eclipse.jdt.core.dom.PrefixExpression;
import org.eclipse.jdt.core.dom.PrimitiveType;
import org.eclipse.jdt.core.dom.PrimitiveType.Code;
-import org.eclipse.jdt.core.manipulation.TypeKinds;
import org.eclipse.jdt.core.dom.QualifiedName;
import org.eclipse.jdt.core.dom.QualifiedType;
import org.eclipse.jdt.core.dom.SimpleName;
@@ -85,6 +84,7 @@ 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.WildcardType;
+import org.eclipse.jdt.core.manipulation.TypeKinds;
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.dom.Bindings;
@@ -103,7 +103,12 @@ import org.eclipse.jdt.internal.ui.util.ASTHelper;
// @see org.eclipse.jdt.internal.ui.text.correction.ASTResolving (subclass of this one)
public class ASTResolving {
+ @SuppressWarnings("nls")
public static ITypeBinding guessBindingForReference(ASTNode node) {
+ String i= "";
+ if ((((i))).equals(((("a"))))) {
+ return Bindings.normalizeTypeBinding(null);
+ }
return Bindings.normalizeTypeBinding(getPossibleReferenceBinding(node));
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/NecessaryParenthesesChecker.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/NecessaryParenthesesChecker.java
index c3e22a4a18..889ad82861 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/NecessaryParenthesesChecker.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/NecessaryParenthesesChecker.java
@@ -43,6 +43,8 @@ import org.eclipse.jdt.core.dom.ThrowStatement;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.dom.WhileStatement;
+import org.eclipse.jdt.internal.corext.dom.ASTNodes;
+
/**
* Helper class to check if an expression requires parentheses.
*
@@ -50,19 +52,6 @@ import org.eclipse.jdt.core.dom.WhileStatement;
* @since 3.7
*/
public class NecessaryParenthesesChecker {
-
- /*
- * Get the expression wrapped by the parentheses
- * i.e. ((((expression)))) -> expression
- */
- private static Expression getExpression(ParenthesizedExpression node) {
- Expression expression= node.getExpression();
- while (expression instanceof ParenthesizedExpression) {
- expression= ((ParenthesizedExpression)expression).getExpression();
- }
- return expression;
- }
-
private static boolean expressionTypeNeedsParentheses(Expression expression) {
int type= expression.getNodeType();
return type == ASTNode.INFIX_EXPRESSION
@@ -286,7 +275,7 @@ public class NecessaryParenthesesChecker {
if (!(expression instanceof ParenthesizedExpression)) {
return false;
}
- return !needsParentheses(getExpression((ParenthesizedExpression)expression), parent, locationInParent);
+ return !needsParentheses(ASTNodes.getUnparenthesedExpression(expression), parent, locationInParent);
}
/**
@@ -418,4 +407,7 @@ public class NecessaryParenthesesChecker {
}
return false;
}
+
+ private NecessaryParenthesesChecker() {
+ }
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/OperatorPrecedence.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/OperatorPrecedence.java
index ec204ba920..a02caacc9a 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/OperatorPrecedence.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/core/manipulation/dom/OperatorPrecedence.java
@@ -137,4 +137,7 @@ public class OperatorPrecedence {
}
return Integer.MAX_VALUE;
}
+
+ private OperatorPrecedence() {
+ }
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/CorextCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/CorextCore.java
index 17f425156a..e056b02071 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/CorextCore.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/CorextCore.java
@@ -24,4 +24,7 @@ public class CorextCore {
public static String getPluginId() {
return JavaManipulationPlugin.getPluginId();
}
+
+ private CorextCore() {
+ }
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/SourceRangeFactory.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/SourceRangeFactory.java
index 1da179e858..c90716f9fc 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/SourceRangeFactory.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/SourceRangeFactory.java
@@ -30,4 +30,7 @@ public class SourceRangeFactory {
return new SourceRange(problem.getSourceStart(), problem.getSourceEnd() - problem.getSourceStart() + 1);
}
+ private SourceRangeFactory() {
+ }
+
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/CodeGenerationSettingsConstants.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/CodeGenerationSettingsConstants.java
index 6e57b46164..3b98d39407 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/CodeGenerationSettingsConstants.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/CodeGenerationSettingsConstants.java
@@ -51,5 +51,8 @@ public class CodeGenerationSettingsConstants {
*/
public static final String ORGIMPORTS_IGNORELOWERCASE= "org.eclipse.jdt.ui.ignorelowercasenames"; //$NON-NLS-1$
+ private CodeGenerationSettingsConstants() {
+ }
+
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/CustomBuilderGenerator.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/CustomBuilderGenerator.java
index 1ab9a9c022..bc916f778f 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/CustomBuilderGenerator.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/tostringgeneration/CustomBuilderGenerator.java
@@ -83,7 +83,7 @@ import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
*/
public class CustomBuilderGenerator extends AbstractToStringGenerator {
- private final List<String> primitiveTypes= Arrays.asList(new String[] { "byte", "short", "char", "int", "long", "float", "double", "boolean" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
+ private final List<String> primitiveTypes= Arrays.asList("byte", "short", "char", "int", "long", "float", "double", "boolean"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
private final String[] wrapperTypes= new String[] { "java.lang.Byte", "java.lang.Short", "java.lang.Character", "java.lang.Integer", "java.lang.Long", "java.lang.Float", "java.lang.Double", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
"java.lang.Boolean" }; //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodeFactory.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodeFactory.java
index a0523b874e..8148f2ab6f 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodeFactory.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodeFactory.java
@@ -40,6 +40,7 @@ import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.NodeFinder;
import org.eclipse.jdt.core.dom.ParameterizedType;
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
+import org.eclipse.jdt.core.dom.PrefixExpression;
import org.eclipse.jdt.core.dom.PrimitiveType;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.Type;
@@ -48,6 +49,7 @@ import org.eclipse.jdt.core.dom.TypeParameter;
import org.eclipse.jdt.core.dom.UnionType;
import org.eclipse.jdt.core.dom.VariableDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.core.dom.rewrite.ImportRewrite;
import org.eclipse.jdt.core.dom.rewrite.ImportRewrite.ImportRewriteContext;
import org.eclipse.jdt.core.dom.rewrite.ImportRewrite.TypeLocation;
@@ -98,15 +100,40 @@ public class ASTNodeFactory {
*/
public static Expression parenthesizeIfNeeded(AST ast, Expression expression) {
switch (expression.getNodeType()) {
- case ASTNode.ASSIGNMENT:
- case ASTNode.CAST_EXPRESSION:
- case ASTNode.CONDITIONAL_EXPRESSION:
- case ASTNode.INFIX_EXPRESSION:
- case ASTNode.INSTANCEOF_EXPRESSION:
- return parenthesize(ast, expression);
-
- default:
- return expression;
+ case ASTNode.ANNOTATION_TYPE_DECLARATION:
+ case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION:
+ case ASTNode.ANONYMOUS_CLASS_DECLARATION:
+ case ASTNode.ARRAY_ACCESS:
+ case ASTNode.ARRAY_CREATION:
+ case ASTNode.ARRAY_INITIALIZER:
+ case ASTNode.BOOLEAN_LITERAL:
+ case ASTNode.CHARACTER_LITERAL:
+ case ASTNode.CLASS_INSTANCE_CREATION:
+ case ASTNode.CREATION_REFERENCE:
+ case ASTNode.EXPRESSION_METHOD_REFERENCE:
+ case ASTNode.FIELD_ACCESS:
+ case ASTNode.MEMBER_REF:
+ case ASTNode.METHOD_INVOCATION:
+ case ASTNode.METHOD_REF:
+ case ASTNode.NULL_LITERAL:
+ case ASTNode.NUMBER_LITERAL:
+ case ASTNode.PARENTHESIZED_EXPRESSION:
+ case ASTNode.POSTFIX_EXPRESSION:
+ case ASTNode.PREFIX_EXPRESSION:
+ case ASTNode.QUALIFIED_NAME:
+ case ASTNode.SIMPLE_NAME:
+ case ASTNode.STRING_LITERAL:
+ case ASTNode.SUPER_FIELD_ACCESS:
+ case ASTNode.SUPER_METHOD_INVOCATION:
+ case ASTNode.SUPER_METHOD_REFERENCE:
+ case ASTNode.THIS_EXPRESSION:
+ case ASTNode.TYPE_LITERAL:
+ case ASTNode.TYPE_METHOD_REFERENCE:
+ case ASTNode.VARIABLE_DECLARATION_EXPRESSION:
+ return expression;
+
+ default:
+ return parenthesize(ast, expression);
}
}
@@ -123,6 +150,52 @@ public class ASTNodeFactory {
return pe;
}
+ /**
+ * Builds a new {@link PrefixExpression} instance using the not operator ('!').
+ *
+ * @param ast The AST to create the resulting node with.
+ * @param expression the expression to negate
+ * @return a new prefix expression
+ */
+ public static Expression not(final AST ast, final Expression expression) {
+ final PrefixExpression prefixExpression= ast.newPrefixExpression();
+ prefixExpression.setOperator(PrefixExpression.Operator.NOT);
+ prefixExpression.setOperand(parenthesizeIfNeeded(ast, expression));
+ return prefixExpression;
+ }
+
+ /**
+ * Negates the provided expression and applies the provided copy operation on
+ * the returned expression.
+ *
+ * @param ast The AST to create the resulting node with.
+ * @param rewrite the rewrite
+ * @param expression the expression to negate
+ * @param isMove the copy operation to perform
+ * @return the negated expression, copied according to the copy operation
+ */
+ public static Expression negate(final AST ast, final ASTRewrite rewrite, final Expression expression, final boolean isMove) {
+ Expression exprNoParen= ASTNodes.getUnparenthesedExpression(expression);
+
+ if (exprNoParen.getNodeType() == ASTNode.PREFIX_EXPRESSION) {
+ PrefixExpression prefixExpression= (PrefixExpression) exprNoParen;
+
+ if (ASTNodes.hasOperator(prefixExpression, PrefixExpression.Operator.NOT)) {
+ if (isMove) {
+ return (Expression) rewrite.createMoveTarget(prefixExpression.getOperand());
+ } else {
+ return (Expression) rewrite.createCopyTarget(prefixExpression.getOperand());
+ }
+ }
+ }
+
+ if (isMove) {
+ return not(ast, (Expression) rewrite.createMoveTarget(expression));
+ } else {
+ return not(ast, (Expression) rewrite.createCopyTarget(expression));
+ }
+ }
+
public static ASTNode newStatement(AST ast, String content) {
StringBuilder buffer= new StringBuilder(STATEMENT_HEADER);
buffer.append(content);
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java
index e2f8b4ae2b..dc9b9dbeb9 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTNodes.java
@@ -26,6 +26,7 @@ package org.eclipse.jdt.internal.corext.dom;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -155,6 +156,7 @@ public class ASTNodes {
public static final int ERROR= 1 << 1;
public static final int INFO= 1 << 2;
public static final int PROBLEMS= WARNING | ERROR | INFO;
+ public static final int EXCESSIVE_OPERAND_NUMBER= 5;
private static final Message[] EMPTY_MESSAGES= new Message[0];
private static final IProblem[] EMPTY_PROBLEMS= new IProblem[0];
@@ -584,7 +586,7 @@ public class ASTNodes {
*/
public static boolean isPassiveWithoutFallingThrough(final ASTNode node) {
final ExprActivityVisitor visitor= new ExprActivityVisitor();
- visitor.visitNode(node);
+ visitor.traverseNodeInterruptibly(node);
return ExprActivity.PASSIVE_WITHOUT_FALLING_THROUGH.equals(visitor.getActivityLevel());
}
@@ -603,7 +605,11 @@ public class ASTNodes {
if (method.resolveMethodBinding() != null) {
return (method.resolveMethodBinding().getModifiers() & Modifier.STATIC) != 0;
- } else if ((calledType instanceof Name) && ((Name) calledType).resolveBinding().getKind() == IBinding.TYPE) {
+ }
+
+ if ((calledType instanceof Name)
+ && ((Name) calledType).resolveBinding() != null
+ && ((Name) calledType).resolveBinding().getKind() == IBinding.TYPE) {
return Boolean.TRUE;
}
@@ -755,6 +761,33 @@ public class ASTNodes {
}
/**
+ * Casts the provided statement to an object of the provided type if type
+ * matches.
+ *
+ * @param <T> the required statement type
+ * @param statement the statement to cast
+ * @param stmtClass the class representing the required statement type
+ * @return the provided statement as an object of the provided type if type matches, null otherwise
+ */
+ @SuppressWarnings("unchecked")
+ public static <T extends Statement> T as(final Statement statement, final Class<T> stmtClass) {
+ if (statement == null) {
+ return null;
+ }
+
+ List<Statement> statements= asList(statement);
+ if (statements.size() == 1) {
+ Statement oneStatement= statements.get(0);
+
+ if (stmtClass.isAssignableFrom(oneStatement.getClass())) {
+ return (T) oneStatement;
+ }
+ }
+
+ return null;
+ }
+
+ /**
* Casts the provided expression to an object of the provided type if type matches.
*
* @param <T> the required expression type
@@ -769,7 +802,9 @@ public class ASTNodes {
if (exprClass.isAssignableFrom(expression.getClass())) {
return (T) expression;
} else if (expression instanceof ParenthesizedExpression) {
- return as(((ParenthesizedExpression) expression).getExpression(), exprClass);
+ expression= ASTNodes.getUnparenthesedExpression(expression);
+
+ return as(expression, exprClass);
}
}
return null;
@@ -815,6 +850,31 @@ public class ASTNodes {
}
/**
+ * Returns the number of logical operands in the expression.
+ *
+ * @param node The expression
+ * @return the number of logical operands in the expression
+ */
+ public static int getNbOperands(final Expression node) {
+ InfixExpression infixExpression= as(node, InfixExpression.class);
+
+ if (infixExpression == null
+ || !hasOperator(infixExpression, InfixExpression.Operator.CONDITIONAL_AND, InfixExpression.Operator.CONDITIONAL_OR)
+ && (!hasOperator(infixExpression, InfixExpression.Operator.AND, InfixExpression.Operator.OR, InfixExpression.Operator.XOR)
+ || !hasType(infixExpression.getLeftOperand(), boolean.class.getCanonicalName(), Boolean.class.getCanonicalName()))) {
+ return 1;
+ }
+
+ int nbOperands= 0;
+
+ for (Expression operand : allOperands(infixExpression)) {
+ nbOperands+= getNbOperands(operand);
+ }
+
+ return nbOperands;
+ }
+
+ /**
* Returns the {@link Boolean} object constant value represented by the provided qualified name.
*
* @param qualifiedName the qualified name that must represent a Boolean object constant
@@ -1674,8 +1734,8 @@ public class ASTNodes {
* returned
*/
public static Expression getUnparenthesedExpression(Expression expression) {
- if (expression != null && expression.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION) {
- return getUnparenthesedExpression(((ParenthesizedExpression) expression).getExpression());
+ while (expression != null && expression.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION) {
+ expression= ((ParenthesizedExpression) expression).getExpression();
}
return expression;
}
@@ -2335,6 +2395,30 @@ public class ASTNodes {
* Type-safe variant of {@link ASTRewrite#createMoveTarget(ASTNode)}.
*
* @param rewrite ASTRewrite for the given node
+ * @param nodes the nodes to create a move placeholder for
+ * @return the new placeholder nodes
+ * @throws IllegalArgumentException if the node is null, or if the node
+ * is not part of the rewrite's AST
+ */
+ @SuppressWarnings("unchecked")
+ public static <T extends ASTNode> List<T> createMoveTarget(final ASTRewrite rewrite, final Collection<T> nodes) {
+ if (nodes != null) {
+ List<T> newNodes= new ArrayList<>(nodes.size());
+
+ for (T node : nodes) {
+ newNodes.add((T) rewrite.createMoveTarget(node));
+ }
+
+ return newNodes;
+ }
+
+ return null;
+ }
+
+ /**
+ * Type-safe variant of {@link ASTRewrite#createMoveTarget(ASTNode)}.
+ *
+ * @param rewrite ASTRewrite for the given node
* @param node the node to create a move placeholder for
* @return the new placeholder node
* @throws IllegalArgumentException if the node is null, or if the node
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/DimensionRewrite.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/DimensionRewrite.java
index e4ef250ec8..45e8df414a 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/DimensionRewrite.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/DimensionRewrite.java
@@ -99,4 +99,7 @@ public class DimensionRewrite {
}
}
+ private DimensionRewrite() {
+ }
+
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/InterruptibleVisitor.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/InterruptibleVisitor.java
index 1de1b6dac5..a9a8aa4346 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/InterruptibleVisitor.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/InterruptibleVisitor.java
@@ -21,11 +21,11 @@ import org.eclipse.jdt.core.dom.ASTVisitor;
*/
public class InterruptibleVisitor extends ASTVisitor {
/**
- * Visit the node.
+ * Traverse the node, silently swallowing {@link AbortSearchException}.
*
* @param node The visited node.
*/
- public void visitNode(ASTNode node) {
+ public void traverseNodeInterruptibly(ASTNode node) {
try {
node.accept(this);
} catch (AbortSearchException e) {
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/LinkedNodeFinder.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/LinkedNodeFinder.java
index 8e7cfde240..4dd92ef408 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/LinkedNodeFinder.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/LinkedNodeFinder.java
@@ -16,6 +16,7 @@ package org.eclipse.jdt.internal.corext.dom;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
@@ -50,7 +51,6 @@ public class LinkedNodeFinder {
public static SimpleName getAssociatedRecordComponentNode(SimpleName simpleName) {
SimpleName rcName= null;
- ASTNode parent= simpleName;
if (simpleName == null) {
return null;
}
@@ -58,6 +58,7 @@ public class LinkedNodeFinder {
return null;
}
IBinding binding= simpleName.resolveBinding();
+ IVariableBinding rcBinding= null;
if (binding instanceof IVariableBinding) {
IVariableBinding vbinding= (IVariableBinding) binding;
IVariableBinding bBinding= vbinding.getVariableDeclaration();
@@ -68,6 +69,11 @@ public class LinkedNodeFinder {
if (!typeBinding.isRecord()) {
return null;
}
+ int modifiers= bBinding.getModifiers();
+ if (Flags.isFinal(modifiers)
+ && !Flags.isStatic(modifiers)) {
+ rcBinding= bBinding;
+ }
} else if (binding instanceof IMethodBinding) {
IMethodBinding mBinding = (IMethodBinding)binding;
ITypeBinding typeBinding= mBinding.getDeclaringClass().getTypeDeclaration();
@@ -75,16 +81,37 @@ public class LinkedNodeFinder {
if (bBinding.getParameterTypes().length != 0 || !typeBinding.isRecord()) {
return null;
}
+ if (typeBinding.isRecord()) {
+ IVariableBinding varBindings[]= typeBinding.getDeclaredFields();
+ for (IVariableBinding varBinding : varBindings) {
+ String name= varBinding.getName();
+ if (simpleName.getIdentifier().equals(name)) {
+ int modifiers= varBinding.getModifiers();
+ if (bBinding.getReturnType().isEqualTo(varBinding.getType())
+ && Flags.isFinal(modifiers)
+ && !Flags.isStatic(modifiers)) {
+ rcBinding= varBinding;
+ break;
+ }
+ }
+ }
+ }
} else {
return null;
}
RecordDeclaration recordDeclaration= null;
- while(parent != null) {
- parent= parent.getParent();
- if (parent instanceof RecordDeclaration) {
- recordDeclaration= (RecordDeclaration) parent;
- break;
+ if (rcBinding != null) {
+ ITypeBinding typeBinding= rcBinding.getDeclaringClass().getTypeDeclaration();
+ if (typeBinding != null) {
+ ASTNode root= simpleName.getRoot();
+ if (root instanceof CompilationUnit) {
+ CompilationUnit astRoot= (CompilationUnit) root;
+ ASTNode foundNode= astRoot.findDeclaringNode(typeBinding);
+ if (foundNode instanceof RecordDeclaration) {
+ recordDeclaration= (RecordDeclaration) foundNode;
+ }
+ }
}
}
if (recordDeclaration != null) {
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/TypeRules.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/TypeRules.java
index e2cf86370a..a093bbbf26 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/TypeRules.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/TypeRules.java
@@ -138,4 +138,7 @@ public class TypeRules {
}
}
+ private TypeRules() {
+ }
+
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/VariableDeclarationRewrite.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/VariableDeclarationRewrite.java
index 8eb8be6dcc..2dcedae525 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/VariableDeclarationRewrite.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/VariableDeclarationRewrite.java
@@ -236,4 +236,7 @@ public class VariableDeclarationRewrite {
lastFragment= currentFragment;
}
}
+
+ private VariableDeclarationRewrite() {
+ }
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/ASTFragmentFactory.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/ASTFragmentFactory.java
index 2d17f4d6e2..76955bbe72 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/ASTFragmentFactory.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/ASTFragmentFactory.java
@@ -202,4 +202,7 @@ public class ASTFragmentFactory {
return getFragment() != null;
}
}
+
+ private ASTFragmentFactory() {
+ }
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/Util.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/Util.java
index dbf7adf06a..f63dce352f 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/Util.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/fragments/Util.java
@@ -87,4 +87,7 @@ class Util {
&& getEndInclusive(thisRange) >= getEndInclusive(otherRange);
}
+ private Util() {
+ }
+
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java
index 32b485049d..7ceec707c9 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstants.java
@@ -488,7 +488,8 @@ public class CleanUpConstants {
public static final String CONTROL_STATMENTS_USE_BLOCKS_NEVER= "cleanup.never_use_blocks"; //$NON-NLS-1$
/**
- * Convert for loops to enhanced for loops.
+ * Convert for loops to enhanced for loops. For detailed setting use<br>
+ * {@link #CONTROL_STATMENTS_CONVERT_FOR_LOOP_ONLY_IF_LOOP_VAR_USED}<br>
* <p>
* Example:
*
@@ -507,6 +508,27 @@ public class CleanUpConstants {
public static final String CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED= "cleanup.convert_to_enhanced_for_loop"; //$NON-NLS-1$
/**
+ * Convert a for loop to enhanced for loop only if the loop variable will be used.
+ * <p>
+ * Example:
+ *
+ * <pre>
+ * for (int i = 0; i &lt; array.length; i++) {}; -&gt; will not be converted
+ * </pre>
+ * <br>
+ * Only has an effect if {@link #CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED} is TRUE <br>
+ * <br>
+ * Possible values: {TRUE, FALSE}<br>
+ *
+ * <br>
+ *
+ * @see CleanUpOptionsCore#TRUE
+ * @see CleanUpOptionsCore#FALSE
+ * @since 4.16
+ */
+ public static String CONTROL_STATMENTS_CONVERT_FOR_LOOP_ONLY_IF_LOOP_VAR_USED= "cleanup.convert_to_enhanced_for_loop_if_loop_var_used"; //$NON-NLS-1$
+
+ /**
* Controls the usage of parentheses in expressions. For detailed settings use<br>
* {@link #EXPRESSIONS_USE_PARENTHESES_ALWAYS}<br> {@link #EXPRESSIONS_USE_PARENTHESES_NEVER}<br>
* <br>
@@ -935,6 +957,18 @@ public class CleanUpConstants {
*/
public static final String PUSH_DOWN_NEGATION= "cleanup.push_down_negation"; //$NON-NLS-1$
+ /**
+ * Merge conditions of if/else if/else that have the same blocks.
+ * <p>
+ * Possible values: {TRUE, FALSE}
+ * <p>
+ *
+ * @see CleanUpOptionsCore#TRUE
+ * @see CleanUpOptionsCore#FALSE
+ * @since 4.16
+ */
+ public static final String MERGE_CONDITIONAL_BLOCKS= "cleanup.merge_conditional_blocks"; //$NON-NLS-1$
+
/**
* Use directly map method.<br>
@@ -1293,4 +1327,5 @@ public class CleanUpConstants {
*/
public final static String DEFAULT_SAVE_PARTICIPANT_PROFILE= SAVE_PARTICIPANT_PROFILE;
+
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertForLoopOperation.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertForLoopOperation.java
index 2e8d1b1c53..d7f944f4cf 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertForLoopOperation.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertForLoopOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -93,13 +93,16 @@ public class ConvertForLoopOperation extends ConvertLoopOperation {
private IMethodBinding fSizeMethodBinding;
private IMethodBinding fGetMethodBinding;
private MethodInvocation fSizeMethodAccess;
+ private boolean fCheckLoopVarUsed;
+ private boolean fLoopVarReferenced;
public ConvertForLoopOperation(ForStatement forStatement) {
- this(forStatement, new String[0], false);
+ this(forStatement, new String[0], false, false);
}
- public ConvertForLoopOperation(ForStatement forStatement, String[] usedNames, boolean makeFinal) {
+ public ConvertForLoopOperation(ForStatement forStatement, String[] usedNames, boolean makeFinal, boolean checkLoopVarUsed) {
super(forStatement, usedNames);
fMakeFinal= makeFinal;
+ fCheckLoopVarUsed= checkLoopVarUsed;
}
@Override
@@ -126,6 +129,9 @@ public class ConvertForLoopOperation extends ConvertLoopOperation {
if (!validateBody(statement))
return ERROR_STATUS;
+ if (fCheckLoopVarUsed && !fLoopVarReferenced)
+ return ERROR_STATUS;
+
return Status.OK_STATUS;
}
@@ -479,6 +485,7 @@ public class ConvertForLoopOperation extends ConvertLoopOperation {
throw new InvalidBodyError();
if (nameBinding.equals(fIndexBinding)) {
+ fLoopVarReferenced= true;
if (node.getLocationInParent() == ArrayAccess.INDEX_PROPERTY) {
if (fIsCollection)
throw new InvalidBodyError();
@@ -582,7 +589,7 @@ public class ConvertForLoopOperation extends ConvertLoopOperation {
return true;
if (current instanceof PrefixExpression
- && !(((PrefixExpression) current).getOperand() instanceof MethodInvocation && ((PrefixExpression) current).getOperator().equals(PrefixExpression.Operator.NOT)))
+ && !((PrefixExpression) current).getOperator().equals(PrefixExpression.Operator.NOT))
return true;
if (current instanceof PostfixExpression)
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertIterableLoopOperation.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertIterableLoopOperation.java
index d96a37f3a1..8cc9f56db9 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertIterableLoopOperation.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertIterableLoopOperation.java
@@ -15,6 +15,8 @@
package org.eclipse.jdt.internal.corext.fix;
import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
@@ -45,6 +47,7 @@ import org.eclipse.jdt.core.dom.NullLiteral;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.Statement;
+import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.VariableDeclarationExpression;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
@@ -71,7 +74,6 @@ import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
* @since 3.1
*/
public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
-
private static final StatusInfo SEMANTIC_CHANGE_WARNING_STATUS= new StatusInfo(IStatus.WARNING, FixMessages.ConvertIterableLoopOperation_semanticChangeWarning);
/**
@@ -84,21 +86,20 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
* @return the supertype, or <code>null</code>
*/
private static ITypeBinding getSuperType(final ITypeBinding binding, final String name) {
-
if (binding.isArray() || binding.isPrimitive())
return null;
- if (binding.getQualifiedName().startsWith(name))
+ if (binding.getErasure().getQualifiedName().equals(name))
return binding;
- final ITypeBinding type= binding.getSuperclass();
+ ITypeBinding type= binding.getSuperclass();
if (type != null) {
- final ITypeBinding result= getSuperType(type, name);
+ ITypeBinding result= getSuperType(type, name);
if (result != null)
return result;
}
for (ITypeBinding type2 : binding.getInterfaces()) {
- final ITypeBinding result= getSuperType(type2, name);
+ ITypeBinding result= getSuperType(type2, name);
if (result != null)
return result;
}
@@ -106,22 +107,22 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
}
/** Has the element variable been assigned outside the for statement? */
- private boolean fAssigned= false;
+ private boolean fAssigned;
/** The binding of the element variable */
- private IBinding fElementVariable= null;
+ private IBinding fElementVariable;
/** The node of the iterable expression */
- private Expression fExpression= null;
+ private Expression fExpression;
/** The type binding of the iterable expression */
- private IBinding fIterable= null;
+ private IBinding fIterable;
/** Is the iterator method invoked on <code>this</code>? */
- private boolean fThis= false;
+ private boolean fThis;
/** The binding of the iterator variable */
- private IVariableBinding fIteratorVariable= null;
+ private IVariableBinding fIteratorVariable;
/** The nodes of the element variable occurrences */
private final List<Expression> fOccurrences= new ArrayList<>(2);
@@ -130,30 +131,33 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
private boolean fMakeFinal;
+ private boolean fCheckIfVarUsed;
+
+ private boolean fElementVariableReferenced;
+
public ConvertIterableLoopOperation(ForStatement statement) {
- this(statement, new String[0], false);
+ this(statement, new String[0], false, false);
}
- public ConvertIterableLoopOperation(ForStatement statement, String[] usedNames, boolean makeFinal) {
+ public ConvertIterableLoopOperation(ForStatement statement, String[] usedNames, boolean makeFinal, boolean checkIfVarUsed) {
super(statement, usedNames);
fMakeFinal= makeFinal;
+ fCheckIfVarUsed= checkIfVarUsed;
}
@Override
public String getIntroducedVariableName() {
if (fElementVariable != null) {
return fElementVariable.getName();
- } else {
- return getVariableNameProposals()[0];
}
+ return getVariableNameProposals()[0];
}
private String[] getVariableNameProposals() {
-
String[] variableNames= getUsedVariableNames();
String[] elementSuggestions= StubUtility.getLocalNameSuggestions(getJavaProject(), FOR_LOOP_ELEMENT_IDENTIFIER, 0, variableNames);
- final ITypeBinding binding= fIteratorVariable.getType();
+ ITypeBinding binding= fIteratorVariable.getType();
if (binding != null && binding.isParameterizedType()) {
String type= binding.getTypeArguments()[0].getName();
String[] typeSuggestions= StubUtility.getLocalNameSuggestions(getJavaProject(), type, 0, variableNames);
@@ -162,9 +166,8 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
System.arraycopy(typeSuggestions, 0, result, 0, typeSuggestions.length);
System.arraycopy(elementSuggestions, 0, result, typeSuggestions.length, elementSuggestions.length);
return result;
- } else {
- return elementSuggestions;
}
+ return elementSuggestions;
}
private IJavaProject getJavaProject() {
@@ -199,7 +202,7 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
*/
private ITypeBinding getElementType(final ITypeBinding iterator) {
if (iterator != null) {
- final ITypeBinding[] bindings= iterator.getTypeArguments();
+ ITypeBinding[] bindings= iterator.getTypeArguments();
if (bindings.length > 0) {
ITypeBinding arg= bindings[0];
if (arg.isWildcardType()) {
@@ -208,14 +211,14 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
return arg;
}
}
- return getRoot().getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$
+ return getRoot().getAST().resolveWellKnownType(Object.class.getCanonicalName());
}
@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore positionGroups) throws CoreException {
- final TextEditGroup group= createTextEditGroup(FixMessages.Java50Fix_ConvertToEnhancedForLoop_description, cuRewrite);
+ TextEditGroup group= createTextEditGroup(FixMessages.Java50Fix_ConvertToEnhancedForLoop_description, cuRewrite);
- final ASTRewrite astRewrite= cuRewrite.getASTRewrite();
+ ASTRewrite astRewrite= cuRewrite.getASTRewrite();
TightSourceRangeComputer rangeComputer;
if (astRewrite.getExtendedSourceRangeComputer() instanceof TightSourceRangeComputer) {
@@ -232,10 +235,10 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
@Override
protected Statement convert(CompilationUnitRewrite cuRewrite, final TextEditGroup group, final LinkedProposalModelCore positionGroups) throws CoreException {
- final AST ast= cuRewrite.getAST();
- final ASTRewrite astRewrite= cuRewrite.getASTRewrite();
- final ImportRewrite importRewrite= cuRewrite.getImportRewrite();
- final ImportRemover remover= cuRewrite.getImportRemover();
+ AST ast= cuRewrite.getAST();
+ ASTRewrite astRewrite= cuRewrite.getASTRewrite();
+ ImportRewrite importRewrite= cuRewrite.getImportRewrite();
+ ImportRemover remover= cuRewrite.getImportRemover();
fEnhancedForLoop= ast.newEnhancedForStatement();
String[] names= getVariableNameProposals();
@@ -246,20 +249,20 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
} else {
name= names[0];
}
- final LinkedProposalPositionGroupCore pg= positionGroups.getPositionGroup(name, true);
+ LinkedProposalPositionGroupCore pg= positionGroups.getPositionGroup(name, true);
if (fElementVariable != null)
pg.addProposal(name, 10);
for (String name2 : names) {
pg.addProposal(name2, 10);
}
- final Statement body= getForStatement().getBody();
+ Statement body= getForStatement().getBody();
if (body != null) {
- final ListRewrite list;
+ ListRewrite list;
if (body instanceof Block) {
list= astRewrite.getListRewrite(body, Block.STATEMENTS_PROPERTY);
for (Expression expression : fOccurrences) {
- final Statement parent= ASTNodes.getParent(expression, Statement.class);
+ Statement parent= ASTNodes.getParent(expression, Statement.class);
if (parent != null && list.getRewrittenList().contains(parent)) {
list.remove(parent, null);
remover.registerRemovedNode(parent);
@@ -268,11 +271,11 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
} else {
list= null;
}
- final String text= name;
+ String text= name;
body.accept(new ASTVisitor() {
private boolean replace(final Expression expression) {
- final SimpleName node= ast.newSimpleName(text);
+ SimpleName node= ast.newSimpleName(text);
astRewrite.replace(expression, node, group);
remover.registerRemovedNode(expression);
checkChildOperations(expression, node);
@@ -295,15 +298,15 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
@Override
public final boolean visit(final MethodInvocation node) {
- final IMethodBinding binding= node.resolveMethodBinding();
- if (binding != null && (binding.getName().equals("next") || binding.getName().equals("nextElement"))) { //$NON-NLS-1$ //$NON-NLS-2$
- final Expression expression= node.getExpression();
+ IMethodBinding binding= node.resolveMethodBinding();
+ if (binding != null && ("next".equals(binding.getName()) || "nextElement".equals(binding.getName()))) { //$NON-NLS-1$ //$NON-NLS-2$
+ Expression expression= node.getExpression();
if (expression instanceof Name) {
- final IBinding result= ((Name)expression).resolveBinding();
+ IBinding result= ((Name)expression).resolveBinding();
if (result != null && result.equals(fIteratorVariable))
return replace(node);
} else if (expression instanceof FieldAccess) {
- final IBinding result= ((FieldAccess)expression).resolveFieldBinding();
+ IBinding result= ((FieldAccess)expression).resolveFieldBinding();
if (result != null && result.equals(fIteratorVariable))
return replace(node);
}
@@ -314,9 +317,9 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
@Override
public final boolean visit(final SimpleName node) {
if (fElementVariable != null) {
- final IBinding binding= node.resolveBinding();
+ IBinding binding= node.resolveBinding();
if (binding != null && binding.equals(fElementVariable)) {
- final Statement parent= ASTNodes.getParent(node, Statement.class);
+ Statement parent= ASTNodes.getParent(node, Statement.class);
if (parent != null && (list == null || list.getRewrittenList().contains(parent)))
pg.addPosition(astRewrite.track(node), false);
}
@@ -327,11 +330,11 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
fEnhancedForLoop.setBody(getBody(cuRewrite, group, positionGroups));
}
- final SingleVariableDeclaration declaration= ast.newSingleVariableDeclaration();
- final SimpleName simple= ast.newSimpleName(name);
+ SingleVariableDeclaration declaration= ast.newSingleVariableDeclaration();
+ SimpleName simple= ast.newSimpleName(name);
pg.addPosition(astRewrite.track(simple), true);
declaration.setName(simple);
- final ITypeBinding elementType= getElementType(fIteratorVariable.getType());
+ ITypeBinding elementType= getElementType(fIteratorVariable.getType());
Type importType= importType(elementType, getForStatement(), importRewrite, getRoot(), TypeLocation.LOCAL_VARIABLE);
remover.registerAddedImports(importType);
declaration.setType(importType);
@@ -373,7 +376,7 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
* applicable
*/
@Override
- public final IStatus satisfiesPreconditions() {
+ public IStatus satisfiesPreconditions() {
IStatus resultStatus= StatusInfo.OK_STATUS;
if (JavaModelUtil.is50OrHigher(getJavaProject())) {
resultStatus= checkExpressionCondition();
@@ -388,77 +391,66 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
}
for (final Object outer : getForStatement().initializers()) {
- final Expression initializer= (Expression) outer;
+ Expression initializer= (Expression) outer;
if (initializer instanceof VariableDeclarationExpression) {
- final VariableDeclarationExpression declaration= (VariableDeclarationExpression)initializer;
+ VariableDeclarationExpression declaration= (VariableDeclarationExpression)initializer;
List<VariableDeclarationFragment> fragments= declaration.fragments();
if (fragments.size() != 1) {
return new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$
- } else {
- final VariableDeclarationFragment fragment= fragments.get(0);
- fragment.accept(new ASTVisitor() {
-
- @Override
- public final boolean visit(final MethodInvocation node) {
- final IMethodBinding binding= node.resolveMethodBinding();
- if (binding != null) {
- final ITypeBinding type= binding.getReturnType();
- if (type != null) {
- final String qualified= type.getQualifiedName();
- if (qualified.startsWith("java.util.Enumeration<") || qualified.startsWith("java.util.Iterator<")) { //$NON-NLS-1$ //$NON-NLS-2$
- final Expression qualifier= node.getExpression();
- if (qualifier != null) {
- final ITypeBinding resolved= qualifier.resolveTypeBinding();
- if (resolved != null) {
- final ITypeBinding iterable= getSuperType(resolved, "java.lang.Iterable"); //$NON-NLS-1$
- if (iterable != null) {
- fExpression= qualifier;
- fIterable= resolved;
- }
- }
- } else {
- final ITypeBinding declaring= binding.getDeclaringClass();
- if (declaring != null) {
- final ITypeBinding superBinding= getSuperType(declaring, "java.lang.Iterable"); //$NON-NLS-1$
- if (superBinding != null) {
- fIterable= superBinding;
- fThis= true;
- }
- }
- }
- }
- }
- }
- return true;
+ }
+ VariableDeclarationFragment fragment= fragments.get(0);
+ IVariableBinding binding= fragment.resolveBinding();
+ if (binding != null) {
+ ITypeBinding type= binding.getType();
+ if (type != null) {
+ ITypeBinding iterator= getSuperType(type, Iterator.class.getCanonicalName());
+
+ if (iterator == null) {
+ iterator= getSuperType(type, Enumeration.class.getCanonicalName());
}
- @Override
- public final boolean visit(final VariableDeclarationFragment node) {
- final IVariableBinding binding= node.resolveBinding();
- if (binding != null) {
- final ITypeBinding type= binding.getType();
- if (type != null) {
- ITypeBinding iterator= getSuperType(type, "java.util.Iterator"); //$NON-NLS-1$
- if (iterator != null)
- fIteratorVariable= binding;
- else {
- iterator= getSuperType(type, "java.util.Enumeration"); //$NON-NLS-1$
- if (iterator != null)
- fIteratorVariable= binding;
+ if (iterator != null) {
+ fIteratorVariable= binding;
+ }
+ }
+ }
+ MethodInvocation method= ASTNodes.as(fragment.getInitializer(), MethodInvocation.class);
+ if (method != null && method.resolveMethodBinding() != null) {
+ IMethodBinding methodBinding= method.resolveMethodBinding();
+ ITypeBinding type= methodBinding.getReturnType();
+ if (type != null) {
+ String qualified= type.getQualifiedName();
+ if (qualified.startsWith("java.util.Enumeration<") || qualified.startsWith("java.util.Iterator<")) { //$NON-NLS-1$ //$NON-NLS-2$
+ Expression qualifier= method.getExpression();
+ if (qualifier != null) {
+ ITypeBinding resolved= qualifier.resolveTypeBinding();
+ if (resolved != null) {
+ ITypeBinding iterable= getSuperType(resolved, Iterable.class.getCanonicalName());
+ if (iterable != null) {
+ fExpression= qualifier;
+ fIterable= resolved;
+ }
+ }
+ } else {
+ ITypeBinding declaring= methodBinding.getDeclaringClass();
+ if (declaring != null) {
+ ITypeBinding superBinding= getSuperType(declaring, Iterable.class.getCanonicalName());
+ if (superBinding != null) {
+ fIterable= superBinding;
+ fThis= true;
}
}
}
- return true;
}
- });
+ }
}
}
}
- final Statement statement= getForStatement().getBody();
- final boolean[] otherInvocationThenNext= new boolean[] {false};
- final int[] nextInvocationCount= new int[] {0};
+ Statement statement= getForStatement().getBody();
if (statement != null && fIteratorVariable != null) {
- final ITypeBinding elementType= getElementType(fIteratorVariable.getType());
+ boolean[] otherInvocationThenNext= { false };
+ int[] nextInvocationCount= { 0 };
+ ITypeBinding elementType= getElementType(fIteratorVariable.getType());
statement.accept(new ASTVisitor() {
@Override
@@ -472,7 +464,7 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
if (node.getLocationInParent() == MethodInvocation.EXPRESSION_PROPERTY) {
MethodInvocation invocation= (MethodInvocation) node.getParent();
String name= invocation.getName().getIdentifier();
- if (name.equals("next") || name.equals("nextElement")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if ("next".equals(name) || "nextElement".equals(name)) { //$NON-NLS-1$ //$NON-NLS-2$
nextInvocationCount[0]++;
Expression left= null;
@@ -492,19 +484,19 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
private boolean visitElementVariable(final Expression node) {
if (node != null) {
- final ITypeBinding binding= node.resolveTypeBinding();
+ ITypeBinding binding= node.resolveTypeBinding();
if (binding != null && elementType.equals(binding)) {
if (node instanceof Name) {
- final Name name= (Name)node;
- final IBinding result= name.resolveBinding();
+ Name name= (Name)node;
+ IBinding result= name.resolveBinding();
if (result != null) {
fOccurrences.add(node);
fElementVariable= result;
return false;
}
} else if (node instanceof FieldAccess) {
- final FieldAccess access= (FieldAccess)node;
- final IBinding result= access.resolveFieldBinding();
+ FieldAccess access= (FieldAccess)node;
+ IBinding result= access.resolveFieldBinding();
if (result != null) {
fOccurrences.add(node);
fElementVariable= result;
@@ -516,13 +508,11 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
return true;
}
});
- if (otherInvocationThenNext[0])
- return ERROR_STATUS;
-
- if (nextInvocationCount[0] > 1)
+ if (otherInvocationThenNext[0] || nextInvocationCount[0] > 1)
return ERROR_STATUS;
if (fElementVariable != null) {
+ final String elementVarName= fElementVariable.getName();
statement.accept(new ASTVisitor() {
@Override
public final boolean visit(final VariableDeclarationFragment node) {
@@ -535,24 +525,35 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
return true;
}
+
+ @Override
+ public final boolean visit(final SimpleName node) {
+ if (fCheckIfVarUsed && !fElementVariableReferenced && node.getFullyQualifiedName().equals(elementVarName)) {
+ IBinding binding= node.resolveBinding();
+ if (binding != null && binding.equals(fElementVariable)) {
+ StructuralPropertyDescriptor location= node.getLocationInParent();
+ if (location != VariableDeclarationFragment.NAME_PROPERTY) {
+ fElementVariableReferenced= true;
+ }
+ }
+ }
+ return true;
+ }
});
}
}
- final ASTNode root= getForStatement().getRoot();
+ ASTNode root= getForStatement().getRoot();
if (root != null) {
root.accept(new ASTVisitor() {
@Override
public final boolean visit(final ForStatement node) {
- if (node.equals(getForStatement()))
- return false;
- else
- return true;
+ return !node.equals(getForStatement());
}
@Override
public final boolean visit(final SimpleName node) {
- final IBinding binding= node.resolveBinding();
+ IBinding binding= node.resolveBinding();
if (binding != null && binding.equals(fElementVariable))
fAssigned= true;
return false;
@@ -560,11 +561,10 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
});
}
}
- if ((fExpression != null || fThis) && fIterable != null && fIteratorVariable != null && !fAssigned) {
+ if ((fExpression != null || fThis) && fIterable != null && fIteratorVariable != null && !fAssigned && (fElementVariableReferenced || !fCheckIfVarUsed)) {
return resultStatus;
- } else {
- return ERROR_STATUS;
}
+ return ERROR_STATUS;
}
private IStatus checkExpressionCondition() {
@@ -581,13 +581,13 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
if (declaringClass == null)
return ERROR_STATUS;
- String qualifiedName= declaringClass.getQualifiedName();
+ String qualifiedName= declaringClass.getErasure().getQualifiedName();
String methodName= invoc.getName().getIdentifier();
- if (qualifiedName.startsWith("java.util.Enumeration")) { //$NON-NLS-1$
- if (!methodName.equals("hasMoreElements")) //$NON-NLS-1$
+ if (Enumeration.class.getCanonicalName().equals(qualifiedName)) {
+ if (!"hasMoreElements".equals(methodName)) //$NON-NLS-1$
return SEMANTIC_CHANGE_WARNING_STATUS;
- } else if (qualifiedName.startsWith("java.util.Iterator")) { //$NON-NLS-1$
- if (!methodName.equals("hasNext")) //$NON-NLS-1$
+ } else if (Iterator.class.getCanonicalName().equals(qualifiedName)) {
+ if (!"hasNext".equals(methodName)) //$NON-NLS-1$
return SEMANTIC_CHANGE_WARNING_STATUS;
return checkIteratorCondition();
} else {
@@ -598,7 +598,6 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
}
private IStatus checkIteratorCondition() {
-
List<Expression> initializers= getForStatement().initializers();
if (initializers.size() != 1)
return SEMANTIC_CHANGE_WARNING_STATUS;
@@ -620,10 +619,9 @@ public final class ConvertIterableLoopOperation extends ConvertLoopOperation {
MethodInvocation methodInvocation= (MethodInvocation)initializer;
String methodName= methodInvocation.getName().getIdentifier();
- if (!"iterator".equals(methodName) || methodInvocation.arguments().size() != 0) //$NON-NLS-1$
+ if (!"iterator".equals(methodName) || !methodInvocation.arguments().isEmpty()) //$NON-NLS-1$
return SEMANTIC_CHANGE_WARNING_STATUS;
return StatusInfo.OK_STATUS;
}
-
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopFixCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopFixCore.java
index a8e6df176f..3990e00185 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopFixCore.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopFixCore.java
@@ -40,12 +40,15 @@ public class ConvertLoopFixCore extends CompilationUnitRewriteOperationsFixCore
private final boolean fFindForLoopsToConvert;
private final boolean fConvertIterableForLoops;
private final boolean fMakeFinal;
+ private final boolean fCheckIfLoopVarUsed;
private ConvertLoopOperation fParentOperation;
- public ControlStatementFinder(boolean findForLoopsToConvert, boolean convertIterableForLoops, boolean makeFinal, List<ConvertLoopOperation> resultingCollection) {
+ public ControlStatementFinder(boolean findForLoopsToConvert, boolean convertIterableForLoops, boolean makeFinal,
+ boolean checkIfLoopVarUsed, List<ConvertLoopOperation> resultingCollection) {
fFindForLoopsToConvert= findForLoopsToConvert;
fConvertIterableForLoops= convertIterableForLoops;
fMakeFinal= makeFinal;
+ fCheckIfLoopVarUsed= checkIfLoopVarUsed;
fResult= resultingCollection;
fUsedNames= new Hashtable<>();
fParentOperation= null;
@@ -89,14 +92,14 @@ public class ConvertLoopFixCore extends CompilationUnitRewriteOperationsFixCore
Collection<String> usedNamesCollection= fUsedNames.values();
String[] usedNames= usedNamesCollection.toArray(new String[usedNamesCollection.size()]);
- ConvertLoopOperation convertForLoopOperation= new ConvertForLoopOperation(node, usedNames, fMakeFinal);
+ ConvertLoopOperation convertForLoopOperation= new ConvertForLoopOperation(node, usedNames, fMakeFinal, fCheckIfLoopVarUsed);
if (convertForLoopOperation.satisfiesPreconditions().isOK()) {
if (fFindForLoopsToConvert) {
fUsedNames.put(node, convertForLoopOperation.getIntroducedVariableName());
return convertForLoopOperation;
}
} else if (fConvertIterableForLoops) {
- ConvertLoopOperation iterableConverter= new ConvertIterableLoopOperation(node, usedNames, fMakeFinal);
+ ConvertLoopOperation iterableConverter= new ConvertIterableLoopOperation(node, usedNames, fMakeFinal, fCheckIfLoopVarUsed);
if (iterableConverter.satisfiesPreconditions().isOK()) {
fUsedNames.put(node, iterableConverter.getIntroducedVariableName());
return iterableConverter;
@@ -116,7 +119,8 @@ public class ConvertLoopFixCore extends CompilationUnitRewriteOperationsFixCore
}
- public static ICleanUpFixCore createCleanUp(CompilationUnit compilationUnit, boolean convertForLoops, boolean convertIterableForLoops, boolean makeFinal) {
+ public static ICleanUpFixCore createCleanUp(CompilationUnit compilationUnit, boolean convertForLoops, boolean convertIterableForLoops,
+ boolean makeFinal, boolean checkIfLoopVarUsed) {
if (!JavaModelUtil.is50OrHigher(compilationUnit.getJavaElement().getJavaProject()))
return null;
@@ -124,7 +128,7 @@ public class ConvertLoopFixCore extends CompilationUnitRewriteOperationsFixCore
return null;
List<ConvertLoopOperation> operations= new ArrayList<>();
- ControlStatementFinder finder= new ControlStatementFinder(convertForLoops, convertIterableForLoops, makeFinal, operations);
+ ControlStatementFinder finder= new ControlStatementFinder(convertForLoops, convertIterableForLoops, makeFinal, checkIfLoopVarUsed, operations);
compilationUnit.accept(finder);
if (operations.isEmpty())
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopOperation.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopOperation.java
index a6c9127cb8..7d21d8833d 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopOperation.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopOperation.java
@@ -59,38 +59,33 @@ public abstract class ConvertLoopOperation extends CompilationUnitRewriteOperati
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
private static final Set<String> NO_BASE_TYPES = Stream.of(
- new String[] {
- /* note: ints left out intentionally */
- "integers", //$NON-NLS-1$
- "floats", //$NON-NLS-1$
- "doubles", //$NON-NLS-1$
- "booleans", //$NON-NLS-1$
- "bytes", //$NON-NLS-1$
- "chars", //$NON-NLS-1$
- "shorts", //$NON-NLS-1$
- "longs"}) //$NON-NLS-1$
+ "integers", //$NON-NLS-1$
+ "floats", //$NON-NLS-1$
+ "doubles", //$NON-NLS-1$
+ "booleans", //$NON-NLS-1$
+ "bytes", //$NON-NLS-1$
+ "chars", //$NON-NLS-1$
+ "shorts", //$NON-NLS-1$
+ "longs") //$NON-NLS-1$
.collect(Collectors.toSet());
- private static final Set<String> CUT_PREFIX= Stream.of(
- new String[] {
- "all"}) //$NON-NLS-1$
+ private static final Set<String> CUT_PREFIX= Stream.of("all") //$NON-NLS-1$
.collect(Collectors.toSet());
private static final Set<String> IRREG_ENDINGS= Stream.of(
- new String[] {
- "xes", //$NON-NLS-1$
- "ies", //$NON-NLS-1$
- "oes", //$NON-NLS-1$
- "ses", //$NON-NLS-1$
- "hes", //$NON-NLS-1$
- "zes", //$NON-NLS-1$
- "ves", //$NON-NLS-1$
- "ces", //$NON-NLS-1$
- "ss", //$NON-NLS-1$
- "is", //$NON-NLS-1$
- "us", //$NON-NLS-1$
- "os", //$NON-NLS-1$
- "as"}) //$NON-NLS-1$
+ "xes", //$NON-NLS-1$
+ "ies", //$NON-NLS-1$
+ "oes", //$NON-NLS-1$
+ "ses", //$NON-NLS-1$
+ "hes", //$NON-NLS-1$
+ "zes", //$NON-NLS-1$
+ "ves", //$NON-NLS-1$
+ "ces", //$NON-NLS-1$
+ "ss", //$NON-NLS-1$
+ "is", //$NON-NLS-1$
+ "us", //$NON-NLS-1$
+ "os", //$NON-NLS-1$
+ "as") //$NON-NLS-1$
.collect(Collectors.toSet());
private final ForStatement fStatement;
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/LambdaExpressionsFixCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/LambdaExpressionsFixCore.java
index f3a6fa30f8..4154d86e77 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/LambdaExpressionsFixCore.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/LambdaExpressionsFixCore.java
@@ -391,6 +391,62 @@ public class LambdaExpressionsFixCore extends CompilationUnitRewriteOperationsFi
}
}
+ private static final class MethodRecursionFinder extends HierarchicalASTVisitor {
+ private MethodDeclaration fMethodDeclaration;
+ private IMethodBinding fMethodBinding;
+ private ASTNode fFieldDeclaration;
+
+ private static boolean isRecursiveLocal(MethodDeclaration node) {
+ try {
+ MethodRecursionFinder finder= new MethodRecursionFinder();
+ ClassInstanceCreation cic= (ClassInstanceCreation) node.getParent().getParent();
+ cic.getType().resolveBinding();
+ finder.fMethodDeclaration= node;
+ finder.fFieldDeclaration= finder.findFieldDeclaration(node);
+ if (finder.fFieldDeclaration != null) {
+ return false;
+ }
+ finder.fMethodBinding= finder.fMethodDeclaration.resolveBinding();
+ if (finder.fMethodBinding == null) {
+ return false;
+ }
+ node.accept(finder);
+ } catch (AbortSearchException e) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private ASTNode findFieldDeclaration(ASTNode node) {
+ ASTNode originalNode= node;
+ while (node != null) {
+ if (node instanceof FieldDeclaration) {
+ return node;
+ }
+ if (node instanceof AbstractTypeDeclaration) {
+ return null;
+ }
+ if (node instanceof MethodDeclaration && node != originalNode) {
+ return null;
+ }
+ node= node.getParent();
+ }
+ return null;
+ }
+
+ @Override
+ public boolean visit(MethodInvocation node) {
+ if (node.getExpression() == null) {
+ IMethodBinding binding= node.resolveMethodBinding();
+ if (binding != null && binding.isEqualTo(fMethodBinding)) {
+ throw new AbortSearchException();
+ }
+ }
+ return true;
+ }
+ }
+
public static class CreateLambdaOperation extends CompilationUnitRewriteOperation {
private final List<ClassInstanceCreation> fExpressions;
@@ -418,7 +474,7 @@ public class LambdaExpressionsFixCore extends CompilationUnitRewriteOperationsFi
if (!(object instanceof MethodDeclaration)) {
continue;
}
- MethodDeclaration methodDeclaration= (MethodDeclaration) object;
+ final MethodDeclaration methodDeclaration= (MethodDeclaration) object;
HashSet<String> excludedNames= new HashSet<>();
if (i != 0) {
for (ClassInstanceCreation convertedCic : fExpressions.subList(0, i)) {
@@ -470,60 +526,94 @@ public class LambdaExpressionsFixCore extends CompilationUnitRewriteOperationsFi
}
@SuppressWarnings("unchecked")
- final ASTNode field= ASTNodes.getFirstAncestorOrNull(classInstanceCreation, FieldDeclaration.class, BodyDeclaration.class);
+ ASTNode fragment= ASTNodes.getFirstAncestorOrNull(classInstanceCreation, VariableDeclarationFragment.class, BodyDeclaration.class);
- if (field instanceof FieldDeclaration) {
- FieldDeclaration fieldDeclaration= (FieldDeclaration) field;
+ if (fragment instanceof VariableDeclarationFragment) {
+ final VariableDeclarationFragment actualFragment= (VariableDeclarationFragment) fragment;
- @SuppressWarnings("unchecked")
- ASTNode declarationClass= ASTNodes.getFirstAncestorOrNull(fieldDeclaration, TypeDeclaration.class);
+ if (actualFragment.getParent() instanceof FieldDeclaration) {
+ FieldDeclaration fieldDeclaration= (FieldDeclaration) actualFragment.getParent();
- if (declarationClass instanceof TypeDeclaration) {
- TypeDeclaration typeDeclaration= (TypeDeclaration) declarationClass;
+ @SuppressWarnings("unchecked")
+ ASTNode declarationClass= ASTNodes.getFirstAncestorOrNull(fieldDeclaration, TypeDeclaration.class);
- final List<FieldDeclaration> nextFields= new ArrayList<>();
- boolean isBefore= true;
+ if (declarationClass instanceof TypeDeclaration) {
+ TypeDeclaration typeDeclaration= (TypeDeclaration) declarationClass;
- for (FieldDeclaration oneField : typeDeclaration.getFields()) {
- if (oneField == fieldDeclaration) {
- isBefore= false;
- }
+ final List<FieldDeclaration> nextFields= new ArrayList<>(typeDeclaration.getFields().length);
+ boolean isBefore= true;
- if (!isBefore) {
- nextFields.add(oneField);
+ for (FieldDeclaration oneField : typeDeclaration.getFields()) {
+ if (oneField == fieldDeclaration) {
+ isBefore= false;
+ }
+
+ if (!isBefore) {
+ nextFields.add(oneField);
+ }
}
- }
- ASTVisitor visitor= new ASTVisitor() {
- @Override
- public boolean visit(final SimpleName node) {
- ASTNode declaration= ASTNodes.findDeclaration(node.resolveBinding(), declarationClass);
+ ASTVisitor visitor= new ASTVisitor() {
+ @Override
+ public boolean visit(final MethodInvocation node) {
+ ITypeBinding fieldType= fieldDeclaration.getType().resolveBinding();
+ ASTNode declaration= ASTNodes.findDeclaration(node.resolveMethodBinding(), declarationClass);
- if (declaration != null
- && declaration instanceof VariableDeclarationFragment
- && declaration.getParent() instanceof FieldDeclaration) {
- FieldDeclaration currentField= (FieldDeclaration) declaration.getParent();
+ if (node.getExpression() == null && fieldType != null && methodDeclaration == declaration) {
+ ASTNode replacement;
- if (nextFields.contains(currentField)) {
- if ((currentField.getModifiers() & Modifier.STATIC) != 0) {
+ if ((fieldDeclaration.getModifiers() & Modifier.STATIC) != 0) {
SimpleName copyOfClassName= (SimpleName) rewrite.createCopyTarget(typeDeclaration.getName());
- QualifiedName replacement= ast.newQualifiedName(copyOfClassName, (SimpleName) rewrite.createMoveTarget(node));
- rewrite.replace(node, replacement, group);
+ replacement= ast.newQualifiedName(copyOfClassName, (SimpleName) rewrite.createCopyTarget(actualFragment.getName()));
} else {
FieldAccess newFieldAccess= ast.newFieldAccess();
newFieldAccess.setExpression(ast.newThisExpression());
- newFieldAccess.setName((SimpleName) rewrite.createMoveTarget(node));
- rewrite.replace(node, newFieldAccess, group);
+ newFieldAccess.setName((SimpleName) rewrite.createCopyTarget(actualFragment.getName()));
+ replacement= newFieldAccess;
}
+ rewrite.set(node, MethodInvocation.EXPRESSION_PROPERTY, replacement, group);
+
return false;
}
+
+ return true;
}
- return true;
- }
- };
- lambdaBody.accept(visitor);
+ @Override
+ public boolean visit(final SimpleName node) {
+ if ((!(node.getParent() instanceof QualifiedName) || node.getLocationInParent() != QualifiedName.NAME_PROPERTY)
+ && (!(node.getParent() instanceof FieldAccess) || node.getLocationInParent() != FieldAccess.NAME_PROPERTY)
+ && (!(node.getParent() instanceof SuperFieldAccess) || node.getLocationInParent() != SuperFieldAccess.NAME_PROPERTY)) {
+ ASTNode declaration= ASTNodes.findDeclaration(node.resolveBinding(), declarationClass);
+
+ if (declaration != null
+ && declaration instanceof VariableDeclarationFragment
+ && declaration.getParent() instanceof FieldDeclaration) {
+ FieldDeclaration currentField= (FieldDeclaration) declaration.getParent();
+
+ if (nextFields.contains(currentField)) {
+ if ((currentField.getModifiers() & Modifier.STATIC) != 0) {
+ SimpleName copyOfClassName= (SimpleName) rewrite.createCopyTarget(typeDeclaration.getName());
+ QualifiedName replacement= ast.newQualifiedName(copyOfClassName, ASTNodes.createMoveTarget(rewrite, node));
+ rewrite.replace(node, replacement, group);
+ } else {
+ FieldAccess newFieldAccess= ast.newFieldAccess();
+ newFieldAccess.setExpression(ast.newThisExpression());
+ newFieldAccess.setName(ASTNodes.createMoveTarget(rewrite, node));
+ rewrite.replace(node, newFieldAccess, group);
+ }
+
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+ };
+ lambdaBody.accept(visitor);
+ }
}
}
@@ -875,6 +965,11 @@ public class LambdaExpressionsFixCore extends CompilationUnitRewriteOperationsFi
return false;
}
+ // Cannot handle recursive calls in a locally declared anonymous class
+ if (MethodRecursionFinder.isRecursiveLocal(methodDecl)) {
+ return false;
+ }
+
// Check if annotations other than @Override and @Deprecated will be removed
checkAnnotationsRemoval(methodBinding);
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/Messages.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/Messages.java
index 5f64ff0ef8..c2ee50ea7f 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/Messages.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/Messages.java
@@ -14,7 +14,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.corext.fix;
-import com.ibm.icu.text.MessageFormat;
+import java.text.MessageFormat;
/**
* Helper class to format message strings.
@@ -24,7 +24,7 @@ import com.ibm.icu.text.MessageFormat;
public class Messages {
public static String format(String message, Object object) {
- return MessageFormat.format(message, new Object[] { object});
+ return MessageFormat.format(message, object);
}
public static String format(String message, Object[] objects) {
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/UnusedCodeFixCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/UnusedCodeFixCore.java
index 85d139907e..cfe292e8e3 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/UnusedCodeFixCore.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/UnusedCodeFixCore.java
@@ -333,12 +333,12 @@ public class UnusedCodeFixCore extends CompilationUnitRewriteOperationsFixCore {
}
IfStatement ifStatement= ast.newIfStatement();
- ifStatement.setExpression((Expression) rewrite.createCopyTarget(getExpressionWithoutParenthezis(ce.getExpression())));
+ ifStatement.setExpression((Expression) rewrite.createCopyTarget(ASTNodes.getUnparenthesedExpression(ce.getExpression())));
Block thenBlock= ast.newBlock();
// check if 'then' block contains code to keep
if (checkCondtionalExpression(ce.getThenExpression())) {
- ASTNode thenExpression= rewrite.createCopyTarget(getExpressionWithoutParenthezis(ce.getThenExpression()));
+ ASTNode thenExpression= rewrite.createCopyTarget(ASTNodes.getUnparenthesedExpression(ce.getThenExpression()));
thenBlock.statements().add(ast.newExpressionStatement((Expression) thenExpression));
}
ifStatement.setThenStatement(thenBlock);
@@ -346,7 +346,7 @@ public class UnusedCodeFixCore extends CompilationUnitRewriteOperationsFixCore {
// check if 'else' block contains code to keep
if (checkCondtionalExpression(ce.getElseExpression())) {
Block elseBlock= ast.newBlock();
- ASTNode elseExpression= rewrite.createCopyTarget(getExpressionWithoutParenthezis(ce.getElseExpression()));
+ ASTNode elseExpression= rewrite.createCopyTarget(ASTNodes.getUnparenthesedExpression(ce.getElseExpression()));
elseBlock.statements().add(ast.newExpressionStatement((Expression) elseExpression));
ifStatement.setElseStatement(elseBlock);
}
@@ -411,19 +411,11 @@ public class UnusedCodeFixCore extends CompilationUnitRewriteOperationsFixCore {
}
}
- private static Expression getExpressionWithoutParenthezis(Expression expression) {
- Expression currExpression= expression;
- while (currExpression instanceof ParenthesizedExpression) {
- currExpression= ((ParenthesizedExpression) currExpression).getExpression();
- }
- return currExpression;
- }
-
/*
* Return TRUE if the expression node type is a method, pre/posfix or assignment
*/
private static boolean checkCondtionalExpression(Expression expression) {
- int nodeType= getExpressionWithoutParenthezis(expression).getNodeType();
+ int nodeType= ASTNodes.getUnparenthesedExpression(expression).getNodeType();
if (nodeType == ASTNode.METHOD_INVOCATION ||
nodeType == ASTNode.POSTFIX_EXPRESSION ||
nodeType == ASTNode.PREFIX_EXPRESSION ||
@@ -677,10 +669,7 @@ public class UnusedCodeFixCore extends CompilationUnitRewriteOperationsFixCore {
ASTNode selectedNode= problem.getCoveringNode(compilationUnit);
- ASTNode curr= selectedNode;
- while (curr instanceof ParenthesizedExpression) {
- curr= ((ParenthesizedExpression) curr).getExpression();
- }
+ ASTNode curr= ASTNodes.getUnparenthesedExpression(selectedNode);
if (!(curr instanceof CastExpression))
return null;
@@ -771,10 +760,7 @@ public class UnusedCodeFixCore extends CompilationUnitRewriteOperationsFixCore {
if (removeUnusedCast && id == IProblem.UnnecessaryCast) {
ASTNode selectedNode= problem.getCoveringNode(compilationUnit);
- ASTNode curr= selectedNode;
- while (curr instanceof ParenthesizedExpression) {
- curr= ((ParenthesizedExpression) curr).getExpression();
- }
+ ASTNode curr= ASTNodes.getUnparenthesedExpression(selectedNode);
if (curr instanceof CastExpression) {
unnecessaryCasts.add((CastExpression) curr);
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/UnwrapNewArrayOperation.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/UnwrapNewArrayOperation.java
index 9525bb75cc..d4a5d7e289 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/UnwrapNewArrayOperation.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/fix/UnwrapNewArrayOperation.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.internal.corext.fix;
+import java.util.List;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.dom.AST;
@@ -24,6 +26,7 @@ import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.SuperMethodInvocation;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
@@ -50,22 +53,25 @@ public class UnwrapNewArrayOperation extends CompilationUnitRewriteOperation {
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModelCore linkedModel) throws CoreException {
ASTRewrite rewrite= cuRewrite.getASTRewrite();
AST ast= cuRewrite.getRoot().getAST();
+
if (call instanceof MethodInvocation) {
MethodInvocation method= (MethodInvocation)call;
MethodInvocation newMethod= ast.newMethodInvocation();
newMethod.setSourceRange(method.getStartPosition(), method.getLength());
newMethod.setName(ast.newSimpleName(method.getName().getFullyQualifiedName()));
- newMethod.setExpression((Expression) ASTNode.copySubtree(ast, method.getExpression()));
+ newMethod.setExpression(ASTNodes.copySubtree(ast, method.getExpression()));
if (method.typeArguments() != null) {
- newMethod.typeArguments().addAll(ASTNode.copySubtrees(ast, method.typeArguments()));
+ @SuppressWarnings("unchecked")
+ List<?> createMoveTarget= ASTNodes.createMoveTarget(rewrite, method.typeArguments());
+ newMethod.typeArguments().addAll(createMoveTarget);
}
for (int i= 0; i < method.arguments().size() - 1; ++i) {
- newMethod.arguments().add(ASTNode.copySubtree(ast, (Expression)method.arguments().get(i)));
+ newMethod.arguments().add(ASTNodes.createMoveTarget(rewrite, (Expression) method.arguments().get(i)));
}
ArrayInitializer initializer= node.getInitializer();
if (initializer != null && initializer.expressions() != null) {
for (Object exp : initializer.expressions()) {
- newMethod.arguments().add(ASTNode.copySubtree(ast, (Expression)exp));
+ newMethod.arguments().add(ASTNodes.createMoveTarget(rewrite, (Expression) exp));
}
}
rewrite.replace(method, newMethod, null);
@@ -75,15 +81,17 @@ public class UnwrapNewArrayOperation extends CompilationUnitRewriteOperation {
newSuperMethod.setSourceRange(method.getStartPosition(), method.getLength());
newSuperMethod.setName(ast.newSimpleName(method.getName().getFullyQualifiedName()));
if (method.typeArguments() != null) {
- newSuperMethod.typeArguments().addAll(ASTNode.copySubtrees(ast, method.typeArguments()));
+ @SuppressWarnings("unchecked")
+ List<?> createMoveTarget= ASTNodes.createMoveTarget(rewrite, method.typeArguments());
+ newSuperMethod.typeArguments().addAll(createMoveTarget);
}
for (int i= 0; i < method.arguments().size() - 1; ++i) {
- newSuperMethod.arguments().add(ASTNode.copySubtree(ast, (Expression)method.arguments().get(i)));
+ newSuperMethod.arguments().add(ASTNodes.createMoveTarget(rewrite, (Expression) method.arguments().get(i)));
}
ArrayInitializer initializer= node.getInitializer();
if (initializer != null && initializer.expressions() != null) {
for (Object exp : initializer.expressions()) {
- newSuperMethod.arguments().add(ASTNode.copySubtree(ast, (Expression)exp));
+ newSuperMethod.arguments().add(ASTNodes.createMoveTarget(rewrite, (Expression) exp));
}
}
rewrite.replace(method, newSuperMethod, null);
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/RefactoringAvailabilityTesterCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/RefactoringAvailabilityTesterCore.java
index b33e333230..ee17d5fef0 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/RefactoringAvailabilityTesterCore.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/RefactoringAvailabilityTesterCore.java
@@ -179,4 +179,7 @@ public final class RefactoringAvailabilityTesterCore {
}
return null;
}
+
+ private RefactoringAvailabilityTesterCore() {
+ }
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/changes/TextChangeCompatibility.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/changes/TextChangeCompatibility.java
index 17d1f20bb6..e9f7050d42 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/changes/TextChangeCompatibility.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/changes/TextChangeCompatibility.java
@@ -103,4 +103,7 @@ public class TextChangeCompatibility {
}
}
+ private TextChangeCompatibility() {
+ }
+
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/code/ConstantChecks.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/code/ConstantChecks.java
index 684de23c9e..d354c634d5 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/code/ConstantChecks.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/code/ConstantChecks.java
@@ -199,4 +199,7 @@ public class ConstantChecks {
public static boolean isLoadTimeConstant(IExpressionFragment ex) {
return new LoadTimeConstantChecker(ex).check();
}
+
+ private ConstantChecks() {
+ }
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/code/Invocations.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/code/Invocations.java
index c46c313b3e..7482132dfb 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/code/Invocations.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/code/Invocations.java
@@ -197,4 +197,7 @@ public class Invocations {
throw new IllegalArgumentException(invocation.toString());
}
}
+
+ private Invocations() {
+ }
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/nls/NLSUtil.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/nls/NLSUtil.java
index ccaaa30b59..be8b94283b 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/nls/NLSUtil.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/nls/NLSUtil.java
@@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import com.ibm.icu.text.Collator;
+import java.text.Collator;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/participants/JavaProcessors.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/participants/JavaProcessors.java
index cbff353fc9..fa3071d89a 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/participants/JavaProcessors.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/participants/JavaProcessors.java
@@ -50,4 +50,7 @@ public class JavaProcessors {
}
return result.toArray(new String[result.size()]);
}
+
+ private JavaProcessors() {
+ }
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/participants/ResourceProcessors.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/participants/ResourceProcessors.java
index fd08091981..9b099dbb2a 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/participants/ResourceProcessors.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/participants/ResourceProcessors.java
@@ -52,4 +52,7 @@ public class ResourceProcessors {
computeNatures(result, visitedProjects, element);
}
}
+
+ private ResourceProcessors() {
+ }
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/rename/RenamingNameSuggestor.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/rename/RenamingNameSuggestor.java
index b601a515e7..8595502cc2 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/rename/RenamingNameSuggestor.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/rename/RenamingNameSuggestor.java
@@ -16,7 +16,7 @@ package org.eclipse.jdt.internal.corext.refactoring.rename;
import java.util.ArrayList;
import java.util.List;
-import com.ibm.icu.text.BreakIterator;
+import java.text.BreakIterator;
import org.eclipse.core.runtime.Assert;
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInnerToTopRefactoring.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInnerToTopRefactoring.java
index c1655b6f6e..aa7074820f 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInnerToTopRefactoring.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInnerToTopRefactoring.java
@@ -1155,7 +1155,7 @@ public final class MoveInnerToTopRefactoring extends Refactoring {
if (suggestedNames.length > 0)
return suggestedNames[0];
String name= enclosingType.getElementName();
- if (name.equals("")) //$NON-NLS-1$
+ if (name.isEmpty())
return ""; //$NON-NLS-1$
return Character.toLowerCase(name.charAt(0)) + name.substring(1);
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextEditUtil.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextEditUtil.java
index 3f235d455e..4e993604d5 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextEditUtil.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/util/TextEditUtil.java
@@ -352,4 +352,7 @@ public class TextEditUtil {
}
}
+ private TextEditUtil() {
+ }
+
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitContext.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitContext.java
index 971c22f98f..2af831ca26 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitContext.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitContext.java
@@ -30,7 +30,7 @@ import org.eclipse.jdt.core.JavaModelException;
/**
* A compilation unit context.
*/
-public class CompilationUnitContext extends DocumentTemplateContext implements ICompilationUnitContext {
+public class CompilationUnitContext extends DocumentTemplateContext {
/** The compilation unit, may be <code>null</code>. */
private final ICompilationUnit fCompilationUnit;
@@ -75,7 +75,6 @@ public class CompilationUnitContext extends DocumentTemplateContext implements I
*
* @return the compilation unit of this context or <code>null</code>
*/
- @Override
public final ICompilationUnit getCompilationUnit() {
return fCompilationUnit;
}
@@ -87,7 +86,6 @@ public class CompilationUnitContext extends DocumentTemplateContext implements I
* @param elementType the element type
* @return the enclosing element of the given type or <code>null</code>
*/
- @Override
public IJavaElement findEnclosingElement(int elementType) {
if (fCompilationUnit == null)
return null;
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitContextType.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitContextType.java
index b588dc3b33..f891bed637 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitContextType.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitContextType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -47,7 +47,7 @@ public abstract class CompilationUnitContextType extends TemplateContextType {
}
@Override
protected String resolve(TemplateContext context) {
- IJavaElement element= ((ICompilationUnitContext) context).findEnclosingElement(IJavaElement.METHOD);
+ IJavaElement element= ((CompilationUnitContext) context).findEnclosingElement(IJavaElement.METHOD);
if (element == null)
return null;
@@ -65,7 +65,7 @@ public abstract class CompilationUnitContextType extends TemplateContextType {
}
@Override
protected String resolve(TemplateContext context) {
- ICompilationUnit unit= ((ICompilationUnitContext) context).getCompilationUnit();
+ ICompilationUnit unit= ((CompilationUnitContext) context).getCompilationUnit();
return (unit == null) ? null : unit.getElementName();
}
@@ -86,7 +86,7 @@ public abstract class CompilationUnitContextType extends TemplateContextType {
}
@Override
protected String resolve(TemplateContext context) {
- ICompilationUnit unit= ((ICompilationUnitContext) context).getCompilationUnit();
+ ICompilationUnit unit= ((CompilationUnitContext) context).getCompilationUnit();
if (unit == null)
return null;
return JavaCore.removeJavaLikeExtension(unit.getElementName());
@@ -110,7 +110,7 @@ public abstract class CompilationUnitContextType extends TemplateContextType {
}
@Override
protected String resolve(TemplateContext context) {
- IJavaElement element= ((ICompilationUnitContext) context).findEnclosingElement(fElementType);
+ IJavaElement element= ((CompilationUnitContext) context).findEnclosingElement(fElementType);
if (element instanceof IType)
return JavaElementLabelsCore.getElementLabel(element, JavaElementLabelsCore.T_CONTAINER_QUALIFIED);
return (element == null) ? null : element.getElementName();
@@ -155,7 +155,7 @@ public abstract class CompilationUnitContextType extends TemplateContextType {
}
@Override
protected String resolve(TemplateContext context) {
- IJavaElement element= ((ICompilationUnitContext) context).findEnclosingElement(IJavaElement.METHOD);
+ IJavaElement element= ((CompilationUnitContext) context).findEnclosingElement(IJavaElement.METHOD);
if (element == null)
return null;
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/ICompilationUnitContext.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/ICompilationUnitContext.java
deleted file mode 100644
index ed56109a8a..0000000000
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/ICompilationUnitContext.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2019 Microsoft Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Microsoft Corporation - moved template related code to jdt.core.manipulation - https://bugs.eclipse.org/549989
- *******************************************************************************/
-package org.eclipse.jdt.internal.corext.template.java;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-
-public interface ICompilationUnitContext {
- /**
- * Returns the compilation unit if one is associated with this context,
- * <code>null</code> otherwise.
- * @param elementType the type of the element
- *
- * @return the compilation unit of this context or <code>null</code>
- */
- IJavaElement findEnclosingElement(int elementType);
-
- /**
- * Returns the compilation unit if one is associated with this context,
- * <code>null</code> otherwise.
- *
- * @return the compilation unit of this context or <code>null</code>
- */
- ICompilationUnit getCompilationUnit();
-}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/JavaContextCore.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/JavaContextCore.java
index f0fcdf040d..01a85b8291 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/JavaContextCore.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/template/java/JavaContextCore.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
+ * Copyright (c) 2019, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -51,7 +51,6 @@ import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.NamingConventions;
import org.eclipse.jdt.core.Signature;
@@ -183,7 +182,7 @@ public class JavaContextCore extends CompilationUnitContext implements IJavaCont
String key= getKey().toLowerCase();
if (key.length() > 0 || !isAfterDot()) {
String templateName= template.getName().toLowerCase();
- return JavaCore.ENABLED.equals(JavaCore.getOption(JavaCore.CODEASSIST_SUBSTRING_MATCH))
+ return JavaManipulationPlugin.CODEASSIST_SUBSTRING_MATCH_ENABLED
? templateName.contains(key)
: templateName.startsWith(key);
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/CodeFormatterUtil.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/CodeFormatterUtil.java
index 8e10f9abce..6e0501c1af 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/CodeFormatterUtil.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/CodeFormatterUtil.java
@@ -477,4 +477,7 @@ public class CodeFormatterUtil {
return edit;
}
+ private CodeFormatterUtil() {
+ }
+
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaConventionsUtil.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaConventionsUtil.java
index d1d4f6a52f..d1f39faa8a 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaConventionsUtil.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaConventionsUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 IBM Corporation and others.
+ * Copyright (c) 2007, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -37,7 +37,8 @@ public class JavaConventionsUtil {
* @param context an {@link IJavaElement} or <code>null</code>
* @return a <code>String[]</code> whose <code>[0]</code> is the
* {@link JavaCore#COMPILER_SOURCE} and whose <code>[1]</code> is
- * the {@link JavaCore#COMPILER_COMPLIANCE} level at the given
+ * the {@link JavaCore#COMPILER_COMPLIANCE} and whose <code>[2]</code> is
+ * the {@link JavaCore#COMPILER_PB_ENABLE_PREVIEW_FEATURES} value at the given
* <code>context</code>.
*/
public static String[] getSourceComplianceLevels(IJavaElement context) {
@@ -46,13 +47,15 @@ public class JavaConventionsUtil {
if (javaProject != null) {
return new String[] {
javaProject.getOption(JavaCore.COMPILER_SOURCE, true),
- javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true)
+ javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true),
+ javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true)
};
}
}
return new String[] {
JavaCore.getOption(JavaCore.COMPILER_SOURCE),
- JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE)
+ JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE),
+ JavaCore.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES)
};
}
@@ -125,7 +128,7 @@ public class JavaConventionsUtil {
*/
public static IStatus validateJavaTypeName(String name, IJavaElement context) {
String[] sourceComplianceLevels= getSourceComplianceLevels(context);
- return JavaConventions.validateJavaTypeName(name, sourceComplianceLevels[0], sourceComplianceLevels[1]);
+ return JavaConventions.validateJavaTypeName(name, sourceComplianceLevels[0], sourceComplianceLevels[1], sourceComplianceLevels[2]);
}
/**
@@ -163,4 +166,7 @@ public class JavaConventionsUtil {
String[] sourceComplianceLevels= getSourceComplianceLevels(context);
return JavaConventions.validateTypeVariableName(name, sourceComplianceLevels[0], sourceComplianceLevels[1]);
}
+
+ private JavaConventionsUtil() {
+ }
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java
index 37daa4497a..7fcd817889 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java
@@ -1185,4 +1185,7 @@ public final class JavaModelUtil {
cu.save(subMonitor.split(1), true);
}
}
+
+ private JavaModelUtil() {
+ }
}
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/Messages.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/Messages.java
index 9664b8c06f..50f6056966 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/Messages.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/Messages.java
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.corext.util;
-import com.ibm.icu.text.MessageFormat;
+import java.text.MessageFormat;
/**
* Helper class to format message strings.
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/SearchUtils.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/SearchUtils.java
index 656b8684fd..23bf0bce55 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/SearchUtils.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/SearchUtils.java
@@ -76,4 +76,7 @@ public class SearchUtils {
public static boolean isCamelCasePattern(String pattern) {
return SearchPattern.validateMatchRule(pattern, SearchPattern.R_CAMELCASE_MATCH) == SearchPattern.R_CAMELCASE_MATCH;
}
+
+ private SearchUtils() {
+ }
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/SuperTypeHierarchyCache.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/SuperTypeHierarchyCache.java
index 9981312e9f..ac82f37b02 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/SuperTypeHierarchyCache.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/SuperTypeHierarchyCache.java
@@ -232,4 +232,7 @@ public class SuperTypeHierarchyCache {
public static int getCacheMisses() {
return fgCacheMisses;
}
+
+ private SuperTypeHierarchyCache() {
+ }
}
diff --git a/org.eclipse.jdt.core.manipulation/pom.xml b/org.eclipse.jdt.core.manipulation/pom.xml
index 406193888d..489d075a36 100644
--- a/org.eclipse.jdt.core.manipulation/pom.xml
+++ b/org.eclipse.jdt.core.manipulation/pom.xml
@@ -14,10 +14,10 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core.manipulation</artifactId>
- <version>1.14.0-SNAPSHOT</version>
+ <version>1.14.100-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/core/refactoring/descriptors/JavaRefactoringDescriptor.java b/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/core/refactoring/descriptors/JavaRefactoringDescriptor.java
index 41e6fa976e..ba47d5da87 100644
--- a/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/core/refactoring/descriptors/JavaRefactoringDescriptor.java
+++ b/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/core/refactoring/descriptors/JavaRefactoringDescriptor.java
@@ -302,7 +302,7 @@ public abstract class JavaRefactoringDescriptor extends RefactoringDescriptor {
JavaRefactoringContribution javaContribution= (JavaRefactoringContribution) contribution;
refactoring= javaContribution.createRefactoring(this, status);
} else
- JavaManipulationPlugin.log(new Status(IStatus.ERROR, JavaManipulationPlugin.getPluginId(), 0, MessageFormat.format(DescriptorMessages.JavaRefactoringDescriptor_no_resulting_descriptor, new Object[] { id}), null));
+ JavaManipulationPlugin.log(new Status(IStatus.ERROR, JavaManipulationPlugin.getPluginId(), 0, MessageFormat.format(DescriptorMessages.JavaRefactoringDescriptor_no_resulting_descriptor, id), null));
}
return refactoring;
}
diff --git a/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/core/refactoring/descriptors/JavaRefactoringDescriptorUtil.java b/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/core/refactoring/descriptors/JavaRefactoringDescriptorUtil.java
index 37863cadce..708d8c1ecf 100644
--- a/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/core/refactoring/descriptors/JavaRefactoringDescriptorUtil.java
+++ b/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/core/refactoring/descriptors/JavaRefactoringDescriptorUtil.java
@@ -661,4 +661,7 @@ public class JavaRefactoringDescriptorUtil {
}
}
+ private JavaRefactoringDescriptorUtil() {
+ }
+
}
diff --git a/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/core/refactoring/descriptors/RefactoringSignatureDescriptorFactory.java b/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/core/refactoring/descriptors/RefactoringSignatureDescriptorFactory.java
index 2ef44279fc..14445a1d32 100644
--- a/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/core/refactoring/descriptors/RefactoringSignatureDescriptorFactory.java
+++ b/org.eclipse.jdt.core.manipulation/refactoring/org/eclipse/jdt/internal/core/refactoring/descriptors/RefactoringSignatureDescriptorFactory.java
@@ -285,4 +285,7 @@ public class RefactoringSignatureDescriptorFactory {
return new UseSupertypeDescriptor(project, description, comment, arguments, flags);
}
+ private RefactoringSignatureDescriptorFactory() {
+ }
+
}
diff --git a/org.eclipse.jdt.jeview.feature/feature.xml b/org.eclipse.jdt.jeview.feature/feature.xml
index f9783ef181..f2839a0c32 100644
--- a/org.eclipse.jdt.jeview.feature/feature.xml
+++ b/org.eclipse.jdt.jeview.feature/feature.xml
@@ -2,15 +2,15 @@
<feature
id="org.eclipse.jdt.jeview.feature"
label="JavaElement View"
- version="1.0.10.qualifier"
+ version="1.0.11.qualifier"
provider-name="Eclipse.org"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
<description>
- JavaElement View for Eclipse 2019-12 and later (jdt.core 3.20)
+ JavaElement View for Eclipse 2020-06 and later (jdt.core 3.22)
</description>
-
+
<license url="%licenseURL">
%license
</license>
diff --git a/org.eclipse.jdt.jeview.feature/pom.xml b/org.eclipse.jdt.jeview.feature/pom.xml
index c8d7a9e967..7f261075d7 100644
--- a/org.eclipse.jdt.jeview.feature/pom.xml
+++ b/org.eclipse.jdt.jeview.feature/pom.xml
@@ -14,10 +14,10 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt.feature</groupId>
<artifactId>org.eclipse.jdt.jeview.feature</artifactId>
- <version>1.0.10-SNAPSHOT</version>
+ <version>1.0.11-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
</project>
diff --git a/org.eclipse.jdt.jeview/pom.xml b/org.eclipse.jdt.jeview/pom.xml
index 08c90bbef9..cc4abe7050 100644
--- a/org.eclipse.jdt.jeview/pom.xml
+++ b/org.eclipse.jdt.jeview/pom.xml
@@ -14,7 +14,7 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.jeview</artifactId>
diff --git a/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/JEPluginImages.java b/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/JEPluginImages.java
index 9e30101dcb..5f824bd875 100644
--- a/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/JEPluginImages.java
+++ b/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/JEPluginImages.java
@@ -49,4 +49,7 @@ public class JEPluginImages {
return ImageDescriptor.getMissingImageDescriptor();
}
}
+
+ private JEPluginImages() {
+ }
}
diff --git a/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/properties/MarkerProperties.java b/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/properties/MarkerProperties.java
index 5297920f8f..4b03f672fc 100644
--- a/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/properties/MarkerProperties.java
+++ b/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/properties/MarkerProperties.java
@@ -207,9 +207,7 @@ public class MarkerProperties implements IPropertySource {
if (f.getType() == int.class && f.getInt(f) == id) {
return "IProblem." + f.getName();
}
- } catch (IllegalArgumentException e) {
- // does not happen
- } catch (IllegalAccessException e) {
+ } catch (IllegalArgumentException | IllegalAccessException e) {
// does not happen
}
}
diff --git a/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/properties/MemberValuePairProperties.java b/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/properties/MemberValuePairProperties.java
index 8ffc210ed8..e4003587b2 100644
--- a/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/properties/MemberValuePairProperties.java
+++ b/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/properties/MemberValuePairProperties.java
@@ -95,9 +95,7 @@ public class MemberValuePairProperties implements IPropertySource {
name= "IMemberValuePair." + f.getName();
break;
}
- } catch (IllegalArgumentException e) {
- // continue
- } catch (IllegalAccessException e) {
+ } catch (IllegalArgumentException | IllegalAccessException e) {
// continue
}
}
diff --git a/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/views/JavaElementView.java b/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/views/JavaElementView.java
index 9e4ba42fb6..6fac75a96f 100644
--- a/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/views/JavaElementView.java
+++ b/org.eclipse.jdt.jeview/src/org/eclipse/jdt/jeview/views/JavaElementView.java
@@ -619,9 +619,7 @@ public class JavaElementView extends ViewPart implements IShowInSource, IShowInT
Runner runner= new Runner();
try {
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runner);
- } catch (InvocationTargetException e) {
- JEViewPlugin.log(e);
- } catch (InterruptedException e) {
+ } catch (InvocationTargetException | InterruptedException e) {
JEViewPlugin.log(e);
}
JavaElement element= new JavaElement(fInput, fullyQualifiedName, runner.type);
@@ -709,9 +707,7 @@ public class JavaElementView extends ViewPart implements IShowInSource, IShowInT
Runner runner= new Runner();
try {
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runner);
- } catch (InvocationTargetException e) {
- JEViewPlugin.log(e);
- } catch (InterruptedException e) {
+ } catch (InvocationTargetException | InterruptedException e) {
JEViewPlugin.log(e);
}
JavaElement element= new JavaElement(fInput, bindingKey, runner.element);
diff --git a/org.eclipse.jdt.junit.core/pom.xml b/org.eclipse.jdt.junit.core/pom.xml
index cab837a094..e4f997ae01 100644
--- a/org.eclipse.jdt.junit.core/pom.xml
+++ b/org.eclipse.jdt.junit.core/pom.xml
@@ -14,7 +14,7 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.junit.core</artifactId>
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/buildpath/BuildPathSupport.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/buildpath/BuildPathSupport.java
index 36f6b0d4ad..6289df46ee 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/buildpath/BuildPathSupport.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/buildpath/BuildPathSupport.java
@@ -496,4 +496,7 @@ public class BuildPathSupport {
public static IClasspathEntry getJUnitApiGuardianLibraryEntry() {
return JUNIT_APIGUARDIAN_PLUGIN.getLibraryEntry();
}
+
+ private BuildPathSupport() {
+ }
}
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/buildpath/P2Utils.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/buildpath/P2Utils.java
index 1321800bf7..5a0c548380 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/buildpath/P2Utils.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/buildpath/P2Utils.java
@@ -142,4 +142,7 @@ class P2Utils {
}
}
+ private P2Utils() {
+ }
+
}
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfigurationConstants.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfigurationConstants.java
index 424abfeff2..d45248e367 100644
--- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfigurationConstants.java
+++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/launcher/JUnitLaunchConfigurationConstants.java
@@ -106,5 +106,8 @@ public class JUnitLaunchConfigurationConstants {
return null;
}
+ private JUnitLaunchConfigurationConstants() {
+ }
+
}
diff --git a/org.eclipse.jdt.junit.runtime/META-INF/MANIFEST.MF b/org.eclipse.jdt.junit.runtime/META-INF/MANIFEST.MF
index 2a2170e55b..7a0be9183c 100644
--- a/org.eclipse.jdt.junit.runtime/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.junit.runtime/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.junit.runtime
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.junit.runtime;singleton:=true
-Bundle-Version: 3.5.100.qualifier
+Bundle-Version: 3.5.200.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.jdt.internal.junit.runner;
diff --git a/org.eclipse.jdt.junit.runtime/pom.xml b/org.eclipse.jdt.junit.runtime/pom.xml
index 824f3b8981..d30d8230e1 100644
--- a/org.eclipse.jdt.junit.runtime/pom.xml
+++ b/org.eclipse.jdt.junit.runtime/pom.xml
@@ -14,10 +14,10 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.junit.runtime</artifactId>
- <version>3.5.100-SNAPSHOT</version>
+ <version>3.5.200-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/MessageIds.java b/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/MessageIds.java
index bb24f00b69..0f6c41cf99 100644
--- a/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/MessageIds.java
+++ b/org.eclipse.jdt.junit.runtime/src/org/eclipse/jdt/internal/junit/runner/MessageIds.java
@@ -149,6 +149,9 @@ public class MessageIds {
* Test identifier prefix for tests with assumption failures.
*/
public static final String ASSUMPTION_FAILED_TEST_PREFIX= "@AssumptionFailure: "; //$NON-NLS-1$
+
+ private MessageIds() {
+ }
}
diff --git a/org.eclipse.jdt.junit/pom.xml b/org.eclipse.jdt.junit/pom.xml
index f2d5e66193..54d94953a8 100644
--- a/org.eclipse.jdt.junit/pom.xml
+++ b/org.eclipse.jdt.junit/pom.xml
@@ -14,7 +14,7 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.junit</artifactId>
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/buildpath/JUnitContainerWizardPage.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/buildpath/JUnitContainerWizardPage.java
index f42b8507e3..4a22fd62e0 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/buildpath/JUnitContainerWizardPage.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/buildpath/JUnitContainerWizardPage.java
@@ -122,11 +122,7 @@ public class JUnitContainerWizardPage extends NewElementWizardPage implements IC
label.setText(JUnitMessages.JUnitContainerWizardPage_combo_label);
fVersionCombo= new Combo(composite, SWT.READ_ONLY);
- fVersionCombo.setItems(new String[] {
- JUnitMessages.JUnitContainerWizardPage_option_junit3,
- JUnitMessages.JUnitContainerWizardPage_option_junit4,
- JUnitMessages.JUnitContainerWizardPage_option_junit5
- });
+ fVersionCombo.setItems(JUnitMessages.JUnitContainerWizardPage_option_junit3, JUnitMessages.JUnitContainerWizardPage_option_junit4, JUnitMessages.JUnitContainerWizardPage_option_junit5);
fVersionCombo.setFont(composite.getFont());
GridData data= new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1);
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/AssertionVMArg.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/AssertionVMArg.java
index 1c8335bdbb..058087d0f7 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/AssertionVMArg.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/launcher/AssertionVMArg.java
@@ -134,4 +134,7 @@ public class AssertionVMArg {
}
}*/
+
+ private AssertionVMArg() {
+ }
}
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/OpenTestAction.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/OpenTestAction.java
index 2fccc7e0b9..a0c4d8ae67 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/OpenTestAction.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/OpenTestAction.java
@@ -110,7 +110,7 @@ public class OpenTestAction extends OpenEditorAction {
private static String extractRealMethodName(TestCaseElement testCase) {
//workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=334864 :
- if (testCase.isIgnored() && JavaConventions.validateJavaTypeName(testCase.getTestName(), JavaCore.VERSION_1_5, JavaCore.VERSION_1_5).getSeverity() != IStatus.ERROR) {
+ if (testCase.isIgnored() && JavaConventions.validateJavaTypeName(testCase.getTestName(), JavaCore.VERSION_1_5, JavaCore.VERSION_1_5, null).getSeverity() != IStatus.ERROR) {
return null;
}
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java
index 82e4e1a54f..ec5084f714 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestRunnerViewPart.java
@@ -53,7 +53,6 @@ import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.DropTargetAdapter;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.dnd.URLTransfer;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
@@ -1629,7 +1628,7 @@ action enablement
String testRunLabel= BasicElementLabels.getJavaElementName(fTestRunSession.getTestRunName());
if (testKindDisplayStr != null)
- setTitleToolTip(MessageFormat.format(JUnitMessages.TestRunnerViewPart_titleToolTip, new Object[] {testRunLabel, testKindDisplayStr}));
+ setTitleToolTip(MessageFormat.format(JUnitMessages.TestRunnerViewPart_titleToolTip, testRunLabel, testKindDisplayStr));
else
setTitleToolTip(testRunLabel);
}
@@ -1871,7 +1870,7 @@ action enablement
private void addDropAdapter(Composite parent) {
DropTarget dropTarget = new DropTarget(parent, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
- dropTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
+ dropTarget.setTransfer(TextTransfer.getInstance());
class DropAdapter extends DropTargetAdapter {
@Override
public void dragEnter(DropTargetEvent event) {
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/CheckedTableSelectionDialog.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/CheckedTableSelectionDialog.java
index eb7f89a5d1..818b595117 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/CheckedTableSelectionDialog.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/CheckedTableSelectionDialog.java
@@ -90,7 +90,7 @@ public class CheckedTableSelectionDialog extends SelectionStatusDialog {
* @param selection the initial selection.
*/
public void setInitialSelection(Object selection) {
- setInitialSelections(new Object[] {selection});
+ setInitialSelections(selection);
}
/**
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/JUnitStubUtility.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/JUnitStubUtility.java
index d27646cf90..4b288943cb 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/JUnitStubUtility.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/JUnitStubUtility.java
@@ -409,5 +409,8 @@ public class JUnitStubUtility {
return result;
}
+ private JUnitStubUtility() {
+ }
+
}
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/LayoutUtil.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/LayoutUtil.java
index afa5a3cd31..d76a1e08c7 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/LayoutUtil.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/LayoutUtil.java
@@ -169,4 +169,7 @@ public class LayoutUtil {
((GridData) ld).heightHint= heightHint;
}
}
+
+ private LayoutUtil() {
+ }
}
diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationTab.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationTab.java
index 0d144d312c..7a900f1b34 100644
--- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationTab.java
+++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationTab.java
@@ -886,7 +886,7 @@ public class JUnitLaunchConfigurationTab extends AbstractLaunchConfigurationTab
IJavaProject javaProject = getJavaProject();
if (javaProject != null) {
- dialog.setInitialSelections(new Object[] { javaProject });
+ dialog.setInitialSelections(javaProject);
}
if (dialog.open() == Window.OK) {
return (IJavaProject) dialog.getFirstResult();
diff --git a/org.eclipse.jdt.junit4.runtime/pom.xml b/org.eclipse.jdt.junit4.runtime/pom.xml
index 48e72641ab..f8cd1554b4 100644
--- a/org.eclipse.jdt.junit4.runtime/pom.xml
+++ b/org.eclipse.jdt.junit4.runtime/pom.xml
@@ -14,7 +14,7 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.junit4.runtime</artifactId>
diff --git a/org.eclipse.jdt.junit5.runtime/META-INF/MANIFEST.MF b/org.eclipse.jdt.junit5.runtime/META-INF/MANIFEST.MF
index b0f62c8ed4..4c24b93662 100644
--- a/org.eclipse.jdt.junit5.runtime/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.junit5.runtime/META-INF/MANIFEST.MF
@@ -4,7 +4,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.jdt.junit5.runtime;singleton:=true
-Bundle-Version: 1.0.800.qualifier
+Bundle-Version: 1.0.900.qualifier
Bundle-Localization: plugin
Export-Package: org.eclipse.jdt.internal.junit5.runner;x-internal:=true
Require-Bundle: org.eclipse.jdt.junit.runtime;bundle-version="[3.5.0,4.0.0)",
diff --git a/org.eclipse.jdt.junit5.runtime/pom.xml b/org.eclipse.jdt.junit5.runtime/pom.xml
index 558785cec2..69d7f5c44e 100644
--- a/org.eclipse.jdt.junit5.runtime/pom.xml
+++ b/org.eclipse.jdt.junit5.runtime/pom.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (c) 2016, 2019 Eclipse Foundation and others.
+ Copyright (c) 2016, 2020 Eclipse Foundation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
@@ -14,10 +14,10 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.junit5.runtime</artifactId>
- <version>1.0.800-SNAPSHOT</version>
+ <version>1.0.900-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/org.eclipse.jdt.junit5.runtime/src/org/eclipse/jdt/internal/junit5/runner/JUnit5TestListener.java b/org.eclipse.jdt.junit5.runtime/src/org/eclipse/jdt/internal/junit5/runner/JUnit5TestListener.java
index bb6b7669e8..618c114399 100644
--- a/org.eclipse.jdt.junit5.runtime/src/org/eclipse/jdt/internal/junit5/runner/JUnit5TestListener.java
+++ b/org.eclipse.jdt.junit5.runtime/src/org/eclipse/jdt/internal/junit5/runner/JUnit5TestListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016, 2018 IBM Corporation and others.
+ * Copyright (c) 2016, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -113,25 +113,7 @@ public class JUnit5TestListener implements TestExecutionListener {
}
if (exception instanceof MultipleFailuresError) {
- String expectedStr= ""; //$NON-NLS-1$
- String actualStr= ""; //$NON-NLS-1$
- String delimiter= "\n\n"; //$NON-NLS-1$
- List<Throwable> failures= ((MultipleFailuresError) exception).getFailures();
- for (Throwable assertionError : failures) {
- if (assertionError instanceof AssertionFailedError) {
- AssertionFailedError assertionFailedError= (AssertionFailedError) assertionError;
- ValueWrapper expected= assertionFailedError.getExpected();
- ValueWrapper actual= assertionFailedError.getActual();
- if (expected == null || actual == null) {
- return null;
- }
- expectedStr+= expected.getStringRepresentation() + delimiter;
- actualStr+= actual.getStringRepresentation() + delimiter;
- } else {
- return null;
- }
- }
- return new FailedComparison(expectedStr, actualStr);
+ return getComparisonForMultipleFailures(exception);
}
// Avoid reference to ComparisonFailure initially to avoid NoClassDefFoundError for ComparisonFailure when junit.jar is not on the build path
@@ -148,6 +130,37 @@ public class JUnit5TestListener implements TestExecutionListener {
return null;
}
+ protected FailedComparison getComparisonForMultipleFailures(Throwable exception) {
+ String expectedStr= ""; //$NON-NLS-1$
+ String actualStr= ""; //$NON-NLS-1$
+ String delimiter= "\n\n"; //$NON-NLS-1$
+ List<Throwable> failures= ((MultipleFailuresError) exception).getFailures();
+ for (Throwable assertionError : failures) {
+ if (assertionError instanceof MultipleFailuresError) {
+ FailedComparison failedComparison= getComparisonForMultipleFailures(assertionError);
+ String expected= failedComparison.getExpected();
+ String actual= failedComparison.getActual();
+ if (expected == null || actual == null) {
+ return null;
+ }
+ expectedStr+= expected;
+ actualStr+= actual;
+ } else if (assertionError instanceof AssertionFailedError) {
+ AssertionFailedError assertionFailedError= (AssertionFailedError) assertionError;
+ ValueWrapper expected= assertionFailedError.getExpected();
+ ValueWrapper actual= assertionFailedError.getActual();
+ if (expected == null || actual == null) {
+ return null;
+ }
+ expectedStr+= expected.getStringRepresentation() + delimiter;
+ actualStr+= actual.getStringRepresentation() + delimiter;
+ } else {
+ return null;
+ }
+ }
+ return new FailedComparison(expectedStr, actualStr);
+ }
+
@Override
public void executionSkipped(TestIdentifier testIdentifier, String reason) {
if (testIdentifier.isContainer() && fTestPlan != null) {
diff --git a/org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF
index fa88eff2ce..6b0aa10026 100644
--- a/org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF
@@ -35,7 +35,6 @@ Require-Bundle:
org.eclipse.core.filebuffers.tests,
org.eclipse.jdt.ui.tests,
org.eclipse.test.performance,
- com.ibm.icu,
org.eclipse.jdt.core.manipulation,
org.eclipse.core.expressions
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/org.eclipse.jdt.text.tests/pom.xml b/org.eclipse.jdt.text.tests/pom.xml
index eb6eb7f751..69a778fc33 100644
--- a/org.eclipse.jdt.text.tests/pom.xml
+++ b/org.eclipse.jdt.text.tests/pom.xml
@@ -15,7 +15,7 @@
<parent>
<artifactId>tests-pom</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
<relativePath>../tests-pom/</relativePath>
</parent>
<groupId>org.eclipse.jdt</groupId>
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BracketInserterTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BracketInserterTest.java
index 7b0e872400..aeac004f5a 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BracketInserterTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BracketInserterTest.java
@@ -13,9 +13,18 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.text.tests.performance.DisplayHelper;
@@ -57,14 +66,15 @@ import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
-
/**
* Tests the automatic bracket insertion feature of the CUEditor. Also tests
* linked mode along the way.
*
* @since 3.1
*/
-public class BracketInserterTest extends TestCase {
+public class BracketInserterTest {
+ @Rule
+ public TestName tn= new TestName();
private static final String SRC= "src";
private static final String SEP= "/";
@@ -97,36 +107,28 @@ public class BracketInserterTest extends TestCase {
private static final int FOO_VOID_OFFSET= 207;
private static final int FIELD_OFFSET= 264;
- public static Test suite() {
- TestSuite suite= new TestSuite(BracketInserterTest.class);
-// BracketInserterTest loop= new BracketInserterTest();
-// loop.setName("testLoop");
- return suite;
-// return loop;
- }
-
private JavaEditor fEditor;
private StyledText fTextWidget;
private IDocument fDocument;
private Accessor fAccessor;
private IJavaProject fProject;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setValue(PreferenceConstants.EDITOR_CLOSE_BRACKETS, true);
}
private void setUpProject(String sourceLevel) throws CoreException, JavaModelException {
- fProject= JavaProjectHelper.createJavaProject(getName(), "bin");
+ fProject= JavaProjectHelper.createJavaProject(tn.getMethodName(), "bin");
fProject.setOption(JavaCore.COMPILER_SOURCE, sourceLevel);
JavaProjectHelper.addSourceContainer(fProject, SRC);
- IPackageFragment fragment= fProject.findPackageFragment(new Path(SEP + getName() + SEP + SRC));
+ IPackageFragment fragment= fProject.findPackageFragment(new Path(SEP + tn.getMethodName() + SEP + SRC));
fragment.createCompilationUnit(CU_NAME, CU_CONTENTS, true, new NullProgressMonitor());
}
private void setUpEditor() {
- fEditor= openJavaEditor(new Path(SEP + getName() + SEP + SRC + SEP + CU_NAME));
+ fEditor= openJavaEditor(new Path(SEP + tn.getMethodName() + SEP + SRC + SEP + CU_NAME));
assertNotNull(fEditor);
fTextWidget= fEditor.getViewer().getTextWidget();
assertNotNull(fTextWidget);
@@ -138,7 +140,8 @@ public class BracketInserterTest extends TestCase {
private JavaEditor openJavaEditor(IPath path) {
IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- assertTrue(file != null && file.exists());
+ assertNotNull(file);
+ assertTrue(file.exists());
try {
return (JavaEditor)EditorTestHelper.openInEditor(file, true);
} catch (PartInitException e) {
@@ -147,8 +150,8 @@ public class BracketInserterTest extends TestCase {
}
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
EditorTestHelper.closeEditor(fEditor);
fEditor= null;
if (fProject != null) {
@@ -161,6 +164,7 @@ public class BracketInserterTest extends TestCase {
store.setValue(PreferenceConstants.EDITOR_CLOSE_BRACKETS, true);
}
+ @Test
public void testInsertClosingParenthesis() throws BadLocationException, JavaModelException, CoreException, JavaModelException, CoreException {
use14();
setCaret(BODY_OFFSET);
@@ -170,6 +174,7 @@ public class BracketInserterTest extends TestCase {
assertSingleLinkedPosition(BODY_OFFSET + 1);
}
+ @Test
public void testDeletingParenthesis() throws JavaModelException, CoreException {
use14();
setCaret(BODY_OFFSET);
@@ -180,6 +185,7 @@ public class BracketInserterTest extends TestCase {
assertFalse(LinkedModeModel.hasInstalledModel(fDocument));
}
+ @Test
public void testMultipleParenthesisInsertion() throws BadLocationException, JavaModelException, CoreException {
use14();
setCaret(BODY_OFFSET);
@@ -191,6 +197,7 @@ public class BracketInserterTest extends TestCase {
assertModel(true);
}
+ @Test
public void testDeletingMultipleParenthesisInertion() throws BadLocationException, JavaModelException, CoreException {
use14();
setCaret(BODY_OFFSET);
@@ -217,6 +224,7 @@ public class BracketInserterTest extends TestCase {
assertFalse(LinkedModeModel.hasInstalledModel(fDocument));
}
+ @Test
public void testNoInsertInsideText() throws BadLocationException, JavaModelException, CoreException {
use14();
setCaret(ARGS_OFFSET);
@@ -227,6 +235,7 @@ public class BracketInserterTest extends TestCase {
assertFalse(LinkedModeModel.hasInstalledModel(fDocument));
}
+ @Test
public void testInsertInsideBrackets() throws BadLocationException, JavaModelException, CoreException {
use14();
setCaret(BRACKETS_OFFSET);
@@ -236,6 +245,7 @@ public class BracketInserterTest extends TestCase {
assertSingleLinkedPosition(BRACKETS_OFFSET + 1);
}
+ @Test
public void testPeerEntry() throws BadLocationException, JavaModelException, CoreException {
use14();
setCaret(BODY_OFFSET);
@@ -255,6 +265,7 @@ public class BracketInserterTest extends TestCase {
// }
// }
//
+ @Test
public void testMultiplePeerEntry() throws BadLocationException, JavaModelException, CoreException {
use14();
setCaret(BODY_OFFSET);
@@ -279,6 +290,7 @@ public class BracketInserterTest extends TestCase {
assertFalse(LinkedModeModel.hasInstalledModel(fDocument));
}
+ @Test
public void testExitOnTab() throws BadLocationException, JavaModelException, CoreException {
use14();
setCaret(BODY_OFFSET);
@@ -302,6 +314,7 @@ public class BracketInserterTest extends TestCase {
assertFalse(LinkedModeModel.hasInstalledModel(fDocument));
}
+ @Test
public void testExitOnReturn() throws BadLocationException, JavaModelException, CoreException {
use14();
setCaret(BODY_OFFSET);
@@ -314,6 +327,7 @@ public class BracketInserterTest extends TestCase {
assertFalse(LinkedModeModel.hasInstalledModel(fDocument));
}
+ @Test
public void testExitOnEsc() throws BadLocationException, JavaModelException, CoreException {
use14();
setCaret(BODY_OFFSET);
@@ -326,6 +340,7 @@ public class BracketInserterTest extends TestCase {
assertFalse(LinkedModeModel.hasInstalledModel(fDocument));
}
+ @Test
public void testInsertClosingQuote() throws BadLocationException, JavaModelException, CoreException {
use14();
setCaret(BODY_OFFSET);
@@ -336,6 +351,7 @@ public class BracketInserterTest extends TestCase {
assertSingleLinkedPosition(BODY_OFFSET + 1);
}
+ @Test
public void testPreferences() throws BadLocationException, JavaModelException, CoreException {
use14();
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
@@ -350,30 +366,33 @@ public class BracketInserterTest extends TestCase {
assertFalse(LinkedModeModel.hasInstalledModel(fDocument));
}
+ @Test
public void testAngleBracketsAsOperator() throws Exception {
use15();
setCaret(BODY_OFFSET);
type("test<");
assertEquals("test<", fDocument.get(BODY_OFFSET, 5));
- assertFalse(">".equals(fDocument.get(BODY_OFFSET + 5, 1)));
+ assertNotEquals(">", fDocument.get(BODY_OFFSET + 5, 1));
assertEquals(BODY_OFFSET + 5, getCaret());
assertFalse(LinkedModeModel.hasInstalledModel(fDocument));
}
+ @Test
public void testAngleBracketsIn14Project() throws BadLocationException, JavaModelException, CoreException {
use14();
setCaret(BODY_OFFSET);
type("Test<");
assertEquals("Test<", fDocument.get(BODY_OFFSET, 5));
- assertFalse(">".equals(fDocument.get(BODY_OFFSET + 5, 1)));
+ assertNotEquals(">", fDocument.get(BODY_OFFSET + 5, 1));
assertEquals(BODY_OFFSET + 5, getCaret());
assertFalse(LinkedModeModel.hasInstalledModel(fDocument));
}
+ @Test
public void testAngleBracketsIn15Project() throws Exception {
use15();
@@ -384,6 +403,7 @@ public class BracketInserterTest extends TestCase {
assertSingleLinkedPosition(BODY_OFFSET + 5);
}
+ @Test
public void testAngleBracketsInFieldDecl15() throws Exception {
use15();
@@ -394,6 +414,7 @@ public class BracketInserterTest extends TestCase {
assertSingleLinkedPosition(FIELD_OFFSET + 1);
}
+ @Test
public void testAngleBracketsInsideMethodDecl15() throws Exception {
use15();
@@ -404,6 +425,7 @@ public class BracketInserterTest extends TestCase {
assertSingleLinkedPosition(MAIN_VOID_OFFSET + 1);
}
+ @Test
public void testAngleBracketsBeforeMethodDecl15() throws Exception {
use15();
@@ -415,6 +437,7 @@ public class BracketInserterTest extends TestCase {
assertSingleLinkedPosition(FOO_VOID_OFFSET + 1);
}
+ @Test
public void testAngleBracketsBeforeTypeArgument15() throws Exception {
use15();
@@ -430,6 +453,7 @@ public class BracketInserterTest extends TestCase {
assertFalse(LinkedModeModel.hasInstalledModel(fDocument));
}
+ @Test
public void testAngleBracketsBeforeWildcard15() throws Exception {
use15();
@@ -445,6 +469,7 @@ public class BracketInserterTest extends TestCase {
assertFalse(LinkedModeModel.hasInstalledModel(fDocument));
}
+ @Test
public void testAngleBracketsAfterIdentifierOnFirstColumn1_15() throws Exception {
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=347734
use15();
@@ -460,6 +485,7 @@ public class BracketInserterTest extends TestCase {
assertFalse(LinkedModeModel.hasInstalledModel(fDocument));
}
+ @Test
public void testAngleBracketsAfterIdentifierOnFirstColumn2_15() throws Exception {
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=347734
use15();
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BreakContinueTargetFinderTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BreakContinueTargetFinderTest.java
index feaeed01a5..5f053ed41b 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BreakContinueTargetFinderTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BreakContinueTargetFinderTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2016 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,9 +13,17 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import java.util.Arrays;
import java.util.Comparator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.core.ICompilationUnit;
@@ -26,31 +34,21 @@ import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.ui.tests.core.ProjectTestSetup;
-
-import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
-import org.eclipse.jdt.internal.ui.search.BreakContinueTargetFinder;
import org.eclipse.jdt.internal.core.manipulation.search.IOccurrencesFinder.OccurrenceLocation;
+import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
+
+import org.eclipse.jdt.internal.ui.search.BreakContinueTargetFinder;
/**
* Tests for the BreakContinueTargerFinder class.
*
* @since 3.2
*/
-public class BreakContinueTargetFinderTest extends TestCase{
- private static final Class<BreakContinueTargetFinderTest> THIS= BreakContinueTargetFinderTest.class;
-
- public static Test suite() {
- return new ProjectTestSetup(new TestSuite(THIS));
- }
-
- public static Test setUpTest(Test test) {
- return new ProjectTestSetup(test);
- }
+public class BreakContinueTargetFinderTest {
+ @Rule
+ public ProjectTestSetup pts= new ProjectTestSetup();
private ASTParser fParser;
private BreakContinueTargetFinder fFinder;
@@ -60,8 +58,8 @@ public class BreakContinueTargetFinderTest extends TestCase{
/*
* @see junit.framework.TestCase#setUp()
*/
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
fParser = ASTParser.newParser(IASTSharedValues.SHARED_AST_LEVEL);
fFinder= new BreakContinueTargetFinder();
@@ -69,8 +67,8 @@ public class BreakContinueTargetFinderTest extends TestCase{
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
JavaProjectHelper.clear(fJProject1, ProjectTestSetup.getDefaultClasspath());
}
@@ -126,6 +124,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
return find(s, pattern, ithOccurrence-1, idx+1);
}
+ @Test
public void testBreakFor() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -141,6 +140,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testBreakForeach() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -156,6 +156,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testBreakWhile() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -172,6 +173,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testBreakDo() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -188,6 +190,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testBreakSwitch() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -204,6 +207,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testLabeledBreakFor() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -221,6 +225,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testLabeledBreakFor1() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -238,6 +243,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testBreakFor2() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -255,6 +261,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testLabeledBreakIf() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -277,6 +284,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testContinueFor() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -292,6 +300,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testContinueForeach() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -307,6 +316,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testContinueWhile() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -323,6 +333,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testContinueDo() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -340,6 +351,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
}
//continue skips over switches
+ @Test
public void testContinueSwitch() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -358,6 +370,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testLabeledContinueFor() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -375,6 +388,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testLabeledContinueFor1() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -392,6 +406,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testLabeledContinueFor2() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
@@ -409,6 +424,7 @@ public class BreakContinueTargetFinderTest extends TestCase{
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testContinueFor2() throws Exception {
StringBuffer s= new StringBuffer();
s.append("class A{\n");
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BreakIteratorTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BreakIteratorTest.java
index 8e773f0531..1ad80b05d9 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BreakIteratorTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/BreakIteratorTest.java
@@ -15,7 +15,7 @@ package org.eclipse.jdt.text.tests;
import junit.framework.TestCase;
-import com.ibm.icu.text.BreakIterator;
+import java.text.BreakIterator;
/**
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/IndentActionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/IndentActionTest.java
index e35e248caf..2bbc4e0f26 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/IndentActionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/IndentActionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2015 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,17 +13,23 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
+import static org.junit.Assert.assertEquals;
+
import java.util.ListResourceBundle;
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExternalResource;
+import org.junit.rules.TestName;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.text.tests.performance.EditorTestHelper;
import org.eclipse.jdt.text.tests.performance.ResourceTestHelper;
+import org.eclipse.core.runtime.CoreException;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -41,28 +47,17 @@ import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
*
* @since 3.2
*/
-public class IndentActionTest extends TestCase {
- private static final String PROJECT= "IndentTests";
+public class IndentActionTest {
+ @Rule
+ public TestName tn= new TestName();
- private static final class EmptyBundle extends ListResourceBundle {
- @Override
- protected Object[][] getContents() {
- return new Object[0][];
- }
- }
-
- protected static class IndentTestSetup extends TestSetup {
+ private static final String PROJECT= "IndentTests";
+ private final class IndentTestSetup extends ExternalResource {
private IJavaProject fJavaProject;
- public IndentTestSetup(Test test) {
- super(test);
- }
-
@Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ protected void before() throws Exception {
fJavaProject= EditorTestHelper.createJavaProject(PROJECT, "testResources/indentation");
fJavaProject.setOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB);
fJavaProject.setOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, DefaultCodeFormatterConstants.FALSE);
@@ -71,24 +66,31 @@ public class IndentActionTest extends TestCase {
}
@Override
- protected void tearDown () throws Exception {
+ protected void after () {
if (fJavaProject != null)
- JavaProjectHelper.delete(fJavaProject);
-
- super.tearDown();
+ try {
+ JavaProjectHelper.delete(fJavaProject);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
}
- public static IJavaProject getProject() {
+ public IJavaProject getProject() {
IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT);
return JavaCore.create(project);
}
}
- private static final Class<IndentActionTest> THIS= IndentActionTest.class;
- public static Test suite() {
- return new IndentTestSetup(new TestSuite(THIS));
+ private static final class EmptyBundle extends ListResourceBundle {
+ @Override
+ protected Object[][] getContents() {
+ return new Object[0][];
+ }
}
+ @Rule
+ public IndentTestSetup indentTestSetup=new IndentTestSetup();
+
private JavaEditor fEditor;
private SourceViewer fSourceViewer;
private IDocument fDocument;
@@ -96,8 +98,8 @@ public class IndentActionTest extends TestCase {
/*
* @see junit.framework.TestCase#setUp()
*/
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
String filename= createFileName("Before");
fEditor= (JavaEditor) EditorTestHelper.openInEditor(ResourceTestHelper.findFile(filename), true);
fSourceViewer= EditorTestHelper.getSourceViewer(fEditor);
@@ -107,8 +109,8 @@ public class IndentActionTest extends TestCase {
/*
* @see junit.framework.TestCase#tearDown()
*/
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
EditorTestHelper.closeEditor(fEditor);
fEditor= null;
fSourceViewer= null;
@@ -124,7 +126,7 @@ public class IndentActionTest extends TestCase {
}
private String createFileName(String qualifier) {
- String name= getName();
+ String name= tn.getMethodName();
name= name.substring(4, 5).toLowerCase() + name.substring(5);
return "/" + PROJECT + "/src/" + name + "/" + qualifier + ".java";
}
@@ -133,23 +135,27 @@ public class IndentActionTest extends TestCase {
fSourceViewer.setSelectedRange(0, fDocument.getLength());
}
+ @Test
public void testUnchanged() throws Exception {
selectAll();
assertIndentResult();
}
+ @Test
public void testBug122261() throws Exception {
selectAll();
assertIndentResult();
}
+ @Test
public void testEmptySingleLineComment01() throws Exception {
selectAll();
assertIndentResult();
}
+ @Test
public void testEmptySingleLineComment02() throws Exception {
- IJavaProject project= IndentTestSetup.getProject();
+ IJavaProject project= indentTestSetup.getProject();
project.setOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, DefaultCodeFormatterConstants.TRUE);
try {
selectAll();
@@ -159,8 +165,9 @@ public class IndentActionTest extends TestCase {
}
}
+ @Test
public void testEmptySingleLineComment03() throws Exception {
- IJavaProject project= IndentTestSetup.getProject();
+ IJavaProject project= indentTestSetup.getProject();
project.setOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, DefaultCodeFormatterConstants.TRUE);
project.setOption(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE);
project.setOption(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, DefaultCodeFormatterConstants.FALSE);
@@ -174,18 +181,21 @@ public class IndentActionTest extends TestCase {
}
}
+ @Test
public void testBug424772() throws Exception {
selectAll();
assertIndentResult();
}
+ @Test
public void testBug428384() throws Exception {
selectAll();
assertIndentResult();
}
+ @Test
public void testBug439582_1() throws Exception {
- IJavaProject project= IndentTestSetup.getProject();
+ IJavaProject project= indentTestSetup.getProject();
String value= project.getOption(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, true);
project.setOption(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, "1");
try {
@@ -196,30 +206,35 @@ public class IndentActionTest extends TestCase {
}
}
+ @Test
public void testBug439582_2() throws Exception {
selectAll();
assertIndentResult();
}
+ @Test
public void testBug439582_3() throws Exception {
selectAll();
assertIndentResult();
}
+ @Test
public void testBug439582_4() throws Exception {
selectAll();
assertIndentResult();
}
+ @Test
public void testBug439582_5() throws Exception {
selectAll();
assertIndentResult();
}
+ @Test
public void testBug400670_1() throws Exception {
// With formatter profile from https://bugs.eclipse.org/bugs/show_bug.cgi?id=400670#c0
String indentOnColumn= DefaultCodeFormatterConstants.createAlignmentValue(true, DefaultCodeFormatterConstants.WRAP_NEXT_PER_LINE, DefaultCodeFormatterConstants.INDENT_ON_COLUMN);
- IJavaProject project= IndentTestSetup.getProject();
+ IJavaProject project= indentTestSetup.getProject();
String value1= project.getOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, true);
project.setOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, indentOnColumn);
String value2= project.getOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, true);
@@ -236,14 +251,16 @@ public class IndentActionTest extends TestCase {
}
}
+ @Test
public void testBug400670_2() throws Exception {
// With default formatter profile
selectAll();
assertIndentResult();
}
+ @Test
public void testBug458763() throws Exception {
- IJavaProject project= IndentTestSetup.getProject();
+ IJavaProject project= indentTestSetup.getProject();
String value= project.getOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, true);
project.setOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, DefaultCodeFormatterConstants.FALSE);
try {
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaAutoIndentStrategyTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaAutoIndentStrategyTest.java
index 9fedaf9c2c..fff08bc712 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaAutoIndentStrategyTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaAutoIndentStrategyTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 IBM Corporation and others.
+ * Copyright (c) 2009, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,9 +13,12 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.eclipse.core.runtime.ILogListener;
import org.eclipse.core.runtime.IStatus;
@@ -38,12 +41,7 @@ import org.eclipse.jdt.internal.ui.text.java.JavaAutoIndentStrategy;
*
* @since 3.6
*/
-public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener {
-
- public static Test suite() {
- return new TestSuite(JavaAutoIndentStrategyTest.class);
- }
-
+public class JavaAutoIndentStrategyTest implements ILogListener {
private FastPartitioner fPartitioner;
private Document fDocument;
@@ -80,6 +78,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
fAccessor.invoke("smartPaste", new Class[] { IDocument.class, DocumentCommand.class }, new Object[] { fDocument, fDocumentCommand });
}
+ @Test
public void testPasteDefaultAtEnd() {
fDocument.set("public class Test2 {\r\n\r\n}\r\n");
@@ -91,6 +90,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(result, fDocumentCommand.text);
}
+ @Test
public void testPasteFooAtEnd() {
fDocument.set("public class Test2 {\r\n\r\n}\r\n");
@@ -102,6 +102,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(result, fDocumentCommand.text);
}
+ @Test
public void testPasteAndIndentOfLongStringWithContinuations1() {
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=330556
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=65317
@@ -151,6 +152,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(result, fDocumentCommand.text);
}
+ @Test
public void testPasteAndIndentOfStringWithContinuations2() {
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=337150
fDocument.set("public class Test2 {\n}");
@@ -167,6 +169,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(result, fDocumentCommand.text);
}
+ @Test
public void testPasteAndIndentOfStringWithContinuations3() {
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=337150
fDocument.set("public class Test2 {\n}");
@@ -183,6 +186,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(result, fDocumentCommand.text);
}
+ @Test
public void testPasteAndIndentOfStringWithContinuations4() {
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=337150
fDocument.set("public class Test2 {\n}");
@@ -199,6 +203,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(result, fDocumentCommand.text);
}
+ @Test
public void testPasteAndIndentOfStringWithContinuations5() {
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=337150
fDocument.set("public class Test2 {\n}");
@@ -221,6 +226,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
fCommandAccessor.invoke("execute", new Class[] { IDocument.class }, new Object[] { fDocument });
}
+ @Test
public void testSmartIndentAfterNewLine1() {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=29379
fDocument.setInitialLineDelimiter("\r\n");
@@ -247,6 +253,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(buf1.toString(), fDocument.get());
}
+ @Test
public void testSmartIndentAfterNewLine2() {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=395071
fDocument.setInitialLineDelimiter("\r\n");
@@ -273,6 +280,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(buf1.toString(), fDocument.get());
}
+ @Test
public void testSmartIndentAfterNewLine3() {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=395071
fDocument.setInitialLineDelimiter("\r\n");
@@ -288,6 +296,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(buf.toString(), fDocument.get());
}
+ @Test
public void testSmartIndentAfterNewLine4() {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=254704
fDocument.setInitialLineDelimiter("\r\n");
@@ -315,6 +324,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(buf1.toString(), fDocument.get());
}
+ @Test
public void testSmartIndentAfterNewLine5() {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=256087
fDocument.setInitialLineDelimiter("\r\n");
@@ -341,6 +351,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(buf1.toString(), fDocument.get());
}
+ @Test
public void testSmartIndentAfterNewLine6() {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=200015
fDocument.setInitialLineDelimiter("\r\n");
@@ -362,6 +373,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(buf.toString(), fDocument.get());
}
+ @Test
public void testSmartIndentAfterNewLine7() {
fDocument.setInitialLineDelimiter("\r\n");
fDocument.set("int[] a= new int[] { ;");
@@ -376,6 +388,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(buf.toString(), fDocument.get());
}
+ @Test
public void testSmartIndentAfterNewLine8() {
fDocument.setInitialLineDelimiter("\r\n");
fDocument.set("String[] strs = {\"a\",\"b\",");
@@ -390,6 +403,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(buf.toString(), fDocument.get());
}
+ @Test
public void testSmartIndentAfterNewLine9() {
fDocument.setInitialLineDelimiter("\r\n");
fDocument.set("{ int a;");
@@ -404,6 +418,7 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
assertEquals(buf.toString(), fDocument.get());
}
+ @Test
public void testSmartIndentAfterNewLine10() {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=404879
fDocument.setInitialLineDelimiter("\r\n");
@@ -422,18 +437,16 @@ public class JavaAutoIndentStrategyTest extends TestCase implements ILogListener
/*
* @see junit.framework.TestCase#setUp()
*/
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
JavaPlugin.getDefault().getLog().addLogListener(this);
}
/*
* @see junit.framework.TestCase#tearDown()
*/
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
JavaPlugin.getDefault().getLog().removeLogListener(this);
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaColoringTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaColoringTest.java
index 29dfbcd781..087b14b9d9 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaColoringTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaColoringTest.java
@@ -13,8 +13,14 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
+import static org.junit.Assert.fail;
+
import java.util.Iterator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -36,25 +42,13 @@ import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration;
import org.eclipse.jdt.ui.text.JavaTextTools;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-
-
-public class JavaColoringTest extends TestCase {
-
+public class JavaColoringTest {
protected TestTextViewer fTextViewer;
protected IDocument fDocument;
protected JavaTextTools fTextTools;
- public JavaColoringTest(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() {
-
+ @Before
+ public void setUp() {
IPreferenceStore store= new PreferenceStore();
fTextTools= new JavaTextTools(store);
@@ -73,16 +67,10 @@ public class JavaColoringTest extends TestCase {
reconciler.install(fTextViewer);
System.out.print("------ next ---------\n");
-
}
- public static Test suite() {
- return new TestSuite(JavaColoringTest.class);
- }
-
- @Override
- protected void tearDown () {
-
+ @After
+ public void tearDown () {
fTextTools.dispose();
fTextTools= null;
@@ -112,12 +100,14 @@ public class JavaColoringTest extends TestCase {
return buf.toString();
}
+ @Test
public void testSimple() {
fDocument.set("xx //");
fTextViewer.setDocument(fDocument);
System.out.print(print(fTextViewer.getTextPresentation()));
}
+ @Test
public void testTypingWithPartitionChange() {
try {
fTextViewer.setDocument(fDocument);
@@ -126,10 +116,11 @@ public class JavaColoringTest extends TestCase {
fDocument.replace(2,0, "/");
System.out.print(print(fTextViewer.getTextPresentation()));
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testTogglingPartitions() {
try {
fTextViewer.setDocument(fDocument);
@@ -138,7 +129,7 @@ public class JavaColoringTest extends TestCase {
fDocument.replace(0,0, "//");
System.out.print(print(fTextViewer.getTextPresentation()));
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaDoc2HTMLTextReaderTester.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaDoc2HTMLTextReaderTester.java
index 63dd496ab1..121bd9a49f 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaDoc2HTMLTextReaderTester.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaDoc2HTMLTextReaderTester.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,11 +15,13 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
+import static org.junit.Assert.assertEquals;
+
import java.io.Reader;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -36,20 +38,12 @@ import org.eclipse.jdt.internal.corext.javadoc.JavaDocCommentReader;
import org.eclipse.jdt.internal.ui.text.javadoc.JavaDoc2HTMLTextReader;
-
-public class JavaDoc2HTMLTextReaderTester extends TestCase {
+public class JavaDoc2HTMLTextReaderTester {
+ @Rule
+ public TestName tn= new TestName();
private static final boolean DEBUG= false;
-
- public JavaDoc2HTMLTextReaderTester(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new TestSuite(JavaDoc2HTMLTextReaderTester.class);
- }
-
private String getTransformedJavaDoc(String string) {
Reader reader= new JavaDocCommentReader(new MockBuffer(string), 0, string.length());
return HTMLPrinter.read(new JavaDoc2HTMLTextReader(reader));
@@ -62,18 +56,21 @@ public class JavaDoc2HTMLTextReaderTester extends TestCase {
assertEquals(expected, result);
}
+ @Test
public void test0(){
String string= "/**@deprecated*/"; //$NON-NLS-1$
String expected= "<dl><dt>@deprecated</dt><dd></dd></dl>"; //$NON-NLS-1$
verify(string, expected);
}
+ @Test
public void test1(){
String string= "/**@author Foo Bar*/"; //$NON-NLS-1$
String expected= "<dl><dt>Author:</dt><dd>Foo Bar</dd></dl>"; //$NON-NLS-1$
verify(string, expected);
}
+ @Test
public void test2(){
//test for bug 14658
String string= "/**@author Foo Bar<a href=\"mailto:foobar@eclipse.org\">foobar@eclipse.org</a>*/"; //$NON-NLS-1$
@@ -81,6 +78,7 @@ public class JavaDoc2HTMLTextReaderTester extends TestCase {
verify(string, expected);
}
+ @Test
public void test3(){
//test for bug 14658
String string= "/**@author Foo Bar<a href=\"mailto:foobar@eclipse.org\">foobar@eclipse.org</a>\n *@deprecated*/"; //$NON-NLS-1$
@@ -88,28 +86,31 @@ public class JavaDoc2HTMLTextReaderTester extends TestCase {
verify(string, expected);
}
+ @Test
public void test4(){
String string= "/**@author Foo Bar\n * @deprecated*/"; //$NON-NLS-1$
String expected= "<dl><dt>Author:</dt><dd>Foo Bar</dd><dt>@deprecated</dt><dd></dd></dl>"; //$NON-NLS-1$
verify(string, expected);
}
+ @Test
public void test5(){
String string= "/**@author Foo Bar\n * @author Baz Fred*/"; //$NON-NLS-1$
String expected= "<dl><dt>Author:</dt><dd>Foo Bar</dd><dd>Baz Fred</dd></dl>"; //$NON-NLS-1$
verify(string, expected);
}
+ @Test
public void test6(){
String string= "/**@author Foo Bar\n * @since 2.0*/"; //$NON-NLS-1$
String expected= "<dl><dt>Author:</dt><dd>Foo Bar</dd><dt>Since:</dt><dd>2.0</dd></dl>"; //$NON-NLS-1$
verify(string, expected);
}
-
+ @Test
public void test7(){
if (DEBUG) {
- System.out.println(getClass().getName()+"::" + getName() +" disabled(corner case - @see tag inside <a> tag)"); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println(getClass().getName()+"::" + tn.getMethodName() +" disabled(corner case - @see tag inside <a> tag)"); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
String string= "/**@author Foo Bar<a href=\"mailto:foobar@see.org\">foobar@see.org</a>*/"; //$NON-NLS-1$
@@ -117,9 +118,10 @@ public class JavaDoc2HTMLTextReaderTester extends TestCase {
verify(string, expected);
}
+ @Test
public void test8(){
if (DEBUG) {
- System.out.println(getClass().getName()+"::" + getName() +" disabled(corner case - @see tag inside <a> tag)"); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println(getClass().getName()+"::" + tn.getMethodName() +" disabled(corner case - @see tag inside <a> tag)"); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
String string= "/**@author Foo Bar<a href=\"mailto:foobar@see.org\">foobar@eclipse.org</a>*/"; //$NON-NLS-1$
@@ -127,12 +129,14 @@ public class JavaDoc2HTMLTextReaderTester extends TestCase {
verify(string, expected);
}
+ @Test
public void test9(){
String string= "/**@throws NullPointerException*/"; //$NON-NLS-1$
String expected= "<dl><dt>Throws:</dt><dd>NullPointerException</dd></dl>"; //$NON-NLS-1$
verify(string, expected);
}
+ @Test
public void test10(){
//test for bug 8131
String string= "/**@exception NullPointerException*/"; //$NON-NLS-1$
@@ -140,6 +144,7 @@ public class JavaDoc2HTMLTextReaderTester extends TestCase {
verify(string, expected);
}
+ @Test
public void test11(){
//test for bug 8132
String string= "/**@exception NullPointerException \n * @throws java.lang.Exception*/"; //$NON-NLS-1$
@@ -147,67 +152,77 @@ public class JavaDoc2HTMLTextReaderTester extends TestCase {
verify(string, expected);
}
+ @Test
public void test12(){
String string= "/** \n *@param i fred or <code>null</code> \n*/"; //$NON-NLS-1$
String expected= "<dl><dt>Parameters:</dt><dd><b>i</b> fred or <code>null</code></dd></dl>"; //$NON-NLS-1$
verify(string, expected);
}
+ @Test
public void test13_withText(){
String string= "/**\n * This is a {@linkplain Foo#bar(String, int) test link}. End.*/"; //$NON-NLS-1$
String expected= " This is a test link. End."; //$NON-NLS-1$
verify(string, expected);
}
+ @Test
public void test13_withoutText(){
String string= "/**\n * This is a {@linkplain Foo#bar(String, int)}. End.*/"; //$NON-NLS-1$
String expected= " This is a Foo.bar(String, int). End."; //$NON-NLS-1$
verify(string, expected);
}
+ @Test
public void test14_withText(){
String string= "/**\n * This is a {@link Foo#bar(String, int) test link}. End.*/"; //$NON-NLS-1$
String expected= " This is a <code>test link</code>. End."; //$NON-NLS-1$
verify(string, expected);
}
-
+ @Test
public void test14_withoutText(){
String string= "/**\n * This is a {@link Foo#bar(String, int)}. End.*/"; //$NON-NLS-1$
String expected= " This is a <code>Foo.bar(String, int)</code>. End."; //$NON-NLS-1$
verify(string, expected);
}
+ @Test
public void test15(){
String string= "/**\n * This is a <a href=\"{@docRoot}/test.html\">test link</a>. End.*/"; //$NON-NLS-1$
String expected= " This is a <a href=\"/test.html\">test link</a>. End."; //$NON-NLS-1$
verify(string, expected);
}
+ @Test
public void test16() {
String string= "/**\n *@param foo {@link Bar bar}*/"; //$NON-NLS-1$
String expected= "<dl><dt>Parameters:</dt><dd><b>foo</b> <code>bar</code></dd></dl>"; //$NON-NLS-1$
verify(string, expected);
}
+ @Test
public void test17(){
String string= "/**\n @model name='abc' value='@'\n * @generated*/"; // $NON-NLS-1$
String expected= "<dl><dt>@model</dt><dd>name='abc' value='@'</dd><dt>@generated</dt><dd></dd></dl>"; //$NON-NLS-1$
verify(string, expected);
}
+ @Test
public void test18(){
String string= "/**\r\n* Method foo.\r\n* @param bar\t\n* @custom fooBar\t\n*/"; // $NON-NLS-1$
String expected= " Method foo.\r\n <dl><dt>Parameters:</dt><dd><b>bar</b></dd><dt>@custom</dt><dd>fooBar</dd></dl>"; //$NON-NLS-1$
verify(string, expected);
}
+ @Test
public void test19(){
String string= "/**\n @model\n * @generated*/"; // $NON-NLS-1$
String expected= "<dl><dt>@model</dt><dd></dd><dt>@generated</dt><dd></dd></dl>"; //$NON-NLS-1$
verify(string, expected);
}
+ @Test
public void test20(){
//test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=94189
String string= "/**This is {@code}{@literal <literal>} {@code & code}.*/"; // $NON-NLS-1$
@@ -215,6 +230,7 @@ public class JavaDoc2HTMLTextReaderTester extends TestCase {
verify(string, expected);
}
+ @Test
public void test21(){
//test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=70870
String string= "/**@see <a href=\"http://foo.bar#baz\">foo</a>*/"; //$NON-NLS-1$
@@ -222,6 +238,7 @@ public class JavaDoc2HTMLTextReaderTester extends TestCase {
verify(string, expected);
}
+ @Test
public void test22(){
//test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=70870
String string= "/**@see <a href=\"http://foo.bar#baz\">foo</a> and {@link Foo#bar(String, int)} and <a href=\"http://foo.bar#baz\">foo</a>*/"; //$NON-NLS-1$
@@ -231,7 +248,6 @@ public class JavaDoc2HTMLTextReaderTester extends TestCase {
}
class MockBuffer implements IBuffer{
-
private StringBuffer fStringBuffer;
MockBuffer(String string){
fStringBuffer= new StringBuffer(string);
@@ -241,110 +257,91 @@ class MockBuffer implements IBuffer{
public void addBufferChangedListener(IBufferChangedListener listener) {
}
-
@Override
public void append(char[] text) {
fStringBuffer.append(text);
}
-
@Override
public void append(String text) {
fStringBuffer.append(text);
}
-
@Override
public void close() {
}
-
@Override
public char getChar(int position) {
return fStringBuffer.charAt(position);
}
-
@Override
public char[] getCharacters() {
return fStringBuffer.toString().toCharArray();
}
-
@Override
public String getContents() {
return fStringBuffer.toString();
}
-
@Override
public int getLength() {
return fStringBuffer.length();
}
-
@Override
public IOpenable getOwner() {
return null;
}
-
@Override
public String getText(int offset, int length) {
return fStringBuffer.toString().substring(offset, offset + length);
}
-
@Override
public IResource getUnderlyingResource() {
return null;
}
-
@Override
public boolean hasUnsavedChanges() {
return false;
}
-
@Override
public boolean isClosed() {
return false;
}
-
@Override
public boolean isReadOnly() {
return false;
}
-
@Override
public void removeBufferChangedListener(IBufferChangedListener listener) {
}
-
@Override
public void replace(int position, int length, char[] text) {
}
-
@Override
public void replace(int position, int length, String text) {
}
-
@Override
public void save(IProgressMonitor progress, boolean force)
throws JavaModelException {
}
-
@Override
public void setContents(char[] contents) {
}
-
@Override
public void setContents(String contents) {
fStringBuffer= new StringBuffer(contents);
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaDoubleClickSelectorTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaDoubleClickSelectorTest.java
index b5a9fefdfa..96d34c951a 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaDoubleClickSelectorTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaDoubleClickSelectorTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,9 +13,9 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
@@ -26,24 +26,17 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.ui.text.java.JavaDoubleClickSelector;
-
/**
* @since 3.1
*/
-public class JavaDoubleClickSelectorTest extends TestCase {
-
+public class JavaDoubleClickSelectorTest {
private static class PublicSelector extends JavaDoubleClickSelector {
-
@Override
public IRegion findWord(IDocument document, int anchor) {
return super.findWord(document, anchor);
}
}
- public static Test suite() {
- return new TestSuite(JavaDoubleClickSelectorTest.class);
- }
-
private void assert14Selection(String content, int offset, int selOffset, int selLength) {
IDocument document= new Document(content);
PublicSelector selector= new PublicSelector();
@@ -60,106 +53,132 @@ public class JavaDoubleClickSelectorTest extends TestCase {
assertEquals(new Region(selOffset, selLength), selection);
}
+ @Test
public void testIdentifierBefore() throws Exception {
assert14Selection(" foobar ", 2, 2, 6);
}
+ @Test
public void testIdentifierInside() throws Exception {
assert14Selection(" foobar ", 3, 2, 6);
}
+ @Test
public void testIdentifierBehind() throws Exception {
assert14Selection(" foobar ", 8, 8, 0);
}
+ @Test
public void testWhitespaceBefore() throws Exception {
assert14Selection(" foobar ", 1, 1, 0);
}
+ @Test
public void testWhitespaceBehind() throws Exception {
assert14Selection(" foobar ", 9, 9, 0);
}
+ @Test
public void test14AnnotationBefore() throws Exception {
assert14Selection(" @ Deprecated ", 2, 2, 0);
}
+ @Test
public void test14AnnotationInside1() throws Exception {
assert14Selection(" @ Deprecated ", 3, 3, 0);
}
+ @Test
public void test14AnnotationInside2() throws Exception {
assert14Selection(" @ Deprecated ", 4, 4, 0);
}
+ @Test
public void test14AnnotationInside3() throws Exception {
assert14Selection(" @ Deprecated ", 5, 5, 10);
}
+ @Test
public void test14AnnotationInside4() throws Exception {
assert14Selection(" @ Deprecated ", 6, 5, 10);
}
+ @Test
public void test14AnnotationBehind() throws Exception {
assert14Selection(" @ Deprecated ", 15, 15, 0);
}
+ @Test
public void test15AnnotationBefore() throws Exception {
assert15Selection(" @ Deprecated ", 2, 2, 13);
}
+ @Test
public void test15AnnotationInside1() throws Exception {
assert15Selection(" @ Deprecated ", 3, 2, 13);
}
+ @Test
public void test15AnnotationInside2() throws Exception {
assert15Selection(" @ Deprecated ", 4, 2, 13);
}
+ @Test
public void test15AnnotationInside3() throws Exception {
assert15Selection(" @ Deprecated ", 5, 2, 13);
}
+ @Test
public void test15AnnotationInside4() throws Exception {
assert15Selection(" @ Deprecated ", 6, 2, 13);
}
+ @Test
public void test15AnnotationBehind() throws Exception {
assert15Selection(" @ Deprecated ", 15, 15, 0);
}
+ @Test
public void test15AnnotationNoSpaceBefore() throws Exception {
assert15Selection(" @Deprecated ", 2, 2, 11);
}
+ @Test
public void test15AnnotationNoSpaceInside1() throws Exception {
assert15Selection(" @Deprecated ", 3, 2, 11);
}
+ @Test
public void test15AnnotationNoSpaceInside2() throws Exception {
assert15Selection(" @Deprecated ", 4, 2, 11);
}
+ @Test
public void test15AnnotationNoSpaceBehind() throws Exception {
assert15Selection(" @Deprecated ", 13, 13, 0);
}
+ @Test
public void testAnnotationNoIdStartBefore() {
assert15Selection(" @2foobar ", 2, 2, 0);
}
+ @Test
public void testAnnotationNoIdStartInside1() {
assert15Selection(" @2foobar ", 3, 3, 7);
}
+ @Test
public void testAnnotationNoIdStartInside2() {
assert15Selection(" @2foobar ", 4, 3, 7);
}
+ @Test
public void testAnnotationNoIdStartBehind() {
assert15Selection(" @2foobar ", 10, 10, 0);
}
+ @Test
public void testBackwardsOnDot() {
assert14Selection("Systen.out", 6, 0, 6);
assert15Selection("Systen.out", 6, 0, 6);
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaElementPrefixPatternMatcherTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaElementPrefixPatternMatcherTest.java
index 88cbf37b18..6064210663 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaElementPrefixPatternMatcherTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaElementPrefixPatternMatcherTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 IBM Corporation and others.
+ * Copyright (c) 2012, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -16,9 +16,7 @@ package org.eclipse.jdt.text.tests;
import java.lang.reflect.Field;
import java.util.ArrayList;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Test;
import org.eclipse.jdt.testplugin.StringAsserts;
@@ -26,8 +24,7 @@ import org.eclipse.jdt.internal.corext.util.CollectionsUtil;
import org.eclipse.jdt.internal.ui.text.JavaElementPrefixPatternMatcher;
-public class JavaElementPrefixPatternMatcherTest extends TestCase {
-
+public class JavaElementPrefixPatternMatcherTest {
private static final String toString_int_int= "toString(int, int) : String - java.lang.Integer";
private static final String toString_int= "toString(int) : String - java.lang.Integer";
@@ -71,19 +68,13 @@ public class JavaElementPrefixPatternMatcherTest extends TestCase {
if (String.class.equals(field.getType()))
try {
strings.add((String) field.get(null));
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
+ } catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
ALL_STRING_CONSTANTS= strings.toArray(new String[strings.size()]);
}
- public static Test suite() {
- return new TestSuite(JavaElementPrefixPatternMatcherTest.class);
- }
-
private static void doMatch(String pattern, String... labelStrings) {
JavaElementPrefixPatternMatcher matcher= new JavaElementPrefixPatternMatcher(pattern);
@@ -96,89 +87,103 @@ public class JavaElementPrefixPatternMatcherTest extends TestCase {
StringAsserts.assertEqualStringsIgnoreOrder(CollectionsUtil.toArray(matched, String.class), labelStrings);
}
-
+ @Test
public void testEmptyPattern() throws Exception {
doMatch("", ALL_STRING_CONSTANTS);
}
+ @Test
public void testStarPattern() throws Exception {
doMatch("*", ALL_STRING_CONSTANTS);
}
-
+ @Test
public void testMethodPattern_1() throws Exception {
doMatch("*tos", toString_int_int, toString_int);
}
-
+ @Test
public void testMethodPattern_2() throws Exception {
doMatch("tS", toString_int_int, toString_int);
}
+ @Test
public void testMethodPattern_3() throws Exception {
doMatch("tS(", toString_int_int, toString_int);
}
+ @Test
public void testMethodPattern_4() throws Exception {
doMatch("tS(int", toString_int_int, toString_int);
}
+ @Test
public void testMethodPattern_5() throws Exception {
doMatch("tS(int, ", toString_int_int);
}
+ @Test
public void testMethodPattern_6() throws Exception {
doMatch("toString(int, int) : S", toString_int_int);
}
+ @Test
public void testMethodPattern_7() throws Exception {
doMatch("*(in", toString_int_int, toString_int, Integer_int);
}
+ @Test
public void testMethodPattern_8() throws Exception {
doMatch("*) : St", toString_int_int, toString_int);
}
+ @Test
public void testMethodPattern_9() throws Exception {
doMatch("p*) : i", parseInt_String, parseInt_String_int);
}
+ @Test
public void testMethodPattern_10() throws Exception {
doMatch("to*ng(", toString_int_int, toString_int);
}
+ @Test
public void testMethodPattern_11() throws Exception {
doMatch("tS*ng(");
}
+ @Test
public void testReturnPattern_1() throws Exception {
doMatch("*: int", parseInt_String, parseInt_String_int, MIN_VALUE__int);
}
+ @Test
public void testReturnPattern_2() throws Exception {
doMatch("*: Class<In", TYPE__Class_Integer);
}
-
+ @Test
public void testFieldPattern_1() throws Exception {
doMatch("DT : ", DigitTens__char_);
}
-
+ @Test
public void testTypePattern_2() throws Exception {
doMatch("AI", AtomicInteger);
}
+ @Test
public void testTypePattern_3() throws Exception {
doMatch("b", BigDecimal, Byte, BigInteger);
}
+ @Test
public void testDeclaringClassPattern_1() throws Exception {
doMatch("*-", ALL_STRING_CONSTANTS);
}
+ @Test
public void testDeclaringClassPattern_2() throws Exception {
doMatch("*- java.lang", toString_int_int, toString_int, parseInt_String, parseInt_String_int, Integer_int, MIN_VALUE__int, TYPE__Class_Integer, DigitTens__char_, Object, Number, Byte, Long, Double);
}
-
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaHeuristicScannerTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaHeuristicScannerTest.java
index aa7c535055..0f5b6789f8 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaHeuristicScannerTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaHeuristicScannerTest.java
@@ -13,11 +13,15 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.Hashtable;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
@@ -36,23 +40,18 @@ import org.eclipse.jdt.internal.ui.text.JavaIndenter;
* SmartSemicolonAutoEditStrategyTest
* @since 3.0
*/
-public class JavaHeuristicScannerTest extends TestCase {
-
+public class JavaHeuristicScannerTest {
private static final boolean BUG_65463= true;
private FastPartitioner fPartitioner;
private Document fDocument;
private JavaIndenter fScanner;
private JavaHeuristicScanner fHeuristicScanner;
- public static Test suite() {
- return new TestSuite(JavaHeuristicScannerTest.class);
- }
-
/*
* @see junit.framework.TestCase#setUp()
*/
- @Override
- protected void setUp() {
+ @Before
+ public void setUp() {
if (JavaCore.getPlugin() != null) {
Hashtable<String, String> options= JavaCore.getDefaultOptions();
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB);
@@ -85,8 +84,8 @@ public class JavaHeuristicScannerTest extends TestCase {
/*
* @see junit.framework.TestCase#tearDown()
*/
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
fDocument.setDocumentPartitioner(IJavaPartitions.JAVA_PARTITIONING, null);
fPartitioner.disconnect();
fPartitioner= null;
@@ -95,8 +94,9 @@ public class JavaHeuristicScannerTest extends TestCase {
if (JavaCore.getPlugin() != null) {
JavaCore.setOptions(JavaCore.getDefaultOptions());
}
-}
+ }
+ @Test
public void testPrevIndentationUnit1() {
fDocument.set("\tint a;\n" +
"\tif (true)\n" +
@@ -106,6 +106,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(9, pos);
}
+ @Test
public void testPrevIndentationUnit2() {
fDocument.set("\tint a;\n" +
"\tif (true)\n" +
@@ -116,6 +117,7 @@ public class JavaHeuristicScannerTest extends TestCase {
}
+ @Test
public void testPrevIndentationUnit5() {
fDocument.set("\tint a;\n" +
"\tif (true)\n" +
@@ -126,6 +128,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(9, pos);
}
+ @Test
public void testPrevIndentationUnit6() {
// method definition
fDocument.set("\tvoid proc (int par1, int par2\n");
@@ -134,6 +137,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(12, pos);
}
+ @Test
public void testPrevIndentationUnit7() {
// for with semis
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -145,15 +149,17 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(39, pos);
}
+ @Test
public void testPrevIndentationUnit8() {
// TODO this is mean - comment at indentation spot
fDocument.set("\t/* package */ void proc (int par1, int par2) {\n");
int pos= fScanner.findReferencePosition(fDocument.getLength());
-// Assert.assertEquals(1, pos);
+// assertEquals(1, pos);
assertEquals(15, pos);
}
+ @Test
public void testPrevIndentationUnit9() {
// block
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -167,6 +173,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(fDocument.getLength() - 7, pos);
}
+ @Test
public void testPrevIndentationUnit10() {
// if else
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -182,6 +189,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(39, pos);
}
+ @Test
public void testPrevIndentationUnit11() {
// inside else block
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -197,6 +205,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(83, pos);
}
+ @Test
public void testPrevIndentation1() {
fDocument.set("\tint a;\n" +
"\tif (true)\n" +
@@ -206,6 +215,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testPrevIndentation2() {
fDocument.set("\tint a;\n" +
"\tif (true)\n" +
@@ -215,6 +225,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testPrevIndentation3() {
fDocument.set("\tint a;\n" +
"\tif (true)\n" +
@@ -224,6 +235,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testPrevIndentation4() {
fDocument.set("\tint a;\n" +
"\tif (true)\n" +
@@ -234,6 +246,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testPrevIndentation5() {
fDocument.set("\tint a;\n" +
"\tif (true)\n" +
@@ -244,6 +257,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testPrevIndentation6() {
fDocument.set("\tvoid proc (int par1, int par2\n");
@@ -251,6 +265,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testPrevIndentation7() {
// for with semis
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -262,6 +277,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testPrevIndentation8() {
fDocument.set("\t/* package */ void proc (int par1, int par2) {\n");
@@ -269,6 +285,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testPrevIndentation9() {
// block
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -282,6 +299,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testPrevIndentation10() {
// else
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -297,6 +315,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testPrevIndentation11() {
// else
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -312,6 +331,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testIndentation1() {
fDocument.set("\tint a;\n" +
"\tif (true)\n" +
@@ -321,6 +341,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testIndentation5() {
fDocument.set("\tint a;\n" +
"\tif (true)\n" +
@@ -331,6 +352,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testIndentation6() {
// parameter declaration - alignment with parenthesis
fDocument.set("\tvoid proc (int par1, int par2\n");
@@ -339,6 +361,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t ", indent);
}
+ @Test
public void testIndentation6a() {
// parameter declaration - alignment with parenthesis
fDocument.set("\tvoid proc ( int par1, int par2\n");
@@ -347,6 +370,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t ", indent);
}
+ @Test
public void testIndentation7() {
// for with semis
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -358,6 +382,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testIndentation8() {
// method definition
fDocument.set("\t/* package */ void proc (int par1, int par2) {\n");
@@ -366,6 +391,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testIndentation9() {
// block
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -379,6 +405,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testIndentation10() {
// else
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -394,6 +421,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testIndentation11() {
// else
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -409,6 +437,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testIndentation12() {
// multi-line condition
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -420,6 +449,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testIndentation13() {
// multi-line call
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -431,6 +461,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testIndentation14() {
// multi-line array initializer
fDocument.set("\tvoid proc (int par1, int par2) {\n" +
@@ -442,6 +473,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(" ", indent);
}
+ @Test
public void testIndentation15() {
// for
fDocument.set("\tfor (int i= 0; i < 10; i++) {\n" +
@@ -452,6 +484,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testIndentation16() {
// if
fDocument.set("\tif (true)\n" +
@@ -461,6 +494,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testIndentation17() {
// if
fDocument.set("\tif (true)\n" +
@@ -470,6 +504,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testIndentation18() {
// if
fDocument.set("\tif (true)\n" +
@@ -479,6 +514,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testIndentation19() {
// if w/ brace right after }
fDocument.set("\tif (true) {\n" +
@@ -488,6 +524,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testIndentation20() {
// if w/ brace right before }
fDocument.set("\tif (true) {\n" +
@@ -497,6 +534,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testIndentation21() {
// double if w/ brace
fDocument.set("\tif (true)\n" +
@@ -507,6 +545,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testIndentation22() {
// after double if w/ brace
fDocument.set("\tif (true)\n" +
@@ -519,6 +558,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent); // because of possible dangling else
}
+ @Test
public void testIndentation22a() {
// after double if w/ brace
fDocument.set("\tif (true)\n" +
@@ -531,6 +571,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testIndentation22b() {
// after double if w/ brace
fDocument.set("\tif (true)\n" +
@@ -543,6 +584,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent); // no dangling else possible
}
+ @Test
public void testIndentation23() {
// do
fDocument.set("\tdo\n" +
@@ -552,6 +594,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testIndentation24() {
// braceless else
fDocument.set("\tif (true) {\n" +
@@ -563,6 +606,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testIndentation25() {
// braceless else
fDocument.set("\tif (true) {\r\n" +
@@ -574,6 +618,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testIndentation26() {
// do while
fDocument.set("\tdo\n" +
@@ -585,6 +630,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testIndentation27() {
// do while
fDocument.set("\tdo\n" +
@@ -598,6 +644,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testIndentation28() {
// TODO do while - how to we distinguish from while {} loop?
fDocument.set("\tdo\n" +
@@ -611,6 +658,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testIndentation29() {
fDocument.set("\t\twhile (condition)\n" +
"\t\t\twhile (condition)\n" +
@@ -622,6 +670,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testIndentation30() {
// braceless else
fDocument.set("\tif (true)\n" +
@@ -631,6 +680,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testIndentation31() {
// braceless else
fDocument.set("\tif (true)\n" +
@@ -643,6 +693,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testIndentation32() {
// braceless else
fDocument.set("\tswitch(ch) {\n" +
@@ -652,6 +703,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(" ", indent);
}
+ @Test
public void testAnonymousIndentation1() {
fDocument.set( " MenuItem mi= new MenuItem(\"About...\");\n" +
" mi.addActionListener(\n" +
@@ -662,6 +714,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(" ", indent);
}
+ @Test
public void testAnonymousIndentation2() {
fDocument.set( " MenuItem mi= new MenuItem(\"About...\");\n" +
" mi.addActionListener(\n" +
@@ -678,6 +731,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(" ", indent);
}
+ @Test
public void testExceptionIndentation1() {
fDocument.set("public void processChildren(CompositeExpression result, IConfigurationElement element) throws CoreException {\n" +
" IConfigurationElement[] children= element.getChildren();\n" +
@@ -691,6 +745,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(" ", indent);
}
+ @Test
public void testExceptionIndentation2() {
fDocument.set("public void processChildren(CompositeExpression result, IConfigurationElement element) throws CoreException {\n" +
" IConfigurationElement[] children= element.getChildren();\n" +
@@ -704,6 +759,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(" ", indent);
}
+ @Test
public void testExceptionIndentation3() {
fDocument.set("public void processChildren(CompositeExpression result, IConfigurationElement element) throws CoreException {\n" +
" IConfigurationElement[] children= element.getChildren();\n" +
@@ -717,6 +773,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(" ", indent);
}
+ @Test
public void testListAlignmentMethodDeclaration() {
// parameter declaration - alignment with parenthesis
fDocument.set( "\tvoid proc ( int par1, int par2,\n" +
@@ -726,6 +783,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(" ", indent);
}
+ @Test
public void testListAlignmentMethodCall() {
// parameter declaration - alignment with parenthesis
fDocument.set( "\this.proc (par1, par2,\n" +
@@ -735,6 +793,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(" ", indent);
}
+ @Test
public void testListAlignmentArray() {
// parameter declaration - alignment with parenthesis
fDocument.set( "\tint[]= new int[] { 1, two,\n" +
@@ -744,6 +803,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(" ", indent);
}
+ @Test
public void testListAlignmentArray2() {
// no prior art - probe system settings.
fDocument.set( "\tint[]= new int[] { 1, two,\n");
@@ -753,6 +813,7 @@ public class JavaHeuristicScannerTest extends TestCase {
}
+ @Test
public void testBraceAlignmentOfMultilineDeclaration() {
fDocument.set( " protected int foobar(int one, int two,\n" +
" int three, int four,\n" +
@@ -765,6 +826,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(" ", indent);
}
+ @Test
public void testBlocksInCaseStatements() {
fDocument.set(
" switch (i) {\n" +
@@ -776,6 +838,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(" ", indent);
}
+ @Test
public void testAnonymousTypeBraceNextLine() throws Exception {
fDocument.set(
" MenuItem mi= new MenuItem(\"About...\");\n" +
@@ -791,6 +854,7 @@ public class JavaHeuristicScannerTest extends TestCase {
/*
* @since 3.2
*/
+ @Test
public void testClassInstanceCreationHeuristic() throws Exception {
fDocument.set(" method(new java.util.ArrayList<String>(10), foo, new int[])");
@@ -814,6 +878,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertFalse(fHeuristicScanner.looksLikeClassInstanceCreationBackward(offset, JavaHeuristicScanner.UNBOUND));
}
+ @Test
public void testConditional1() throws Exception {
if (BUG_65463) // XXX enable when https://bugs.eclipse.org/bugs/show_bug.cgi?id=65463 is fixed
return;
@@ -827,6 +892,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(" ", indent);
}
+ @Test
public void testConditional2() throws Exception {
if (BUG_65463) // XXX enable when https://bugs.eclipse.org/bugs/show_bug.cgi?id=65463 is fixed
return;
@@ -842,6 +908,7 @@ public class JavaHeuristicScannerTest extends TestCase {
}
+ @Test
public void testContinuationIndentationOfForStatement() throws Exception {
fDocument.set("\tfor (int i = (2 * 2); i < array.length; i++) {\n" +
"\tint i= 25;\n" +
@@ -863,6 +930,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testContinuationIndentationOfForEachStatement() throws Exception {
// Bug 331028 and Bug 331734
fDocument.set("\tfor (int value : values) {\n" +
@@ -874,6 +942,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testContinuationIndentationOfForEachStatement2() throws Exception {
// Bug 348198
fDocument.set("\tfor (int value : values)\n" +
@@ -885,6 +954,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testContinuationIndentationOfBooleanExpression() throws Exception {
fDocument.set("\tboolean a = true || false;\n" +
"\tboolean b = a || false;\n");
@@ -895,6 +965,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testContinuationIndentationOfReturnStatement() throws Exception {
fDocument.set("\t\treturn \"I'm such a long string that you have to split me to see the whole line without scrolling around\"\n");
@@ -906,6 +977,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testContinuationIndentationOfAssignmentStatement() throws Exception {
fDocument.set("\tint i= 5+");
@@ -915,6 +987,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testContinuationIndentationOfThrowsClause() throws Exception {
fDocument.set("\tprivate void thrower() throws java.sql.SQLException, java.io.IOException {");
@@ -924,6 +997,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testContinuationIndentationOfParentheses() throws Exception {
fDocument.set("\tint foo() {\n\treturn \"\".length(\n\t\t);\n\t}");
@@ -931,6 +1005,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testContinuationIndentationOfAnnotation() throws Exception {
fDocument.set("\t@MyAnnotation(\n\t\tvalue=\"hello\")\n\t\tpublic class ArrayAnnotationBug {\n\t\t}");
String indent= fScanner.computeIndentation(33).toString();
@@ -941,6 +1016,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t", indent);
}
+ @Test
public void testIndentationAfterIfTryCatch() throws Exception {
fDocument.set("\tpublic class Bug237081 {\n" +
"\t\tpublic void foo() {\n" +
@@ -969,6 +1045,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testContinuationIndentationOfBrackets() throws Exception {
fDocument.set("\tprivate void helper2(boolean[] booleans) {\n\t}");
@@ -990,6 +1067,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testContinuationIndentationOfStrings1() throws Exception {
fDocument.set(
" String[] i = new String[] {\n" + //0-28
@@ -1014,6 +1092,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testContinuationIndentationOfStrings2() throws Exception {
//Bug 338229
fDocument.set(
@@ -1025,6 +1104,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testContinuationIndentationOfStrings3() throws Exception {
fDocument.set(
" String test =\n" + //0-14
@@ -1035,6 +1115,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testContinuationIndentation1() throws Exception {
fDocument.set("\treturn (thisIsAVeryLongName == 1 && anotherVeryLongName == 1)\n" +
"\t\t|| thisIsAVeryLongName == 2;");
@@ -1045,6 +1126,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testContinuationIndentation2() {
fDocument.set("\tint a;\n" +
"\tif (true)\n" +
@@ -1055,6 +1137,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals(21, pos);
}
+ @Test
public void testContinuationIndentation3() {
fDocument.set("\tint a;\n" +
"\tif (true)\n" +
@@ -1064,6 +1147,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testContinuationIndentation4() {
fDocument.set("\tint a;\n" +
"\tif (true)\n" +
@@ -1073,6 +1157,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testContinuationIndentation5() {
fDocument.set("\tint a;\n" +
"\tif (true)\n" +
@@ -1083,6 +1168,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testIndentationTryWithResources() throws Exception {
String s= "class A {\n" +
" void foo() throws Throwable {\n" +
@@ -1109,6 +1195,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t\t", indent);
}
+ @Test
public void testDefaultMethod1() {
StringBuilder buf= new StringBuilder();
buf.append("interface I {\n");
@@ -1132,6 +1219,7 @@ public class JavaHeuristicScannerTest extends TestCase {
assertEquals("\t\t", indent);
}
+ @Test
public void testDefaultMethod2() {
StringBuilder buf= new StringBuilder();
buf.append("interface I {\n");
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaModelOpCompundUndoTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaModelOpCompundUndoTest.java
index f044005dbf..a5ee4b6658 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaModelOpCompundUndoTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaModelOpCompundUndoTest.java
@@ -13,9 +13,17 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.text.tests.performance.EditorTestHelper;
@@ -48,7 +56,6 @@ import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
-
/**
* Tests that Java model operations can be undone in one group.
* <p>
@@ -57,7 +64,9 @@ import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
*
* @since 3.5
*/
-public class JavaModelOpCompundUndoTest extends TestCase {
+public class JavaModelOpCompundUndoTest {
+ @Rule
+ public TestName tn= new TestName();
private static final String SRC= "src";
private static final String SEP= "/";
@@ -77,11 +86,6 @@ public class JavaModelOpCompundUndoTest extends TestCase {
" \n" +
"}\n";
- public static Test suite() {
- TestSuite suite= new TestSuite(JavaModelOpCompundUndoTest.class);
- return suite;
- }
-
private JavaEditor fEditor;
private IDocument fDocument;
private IJavaProject fProject;
@@ -89,21 +93,21 @@ public class JavaModelOpCompundUndoTest extends TestCase {
private IUndoManager fUndoManager;
private void setUpProject(String sourceLevel) throws CoreException, JavaModelException {
- fProject= JavaProjectHelper.createJavaProject(getName(), "bin");
+ fProject= JavaProjectHelper.createJavaProject(tn.getMethodName(), "bin");
fProject.setOption(JavaCore.COMPILER_SOURCE, sourceLevel);
JavaProjectHelper.addSourceContainer(fProject, SRC);
- IPackageFragment fragment= fProject.findPackageFragment(new Path(SEP + getName() + SEP + SRC));
+ IPackageFragment fragment= fProject.findPackageFragment(new Path(SEP + tn.getMethodName() + SEP + SRC));
fCompilationUnit= fragment.createCompilationUnit(CU_NAME, CU_CONTENTS, true, new NullProgressMonitor());
}
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
setUpProject(JavaCore.VERSION_1_5);
setUpEditor();
}
private void setUpEditor() {
- fEditor= openJavaEditor(new Path(SEP + getName() + SEP + SRC + SEP + CU_NAME));
+ fEditor= openJavaEditor(new Path(SEP + tn.getMethodName() + SEP + SRC + SEP + CU_NAME));
assertNotNull(fEditor);
fUndoManager= ((ITextViewerExtension6)fEditor.getViewer()).getUndoManager();
assertNotNull(fUndoManager);
@@ -114,7 +118,8 @@ public class JavaModelOpCompundUndoTest extends TestCase {
private JavaEditor openJavaEditor(IPath path) {
IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- assertTrue(file != null && file.exists());
+ assertNotNull(file);
+ assertTrue(file.exists());
try {
return (JavaEditor)EditorTestHelper.openInEditor(file, true);
} catch (PartInitException e) {
@@ -123,8 +128,8 @@ public class JavaModelOpCompundUndoTest extends TestCase {
}
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
EditorTestHelper.closeEditor(fEditor);
fEditor= null;
if (fProject != null) {
@@ -133,6 +138,7 @@ public class JavaModelOpCompundUndoTest extends TestCase {
}
}
+ @Test
public void test1() throws Exception {
assertEquals(CU_CONTENTS, fDocument.get());
@@ -144,13 +150,14 @@ public class JavaModelOpCompundUndoTest extends TestCase {
model.delete(new IJavaElement[] { foo, bar }, true, null);
fUndoManager.endCompoundChange();
- assertFalse(CU_CONTENTS.equals(fDocument.get()));
+ assertNotEquals(CU_CONTENTS, fDocument.get());
fUndoManager.undo();
assertEquals(CU_CONTENTS, fDocument.get());
}
+ @Test
public void test2() throws Exception {
setUpProject(JavaCore.VERSION_1_5);
setUpEditor();
@@ -165,10 +172,9 @@ public class JavaModelOpCompundUndoTest extends TestCase {
model.delete(new IJavaElement[] { bar }, true, null);
fUndoManager.endCompoundChange();
- assertFalse(CU_CONTENTS.equals(fDocument.get()));
+ assertNotEquals(CU_CONTENTS, fDocument.get());
fUndoManager.undo();
assertEquals(CU_CONTENTS, fDocument.get());
-
}
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaParameterListValidatorTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaParameterListValidatorTest.java
index c7f33d48e8..86736dc878 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaParameterListValidatorTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaParameterListValidatorTest.java
@@ -13,11 +13,18 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
@@ -30,79 +37,74 @@ import org.eclipse.jface.text.tests.TestTextViewer;
import org.eclipse.jdt.internal.ui.text.java.JavaParameterListValidator;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-
-public class JavaParameterListValidatorTest extends TestCase {
-
+public class JavaParameterListValidatorTest {
protected TestTextViewer fTextViewer;
protected IDocument fDocument;
protected JavaParameterListValidator fValidator;
- public JavaParameterListValidatorTest(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() {
+ @Before
+ public void setUp() {
fTextViewer= new TestTextViewer();
fDocument= new Document();
fValidator= new JavaParameterListValidator();
}
- public static Test suite() {
- return new TestSuite(JavaParameterListValidatorTest.class);
- }
-
- @Override
- protected void tearDown () {
+ @After
+ public void tearDown () {
fTextViewer= null;
fDocument= null;
fValidator= null;
}
+ @Test
public void testParameterStyling() {
final String code= "a, b, c, d, e";
assertParameterInfoStyles(code, "int a, int b, int c, int d, int e", computeCommaPositions(code));
}
+ @Test
public void testParameterStylingWithString() {
final String code= "a, b, \"foo, bar, and such\", d, e";
assertParameterInfoStyles(code, "int a, int b, String c, int d, int e", computeCommaPositions(code));
}
+ @Test
public void testParameterStylingWithEscapedString() {
final String code= "a, b, \"foo, b\\\"ar, and such\\\\\", d, e";
assertParameterInfoStyles(code, "int a, int b, String c, int d, int e", computeCommaPositions(code));
}
+ @Test
public void testParameterStylingWithComment() {
final String code= "a, b, c /* the ( argument */, d, e";
assertParameterInfoStyles(code, "int a, int b, String c, int d, int e", computeCommaPositions(code));
}
+ @Test
public void testParameterStylingWithGenerics() {
final String code= "new HashMap <String, HashMap<String,Integer[]>>(), p1, p2";
assertParameterInfoStyles(code, "Map<String, Map> m, int p1, int p2", computeCommaPositions(code));
}
+ @Test
public void testParameterStylingWithGenericsAndComments() {
final String code= "new HashMap <String, /* comment > */HashMap<String,Integer[]>>(), p1, p2";
assertParameterInfoStyles(code, "Map<String, Map> m, int p1, int p2", new int[] {64, 68});
}
+ @Test
public void testParameterStylingWithConstants() {
final String code= "MAX < MIN, MAX > MIN";
assertParameterInfoStyles(code, "boolean b1, boolean b2", new int[] {9});
}
+ @Test
public void testParameterStylingWithGenericsThatLookLikeConstants() {
final String code= "new MAX < MIN, MAX >";
assertParameterInfoStyles(code, "MAX<?,?>", new int[0]);
}
+ @Test
public void testParameterStylingWithNestedGenerics() {
final String code= "null, null";
assertParameterInfoStyles(code, "ICallback<List<ETypedElement>, T2, D> callback, Shell shell", computeCommaPositions(code));
@@ -231,14 +233,14 @@ public class JavaParameterListValidatorTest extends TestCase {
private static void assertEquals(TextPresentation expected, TextPresentation actual) {
// check lengths
- assertTrue(expected.getDenumerableRanges() == actual.getDenumerableRanges());
+ Assert.assertEquals(expected.getDenumerableRanges(), actual.getDenumerableRanges());
// check default range
- assertEquals(expected.getDefaultStyleRange(), actual.getDefaultStyleRange());
+ Assert.assertEquals(expected.getDefaultStyleRange(), actual.getDefaultStyleRange());
// check rest
Iterator<StyleRange> e1= expected.getAllStyleRangeIterator();
Iterator<StyleRange> e2= actual.getAllStyleRangeIterator();
while (e1.hasNext())
- assertEquals(e1.next(), e2.next());
+ Assert.assertEquals(e1.next(), e2.next());
}
protected String print(TextPresentation presentation) {
@@ -259,26 +261,32 @@ public class JavaParameterListValidatorTest extends TestCase {
}
return buf.toString();
}
+ @Test
public void testValidPositions() {
assertValidPositions("(a, b, c)");
}
+ @Test
public void testValidPositionsWithComment() {
assertValidPositions("(a, b /* the ( argument */, c)");
}
+ @Test
public void testValidPositionsWithString() {
assertValidPositions("(a, \"foo, bar, and such\", c)");
}
+ @Test
public void testValidGenericPositions() throws Exception {
assertValidPositions("(new A<T>(), new B<T>())");
}
+ @Test
public void testValidAllPositions() throws Exception {
assertValidPositions("(new HashMap<String, HashMap<String,Integer[]>>(), p1, p2)");
}
+ @Test
public void testValidArrayPositions() throws Exception {
assertValidPositions("(foo[], bar[13])");
}
@@ -297,7 +305,7 @@ public class JavaParameterListValidatorTest extends TestCase {
IContextInformation info= new ContextInformation("context", "info");
fValidator.install(info, fTextViewer, 1);
- assertTrue(!fValidator.isContextInformationValid(0));
+ assertFalse(fValidator.isContextInformationValid(0));
final int length= code.length();
final int firstInnerPosition= 1;
final int lastInnerPosition= length - 1;
@@ -305,11 +313,11 @@ public class JavaParameterListValidatorTest extends TestCase {
// forward
for (int pos= firstInnerPosition; pos <= lastInnerPosition; pos++)
assertTrue(fValidator.isContextInformationValid(pos));
- assertTrue(!fValidator.isContextInformationValid(length));
+ assertFalse(fValidator.isContextInformationValid(length));
// backward
for (int pos= lastInnerPosition; pos >= firstInnerPosition; pos--)
assertTrue(fValidator.isContextInformationValid(pos));
- assertTrue(!fValidator.isContextInformationValid(0));
+ assertFalse(fValidator.isContextInformationValid(0));
}
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaPartitionerExtensionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaPartitionerExtensionTest.java
index 4e88e83751..34fb126a57 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaPartitionerExtensionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaPartitionerExtensionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,9 +13,16 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.eclipse.jface.preference.PreferenceStore;
@@ -30,13 +37,7 @@ import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jdt.ui.text.JavaTextTools;
-
-
-
-
-public class JavaPartitionerExtensionTest extends TestCase {
-
-
+public class JavaPartitionerExtensionTest {
class PartitioningListener implements IDocumentPartitioningListener, IDocumentPartitioningListenerExtension {
/*
* @see IDocumentPartitioningListener#documentPartitioningChanged(IDocument)
@@ -61,13 +62,8 @@ public class JavaPartitionerExtensionTest extends TestCase {
protected boolean fDocumentPartitioningChanged;
protected IRegion fChangedDocumentPartitioning;
-
- public JavaPartitionerExtensionTest(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() {
+ @Before
+ public void setUp() {
fTextTools= new JavaTextTools(new PreferenceStore());
@@ -81,12 +77,8 @@ public class JavaPartitionerExtensionTest extends TestCase {
fDocument.addDocumentPartitioningListener(new PartitioningListener());
}
- public static Test suite() {
- return new TestSuite(JavaPartitionerExtensionTest.class);
- }
-
- @Override
- protected void tearDown () {
+ @After
+ public void tearDown () {
fTextTools.dispose();
fTextTools= null;
@@ -107,18 +99,19 @@ public class JavaPartitionerExtensionTest extends TestCase {
protected void check(int offset, int length) {
assertTrue(fDocumentPartitioningChanged);
assertNotNull(fChangedDocumentPartitioning);
- assertTrue(fChangedDocumentPartitioning.getOffset() == offset);
- assertTrue(fChangedDocumentPartitioning.getLength() == length);
+ assertEquals(fChangedDocumentPartitioning.getOffset(), offset);
+ assertEquals(fChangedDocumentPartitioning.getLength(), length);
fDocumentPartitioningChanged= false;
fChangedDocumentPartitioning= null;
}
protected void check() {
- assertTrue(!fDocumentPartitioningChanged);
- assertTrue(fChangedDocumentPartitioning == null);
+ assertFalse(fDocumentPartitioningChanged);
+ assertNull(fChangedDocumentPartitioning);
}
+ @Test
public void testConvertPartition() {
try {
@@ -127,10 +120,11 @@ public class JavaPartitionerExtensionTest extends TestCase {
fDocument.replace(0,0,"//");
check(0, 9);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testTransformPartition() {
try {
@@ -139,10 +133,11 @@ public class JavaPartitionerExtensionTest extends TestCase {
fDocument.replace(0,0,"//");
check(0, 13);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testToggleMultiPartition() {
try {
@@ -151,10 +146,11 @@ public class JavaPartitionerExtensionTest extends TestCase {
fDocument.replace(0,0,"//");
check(0, 43);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testSplitPartition() {
try {
fDocument.set("class X {}");
@@ -162,10 +158,11 @@ public class JavaPartitionerExtensionTest extends TestCase {
fDocument.replace(9, 0, "/**/");
check(9, 4);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testShortenDocument() {
try {
fDocument.set("class x {\n/***/\n}");
@@ -173,10 +170,11 @@ public class JavaPartitionerExtensionTest extends TestCase {
fDocument.replace(0, fDocument.getLength(), "/**/");
check(0, 4);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testDeletePartition() {
try {
fDocument.set("class x {\n/***/\n}");
@@ -184,10 +182,11 @@ public class JavaPartitionerExtensionTest extends TestCase {
fDocument.replace(10, 5, "");
check(10, 0);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testDeletePartition2() {
try {
fDocument.set("class x {\n/***/\n}");
@@ -195,7 +194,7 @@ public class JavaPartitionerExtensionTest extends TestCase {
fDocument.replace(10, 7, "");
check(10, 0);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaPartitionerTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaPartitionerTest.java
index 30db9a814c..ff87b17a24 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaPartitionerTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JavaPartitionerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,9 +13,14 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.eclipse.jface.preference.PreferenceStore;
@@ -30,20 +35,13 @@ import org.eclipse.jface.text.TypedRegion;
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jdt.ui.text.JavaTextTools;
-
-public class JavaPartitionerTest extends TestCase {
-
+public class JavaPartitionerTest {
private JavaTextTools fTextTools;
private Document fDocument;
protected boolean fDocumentPartitioningChanged;
-
- public JavaPartitionerTest(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() {
+ @Before
+ public void setUp() {
fTextTools= new JavaTextTools(new PreferenceStore());
@@ -62,12 +60,8 @@ public class JavaPartitionerTest extends TestCase {
});
}
- public static Test suite() {
- return new TestSuite(JavaPartitionerTest.class);
- }
-
- @Override
- protected void tearDown () {
+ @After
+ public void tearDown () {
fTextTools.dispose();
fTextTools= null;
@@ -87,11 +81,12 @@ public class JavaPartitionerTest extends TestCase {
for (int i= 0; i < expectation.length; i++) {
ITypedRegion e= expectation[i];
ITypedRegion r= result[i];
- assertTrue(print(r) + " != " + print(e), r.equals(e));
+ assertEquals(print(r) + " != " + print(e), r, e);
}
}
+ @Test
public void testInitialPartitioning() {
try {
@@ -112,17 +107,18 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testIntraPartitionChange() {
try {
fDocument.replace(34, 3, "y");
// "xxx\n/*xxx*/\nxxx\n/**xxx*/\nxxx\n/**/\ny\n/***/\nxxx");
- assertTrue(!fDocumentPartitioningChanged);
+ assertFalse(fDocumentPartitioningChanged);
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
TypedRegion[] expectation= {
@@ -139,10 +135,11 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testIntraPartitionChange2() {
try {
@@ -166,9 +163,10 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testInsertNewPartition() {
try {
@@ -194,10 +192,11 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testRemovePartition1() {
try {
@@ -220,10 +219,11 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testRemovePartition2() {
testJoinPartition3();
@@ -249,11 +249,12 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testJoinPartitions1() {
try {
@@ -275,10 +276,11 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testJoinPartitions2() {
try {
@@ -300,10 +302,11 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testJoinPartition3() {
try {
@@ -325,11 +328,12 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testSplitPartition1() {
testJoinPartitions1();
@@ -346,12 +350,13 @@ public class JavaPartitionerTest extends TestCase {
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
testInitialPartitioning();
}
+ @Test
public void testSplitPartition2() {
testJoinPartitions2();
@@ -366,12 +371,13 @@ public class JavaPartitionerTest extends TestCase {
assertTrue(fDocumentPartitioningChanged);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
testInitialPartitioning();
}
+ @Test
public void testSplitPartition3() {
fDocumentPartitioningChanged= false;
@@ -397,10 +403,11 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testCorruptPartitioning1() {
try {
@@ -428,10 +435,11 @@ public class JavaPartitionerTest extends TestCase {
};
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testCorruptPartitioning2() {
try {
@@ -463,10 +471,11 @@ public class JavaPartitionerTest extends TestCase {
};
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testCorruptPartitioning3() {
try {
@@ -496,10 +505,11 @@ public class JavaPartitionerTest extends TestCase {
};
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testOpenPartition1() {
try {
@@ -523,10 +533,11 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testOpenPartition2() {
try {
@@ -552,11 +563,12 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testChangeContentTypeOfPartition() {
try {
@@ -581,25 +593,27 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testPartitionFinder() {
try {
for (ITypedRegion expected : fDocument.computePartitioning(0, fDocument.getLength())) {
for (int j= 0; j < expected.getLength(); j++) {
ITypedRegion result= fDocument.getPartition(expected.getOffset() + j);
- assertTrue(expected.equals(result));
+ assertEquals(expected, result);
}
}
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testExtendPartition() {
try {
@@ -621,10 +635,11 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testTransformPartition() {
try {
@@ -646,10 +661,11 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testTogglePartition() {
try {
@@ -677,10 +693,11 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation2, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testEditing1() {
try {
@@ -714,10 +731,11 @@ public class JavaPartitionerTest extends TestCase {
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testEditing2() {
try {
@@ -759,10 +777,11 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
+ @Test
public void testEditing3() {
try {
@@ -796,7 +815,7 @@ public class JavaPartitionerTest extends TestCase {
checkPartitioning(expectation, result);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
}
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JdtTextTestSuite.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JdtTextTestSuite.java
index ca535fc9ef..c90b5bb456 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JdtTextTestSuite.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/JdtTextTestSuite.java
@@ -46,8 +46,8 @@ import org.eclipse.jdt.text.tests.templates.TemplatesTestSuite;
PropertiesFileAutoEditStrategyTest.class,
// PartitionTokenScannerTest.class,
MarkOccurrenceTest.class,
- MarkOccurrenceTest17.class,
- MarkOccurrenceTest18.class,
+ MarkOccurrenceTest1d7.class,
+ MarkOccurrenceTest1d8.class,
PluginsNotLoadedTest.class,
// PluginsNotLoadedTest.addLoadedPlugIns(
// new String[] {
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest17.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest1d7.java
index fb74fd38cc..e1ca9d61ae 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest17.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest1d7.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2016 IBM Corporation and others.
+ * Copyright (c) 2011, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,9 +13,17 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import java.util.Arrays;
import java.util.Comparator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.core.ICompilationUnit;
@@ -26,33 +34,24 @@ import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.internal.core.manipulation.search.IOccurrencesFinder;
+import org.eclipse.jdt.internal.core.manipulation.search.IOccurrencesFinder.OccurrenceLocation;
+import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
+
import org.eclipse.jdt.ui.PreferenceConstants;
-import org.eclipse.jdt.ui.tests.core.Java1d7ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d7ProjectTestSetup;
import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
import org.eclipse.jdt.internal.ui.search.ExceptionOccurrencesFinder;
-import org.eclipse.jdt.internal.core.manipulation.search.IOccurrencesFinder;
-import org.eclipse.jdt.internal.core.manipulation.search.IOccurrencesFinder.OccurrenceLocation;
import org.eclipse.jdt.internal.ui.search.MethodExitsFinder;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
/**
* Tests the Java Editor's occurrence marking feature.
+ * Those tests should run on Java Dolphin 1.7 .
*/
-public class MarkOccurrenceTest17 extends TestCase {
- private static final Class<MarkOccurrenceTest17> THIS= MarkOccurrenceTest17.class;
-
- public static Test suite() {
- return new Java1d7ProjectTestSetup(new TestSuite(THIS));
- }
-
- public static Test setUpTest(Test test) {
- return new Java1d7ProjectTestSetup(test);
- }
+public class MarkOccurrenceTest1d7 {
+ @Rule
+ public Java1d7ProjectTestSetup j7s= new Java1d7ProjectTestSetup();
private ASTParser fParser;
@@ -65,8 +64,8 @@ public class MarkOccurrenceTest17 extends TestCase {
/*
* @see junit.framework.TestCase#setUp()
*/
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
fParser= ASTParser.newParser(IASTSharedValues.SHARED_AST_LEVEL);
fJProject1= Java1d7ProjectTestSetup.getProject();
@@ -75,8 +74,8 @@ public class MarkOccurrenceTest17 extends TestCase {
JavaPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.EDITOR_MARK_IMPLEMENTORS, true);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
JavaProjectHelper.clear(fJProject1, Java1d7ProjectTestSetup.getDefaultClasspath());
}
@@ -133,6 +132,7 @@ public class MarkOccurrenceTest17 extends TestCase {
return find(s, pattern, ithOccurrence - 1, idx + 1);
}
+ @Test
public void testMarkMethodExits1() throws Exception {
fFinder= new MethodExitsFinder();
StringBuffer s= new StringBuffer();
@@ -159,6 +159,7 @@ public class MarkOccurrenceTest17 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testMarkMethodExits2() throws Exception {
fFinder= new MethodExitsFinder();
StringBuffer s= new StringBuffer();
@@ -183,6 +184,7 @@ public class MarkOccurrenceTest17 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testMarkMethodExits3() throws Exception {
fFinder= new MethodExitsFinder();
StringBuffer s= new StringBuffer();
@@ -207,6 +209,7 @@ public class MarkOccurrenceTest17 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testMarkMethodExits4() throws Exception {
fFinder= new MethodExitsFinder();
StringBuffer s= new StringBuffer();
@@ -234,6 +237,7 @@ public class MarkOccurrenceTest17 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testMarkMethodExits5() throws Exception {
fFinder= new MethodExitsFinder();
StringBuffer s= new StringBuffer();
@@ -261,6 +265,7 @@ public class MarkOccurrenceTest17 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testMarkMethodExits6() throws Exception {
fFinder= new MethodExitsFinder();
StringBuffer s= new StringBuffer();
@@ -288,6 +293,7 @@ public class MarkOccurrenceTest17 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testMarkMethodExits7() throws Exception {
fFinder= new MethodExitsFinder();
StringBuffer s= new StringBuffer();
@@ -313,6 +319,7 @@ public class MarkOccurrenceTest17 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testThrowingException1() throws Exception {
fFinder= new ExceptionOccurrencesFinder();
StringBuffer s= new StringBuffer();
@@ -339,6 +346,7 @@ public class MarkOccurrenceTest17 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testThrowingException2() throws Exception {
fFinder= new ExceptionOccurrencesFinder();
StringBuffer s= new StringBuffer();
@@ -363,6 +371,7 @@ public class MarkOccurrenceTest17 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testThrowingException3() throws Exception {
fFinder= new ExceptionOccurrencesFinder();
StringBuffer s= new StringBuffer();
@@ -390,6 +399,7 @@ public class MarkOccurrenceTest17 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testThrowingException4() throws Exception {
fFinder= new ExceptionOccurrencesFinder();
StringBuffer s= new StringBuffer();
@@ -417,6 +427,7 @@ public class MarkOccurrenceTest17 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testThrowingException5() throws Exception {
fFinder= new ExceptionOccurrencesFinder();
StringBuffer s= new StringBuffer();
@@ -444,6 +455,7 @@ public class MarkOccurrenceTest17 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testThrowingException6() throws Exception {
fFinder= new ExceptionOccurrencesFinder();
StringBuffer s= new StringBuffer();
@@ -471,6 +483,7 @@ public class MarkOccurrenceTest17 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testThrowingException7() throws Exception {
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=68305
fFinder= new ExceptionOccurrencesFinder();
@@ -498,6 +511,7 @@ public class MarkOccurrenceTest17 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testThrowingException8() throws Exception {
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=68305
fFinder= new ExceptionOccurrencesFinder();
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest18.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest1d8.java
index c16baaf9a5..4a8e7bc81f 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest18.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/MarkOccurrenceTest1d8.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2016 IBM Corporation and others.
+ * Copyright (c) 2011, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,9 +13,17 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import java.util.Arrays;
import java.util.Comparator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.core.ICompilationUnit;
@@ -26,29 +34,22 @@ import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.ui.PreferenceConstants;
-import org.eclipse.jdt.ui.tests.core.Java18ProjectTestSetup;
-
-import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
-import org.eclipse.jdt.internal.ui.search.ExceptionOccurrencesFinder;
import org.eclipse.jdt.internal.core.manipulation.search.IOccurrencesFinder;
import org.eclipse.jdt.internal.core.manipulation.search.IOccurrencesFinder.OccurrenceLocation;
+import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class MarkOccurrenceTest18 extends TestCase {
- private static final Class<MarkOccurrenceTest18> THIS= MarkOccurrenceTest18.class;
+import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
- public static Test suite() {
- return new Java18ProjectTestSetup(new TestSuite(THIS));
- }
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.internal.ui.search.ExceptionOccurrencesFinder;
- public static Test setUpTest(Test test) {
- return new Java18ProjectTestSetup(test);
- }
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
+public class MarkOccurrenceTest1d8 {
+ @Rule
+ public Java1d8ProjectTestSetup f18p= new Java1d8ProjectTestSetup();
private ASTParser fParser;
@@ -61,18 +62,18 @@ public class MarkOccurrenceTest18 extends TestCase {
/*
* @see junit.framework.TestCase#setUp()
*/
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
fParser= ASTParser.newParser(IASTSharedValues.SHARED_AST_LEVEL);
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
JavaPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.EDITOR_MARK_OCCURRENCES, true);
}
- @Override
- protected void tearDown() throws Exception {
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ @After
+ public void tearDown() throws Exception {
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
private OccurrenceLocation[] getHighlights(StringBuffer source, int offset, int length) throws Exception {
@@ -128,6 +129,7 @@ public class MarkOccurrenceTest18 extends TestCase {
return find(s, pattern, ithOccurrence - 1, idx + 1);
}
+ @Test
public void testThrowingAnnotatedException1() throws Exception {
StringBuffer s= new StringBuffer();
s.append("package test1;\n");
@@ -208,6 +210,7 @@ public class MarkOccurrenceTest18 extends TestCase {
checkSelection(s, offset, length, ranges);
}
+ @Test
public void testThrownExceptionInLambda() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
@@ -236,6 +239,7 @@ public class MarkOccurrenceTest18 extends TestCase {
checkSelection(buf, offset, length, ranges);
}
+ @Test
public void testTryCatchInLambda() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
@@ -258,5 +262,4 @@ public class MarkOccurrenceTest18 extends TestCase {
OccurrenceLocation[] ranges= { find(buf, "FileInputStream", 2), find(buf, "FileNotFoundException", 2) };
checkSelection(buf, offset, length, ranges);
}
-
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PartitionTokenScannerTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PartitionTokenScannerTest.java
index d6d79c0271..f39dd687d1 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PartitionTokenScannerTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PartitionTokenScannerTest.java
@@ -13,14 +13,15 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
+import static org.junit.Assert.assertEquals;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.Before;
+import org.junit.Test;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
@@ -35,18 +36,13 @@ import org.eclipse.jdt.internal.ui.text.JavaPartitionScanner;
/**
* Compares two <code>IParitionTokenScanner</code>s for conformance and performance.
*/
-public class PartitionTokenScannerTest extends TestCase {
-
+public class PartitionTokenScannerTest {
private static final boolean DEBUG= false;
private IPartitionTokenScanner fReference;
private IPartitionTokenScanner fTestee;
- public PartitionTokenScannerTest(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() {
+ @Before
+ public void setUp() {
fReference= new JavaPartitionScanner();
fTestee= new FastJavaPartitionScanner(true);
}
@@ -86,30 +82,32 @@ public class PartitionTokenScannerTest extends TestCase {
return new Document(buffer.toString());
}
- public static Test suite() {
- return new TestSuite(PartitionTokenScannerTest.class);
- }
-
+ @Test
public void testTestCaseLF() {
testConformance(getDocument("TestCase.txt", "\n"));
}
+ @Test
public void testTestCaseCRLF() {
testConformance(getDocument("TestCase.txt", "\r\n"));
}
+ @Test
public void testTestCaseCR() {
testConformance(getDocument("TestCase.txt", "\r"));
}
+ @Test
public void testTestCase2LF() {
testConformance(getDocument("TestCase2.txt", "\n"));
}
+ @Test
public void testTestCase2CRLF() {
testConformance(getDocument("TestCase2.txt", "\r\n"));
}
+ @Test
public void testTestCase2CR() {
testConformance(getDocument("TestCase2.txt", "\r"));
}
@@ -122,6 +120,7 @@ public class PartitionTokenScannerTest extends TestCase {
/**
* Tests performance of the testee against the reference IPartitionTokenScanner.
*/
+ @Test
public void testPerformance() {
final int COUNT= 5000;
final IDocument document= getDocument("TestCase.txt", "\n");
@@ -139,6 +138,7 @@ public class PartitionTokenScannerTest extends TestCase {
// assertTrue(testeeTime <= referenceTime);
}
+ @Test
public void test_bug57903() {
final Document document= new Document("<%/**f%>");
fReference.setRange(document, 2, 4);
@@ -272,5 +272,4 @@ public class PartitionTokenScannerTest extends TestCase {
return buffer.toString();
}
-
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PluginsNotLoadedTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PluginsNotLoadedTest.java
index c296aad86a..6c1b74fadc 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PluginsNotLoadedTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PluginsNotLoadedTest.java
@@ -203,13 +203,7 @@ public class PluginsNotLoadedTest {
if (Platform.getBundle("org.eclipse.egit.ui") != null) {
addLoadedPlugIns("org.eclipse.compare");
}
- addLoadedPlugIns(
- new String[] {
- "org.eclipse.core.filebuffers.tests",
- "org.eclipse.core.variables",
- "org.eclipse.team.cvs.core",
- "org.eclipse.test.performance"
- });
+ addLoadedPlugIns("org.eclipse.core.filebuffers.tests", "org.eclipse.core.variables", "org.eclipse.team.cvs.core", "org.eclipse.test.performance");
}
};
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PropertiesFileAutoEditStrategyTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PropertiesFileAutoEditStrategyTest.java
index 6547f0cc0e..4e7cefa6f5 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PropertiesFileAutoEditStrategyTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PropertiesFileAutoEditStrategyTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2013 IBM Corporation and others.
+ * Copyright (c) 2010, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,14 +13,18 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
@@ -39,15 +43,14 @@ import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.ui.tests.core.ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
/**
* PropertiesFileAutoEditStratergyTest
*
* @since 3.7
*/
-public class PropertiesFileAutoEditStrategyTest extends TestCase {
-
+public class PropertiesFileAutoEditStrategyTest {
private static final String UTF_8= "UTF-8";
private static final String ISO_8859_1= "ISO-8859-1";
@@ -62,19 +65,17 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
private Accessor fAccessorPropertiesFileUTF8;
- public PropertiesFileAutoEditStrategyTest(String name) {
- super(name);
+ @Rule
+ public ProjectTestSetup pts= new ProjectTestSetup();
+
+ public PropertiesFileAutoEditStrategyTest() {
fDocumentCommand= new DocumentCommand() {
};
}
- public static Test suite() {
- return new ProjectTestSetup(new TestSuite(PropertiesFileAutoEditStrategyTest.class));
- }
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
try {
fJProject1= ProjectTestSetup.getProject();
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -95,10 +96,9 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
}
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
JavaProjectHelper.clear(fJProject1, ProjectTestSetup.getDefaultClasspath());
- super.tearDown();
}
//utility methods
@@ -131,6 +131,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
}
//typing ISO-8859-1
+ @Test
public void testTypeISO_8859_1_01() throws Exception {
fDocumentCommand.text= "\\";
Object proposal= performTestISO_8859_1();
@@ -138,6 +139,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testTypeISO_8859_1_02() throws Exception {
fDocumentCommand.text= "\t";
Object proposal= performTestISO_8859_1();
@@ -145,6 +147,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testTypeISO_8859_1_03() throws Exception {
fDocumentCommand.text= "\f";
Object proposal= performTestISO_8859_1();
@@ -152,6 +155,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testTypeISO_8859_1_04() throws Exception {
fDocumentCommand.text= "\r";
Object proposal= performTestISO_8859_1();
@@ -159,6 +163,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testTypeISO_8859_1_05() throws Exception {
fDocumentCommand.text= "\n";
Object proposal= performTestISO_8859_1();
@@ -166,6 +171,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testTypeISO_8859_1_06() throws Exception {
fDocumentCommand.text= "\u2603";
Object proposal= performTestISO_8859_1();
@@ -174,6 +180,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
}
//typing UTF-8
+ @Test
public void testTypeUTF8_01() throws Exception {
fDocumentCommand.text= "\u2603";
Object proposal= performTestUTF8();
@@ -182,6 +189,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
}
//paste ISO-8859-1
+ @Test
public void testPasteISO_8859_1_01() throws Exception {
fDocumentCommand.text= "C:\\Program Files\\Java";
Object proposal= performTestISO_8859_1();
@@ -189,6 +197,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertEquals("C:\\\\Program Files\\\\Java", getProposalText(proposal));
}
+ @Test
public void testPasteISO_8859_1_02() throws Exception {
fDocumentCommand.text= "C:\\new folder\\A.java";
Object proposal= performTestISO_8859_1();
@@ -196,6 +205,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertEquals("C:\\\\new folder\\\\A.java", getProposalText(proposal));
}
+ @Test
public void testPasteISO_8859_1_03() throws Exception {
fDocumentCommand.text= "\u0926 \u0905";
Object proposal= performTestISO_8859_1();
@@ -203,6 +213,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testPasteISO_8859_1_04() throws Exception {
fDocumentCommand.text= "\u0926 \\u0905";
Object proposal= performTestISO_8859_1();
@@ -210,6 +221,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertEquals("\\u0926 \\\\u0905", getProposalText(proposal));
}
+ @Test
public void testPasteISO_8859_1_05() throws Exception {
fDocumentCommand.text= "ä \u0926";
Object proposal= performTestISO_8859_1();
@@ -217,6 +229,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testPasteISO_8859_1_06() throws Exception {
fDocumentCommand.text= "some text\\";
Object proposal= performTestISO_8859_1();
@@ -225,6 +238,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
}
//paste UTF-8
+ @Test
public void testPasteUTF8_01() throws Exception {
fDocumentCommand.text= "C:\\Program Files\\Java";
Object proposal= performTestUTF8();
@@ -232,6 +246,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertEquals("C:\\\\Program Files\\\\Java", getProposalText(proposal));
}
+ @Test
public void testPasteUTF8_02() throws Exception {
fDocumentCommand.text= "C:\\new folder\\A.java";
Object proposal= performTestUTF8();
@@ -239,6 +254,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertEquals("C:\\\\new folder\\\\A.java", getProposalText(proposal));
}
+ @Test
public void testPasteUTF8_03() throws Exception {
fDocumentCommand.text= "\u0926 \u0905";
Object proposal= performTestUTF8();
@@ -246,6 +262,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testPasteUTF8_04() throws Exception {
fDocumentCommand.text= "\u0926 \\u0905";
Object proposal= performTestUTF8();
@@ -253,6 +270,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testPasteUTF8_05() throws Exception {
fDocumentCommand.text= "\u0926 \\some text";
Object proposal= performTestUTF8();
@@ -261,6 +279,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
}
//paste from properties file ISO-8859-1
+ @Test
public void testPasteFromPropertiesFileISO_8859_1_01() throws Exception {
fDocumentCommand.text= "\t \n \f \r";
Object proposal= performTestISO_8859_1();
@@ -268,6 +287,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testPasteFromPropertiesFileISO_8859_1_02() throws Exception {
fDocumentCommand.text= "\\u00e4 \\t \\u0926 \\n";
Object proposal= performTestISO_8859_1();
@@ -275,6 +295,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testPasteFromPropertiesFileISO_8859_1_03() throws Exception {
fDocumentCommand.text= "C:\\\\Program Files\\\\Java";
Object proposal= performTestISO_8859_1();
@@ -282,6 +303,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testPasteFromPropertiesFileISO_8859_1_04() throws Exception {
fDocumentCommand.text= "C:\\\\new folder\\\\A.java";
Object proposal= performTestISO_8859_1();
@@ -289,6 +311,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testPasteFromPropertiesFileISO_8859_1_05() throws Exception {
fDocumentCommand.text= "\\u2603 \\\\u2603";
Object proposal= performTestISO_8859_1();
@@ -296,6 +319,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testPasteFromPropertiesFileISO_8859_1_06() throws Exception {
fDocumentCommand.text= "key=value\\\nsecond line";
Object proposal= performTestISO_8859_1();
@@ -303,6 +327,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
assertNull(proposal);
}
+ @Test
public void testPasteFromPropertiesFileISO_8859_1_07() throws Exception {
fDocumentCommand.text= "\\:\\=";
Object proposal= performTestISO_8859_1();
@@ -311,6 +336,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
}
//change encoding of file
+ @Test
public void testChangeEncodingOfFile_01() throws Exception {
fDocumentCommand.text= "\u2603";
performTestUTF8();
@@ -325,6 +351,7 @@ public class PropertiesFileAutoEditStrategyTest extends TestCase {
fPropertiesFileUTF8.setCharset(UTF_8, null);
}
+ @Test
public void testChangeEncodingOfFile_02() throws Exception {
fDocumentCommand.text= "\u2603";
performTestISO_8859_1();
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PropertiesFilePartitionerTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PropertiesFilePartitionerTest.java
index 482cf3efd1..ae131c177a 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PropertiesFilePartitionerTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/PropertiesFilePartitionerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,9 +13,14 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.eclipse.jface.preference.PreferenceStore;
@@ -33,21 +38,13 @@ import org.eclipse.jdt.ui.text.JavaTextTools;
import org.eclipse.jdt.internal.ui.propertiesfileeditor.IPropertiesFilePartitions;
import org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertiesFileDocumentSetupParticipant;
-
-
-public class PropertiesFilePartitionerTest extends TestCase {
-
+public class PropertiesFilePartitionerTest {
private JavaTextTools fTextTools;
private Document fDocument;
protected boolean fDocumentPartitioningChanged;
-
- public PropertiesFilePartitionerTest(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() {
+ @Before
+ public void setUp() {
fTextTools= new JavaTextTools(new PreferenceStore());
@@ -65,12 +62,8 @@ public class PropertiesFilePartitionerTest extends TestCase {
});
}
- public static Test suite() {
- return new TestSuite(PropertiesFilePartitionerTest.class);
- }
-
- @Override
- protected void tearDown () {
+ @After
+ public void tearDown () {
fTextTools.dispose();
fTextTools= null;
@@ -90,11 +83,12 @@ public class PropertiesFilePartitionerTest extends TestCase {
for (int i= 0; i < expectation.length; i++) {
ITypedRegion e= expectation[i];
ITypedRegion r= result[i];
- assertTrue("was: "+ print(r) + ", expected: " + print(e), r.equals(e));
+ assertEquals("was: "+ print(r) + ", expected: " + print(e), r, e);
}
}
+ @Test
public void testInitialPartitioning() {
try {
ITypedRegion[] result= fDocument.computePartitioning(IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, 0, fDocument.getLength(), false);
@@ -116,6 +110,7 @@ public class PropertiesFilePartitionerTest extends TestCase {
}
}
+ @Test
public void testPartitioningWithEndingEscape() {
try {
fDocument.replace(40, 0, "\n key value\\n\nkey value\n");
@@ -142,6 +137,7 @@ public class PropertiesFilePartitionerTest extends TestCase {
}
}
+ @Test
public void testPartitioningWithLeadingWhitespace() {
try {
fDocument.replace(40, 0, "\n key value\n key value\n\tkey value\n\t\tkey value");
@@ -172,12 +168,13 @@ public class PropertiesFilePartitionerTest extends TestCase {
}
}
+ @Test
public void testIntraPartitionChange1() {
try {
fDocument.replace(1, 3, "ttt");
- assertTrue(!fDocumentPartitioningChanged);
+ assertFalse(fDocumentPartitioningChanged);
ITypedRegion[] result= fDocument.computePartitioning(IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, 0, fDocument.getLength(), false);
TypedRegion[] expectation= {
@@ -198,12 +195,13 @@ public class PropertiesFilePartitionerTest extends TestCase {
}
}
+ @Test
public void testIntraPartitionChange2() {
try {
fDocument.replace(14, 1, " ");
- assertTrue(!fDocumentPartitioningChanged);
+ assertFalse(fDocumentPartitioningChanged);
ITypedRegion[] result= fDocument.computePartitioning(IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, 0, fDocument.getLength(), false);
TypedRegion[] expectation= {
@@ -224,6 +222,7 @@ public class PropertiesFilePartitionerTest extends TestCase {
}
}
+ @Test
public void testInsertNewPartition() {
try {
@@ -252,6 +251,7 @@ public class PropertiesFilePartitionerTest extends TestCase {
}
}
+ @Test
public void testRemoveCommentPartition() {
try {
@@ -277,6 +277,7 @@ public class PropertiesFilePartitionerTest extends TestCase {
}
}
+ @Test
public void testRemoveValuePartition() {
fDocumentPartitioningChanged= false;
@@ -306,6 +307,7 @@ public class PropertiesFilePartitionerTest extends TestCase {
}
+ @Test
public void testJoinPartitions1() {
try {
@@ -330,6 +332,7 @@ public class PropertiesFilePartitionerTest extends TestCase {
}
}
+ @Test
public void testJoinPartitions2() {
try {
@@ -355,6 +358,7 @@ public class PropertiesFilePartitionerTest extends TestCase {
}
+ @Test
public void testSplitPartition1() {
testJoinPartitions1();
@@ -369,12 +373,13 @@ public class PropertiesFilePartitionerTest extends TestCase {
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
testInitialPartitioning();
}
+ @Test
public void testSplitPartition2() {
testJoinPartitions2();
@@ -387,19 +392,20 @@ public class PropertiesFilePartitionerTest extends TestCase {
assertTrue(fDocumentPartitioningChanged);
} catch (BadLocationException x) {
- assertTrue(false);
+ fail();
}
testInitialPartitioning();
}
+ @Test
public void testPartitionFinder() {
try {
for (ITypedRegion expected : fDocument.computePartitioning(IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, 0, fDocument.getLength(), false)) {
for (int j= 0; j < expected.getLength(); j++) {
ITypedRegion result= fDocument.getPartition(IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, expected.getOffset() + j, false);
- assertTrue(expected.equals(result));
+ assertEquals(expected, result);
}
}
@@ -410,6 +416,7 @@ public class PropertiesFilePartitionerTest extends TestCase {
}
}
+ @Test
public void testReplaceWithCommentPartition() {
try {
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/SmartSemicolonAutoEditStrategyTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/SmartSemicolonAutoEditStrategyTest.java
index a965b22ba2..6d41aa89df 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/SmartSemicolonAutoEditStrategyTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/SmartSemicolonAutoEditStrategyTest.java
@@ -13,7 +13,9 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests;
-import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
@@ -28,16 +30,11 @@ import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jdt.internal.ui.text.FastJavaPartitionScanner;
import org.eclipse.jdt.internal.ui.text.java.SmartSemicolonAutoEditStrategy;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
/**
* SmartSemicolonAutoEditStrategyTest
* @since 3.0
*/
-public class SmartSemicolonAutoEditStrategyTest extends TestCase {
-
+public class SmartSemicolonAutoEditStrategyTest {
private static final boolean BUG_EXISTING_CHARACTERS_HANDLED_BY_FRAMEWORK= true;
private static final boolean BUG_UNWANTED_FUNCTIONALITY= true;
@@ -56,10 +53,6 @@ public class SmartSemicolonAutoEditStrategyTest extends TestCase {
}
}
- public static Test suite() {
- return new TestSuite(SmartSemicolonAutoEditStrategyTest.class);
- }
-
private FastPartitioner fPartitioner;
private static final char SEMI= ';';
@@ -86,7 +79,7 @@ public class SmartSemicolonAutoEditStrategyTest extends TestCase {
IRegion region= fDocument.getLineInformation(0);
ITextSelection selection= new TextSelection(fDocument, region.getOffset(), region.getLength());
int pos= SmartSemicolon.computeCharacterPosition(fDocument, selection, caret, SEMI, IJavaPartitions.JAVA_PARTITIONING);
- Assert.assertEquals(expected, pos);
+ assertEquals(expected, pos);
}
private void verifyBracePosition(int caret, int expected) throws BadLocationException {
@@ -94,16 +87,18 @@ public class SmartSemicolonAutoEditStrategyTest extends TestCase {
ITextSelection selection= new TextSelection(fDocument, region.getOffset(), region.getLength());
int pos= SmartSemicolon.computeCharacterPosition(fDocument, selection, caret, BRACE, IJavaPartitions.JAVA_PARTITIONING);
if (pos == -1) pos= caret;
- Assert.assertEquals(expected, pos);
+ assertEquals(expected, pos);
}
/* semicolon tests */
+ @Test
public void testGoToEOL() throws BadLocationException {
fDocument.set("public void foobar()");
verifySemicolonPosition(5, 20);
}
+ @Test
public void testGoToExisting() throws BadLocationException {
if (BUG_UNWANTED_FUNCTIONALITY) {
System.out.println("testGoToExisting disabled - unwanted functionality");
@@ -113,21 +108,25 @@ public class SmartSemicolonAutoEditStrategyTest extends TestCase {
verifySemicolonPosition(5, 11);
}
+ @Test
public void testFor() throws BadLocationException {
fDocument.set("for (int i= 0)");
verifySemicolonPosition(13, -1);
}
+ @Test
public void testWithExistingBefore() throws BadLocationException {
fDocument.set("public void; foobar()");
verifySemicolonPosition(12, 21);
}
+ @Test
public void testWithExistingBeforeWithComment() throws BadLocationException {
fDocument.set("public void; foobar() // comment\r\n ");
verifySemicolonPosition(12, 21);
}
+ @Test
public void testWithExistingAtInsertPosition() throws BadLocationException {
if (BUG_EXISTING_CHARACTERS_HANDLED_BY_FRAMEWORK) {
System.out.println("testWithExistingAtInsertPosition disabled - existing characters handled by framework");
@@ -137,46 +136,55 @@ public class SmartSemicolonAutoEditStrategyTest extends TestCase {
verifySemicolonPosition(12, 12);
}
+ @Test
public void testEndLineComment() throws BadLocationException {
fDocument.set("private string foo= \"foobar\" // comment\r\n");
verifySemicolonPosition(12, 28);
}
+ @Test
public void testFakeEndLineComment() throws BadLocationException {
fDocument.set("private string foo= \"foobar\" /* comment */ \r\n");
verifySemicolonPosition(12, 28);
}
+ @Test
public void testBlockComment() throws BadLocationException {
fDocument.set("doStuff(arg1 /* comment */, args) ");
verifySemicolonPosition(5, 33);
}
+ @Test
public void testMultiLineComment() throws BadLocationException {
fDocument.set("private string foo= \"foobar\" /* comment1 \r\n comment2 */");
verifySemicolonPosition(12, 28);
}
+ @Test
public void testEndLineCommentWithFor() throws BadLocationException {
fDocument.set("for (int i= 0; i < 2; i++) // comment");
verifySemicolonPosition(13, -1);
}
+ @Test
public void testFakeEndLineCommentWithFor() throws BadLocationException {
fDocument.set("for (int i= 0; i < 2; i++) /* comment */ ");
verifySemicolonPosition(13, -1);
}
+ @Test
public void testMultiLineCommentWithFor() throws BadLocationException {
fDocument.set("for (int i= 0; i < 2; i++) /* comment\r\n comment2 */ ");
verifySemicolonPosition(13, -1);
}
+ @Test
public void testSemicolonInEmptyMethodBody() throws BadLocationException {
fDocument.set("void foobar(int param) {}");
verifySemicolonPosition(24, 24);
}
+ @Test
public void testSemicolonInString() throws BadLocationException {
fDocument.set(" new Thread(\"\")");
verifySemicolonPosition(14, -1);
@@ -184,81 +192,96 @@ public class SmartSemicolonAutoEditStrategyTest extends TestCase {
/* brace tests */
+ @Test
public void testBraceClassDef() throws BadLocationException {
fDocument.set("public static final class Main ");
verifyBracePosition(31, 31);
}
+ @Test
public void testBraceMethodDef() throws BadLocationException {
fDocument.set("void bla(int p1, int p2) // comment");
verifyBracePosition(8, 24);
}
+ @Test
public void testBraceMethodDef2() throws BadLocationException {
fDocument.set("void bla(int p1, int p2) // comment");
verifyBracePosition(12, 24);
}
+ @Test
public void testBraceIf() throws BadLocationException {
fDocument.set("if (condition && condition()) // comment");
verifyBracePosition(12, 29);
}
+ @Test
public void testBraceIf2() throws BadLocationException {
fDocument.set("if (value == expected) // comment");
verifyBracePosition(12, 22);
}
+ @Test
public void testBraceMethodCall() throws BadLocationException {
fDocument.set("call(param1, param2) // comment");
verifyBracePosition(12, 12);
}
+ @Test
public void testBraceElse() throws BadLocationException {
fDocument.set(" } else somecode();");
verifyBracePosition(4, 7);
}
+ @Test
public void testBraceArray() throws BadLocationException {
fDocument.set("int[] arr= bla, bli, blu;");
verifyBracePosition(10, 10);
verifyBracePosition(11, 11);
}
+ @Test
public void testBraceArray2() throws BadLocationException {
fDocument.set("arr= bla, bli, blu;");
verifyBracePosition(4, 4);
verifyBracePosition(5, 5);
}
+ @Test
public void testBraceAnonymousClassDef() throws BadLocationException {
fDocument.set("this.addListener(blu, new Listener(), bla)");
verifyBracePosition(34, 36);
}
+ @Test
public void testBraceAnonymousClassDef2() throws BadLocationException {
fDocument.set("this.addListener(blu, \"new\", Listener(), bla)");
verifyBracePosition(41, 41);
}
+ @Test
public void testBraceIfAnonymousClassDef() throws BadLocationException {
fDocument.set(" if addListener(blu, new Listener(), bla)");
verifyBracePosition(34, 36);
verifyBracePosition(37, 42);
}
+ @Test
public void testBraceIfAnonymousClassDef2() throws BadLocationException {
fDocument.set(" if addListener(blu, \"new\", Listener(), bla)");
verifyBracePosition(20, 45);
verifyBracePosition(39, 45);
}
+ @Test
public void testBraceAnonymousClassInstantiation() throws BadLocationException {
fDocument.set(" Object object=new Object();");
verifyBracePosition(27, 28);
verifyBracePosition(28, 28);
}
+ @Test
public void testBraceLambdaBlock() throws BadLocationException {
fDocument.set(" new Thread(() -> );");
verifyBracePosition(18, 18);
@@ -266,14 +289,15 @@ public class SmartSemicolonAutoEditStrategyTest extends TestCase {
verifyBracePosition(20, 20);
}
+ @Test
public void testBraceInString() throws BadLocationException {
fDocument.set(" new Thread(\"\")");
verifyBracePosition(14, 14);
}
+ @Test
public void testBraceInString2() throws BadLocationException {
fDocument.set(" System.out.write(\"((?\\\"{\\\\\\\"\\\\\\\":\\\"+()+\\\",\\\":\\\"ss\\\").());try {\");");
verifyBracePosition(50, 50);
}
-
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/codemining/CodeMiningTriggerTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/codemining/CodeMiningTriggerTest.java
index e73120a567..513a88427e 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/codemining/CodeMiningTriggerTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/codemining/CodeMiningTriggerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2018 Pivotal, Inc.
+ * Copyright (c) 2018, 2020 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.codemining;
+import static org.junit.Assert.assertTrue;
+
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -20,6 +22,7 @@ import java.util.concurrent.CompletableFuture;
import org.junit.After;
import org.junit.Before;
+import org.junit.Test;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.text.tests.performance.DisplayHelper;
@@ -59,17 +62,8 @@ import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
@SuppressWarnings("unchecked")
-public class CodeMiningTriggerTest extends TestCase {
-
- public static Test suite() {
- return new TestSuite(CodeMiningTriggerTest.class);
- }
-
+public class CodeMiningTriggerTest {
private IPreferenceStore fPreferenceStore;
private boolean wasCodeMiningEnabled;
@@ -115,7 +109,6 @@ public class CodeMiningTriggerTest extends TestCase {
}
}
- @Override
@Before
public void setUp() throws CoreException {
fPreferenceStore= JavaPlugin.getDefault().getPreferenceStore();
@@ -129,13 +122,13 @@ public class CodeMiningTriggerTest extends TestCase {
TestCodeMiningProvider.isOn = true;
}
- @Override
@After
public void tearDown() {
TestCodeMiningProvider.isOn = false;
this.fPreferenceStore.setValue(PreferenceConstants.EDITOR_CODEMINING_ENABLED, wasCodeMiningEnabled);
}
+ @Test
public void testPullCodeMining() throws Exception {
String contents= "public class Foo {\n" +
" int ab, ba;\n" +
@@ -199,5 +192,4 @@ public class CodeMiningTriggerTest extends TestCase {
}
}.waitForCondition(Display.getDefault(), timeout));
}
-
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/codemining/ParameterNamesCodeMiningTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/codemining/ParameterNamesCodeMiningTest.java
index ad8285fbbc..67d0664d60 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/codemining/ParameterNamesCodeMiningTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/codemining/ParameterNamesCodeMiningTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019 Red Hat Inc. and others.
+ * Copyright (c) 2019, 2020 Red Hat Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,14 +13,18 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.codemining;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.LongSupplier;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
+import org.junit.Test;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
@@ -61,25 +65,14 @@ import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer;
import org.eclipse.jdt.internal.ui.javaeditor.codemining.JavaMethodParameterCodeMiningProvider;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class ParameterNamesCodeMiningTest extends TestCase {
-
+public class ParameterNamesCodeMiningTest {
private IJavaProject fProject;
private IPackageFragment fPackage;
private JavaMethodParameterCodeMiningProvider fParameterNameCodeMiningProvider;
private boolean wasCodeMiningEnabled;
- public static Test suite() {
- return new TestSuite(ParameterNamesCodeMiningTest.class);
- }
-
- @Override
@Before
- protected void setUp() throws Exception {
- super.setUp();
+ public void setUp() throws Exception {
if(!welcomeClosed) {
closeIntro(PlatformUI.getWorkbench());
}
@@ -92,10 +85,8 @@ public class ParameterNamesCodeMiningTest extends TestCase {
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.EDITOR_CODEMINING_ENABLED, true);
}
- @Override
@After
- protected void tearDown() throws Exception {
- super.tearDown();
+ public void tearDown() throws Exception {
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.EDITOR_CODEMINING_ENABLED, wasCodeMiningEnabled);
IWorkbenchPage workbenchPage= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
for (IEditorReference ref : workbenchPage.getEditorReferences()) {
@@ -112,6 +103,7 @@ public class ParameterNamesCodeMiningTest extends TestCase {
}.waitForCondition(viewer.getTextWidget().getDisplay(), 2000));
}
+ @Test
public void testParameterNamesOK() throws Exception {
String contents= "public class Foo {\n" +
" int n= Math.max(1, 2);\n" +
@@ -125,6 +117,7 @@ public class ParameterNamesCodeMiningTest extends TestCase {
assertEquals(2, fParameterNameCodeMiningProvider.provideCodeMinings(viewer, new NullProgressMonitor()).get().size());
}
+ @Test
public void testVarargs() throws Exception {
String contents= "public class Foo {\n" +
" String s= String.format(\"%d %d\", 1, 2);\n" +
@@ -137,6 +130,7 @@ public class ParameterNamesCodeMiningTest extends TestCase {
assertEquals(2, fParameterNameCodeMiningProvider.provideCodeMinings(viewer, new NullProgressMonitor()).get().size());
}
+ @Test
public void testMultiLines() throws Exception {
String contents =
"class Foo {\n" +
@@ -167,6 +161,7 @@ public class ParameterNamesCodeMiningTest extends TestCase {
assertEquals(2, drawnCodeMiningsCount.getAsLong());
}
+ @Test
public void testUnresolvedMethodBinding() throws Exception {
String contents= "public class Foo {\n" +
" public void mehod() {\n" +
@@ -183,6 +178,7 @@ public class ParameterNamesCodeMiningTest extends TestCase {
assertEquals(2, fParameterNameCodeMiningProvider.provideCodeMinings(viewer, new NullProgressMonitor()).get().size());
}
+ @Test
public void testCollapsedFolding() throws Exception {
String contents= "/**\n" +
" * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" +
@@ -217,12 +213,13 @@ public class ParameterNamesCodeMiningTest extends TestCase {
try {
log.addLogListener(logListener);
DisplayHelper.sleep(editor.getViewer().getTextWidget().getDisplay(), 1000);
- Assert.assertNull(errorInLog.get());
+ assertNull(errorInLog.get());
} finally {
log.removeLogListener(logListener);
}
}
+ @Test
public void testCollapsedFoldingAndToggleHighlight() throws Exception {
String contents= "/**\n" +
" *\n" +
@@ -291,6 +288,7 @@ public class ParameterNamesCodeMiningTest extends TestCase {
}
}
+ @Test
public void testBug547232() throws Exception {
String contents= "public class Test {\n" +
" public final Object object;\n" +
@@ -315,6 +313,7 @@ public class ParameterNamesCodeMiningTest extends TestCase {
assertEquals(2, fParameterNameCodeMiningProvider.provideCodeMinings(viewer, new NullProgressMonitor()).get().size());
}
+ @Test
public void testBug549023() throws Exception {
String contents= "class Base {\n" +
" public final Object object;\n" +
@@ -341,6 +340,7 @@ public class ParameterNamesCodeMiningTest extends TestCase {
assertEquals(2, fParameterNameCodeMiningProvider.provideCodeMinings(viewer, new NullProgressMonitor()).get().size());
}
+ @Test
public void testBug549126() throws Exception {
String contents= "public enum TestEnum {\n" +
" A(\"bla\", null);\n" +
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/AbstractCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/AbstractCompletionTest.java
index 3227efe726..589edd950f 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/AbstractCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/AbstractCompletionTest.java
@@ -13,9 +13,19 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
import java.lang.reflect.Field;
import java.util.Hashtable;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.TestOptions;
import org.eclipse.jdt.text.tests.performance.EditorTestHelper;
@@ -23,6 +33,7 @@ import org.eclipse.jdt.text.tests.performance.EditorTestHelper;
import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.core.runtime.CoreException;
@@ -45,6 +56,7 @@ import org.eclipse.jface.text.contentassist.ICompletionProposalExtension;
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.tests.util.DisplayHelper;
import org.eclipse.ui.texteditor.ITextEditor;
@@ -67,9 +79,7 @@ import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor;
import org.eclipse.jdt.internal.ui.text.java.JavaCompletionProcessor;
-import junit.framework.TestCase;
-
-public class AbstractCompletionTest extends TestCase {
+public class AbstractCompletionTest {
protected static String suiteName(Class<?> fqn) {
String name= fqn.toString();
name= name.substring(name.lastIndexOf('.') + 1);
@@ -88,8 +98,8 @@ public class AbstractCompletionTest extends TestCase {
private char fTrigger;
private boolean fWaitBeforeCompleting;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
Hashtable<String, String> options= TestOptions.getDefaultOptions();
configureCoreOptions(options);
JavaCore.setOptions(options);
@@ -147,8 +157,8 @@ public class AbstractCompletionTest extends TestCase {
return cu;
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
IPreferenceStore store= getJDTUIPrefs();
store.setToDefault(PreferenceConstants.CODEGEN_ADD_COMMENTS);
store.setToDefault(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS);
@@ -367,6 +377,7 @@ public class AbstractCompletionTest extends TestCase {
e.doit= true;
verifyKeyListeners.verifyKey(e);
+ DisplayHelper.driveEventQueue(Display.getCurrent());
if (!e.doit)
continue;
@@ -528,6 +539,13 @@ public class AbstractCompletionTest extends TestCase {
return new Region(firstPipe + prefix.length(), secondPipe - firstPipe);
}
+ @Rule
+ public TestName tn= new TestName();
+
+ protected String getName() {
+ return tn.getMethodName();
+ }
+
private ICompletionProposal findNonNullProposal(String prefix, IRegion selection) {
ICompletionProposal proposal= findNamedProposal(prefix, selection);
assertNotNull("no proposal starting with \"" + prefix + "\"", proposal);
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CamelCaseCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CamelCaseCompletionTest.java
index 4c1f5a68c2..12f6c7956e 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CamelCaseCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CamelCaseCompletionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2013 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,8 +15,8 @@ package org.eclipse.jdt.text.tests.contentassist;
import java.util.Hashtable;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.core.JavaCore;
@@ -25,15 +25,8 @@ import org.eclipse.jdt.core.JavaCore;
* @since 3.2
*/
public class CamelCaseCompletionTest extends AbstractCompletionTest {
- private static final Class<CamelCaseCompletionTest> THIS= CamelCaseCompletionTest.class;
-
- public static Test setUpTest(Test test) {
- return new CompletionTestSetup(test);
- }
-
- public static Test suite() {
- return setUpTest(new TestSuite(THIS, suiteName(THIS)));
- }
+ @Rule
+ public CompletionTestSetup cts= new CompletionTestSetup();
/*
* @see org.eclipse.jdt.text.tests.contentassist.AbstractCompletionTest#configureCoreOptions(java.util.Hashtable)
@@ -44,19 +37,21 @@ public class CamelCaseCompletionTest extends AbstractCompletionTest {
options.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
}
+ @Test
public void testMethod() throws Exception {
addMembers("void methodCallWithParams(int par) {}");
assertMethodBodyProposal("this.mCW|", "methodCallWith", "this.methodCallWithParams(|);");
}
+ @Test
public void testMethodWithTrailing() throws Exception {
addMembers("void methodCallWithParams(int par) {}");
assertMethodBodyProposal("this.mCWith|", "methodCallWith", "this.methodCallWithParams(|);");
}
+ @Test
public void testField() throws Exception {
addMembers("int multiCamelCaseField;");
assertMethodBodyProposal("this.mCC|", "multiCamel", "this.multiCamelCaseField|");
}
-
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ChainCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ChainCompletionTest.java
index 23cc722780..227384b3a7 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ChainCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ChainCompletionTest.java
@@ -12,17 +12,28 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.Arrays;
import java.util.List;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.swt.SWT;
import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.TextViewer;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
import org.eclipse.ui.IEditorPart;
@@ -32,47 +43,36 @@ import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.ui.tests.core.ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.text.java.ChainCompletionProposalComputer;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class ChainCompletionTest extends TestCase {
-
- private static final Class<ChainCompletionTest> THIS= ChainCompletionTest.class;
-
+public class ChainCompletionTest {
private IJavaProject fJProject;
private IPackageFragmentRoot javaSrc;
private IPackageFragment pkg;
- public static Test suite() {
- return setUpTest(new TestSuite(THIS));
- }
-
- public static Test setUpTest(Test test) {
- return new ProjectTestSetup(test);
- }
+ @Rule
+ public ProjectTestSetup pts= new ProjectTestSetup();
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
fJProject= JavaProjectHelper.createJavaProject("TestProject", "bin");
JavaProjectHelper.addRTJar18(fJProject);
javaSrc= JavaProjectHelper.addSourceContainer(fJProject, "src");
pkg= javaSrc.createPackageFragment("test", false, null);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
JavaProjectHelper.delete(fJProject);
}
+ @Test
public void testNullExpectedType() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("$package test;\n" +
@@ -87,6 +87,7 @@ public class ChainCompletionTest extends TestCase {
assertEquals(0, proposals.size());
}
+ @Test
public void testBasic() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -120,6 +121,7 @@ public class ChainCompletionTest extends TestCase {
assertEquals("getBar().getBaz() - 2 elements", proposals.get(0).getDisplayString());
}
+ @Test
public void testPrimitiveCompletion() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -135,7 +137,7 @@ public class ChainCompletionTest extends TestCase {
List<ICompletionProposal> proposals= computeCompletionProposals(cu, completionIndex);
- assertTrue(!proposals.isEmpty());
+ assertFalse(proposals.isEmpty());
List<String> expected= Arrays.asList(
"s.length() - 2 elements",
"s.hashCode() - 2 elements",
@@ -145,6 +147,7 @@ public class ChainCompletionTest extends TestCase {
assertProposalsExist(expected, proposals);
}
+ @Test
public void testAccessMethodParameters() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -173,6 +176,7 @@ public class ChainCompletionTest extends TestCase {
assertProposalsExist(expected, proposals);
}
+ @Test
public void testAvoidRecursiveCallToMember() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -199,6 +203,7 @@ public class ChainCompletionTest extends TestCase {
assertEquals("getSubElement().findMe - 2 elements", proposals.get(0).getDisplayString());
}
+ @Test
public void testCompletionOnArrayMemberAccessInMethod1() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -225,6 +230,7 @@ public class ChainCompletionTest extends TestCase {
assertProposalsExist(expected, proposals);
}
+ @Test
public void testCompletionOnArrayWithCastsSupertype1() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -251,6 +257,7 @@ public class ChainCompletionTest extends TestCase {
assertEquals("obj.findme[][][] - 2 elements", proposals.get(0).getDisplayString());
}
+ @Test
public void testCompletionOnGenericTypeInMethod1() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -276,6 +283,7 @@ public class ChainCompletionTest extends TestCase {
assertEquals("variable.findMe - 2 elements", proposals.get(0).getDisplayString());
}
+ @Test
public void testCompletionOnMemberCallChainDepth1() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -308,6 +316,7 @@ public class ChainCompletionTest extends TestCase {
assertProposalsExist(expected, proposals);
}
+ @Test
public void testCompletionOnMemberInMethodWithPrefix() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -337,6 +346,7 @@ public class ChainCompletionTest extends TestCase {
assertEquals("getSubElement().findMe - 2 elements", proposals.get(0).getDisplayString());
}
+ @Test
public void testCompletionOnMethodReturn() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -371,6 +381,7 @@ public class ChainCompletionTest extends TestCase {
assertProposalsExist(expected, proposals);
}
+ @Test
public void testCompletionOnNonPublicMemberInMethod1() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -395,6 +406,7 @@ public class ChainCompletionTest extends TestCase {
assertProposalsExist(expected, proposals);
}
+ @Test
public void testCompletionOnSuperTypeInMethod1() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -420,6 +432,7 @@ public class ChainCompletionTest extends TestCase {
assertEquals("useMe.findMe - 2 elements", proposals.get(0).getDisplayString());
}
+ @Test
public void testCompletionOnSuperTypeMemberInMethod1() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -446,6 +459,7 @@ public class ChainCompletionTest extends TestCase {
assertProposalsExist(expected, proposals);
}
+ @Test
public void testCompletionOnSuperTypeMemberInMethod2() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -474,6 +488,7 @@ public class ChainCompletionTest extends TestCase {
assertProposalsExist(expected, proposals);
}
+ @Test
public void testCompletionOnThisAndLocal() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("import java.util.Collection;\n" +
@@ -502,6 +517,7 @@ public class ChainCompletionTest extends TestCase {
assertProposalsExist(expected, proposals);
}
+ @Test
public void testCompletionOnType() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -535,6 +551,7 @@ public class ChainCompletionTest extends TestCase {
assertProposalsExist(expected, proposals);
}
+ @Test
public void testBug552849 () throws Exception {
IPackageFragment pkg2= javaSrc.createPackageFragment("test2", false, null);
IPackageFragment pkg3= javaSrc.createPackageFragment("test3", false, null);
@@ -581,6 +598,7 @@ public class ChainCompletionTest extends TestCase {
assertProposalsExist(expected, proposals);
}
+ @Test
public void testBug559385 () throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -606,6 +624,47 @@ public class ChainCompletionTest extends TestCase {
assertTrue(proposals.size() > 0);
}
+ @Test
+ public void testNoTriggerCompletionInvocation() throws Exception {
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test;\n" +
+ "\n" +
+ "import java.util.Iterator;\n" +
+ "import java.util.List;\n" +
+ "\n" +
+ "public class NoTriggerCompletionInvocation {\n" +
+ " public void method(){\n" +
+ " List longVariableName, longVariableName2;\n" +
+ " Iterator it = longVariableName$\n" +
+ " String foo = null;\n" +
+ " }\n" +
+ "}");
+
+ int completionIndex= getCompletionIndex(buf);
+ ICompilationUnit cu= getCompilationUnit(pkg, buf, "NoTriggerCompletionInvocation.java");
+
+ List<ICompletionProposal> proposals= computeCompletionProposals(cu, completionIndex);
+ String expectedProposal= "longVariableName.iterator() - 2 elements";
+ assertProposalsExist(Arrays.asList(expectedProposal), proposals);
+
+ ICompletionProposal proposal= proposals.stream().filter(p -> p.getDisplayString().equals(expectedProposal)).findFirst().get();
+ IDocument doc= new Document(buf.toString().replace("$", ""));
+ applyProposal(proposal, doc, cu, completionIndex);
+ String expectedContent = "package test;\n" +
+ "\n" +
+ "import java.util.Iterator;\n" +
+ "import java.util.List;\n" +
+ "\n" +
+ "public class NoTriggerCompletionInvocation {\n" +
+ " public void method(){\n" +
+ " List longVariableName, longVariableName2;\n" +
+ " Iterator it = longVariableName.iterator()\n" +
+ " String foo = null;\n" +
+ " }\n" +
+ "}";
+ assertEquals(expectedContent,doc.get());
+ }
+
private ICompilationUnit getCompilationUnit(IPackageFragment pack, StringBuffer buf, String name) throws JavaModelException {
return pack.createCompilationUnit(name, buf.toString().replace("$", ""), false, null);
}
@@ -625,10 +684,18 @@ public class ChainCompletionTest extends TestCase {
return comp.computeCompletionProposals(ctx, null);
}
+ private void applyProposal (ICompletionProposal prop, IDocument doc, ICompilationUnit cu, int completionIndex) throws Exception {
+ IEditorPart editor= EditorUtility.openInEditor(cu);
+ ITextViewer viewer= new TextViewer(editor.getSite().getShell(), SWT.NONE);
+ viewer.setDocument(doc);
+ if (prop instanceof ICompletionProposalExtension2) {
+ ((ICompletionProposalExtension2)prop).apply(viewer, '\0', 0, completionIndex);
+ }
+ }
+
private void assertProposalsExist(List<String> expected, List<ICompletionProposal> proposals) {
for (String propDisplay : expected) {
assertTrue(proposals.stream().anyMatch(p -> propDisplay.equals(p.getDisplayString())));
}
}
-
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CodeCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CodeCompletionTest.java
index 2facfdf80f..28a7b2ae14 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CodeCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CodeCompletionTest.java
@@ -14,6 +14,12 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
@@ -26,10 +32,13 @@ import java.util.Hashtable;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.NullTestUtils;
import org.eclipse.jdt.testplugin.TestOptions;
-import org.eclipse.test.OrderedTestSuite;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
@@ -88,36 +97,13 @@ import org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer;
import org.eclipse.jdt.internal.ui.text.java.JavaNoTypeCompletionProposalComputer;
import org.eclipse.jdt.internal.ui.text.java.JavaTypeCompletionProposalComputer;
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-
-
+//predictable order for https://bugs.eclipse.org/bugs/show_bug.cgi?id=423416
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class CodeCompletionTest extends AbstractCompletionTest {
-
private final static boolean BUG_80782= true;
- private static final Class<CodeCompletionTest> THIS= CodeCompletionTest.class;
-
- public static Test suite() {
- OrderedTestSuite suite= new OrderedTestSuite(THIS); //predictable order for https://bugs.eclipse.org/bugs/show_bug.cgi?id=423416
- return new TestSetup(suite) {
- @Override
- protected void setUp() throws Exception {
- JavaProjectHelper.PERFORM_DUMMY_SEARCH++;
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- JavaProjectHelper.PERFORM_DUMMY_SEARCH--;
- }
- };
- }
-
private IJavaProject fJProject1;
-
private void assertAppliedProposal(String contents, IJavaCompletionProposal proposal, String completion) {
IDocument doc= new Document(contents);
proposal.apply(doc);
@@ -169,7 +155,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
}
@Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
JavaProjectHelper.addRTJar(fJProject1);
@@ -197,7 +183,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
}
@Override
- protected void tearDown() throws Exception {
+ public void tearDown() throws Exception {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setToDefault(PreferenceConstants.CODEGEN_ADD_COMMENTS);
store.setToDefault(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS);
@@ -224,6 +210,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
}
}
+ @Test
public void testAnonymousTypeCompletion1() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -273,6 +260,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testAnonymousTypeCompletion2() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -322,6 +310,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testAnonymousTypeCompletion3() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -376,6 +365,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testAnonymousTypeCompletion4() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -431,6 +421,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testAnonymousTypeCompletion5() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -487,6 +478,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testAnonymousTypeCompletion6() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -538,6 +530,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
// same CU
// @NonNullByDefault on class
// -> don't insert redundant @NonNull
+ @Test
public void testAnonymousTypeCompletion7() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
NullTestUtils.prepareNullDeclarationAnnotations(sourceFolder);
@@ -590,6 +583,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
// @NonNullByDefault on method
// anonymous class is argument in a method invocation.
// -> don't insert redundant @NonNull
+ @Test
public void testAnonymousTypeCompletion8() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
NullTestUtils.prepareNullDeclarationAnnotations(sourceFolder);
@@ -651,6 +645,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
// not same CU
// @NonNullByDefault on field
// -> don't insert redundant @NonNull
+ @Test
public void testAnonymousTypeCompletion9() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
NullTestUtils.prepareNullDeclarationAnnotations(sourceFolder);
@@ -708,6 +703,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
// not same CU
// @NonNullByDefault on class, completion in instance initializer
// -> don't insert redundant @NonNull
+ @Test
public void testAnonymousTypeCompletion10() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
NullTestUtils.prepareNullDeclarationAnnotations(sourceFolder);
@@ -764,6 +760,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(expected, doc.get());
}
+ @Test
public void testAnonymousTypeCompletionBug280801() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -812,6 +809,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals("", buf.toString(), doc.get());
}
+ @Test
public void testAnonymousTypeCompletionBug324391() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -860,6 +858,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals("", buf.toString(), doc.get());
}
+ @Test
public void testAnonymousTypeCompletionBug326377() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -908,6 +907,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals("", buf.toString(), doc.get());
}
+ @Test
public void testAnonymousTypeCompletionBug526615() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -965,6 +965,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testConstructorCompletion() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1026,6 +1027,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
}
}
+ @Test
public void testEnumCompletions() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1097,6 +1099,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
return new JavaContentAssistInvocationContext(viewer, offset, editor);
}
+ @Test
public void testGetterCompletion1() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1157,6 +1160,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
}
}
+ @Test
public void testMethodCompletion() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1218,6 +1222,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
}
}
+ @Test
public void testNormalAllMethodCompletion() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1264,6 +1269,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertAppliedProposal(contents, proposals[i++], "wait();");
}
+ @Test
public void testNormalAllMethodCompletionWithParametersGuessed() throws Exception {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setValue(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, true);
@@ -1317,6 +1323,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(i, proposals.length);
}
+ @Test
public void testNormalAllMethodCompletionWithParametersNames() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1367,6 +1374,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(i, proposals.length);
}
+ @Test
public void testNormalMethodCompletion() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1414,6 +1422,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(result, doc.get());
}
+ @Test
public void testOverrideCompletion1() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1475,6 +1484,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverrideCompletion2() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1537,6 +1547,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverrideCompletion3() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1599,6 +1610,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverrideCompletion4() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1669,6 +1681,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverrideCompletion5() throws Exception {
if (BUG_80782) {
return;
@@ -1733,6 +1746,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverrideCompletion6_bug157069() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1796,6 +1810,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverrideCompletion7_bug355926() throws Exception {
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=355926
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1862,6 +1877,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverrideCompletion8_bug355926() throws Exception {
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=355926
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1928,6 +1944,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverrideCompletion9_bug355926() throws Exception {
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=355926
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -1998,6 +2015,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverrideCompletion10_bug377184() throws Exception {
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=377184
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -2055,6 +2073,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverrideCompletionArrayOfTypeVariable() throws Exception {
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=391265
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -2112,6 +2131,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testSetterCompletion1() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -2172,6 +2192,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
}
}
+ @Test
public void testStaticImports1() throws Exception {
IPreferenceStore store= PreferenceConstants.getPreferenceStore();
store.setValue(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, "test1.A.foo");
@@ -2244,6 +2265,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
}
}
+ @Test
public void testStaticImports2() throws Exception {
IPreferenceStore store= PreferenceConstants.getPreferenceStore();
store.setValue(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, "test1.A.foo");
@@ -2326,6 +2348,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
/*
* Ensure no extra ';' is inserted
*/
+ @Test
public void testImport() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -2366,6 +2389,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
/*
* Ensure no extra ';' is inserted, whereas a selected text part is correctly replaced
*/
+ @Test
public void testImportReplacingSelection() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -2406,6 +2430,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
/*
* Ensure no extra ';' is inserted, whereas remain text is replaced as per the preference option
*/
+ @Test
public void testImportReplacing() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, false);
@@ -2444,6 +2469,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testConstructorCompletion_Bug336451() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -2528,6 +2554,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testBug466252() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("p", false, null);
@@ -2548,7 +2575,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
TemplateStore templateStore= JavaPlugin.getDefault().getTemplateStore();
int tokenLocation= createContext(offset, cu).getCoreContext().getTokenLocation();
- assertTrue((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0);
+ assertNotEquals(0, tokenLocation & CompletionContext.TL_STATEMENT_START);
Template[] templates= templateStore.getTemplates(JavaContextType.ID_STATEMENTS);
@@ -2562,6 +2589,7 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertTrue(finallyTemplateFound);
}
+ @Test
public void testCompletionInPackageInfo() throws Exception {
IPreferenceStore store= PreferenceConstants.getPreferenceStore();
store.setValue(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, "annots.DefaultLocation.*");
@@ -2633,10 +2661,10 @@ public class CodeCompletionTest extends AbstractCompletionTest {
}
private static void assertNumberOf(String name, int is, int expected) {
- assertTrue("Wrong number of " + name + ", is: " + is + ", expected: " + expected, is == expected);
+ assertEquals("Wrong number of " + name + ", is: " + is + ", expected: " + expected, expected, is);
}
- @org.junit.Test
+ @Test
public void testComputeCompletionInNonUIThread() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("test1", false, null);
@@ -2668,5 +2696,4 @@ public class CodeCompletionTest extends AbstractCompletionTest {
assertNull(exception.get());
assertEquals(Collections.emptyList(), errors);
}
-
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CodeCompletionTest18.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CodeCompletionTest1d8.java
index 0581d54418..b572cdec88 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CodeCompletionTest18.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CodeCompletionTest1d8.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014, 2018 GK Software AG, IBM Corporation and others.
+ * Copyright (c) 2014, 2020 GK Software AG, IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,8 +14,15 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
import java.util.Hashtable;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.NullTestUtils;
import org.eclipse.jdt.testplugin.TestOptions;
@@ -51,7 +58,7 @@ import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.PreferenceConstants;
-import org.eclipse.jdt.ui.tests.core.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.CompletionProposalCollector;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext;
@@ -59,27 +66,18 @@ import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class CodeCompletionTest18 extends AbstractCompletionTest {
-
- private static final Class<CodeCompletionTest18> THIS= CodeCompletionTest18.class;
-
- public static Test suite() {
- return new Java18ProjectTestSetup(new TestSuite(THIS));
- }
-
- public static Test setUpTest(Test test) {
- return new Java18ProjectTestSetup(test);
- }
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
+public class CodeCompletionTest1d8 extends AbstractCompletionTest {
+ @Rule
+ public Java1d8ProjectTestSetup j18s= new Java1d8ProjectTestSetup();
private IJavaProject fJProject1;
-
@Override
- protected void setUp() throws Exception {
- fJProject1= Java18ProjectTestSetup.getProject();
+ public void setUp() throws Exception {
+ fJProject1= Java1d8ProjectTestSetup.getProject();
Hashtable<String, String> options= TestOptions.getDefaultOptions();
options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1");
@@ -104,13 +102,13 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
}
@Override
- protected void tearDown() throws Exception {
+ public void tearDown() throws Exception {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setToDefault(PreferenceConstants.CODEGEN_ADD_COMMENTS);
store.setToDefault(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS);
store.setToDefault(PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS);
closeAllEditors();
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
public static void closeEditor(IEditorPart editor) {
@@ -146,6 +144,7 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
cu.codeComplete(offset, collector, new NullProgressMonitor());
}
+ @Test
public void testBug425183_comment8() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -193,6 +192,7 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
assertEquals(expectedContents, doc.get());
}
+ @Test
public void testOverride1() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("test1", false, null);
@@ -245,6 +245,7 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverride2() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("test1", false, null);
@@ -297,6 +298,7 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverride3() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("test1", false, null);
@@ -345,6 +347,7 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverride4() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("test1", false, null);
@@ -386,6 +389,7 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverride5() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("test1", false, null);
@@ -423,6 +427,7 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverride6() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("test1", false, null);
@@ -460,6 +465,7 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverride7() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("test1", false, null);
@@ -497,6 +503,7 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverride8() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("test1", false, null);
@@ -533,6 +540,7 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverride9() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("test1", false, null);
@@ -569,6 +577,7 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverride10() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("test1", false, null);
@@ -617,6 +626,7 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverride11() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("pp", false, null);
@@ -665,6 +675,7 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverride12() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("pp", false, null);
@@ -713,6 +724,7 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
+ @Test
public void testOverride13() throws CoreException {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack1= sourceFolder.createPackageFragment("pp", false, null);
@@ -769,9 +781,10 @@ public class CodeCompletionTest18 extends AbstractCompletionTest {
assertEquals(buf.toString(), doc.get());
}
private static void assertNumberOf(String name, int is, int expected) {
- assertTrue("Wrong number of " + name + ", is: " + is + ", expected: " + expected, is == expected);
+ assertEquals("Wrong number of " + name + ", is: " + is + ", expected: " + expected, expected, is);
}
+ @Test
public void testBug528871() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
NullTestUtils.prepareNullTypeAnnotations(sourceFolder);
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CompletionTestSetup.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CompletionTestSetup.java
index 6061f86b17..588cffa861 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CompletionTestSetup.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CompletionTestSetup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,6 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
-import junit.framework.Test;
-
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.core.runtime.CoreException;
@@ -23,10 +21,9 @@ import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.ui.tests.core.ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
class CompletionTestSetup extends ProjectTestSetup {
-
public static IPackageFragment getTestPackage() throws CoreException {
IJavaProject project= getProject();
IPackageFragmentRoot root= project.getPackageFragmentRoot("src");
@@ -54,8 +51,4 @@ class CompletionTestSetup extends ProjectTestSetup {
return fragment;
}
-
- public CompletionTestSetup(Test test) {
- super(test);
- }
-} \ No newline at end of file
+}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistAndThreadsTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistAndThreadsTest.java
index 2fc1067f73..1e11ea3955 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistAndThreadsTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistAndThreadsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019 Red Hat Inc., and others.
+ * Copyright (c) 2019, 2020 Red Hat Inc., and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,10 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -52,7 +56,6 @@ import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.text.java.JavaCompletionProcessor;
public class ContentAssistAndThreadsTest extends AbstractCompletionTest {
-
@After
public void resetPreference() {
JavaPlugin.getDefault().getPreferenceStore().setToDefault(PreferenceConstants.CODEASSIST_NONUITHREAD_COMPUTATION);
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistHistoryTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistHistoryTest.java
index ad724ebe44..f75753d547 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistHistoryTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistHistoryTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2015 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,31 +13,32 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.ui.tests.core.ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.internal.ui.text.java.ContentAssistHistory;
import org.eclipse.jdt.internal.ui.text.java.ContentAssistHistory.RHSHistory;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
/**
* @since 3.2
*/
-public class ContentAssistHistoryTest extends TestCase {
- private static final Class<ContentAssistHistoryTest> THIS= ContentAssistHistoryTest.class;
-
+public class ContentAssistHistoryTest {
private static final String LINKED_LIST= "java.util.LinkedList";
private static final String ARRAY_LIST= "java.util.ArrayList";
private static final String ITERABLE= "java.lang.Iterable";
@@ -55,23 +56,14 @@ public class ContentAssistHistoryTest extends TestCase {
private static IType fgArrayListT;
private static IType fgLinkedListT;
-
- public ContentAssistHistoryTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return setUpTest(new TestSuite(THIS, "ContentAssistHistoryTest"));
- }
-
- public static Test setUpTest(Test test) {
- return new ProjectTestSetup(test) {
+ @Rule
+ public ProjectTestSetup pts= new ProjectTestSetup() {
/*
* @see org.eclipse.jdt.ui.tests.core.ProjectTestSetup#setUp()
*/
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ protected void before() throws Throwable {
+ super.before();
IJavaProject project= ProjectTestSetup.getProject();
fgStringT= project.findType(STRING);
@@ -83,8 +75,8 @@ public class ContentAssistHistoryTest extends TestCase {
fgLinkedListT= project.findType(LINKED_LIST);
}
};
- }
+ @Test
public void testContentAssistHistoryIntInt() {
try {
new ContentAssistHistory(-1, 1);
@@ -103,6 +95,7 @@ public class ContentAssistHistoryTest extends TestCase {
}
}
+ @Test
public void testContentAssistHistory() {
try {
new ContentAssistHistory();
@@ -111,6 +104,7 @@ public class ContentAssistHistoryTest extends TestCase {
}
}
+ @Test
public void testRememberArgumentChecking() throws Exception {
ContentAssistHistory history= new ContentAssistHistory();
try {
@@ -135,6 +129,7 @@ public class ContentAssistHistoryTest extends TestCase {
}
}
+ @Test
public void testGetHistory() {
ContentAssistHistory history= new ContentAssistHistory();
assertTrue(history.getHistory(STRING).getTypes().isEmpty());
@@ -155,6 +150,7 @@ public class ContentAssistHistoryTest extends TestCase {
assertEquals("order not correct", list(STRING_BUFFER, STRING), history.getHistory(CHAR_SEQUENCE).getTypes());
}
+ @Test
public void testHistoryCapSize() {
ContentAssistHistory history= new ContentAssistHistory(1, 1);
@@ -177,6 +173,7 @@ public class ContentAssistHistoryTest extends TestCase {
assertEqualMap(map(COLLECTION, list(ARRAY_LIST)), history.getEntireHistory());
}
+ @Test
public void testGetHistoryForHierarchy() {
ContentAssistHistory history= new ContentAssistHistory();
@@ -184,6 +181,7 @@ public class ContentAssistHistoryTest extends TestCase {
assertEqualMap(map(LIST, list(ARRAY_LIST), COLLECTION, list(ARRAY_LIST), ITERABLE, list(ARRAY_LIST)), history.getEntireHistory());
}
+ @Test
public void testGetEntireHistory() {
ContentAssistHistory history= new ContentAssistHistory();
@@ -193,6 +191,7 @@ public class ContentAssistHistoryTest extends TestCase {
assertEqualMap(map(LIST, list(ARRAY_LIST), COLLECTION, list(ARRAY_LIST, LINKED_LIST), ITERABLE, list(ARRAY_LIST, LINKED_LIST)), history.getEntireHistory());
}
+ @Test
public void testReadOnlyEntireHistory() {
ContentAssistHistory history= new ContentAssistHistory();
@@ -213,6 +212,7 @@ public class ContentAssistHistoryTest extends TestCase {
}
}
+ @Test
public void testReadOnlyHistory() {
ContentAssistHistory history= new ContentAssistHistory();
@@ -227,6 +227,7 @@ public class ContentAssistHistoryTest extends TestCase {
}
}
+ @Test
public void testLoadStore() throws Exception {
ContentAssistHistory history= new ContentAssistHistory();
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistTestSuite.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistTestSuite.java
index 827c98f2cf..569e85c446 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistTestSuite.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContentAssistTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,38 +14,35 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
/**
* Content assist test suite.
*
* @since 3.2
*/
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ //$JUnit-BEGIN$
+ CamelCaseCompletionTest.class,
+ JavadocCompletionTest.class,
+ ContentAssistHistoryTest.class,
+ MethodInsertCompletionTest.class,
+ MethodInsertionFormattedCompletionTest.class,
+ MethodOverwriteCompletionTest.class,
+ MethodParamsCompletionTest.class,
+ MethodParameterGuessingCompletionTest.class,
+ MissingTypeCompletionTest.class,
+ TypeCompletionTest.class,
+ TypeCompletionTest1d7.class,
+ SpecialMethodsCompletionTest.class,
+ CodeCompletionTest.class,
+ CodeCompletionTest1d8.class,
+ ContinuousTypingCompletionTest.class,
+ ChainCompletionTest.class,
+ PostFixCompletionTest.class
+ //$JUnit-END$
+})
public class ContentAssistTestSuite {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(ContentAssistTestSuite.class.getName());
- //$JUnit-BEGIN$
- suite.addTest(CamelCaseCompletionTest.suite());
- suite.addTest(JavadocCompletionTest.suite());
- suite.addTest(ContentAssistHistoryTest.suite());
- suite.addTest(MethodInsertCompletionTest.suite());
- suite.addTest(MethodInsertionFormattedCompletionTest.suite());
- suite.addTest(MethodOverwriteCompletionTest.suite());
- suite.addTest(MethodParamsCompletionTest.suite());
- suite.addTest(MethodParameterGuessingCompletionTest.suite());
- suite.addTest(TypeCompletionTest.suite());
- suite.addTest(TypeCompletionTest17.suite());
- suite.addTest(SpecialMethodsCompletionTest.suite());
- suite.addTest(CodeCompletionTest.suite());
- suite.addTest(CodeCompletionTest18.suite());
- suite.addTest(ContinuousTypingCompletionTest.suite());
- suite.addTest(ChainCompletionTest.suite());
- suite.addTest(PostFixCompletionTest.suite());
- //$JUnit-END$
-
- return suite;
- }
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContinuousTypingCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContinuousTypingCompletionTest.java
index 2b938c53f8..fca4471bff 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContinuousTypingCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/ContinuousTypingCompletionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2017 Red Hat Inc. and others
+ * Copyright (c) 2017, 2020 Red Hat Inc. and others
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,7 +13,10 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
-import org.junit.After;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.testplugin.util.DisplayHelper;
@@ -35,11 +38,7 @@ import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer;
import org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
public class ContinuousTypingCompletionTest extends AbstractCompletionTest {
-
private final class CompletionSelectionTracker implements ICompletionListener {
private ICompletionProposal fSelectedProposal;
@@ -63,21 +62,15 @@ public class ContinuousTypingCompletionTest extends AbstractCompletionTest {
}
}
- private static final Class<ContinuousTypingCompletionTest> THIS= ContinuousTypingCompletionTest.class;
-
private JavaEditor fEditor;
- public static Test setUpTest(Test test) {
- return new CompletionTestSetup(test);
- }
-
- public static Test suite() {
- return setUpTest(new TestSuite(THIS, suiteName(THIS)));
- }
+ @Rule
+ public CompletionTestSetup cts= new CompletionTestSetup();
/*
* This tests https://bugs.eclipse.org/bugs/show_bug.cgi?id=511542
*/
+ @Test
public void testContinousTypingSelectsTopProposal() throws Exception {
String contents= "public class " + getName() + " {\n" +
" int ab, ba;\n" +
@@ -101,7 +94,6 @@ public class ContinuousTypingCompletionTest extends AbstractCompletionTest {
assertEquals("ba", selectionTracker.getSelectedProposal().getJavaElement().getElementName());
}
- @After
@Override
public void tearDown() throws Exception {
if (fEditor != null) {
@@ -110,5 +102,4 @@ public class ContinuousTypingCompletionTest extends AbstractCompletionTest {
}
super.tearDown();
}
-
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/Java17CompletionTestSetup.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/Java1d7CompletionTestSetup.java
index 3e63004e2d..3aa56fdfe1 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/Java17CompletionTestSetup.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/Java1d7CompletionTestSetup.java
@@ -13,8 +13,6 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
-import junit.framework.Test;
-
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.core.runtime.CoreException;
@@ -23,11 +21,12 @@ import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.ui.tests.core.Java1d7ProjectTestSetup;
-
-
-class Java17CompletionTestSetup extends Java1d7ProjectTestSetup {
+import org.eclipse.jdt.ui.tests.core.rules.Java1d7ProjectTestSetup;
+/**
+ * This class is used to run tests on Java Dolphin 1.7 .
+ */
+class Java1d7CompletionTestSetup extends Java1d7ProjectTestSetup {
public static IPackageFragment getTestPackage() throws CoreException {
IJavaProject project= getProject();
IPackageFragmentRoot root= project.getPackageFragmentRoot("src");
@@ -55,8 +54,4 @@ class Java17CompletionTestSetup extends Java1d7ProjectTestSetup {
return fragment;
}
-
- public Java17CompletionTestSetup(Test test) {
- super(test);
- }
} \ No newline at end of file
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/JavadocCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/JavadocCompletionTest.java
index 7d43cd91a5..017786aacc 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/JavadocCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/JavadocCompletionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,23 +13,21 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.text.IJavaPartitions;
+/*
+ * This test tests only <= 1.5 source level tags.
+ */
public class JavadocCompletionTest extends AbstractCompletionTest {
- /*
- * This test tests only <= 1.5 source level tags.
- */
-
private static final boolean BUG_NO_HTML_TAG_PROPOSALS_IN_CORE_JDOC_ASSIST= true;
private static final boolean BUG_NO_BEST_EFFORT_IMPORTS_WITH_CORE_COMPLETION= true;
private static final boolean BUG_113544= true;
- private static final Class<JavadocCompletionTest> THIS= JavadocCompletionTest.class;
private static final String METHOD=
" public int method(int param) {\n" +
" return 0;\n" +
@@ -44,49 +42,50 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
private static final String[] FIELD_INLINE_TAGS= {"@docRoot", "@link", "@linkplain", "@value", "@code", "@literal", };
private static final String[] HTML_TAGS= {"b", "blockquote", "br", "code", "dd", "dl", "dt", "em", "hr", "h1", "h2", "h3", "h4", "h5", "h6", "i", "li", "nl", "ol", "p", "pre", "q", "td", "th", "tr", "tt", "ul",};
- public static Test setUpTest(Test test) {
- return new CompletionTestSetup(test);
- }
-
- public static Test suite() {
- return setUpTest(new TestSuite(THIS, suiteName(THIS)));
- }
+ @Rule
+ public CompletionTestSetup cts= new CompletionTestSetup();
/*
* @see org.eclipse.jdt.text.tests.contentassist.AbstractCompletionTest#setUp()
*/
@Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_ADDIMPORT, false);
}
+ @Test
public void testSeeType() throws Exception {
assertTypeJavadocProposal(" * @see List|", "List ", " * @see java.util.List|");
}
+ @Test
public void testSeeTypeImportsOn() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_ADDIMPORT, true);
expectImport("java.util.List");
assertTypeJavadocProposal(" * @see List|", "List ", " * @see List|");
}
+ @Test
public void testSeeTypeJavaLang() throws Exception {
assertTypeJavadocProposal(" * @see Str|", "String ", " * @see String|");
}
+ @Test
public void testSeeImportedQualifiedType() throws Exception {
addImport("java.util.List");
expectImport("java.util.List");
assertTypeJavadocProposal(" * @see java.util.Lis|", "List ", " * @see java.util.List|");
}
+ @Test
public void testSeeImportedType() throws Exception {
addImport("java.util.List");
expectImport("java.util.List");
assertTypeJavadocProposal(" * @see Lis|", "List ", " * @see List|");
}
+ @Test
public void testSeeImportedTypeImportsOn() throws Exception {
addImport("java.util.List");
expectImport("java.util.List");
@@ -94,10 +93,12 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
assertTypeJavadocProposal(" * @see Lis|", "List ", " * @see List|");
}
+ @Test
public void testSeeTypeSameType() throws Exception {
assertTypeJavadocProposal(" * @see Comple|", "Completion_testSeeTypeSameType", " * @see Completion_testSeeTypeSameType|");
}
+ @Test
public void testSeeTypeSameTypeImportsOn() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_ADDIMPORT, true);
assertTypeJavadocProposal(" * @see Comple|", "Completion_testSeeTypeSameTypeImportsOn", " * @see Completion_testSeeTypeSameTypeImportsOn|");
@@ -116,10 +117,12 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
// assertTypeJavadocProposal(" * Prefix <code>Completion|</code> postfix", " * Prefix <code>Completion|</code> postfix", "Completion ");
// }
//
+ @Test
public void testSeeMethod() throws Exception {
assertTypeJavadocProposal(" * @see java.util.List#siz|", "size(", " * @see java.util.List#size()|");
}
+ @Test
public void testSeeMethodWithoutImport() throws Exception {
if (BUG_NO_BEST_EFFORT_IMPORTS_WITH_CORE_COMPLETION) {
System.out.println("JavadocCompletionTest.testSeeMethodWithoutImport() - no best-effort imports with Core completion");
@@ -128,32 +131,40 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
assertTypeJavadocProposal(" * @see List#siz|", "size(", " * @see List#size()|");
}
+ @Test
public void testSeeMethodWithParam() throws Exception {
assertTypeJavadocProposal(" * @see java.util.List#ge|", "get(", " * @see java.util.List#get(int)|");
}
+ @Test
public void testSeeMethodWithTypeVariableParameter() throws Exception {
assertTypeJavadocProposal(" * @see java.util.List#ad|", "add(O", " * @see java.util.List#add(Object)|");
}
+ @Test
public void testSeeMethodLocal() throws Exception {
addMembers(METHOD);
assertTypeJavadocProposal(" * @see #me|", "met", " * @see #method(int)|");
}
+ @Test
public void testSeeConstant() throws Exception {
assertTypeJavadocProposal(" * @see java.util.Collections#|", "EMPTY_LI", " * @see java.util.Collections#EMPTY_LIST|");
}
+ @Test
public void testLinkType() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link List|", "List ", " * Prefix {@link java.util.List|");
}
+ @Test
public void testLinkTypeClosed() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link List|}", "List ", " * Prefix {@link java.util.List|}");
}
+ @Test
public void testDirectLinkType() throws Exception {
assertTypeJavadocProposal(" * Prefix List|", "{@link List}", " * Prefix {@link java.util.List}|");
}
+ @Test
public void testDirectLinkTypeNoAutoClose() throws Exception {
if (BUG_113544) {
System.out.println("not testing autoclosing behavior, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=113544");
@@ -163,18 +174,21 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
assertTypeJavadocProposal(" * Prefix List|", "{@link List}", " * Prefix {@link java.util.List|");
}
+ @Test
public void testDirectLinkTypeImportsOn() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_ADDIMPORT, true);
expectImport("java.util.List");
assertTypeJavadocProposal(" * Prefix List|", "{@link List}", " * Prefix {@link List}|");
}
+ @Test
public void testDirectLinkTypeExistingImport() throws Exception {
addImport("java.util.List");
expectImport("java.util.List");
assertTypeJavadocProposal(" * Prefix List|", "{@link List}", " * Prefix {@link List}|");
}
+ @Test
public void testDirectLinkImportsOnExistingImport() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_ADDIMPORT, true);
addImport("java.util.List");
@@ -182,6 +196,7 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
assertTypeJavadocProposal(" * Prefix List|", "{@link List}", " * Prefix {@link List}|");
}
+ @Test
public void testDirectLinkImportsOnExistingImportQualifiedPrefix() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_ADDIMPORT, true);
addImport("java.util.List");
@@ -189,6 +204,7 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
assertTypeJavadocProposal(" * Prefix java.util.List|", "{@link List}", " * Prefix {@link java.util.List}|");
}
+ @Test
public void testDirectLinkImportsOnExistingImportCamelCase() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_ADDIMPORT, true);
setCoreOption(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
@@ -197,6 +213,7 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
assertTypeJavadocProposal(" * Prefix DF|", "{@link DateFormat}", " * Prefix {@link DateFormat}|");
}
+ @Test
public void testDirectLinkImportsOnExistingImportCamelCaseQualifiedPrefix() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_ADDIMPORT, true);
setCoreOption(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
@@ -205,6 +222,7 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
assertTypeJavadocProposal(" * Prefix java.text.DF|", "{@link DateFormat}", " * Prefix {@link java.text.DateFormat}|");
}
+ @Test
public void testDirectLinkTypeNoAutoCloseImportsOn() throws Exception {
if (BUG_113544) {
System.out.println("not testing autoclosing behavior, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=113544");
@@ -216,20 +234,25 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
assertTypeJavadocProposal(" * Prefix List|", "{@link List}", " * Prefix {@link List|");
}
+ @Test
public void testLinkTypeJavaLang() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link Str|", "String ", " * Prefix {@link String|");
}
+ @Test
public void testLinkTypeJavaLangClosed() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link Str|}", "String ", " * Prefix {@link String|}");
}
+ @Test
public void testLinkTypeSameType() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link Comple|", "Completion_testLinkTypeSameType", " * Prefix {@link Completion_testLinkTypeSameType|");
}
+ @Test
public void testLinkTypeSameTypeClosed() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link Comple|}", "Completion_testLinkTypeSameTypeClosed", " * Prefix {@link Completion_testLinkTypeSameTypeClosed|}");
}
+ @Test
public void testLinkMethodWithoutImport() throws Exception {
if (BUG_NO_BEST_EFFORT_IMPORTS_WITH_CORE_COMPLETION) {
System.out.println("JavadocCompletionTest.testLinkMethodWithoutImport() - no best-effort imports with Core completion");
@@ -238,78 +261,96 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
assertTypeJavadocProposal(" * Prefix {@link List#siz|", "size(", " * Prefix {@link List#size()|");
}
+ @Test
public void testLinkMethod() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link java.util.List#siz|", "size(", " * Prefix {@link java.util.List#size()|");
}
+ @Test
public void testLinkMethodLocal() throws Exception {
addMembers(METHOD);
assertTypeJavadocProposal(" * {@link #me|", "met", " * {@link #method(int)|");
}
+ @Test
public void testLinkMethodClosed() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link java.util.List#siz|}", "size(", " * Prefix {@link java.util.List#size()|}");
}
+ @Test
public void testLinkMethodWithParam() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link java.util.List#ge|", "get(", " * Prefix {@link java.util.List#get(int)|");
}
+ @Test
public void testLinkMethodWithParamNoOverwrite() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link java.util.List#|add} postfix", "clear", " * Prefix {@link java.util.List#clear()|add} postfix");
}
+ @Test
public void testLinkMethodWithParamNoOverwriteWithParams() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link java.util.List#|add(int, Object)} postfix", "clear", " * Prefix {@link java.util.List#clear()|add(int, Object)} postfix");
}
+ @Test
public void testLinkMethodWithParamOverwriteNoPrefix() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, false);
assertTypeJavadocProposal(" * Prefix {@link java.util.List#|add} postfix", "clear", " * Prefix {@link java.util.List#clear()|} postfix");
}
+ @Test
public void testLinkMethodWithParamOverwrite() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, false);
assertTypeJavadocProposal(" * Prefix {@link java.util.List#g|et} postfix", "get(", " * Prefix {@link java.util.List#get(int)|} postfix");
}
+ @Test
public void testLinkMethodWithParamOverwriteWithParamsNoPrefix() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, false);
assertTypeJavadocProposal(" * Prefix {@link java.util.List#|add(int, Object)} postfix", "clear", " * Prefix {@link java.util.List#clear()|} postfix");
}
+ @Test
public void testLinkMethodWithParamOverwriteWithParams() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, false);
assertTypeJavadocProposal(" * Prefix {@link java.util.List#g|et(long)} postfix", "get(", " * Prefix {@link java.util.List#get(int)|} postfix");
}
+ @Test
public void testLinkMethodWithParamClosed() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link java.util.List#ge|}", "get(", " * Prefix {@link java.util.List#get(int)|}");
}
+ @Test
public void testLinkMethodWithTypeVariableParameter() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link java.util.List#ad|", "add(O", " * Prefix {@link java.util.List#add(Object)|");
}
+ @Test
public void testLinkMethodWithTypeVariableParameterClosed() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link java.util.List#ad|}", "add(O", " * Prefix {@link java.util.List#add(Object)|}");
}
+ @Test
public void testLinkConstant() throws Exception {
assertTypeJavadocProposal(" * Prefix {@link java.util.Collections#|", "EMPTY_LI", " * Prefix {@link java.util.Collections#EMPTY_LIST|");
}
+ @Test
public void testFieldReference() throws Exception {
assertTypeJavadocProposal(" * Prefix java.util.Collections#|", "{@link java.util.Collections#EMPTY_LI", " * Prefix {@link java.util.Collections#EMPTY_LIST}|");
}
+ @Test
public void testFieldValueReference() throws Exception {
assertTypeJavadocProposal(" * Prefix java.util.Collections#|", "{@value java.util.Collections#EMPTY_LI", " * Prefix {@value java.util.Collections#EMPTY_LIST}|");
}
+ @Test
public void testMethodReference() throws Exception {
assertTypeJavadocProposal(" * Prefix java.util.Collections#|", "{@link java.util.Collections#toSt", " * Prefix {@link java.util.Collections#toString()}|");
}
+ @Test
public void testTypeBlockTags() throws Exception {
tearDown();
for (String t : TYPE_BLOCK_TAGS) {
@@ -321,6 +362,7 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
setUp();
}
+ @Test
public void testMethodBlockTags() throws Exception {
tearDown();
for (String t : METHOD_BLOCK_TAGS) {
@@ -333,6 +375,7 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
setUp();
}
+ @Test
public void testFieldBlockTags() throws Exception {
tearDown();
for (String t : FIELD_BLOCK_TAGS) {
@@ -356,6 +399,7 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
setUp();
}
+ @Test
public void testTypeInlineTags() throws Exception {
tearDown();
for (String t : TYPE_INLINE_TAGS) {
@@ -367,6 +411,7 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
setUp();
}
+ @Test
public void testMethodInlineTags() throws Exception {
tearDown();
for (String t : METHOD_INLINE_TAGS) {
@@ -379,6 +424,7 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
setUp();
}
+ @Test
public void testFieldInlineTags() throws Exception {
tearDown();
for (String t : FIELD_INLINE_TAGS) {
@@ -391,6 +437,7 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
setUp();
}
+ @Test
public void testNoBlockAsInlineTags() throws Exception {
tearDown();
for (String tag : TYPE_BLOCK_TAGS) {
@@ -401,6 +448,7 @@ public class JavadocCompletionTest extends AbstractCompletionTest {
setUp();
}
+ @Test
public void testHTMLTags() throws Exception {
if (BUG_NO_HTML_TAG_PROPOSALS_IN_CORE_JDOC_ASSIST) {
System.out.println("no HTML tag proposals in core jdoc assist");
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodInsertCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodInsertCompletionTest.java
index 006b17d7b1..95b3f2d094 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodInsertCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodInsertCompletionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2016 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,75 +14,68 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.PreferenceConstants;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-
/**
*
* @since 3.2
*/
public class MethodInsertCompletionTest extends AbstractCompletionTest {
- private static final Class<MethodInsertCompletionTest> THIS= MethodInsertCompletionTest.class;
-
- public static Test setUpTest(Test test) {
- return new CompletionTestSetup(test);
- }
-
- public static Test suite() {
- return setUpTest(new TestSuite(THIS, suiteName(THIS)));
- }
-
- /*
- * @see org.eclipse.jdt.text.tests.contentassist.AbstractCompletionTest#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
+ @Rule
+ public CompletionTestSetup cts= new CompletionTestSetup();
+ @Test
public void testThisMethod() throws Exception {
assertMethodBodyProposal("this.|", "hashCode(", "this.hashCode()|");
}
+ @Test
public void testMethod() throws Exception {
assertMethodBodyProposal("h", "hashCode(", "hashCode()");
}
+ @Test
public void testMethodWithParam() throws Exception {
assertMethodBodyProposal("e", "equals(", "equals(|)");
}
/* inserting */
+ @Test
public void testInsertThisMethod() throws Exception {
assertMethodBodyProposal("this.|class", "hashCode(", "this.hashCode()|class");
}
+ @Test
public void testInsertMethod() throws Exception {
assertMethodBodyProposal("h|foobar", "hashCode(", "hashCode()|foobar");
}
+ @Test
public void testInsertMethodWithParam() throws Exception {
assertMethodBodyProposal("e|foobar", "equals(", "equals(|)foobar");
}
+ @Test
public void testFieldThisQualification() throws Exception {
addMembers("private String qqqString;");
addLocalVariables("String qqqString;");
assertMethodBodyProposal("q|", "this.qqqString", "this.qqqString|");
}
+ @Test
public void testCastMethod() throws Exception {
// bug 208540
addLocalVariables("Object o;");
assertMethodBodyProposal("if (o instanceof Integer) o.get|", "getInteger", "if (o instanceof Integer) ((Integer) o).getInteger(|)");
}
+ @Test
public void testCastMethodIncremental() throws Exception {
// bug 208540
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
@@ -93,11 +86,13 @@ public class MethodInsertCompletionTest extends AbstractCompletionTest {
/* camel case */
+ @Test
public void testCamelCase() throws Exception {
setCoreOption(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
assertMethodBodyProposal("hC", "hashCode(", "hashCode()");
}
+ @Test
public void testCamelCaseWithEmptyPrefix() throws Exception {
setCoreOption(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
assertMethodBodyProposal("", "hashCode(", "hashCode()");
@@ -105,50 +100,50 @@ public class MethodInsertCompletionTest extends AbstractCompletionTest {
/* Insert common prefixes automatically */
+ @Test
public void test1() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_AUTOINSERT, true);
- setCoreOption(JavaCore.CODEASSIST_SUBSTRING_MATCH, JavaCore.ENABLED);
addLocalVariables("String s;");
assertMethodBodyIncrementalCompletion("s.ind|", "s.indexOf|");
}
+ @Test
public void test2() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_AUTOINSERT, true);
- setCoreOption(JavaCore.CODEASSIST_SUBSTRING_MATCH, JavaCore.ENABLED);
addLocalVariables("String s;");
assertMethodBodyIncrementalCompletion("s.su|", "s.sub|");
}
+ @Test
public void test3() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_AUTOINSERT, true);
- setCoreOption(JavaCore.CODEASSIST_SUBSTRING_MATCH, JavaCore.ENABLED);
addLocalVariables("String s;");
assertMethodBodyIncrementalCompletion("s.tar|", "s.tartsWith|");
}
+ @Test
public void test4() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_AUTOINSERT, true);
- setCoreOption(JavaCore.CODEASSIST_SUBSTRING_MATCH, JavaCore.ENABLED);
addLocalVariables("String s;");
assertMethodBodyIncrementalCompletion("s.Po|", "s.Point|");
}
+ @Test
public void test5() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_AUTOINSERT, true);
- setCoreOption(JavaCore.CODEASSIST_SUBSTRING_MATCH, JavaCore.ENABLED);
addLocalVariables("String s;");
assertMethodBodyIncrementalCompletion("s.ubs|", "s.ubs|");
}
+ @Test
public void test6() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_AUTOINSERT, true);
- setCoreOption(JavaCore.CODEASSIST_SUBSTRING_MATCH, JavaCore.ENABLED);
addLocalVariables("String s;");
assertMethodBodyIncrementalCompletion("s.Su|", "s.sub|");
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodInsertionFormattedCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodInsertionFormattedCompletionTest.java
index 4b410c3b78..31035dddd1 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodInsertionFormattedCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodInsertionFormattedCompletionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2013 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,8 +15,8 @@ package org.eclipse.jdt.text.tests.contentassist;
import java.util.Hashtable;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
@@ -29,15 +29,9 @@ import org.eclipse.jdt.ui.PreferenceConstants;
*/
public class MethodInsertionFormattedCompletionTest extends AbstractCompletionTest {
private static final boolean BUG_DISABLED_DUE_TO_FORMATTER_CONTEXT_INFO_INTERATION= true;
- private static final Class<MethodInsertionFormattedCompletionTest> THIS= MethodInsertionFormattedCompletionTest.class;
- public static Test setUpTest(Test test) {
- return new CompletionTestSetup(test);
- }
-
- public static Test suite() {
- return setUpTest(new TestSuite(THIS, suiteName(THIS)));
- }
+ @Rule
+ public CompletionTestSetup cts= new CompletionTestSetup();
/*
* @see org.eclipse.jdt.text.tests.contentassist.AbstractCompletionTest#configureCoreOptions(java.util.Hashtable)
@@ -53,14 +47,17 @@ public class MethodInsertionFormattedCompletionTest extends AbstractCompletionTe
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, JavaCore.INSERT);
}
+ @Test
public void testThisMethod() throws Exception {
assertMethodBodyProposal("this.|", "hashCode(", "this.hashCode ( )|");
}
+ @Test
public void testMethod() throws Exception {
assertMethodBodyProposal("h", "hashCode(", "hashCode ( )");
}
+ @Test
public void testMethodWithParam() throws Exception {
if (BUG_DISABLED_DUE_TO_FORMATTER_CONTEXT_INFO_INTERATION) {
// FIXME
@@ -73,14 +70,17 @@ public class MethodInsertionFormattedCompletionTest extends AbstractCompletionTe
/* inserting */
+ @Test
public void testInsertThisMethod() throws Exception {
assertMethodBodyProposal("this.|class", "hashCode(", "this.hashCode ( )|class");
}
+ @Test
public void testInsertMethod() throws Exception {
assertMethodBodyProposal("h|foobar", "hashCode(", "hashCode ( )|foobar");
}
+ @Test
public void testInsertMethodWithParam() throws Exception {
if (BUG_DISABLED_DUE_TO_FORMATTER_CONTEXT_INFO_INTERATION) {
// FIXME
@@ -91,18 +91,21 @@ public class MethodInsertionFormattedCompletionTest extends AbstractCompletionTe
assertMethodBodyProposal("e|foobar", "equals(", "equals ( |)foobar");
}
+ @Test
public void testFormattedMethodWithParameterFilling1() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, true);
addMembers("private java.util.List fList;");
assertMethodBodyProposal("fList.", "add(O", "fList.add ( |arg0| )");
}
+ @Test
public void testFormattedMethodWithParameterFilling2() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, true);
addMembers("private java.util.List fList;");
assertMethodBodyProposal("fList.", "add(int", "fList.add ( |arg0|, arg1 );");
}
+ @Test
public void testFormattedMethodWithParameterGuessing1() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, true);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, true);
@@ -112,6 +115,7 @@ public class MethodInsertionFormattedCompletionTest extends AbstractCompletionTe
assertMethodBodyProposal("fList.", "add(O", "fList.add ( |obj| )");
}
+ @Test
public void testFormattedMethodWithParameterGuessing2() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, true);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, true);
@@ -120,5 +124,4 @@ public class MethodInsertionFormattedCompletionTest extends AbstractCompletionTe
assertMethodBodyProposal("fList.", "add(int", "fList.add ( |foo|, obj );");
}
-
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodOverwriteCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodOverwriteCompletionTest.java
index 317ce88881..d37077fe63 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodOverwriteCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodOverwriteCompletionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.ui.PreferenceConstants;
@@ -23,49 +23,47 @@ import org.eclipse.jdt.ui.PreferenceConstants;
* @since 3.2
*/
public class MethodOverwriteCompletionTest extends AbstractCompletionTest {
- private static final Class<MethodOverwriteCompletionTest> THIS= MethodOverwriteCompletionTest.class;
-
- public static Test setUpTest(Test test) {
- return new CompletionTestSetup(test);
- }
-
- public static Test suite() {
- return setUpTest(new TestSuite(THIS, suiteName(THIS)));
- }
+ @Rule
+ public CompletionTestSetup cts= new CompletionTestSetup();
/*
* @see org.eclipse.jdt.text.tests.contentassist.AbstractCompletionTest#setUp()
*/
@Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, false);
}
+ @Test
public void testThisMethod() throws Exception {
assertMethodBodyProposal("this.|", "hashCode(", "this.hashCode()|");
}
+ @Test
public void testMethod() throws Exception {
assertMethodBodyProposal("h", "hashCode(", "hashCode()");
}
+ @Test
public void testMethodWithParam() throws Exception {
assertMethodBodyProposal("e", "equals(", "equals(|)");
}
/* overwriting */
+ @Test
public void testOverwriteThisMethod() throws Exception {
assertMethodBodyProposal("this.|class", "hashCode(", "this.hashCode()|");
}
+ @Test
public void testOverwriteMethod() throws Exception {
assertMethodBodyProposal("h|foobar", "hashCode(", "hashCode()|");
}
+ @Test
public void testOverwriteMethodWithParam() throws Exception {
assertMethodBodyProposal("e|foobar", "equals(", "equals(|)");
}
-
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodParameterGuessingCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodParameterGuessingCompletionTest.java
index 13b4d0bc8a..7ccbc50afc 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodParameterGuessingCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodParameterGuessingCompletionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2013 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.ui.PreferenceConstants;
@@ -23,21 +23,14 @@ import org.eclipse.jdt.ui.PreferenceConstants;
* @since 3.2
*/
public class MethodParameterGuessingCompletionTest extends AbstractCompletionTest {
- private static final Class<MethodParameterGuessingCompletionTest> THIS= MethodParameterGuessingCompletionTest.class;
-
- public static Test setUpTest(Test test) {
- return new CompletionTestSetup(test);
- }
-
- public static Test suite() {
- return setUpTest(new TestSuite(THIS, suiteName(THIS)));
- }
+ @Rule
+ public CompletionTestSetup cts= new CompletionTestSetup();
/*
* @see org.eclipse.jdt.text.tests.contentassist.AbstractCompletionTest#setUp()
*/
@Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, true);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, true);
@@ -45,30 +38,35 @@ public class MethodParameterGuessingCompletionTest extends AbstractCompletionTes
addLocalVariables("int foo= 3; Object obj= null;\n");
}
+ @Test
public void testMethodWithParam1() throws Exception {
assertMethodBodyProposal("fList.", "add(O", "fList.add(|obj|)");
}
+ @Test
public void testMethodWithParam2() throws Exception {
assertMethodBodyProposal("fList.", "add(int", "fList.add(|foo|, obj);");
}
+ @Test
public void testInsertMethodWithParam1() throws Exception {
assertMethodBodyProposal("fList.|bar", "add(O", "fList.add(|obj|)bar");
}
+ @Test
public void testInsertMethodWithParam2() throws Exception {
assertMethodBodyProposal("fList.|bar", "add(int", "fList.add(|foo|, obj);bar");
}
+ @Test
public void testOverwriteMethodWithParam1() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, false);
assertMethodBodyProposal("fList.|bar", "add(O", "fList.add(|obj|)");
}
+ @Test
public void testOverwriteMethodWithParam2() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, false);
assertMethodBodyProposal("fList.|bar", "add(int", "fList.add(|foo|, obj);");
}
-
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodParamsCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodParamsCompletionTest.java
index 011af2b67a..582f4ee23d 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodParamsCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodParamsCompletionTest.java
@@ -13,95 +13,106 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
-import org.eclipse.jdt.ui.PreferenceConstants;
+import org.junit.Rule;
+import org.junit.Test;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.eclipse.jdt.ui.PreferenceConstants;
/**
*
* @since 3.2
*/
public class MethodParamsCompletionTest extends AbstractCompletionTest {
- private static final Class<MethodParamsCompletionTest> THIS= MethodParamsCompletionTest.class;
-
- public static Test setUpTest(Test test) {
- return new CompletionTestSetup(test);
- }
-
- public static Test suite() {
- return setUpTest(new TestSuite(THIS, suiteName(THIS)));
- }
+ @Rule
+ public CompletionTestSetup cts= new CompletionTestSetup();
/*
* @see org.eclipse.jdt.text.tests.contentassist.AbstractCompletionTest#setUp()
*/
@Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, true);
addMembers("private java.util.List fList;");
}
+ @Test
public void testMethodWithParam1() throws Exception {
assertMethodBodyProposal("fList.", "add(O", "fList.add(|arg0|)");
}
+ @Test
public void testMethodWithParam2() throws Exception {
assertMethodBodyProposal("fList.", "add(int", "fList.add(|arg0|, arg1);");
}
+ @Test
public void testInsertMethodWithParam1() throws Exception {
assertMethodBodyProposal("fList.|bar", "add(O", "fList.add(|arg0|)bar");
}
+ @Test
public void testInsertMethodWithParam2() throws Exception {
assertMethodBodyProposal("fList.|bar", "add(int", "fList.add(|arg0|, arg1);bar");
}
+ @Test
public void testOverwriteMethodWithParam1() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, false);
assertMethodBodyProposal("fList.|bar", "add(O", "fList.add(|arg0|)");
}
+ @Test
public void testOverwriteMethodWithParam2() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, false);
assertMethodBodyProposal("fList.|bar", "add(int", "fList.add(|arg0|, arg1);");
}
+ @Test
public void testParenthesisExits() throws Exception {
assertMethodBodyProposal("fList.|", "add(O", "fList.add(|arg0|)");
typeAndVerify(")", "fList.add(arg0)|");
}
+ @Test
public void testParenthesisExits_voidReturn() throws Exception {
assertMethodBodyProposal("fList.|", "add(int", "fList.add(|arg0|, arg1);");
typeAndVerify(",)", "fList.add(arg0, arg1);|");
}
+ @Test
public void testDontExitFromStringLiteral() throws Exception {
assertMethodBodyProposal("fList.|", "add(O", "fList.add(|arg0|)");
typeAndVerify("\")\"", "fList.add(\")\"|)");
}
+ @Test
public void testDontExitFromStringLiteral_voidReturn() throws Exception {
assertMethodBodyProposal("fList.|", "add(int", "fList.add(|arg0|, arg1);");
typeAndVerify(",\")\"", "fList.add(arg0, \")\"|);");
}
+ @Test
+ public void testDontExitFromStringLiteral_semicolon() throws Exception {
+ assertMethodBodyProposal("String.|", "format(String", "String.format(|arg0|, arg1)");
+ typeAndVerify("\";\",", "String.format(\";\", |arg1|)");
+ }
+
+ @Test
public void testCommaSkipsToNextArg() throws Exception {
assertMethodBodyProposal("fList.|", "add(int", "fList.add(|arg0|, arg1);");
typeAndVerify(",", "fList.add(arg0, |arg1|);");
}
+ @Test
public void testDontExitWithUnblancedParenthesis() throws Exception {
assertMethodBodyProposal("fList.|", "add(O", "fList.add(|arg0|)");
typeAndVerify("(1 + \")\" + 2)", "fList.add((1 + \")\" + 2)|)");
}
+ @Test
public void testDontExitWithUnblancedParenthesis_voidReturn() throws Exception {
assertMethodBodyProposal("fList.|", "add(int", "fList.add(|arg0|, arg1);");
typeAndVerify(",(1 + 2)", "fList.add(arg0, (1 + 2)|);");
}
-
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MissingTypeCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MissingTypeCompletionTest.java
new file mode 100644
index 0000000000..9ce1c8223a
--- /dev/null
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MissingTypeCompletionTest.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Julian Honnen
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Julian Honnen - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.text.tests.contentassist;
+
+import org.junit.After;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+
+import org.eclipse.jdt.ui.PreferenceConstants;
+
+public class MissingTypeCompletionTest extends AbstractCompletionTest {
+ @Rule
+ public CompletionTestSetup cts= new CompletionTestSetup();
+
+ private ICompilationUnit missingType;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, true);
+ }
+
+ private void createMissingType(String contents) throws CoreException {
+ IPackageFragmentRoot root= (IPackageFragmentRoot) getAnonymousTestPackage().getParent();
+ IPackageFragment missingFragment= root.createPackageFragment("missing", true, null);
+
+ missingType= missingFragment.createCompilationUnit("MissingType.java", "package missing;\n\n" + contents, true, null);
+ expectImport("missing.MissingType");
+ }
+
+ @After
+ public void cleanupMissingType() throws CoreException {
+ if (missingType != null) {
+ JavaProjectHelper.delete(missingType);
+ }
+ }
+
+ @Test
+ public void testGenericType_method() throws Exception {
+ createMissingType("public class MissingType<T> {\n" +
+ " public static void foo() {}\n" +
+ "}\n");
+ assertMethodBodyProposal("MissingType.", "foo", "MissingType.foo();");
+ }
+
+ @Test
+ public void testGenericType_innerClass() throws Exception {
+ createMissingType("public class MissingType<T> {\n" +
+ " public static class Member {}\n" +
+ "}\n");
+ assertMethodBodyProposal("MissingType.", "Member", "MissingType.Member");
+ }
+
+ @Test
+ public void testGenericType_constructor() throws Exception {
+ createMissingType("public class MissingType<T> {\n" +
+ "}\n");
+ assertMethodBodyProposal("new MissingType", "MissingType", "new MissingType<T>()");
+ }
+
+}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/PostFixCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/PostFixCompletionTest.java
index 7c484153a9..4501ee331f 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/PostFixCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/PostFixCompletionTest.java
@@ -12,10 +12,18 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.util.Arrays;
import java.util.Hashtable;
import java.util.List;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.swt.SWT;
@@ -35,37 +43,25 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.jdt.ui.tests.core.ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.text.java.PostfixCompletionProposalComputer;
import org.eclipse.jdt.internal.ui.text.template.contentassist.PostfixTemplateProposal;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class PostFixCompletionTest extends TestCase {
-
- private static final Class<PostFixCompletionTest> THIS= PostFixCompletionTest.class;
-
+public class PostFixCompletionTest {
private IJavaProject fJProject;
private IPackageFragmentRoot javaSrc;
private IPackageFragment pkg;
- public static Test suite() {
- return setUpTest(new TestSuite(THIS));
- }
-
- public static Test setUpTest(Test test) {
- return new ProjectTestSetup(test);
- }
+ @Rule
+ public ProjectTestSetup cts= new ProjectTestSetup();
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
Hashtable<String, String> options= JavaCore.getDefaultOptions();
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "2");
@@ -77,11 +73,12 @@ public class PostFixCompletionTest extends TestCase {
pkg= javaSrc.createPackageFragment("test", false, null);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
JavaProjectHelper.delete(fJProject);
}
+ @Test
public void testStringVar() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -104,13 +101,14 @@ public class PostFixCompletionTest extends TestCase {
expected.append("package test;\n" +
"public class StringVar {\n" +
" public void test () {\n" +
- " String name = \"Some String Value\";\n" +
+ " String string = \"Some String Value\";\n" +
" }\n" +
"}");
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testStringVar2() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -136,7 +134,7 @@ public class PostFixCompletionTest extends TestCase {
"\n" +
"public class StringVar2 {\n" +
" public void test () {\n" +
- " String name = \"foo\";\n" +
+ " String string = \"foo\";\n" +
" if (true);\n" +
" }\n" +
"}");
@@ -144,6 +142,7 @@ public class PostFixCompletionTest extends TestCase {
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testIntegerVar() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -166,13 +165,14 @@ public class PostFixCompletionTest extends TestCase {
expected.append("package test;\n" +
"public class IntegerVar {\n" +
" public void test () {\n" +
- " Integer name = new Integer(0);\n" +
+ " Integer integer = new Integer(0);\n" +
" }\n" +
"}");
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testBooleanVar() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -195,13 +195,14 @@ public class PostFixCompletionTest extends TestCase {
expected.append("package test;\n" +
"public class BooleanVar {\n" +
" public void test () {\n" +
- " boolean false1 = false;\n" +
+ " boolean b = false;\n" +
" }\n" +
"}");
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testIntVar() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -231,6 +232,7 @@ public class PostFixCompletionTest extends TestCase {
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testStringConcatVar() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -253,13 +255,14 @@ public class PostFixCompletionTest extends TestCase {
expected.append("package test;\n" +
"public class StringConcatVar {\n" +
" public void test () {\n" +
- " String name = (\"two\" + 2);\n" +
+ " String string = (\"two\" + 2);\n" +
" }\n" +
"}");
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testStringConcatVar2() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -282,13 +285,14 @@ public class PostFixCompletionTest extends TestCase {
expected.append("package test;\n" +
"public class testStringConcatVar2 {\n" +
" public void test () {\n" +
- " String name = ((((\"two\" + 2))));\n" +
+ " String string = ((((\"two\" + 2))));\n" +
" }\n" +
"}");
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testArrayVar() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -318,6 +322,39 @@ public class PostFixCompletionTest extends TestCase {
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
+ public void testArrayAccessVar() throws Exception {
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test;\n" +
+ "public class ArrayAccessVar {\n" +
+ " public void test () {\n" +
+ " String [] args = new String [] { \"one\", \"two\" };\n" +
+ " args[0].var$\n" +
+ " }\n" +
+ "}");
+
+ int completionIndex= getCompletionIndex(buf);
+ ICompilationUnit cu= getCompilationUnit(pkg, buf, "ArrayAccessVar.java");
+ List<ICompletionProposal> proposals= computeCompletionProposals(cu, completionIndex);
+
+ assertProposalsExist(Arrays.asList("var - Creates a new variable"), proposals);
+
+ ITextViewer viewer= initializeViewer(cu);
+ applyProposal(viewer, proposals, "var", completionIndex);
+
+ StringBuffer expected= new StringBuffer();
+ expected.append("package test;\n" +
+ "public class ArrayAccessVar {\n" +
+ " public void test () {\n" +
+ " String [] args = new String [] { \"one\", \"two\" };\n" +
+ " String string = args[0];\n" +
+ " }\n" +
+ "}");
+
+ assertEquals(expected.toString(), viewer.getDocument().get());
+ }
+
+ @Test
public void testBoundedExtendsTypeParameterVar() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -344,13 +381,14 @@ public class PostFixCompletionTest extends TestCase {
"public class BoundedExtendsTypeParameterVar {\n" +
" public void test () {\n" +
" List<? extends Number> x = null;\n" +
- " Number name = x.get(0);\n" +
+ " Number number = x.get(0);\n" +
" }\n" +
"}");
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testBoundedSuperTypeParameterVar() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -377,13 +415,14 @@ public class PostFixCompletionTest extends TestCase {
"public class testBoundedSuperTypeParameterVar {\n" +
" public void test () {\n" +
" List<? super Number> x = null;\n" +
- " Object name = x.get(0);\n" +
+ " Object number = x.get(0);\n" +
" }\n" +
"}");
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testVarForMethodInvocation() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -412,13 +451,14 @@ public class PostFixCompletionTest extends TestCase {
"public class VarForMethodInvocation {\n" +
" public void test () {\n" +
" List<String> res = Arrays.asList(\"a\", \"b\");\n" +
- " boolean name = res.get(0).isEmpty();\n" +
+ " boolean empty = res.get(0).isEmpty();\n" +
" }\n" +
"}");
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testVarForMethodInvocation2() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -443,13 +483,14 @@ public class PostFixCompletionTest extends TestCase {
"public class VarForMethodInvocation2 {\n" +
" public void test () {\n" +
" String s = \"5\";\n" +
- " Integer name = Integer.valueOf(s);\n" +
+ " Integer valueOf = Integer.valueOf(s);\n" +
" }\n" +
"}");
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testVarForMethodInvocation3() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -481,7 +522,7 @@ public class PostFixCompletionTest extends TestCase {
" } \n" +
" public class Child extends VarForMethodInvocation3 {\n" +
" public void test() {\n" +
- " VarForMethodInvocation3 name = super.getAdapter(VarForMethodInvocation3.class);\n" +
+ " VarForMethodInvocation3 adapter = super.getAdapter(VarForMethodInvocation3.class);\n" +
" }\n" +
" } \n" +
"}");
@@ -489,6 +530,39 @@ public class PostFixCompletionTest extends TestCase {
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
+ public void testVarForClassCreation() throws Exception {
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test;\n" +
+ "public class VarForClassCreation {\n" +
+ " public static final int STYLE = 7;\n" +
+ " public void test () {\n" +
+ " new Integer(VarForClassCreation.STYLE).var$\n" +
+ " }\n" +
+ "}");
+
+ int completionIndex= getCompletionIndex(buf);
+ ICompilationUnit cu= getCompilationUnit(pkg, buf, "VarForClassCreation.java");
+ List<ICompletionProposal> proposals= computeCompletionProposals(cu, completionIndex);
+
+ assertProposalsExist(Arrays.asList("var - Creates a new variable"), proposals);
+
+ ITextViewer viewer= initializeViewer(cu);
+ applyProposal(viewer, proposals, "var", completionIndex);
+
+ StringBuffer expected= new StringBuffer();
+ expected.append("package test;\n" +
+ "public class VarForClassCreation {\n" +
+ " public static final int STYLE = 7;\n" +
+ " public void test () {\n" +
+ " Integer integer = new Integer(VarForClassCreation.STYLE);\n" +
+ " }\n" +
+ "}");
+
+ assertEquals(expected.toString(), viewer.getDocument().get());
+ }
+
+ @Test
public void testBegForVoidMethodInvocation() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -513,6 +587,7 @@ public class PostFixCompletionTest extends TestCase {
assertEquals(expectedBeg, viewer.getSelectedRange().x);
}
+ @Test
public void testVarForAnonymousClass() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -544,7 +619,7 @@ public class PostFixCompletionTest extends TestCase {
"import java.io.FileFilter;\n" +
"public class Test {\n" +
" public void test() {\n" +
- " File[] name = new File(\"\").listFiles(new FileFilter() {\n" +
+ " File[] listFiles = new File(\"\").listFiles(new FileFilter() {\n" +
" @Override\n" +
" public boolean accept(File pathname) {\n" +
" return false;\n" +
@@ -556,6 +631,7 @@ public class PostFixCompletionTest extends TestCase {
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testNestedQualifiedNames() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -588,7 +664,7 @@ public class PostFixCompletionTest extends TestCase {
"public Foo foo; \n" +
"public void foo () {\n" +
" Foo foo = new Foo ();\n" +
- " String name = foo.bar.res;\n" +
+ " String res = foo.bar.res;\n" +
"}\n" +
"public class Foo {\n" +
" public Bar bar;\n" +
@@ -601,6 +677,7 @@ public class PostFixCompletionTest extends TestCase {
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testFieldAccess() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -628,7 +705,7 @@ public class PostFixCompletionTest extends TestCase {
" public class Foo {\n" +
" public String res;\n" +
" public void foo () {\n" +
- " String name = this.res;\n" +
+ " String res = this.res;\n" +
" }\n" +
" }" +
"}");
@@ -636,6 +713,7 @@ public class PostFixCompletionTest extends TestCase {
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testForStatement() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -671,6 +749,7 @@ public class PostFixCompletionTest extends TestCase {
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testForStatement2() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -706,6 +785,7 @@ public class PostFixCompletionTest extends TestCase {
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testShorthandIfStatement() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -735,6 +815,7 @@ public class PostFixCompletionTest extends TestCase {
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testConcatenatedShorthandIfStatement() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -764,6 +845,7 @@ public class PostFixCompletionTest extends TestCase {
assertEquals(expected.toString(), viewer.getDocument().get());
}
+ @Test
public void testNoThrownExceptions() throws Exception {
StringBuffer buf= new StringBuffer();
buf.append("package test;\n" +
@@ -814,5 +896,4 @@ public class PostFixCompletionTest extends TestCase {
PostfixTemplateProposal proposal= (PostfixTemplateProposal) proposals.stream().filter(p -> ((PostfixTemplateProposal) p).getTemplate().getName().equals(name)).findFirst().get();
proposal.apply(viewer, '0', -1, offset);
}
-
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/SpecialMethodsCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/SpecialMethodsCompletionTest.java
index 9d87dc6da4..6c6117cd06 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/SpecialMethodsCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/SpecialMethodsCompletionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,29 +15,22 @@ package org.eclipse.jdt.text.tests.contentassist;
import java.util.Hashtable;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
/**
*
* @since 3.2
*/
public class SpecialMethodsCompletionTest extends AbstractCompletionTest {
- private static final Class<SpecialMethodsCompletionTest> THIS= SpecialMethodsCompletionTest.class;
-
- public static Test setUpTest(Test test) {
- return new CompletionTestSetup(test);
- }
-
- public static Test suite() {
- return setUpTest(new TestSuite(THIS, suiteName(THIS)));
- }
+ @Rule
+ public CompletionTestSetup cts= new CompletionTestSetup();
/*
* @see org.eclipse.jdt.text.tests.contentassist.AbstractCompletionTest#setUp()
*/
@Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
}
@@ -49,6 +42,7 @@ public class SpecialMethodsCompletionTest extends AbstractCompletionTest {
super.configureCoreOptions(options);
}
+ @Test
public void testInheritedMethod() throws Exception {
assertTypeBodyProposal("toS|", "toString(", "/* (non-Javadoc)\n" +
" * @see java.lang.Object#toString()\n" +
@@ -60,6 +54,7 @@ public class SpecialMethodsCompletionTest extends AbstractCompletionTest {
" }|");
}
+ @Test
public void testMethodCreation() throws Exception {
assertTypeBodyProposal("foobar|", "foobar(", "/**\n" +
" * Method.\n" +
@@ -70,6 +65,7 @@ public class SpecialMethodsCompletionTest extends AbstractCompletionTest {
" }|");
}
+ @Test
public void testGetterCreation() throws Exception {
addMembers("String test;");
assertTypeBodyProposal("get|", "getTest(", "/**\n" +
@@ -80,6 +76,7 @@ public class SpecialMethodsCompletionTest extends AbstractCompletionTest {
" }|");
}
+ @Test
public void testConstGetterCreation() throws Exception {
addMembers("static final String TEST;");
assertTypeBodyProposal("get|", "getTest(", "/**\n" +
@@ -91,6 +88,7 @@ public class SpecialMethodsCompletionTest extends AbstractCompletionTest {
}
+ @Test
public void testDuplicateGetterCreation() throws Exception {
addMembers("static final String TEST;");
addMembers("String test;");
@@ -102,6 +100,7 @@ public class SpecialMethodsCompletionTest extends AbstractCompletionTest {
" }|");
}
+ @Test
public void testSetterCreation() throws Exception {
addMembers("String test;");
assertTypeBodyProposal("set|", "setTest(", "/**\n" +
@@ -112,6 +111,7 @@ public class SpecialMethodsCompletionTest extends AbstractCompletionTest {
" }|");
}
+ @Test
public void testNoFinalSetterCreation() throws Exception {
addMembers("final String test;");
assertNoTypeBodyProposal("set|", "setTest(");
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/TypeCompletionTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/TypeCompletionTest.java
index e1db9d75c2..01a941c466 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/TypeCompletionTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/TypeCompletionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2015 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
@@ -22,62 +22,60 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.PreferenceConstants;
-
/**
* @since 3.2
*/
public class TypeCompletionTest extends AbstractCompletionTest {
-
- private static final Class<TypeCompletionTest> THIS= TypeCompletionTest.class;
-
- public static Test setUpTest(Test test) {
- return new CompletionTestSetup(test);
- }
-
- public static Test suite() {
- return setUpTest(new TestSuite(THIS, suiteName(THIS)));
- }
+ @Rule
+ public CompletionTestSetup cts= new CompletionTestSetup();
/*
* @see org.eclipse.jdt.text.tests.contentassist.AbstractCompletionTest#setUp()
*/
@Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, true);
getJDTUIPrefs().setValue(PreferenceConstants.EDITOR_CLOSE_BRACKETS, true);
}
+ @Test
public void testJavaLang() throws Exception {
assertMethodBodyProposal("S|", "String ", "String|");
}
+ @Test
public void testImported() throws Exception {
addImport("java.util.Random");
expectImport("java.util.Random");
assertMethodBodyProposal("R|", "Random ", "Random|");
}
+ @Test
public void testAutoImport() throws Exception {
expectImport("java.util.Random");
assertMethodBodyProposal("R|", "Random ", "Random|");
}
+ @Test
public void testNoAutoImportForQualifiedPrefix() throws Exception {
assertMethodBodyProposal("java.util.R|", "Random ", "java.util.Random|");
}
+ @Test
public void testNoQualifierRemovalForQualifiedPrefix() throws Exception {
addImport("java.util.Random");
expectImport("java.util.Random");
assertMethodBodyProposal("java.util.R|", "Random ", "java.util.Random|");
}
+ @Test
public void testAutoQualify() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_ADDIMPORT, false);
assertMethodBodyProposal("R|", "Random ", "java.util.Random|");
}
+ @Test
public void testNoAutoQualifyWithImport() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_ADDIMPORT, false);
addImport("java.util.Random");
@@ -85,6 +83,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyProposal("R|", "Random ", "Random|");
}
+ @Test
public void testNoQualifierRemovalWithImport() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_ADDIMPORT, false);
addImport("java.util.Random");
@@ -92,6 +91,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyProposal("java.util.R|", "Random ", "java.util.Random|");
}
+ @Test
public void testAutoImportZeroPrefix() throws Exception {
addImport("java.util.Random");
expectImport("java.util.Random");
@@ -100,6 +100,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyProposal("Random r= new |", "Random ", "Random r= new Random|"); // tests RHS cache
}
+ @Test
public void testInnerImportedType() throws Exception {
waitBeforeCompleting(true);
addImport("java.security.KeyStore");
@@ -108,29 +109,34 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyProposal("Entry|", "Entry - java.security.KeyStore", "Entry|");
}
+ @Test
public void testInnerTypeOuterImported() throws Exception {
addImport("java.security.KeyStore");
expectImport("java.security.KeyStore");
assertMethodBodyProposal("KeyStore.E|", "Entry", "KeyStore.Entry|");
}
+ @Test
public void testGenericInnerTypeOuterImported() throws Exception {
addImport("java.util.Map");
expectImport("java.util.Map");
assertMethodBodyProposal("Map.E|", "Entry", "Map.Entry<|K|, V>");
}
+ @Test
public void testInnerTypeOfGenericOuter() throws Exception {
addMembers("static class Outer<E> { class Inner {} }");
assertMethodBodyProposal("Outer<String>.I|", "Outer<java.lang.String>.Inner", "Outer<String>.Inner|");
}
+ @Test
public void testInnerTypeOfGenericOuter2() throws Exception {
addMembers("static class Outer<E> { class Inner {} }");
expectImport("test1.Completion_" + getName() + ".Outer.Inner");
assertMethodBodyProposal("Inner|", "Outer<E>.Inner", "Inner|");
}
+ @Test
public void testInnerTypeOfGenericOuterImported() throws Exception {
addMembers("static class Outer<E> { class Inner {} }");
addImport("test1.Completion_" + getName() + ".Outer");
@@ -138,6 +144,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyProposal("Outer<String>.I|", "Outer<java.lang.String>.Inner", "Outer<String>.Inner|");
}
+ @Test
public void testInnerTypeOfGenericOuterImported2() throws Exception {
addMembers("static class Outer<E> { class Inner {} }");
addImport("test1.Completion_" + getName() + ".Outer.Inner");
@@ -145,17 +152,20 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyProposal("Inner|", "Outer<E>.Inner", "Inner|");
}
+ @Test
public void testGeneric() throws Exception {
addImport("java.util.List");
expectImport("java.util.List");
assertMethodBodyProposal("L|", "List ", "List<|E|>");
}
+ @Test
public void testAutoImportGeneric() throws Exception {
expectImport("java.util.ArrayList");
assertMethodBodyProposal("A|", "ArrayList ", "ArrayList<|E|>");
}
+ @Test
public void testGenericParameterGuessingUnambiguos() throws Exception {
addImport("java.util.List");
expectImport("java.util.ArrayList");
@@ -163,6 +173,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyProposal("List<String> list= new A|", "ArrayList()", "List<String> list= new ArrayList<String>()|");
}
+ @Test
public void testGenericParameterGuessingExtends() throws Exception {
addImport("java.util.List");
expectImport("java.util.ArrayList");
@@ -170,6 +181,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyProposal("List<? extends Number> list= new A|", "ArrayList()", "List<? extends Number> list= new ArrayList<Number>()|");
}
+ @Test
public void testGenericParameterGuessingSuper() throws Exception {
addImport("java.util.List");
expectImport("java.util.ArrayList");
@@ -177,6 +189,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyProposal("List<? super Number> list= new A|", "ArrayList()", "List<? super Number> list= new ArrayList<E>()|");
}
+ @Test
public void testGenericParameterGuessingMixed() throws Exception {
addImport("java.util.Map");
expectImport("java.util.HashMap");
@@ -184,10 +197,12 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyProposal("Map<String, ? extends Number> list= new H|", "HashMap()", "Map<String, ? extends Number> list= new HashMap<String, Number>()|");
}
+ @Test
public void testNoCamelCase() throws Exception {
assertNoMethodBodyProposals("SB|", "StringBuffer ");
}
+ @Test
public void testCamelCase() throws Exception {
setCoreOption(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
@@ -197,11 +212,13 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyProposal("SB|", "StringBuffer ", "StringBuffer|");
}
+ @Test
public void testConstructorParentheses() throws Exception {
setTrigger('(');
assertMethodBodyProposal("StringBuf|", "StringBuffer ", "StringBuffer(|)");
}
+ @Test
public void testIncrementalInsertion() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_AUTOINSERT, true);
@@ -209,6 +226,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyIncrementalCompletion("Inval|", "Invalid|");
}
+ @Test
public void testNoIncrementalInsertion() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_AUTOINSERT, true);
@@ -216,6 +234,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyIncrementalCompletion("String|", "String|");
}
+ @Test
public void testIncrementalInsertionPrefixCorrection() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_AUTOINSERT, true);
@@ -223,6 +242,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyIncrementalCompletion("InVa|", "Invalid|");
}
+ @Test
public void testNoIncrementalInsertionPrefixCorrection() throws Exception {
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_AUTOINSERT, true);
@@ -230,6 +250,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyIncrementalCompletion("InVaLiD|", "Invalid|");
}
+ @Test
public void testNoIncrementalInsertionCamelCase() throws Exception {
setCoreOption(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
@@ -239,6 +260,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyIncrementalCompletion("IO|", "IO|");
}
+ @Test
public void testIncrementalInsertionCamelCase() throws Exception {
setCoreOption(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
@@ -248,6 +270,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyIncrementalCompletion("JaEn|", "JarEntry|");
}
+ @Test
public void testNoIncrementalInsertionCamelCase2() throws Exception {
setCoreOption(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
@@ -258,6 +281,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyIncrementalCompletion("JaE|", "JaE|");
}
+ @Test
public void testIncrementalInsertionCamelCase2() throws Exception {
setCoreOption(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED);
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, true);
@@ -267,6 +291,7 @@ public class TypeCompletionTest extends AbstractCompletionTest {
assertMethodBodyIncrementalCompletion("IOExce|", "IOException|");
}
+ @Test
public void testBug182468() throws Exception {
IPackageFragmentRoot src= (IPackageFragmentRoot)CompletionTestSetup.getTestPackage().getParent();
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/TypeCompletionTest17.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/TypeCompletionTest1d7.java
index a2433cdc8c..95d27eca1a 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/TypeCompletionTest17.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/TypeCompletionTest1d7.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2011, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.text.tests.contentassist;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.core.runtime.CoreException;
@@ -23,27 +23,20 @@ import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.ui.PreferenceConstants;
-
/**
+ * Those tests should run on Java Dolphin 1.7 .
+ *
* @since 3.7
*/
-public class TypeCompletionTest17 extends TypeCompletionTest {
-
- private static final Class<TypeCompletionTest17> THIS= TypeCompletionTest17.class;
-
- public static Test setUpTest(Test test) {
- return new Java17CompletionTestSetup(test);
- }
-
- public static Test suite() {
- return setUpTest(new TestSuite(THIS, suiteName(THIS)));
- }
+public class TypeCompletionTest1d7 extends TypeCompletionTest {
+ @Rule
+ public Java1d7CompletionTestSetup cts= new Java1d7CompletionTestSetup();
/*
* @see org.eclipse.jdt.text.tests.contentassist.AbstractCompletionTest#setUp()
*/
@Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
getJDTUIPrefs().setValue(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, true);
getJDTUIPrefs().setValue(PreferenceConstants.EDITOR_CLOSE_BRACKETS, true);
@@ -51,10 +44,11 @@ public class TypeCompletionTest17 extends TypeCompletionTest {
@Override
protected IPackageFragment getAnonymousTestPackage() throws CoreException {
- return Java17CompletionTestSetup.getAnonymousTestPackage();
+ return Java1d7CompletionTestSetup.getAnonymousTestPackage();
}
@Override
+ @Test
public void testGenericParameterGuessingUnambiguos() throws Exception {
addImport("java.util.List");
expectImport("java.util.ArrayList");
@@ -63,6 +57,7 @@ public class TypeCompletionTest17 extends TypeCompletionTest {
}
@Override
+ @Test
public void testGenericParameterGuessingExtends() throws Exception {
addImport("java.util.List");
expectImport("java.util.ArrayList");
@@ -71,6 +66,7 @@ public class TypeCompletionTest17 extends TypeCompletionTest {
}
@Override
+ @Test
public void testGenericParameterGuessingSuper() throws Exception {
addImport("java.util.List");
expectImport("java.util.ArrayList");
@@ -79,6 +75,7 @@ public class TypeCompletionTest17 extends TypeCompletionTest {
}
@Override
+ @Test
public void testGenericParameterGuessingMixed() throws Exception {
addImport("java.util.Map");
expectImport("java.util.HashMap");
@@ -87,8 +84,9 @@ public class TypeCompletionTest17 extends TypeCompletionTest {
}
@Override
+ @Test
public void testBug182468() throws Exception {
- IPackageFragmentRoot src= (IPackageFragmentRoot)Java17CompletionTestSetup.getTestPackage().getParent();
+ IPackageFragmentRoot src= (IPackageFragmentRoot)Java1d7CompletionTestSetup.getTestPackage().getParent();
IPackageFragment package1= src.createPackageFragment("package1", true, null);
package1.createCompilationUnit("AClass.java", "package " + package1.getElementName() + "; public class AClass {}", true, null);
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/EditorTestHelper.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/EditorTestHelper.java
index 7227d32b6f..ef7cfb4cd8 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/EditorTestHelper.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/EditorTestHelper.java
@@ -519,4 +519,7 @@ public class EditorTestHelper {
addJavaFiles(subDir, collection);
}
}
+
+ private EditorTestHelper() {
+ }
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/InvocationCountExampleTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/InvocationCountExampleTest.java
index 6ac78523e1..083a57d705 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/InvocationCountExampleTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/InvocationCountExampleTest.java
@@ -33,8 +33,8 @@ public class InvocationCountExampleTest extends TestCase {
public void test() throws Exception {
InvocationCountPerformanceMeter performanceMeter= new InvocationCountPerformanceMeter(Performance.getDefault().getDefaultScenarioId(this), new Method[] {
- Double.class.getDeclaredMethod("hashCode", new Class[] { }),
- Double.class.getDeclaredMethod("equals", new Class[] { Object.class }),
+ Double.class.getDeclaredMethod("hashCode"),
+ Double.class.getDeclaredMethod("equals", Object.class),
});
try {
Set<Double> set= new HashSet<>();
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/InvocationCountPerformanceMeter.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/InvocationCountPerformanceMeter.java
index bedc374f04..155e2c39fd 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/InvocationCountPerformanceMeter.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/InvocationCountPerformanceMeter.java
@@ -392,9 +392,7 @@ public class InvocationCountPerformanceMeter extends InternalPerformanceMeter {
fEventReader= new EventReader(fVM.eventQueue());
fEventReader.start();
- } catch (IOException x) {
- x.printStackTrace();
- } catch (IllegalConnectorArgumentsException x) {
+ } catch (IOException | IllegalConnectorArgumentsException x) {
x.printStackTrace();
} finally {
Assert.assertNotNull("Could not start performance meter, hints:\n1) check the command line arguments (see InvocationCountPerformanceMeter for details)\n2) use a different port number", fEventReader);
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/OpenJavaEditorInvocationCountTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/OpenJavaEditorInvocationCountTest.java
index 9720096ca1..ea80ff616c 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/OpenJavaEditorInvocationCountTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/OpenJavaEditorInvocationCountTest.java
@@ -53,7 +53,7 @@ public class OpenJavaEditorInvocationCountTest extends OpenEditorTest {
public void test() throws Exception {
InvocationCountPerformanceMeter performanceMeter= createInvocationCountPerformanceMeter(new Method[] {
- PresentationReconciler.class.getDeclaredMethod("createPresentation", new Class[] { IRegion.class, IDocument.class }),
+ PresentationReconciler.class.getDeclaredMethod("createPresentation", IRegion.class, IDocument.class),
// AnnotationRulerColumn.class.getDeclaredMethod("doPaint1", new Class[] { GC.class }),
// AbstractDocument.class.getDeclaredMethod("get", new Class[] { }),
});
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/PerfTestSuite.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/PerfTestSuite.java
index 4962abd9f4..f2d73c0e46 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/PerfTestSuite.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/PerfTestSuite.java
@@ -113,7 +113,7 @@ public class PerfTestSuite extends TestSuite {
if (test instanceof TestCase)
((TestCase) test).setName(name);
} else {
- test= constructor.newInstance(new Object[]{name});
+ test= constructor.newInstance(name);
}
} catch (InstantiationException e) {
return(warning("Cannot instantiate test case: "+name+" ("+exceptionToString(e)+")")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/PerformanceTestCase2.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/PerformanceTestCase2.java
index 3cb53380d9..a444897f13 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/PerformanceTestCase2.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/PerformanceTestCase2.java
@@ -62,7 +62,7 @@ public class PerformanceTestCase2 extends TestCase {
// methods. getDeclaredMethods returns all
// methods of this class but excludes the
// inherited ones.
- runMethod= getClass().getMethod(getName(), new Class[] {PerformanceMeter.class});
+ runMethod= getClass().getMethod(getName(), PerformanceMeter.class);
} catch (NoSuchMethodException e) {
fail("Method \""+getName()+"\" not found"); //$NON-NLS-1$//$NON-NLS-2$
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/SWTEventHelper.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/SWTEventHelper.java
index 64adf69048..0157ba2c70 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/SWTEventHelper.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/SWTEventHelper.java
@@ -141,4 +141,7 @@ public class SWTEventHelper {
fgMouseButtonEvent.button= button;
postEvent(display, fgMouseButtonEvent, runEventQueue);
}
+
+ private SWTEventHelper() {
+ }
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/ScrollAnnotatedJavaEditorInvocationCountTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/ScrollAnnotatedJavaEditorInvocationCountTest.java
index 3f320047af..c9eba6a08f 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/ScrollAnnotatedJavaEditorInvocationCountTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/ScrollAnnotatedJavaEditorInvocationCountTest.java
@@ -95,7 +95,7 @@ public class ScrollAnnotatedJavaEditorInvocationCountTest extends AbstractScroll
private InvocationCountPerformanceMeter createInvocationCountPerformanceMeter() throws NoSuchMethodException {
return createInvocationCountPerformanceMeter(new Method[] {
- AnnotationPainter.class.getMethod("paintControl", new Class[] { PaintEvent.class }),
+ AnnotationPainter.class.getMethod("paintControl", PaintEvent.class),
});
}
}
diff --git a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/TypingInvocationCountTest.java b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/TypingInvocationCountTest.java
index c40a345d02..6c4fbfcf71 100644
--- a/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/TypingInvocationCountTest.java
+++ b/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/performance/TypingInvocationCountTest.java
@@ -238,7 +238,7 @@ public abstract class TypingInvocationCountTest extends TextPerformanceTestCase
private void measure(int line, int column, char ch, boolean sendKeyCode) throws Exception {
InvocationCountPerformanceMeter performanceMeter= createInvocationCountPerformanceMeter(new Method[] {
- AnnotationPainter.class.getMethod("paintControl", new Class[] { PaintEvent.class }),
+ AnnotationPainter.class.getMethod("paintControl", PaintEvent.class),
});
performanceMeter.setTimeout(30000);
int offset= EditorTestHelper.getDocument(fEditor).getLineOffset(line) + column;
diff --git a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jsp/launching/TomcatLaunchDelegate.java b/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jsp/launching/TomcatLaunchDelegate.java
index 3772cb5330..3ddc7c862a 100644
--- a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jsp/launching/TomcatLaunchDelegate.java
+++ b/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jsp/launching/TomcatLaunchDelegate.java
@@ -73,7 +73,7 @@ public class TomcatLaunchDelegate extends JavaLaunchDelegate {
if (file.exists() && file.isDirectory()) {
return home;
} else {
- err = new Status(IStatus.ERROR, JspUIPlugin.getDefault().getBundle().getSymbolicName(), 0, MessageFormat.format(LaunchingMessages.TomcatLaunchDelegate_7, new String[]{home}), null);
+ err = new Status(IStatus.ERROR, JspUIPlugin.getDefault().getBundle().getSymbolicName(), 0, MessageFormat.format(LaunchingMessages.TomcatLaunchDelegate_7, home), null);
}
} else {
err = new Status(IStatus.ERROR, JspUIPlugin.getDefault().getBundle().getSymbolicName(), 0, LaunchingMessages.TomcatLaunchDelegate_8, null);
diff --git a/org.eclipse.jdt.ui.examples.projects/examples/org/eclipse/jdt/internal/ui/exampleprojects/ExampleProjectCreationWizard.java b/org.eclipse.jdt.ui.examples.projects/examples/org/eclipse/jdt/internal/ui/exampleprojects/ExampleProjectCreationWizard.java
index df8e3ad58f..b2e21e46ff 100644
--- a/org.eclipse.jdt.ui.examples.projects/examples/org/eclipse/jdt/internal/ui/exampleprojects/ExampleProjectCreationWizard.java
+++ b/org.eclipse.jdt.ui.examples.projects/examples/org/eclipse/jdt/internal/ui/exampleprojects/ExampleProjectCreationWizard.java
@@ -166,7 +166,7 @@ public class ExampleProjectCreationWizard extends Wizard implements INewWizard,
final int[] result= { IDialogConstants.CANCEL_ID };
getShell().getDisplay().syncExec(() -> {
String title= ExampleProjectMessages.ExampleProjectCreationWizard_overwritequery_title;
- String msg= MessageFormat.format(ExampleProjectMessages.ExampleProjectCreationWizard_overwritequery_message, new Object[] {file});
+ String msg= MessageFormat.format(ExampleProjectMessages.ExampleProjectCreationWizard_overwritequery_message, file);
String[] options= {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL};
MessageDialog dialog= new MessageDialog(getShell(), title, null, msg, MessageDialog.QUESTION, options, 0);
result[0]= dialog.open();
diff --git a/org.eclipse.jdt.ui.examples.projects/pom.xml b/org.eclipse.jdt.ui.examples.projects/pom.xml
index be2a900a11..649207b6c2 100644
--- a/org.eclipse.jdt.ui.examples.projects/pom.xml
+++ b/org.eclipse.jdt.ui.examples.projects/pom.xml
@@ -14,7 +14,7 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.ui.examples.projects</artifactId>
diff --git a/org.eclipse.jdt.ui.tests.refactoring/META-INF/MANIFEST.MF b/org.eclipse.jdt.ui.tests.refactoring/META-INF/MANIFEST.MF
index cdd318fa1f..68947ba033 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.ui.tests.refactoring/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.ui.tests.refactoring
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.jdt.ui.tests.refactoring; singleton:=true
-Bundle-Version: 3.13.900.qualifier
+Bundle-Version: 3.13.1000.qualifier
Bundle-Activator: org.eclipse.jdt.ui.tests.refactoring.infra.RefactoringTestPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Plugin.providerName
diff --git a/org.eclipse.jdt.ui.tests.refactoring/pom.xml b/org.eclipse.jdt.ui.tests.refactoring/pom.xml
index f53c30d688..714b9b26d2 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/pom.xml
+++ b/org.eclipse.jdt.ui.tests.refactoring/pom.xml
@@ -14,12 +14,12 @@
<parent>
<artifactId>tests-pom</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
<relativePath>../tests-pom/</relativePath>
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.ui.tests.refactoring</artifactId>
- <version>3.13.900-SNAPSHOT</version>
+ <version>3.13.1000-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test111/in/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test111/in/A.java
new file mode 100644
index 0000000000..d9ccdbb83a
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test111/in/A.java
@@ -0,0 +1,5 @@
+package p;
+
+class A {
+ A[] a= new A[1];
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test111/out/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test111/out/A.java
new file mode 100644
index 0000000000..1af645c448
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test111/out/A.java
@@ -0,0 +1,5 @@
+package p;
+
+class A implements I {
+ I[] a= new A[1];
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test111/out/I.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test111/out/I.java
new file mode 100644
index 0000000000..0854634118
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test111/out/I.java
@@ -0,0 +1,6 @@
+package p;
+
+/** typecomment template*/
+interface I {
+
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test112/in/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test112/in/A.java
new file mode 100644
index 0000000000..a4f8238a1f
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test112/in/A.java
@@ -0,0 +1,5 @@
+package p;
+
+class A<T> {
+ A<?>[] a= new A<?>[1];
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test112/out/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test112/out/A.java
new file mode 100644
index 0000000000..9666ee16bc
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test112/out/A.java
@@ -0,0 +1,5 @@
+package p;
+
+class A<T> implements I<T> {
+ I<?>[] a= new A<?>[1];
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test112/out/I.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test112/out/I.java
new file mode 100644
index 0000000000..2cbd0edeb9
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test112/out/I.java
@@ -0,0 +1,6 @@
+package p;
+
+/** typecomment template*/
+interface I<T> {
+
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_in/A_test628.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_in/A_test628.java
index 12358640a3..81834aa2d1 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_in/A_test628.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_in/A_test628.java
@@ -1,6 +1,6 @@
package expression_in;
-public class A_test627 {
+public class A_test628 {
public void foo() {
int i= 1 - (/*[*/(2 + 3)/*]*/);
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_in/A_test629.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_in/A_test629.java
index 9867644c25..8b8b4d7eef 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_in/A_test629.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_in/A_test629.java
@@ -1,9 +1,9 @@
package expression_in;
-public class A_test627 {
+public class A_test629 {
public void foo() {
int i= 1 - /*[*/((2 + 3))/*]*/;
int j= 1 - ((2 + 3));
- }
+ }
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test627.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test627.java
index b6ec0a1aac..44231f297b 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test627.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test627.java
@@ -3,8 +3,8 @@ package expression_out;
public class A_test627 {
public void foo() {
- int i= 1 - (extracted());
- int j= 1 - (extracted());
+ int i= 1 - extracted();
+ int j= 1 - extracted();
}
protected int extracted() {
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test628.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test628.java
index 454b59854d..3ab6fc4b5e 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test628.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test628.java
@@ -1,6 +1,6 @@
package expression_out;
-public class A_test627 {
+public class A_test628 {
public void foo() {
int i= 1 - extracted();
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test629.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test629.java
index 5c546e79d8..8ff3a3c72a 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test629.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractMethodWorkSpace/ExtractMethodTests/expression_out/A_test629.java
@@ -1,6 +1,6 @@
package expression_out;
-public class A_test627 {
+public class A_test629 {
public void foo() {
int i= 1 - extracted();
@@ -8,6 +8,6 @@ public class A_test627 {
}
protected int extracted() {
- return (2 + 3);
- }
+ return 2 + 3;
+ }
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/IntroduceParameter/simple/out/Expression5.java b/org.eclipse.jdt.ui.tests.refactoring/resources/IntroduceParameter/simple/out/Expression5.java
index 30c784dab5..bc52c7ee5a 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/resources/IntroduceParameter/simple/out/Expression5.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/IntroduceParameter/simple/out/Expression5.java
@@ -7,6 +7,6 @@ public class Expression5 {
int a= 1 - first;
}
public void use() {
- m((2 + 3));
+ m(2 + 3);
}
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/A.java
new file mode 100644
index 0000000000..2236fa818b
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/A.java
@@ -0,0 +1,14 @@
+package p;
+record A(int f){
+ A{
+ this.f= f;
+ }
+
+ public void val(int f) {
+
+ }
+
+ public int getVal() {
+ return f();
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/B.java b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/B.java
new file mode 100644
index 0000000000..22d06fee6b
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/B.java
@@ -0,0 +1,8 @@
+package p;
+class B{
+
+ public int val() {
+ A a= new A(10);
+ return a.f();
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/C.java b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/C.java
new file mode 100644
index 0000000000..3e2d1be2ca
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/C.java
@@ -0,0 +1,8 @@
+package p;
+class C{
+
+ public int val2() {
+ A a= new A(40);
+ return a.f();
+ }
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/D.java b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/D.java
new file mode 100644
index 0000000000..e4fdc829b9
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/in/D.java
@@ -0,0 +1,19 @@
+package p;
+record D(int f){
+ A{
+ this.f= f;
+ }
+
+ public void val(int f) {
+
+ }
+
+ public int getVal() {
+ return f();
+ }
+
+ public static void val() {
+ D d= new D(20);
+ return d.f();
+ }
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/A.java
new file mode 100644
index 0000000000..10ffd7bf0a
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/A.java
@@ -0,0 +1,14 @@
+package p;
+record A(int g){
+ A{
+ this.g= g;
+ }
+
+ public void val(int f) {
+
+ }
+
+ public int getVal() {
+ return g();
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/B.java b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/B.java
new file mode 100644
index 0000000000..4510a323d5
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/B.java
@@ -0,0 +1,8 @@
+package p;
+class B{
+
+ public int val() {
+ A a= new A(10);
+ return a.g();
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/C.java b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/C.java
new file mode 100644
index 0000000000..5d0011a362
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/C.java
@@ -0,0 +1,8 @@
+package p;
+class C{
+
+ public int val2() {
+ A a= new A(40);
+ return a.g();
+ }
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/D.java b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/D.java
new file mode 100644
index 0000000000..e4fdc829b9
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/RenameRecordElements/testRenameRecordCompactConstructorImplicitAccessor2/out/D.java
@@ -0,0 +1,19 @@
+package p;
+record D(int f){
+ A{
+ this.f= f;
+ }
+
+ public void val(int f) {
+
+ }
+
+ public int getVal() {
+ return f();
+ }
+
+ public static void val() {
+ D d= new D(20);
+ return d.f();
+ }
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AbstractJunit4SelectionTestCase.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AbstractJunit4SelectionTestCase.java
index 50d5a8ff56..c9d5f0d3e6 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AbstractJunit4SelectionTestCase.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AbstractJunit4SelectionTestCase.java
@@ -59,9 +59,7 @@ public abstract class AbstractJunit4SelectionTestCase extends AbstractJunit4CUTe
public static final String SQUARE_BRACKET_CLOSE= "/*]*/";
public static final int SQUARE_BRACKET_CLOSE_LENGTH= SQUARE_BRACKET_CLOSE.length();
- protected static final int VALID_SELECTION= 1;
- protected static final int INVALID_SELECTION= 2;
- protected static final int COMPARE_WITH_OUTPUT= 3;
+ enum TestMode { VALID_SELECTION, INVALID_SELECTION, COMPARE_WITH_OUTPUT }
private boolean fIgnoreSelectionMarker;
private int[] fSelection;
@@ -105,7 +103,7 @@ public abstract class AbstractJunit4SelectionTestCase extends AbstractJunit4CUTe
return result;
}
- protected void performTest(final ICompilationUnit unit, final Refactoring refactoring, int mode, final String out, boolean doUndo) throws Exception {
+ protected void performTest(final ICompilationUnit unit, final Refactoring refactoring, TestMode mode, final String out, boolean doUndo) throws Exception {
IProgressMonitor pm= new NullProgressMonitor();
switch (mode) {
case VALID_SELECTION:
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AbstractSelectionTestCase.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AbstractSelectionTestCase.java
deleted file mode 100644
index e23d2a5b52..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AbstractSelectionTestCase.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.TextSelection;
-
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.CheckConditionsOperation;
-import org.eclipse.ltk.core.refactoring.IUndoManager;
-import org.eclipse.ltk.core.refactoring.PerformRefactoringOperation;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.RefactoringCore;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.JavaCore;
-
-import org.eclipse.jdt.ui.tests.refactoring.infra.AbstractCUTestCase;
-import org.eclipse.jdt.ui.tests.refactoring.infra.RefactoringTestPlugin;
-
-/**
- * Selection in the file read by {@link #getFileContents(InputStream)} is marked with
- * /*]*&#47; and /*[*&#47; (excluding the marker comments) or
- * /*[*&#47; and /*]*&#47; (including comments).
- */
-public abstract class AbstractSelectionTestCase extends AbstractCUTestCase {
-
- public static final String SQUARE_BRACKET_OPEN= "/*[*/";
- public static final int SQUARE_BRACKET_OPEN_LENGTH= SQUARE_BRACKET_OPEN.length();
- public static final String SQUARE_BRACKET_CLOSE= "/*]*/";
- public static final int SQUARE_BRACKET_CLOSE_LENGTH= SQUARE_BRACKET_CLOSE.length();
-
- protected static final int VALID_SELECTION= 1;
- protected static final int INVALID_SELECTION= 2;
- protected static final int COMPARE_WITH_OUTPUT= 3;
-
- private boolean fIgnoreSelectionMarker;
- private int[] fSelection;
- protected boolean fIsPreDeltaTest;
-
- public AbstractSelectionTestCase(String name) {
- this(name, false);
- }
-
- public AbstractSelectionTestCase(String name, boolean ignoreSelectionMarker) {
- super(name);
- fIgnoreSelectionMarker= ignoreSelectionMarker;
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- fIsPreDeltaTest= false;
- }
-
- protected int[] getSelection() {
- return fSelection;
- }
-
- protected ITextSelection getTextSelection() {
- int[] s= getSelection();
- return new TextSelection(s[0], s[1]);
- }
-
- @Override
- protected InputStream getFileInputStream(String fileName) throws IOException {
- return RefactoringTestPlugin.getDefault().getTestResourceStream(fileName);
- }
-
- @Override
- protected String getFileContents(InputStream in) throws IOException {
- String result= super.getFileContents(in);
- initializeSelection(result);
- if (fIgnoreSelectionMarker) {
- result= result.replaceAll("/\\*\\[\\*/", "");
- result= result.replaceAll("/\\*\\]\\*/", "");
- }
- return result;
- }
-
- protected void performTest(final ICompilationUnit unit, final Refactoring refactoring, int mode, final String out, boolean doUndo) throws Exception {
- IProgressMonitor pm= new NullProgressMonitor();
- switch (mode) {
- case VALID_SELECTION:
- assertTrue(checkPreconditions(refactoring, pm).isOK());
- break;
- case INVALID_SELECTION:
- assertTrue(!checkPreconditions(refactoring, pm).isOK());
- break;
- case COMPARE_WITH_OUTPUT:
- IUndoManager undoManager= RefactoringCore.getUndoManager();
- undoManager.flush();
- String original= unit.getSource();
-
- final PerformRefactoringOperation op= new PerformRefactoringOperation(
- refactoring, getCheckingStyle());
- if (fIsPreDeltaTest) {
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- IResourceChangeListener listener= new IResourceChangeListener() {
- @Override
- public void resourceChanged(IResourceChangeEvent event) {
- TestModelProvider.assertTrue(event.getDelta());
- }
- };
- try {
- clearPreDelta();
- workspace.checkpoint(false);
- workspace.addResourceChangeListener(listener);
- JavaCore.run(op, new NullProgressMonitor());
- } finally {
- workspace.removeResourceChangeListener(listener);
- }
- } else {
- JavaCore.run(op, new NullProgressMonitor());
- }
- assertTrue("Precondition check failed: " + op.getConditionStatus().toString(), !op.getConditionStatus().hasFatalError());
- assertTrue("Validation check failed: " + op.getConditionStatus().toString(), !op.getValidationStatus().hasFatalError());
- assertNotNull("No Undo", op.getUndoChange());
- compareSource(unit.getSource(), out);
- Change undo= op.getUndoChange();
- assertNotNull("Undo doesn't exist", undo);
- assertTrue("Undo manager is empty", undoManager.anythingToUndo());
-
- if (doUndo) {
- undoManager.performUndo(null, new NullProgressMonitor());
- assertTrue("Undo manager still has undo", !undoManager.anythingToUndo());
- assertTrue("Undo manager is empty", undoManager.anythingToRedo());
- compareSource(original, unit.getSource());
- }
- break;
- default:
- break;
- }
- }
-
- protected RefactoringStatus checkPreconditions(Refactoring refactoring, IProgressMonitor pm) throws CoreException {
- CheckConditionsOperation op= new CheckConditionsOperation(refactoring, getCheckingStyle());
- op.run(pm);
- return op.getStatus();
- }
-
- protected int getCheckingStyle() {
- return CheckConditionsOperation.ALL_CONDITIONS;
- }
-
- protected void clearPreDelta() {
- TestModelProvider.clearDelta();
- }
-
- private void initializeSelection(String source) {
- int start= -1;
- int end= -1;
- int includingStart= source.indexOf(SQUARE_BRACKET_OPEN);
- int excludingStart= source.indexOf(SQUARE_BRACKET_CLOSE);
- int includingEnd= source.lastIndexOf(SQUARE_BRACKET_CLOSE);
- int excludingEnd= source.lastIndexOf(SQUARE_BRACKET_OPEN);
-
- if (includingStart > excludingStart && excludingStart != -1) {
- includingStart= -1;
- } else if (excludingStart > includingStart && includingStart != -1) {
- excludingStart= -1;
- }
-
- if (includingEnd < excludingEnd) {
- includingEnd= -1;
- } else if (excludingEnd < includingEnd) {
- excludingEnd= -1;
- }
-
- if (includingStart != -1) {
- start= includingStart;
- } else {
- start= excludingStart + SQUARE_BRACKET_CLOSE_LENGTH;
- }
-
- if (excludingEnd != -1) {
- end= excludingEnd;
- } else {
- end= includingEnd + SQUARE_BRACKET_CLOSE_LENGTH;
- }
-
- assertTrue("Selection invalid", start >= 0 && end >= 0 && end >= start);
-
- fSelection= new int[] {
- start - (fIgnoreSelectionMarker ? SQUARE_BRACKET_CLOSE_LENGTH : 0),
- end - start
- };
- // System.out.println("|"+ source.substring(result[0], result[0] + result[1]) + "|");
- }
-}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AllRefactoringTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AllRefactoringTests.java
index 874f513c13..7ce00f75e8 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AllRefactoringTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AllRefactoringTests.java
@@ -19,45 +19,45 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
RenameTests18.class,
- InlineTempTests18.class,
- InlineConstantTests18.class,
+ InlineTempTests1d8.class,
+ InlineConstantTests1d8.class,
//--code
ExtractMethodTests.class,
- ExtractMethodTests17.class,
- ExtractMethodTests18.class,
+ ExtractMethodTests1d7.class,
+ ExtractMethodTests1d8.class,
InlineMethodTests.class,
- InlineMethodTests18.class,
+ InlineMethodTests1d8.class,
ReplaceInvocationsTests.class,
SefTests.class,
InlineTempTests.class,
- InlineTempTests17.class,
+ InlineTempTests1d7.class,
ExtractTempTests.class,
- ExtractTempTests17.class,
- ExtractTempTests18.class,
+ ExtractTempTests1d7.class,
+ ExtractTempTests1d8.class,
RenameTempTests.class,
ExtractConstantTests.class,
PromoteTempToFieldTests.class,
- PromoteTempToFieldTests18.class,
+ PromoteTempToFieldTests1d8.class,
ConvertAnonymousToNestedTests.class,
- ConvertAnonymousToNestedTests18.class,
+ ConvertAnonymousToNestedTests1d8.class,
InlineConstantTests.class,
- InlineConstantTests17.class,
+ InlineConstantTests1d7.class,
IntroduceParameterTests.class,
- IntroduceParameterTests17.class,
+ IntroduceParameterTests1d7.class,
IntroduceFactoryTests.class,
//-- structure
ChangeSignatureTests.class,
- ChangeSignatureTests18.class,
+ ChangeSignatureTests1d8.class,
IntroduceParameterObjectTests.class,
PullUpTests.class,
- PullUpTests18.class,
+ PullUpTests1d8.class,
PushDownTests.class,
MoveMembersTests.class,
- MoveMembersTests18.class,
+ MoveMembersTests1d8.class,
ExtractInterfaceTests.class,
- ExtractInterfaceTests18.class,
+ ExtractInterfaceTests1d8.class,
ExtractSupertypeTests.class,
MoveInnerToTopLevelTests.class,
UseSupertypeWherePossibleTests.class,
@@ -73,16 +73,16 @@ import org.junit.runners.Suite;
RenameStaticMethodTests.class,
RenameParametersTests.class,
MoveInstanceMethodTests.class,
- MoveInstanceMethodTests18.class,
+ MoveInstanceMethodTests1d8.class,
IntroduceIndirectionTests.class,
- IntroduceIndirectionTests17.class,
- IntroduceIndirectionTests18.class,
+ IntroduceIndirectionTests1d7.class,
+ IntroduceIndirectionTests1d8.class,
//--types
RenameTypeTests.class,
RenameTypeParameterTests.class,
ChangeTypeRefactoringTests.class,
- ChangeTypeRefactoringTests17.class,
+ ChangeTypeRefactoringTests1d7.class,
//--packages
RenamePackageTests.class,
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AllTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AllTests.java
index 8a41bc6b7c..694794b6c2 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AllTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/AllTests.java
@@ -24,8 +24,8 @@ import org.junit.runners.Suite;
PathTransformationTests.class,
RefactoringScannerTests.class,
SurroundWithTests.class,
- SurroundWithTests17.class,
- SurroundWithTests18.class,
+ SurroundWithTests1d7.class,
+ SurroundWithTests1d8.class,
})
public class AllTests {
} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/BinaryReferencesTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/BinaryReferencesTests.java
index bb9ca33ac0..f2eb74099f 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/BinaryReferencesTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/BinaryReferencesTests.java
@@ -21,7 +21,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
import org.eclipse.core.runtime.CoreException;
@@ -73,8 +73,8 @@ import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
public class BinaryReferencesTests {
private static final boolean BUG_226660= true;
- @ClassRule
- public static BinaryReferencesTestSetup fgTestSetup= new BinaryReferencesTestSetup();
+ @Rule
+ public BinaryReferencesTestSetup fgTestSetup= new BinaryReferencesTestSetup();
private static void assertContainsMatches(List<SearchMatch> matches, String[] expectedHandleIdentifiers) {
int matchCount= matches.size();
@@ -92,7 +92,7 @@ public class BinaryReferencesTests {
assertEquals("not all expected matches", expected.toString(), actual.toString());
}
- private static IType findType(String typeName) throws JavaModelException {
+ private IType findType(String typeName) throws JavaModelException {
return fgTestSetup.getSourceProject().findType(typeName);
}
@@ -178,7 +178,7 @@ public class BinaryReferencesTests {
});
}
- private static List<SearchMatch> doRenameMethod(String typeName, String methodName) throws CoreException {
+ private List<SearchMatch> doRenameMethod(String typeName, String methodName) throws CoreException {
RenameJavaElementDescriptor descriptor= RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_METHOD);
IMethod method= findMethod(findType(typeName), methodName);
descriptor.setJavaElement(method);
@@ -230,7 +230,7 @@ public class BinaryReferencesTests {
});
}
- private static List<SearchMatch> doRenameField(String typeName, String fieldName) throws CoreException {
+ private List<SearchMatch> doRenameField(String typeName, String fieldName) throws CoreException {
IField field= findType(typeName).getField(fieldName);
String refactoringID= field.isEnumConstant() ? IJavaRefactorings.RENAME_ENUM_CONSTANT : IJavaRefactorings.RENAME_FIELD;
RenameJavaElementDescriptor descriptor= RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(refactoringID);
@@ -331,7 +331,7 @@ public class BinaryReferencesTests {
});
}
- private static List<SearchMatch> doChangeSignature(String typeName, String methodName) throws JavaModelException, Exception, CoreException {
+ private List<SearchMatch> doChangeSignature(String typeName, String methodName) throws JavaModelException, Exception, CoreException {
IMethod method= findMethod(findType(typeName), methodName);
ChangeSignatureProcessor processor= new ChangeSignatureProcessor(method);
@@ -381,7 +381,7 @@ public class BinaryReferencesTests {
});
}
- private static List<SearchMatch> doInlineMethod(String typeName, String methodName) throws JavaModelException, Exception, CoreException {
+ private List<SearchMatch> doInlineMethod(String typeName, String methodName) throws JavaModelException, Exception, CoreException {
IMethod method= findMethod(findType(typeName), methodName);
ICompilationUnit cu= method.getCompilationUnit();
CompilationUnit node= new RefactoringASTParser(IASTSharedValues.SHARED_AST_LEVEL).parse(cu, true);
@@ -415,7 +415,7 @@ public class BinaryReferencesTests {
assertFalse(validationStatus.hasError());
}
- private static List<SearchMatch> doMoveType(String typeName, String newPackageName) throws CoreException {
+ private List<SearchMatch> doMoveType(String typeName, String newPackageName) throws CoreException {
IType type= findType(typeName);
IPackageFragmentRoot root= JavaModelUtil.getPackageFragmentRoot(type);
@@ -440,7 +440,7 @@ public class BinaryReferencesTests {
});
}
- private static List<SearchMatch> doMoveStaticMembers(IMember[] members, String targetTypeName) throws CoreException {
+ private List<SearchMatch> doMoveStaticMembers(IMember[] members, String targetTypeName) throws CoreException {
IType targetType= findType(targetTypeName);
MoveStaticMembersDescriptor descriptor= (MoveStaticMembersDescriptor) RefactoringCore.getRefactoringContribution(IJavaRefactorings.MOVE_STATIC_MEMBERS).createDescriptor();
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeSignatureTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeSignatureTests1d8.java
index 553d64e07d..0665c58ac2 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeSignatureTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeSignatureTests1d8.java
@@ -28,14 +28,16 @@ import org.eclipse.jdt.internal.corext.refactoring.ParameterInfo;
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class ChangeSignatureTests18 extends ChangeSignatureTests {
-
+public class ChangeSignatureTests1d8 extends ChangeSignatureTests {
@Rule
- public Java18ProjectTestSetup jps= new Java18ProjectTestSetup();
+ public Java1d8ProjectTestSetup jps= new Java1d8ProjectTestSetup();
private IJavaProject fJProject1;
@@ -46,12 +48,12 @@ public class ChangeSignatureTests18 extends ChangeSignatureTests {
@Override
public void genericafter() throws Exception {
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
@Override
public void genericbefore() throws Exception {
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
fRoot= JavaProjectHelper.addSourceContainer(fJProject1, "src");
fPackageP= fRoot.createPackageFragment("p", true, null);
fIsPreDeltaTest= false;
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeTypeRefactoringTests17.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeTypeRefactoringTests1d7.java
index 5a6d36eace..ba2418d599 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeTypeRefactoringTests17.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ChangeTypeRefactoringTests1d7.java
@@ -23,14 +23,17 @@ import org.eclipse.jdt.testplugin.StringAsserts;
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java17Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d7Setup;
import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+/**
+ * Those tests should run on Java Dolphin 1.7 .
+ */
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class ChangeTypeRefactoringTests17 extends ChangeTypeRefactoringTests {
+public class ChangeTypeRefactoringTests1d7 extends ChangeTypeRefactoringTests {
@Rule
- public RefactoringTestSetup js= new Java17Setup();
+ public RefactoringTestSetup js= new Java1d7Setup();
@Override
protected String getTestFileName(boolean positive, boolean input) {
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests1d8.java
index 6db7653f5c..8d0e6aae39 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ConvertAnonymousToNestedTests1d8.java
@@ -21,16 +21,19 @@ import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java18Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class ConvertAnonymousToNestedTests18 extends ConvertAnonymousToNestedTests {
+public class ConvertAnonymousToNestedTests1d8 extends ConvertAnonymousToNestedTests {
private static final String REFACTORING_PATH= "ConvertAnonymousToNested18/";
@Rule
- public RefactoringTestSetup js= new Java18Setup();
+ public RefactoringTestSetup js= new Java1d8Setup();
@Override
protected String getRefactoringPath() {
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractClassTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractClassTests1d8.java
index 34921d7e48..12eb2c6d55 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractClassTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractClassTests1d8.java
@@ -29,17 +29,20 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
-import org.eclipse.jdt.ui.tests.core.Java18ProjectTestSetup;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java18Setup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class ExtractClassTests18 extends ExtractClassTests {
+public class ExtractClassTests1d8 extends ExtractClassTests {
private static final String REFACTORING_PATH= "ExtractClass18/";
@Rule
- public RefactoringTestSetup rts= new Java18Setup();
+ public RefactoringTestSetup rts= new Java1d8Setup();
@Override
protected String getRefactoringPath() {
@@ -55,7 +58,7 @@ public class ExtractClassTests18 extends ExtractClassTests {
Hashtable<String, String> newOptions= new Hashtable<>(originalOptions);
newOptions.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
javaProject.setOptions(newOptions);
- JavaProjectHelper.addLibrary(javaProject, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(javaProject, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
fDescriptor.setType(setupType());
fDescriptor.setCreateGetterSetter(true);
@@ -77,7 +80,7 @@ public class ExtractClassTests18 extends ExtractClassTests {
Hashtable<String, String> newOptions= new Hashtable<>(originalOptions);
newOptions.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
javaProject.setOptions(newOptions);
- JavaProjectHelper.addLibrary(javaProject, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(javaProject, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
fDescriptor.setType(setupType());
fDescriptor.setCreateGetterSetter(true);
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests.java
index 9e2d4560f6..8e8cacc1cd 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests.java
@@ -14,8 +14,15 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.Hashtable;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -33,15 +40,11 @@ import org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactori
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.tests.refactoring.infra.TextRangeUtil;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
import org.eclipse.jdt.internal.ui.JavaPlugin;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class ExtractConstantTests extends RefactoringTest {
-
- private static final Class<ExtractConstantTests> clazz = ExtractConstantTests.class;
+public class ExtractConstantTests extends GenericRefactoringTest {
private static final String REFACTORING_PATH = "ExtractConstant/";
private static final boolean BUG_86113_ImportRewrite= true;
@@ -50,23 +53,14 @@ public class ExtractConstantTests extends RefactoringTest {
private String fCompactPref;
private boolean fAddComments;
- public ExtractConstantTests(String name) {
- super(name);
- }
+ @Rule
+ public RefactoringTestSetup rts= new RefactoringTestSetup();
@Override
protected String getRefactoringPath() {
return REFACTORING_PATH;
}
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test test) {
- return new RefactoringTestSetup(test);
- }
-
protected String getSimpleTestFileName(boolean canInline, boolean input) {
String fileName = "A_" + getName();
if (canInline)
@@ -85,8 +79,8 @@ public class ExtractConstantTests extends RefactoringTest {
}
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void genericbefore() throws Exception {
+ super.genericbefore();
Hashtable<String, String> options= JavaCore.getOptions();
String setting= DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR;
@@ -100,8 +94,8 @@ public class ExtractConstantTests extends RefactoringTest {
}
@Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ public void genericafter() throws Exception {
+ super.genericafter();
Hashtable<String, String> options= JavaCore.getOptions();
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, fCompactPref);
JavaCore.setOptions(options);
@@ -173,102 +167,127 @@ public class ExtractConstantTests extends RefactoringTest {
//--- TESTS
+ @Test
public void test0() throws Exception {
helper1(5, 16, 5, 17, true, false, "CONSTANT", "_0");
}
+ @Test
public void test1() throws Exception {
helper1(5, 16, 5, 21, false, false, "CONSTANT", "INT");
}
+ @Test
public void test2() throws Exception {
helper1(8, 16, 8, 27, false, false, "CONSTANT", "INT");
}
+ @Test
public void test3() throws Exception {
helper1(8, 16, 8, 27, true, false, "CONSTANT", "INT");
}
+ @Test
public void test4() throws Exception {
helper1(5, 23, 5, 34, true, false, "CONSTANT", "INT");
}
+ @Test
public void test5() throws Exception {
helper1(11, 20, 11, 26, true, true, "CONSTANT", "R_G");
}
+ @Test
public void test6() throws Exception {
helper1(13, 20, 13, 35, true, true, "CONSTANT", "R_F");
}
+ @Test
public void test7() throws Exception {
helper1(12, 20, 12, 28, true, true, "CONSTANT", "R_G");
}
+ @Test
public void test8() throws Exception {
helper1(8, 16, 8, 22, true, true, "CONSTANT", "INT");
}
+ @Test
public void test9() throws Exception {
helper1(6, 24, 6, 29, true, true, "CONSTANT", "INT");
}
+ @Test
public void test10() throws Exception {
helper1(8, 17, 8, 22, true, true, "CONSTANT", "INT");
}
+ @Test
public void test11() throws Exception {
helper1(10, 37, 10, 43, true, true, "CONSTANT", "INT");
}
+ @Test
public void test12() throws Exception {
helper1(9, 19, 9, 24, true, true, "CONSTANT", "INT");
}
+ @Test
public void test13() throws Exception{
helper1(9, 16, 9, 28, true, true, "CONSTANT", "F");
}
+ @Test
public void test14() throws Exception{
helper1(10, 28, 10, 44, true, true, "CONSTANT", "INT");
}
+ @Test
public void test15() throws Exception{
helper1(5, 16, 5, 25, true, false, "CONSTANT", "FRED");
}
+ @Test
public void test16() throws Exception{
helper1(5, 20, 5, 27, true, false, "CONSTANT", "RED");
}
+ @Test
public void test17() throws Exception{
helper1(5, 16, 5, 35, true, false, "CONSTANT", "YET_ANOTHER_FRED");
}
+ @Test
public void test18() throws Exception {
helper1(5, 16, 5, 17, true, false, true, "CONSTANT", "_0");
}
+ @Test
public void test19() throws Exception {
helper1(5, 23, 5, 38, false, false, "CONSTANT", "STRING");
}
+ @Test
public void test20() throws Exception {
helper1(7, 19, 7, 28, false, false, "CONSTANT", "STRING");
}
+ @Test
public void test21() throws Exception {
helper1(4, 28, 4, 37, false, false, "CONSTANT", "STRING");
}
+ @Test
public void test22() throws Exception {
helper1(9, 35, 9, 59, false, false, "ITEMS", "ARRAY_LIST");
}
+ @Test
public void test23() throws Exception {
helper1(14, 12, 14, 15, true, false, "COLOR", "RED2");
}
+ @Test
public void test24() throws Exception {
if (BUG_86113_ImportRewrite) {
printTestDisabledMessage("BUG_86113_ImportRewrite");
@@ -277,190 +296,234 @@ public class ExtractConstantTests extends RefactoringTest {
helper1(9, 28, 9, 36, true, false, "NUM", "ENUM");
}
+ @Test
public void test25() throws Exception {
helper1(5, 27, 5, 40, false, false, "DEFAULT_NAME", "JEAN_PIERRE");
}
+ @Test
public void test26() throws Exception {
helper1(6, 16, 6, 32, true, false, true, "INT", "A");
}
+ @Test
public void test27() throws Exception {
helper1(13, 14, 13, 19, true, false, false, "FOO", "FOO");
}
+ @Test
public void test28() throws Exception {
helper1(13, 14, 13, 19, true, false, false, "FOO", "FOO");
}
+ @Test
public void test29() throws Exception {
helper1(12, 19, 12, 28, false, true, "NUMBER", "NUMBER");
}
+ @Test
public void test30() throws Exception {
helper1(12, 19, 12, 28, false, true, "INTEGER", "INTEGER");
}
+ @Test
public void test31() throws Exception { //bug 104293
helper1(9, 32, 9, 44, true, false, "AS_LIST", "AS_LIST");
}
+ @Test
public void test32() throws Exception { //bug 104293
helper1(7, 20, 7, 35, true, false, "STRING", "STRING");
}
+ @Test
public void test33() throws Exception { //bug 108354
helper1(7, 20, 7, 35, true, false, "STRING", "STRING");
}
+ @Test
public void test34() throws Exception { // syntax error
if (BUG_405780)
return;
helper1(7, 20, 7, 35, true, false, "STRING", "STRING");
}
+ @Test
public void test35() throws Exception { // bug 218108
helper1(7, 20, 7, 25, true, false, "BUG", "BUG");
}
+ @Test
public void test36() throws Exception { // bug 218108
helper1(7, 20, 7, 25, true, false, "BUG", "BUG");
}
+ @Test
public void test37() throws Exception { // bug 307758
helper1(6, 17, 6, 24, true, false, "INT", "INT");
}
+ @Test
public void test38() throws Exception { // bug 317224
helper1(3, 19, 3, 24, true, false, "S_ALL", "ALL");
}
+ @Test
public void test39() throws Exception { // bug 335173
helper1(5, 21, 5, 26, false, false, "CONSTANT", "INT");
}
+ @Test
public void test40() throws Exception { // bug 335173
helper1(5, 20, 5, 27, false, false, "CONSTANT", "INT");
}
+ @Test
public void test41() throws Exception { // bug 335173
helper1(5, 22, 5, 27, false, false, "CONSTANT", "INT");
}
+ @Test
public void test42() throws Exception { // bug 335173
helper1(5, 21, 5, 28, false, false, "CONSTANT", "INT");
}
+ @Test
public void test43() throws Exception { // bug 335173
helper1(5, 20, 5, 29, false, false, "CONSTANT", "INT");
}
+ @Test
public void test44() throws Exception { // bug 211529
helper1(7, 18, 7, 19, false, false, "CONSTANT", "_1");
}
+ @Test
public void test45() throws Exception { // bug 406347
helper1(7, 17, 7, 22, false, false, "CONSTANT", "INT");
}
+ @Test
public void test46() throws Exception { // bug 406347
helper1(8, 17, 8, 22, true, false, "CONSTANT", "INT");
}
+ @Test
public void testZeroLengthSelection0() throws Exception {
helper1(5, 18, 5, 18, false, false, "CONSTANT", "_100");
}
// -- testing failing preconditions
+ @Test
public void testFail0() throws Exception{
failHelper1(8, 16, 8, 21, true, true, "CONSTANT");
}
+ @Test
public void testFail1() throws Exception{
failHelper1(8, 16, 8, 26 , true, true, "CONSTANT");
}
+ @Test
public void testFail2() throws Exception{
failHelper1(9, 20, 9, 21 , true, true, "CONSTANT");
}
+ @Test
public void testFail3() throws Exception{
failHelper1(9, 18, 9, 25, true, true, "CONSTANT");
}
+ @Test
public void testFail4() throws Exception{
failHelper1(6, 16, 6, 20, true, true, "CONSTANT");
}
+ @Test
public void testFail5() throws Exception{
failHelper1(9, 16, 9, 25, true, true, "CONSTANT");
}
+ @Test
public void testFail6() throws Exception{
failHelper1(11, 20, 11, 24, true, true, "CONSTANT");
}
+ @Test
public void testFail7() throws Exception{
failHelper1(11, 20, 11, 34, true, true, "CONSTANT");
}
+ @Test
public void testFail10() throws Exception{
failHelper1(15, 20, 15, 37, true, false, "CONSTANT");
}
+ @Test
public void testFail11() throws Exception{
failHelper1(8, 16, 8, 22, true, false, "CONSTANT");
}
+ @Test
public void testFail12() throws Exception{
failHelper1(4, 7, 4, 8, true, true, "CONSTANT", RefactoringStatusCodes.EXPRESSION_NOT_RVALUE, true);
}
+ @Test
public void testFail13() throws Exception {
failHelper1(2, 9, 2, 10, true, true, "CONSTANT", RefactoringStatusCodes.EXPRESSION_NOT_RVALUE, true);
}
+ @Test
public void testFail14() throws Exception {
failHelper1(5, 9, 5, 11, true, true, "CONSTANT");
}
+ @Test
public void testFail15() throws Exception {
failHelper1(5, 10, 5, 13, true, true, "CONSTANT");
}
+ @Test
public void testFail16() throws Exception {
failHelper1(9, 20, 9, 38, true, false, "CONSTANT");
}
+ @Test
public void testFail17() throws Exception {
failHelper1(16, 18, 16, 21, true, true, "COLOR");
}
+ @Test
public void testGuessStringLiteral0() throws Exception {
//test for bug 37377
guessHelper(4, 19, 4, 32, "FOO_HASH_MAP");
}
+ @Test
public void testGuessStringLiteral1() throws Exception {
//test for bug 37377
guessHelper(4, 19, 4, 33, "FOO_HASH_MAP");
}
+ @Test
public void testGuessStringLiteral2() throws Exception {
//test for bug 37377
guessHelper(4, 19, 4, 56, "HANS_IM_GLUECK123_34_BLA_BLA");
}
+ @Test
public void testGuessStringLiteral3() throws Exception {
guessHelper(5, 16, 5, 16, "ASSUME_CAMEL_CASE");
}
+ @Test
public void testGuessFromGetterName0() throws Exception {
guessHelper(4, 19, 4, 30, "FOO_BAR");
}
+ @Test
public void testGuessFromGetterName1() throws Exception {
guessHelper(4, 23, 4, 33, "FOO_BAR");
}
}
-
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests13.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests13.java
index 13c31e0842..95525598b0 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests13.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests13.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
+ * Copyright (c) 2019, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,24 +13,20 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
-import junit.framework.Test;
+import org.eclipse.jdt.ui.tests.CustomBaseRunner;
+import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java13Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+@IgnoreInheritedTests
+@RunWith(CustomBaseRunner.class)
public class ExtractConstantTests13 extends ExtractConstantTests {
-
- private static final Class<ExtractConstantTests13> clazz = ExtractConstantTests13.class;
-
- public ExtractConstantTests13(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new Java13Setup(new NoSuperTestsSuite(clazz));
- }
-
- public static Test setUpTest(Test test) {
- return new Java13Setup(test);
- }
+ @Rule
+ public RefactoringTestSetup rts= new Java13Setup();
@Override
protected String getTestFileName(boolean canExtract, boolean input) {
@@ -42,8 +38,8 @@ public class ExtractConstantTests13 extends ExtractConstantTests {
//--- TESTS
@Override
+ @Test
public void test0() throws Exception {
helper1(6, 19, 9, 22, true, false, "CONSTANT", "STRING");
}
}
-
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests17.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests1d7.java
index 0acb82d5b5..2d4466225c 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests17.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractConstantTests1d7.java
@@ -13,24 +13,23 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-
-import junit.framework.Test;
-
-public class ExtractConstantTests17 extends ExtractConstantTests {
-
- private static final Class<ExtractConstantTests17> clazz = ExtractConstantTests17.class;
-
- public ExtractConstantTests17(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new Java17Setup(new NoSuperTestsSuite(clazz));
- }
-
- public static Test setUpTest(Test test) {
- return new Java17Setup(test);
- }
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.eclipse.jdt.ui.tests.CustomBaseRunner;
+import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d7Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+
+/**
+ * Those tests should run on Java Dolphin 1.7 .
+ */
+@IgnoreInheritedTests
+@RunWith(CustomBaseRunner.class)
+public class ExtractConstantTests1d7 extends ExtractConstantTests {
+ @Rule
+ public RefactoringTestSetup rts= new Java1d7Setup();
@Override
protected String getTestFileName(boolean canExtract, boolean input) {
@@ -43,8 +42,8 @@ public class ExtractConstantTests17 extends ExtractConstantTests {
// -- testing failing preconditions
@Override
+ @Test
public void testFail0() throws Exception{
failHelper1(10, 14, 10, 56, true, true, "CONSTANT");
}
}
-
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java
index 8309c795e1..4cd06e6d00 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java
@@ -895,6 +895,16 @@ public class ExtractInterfaceTests extends GenericRefactoringTest {
}
@Test
+ public void test111() throws Exception{
+ validatePassingTest("A", "I", true, true);
+ }
+
+ @Test
+ public void test112() throws Exception{
+ validatePassingTest("A", "I", true, true);
+ }
+
+ @Test
public void testPaperExample0() throws Exception{
String[] names= new String[]{"add", "addAll", "iterator"};
String[][] signatures= new String[][]{new String[]{"QComparable;"}, new String[]{"QA;"}, new String[0]};
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests1d8.java
index 0f89afdc90..10398c56c0 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests1d8.java
@@ -39,18 +39,21 @@ import org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfacePro
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java18Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class ExtractInterfaceTests18 extends ExtractInterfaceTests {
+public class ExtractInterfaceTests1d8 extends ExtractInterfaceTests {
private static final String REFACTORING_PATH= "ExtractInterface18/";
@Rule
- public RefactoringTestSetup js= new Java18Setup();
+ public RefactoringTestSetup js= new Java1d8Setup();
@Override
protected String getRefactoringPath() {
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTestSetup17.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTestSetup1d7.java
index 9981eab9eb..e56c605b28 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTestSetup17.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTestSetup1d7.java
@@ -18,9 +18,12 @@ import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java17Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d7Setup;
-public class ExtractMethodTestSetup17 extends Java17Setup {
+/**
+ * This class is used to run tests on Java Dolphin 1.7 .
+ */
+public class ExtractMethodTestSetup1d7 extends Java1d7Setup {
private IPackageFragment fTry17Package;
private IPackageFragment fInvalidSelectionPackage;
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTestSetup18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTestSetup1d8.java
index 013ac34536..8a85c55106 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTestSetup18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTestSetup1d8.java
@@ -18,10 +18,12 @@ import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java18Setup;
-
-public class ExtractMethodTestSetup18 extends Java18Setup {
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
+/**
+ * This class is made to run tests on Java Spider 1.8 .
+ */
+public class ExtractMethodTestSetup1d8 extends Java1d8Setup {
private IPackageFragment fDefaultMethodsPackage;
private IPackageFragment fStaticMethodsPackage;
private IPackageFragment fDestinationPackage;
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests.java
index b3f110b765..734f2a36c1 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests.java
@@ -21,6 +21,9 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.INVALID_SELECTION;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.VALID_SELECTION;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -28,7 +31,7 @@ import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
-import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -49,8 +52,8 @@ public class ExtractMethodTests extends AbstractJunit4SelectionTestCase {
private static final boolean BUG_405778= true; //XXX: [1.8][dom ast] method body recovery broken (empty body)
- @ClassRule
- public static ExtractMethodTestSetup fgTestSetup= new ExtractMethodTestSetup();
+ @Rule
+ public ExtractMethodTestSetup fgTestSetup= new ExtractMethodTestSetup();
@Override
public void setUp() throws Exception {
@@ -80,15 +83,15 @@ public class ExtractMethodTests extends AbstractJunit4SelectionTestCase {
return fgTestSetup.getSelectionPackage();
}
- protected void performTest(IPackageFragment packageFragment, String id, int mode, String outputFolder) throws Exception {
+ protected void performTest(IPackageFragment packageFragment, String id, TestMode mode, String outputFolder) throws Exception {
performTest(packageFragment, id, mode, outputFolder, null, null, 0);
}
- protected void performTest(IPackageFragment packageFragment, String id, int mode, String outputFolder, String[] newNames, int[] newOrder, int destination) throws Exception {
+ protected void performTest(IPackageFragment packageFragment, String id, TestMode mode, String outputFolder, String[] newNames, int[] newOrder, int destination) throws Exception {
performTest(packageFragment, id, mode, outputFolder, newNames, newOrder, destination, Modifier.PROTECTED);
}
- protected void performTest(IPackageFragment packageFragment, String id, int mode, String outputFolder, String[] newNames, int[] newOrder, int destination, int visibility) throws Exception {
+ protected void performTest(IPackageFragment packageFragment, String id, TestMode mode, String outputFolder, String[] newNames, int[] newOrder, int destination, int visibility) throws Exception {
ICompilationUnit unit= createCU(packageFragment, id);
int[] selection= getSelection();
ExtractMethodRefactoring refactoring= new ExtractMethodRefactoring(unit, selection[0], selection[1]);
@@ -104,6 +107,7 @@ public class ExtractMethodTests extends AbstractJunit4SelectionTestCase {
if (!status.isOK())
return;
break;
+ case COMPARE_WITH_OUTPUT:
default:
break;
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests10.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests10.java
index 2df8144097..0a0050f5e3 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests10.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests10.java
@@ -13,7 +13,9 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import org.junit.ClassRule;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
+
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -24,8 +26,9 @@ import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
@RunWith(CustomBaseRunner.class)
public class ExtractMethodTests10 extends ExtractMethodTests {
- @ClassRule
- public static ExtractMethodTestSetup10 fgTestSetup= new ExtractMethodTestSetup10();
+ @SuppressWarnings("hiding")
+ @Rule
+ public ExtractMethodTestSetup10 fgTestSetup= new ExtractMethodTestSetup10();
protected void try10Test() throws Exception {
performTest(fgTestSetup.getTry10Package(), "A", COMPARE_WITH_OUTPUT, "try10_out");
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests13.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests13.java
index 84f5243fd2..18988f065b 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests13.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests13.java
@@ -13,7 +13,10 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import org.junit.ClassRule;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.INVALID_SELECTION;
+
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -24,8 +27,9 @@ import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
@RunWith(CustomBaseRunner.class)
public class ExtractMethodTests13 extends ExtractMethodTests {
- @ClassRule
- public static ExtractMethodTestSetup13 fgTestSetup= new ExtractMethodTestSetup13();
+ @SuppressWarnings("hiding")
+ @Rule
+ public ExtractMethodTestSetup13 fgTestSetup= new ExtractMethodTestSetup13();
@Override
protected void invalidSelectionTest() throws Exception {
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests17.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests1d7.java
index 5314478b12..498c4fc635 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests17.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests1d7.java
@@ -13,7 +13,10 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import org.junit.ClassRule;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.INVALID_SELECTION;
+
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -22,10 +25,10 @@ import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class ExtractMethodTests17 extends ExtractMethodTests {
+public class ExtractMethodTests1d7 extends ExtractMethodTests {
- @ClassRule
- public static ExtractMethodTestSetup17 fgTestSetup= new ExtractMethodTestSetup17();
+ @Rule
+ public ExtractMethodTestSetup1d7 fgTestSetup= new ExtractMethodTestSetup1d7();
protected void try17Test() throws Exception {
performTest(fgTestSetup.getTry17Package(), "A", COMPARE_WITH_OUTPUT, "try17_out");
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests1d8.java
index d6d8ee3de0..4c34524a89 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests1d8.java
@@ -13,7 +13,11 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import org.junit.ClassRule;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.INVALID_SELECTION;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.VALID_SELECTION;
+
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -22,12 +26,15 @@ import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class ExtractMethodTests18 extends ExtractMethodTests {
+public class ExtractMethodTests1d8 extends ExtractMethodTests {
- @ClassRule
- public static ExtractMethodTestSetup18 fgTestSetup= new ExtractMethodTestSetup18();
+ @Rule
+ public ExtractMethodTestSetup1d8 fgTestSetup= new ExtractMethodTestSetup1d8();
protected void defaultMethodsTest(int destination, int visibility) throws Exception {
performTest(fgTestSetup.getDefaultMethodsPackage(), "A", COMPARE_WITH_OUTPUT, "defaultMethods18_out", null, null, destination, visibility);
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests9.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests9.java
index bfcd7cc907..cf75dd4e24 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests9.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractMethodTests9.java
@@ -13,7 +13,10 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import org.junit.ClassRule;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.INVALID_SELECTION;
+
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -24,8 +27,8 @@ import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
@RunWith(CustomBaseRunner.class)
public class ExtractMethodTests9 extends ExtractMethodTests {
- @ClassRule
- public static ExtractMethodTestSetup9 fgTestSetup= new ExtractMethodTestSetup9();
+ @Rule
+ public ExtractMethodTestSetup9 fgTestSetup= new ExtractMethodTestSetup9();
protected void try9Test() throws Exception {
performTest(fgTestSetup.getTry9Package(), "A", COMPARE_WITH_OUTPUT, "try9_out");
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractTempTests17.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractTempTests1d7.java
index 68a6a42c69..52818cbfa0 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractTempTests17.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractTempTests1d7.java
@@ -21,14 +21,17 @@ import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java17Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d7Setup;
import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+/**
+ * Those tests should run on Java Dolphin 1.7 .
+ */
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class ExtractTempTests17 extends ExtractTempTests {
+public class ExtractTempTests1d7 extends ExtractTempTests {
@Rule
- public RefactoringTestSetup js= new Java17Setup();
+ public RefactoringTestSetup js= new Java1d7Setup();
@Override
protected String getTestFileName(boolean canExtract, boolean input){
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractTempTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractTempTests1d8.java
index 29fb121203..3cb972da25 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractTempTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractTempTests1d8.java
@@ -21,14 +21,17 @@ import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java18Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class ExtractTempTests18 extends ExtractTempTests {
+public class ExtractTempTests1d8 extends ExtractTempTests {
@Rule
- public RefactoringTestSetup js= new Java18Setup();
+ public RefactoringTestSetup js= new Java1d8Setup();
@Override
protected String getTestFileName(boolean canExtract, boolean input) {
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/GenericRefactoringTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/GenericRefactoringTest.java
index 144ead1c2b..a67e345a28 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/GenericRefactoringTest.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/GenericRefactoringTest.java
@@ -105,8 +105,7 @@ public abstract class GenericRefactoringTest {
protected static final String TEST_OUTPUT_INFIX= "/out/";
protected static final String CONTAINER= "src";
- protected static final List<String> PROJECT_RESOURCE_CHILDREN= Arrays.asList(new String[] {
- ".project", ".classpath", ".settings" });
+ protected static final List<String> PROJECT_RESOURCE_CHILDREN= Arrays.asList(".project", ".classpath", ".settings");
@Before
public void genericbefore() throws Exception {
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InferTypeArgumentsTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InferTypeArgumentsTests.java
index 9a1b91c714..6d1b514fe8 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InferTypeArgumentsTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InferTypeArgumentsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,15 +14,18 @@
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.zip.ZipInputStream;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.JavaTestPlugin;
@@ -46,29 +49,20 @@ import org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester
import org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsRefactoring;
import org.eclipse.jdt.ui.tests.refactoring.infra.ZipTools;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java16Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
-public class InferTypeArgumentsTests extends RefactoringTest {
-
+public class InferTypeArgumentsTests extends GenericRefactoringTest {
private static final boolean DETERMINE_ELEMENT_TYPE_FROM_CAST= false;
private static final boolean BUG_map_entrySet_iterator= true;
- private static final Class<InferTypeArgumentsTests> clazz= InferTypeArgumentsTests.class;
private static final String REFACTORING_PATH= "InferTypeArguments/";
private boolean fAssumeCloneReturnsSameType= true;
private boolean fLeaveUnconstrainedRaw= true;
- public static Test suite() {
- return setUpTest(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new Java16Setup(someTest);
- }
-
- public InferTypeArgumentsTests(String name) {
- super(name);
- }
+ @Rule
+ public Java16Setup fgTestSetup= new Java16Setup();
@Override
protected String getRefactoringPath() {
@@ -118,7 +112,7 @@ public class InferTypeArgumentsTests extends RefactoringTest {
if (finalStatus.getSeverity() == RefactoringStatus.FATAL)
return false;
- assertTrue("Validation check failed: " + op.getValidationStatus(), !op.getValidationStatus().hasFatalError());
+ assertFalse("Validation check failed: " + op.getValidationStatus(), op.getValidationStatus().hasFatalError());
assertNotNull("No Undo", op.getUndoChange());
return true;
}
@@ -133,26 +127,32 @@ public class InferTypeArgumentsTests extends RefactoringTest {
ZipTools.compareWithZipped(src, zis, JavaProjectHelper.JUNIT_SRC_ENCODING);
}
+ @Test
public void testCuQualifiedName() throws Exception {
performCuOK();
}
+ @Test
public void testCuAnonymous01() throws Exception {
performCuOK();
}
+ @Test
public void testCuTypeParams9() throws Exception {
performCuOK();
}
+ @Test
public void testCuExistingParameterized01() throws Exception {
performCuOK();
}
+ @Test
public void testCuGetClass() throws Exception {
performCuOK();
}
+ @Test
public void testCuGetClass2() throws Exception {
// Test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=211037
// In 1.6, Object#getClass() declares return type Class<?>, but in 1.5, it's Class<? extends Object>.
@@ -177,76 +177,92 @@ public class InferTypeArgumentsTests extends RefactoringTest {
}
}
+ @Test
public void testCuGetSuperclass() throws Exception {
performCuOK();
}
+ @Test
public void testCuTypeLiteral() throws Exception {
performCuOK();
}
+ @Test
public void testCuMethodTypeParam() throws Exception {
performCuOK();
}
+ @Test
public void testCuGetTakeClassStayRaw() throws Exception {
performCuOK();
}
+ @Test
public void testCuGetClassNewInstance() throws Exception {
performCuOK();
}
+ @Test
public void testCuSynchronizedList() throws Exception {
fLeaveUnconstrainedRaw= false;
performCuOK();
}
+ @Test
public void testCuAddAll() throws Exception {
performCuOK();
}
+ @Test
public void testCuNestedCells1() throws Exception {
createCUfromTestFile(getPackageP(), "Cell");
fLeaveUnconstrainedRaw= false;
performCuOK();
}
+ @Test
public void testCuNestedVectors0() throws Exception {
fLeaveUnconstrainedRaw= false;
performCuOK();
}
+ @Test
public void testCuNestedVectors1() throws Exception {
performCuOK();
}
+ @Test
public void testCuInferTypeVariable01() throws Exception {
performCuOK();
}
+ @Test
public void testCuBoxing01() throws Exception {
performCuOK();
}
+ @Test
public void testCuBoxing02() throws Exception {
performCuOK();
}
+ @Test
public void testCuConstructor01() throws Exception {
performCuOK();
}
+ @Test
public void testJUnit() throws Exception {
fAssumeCloneReturnsSameType= false;
fLeaveUnconstrainedRaw= true;
IJavaProject javaProject= JavaProjectHelper.createJavaProject("InferTypeArguments", "bin");
try {
IPackageFragmentRoot jdk= JavaProjectHelper.addRTJar(javaProject);
- Assert.assertNotNull(jdk);
+ assertNotNull(jdk);
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- Assert.assertTrue(junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull(junitSrcArchive);
+ assertTrue(junitSrcArchive.exists());
IPackageFragmentRoot src= JavaProjectHelper.addSourceContainerWithImport(javaProject, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
@@ -261,6 +277,7 @@ public class InferTypeArgumentsTests extends RefactoringTest {
}
+ @Test
public void testJUnitWithCloneNotRaw() throws Exception {
fAssumeCloneReturnsSameType= true;
fLeaveUnconstrainedRaw= false;
@@ -268,10 +285,11 @@ public class InferTypeArgumentsTests extends RefactoringTest {
IJavaProject javaProject= JavaProjectHelper.createJavaProject("InferTypeArguments", "bin");
try {
IPackageFragmentRoot jdk= JavaProjectHelper.addRTJar(javaProject);
- Assert.assertNotNull(jdk);
+ assertNotNull(jdk);
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- Assert.assertTrue(junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull(junitSrcArchive);
+ assertTrue(junitSrcArchive.exists());
IPackageFragmentRoot src= JavaProjectHelper.addSourceContainerWithImport(javaProject, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
@@ -286,22 +304,27 @@ public class InferTypeArgumentsTests extends RefactoringTest {
}
+ @Test
public void testCuTwoVectorElements() throws Exception {
performCuOK();
}
+ @Test
public void testCuHalfPair() throws Exception {
performCuOK();
}
+ @Test
public void testCuMethodAndTypeGeneric01() throws Exception {
performCuOK();
}
+ @Test
public void testCuMethodAndTypeGeneric02() throws Exception {
performCuOK();
}
+ @Test
public void testPairDance() throws Exception {
createCUfromTestFile(getPackageP(), "Pair");
createCUfromTestFile(getPackageP(), "InvertedPair");
@@ -309,106 +332,131 @@ public class InferTypeArgumentsTests extends RefactoringTest {
// deleted in tearDown
}
+ @Test
public void testCuAddString() throws Exception {
performCuOK();
}
+ @Test
public void testCuAddString2() throws Exception {
performCuOK();
}
+ @Test
public void testCuIntermediateLocal() throws Exception {
performCuOK();
}
+ @Test
public void testCuSuperAndSub() throws Exception {
performCuOK();
}
+ @Test
public void testCuCommonSuper() throws Exception {
performCuOK();
}
+ @Test
public void testCuAddGetString() throws Exception {
performCuOK();
}
+ @Test
public void testCuAddIntegerGetNumber() throws Exception {
performCuOK();
}
+ @Test
public void testCuAddGetIterator() throws Exception {
performCuOK();
}
+ @Test
public void testCuContains() throws Exception {
performCuOK();
}
+ @Test
public void testCuMethodParam() throws Exception {
performCuOK();
}
+ @Test
public void testCuMethodReturns() throws Exception {
performCuOK();
}
+ @Test
public void testCuCollectionsMin() throws Exception {
performCuOK();
}
+ @Test
public void testCuAddStringInteger() throws Exception {
printTestDisabledMessage("currently, we don't follow flow through variables of type Object");
// performCuOK(); //TODO
}
+ @Test
public void testCuAddStringIntegerA() throws Exception {
performCuOK();
}
+ @Test
public void testCuInferFromCast() throws Exception {
printTestDisabledMessage("not implemented yet");
// performCuOK(); //TODO
}
+ @Test
public void testCuRippleMethods() throws Exception {
performCuOK();
}
+ @Test
public void testCuRippleMethods2() throws Exception {
performCuOK();
}
+ @Test
public void testCuCannotStringDouble() throws Exception {
printTestDisabledMessage("not implemented yet");
// performCuOK();
}
+ @Test
public void testCuRippleMethods3() throws Exception {
printTestDisabledMessage("not implemented yet");
// performCuOK();
}
+ @Test
public void testCuVarargs01() throws Exception {
performCuOK();
}
+ @Test
public void testCuArrays01() throws Exception {
performCuOK();
}
+ @Test
public void testCuArrays02() throws Exception {
performCuOK();
}
+ @Test
public void testCuArrays03() throws Exception {
performCuOK();
}
+ @Test
public void testCuArrays04() throws Exception {
performCuOK();
}
+ @Test
public void testCuArrays05() throws Exception {
if (! DETERMINE_ELEMENT_TYPE_FROM_CAST) {
printTestDisabledMessage("DETERMINE_ELEMENT_TYPE_FROM_CAST");
@@ -417,22 +465,27 @@ public class InferTypeArgumentsTests extends RefactoringTest {
performCuOK();
}
+ @Test
public void testCuArrays06() throws Exception {
performCuOK();
}
+ @Test
public void testCuArrays07() throws Exception {
performCuOK();
}
+ @Test
public void testCuToArray01() throws Exception {
performCuOK();
}
+ @Test
public void testCuToArray02() throws Exception {
performCuOK();
}
+ @Test
public void testCuMapEntry01() throws Exception {
if (BUG_map_entrySet_iterator) {
printTestDisabledMessage("BUG_map_entrySet_iterator");
@@ -441,24 +494,29 @@ public class InferTypeArgumentsTests extends RefactoringTest {
performCuOK();
}
+ @Test
public void testCuFieldAccess01() throws Exception {
performCuOK();
}
+ @Test
public void testCuFieldAccess02() throws Exception {
performCuOK();
}
+ @Test
public void testCuMemberOfRaw() throws Exception {
// regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=110594
performCuOK();
}
+ @Test
public void testCuParameterizedTypes1() throws Exception {
// regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=176742
performCuOK();
}
+ @Test
public void testCuParameterizedTypes2() throws Exception {
// regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=216627
performCuOK();
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests.java
index e8a7a7af17..9b31a0023d 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests.java
@@ -16,6 +16,13 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -30,19 +37,15 @@ import org.eclipse.jdt.internal.corext.refactoring.code.InlineConstantRefactorin
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser;
import org.eclipse.jdt.ui.tests.refactoring.infra.TextRangeUtil;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class InlineConstantTests extends RefactoringTest {
- private static final Class<InlineConstantTests> clazz = InlineConstantTests.class;
+public class InlineConstantTests extends GenericRefactoringTest {
private static final String REFACTORING_PATH = "InlineConstant/";
protected boolean toSucceed;
- public InlineConstantTests(String name) {
- super(name);
- }
+ @Rule
+ public RefactoringTestSetup rts= new RefactoringTestSetup();
@Override
protected String getRefactoringPath() {
@@ -53,14 +56,6 @@ public class InlineConstantTests extends RefactoringTest {
return toSucceed ? "/canInline/" : "/cannotInline/";
}
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test test) {
- return new RefactoringTestSetup(test);
- }
-
private String getSimpleName(String qualifiedName) {
return qualifiedName.substring(qualifiedName.lastIndexOf('.') + 1);
}
@@ -129,11 +124,13 @@ public class InlineConstantTests extends RefactoringTest {
private void failHelper1(String cuQName, int startLine, int startColumn, int endLine, int endColumn, boolean replaceAll, boolean removeDeclaration, int errorCode) throws Exception{
failHelper1(new String[] {cuQName}, cuQName, startLine, startColumn, endLine, endColumn, replaceAll, removeDeclaration, errorCode);
}
+
private void failHelper1(String[] cuQNames, String selectionCuQName, int startLine, int startColumn, int endLine, int endColumn, boolean replaceAll, boolean removeDeclaration, int errorCode) throws Exception{
int selectionCuIndex= firstIndexOf(selectionCuQName, cuQNames);
Assert.isTrue(selectionCuIndex != -1, "parameter selectionCuQName must match some String in cuQNames.");
failHelper1(cuQNames, selectionCuIndex, startLine, startColumn, endLine, endColumn, replaceAll, removeDeclaration, errorCode);
}
+
private void failHelper1(String[] cuQNames, int selectionCuIndex, int startLine, int startColumn, int endLine, int endColumn, boolean replaceAll, boolean removeDeclaration, int errorCode) throws Exception{
Assert.isTrue(0 <= selectionCuIndex && selectionCuIndex < cuQNames.length);
@@ -153,208 +150,254 @@ public class InlineConstantTests extends RefactoringTest {
if(!result.isOK()) {
assertEquals(errorCode, result.getEntryMatchingSeverity(RefactoringStatus.ERROR).getCode());
return;
- } else {
+ }
- ref.setReplaceAllReferences(replaceAll);
- ref.setRemoveDeclaration(removeDeclaration);
+ ref.setReplaceAllReferences(replaceAll);
+ ref.setRemoveDeclaration(removeDeclaration);
- result.merge(ref.checkFinalConditions(new NullProgressMonitor()));
+ result.merge(ref.checkFinalConditions(new NullProgressMonitor()));
- assertTrue("precondition checking is expected to fail.", !result.isOK());
- assertEquals(errorCode, result.getEntryMatchingSeverity(RefactoringStatus.ERROR).getCode());
- }
+ assertFalse("precondition checking is expected to fail.", result.isOK());
+ assertEquals(errorCode, result.getEntryMatchingSeverity(RefactoringStatus.ERROR).getCode());
}
//--- TESTS
+ @Test
public void test0() throws Exception {
helper1("p.C", 5, 30, 5, 36, true, false);
}
+ @Test
public void test1() throws Exception {
helper1("C", 3, 33, 3, 40, true, false);
}
+ @Test
public void test2() throws Exception {
helper1("p.Klass", 10, 22, 10, 30, false, false);
}
+ @Test
public void test3() throws Exception {
helper1("p.LeVinSuperieure", 5, 32, 5, 43, true, true);
}
+ @Test
public void test4() throws Exception {
helper1("p.Klus", 5, 36, 5, 36, true, false);
}
+ @Test
public void test5() throws Exception {
helper1("p.PartOfDeclNameSelected", 5, 32, 5, 34, true, true);
}
+ @Test
public void test6() throws Exception {
helper1("p.CursorPositionedInReference", 8, 57, 8, 57, false, false);
}
+ @Test
public void test7() throws Exception {
helper1("p.PartOfReferenceSelected", 8, 52, 8, 62, false, false);
}
+ @Test
public void test8() throws Exception {
helper1(new String[] {"p1.C", "p2.D"}, "p1.C", 5, 29, 5, 37, true, false);
}
+ @Test
public void test9() throws Exception {
helper1(new String[] {"p1.C", "p2.D", "p3.E"}, "p2.D", 8, 18, 8, 26, true, true);
}
+ @Test
public void test10() throws Exception {
helper1(new String[] {"p1.A", "p2.B"}, "p2.B", 9, 28, 9, 37, false, false);
}
+ @Test
public void test11() throws Exception {
helper1(new String[] {"p1.A", "p2.B", "p3.C"}, "p1.A", 8, 25, 8, 25, false, false);
}
+ @Test
public void test12() throws Exception {
helper1(new String[] {"p1.Declarer", "p2.InlineSite"}, "p2.InlineSite", 7, 37, 7, 43, true, false);
}
+ @Test
public void test13() throws Exception {
helper1(new String[] {"p1.A", "p2.InlineSite"}, "p2.InlineSite", 8, 19, 8, 29, false, false);
}
+ @Test
public void test14() throws Exception {
helper1("cantonzuerich.GrueziWohl", 7, 35, 7, 35, true, false);
}
+ @Test
public void test15() throws Exception {
helper1("schweiz.zuerich.zuerich.Froehlichkeit", 14, 16, 14, 32, true, false);
}
+ @Test
public void test16() throws Exception {
helper1("p.IntegerMath", 8, 23, 8, 23, true, true);
}
+ @Test
public void test17() throws Exception {
helper1("p.EnumRef", 4, 59, 4, 59, true, true);
}
+ @Test
public void test18() throws Exception {
helper1("p.Annot", 5, 18, 5, 18, true, true);
}
+ @Test
public void test19() throws Exception {
helper1("p.Test", 7, 36, 7, 36, true, false);
}
+ @Test
public void test20() throws Exception {
helper1("p.Test", 10, 21, 10, 21, true, true);
}
+ @Test
public void test21() throws Exception {
helper1(new String[] {"p.A", "q.Consts"}, "p.A", 8, 16, 8, 19, true, false);
}
+ @Test
public void test22() throws Exception {
helper1(new String[] {"p.A", "q.Consts", "r.Third"}, "p.A", 11, 16, 11, 19, true, true);
}
+ @Test
public void test23() throws Exception {
helper1("p.Test", 6, 26, 6, 26, false, false);
}
+ @Test
public void test24() throws Exception {
helper1(new String[] {"p.A", "q.Consts"}, "p.A", 14, 17, 14, 17, true, true);
}
+ @Test
public void test25() throws Exception {
helper1("p.A", 5, 32, 5, 32, true, true);
}
+ @Test
public void test26() throws Exception { // test for bug 93689
helper1("p.A", 5, 42, 5, 42, true, true);
}
+ @Test
public void test27() throws Exception { // test for bug 109071
helper1("p.A", 4, 24, 4, 29, true, true);
}
+ @Test
public void test28() throws Exception {
helper1(new String[] {"p.Const", "p.AnotherClass", "q.UsedClass"}, "p.Const", 6, 35, 6, 43, true, true);
}
+ @Test
public void test29() throws Exception { // test for bug 174327
helper1("p.A", 7, 44, 7, 44, true, true);
}
+ @Test
public void test30() throws Exception { //test for bug 237547 (inline unused constant)
helper1(new String[] {"p.A", "p.B", "p.C", "p.D", "q.Consts"}, "q.Consts", 5, 32, 5, 40, true, true);
}
+ @Test
public void test31() throws Exception { // test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=265448
helper1("p.A", 4, 23, 4, 28, true, true);
}
+ @Test
public void test32() throws Exception { // test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=265448
helper1("p.A", 4, 23, 4, 28, true, true);
}
+ @Test
public void test33() throws Exception { // test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=279715
helper1("p.A", 5, 29, 5, 30, true, true);
}
+ @Test
public void test34() throws Exception { // test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=297760
helper1("p.A", 4, 24, 4, 25, true, true);
}
+ @Test
public void test35() throws Exception { // test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=335173
helper1("p.A", 4, 22, 4, 23, true, true);
}
+ @Test
public void test36() throws Exception { // test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=335173
helper1("p.A", 4, 22, 4, 23, true, true);
}
+ @Test
public void test37() throws Exception { // test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=335173
helper1("p.A", 4, 23, 4, 28, true, true);
}
+ @Test
public void test38() throws Exception { // test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=218431
helper1("p.A", 6, 22, 6, 23, true, true);
}
+ @Test
public void test39() throws Exception { // test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=218431
helper1("p.A", 7, 26, 7, 27, true, true);
}
+ @Test
public void test40() throws Exception { // test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=431158
// Select simple name to inline
helper1("p.A", 7, 26, 7, 27, true, true);
}
+ @Test
public void test41() throws Exception { // test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=431158
// Select qualified name to inline
helper1("p.A", 8, 15, 8, 21, true, true);
}
+ @Test
public void test42() throws Exception { // test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=394721
helper1("p.A", 4, 32, 4, 33, true, true);
}
+ @Test
public void test43() throws Exception { // test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=434747
helper1("p.A", 4, 39, 4, 40, true, true);
}
// -- testing failing preconditions
+ @Test
public void testFail0() throws Exception {
failHelper1("foo.NeueZuercherZeitung", 5, 27, 5, 28, true, false, RefactoringStatusCodes.NOT_STATIC_FINAL_SELECTED);
}
+ @Test
public void testFail1() throws Exception {
failHelper1("fun.Fun", 8, 35, 8, 35, false, false, RefactoringStatusCodes.DECLARED_IN_CLASSFILE);
}
+ @Test
public void testFail2() throws Exception {
failHelper1("p.EnumRef", 7, 22, 7, 22, true, true, RefactoringStatusCodes.NOT_STATIC_FINAL_SELECTED);
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests17.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests17.java
deleted file mode 100644
index df5bb07fcb..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests17.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring;
-
-import junit.framework.Test;
-
-public class InlineConstantTests17 extends InlineConstantTests {
- private static final Class<InlineConstantTests17> clazz = InlineConstantTests17.class;
-
- public InlineConstantTests17(String name) {
- super(name);
- }
-
- @Override
- protected String successPath() {
- return toSucceed ? "/canInline17/" : "/cannotInline17/";
- }
-
- public static Test suite() {
- return new Java17Setup(new NoSuperTestsSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new Java17Setup(someTest);
- }
-
-
- //--- TESTS
-
- @Override
- public void test0() throws Exception {
- helper1("p.C", 5, 28, 5, 33, true, false);
- }
-}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests1d7.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests1d7.java
new file mode 100644
index 0000000000..8caad99f6c
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests1d7.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2020 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.refactoring;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.eclipse.jdt.ui.tests.CustomBaseRunner;
+import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d7Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+
+/**
+ * Those tests should run on Java Dolphin 1.7 .
+ */
+@IgnoreInheritedTests
+@RunWith(CustomBaseRunner.class)
+public class InlineConstantTests1d7 extends InlineConstantTests {
+
+ @Rule
+ public RefactoringTestSetup rts= new Java1d7Setup();
+
+ @Override
+ protected String successPath() {
+ return toSucceed ? "/canInline17/" : "/cannotInline17/";
+ }
+
+ //--- TESTS
+
+ @Override
+ @Test
+ public void test0() throws Exception {
+ helper1("p.C", 5, 28, 5, 33, true, false);
+ }
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests1d8.java
index 88812055c7..a0eefc8e76 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineConstantTests1d8.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2014 IBM Corporation and others.
+ * Copyright (c) 2013, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,78 +13,90 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
-public class InlineConstantTests18 extends InlineConstantTests {
- private static final Class<InlineConstantTests18> clazz= InlineConstantTests18.class;
+import org.eclipse.jdt.ui.tests.CustomBaseRunner;
+import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
- public InlineConstantTests18(String name) {
- super(name);
- }
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
+@IgnoreInheritedTests
+@RunWith(CustomBaseRunner.class)
+public class InlineConstantTests1d8 extends InlineConstantTests {
+ @Rule
+ public RefactoringTestSetup rts= new Java1d8Setup();
@Override
protected String successPath() {
return toSucceed ? "/canInline18/" : "/cannotInline18/";
}
- public static Test suite() {
- return new Java18Setup(new NoSuperTestsSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new Java18Setup(someTest);
- }
-
//--- Test lambda expressions
@Override
+ @Test
public void test0() throws Exception {
helper1("p.TestInlineLambda", 5, 28, 5, 30, true, true);
}
@Override
+ @Test
public void test1() throws Exception {
helper1("p.TestInlineLambda_Cast", 5, 28, 5, 30, true, true);
}
@Override
+ @Test
public void test2() throws Exception {
helper1("p.TestInlineLambdaArray", 5, 30, 5, 35, true, true);
}
@Override
+ @Test
public void test3() throws Exception {
helper1("p.TestInlineLambda_Ambiguous", 5, 28, 5, 30, true, true);
}
@Override
+ @Test
public void test4() throws Exception {
helper1("p.TestInlineLambda_Ambiguous", 5, 28, 5, 30, true, true);
}
@Override
+ @Test
public void test5() throws Exception {
helper1("p.TestInlineLambda_Cast", 15, 30, 15, 36, true, true);
}
//--- Test method references
+ @Test
public void test1000() throws Exception {
helper1("p.TestInlineMethodRef", 5, 28, 5, 30, true, true);
}
+ @Test
public void test1001() throws Exception {
helper1("p.TestInlineMethodRef_Cast", 5, 28, 5, 30, true, true);
}
+ @Test
public void test1002() throws Exception {
helper1("p.TestInlineMethodRefArray", 5, 30, 5, 35, true, true);
}
+ @Test
public void test1003() throws Exception {
helper1("p.TestInlineMethodRef_Ambiguous", 5, 28, 5, 30, true, true);
}
+ @Test
public void test1004() throws Exception {
helper1("p.TestInlineMethodRef_Enum", 5, 28, 5, 30, true, true);
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup.java
index 016ac2a0cc..172a4707f8 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -33,8 +33,7 @@ import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.tests.refactoring.infra.RefactoringTestPlugin;
-
-import junit.framework.Test;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
public class InlineMethodTestSetup extends RefactoringTestSetup {
@@ -54,13 +53,9 @@ public class InlineMethodTestSetup extends RefactoringTestSetup {
private IPackageFragment fBinary;
private IPackageFragment fOperator;
- public InlineMethodTestSetup(Test test) {
- super(test);
- }
-
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void before() throws Exception {
+ super.before();
IPackageFragmentRoot root= getDefaultSourceFolder();
fInvalid= root.createPackageFragment("invalid", true, null);
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup13.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup13.java
index 2a822ec916..0c0bd4ee89 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup13.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup13.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
+ * Copyright (c) 2019, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,22 +13,18 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
-
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java13Setup;
+
public class InlineMethodTestSetup13 extends Java13Setup {
private IPackageFragment fSimple13;
- public InlineMethodTestSetup13(Test test) {
- super(test);
- }
-
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void before() throws Exception {
+ super.before();
IPackageFragmentRoot root= getDefaultSourceFolder();
fSimple13= root.createPackageFragment("simple13_in", true, null);
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup1d8.java
index 164fa1b803..1a17be0511 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTestSetup1d8.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 IBM Corporation and others.
+ * Copyright (c) 2014, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,22 +13,20 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
-
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
-public class InlineMethodTestSetup18 extends Java18Setup {
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
+/**
+ * This class is made to run tests on Java Spider 1.8 .
+ */
+public class InlineMethodTestSetup1d8 extends Java1d8Setup {
private IPackageFragment fSimple18;
- public InlineMethodTestSetup18(Test test) {
- super(test);
- }
-
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void before() throws Exception {
+ super.before();
IPackageFragmentRoot root= getDefaultSourceFolder();
fSimple18= root.createPackageFragment("simple18_in", true, null);
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests.java
index 338e99ff12..88b49201d2 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -27,8 +27,15 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.INVALID_SELECTION;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.core.runtime.CoreException;
@@ -41,31 +48,23 @@ import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.InfixExpression;
import org.eclipse.jdt.core.dom.InfixExpression.Operator;
-import org.eclipse.jdt.internal.corext.refactoring.code.InlineMethodRefactoring;
-import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser;
import org.eclipse.jdt.internal.core.manipulation.dom.OperatorPrecedence;
import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
+import org.eclipse.jdt.internal.corext.refactoring.code.InlineMethodRefactoring;
+import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser;
-public class InlineMethodTests extends AbstractSelectionTestCase {
- private static InlineMethodTestSetup fgTestSetup;
+public class InlineMethodTests extends AbstractJunit4SelectionTestCase {
private static final boolean BUG_82166= true;
- public InlineMethodTests(String name) {
- super(name, true);
- }
-
- public static Test suite() {
- fgTestSetup= new InlineMethodTestSetup(new TestSuite(InlineMethodTests.class));
- return fgTestSetup;
+ public InlineMethodTests() {
+ super(true);
}
- public static Test setUpTest(Test someTest) {
- fgTestSetup= new InlineMethodTestSetup(someTest);
- return fgTestSetup;
- }
+ @Rule
+ public InlineMethodTestSetup fgTestSetup= new InlineMethodTestSetup();
@Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
fIsPreDeltaTest= true;
}
@@ -80,7 +79,7 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
return Character.toUpperCase(name.charAt(0)) + name.substring(1) + ".java";
}
- protected void performTestInlineCall(IPackageFragment packageFragment, String id, int mode, String outputFolder) throws Exception {
+ protected void performTestInlineCall(IPackageFragment packageFragment, String id, TestMode mode, String outputFolder) throws Exception {
ICompilationUnit unit= createCU(packageFragment, id);
int[] selection= getSelection();
InlineMethodRefactoring refactoring= InlineMethodRefactoring.create(unit, new RefactoringASTParser(IASTSharedValues.SHARED_AST_LEVEL).parse(unit, true), selection[0], selection[1]);
@@ -92,7 +91,7 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTest(unit, refactoring, mode, out, true);
}
- private void performTestInlineMethod(IPackageFragment packageFragment, String id, int mode, String outputFolder) throws Exception {
+ private void performTestInlineMethod(IPackageFragment packageFragment, String id, TestMode mode, String outputFolder) throws Exception {
ICompilationUnit unit= createCU(packageFragment, id);
IType type= unit.getTypes()[0];
IMethod method= getMethodToInline(type);
@@ -114,7 +113,7 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
return null;
}
- private void performTestInlineFirstConstructor(IPackageFragment packageFragment, String id, int mode, String outputFolder) throws Exception {
+ private void performTestInlineFirstConstructor(IPackageFragment packageFragment, String id, TestMode mode, String outputFolder) throws Exception {
ICompilationUnit unit= createCU(packageFragment, id);
IType type= unit.getTypes()[0];
IMethod method= getFirstConstructor(type);
@@ -146,62 +145,77 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTestInlineMethod(fgTestSetup.getInvalidPackage(), getName(), INVALID_SELECTION, null);
}
+ @Test
public void testRecursion() throws Exception {
performInvalidTest();
}
+ @Test
public void testInvalidFieldInitializer1() throws Exception {
performInvalidTest();
}
+ @Test
public void testInvalidFieldInitializer2() throws Exception {
performInvalidTest();
}
+ @Test
public void testInvalidFieldInitializer3() throws Exception {
performInvalidTest();
}
+ @Test
public void testLocalInitializer() throws Exception {
performInvalidTest();
}
+ @Test
public void testInterruptedStatement() throws Exception {
performInvalidTest();
}
+ @Test
public void testInterruptedExecutionFlow() throws Exception {
performInvalidTest();
}
+ @Test
public void testMultiLocal() throws Exception {
performInvalidTest();
}
+ @Test
public void testComplexBody() throws Exception {
performInvalidTest();
}
+ @Test
public void testCompileError1() throws Exception {
performInvalidTest();
}
+ @Test
public void testCompileError2() throws Exception {
performInvalidTest();
}
+ @Test
public void testCompileError3() throws Exception {
performInvalidTest();
}
+ @Test
public void testMultipleMethods() throws Exception {
performInvalidTestInlineMethod();
}
+ @Test
public void testSuperInThis() throws Exception {
performInvalidTestInlineMethod();
}
+ @Test
public void testNotMethodName() throws Exception {
ICompilationUnit unit= createCU(fgTestSetup.getInvalidPackage(), getName());
int[] selection= getSelection();
@@ -209,6 +223,7 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
assertNull(refactoring);
}
+ @Test
public void test_314407() throws Exception {
performInvalidTest();
}
@@ -227,78 +242,97 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTestInlineFirstConstructor(fgTestSetup.getSimplePackage(), getName(), COMPARE_WITH_OUTPUT, "simple_out");
}
+ @Test
public void testBasic1() throws Exception {
performSimpleTest();
}
+ @Test
public void testBasic2() throws Exception {
performSimpleTest();
}
+ @Test
public void testEmptyBody() throws Exception {
performSimpleTest();
}
+ @Test
public void testPrimitiveArray() throws Exception {
performSimpleTest();
}
+ @Test
public void testTypeArray() throws Exception {
performSimpleTest();
}
+ @Test
public void testInitializer() throws Exception {
performSimpleTest();
}
+ @Test
public void testSuper() throws Exception {
performSimpleTest();
}
+ @Test
public void testFieldInitializer1() throws Exception {
performSimpleTest();
}
+ @Test
public void testFieldInitializer2() throws Exception {
performSimpleTest();
}
+ @Test
public void testFieldInitializerAnonymous() throws Exception {
performSimpleTest();
}
+ @Test
public void testLabeledStatement() throws Exception {
performSimpleTest();
}
+ @Test
public void testConstructor1() throws Exception {
performSimpleTest();
}
+ @Test
public void testConstructor2() throws Exception {
performSimpleTestInlineConstrcutor();
}
+ @Test
public void testCatchClause() throws Exception {
performSimpleTest();
}
+ @Test
public void testTwoCalls() throws Exception {
performSimpleTestInlineMethod();
}
+ @Test
public void testNestedCalls() throws Exception {
performSimpleTestInlineMethod();
}
+ @Test
public void testSurroundingCallers() throws Exception {
performSimpleTestInlineMethod();
}
+ @Test
public void testComment1() throws Exception {
performSimpleTestInlineMethod();
}
+ @Test
public void testComment2() throws Exception {
performSimpleTestInlineMethod();
}
@@ -313,62 +347,77 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTestInlineMethod(fgTestSetup.getBugsPackage(), getName(), COMPARE_WITH_OUTPUT, "bugs_out");
}
+ @Test
public void test_72836() throws Exception {
performBugTest();
}
+ @Test
public void test_76241() throws Exception {
performBugTestInlineMethod();
}
+ @Test
public void test_94426() throws Exception {
performBugTestInlineMethod();
}
+ @Test
public void test_95128() throws Exception {
performBugTestInlineMethod();
}
+ @Test
public void test_117053() throws Exception {
performBugTest();
}
+ @Test
public void test_123356() throws Exception {
performBugTest();
}
+ @Test
public void test_44419() throws Exception {
performBugTest();
}
+ @Test
public void test_44419_2() throws Exception {
performBugTest();
}
+ @Test
public void test_98856() throws Exception {
performBugTest();
}
+ @Test
public void test_50139() throws Exception {
performBugTest();
}
+ @Test
public void test_287378() throws Exception {
performBugTest();
}
+ @Test
public void test_267386() throws Exception {
performBugTest();
}
+ @Test
public void test_267386_2() throws Exception {
performBugTest();
}
+ @Test
public void test_314407_1() throws Exception {
performBugTest();
}
+ @Test
public void test_314407_2() throws Exception {
performBugTest();
}
@@ -379,145 +428,180 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTestInlineCall(fgTestSetup.getArgumentPackage(), getName(), COMPARE_WITH_OUTPUT, "argument_out");
}
+ @Test
public void testFieldReference() throws Exception {
performArgumentTest();
}
+ @Test
public void testLocalReferenceUnused() throws Exception {
performArgumentTest();
}
+ @Test
public void testLocalReferenceRead() throws Exception {
performArgumentTest();
}
+ @Test
public void testLocalReferenceRead2() throws Exception {
performArgumentTest();
}
+ @Test
public void testLocalReferenceWrite() throws Exception {
performArgumentTest();
}
+ @Test
public void testLocalReferenceLoop() throws Exception {
performArgumentTest();
}
+ @Test
public void testLocalReferenceLoop1() throws Exception {
performArgumentTest();
}
+ @Test
public void testLocalReferenceLoop2() throws Exception {
performArgumentTest();
}
+ @Test
public void testLocalReferenceLoop3() throws Exception {
performArgumentTest();
}
+ @Test
public void testLocalReferenceLoop4() throws Exception {
performArgumentTest();
}
+ @Test
public void testLocalReferenceLoop5() throws Exception {
performArgumentTest();
}
+ @Test
public void testLocalReferencePrefix() throws Exception {
performArgumentTest();
}
+ @Test
public void testLiteralReferenceRead() throws Exception {
performArgumentTest();
}
+ @Test
public void testLiteralReferenceWrite() throws Exception {
performArgumentTest();
}
+ @Test
public void testParameterNameUsed1() throws Exception {
performArgumentTest();
}
+ @Test
public void testParameterNameUsed2() throws Exception {
performArgumentTest();
}
+ @Test
public void testParameterNameUsed3() throws Exception {
performArgumentTest();
}
+ @Test
public void testParameterNameUsed4() throws Exception {
performArgumentTest();
}
+ @Test
public void testParameterNameUnused1() throws Exception {
performArgumentTest();
}
+ @Test
public void testParameterNameUnused2() throws Exception {
performArgumentTest();
}
+ @Test
public void testParameterNameUnused3() throws Exception {
performArgumentTest();
}
+ @Test
public void testOneRead() throws Exception {
performArgumentTest();
}
+ @Test
public void testTwoReads() throws Exception {
performArgumentTest();
}
+ @Test
public void testWrite() throws Exception {
performArgumentTest();
}
+ @Test
public void testArray() throws Exception {
performArgumentTest();
}
+ @Test
public void testVarargs() throws Exception {
performArgumentTest();
}
+ @Test
public void testVarargs2() throws Exception {
performArgumentTest();
}
+ @Test
public void testVarargs3() throws Exception {
performArgumentTest();
}
+ @Test
public void testVarargs4() throws Exception {
performArgumentTest();
}
+ @Test
public void testVarargs5() throws Exception {
performArgumentTest();
}
+ @Test
public void testVarargs6() throws Exception {
performArgumentTest();
}
+ @Test
public void test91470() throws Exception {
performArgumentTest();
}
//see bug 269401
+ @Test
public void testFinalParameter1() throws Exception {
performArgumentTest();
}
//see bug 269401
+ @Test
public void testFinalParameter2() throws Exception {
performArgumentTest();
}
//see bug 269401
+ @Test
public void testFinalParameter3() throws Exception {
performArgumentTest();
}
@@ -528,34 +612,42 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTestInlineCall(fgTestSetup.getNameConflictPackage(), getName(), COMPARE_WITH_OUTPUT, "nameconflict_out");
}
+ @Test
public void testSameLocal() throws Exception {
performNameConflictTest();
}
+ @Test
public void testSameType() throws Exception {
performNameConflictTest();
}
+ @Test
public void testSameTypeAfter() throws Exception {
performNameConflictTest();
}
+ @Test
public void testSameTypeInSibling() throws Exception {
performNameConflictTest();
}
+ @Test
public void testLocalInType() throws Exception {
performNameConflictTest();
}
+ @Test
public void testFieldInType() throws Exception {
performNameConflictTest();
}
+ @Test
public void testSwitchStatement() throws Exception {
performNameConflictTest();
}
+ @Test
public void testBlocks() throws Exception {
performNameConflictTest();
}
@@ -566,22 +658,27 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTestInlineCall(fgTestSetup.getCallPackage(), getName(), COMPARE_WITH_OUTPUT, "call_out");
}
+ @Test
public void testExpressionStatement() throws Exception {
performCallTest();
}
+ @Test
public void testExpressionStatementWithReturn() throws Exception {
performCallTest();
}
+ @Test
public void testStatementWithFunction1() throws Exception {
performCallTest();
}
+ @Test
public void testStatementWithFunction2() throws Exception {
performCallTest();
}
+ @Test
public void testParenthesis() throws Exception {
performCallTest();
}
@@ -592,26 +689,32 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTestInlineCall(fgTestSetup.getExpressionPackage(), getName(), COMPARE_WITH_OUTPUT, "expression_out");
}
+ @Test
public void testSimpleExpression() throws Exception {
performExpressionTest();
}
+ @Test
public void testSimpleExpressionWithStatements() throws Exception {
performExpressionTest();
}
+ @Test
public void testSimpleBody() throws Exception {
performExpressionTest();
}
+ @Test
public void testAssignment() throws Exception {
performExpressionTest();
}
+ @Test
public void testReturnStatement() throws Exception {
performExpressionTest();
}
+ @Test
public void testConditionalExpression() throws Exception {
performExpressionTest();
}
@@ -622,62 +725,77 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTestInlineCall(fgTestSetup.getControlStatementPackage(), getName(), COMPARE_WITH_OUTPUT, "controlStatement_out");
}
+ @Test
public void testForEmpty() throws Exception {
performControlStatementTest();
}
+ @Test
public void testForOne() throws Exception {
performControlStatementTest();
}
+ @Test
public void testForTwo() throws Exception {
performControlStatementTest();
}
+ @Test
public void testEnhancedForOne() throws Exception {
performControlStatementTest();
}
+ @Test
public void testEnhancedForTwo() throws Exception {
performControlStatementTest();
}
+ @Test
public void testIfThenTwo() throws Exception {
performControlStatementTest();
}
+ @Test
public void testIfElseTwo() throws Exception {
performControlStatementTest();
}
+ @Test
public void testForAssignmentOne() throws Exception {
performControlStatementTest();
}
+ @Test
public void testForAssignmentTwo() throws Exception {
performControlStatementTest();
}
+ @Test
public void testLabelOne() throws Exception {
performControlStatementTest();
}
+ @Test
public void testLabelTwo() throws Exception {
performControlStatementTest();
}
+ @Test
public void testDanglingIf() throws Exception {
performControlStatementTest();
}
+ @Test
public void testIfWithVariable() throws Exception {
performControlStatementTest();
}
+ @Test
public void testDanglingIfBug229734() throws Exception {
performControlStatementTest();
}
+ @Test
public void testDanglingIfBug229734_2() throws Exception {
performControlStatementTest();
}
@@ -692,74 +810,92 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTestInlineMethod(fgTestSetup.getReceiverPackage(), getName(), COMPARE_WITH_OUTPUT, "receiver_out");
}
+ @Test
public void testNoImplicitReceiver() throws Exception {
performReceiverTest();
}
+ @Test
public void testNameThisReceiver() throws Exception {
performReceiverTest();
}
+ @Test
public void testNameImplicitReceiver() throws Exception {
performReceiverTest();
}
+ @Test
public void testExpressionZeroImplicitReceiver() throws Exception {
performReceiverTest();
}
+ @Test
public void testExpressionOneImplicitReceiver() throws Exception {
performReceiverTest();
}
+ @Test
public void testExpressionTwoImplicitReceiver() throws Exception {
performReceiverTest();
}
+ @Test
public void testStaticReceiver() throws Exception {
performReceiverTest();
}
+ @Test
public void testReceiverWithStatic() throws Exception {
performReceiverTest();
}
+ @Test
public void testThisExpression() throws Exception {
performReceiverTest();
}
+ @Test
public void testFieldReceiver() throws Exception {
performReceiverTest();
}
+ @Test
public void testExplicitStaticThisFieldReceiver() throws Exception {
performReceiverTest();
}
+ @Test
public void testExplicitThisFieldReceiver() throws Exception {
performReceiverTest();
}
+ @Test
public void testExplicitStaticThisMethodReceiver() throws Exception {
performReceiverTest();
}
+ @Test
public void testExplicitThisMethodReceiver() throws Exception {
performReceiverTest();
}
+ @Test
public void testThisReceiver() throws Exception {
performReceiverTestInlineMethod();
}
+ @Test
public void testImplicitReceiverMethod() throws Exception {
performReceiverTest();
}
+ @Test
public void testImplicitReceiverField() throws Exception {
performReceiverTest();
}
+ @Test
public void testRemoteFieldReceiver() throws Exception {
performReceiverTest();
}
@@ -770,42 +906,52 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTestInlineCall(fgTestSetup.getImportPackage(), getName(), COMPARE_WITH_OUTPUT, "import_out");
}
+ @Test
public void testUseArray() throws Exception {
performImportTest();
}
+ @Test
public void testUseInArgument() throws Exception {
performImportTest();
}
+ @Test
public void testUseInClassLiteral() throws Exception {
performImportTest();
}
+ @Test
public void testUseInDecl() throws Exception {
performImportTest();
}
+ @Test
public void testUseInDecl2() throws Exception {
performImportTest();
}
+ @Test
public void testUseInDecl3() throws Exception {
performImportTest();
}
+ @Test
public void testUseInDeclClash() throws Exception {
performImportTest();
}
+ @Test
public void testUseInLocalClass() throws Exception {
performImportTest();
}
+ @Test
public void testStaticImport() throws Exception {
performImportTest();
}
+ @Test
public void testStaticImport2() throws Exception {
if (BUG_82166) {
System.out.println("Disabled static import test 2 due to bug 82166");
@@ -820,70 +966,87 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTestInlineCall(fgTestSetup.getCastPackage(), getName(), COMPARE_WITH_OUTPUT, "cast_out");
}
+ @Test
public void testNotOverloaded() throws Exception {
performCastTest();
}
+ @Test
public void testOverloadedPrimitives() throws Exception {
performCastTest();
}
+ @Test
public void testNotCastableOverloaded() throws Exception {
performCastTest();
}
+ @Test
public void testOverloaded() throws Exception {
performCastTest();
}
+ @Test
public void testHierarchyOverloadedPrimitives() throws Exception {
performCastTest();
}
+ @Test
public void testHierarchyOverloaded() throws Exception {
performCastTest();
}
+ @Test
public void testHierarchyOverloadedMultiLevel() throws Exception {
performCastTest();
}
+ @Test
public void testHierarchyOverloadedPrivate() throws Exception {
performCastTest();
}
+ @Test
public void testReceiverCast() throws Exception {
performCastTest();
}
+ @Test
public void testNoCast() throws Exception {
performCastTest();
}
+ @Test
public void testInfixExpression1() throws Exception {
performCastTest();
}
+ @Test
public void testInfixExpression2() throws Exception {
performCastTest();
}
+ @Test
public void testReturnValue1() throws Exception {
performCastTest();
}
+ @Test
public void testReturnValue2() throws Exception {
performCastTest();
}
+ @Test
public void testReturnValue3() throws Exception {
performCastTest();
}
+ @Test
public void testReturnValue4() throws Exception {
performCastTest();
}
+ @Test
public void testReturnValue5() throws Exception {
performCastTest();
}
@@ -894,14 +1057,17 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTestInlineCall(fgTestSetup.getEnumPackage(), getName(), COMPARE_WITH_OUTPUT, "enum_out");
}
+ @Test
public void testBasic() throws Exception {
performEnumTest();
}
+ @Test
public void testAnonymousEnum() throws Exception {
performEnumTest();
}
+ @Test
public void test_416198() throws Exception {
performEnumTest();
}
@@ -916,68 +1082,84 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTestInlineMethod(fgTestSetup.getGenericPackage(), getName(), COMPARE_WITH_OUTPUT, "generic_out");
}
+ @Test
public void testClassInstance() throws Exception {
performGenericTest();
}
+ @Test
public void testClassInstance2() throws Exception {
performGenericTestInlineMethod();
}
+ @Test
public void testSubClass1() throws Exception {
performGenericTest();
}
+ @Test
public void testSubClass2() throws Exception {
performGenericTest();
}
+ @Test
public void testMethodInstance1() throws Exception {
performGenericTest();
}
+ @Test
public void testMethodInstance2() throws Exception {
performGenericTest();
}
+ @Test
public void testMethodInstance3() throws Exception {
performGenericTestInlineMethod();
}
+ @Test
public void testParameterizedType1() throws Exception {
performGenericTest();
}
+ @Test
public void testParameterizedType2() throws Exception {
performGenericTest();
}
+ @Test
public void testParameterizedType3() throws Exception {
performGenericTest();
}
+ @Test
public void testParameterizedType4() throws Exception {
performGenericTest();
}
+ @Test
public void testParameterizedType5() throws Exception {
performGenericTest();
}
+ @Test
public void testParameterizedType6() throws Exception {
performGenericTest();
}
+ @Test
public void testParameterizedMethod() throws Exception {
performGenericTest();
}
/* *********************** Binary Tests ******************************* */
+ @Test
public void testBinaryInlineSingle() throws Exception { // uses classes.Target#
performTestInlineCall(fgTestSetup.getBinaryPackage(), getName(), COMPARE_WITH_OUTPUT, "binary_out");
}
+ @Test
public void testBinaryInlineAll() throws Exception { // inlines all classes.Target2#logMessage(..)
String id= getName();
ICompilationUnit unit= createCU(fgTestSetup.getBinaryPackage(), id);
@@ -996,10 +1178,12 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTest(unit, refactoring, COMPARE_WITH_OUTPUT, getProofedContent("binary_out", id), true);
}
+ @Test
public void testBinaryNoSource() throws Exception {
performTestInlineCall(fgTestSetup.getBinaryPackage(), getName(), INVALID_SELECTION, null);
}
+ @Test
public void test_133575() throws Exception { // uses classes.BinEnum
performTestInlineCall(fgTestSetup.getBinaryPackage(), getName(), COMPARE_WITH_OUTPUT, "binary_out");
}
@@ -1010,62 +1194,77 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
performTestInlineCall(fgTestSetup.getOperatorPackage(), getName(), COMPARE_WITH_OUTPUT, "operator_out");
}
+ @Test
public void testPlusPlus() throws Exception {
performOperatorTest();
}
+ @Test
public void testPlusPlus_1() throws Exception {
performOperatorTest();
}
+ @Test
public void testPlusDiff() throws Exception {
performOperatorTest();
}
+ @Test
public void testDiffDiff() throws Exception {
performOperatorTest();
}
+ @Test
public void testDiffPlus() throws Exception {
performOperatorTest();
}
+ @Test
public void testTimesPlus() throws Exception {
performOperatorTest();
}
+ @Test
public void testPrefixPlus() throws Exception {
performOperatorTest();
}
+ @Test
public void testPostfixPlus() throws Exception {
performOperatorTest();
}
+ @Test
public void testPlusTimes() throws Exception {
performOperatorTest();
}
+ @Test
public void testPlusPrefix() throws Exception {
performOperatorTest();
}
+ @Test
public void testPlusPostfix() throws Exception {
performOperatorTest();
}
+ @Test
public void testTimesTimes() throws Exception {
performOperatorTest();
}
+ @Test
public void testTimesDivide() throws Exception {
performOperatorTest();
}
+ @Test
public void testDivideDivide() throws Exception {
performOperatorTest();
}
+ @Test
public void testOperatorPredence() throws Exception {
AST ast= AST.newAST(IASTSharedValues.SHARED_AST_LEVEL, false);
@@ -1106,7 +1305,7 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
exp= ast.newInfixExpression();
exp.setOperator(Operator.NOT_EQUALS);
int notEquals= OperatorPrecedence.getExpressionPrecedence(exp);
- assertTrue(equals == notEquals);
+ assertEquals(equals, notEquals);
exp= ast.newInfixExpression();
exp.setOperator(Operator.LESS);
@@ -1116,20 +1315,20 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
exp= ast.newInfixExpression();
exp.setOperator(Operator.LESS_EQUALS);
int lessEquals= OperatorPrecedence.getExpressionPrecedence(exp);
- assertTrue(less == lessEquals);
+ assertEquals(less, lessEquals);
exp= ast.newInfixExpression();
exp.setOperator(Operator.GREATER);
int greater= OperatorPrecedence.getExpressionPrecedence(exp);
- assertTrue(lessEquals == greater);
+ assertEquals(lessEquals, greater);
exp= ast.newInfixExpression();
exp.setOperator(Operator.GREATER_EQUALS);
int greaterEquals= OperatorPrecedence.getExpressionPrecedence(exp);
- assertTrue(greater == greaterEquals);
+ assertEquals(greater, greaterEquals);
int instance= OperatorPrecedence.getExpressionPrecedence(ast.newInstanceofExpression());
- assertTrue(greaterEquals == instance);
+ assertEquals(greaterEquals, instance);
exp= ast.newInfixExpression();
exp.setOperator(Operator.LEFT_SHIFT);
@@ -1139,12 +1338,12 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
exp= ast.newInfixExpression();
exp.setOperator(Operator.RIGHT_SHIFT_SIGNED);
int rightShiftSigned= OperatorPrecedence.getExpressionPrecedence(exp);
- assertTrue(leftShift == rightShiftSigned);
+ assertEquals(leftShift, rightShiftSigned);
exp= ast.newInfixExpression();
exp.setOperator(Operator.RIGHT_SHIFT_UNSIGNED);
int rightShiftUnSigned= OperatorPrecedence.getExpressionPrecedence(exp);
- assertTrue(rightShiftSigned == rightShiftUnSigned);
+ assertEquals(rightShiftSigned, rightShiftUnSigned);
exp= ast.newInfixExpression();
exp.setOperator(Operator.PLUS);
@@ -1154,7 +1353,7 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
exp= ast.newInfixExpression();
exp.setOperator(Operator.MINUS);
int minus= OperatorPrecedence.getExpressionPrecedence(exp);
- assertTrue(plus == minus);
+ assertEquals(plus, minus);
exp= ast.newInfixExpression();
exp.setOperator(Operator.TIMES);
@@ -1164,12 +1363,12 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
exp= ast.newInfixExpression();
exp.setOperator(Operator.DIVIDE);
int divide= OperatorPrecedence.getExpressionPrecedence(exp);
- assertTrue(times == divide);
+ assertEquals(times, divide);
exp= ast.newInfixExpression();
exp.setOperator(Operator.REMAINDER);
int remainder= OperatorPrecedence.getExpressionPrecedence(exp);
- assertTrue(divide == remainder);
+ assertEquals(divide, remainder);
int cast= OperatorPrecedence.getExpressionPrecedence(ast.newCastExpression());
assertTrue(times < cast);
@@ -1181,6 +1380,6 @@ public class InlineMethodTests extends AbstractSelectionTestCase {
assertTrue(prefix < postfix);
int newClass= OperatorPrecedence.getExpressionPrecedence(ast.newClassInstanceCreation());
- assertTrue(postfix == newClass);
+ assertEquals(postfix, newClass);
}
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests13.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests13.java
index 447ed4e6b9..b05c104a16 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests13.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests13.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
+ * Copyright (c) 2019, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,24 +13,21 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
-public class InlineMethodTests13 extends InlineMethodTests {
- private static InlineMethodTestSetup13 fgTestSetup;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
- public InlineMethodTests13(String name) {
- super(name);
- }
+import org.eclipse.jdt.ui.tests.CustomBaseRunner;
+import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
- public static Test suite() {
- fgTestSetup= new InlineMethodTestSetup13(new NoSuperTestsSuite(InlineMethodTests13.class));
- return fgTestSetup;
- }
+@IgnoreInheritedTests
+@RunWith(CustomBaseRunner.class)
+public class InlineMethodTests13 extends InlineMethodTests {
- public static Test setUpTest(Test someTest) {
- fgTestSetup= new InlineMethodTestSetup13(someTest);
- return fgTestSetup;
- }
+ @Rule
+ public InlineMethodTestSetup13 fgTestSetup= new InlineMethodTestSetup13();
protected void performSimpleTest() throws Exception {
performTestInlineCall(fgTestSetup.getSimplePackage(), getName(), COMPARE_WITH_OUTPUT, "simple13_out");
@@ -38,6 +35,7 @@ public class InlineMethodTests13 extends InlineMethodTests {
//--- TESTS
+ @Test
public void testTextBlock1() throws Exception {
performSimpleTest();
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests1d8.java
index ccece3b53e..35f027be16 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests1d8.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 IBM Corporation and others.
+ * Copyright (c) 2014, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,24 +13,23 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
-public class InlineMethodTests18 extends InlineMethodTests {
- private static InlineMethodTestSetup18 fgTestSetup;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
- public InlineMethodTests18(String name) {
- super(name);
- }
-
- public static Test suite() {
- fgTestSetup= new InlineMethodTestSetup18(new NoSuperTestsSuite(InlineMethodTests18.class));
- return fgTestSetup;
- }
+import org.eclipse.jdt.ui.tests.CustomBaseRunner;
+import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
- public static Test setUpTest(Test someTest) {
- fgTestSetup= new InlineMethodTestSetup18(someTest);
- return fgTestSetup;
- }
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
+@IgnoreInheritedTests
+@RunWith(CustomBaseRunner.class)
+public class InlineMethodTests1d8 extends InlineMethodTests {
+ @Rule
+ public InlineMethodTestSetup1d8 fgTestSetup= new InlineMethodTestSetup1d8();
protected void performSimpleTest() throws Exception {
performTestInlineCall(fgTestSetup.getSimplePackage(), getName(), COMPARE_WITH_OUTPUT, "simple18_out");
@@ -38,6 +37,7 @@ public class InlineMethodTests18 extends InlineMethodTests {
//--- TESTS
+ @Test
public void testLambda1() throws Exception {
performSimpleTest();
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests.java
index 060a863178..79c1e60f2b 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests.java
@@ -65,8 +65,8 @@ public class InlineTempTests extends GenericRefactoringTest {
private ISourceRange getSelection(ICompilationUnit cu) throws Exception{
String source= cu.getSource();
- int offset= source.indexOf(AbstractSelectionTestCase.SQUARE_BRACKET_OPEN);
- int end= source.indexOf(AbstractSelectionTestCase.SQUARE_BRACKET_CLOSE);
+ int offset= source.indexOf(AbstractJunit4SelectionTestCase.SQUARE_BRACKET_OPEN);
+ int end= source.indexOf(AbstractJunit4SelectionTestCase.SQUARE_BRACKET_CLOSE);
return new SourceRange(offset, end - offset);
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests17.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests1d7.java
index 1ca4b5e79c..d0a09310e2 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests17.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests1d7.java
@@ -19,14 +19,17 @@ import org.junit.runner.RunWith;
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java17Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d7Setup;
import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+/**
+ * Those tests should run on Java Dolphin 1.7 .
+ */
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class InlineTempTests17 extends InlineTempTests {
+public class InlineTempTests1d7 extends InlineTempTests {
@Rule
- public RefactoringTestSetup js= new Java17Setup();
+ public RefactoringTestSetup js= new Java1d7Setup();
@Override
protected String getTestFileName(boolean canInline, boolean input){
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests1d8.java
index 476728cedc..0d0d658237 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineTempTests1d8.java
@@ -19,14 +19,17 @@ import org.junit.runner.RunWith;
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java18Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class InlineTempTests18 extends InlineTempTests {
+public class InlineTempTests1d8 extends InlineTempTests {
@Rule
- public RefactoringTestSetup js= new Java18Setup();
+ public RefactoringTestSetup js= new Java1d8Setup();
@Override
protected String getTestFileName(boolean canInline, boolean input) {
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceIndirectionTests17.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceIndirectionTests1d7.java
index 074c480ec3..09ca285097 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceIndirectionTests17.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceIndirectionTests1d7.java
@@ -20,14 +20,17 @@ import org.junit.runner.RunWith;
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java17Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d7Setup;
import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+/**
+ * Those tests should run on Java Dolphin 1.7 .
+ */
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class IntroduceIndirectionTests17 extends IntroduceIndirectionTests {
+public class IntroduceIndirectionTests1d7 extends IntroduceIndirectionTests {
@Rule
- public RefactoringTestSetup rts= new Java17Setup();
+ public RefactoringTestSetup rts= new Java1d7Setup();
// ---
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceIndirectionTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceIndirectionTests1d8.java
index 578184d576..655da22cdf 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceIndirectionTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceIndirectionTests1d8.java
@@ -20,14 +20,17 @@ import org.junit.runner.RunWith;
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java18Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class IntroduceIndirectionTests18 extends IntroduceIndirectionTests {
+public class IntroduceIndirectionTests1d8 extends IntroduceIndirectionTests {
@Rule
- public RefactoringTestSetup rts= new Java18Setup();
+ public RefactoringTestSetup rts= new Java1d8Setup();
// ---
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceParameterObjectTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceParameterObjectTests1d8.java
index f60a788a75..43e833768c 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceParameterObjectTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceParameterObjectTests1d8.java
@@ -29,17 +29,20 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
-import org.eclipse.jdt.ui.tests.core.Java18ProjectTestSetup;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java18Setup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class IntroduceParameterObjectTests18 extends IntroduceParameterObjectTests {
+public class IntroduceParameterObjectTests1d8 extends IntroduceParameterObjectTests {
private static final String REFACTORING_PATH= "IntroduceParameterObject18/";
@Rule
- public RefactoringTestSetup rts= new Java18Setup();
+ public RefactoringTestSetup rts= new Java1d8Setup();
@Override
protected String getRefactoringPath() {
@@ -55,7 +58,7 @@ public class IntroduceParameterObjectTests18 extends IntroduceParameterObjectTes
Hashtable<String, String> newOptions= new Hashtable<>(originalOptions);
newOptions.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
javaProject.setOptions(newOptions);
- JavaProjectHelper.addLibrary(javaProject, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(javaProject, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
fDescriptor.setMethod(setupMethod());
fDescriptor.setTopLevel(true);
@@ -66,6 +69,7 @@ public class IntroduceParameterObjectTests18 extends IntroduceParameterObjectTes
javaProject.setOptions(originalOptions);
}
}
+
/* Test that @NonNull annotations ARE NOT created if @NonNullByDefault is in effect for the target location */
@Test
public void testNoRedundantNonNull2() throws Exception {
@@ -75,7 +79,7 @@ public class IntroduceParameterObjectTests18 extends IntroduceParameterObjectTes
Hashtable<String, String> newOptions= new Hashtable<>(originalOptions);
newOptions.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
javaProject.setOptions(newOptions);
- JavaProjectHelper.addLibrary(javaProject, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(javaProject, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
fDescriptor.setMethod(setupMethod());
fDescriptor.setTopLevel(false);
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceParameterTests17.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceParameterTests1d7.java
index f1ae4ff356..9cf8a4e59d 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceParameterTests17.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/IntroduceParameterTests1d7.java
@@ -20,14 +20,17 @@ import org.junit.runner.RunWith;
import org.eclipse.jdt.ui.tests.CustomBaseRunner;
import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java17Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d7Setup;
import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+/**
+ * Those tests should run on Java Dolphin 1.7 .
+ */
@IgnoreInheritedTests
@RunWith(CustomBaseRunner.class)
-public class IntroduceParameterTests17 extends IntroduceParameterTests {
+public class IntroduceParameterTests1d7 extends IntroduceParameterTests {
@Rule
- public RefactoringTestSetup rts= new Java17Setup();
+ public RefactoringTestSetup rts= new Java1d7Setup();
// ---
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java10Setup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java10Setup.java
deleted file mode 100644
index be82cccc04..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java10Setup.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2018 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-
-import junit.framework.Test;
-
-public class Java10Setup extends RefactoringTestSetup {
-
- public Java10Setup(Test test) {
- super(test);
- }
-
- @Override
- protected IPackageFragmentRoot addRTJar(IJavaProject project) throws CoreException {
- return JavaProjectHelper.addRTJar10(project);
- }
-}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java12Setup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java12Setup.java
deleted file mode 100644
index f86ef7f65c..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java12Setup.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-
-import junit.framework.Test;
-
-public class Java12Setup extends RefactoringTestSetup {
-
- public Java12Setup(Test test) {
- super(test);
- }
-
- @Override
- protected IPackageFragmentRoot addRTJar(IJavaProject project) throws CoreException {
- return JavaProjectHelper.addRTJar12(project, true);
- }
-}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java13Setup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java13Setup.java
deleted file mode 100644
index bedfc7cced..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java13Setup.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-
-public class Java13Setup extends RefactoringTestSetup {
-
- public Java13Setup(Test test) {
- super(test);
- }
-
- /*
- * @see org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup#addRTJar(org.eclipse.jdt.core.IJavaProject)
- */
- @Override
- protected IPackageFragmentRoot addRTJar(IJavaProject project) throws CoreException {
- return JavaProjectHelper.addRTJar_13(project, true);
- }
-}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java14Setup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java14Setup.java
deleted file mode 100644
index fa2294d677..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java14Setup.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2020 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-
-import junit.framework.Test;
-
-public class Java14Setup extends RefactoringTestSetup {
-
- public Java14Setup(Test test) {
- super(test);
- }
-
- /*
- * @see org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup#addRTJar(org.eclipse.jdt.core.IJavaProject)
- */
- @Override
- protected IPackageFragmentRoot addRTJar(IJavaProject project) throws CoreException {
- return JavaProjectHelper.addRTJar_14(project, true);
- }
-}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java15Setup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java15Setup.java
deleted file mode 100644
index 629594edfa..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java15Setup.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring;
-
-import junit.framework.Test;
-
-/**
- * TODO: replace by RefactoringTestSetup
- */
-public class Java15Setup extends RefactoringTestSetup {
-
- public Java15Setup(Test test) {
- super(test);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java16Setup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java16Setup.java
deleted file mode 100644
index 6db28e1755..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java16Setup.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-
-public class Java16Setup extends RefactoringTestSetup {
-
- public Java16Setup(Test test) {
- super(test);
- }
-
- /*
- * @see org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup#addRTJar(org.eclipse.jdt.core.IJavaProject)
- */
- @Override
- protected IPackageFragmentRoot addRTJar(IJavaProject project) throws CoreException {
- return JavaProjectHelper.addRTJar16(project);
- }
-}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java17Setup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java17Setup.java
deleted file mode 100644
index c344407073..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java17Setup.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-
-public class Java17Setup extends RefactoringTestSetup {
-
- public Java17Setup(Test test) {
- super(test);
- }
-
- /*
- * @see org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup#addRTJar(org.eclipse.jdt.core.IJavaProject)
- */
- @Override
- protected IPackageFragmentRoot addRTJar(IJavaProject project) throws CoreException {
- return JavaProjectHelper.addRTJar17(project);
- }
-}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java18Setup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java18Setup.java
deleted file mode 100644
index a7069aeb30..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java18Setup.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-
-public class Java18Setup extends RefactoringTestSetup {
-
- public Java18Setup(Test test) {
- super(test);
- }
-
- /*
- * @see org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup#addRTJar(org.eclipse.jdt.core.IJavaProject)
- */
- @Override
- protected IPackageFragmentRoot addRTJar(IJavaProject project) throws CoreException {
- return JavaProjectHelper.addRTJar18(project);
- }
-}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java9Setup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java9Setup.java
deleted file mode 100644
index f4598e942b..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/Java9Setup.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-
-import junit.framework.Test;
-
-public class Java9Setup extends RefactoringTestSetup {
-
- public Java9Setup(Test test) {
- super(test);
- }
-
- @Override
- protected IPackageFragmentRoot addRTJar(IJavaProject project) throws CoreException {
- return JavaProjectHelper.addRTJar9(project);
- }
-}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInitializerTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInitializerTests.java
index ab189d8ac9..82323b9db5 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInitializerTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInitializerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
+ * Copyright (c) 2019, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,6 +14,12 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.core.resources.IResource;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
@@ -31,31 +37,17 @@ import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgDestinationFactory
import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory;
import org.eclipse.jdt.ui.tests.refactoring.ccp.MockReorgQueries;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-
-public class MoveInitializerTests extends RefactoringTest {
-
- private static final Class<MoveInitializerTests> clazz= MoveInitializerTests.class;
+public class MoveInitializerTests extends GenericRefactoringTest {
private static final String REFACTORING_PATH= "MoveInitializer/";
- public MoveInitializerTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new RefactoringTestSetup(someTest);
- }
+ @Rule
+ public RefactoringTestSetup fts= new RefactoringTestSetup();
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void genericbefore() throws Exception {
+ super.genericbefore();
fIsPreDeltaTest= true;
}
@@ -76,6 +68,7 @@ public class MoveInitializerTests extends RefactoringTest {
// Move static initializer in same package and ensure imports are brought along
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=108147
@SuppressWarnings("null")
+ @Test
public void test0() throws Exception{
ParticipantTesting.reset();
final String p1Name= "p1";
@@ -99,7 +92,7 @@ public class MoveInitializerTests extends RefactoringTest {
RefactoringStatus status= performRefactoring(processor, true);
//-- checks
- assertEquals("status should be ok here", null, status);
+ assertNull("status should be ok here", status);
assertEquals("p1 files", 2, packP1.getChildren().length);
@@ -113,6 +106,7 @@ public class MoveInitializerTests extends RefactoringTest {
// Move static initializer in different package and ensure imports are brought along
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=108147
@SuppressWarnings("null")
+ @Test
public void test1() throws Exception{
ParticipantTesting.reset();
final String p1Name= "p1";
@@ -138,7 +132,7 @@ public class MoveInitializerTests extends RefactoringTest {
RefactoringStatus status= performRefactoring(processor, true);
//-- checks
- assertEquals("status should be ok here", null, status);
+ assertNull("status should be ok here", status);
assertEquals("p1 files", 1, packP1.getChildren().length);
assertEquals("p2 files", 1, packP2.getChildren().length);
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInnerToTopLevelTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInnerToTopLevelTests.java
index 5514ff2e68..88a790d297 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInnerToTopLevelTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInnerToTopLevelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,9 +14,19 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.util.Hashtable;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -35,44 +45,31 @@ import org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester
import org.eclipse.jdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring;
import org.eclipse.jdt.ui.tests.refactoring.infra.TextRangeUtil;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java15Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class MoveInnerToTopLevelTests extends RefactoringTest {
-
+public class MoveInnerToTopLevelTests extends GenericRefactoringTest {
private static final boolean BUG_304827= true; // too many imports, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=304827
private static final String FIELD_COMMENT= "/** Comment */";
- private static final Class<MoveInnerToTopLevelTests> clazz= MoveInnerToTopLevelTests.class;
private static final String REFACTORING_PATH= "MoveInnerToTopLevel/";
private static final int NOT_AVAILABLE= 1001;
private String fCompactPref;
- public MoveInnerToTopLevelTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new Java15Setup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new Java15Setup(someTest);
- }
+ @ClassRule
+ public static RefactoringTestSetup fts= new Java15Setup();
@Override
protected String getRefactoringPath() {
return REFACTORING_PATH;
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void before() throws Exception {
StubUtility.setCodeTemplate(CodeTemplateContextType.FIELDCOMMENT_ID, FIELD_COMMENT, null);
StubUtility.setCodeTemplate(CodeTemplateContextType.NEWTYPE_ID,
"${package_declaration}" +
@@ -87,9 +84,8 @@ public class MoveInnerToTopLevelTests extends RefactoringTest {
JavaCore.setOptions(options);
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void after() throws Exception {
Hashtable<String, String> options= JavaCore.getOptions();
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, fCompactPref);
JavaCore.setOptions(options);
@@ -143,7 +139,7 @@ public class MoveInnerToTopLevelTests extends RefactoringTest {
}
RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
- assertTrue("precondition was supposed to pass", !checkInputResult.hasError());
+ assertFalse("precondition was supposed to pass", checkInputResult.hasError());
performChange(ref, false);
for (int i= 0; i < cus.length; i++) {
@@ -204,120 +200,149 @@ public class MoveInnerToTopLevelTests extends RefactoringTest {
//-- tests
+ @Test
public void test0() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test1() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test2() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test3() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test4() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test5() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test6() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test7() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test8() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test9() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test10() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test11() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test12() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test13() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test14() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test15() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A", "A1"}, new String[]{"p", "p1"}, null, false, false);
}
+ @Test
public void test16() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A", "A1"}, new String[]{"p", "p1"}, null, false, false);
}
+ @Test
public void test17() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test18() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A", "A1"}, new String[]{"p", "p1"}, null, false, false);
}
+ @Test
public void test19() throws Exception{
printTestDisabledMessage("bug 23078");
// validatePassingTest("A", "Inner", new String[]{"A", "A1"}, new String[]{"p", "p1"}, null, false, false);
}
+ @Test
public void test20() throws Exception{
// printTestDisabledMessage("bug 23077 ");
validatePassingTest("A", "Inner", new String[]{"A", "A1"}, new String[]{"p", "p1"}, null, false, false);
}
+ @Test
public void test21() throws Exception{
// printTestDisabledMessage("bug 23627");
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test22() throws Exception{
// printTestDisabledMessage("bug 23627");
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test23() throws Exception{
// printTestDisabledMessage("bug 24576 ");
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test24() throws Exception{
// printTestDisabledMessage("bug 28816 ");
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
+ @Test
public void test25() throws Exception{
// printTestDisabledMessage("bug 39716");
validatePassingTest("A", "Inner", "", new String[]{"A"}, new String[]{""}, null, false, false, false, true);
}
+ @Test
public void test26() throws Exception{
validatePassingTest("A", "Inner", "", new String[]{"A"}, new String[]{""}, null, false, true, true, true);
}
+ @Test
public void test30() throws Exception{
validatePassingTest("A", "Inner", "", new String[]{"A"}, new String[]{""}, null, false, true, true, true);
}
+ @Test
public void test31() throws Exception{
printTestDisabledMessage("disabled due to missing support for statically imported methods");
// validatePassingTest("A", "Inner", "", new String[]{"A"}, new String[]{""}, null, false, true, true, true);
@@ -326,11 +351,13 @@ public class MoveInnerToTopLevelTests extends RefactoringTest {
// ---- Visibility issues with the moved member itself and its parents
// Move inner class; enclosing class must remain private if not used
+ @Test
public void test32() throws Exception{
validatePassingTest("A", "Inner", "MoreInner", "p1", new String[]{"A"}, new String[]{"p1"}, null, false, false, false, false);
}
// Move inner class which has access to enclosing private class, enclosing class must be increased in visibility
+ @Test
public void test33() throws Exception{
validatePassingTest("A", "Inner", "MoreInner", "p2", new String[]{"A"}, new String[]{"p2"}, null, false, false, false, false);
}
@@ -338,17 +365,20 @@ public class MoveInnerToTopLevelTests extends RefactoringTest {
// --- Visibility issues with members of moved members
// Move inner class which has private members, which are accessed from enclosing types.
+ @Test
public void test34() throws Exception {
validatePassingTest("A", "SomeClass", "p", new String[] { "A"}, new String[] { "p"}, null, false, true, false, false);
}
// Move inner class which has private members, but they are unused (and must remain private)
+ @Test
public void test35() throws Exception {
validatePassingTest("A", "Inner", "p", new String[] { "A"}, new String[] { "p"}, null, false, true, false, false);
}
// Move inner class which has access private members, and accessing private members of
// enclosing class (4 visibility increments)
+ @Test
public void test36() throws Exception {
validatePassingTest("A", "SomeInner", "Inner", "p", new String[] { "A"}, new String[] { "p"}, null, false, false, false, false);
}
@@ -356,233 +386,291 @@ public class MoveInnerToTopLevelTests extends RefactoringTest {
// Move inner class with some private used and some private non-used members.
// used members go default, non-used stay private
// bug 97411 + 117465 (comment #1)
+ @Test
public void test37() throws Exception {
validatePassingTest("A", "SomeInner", "p", new String[] { "A"}, new String[] { "p"}, null, false, false, false, false);
}
+ @Test
public void test38() throws Exception {
validatePassingTest("A", "B", "p", new String[] { "A"}, new String[] { "p"}, null, false, false, false, false);
}
// change visibility: https://bugs.eclipse.org/319069
+ @Test
public void test39() throws Exception {
validatePassingTest("A", "B", "p", new String[] { "A"}, new String[] { "p"}, null, false, true, false, false);
}
// change visibility: https://bugs.eclipse.org/319069
+ @Test
public void test40() throws Exception {
validatePassingTest("A", "B", "p", new String[] { "A"}, new String[] { "p"}, null, false, true, false, false);
}
// change visibility: https://bugs.eclipse.org/319069
+ @Test
public void test41() throws Exception {
validatePassingTest("A", "B", "p", new String[] { "A"}, new String[] { "p"}, null, false, true, false, false);
}
// change visibility: https://bugs.eclipse.org/319069
+ @Test
public void test42() throws Exception {
validatePassingTest("A", "B", "p", new String[] { "A"}, new String[] { "p"}, null, false, true, false, false);
}
+ @Test
public void test43() throws Exception {
validatePassingTest("A", "B", "p", new String[] { "A"}, new String[] { "p"}, "", false, true, false, false);
}
+ @Test
public void test44() throws Exception {
validatePassingTest("A", "B", "p", new String[] { "A"}, new String[] { "p"}, "a", true, true, true, true);
}
// static context: https://bugs.eclipse.org/bugs/show_bug.cgi?id=385237
+ @Test
public void test_static_context_0() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, null, false, false);
}
// --- Non static
+ @Test
public void test_nonstatic_0() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_1() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_2() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_3() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_4() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_5() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_6() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_7() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_8() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_9() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_10() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_11() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_12() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, true);
}
+ @Test
public void test_nonstatic_13() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, true);
}
+ @Test
public void test_nonstatic_14() throws Exception{
// printTestDisabledMessage("bug 23488");
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_15() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_16() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_17() throws Exception{
// printTestDisabledMessage("bug 23488");
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_18() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_19() throws Exception{
// printTestDisabledMessage("bug 23464 ");
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_20() throws Exception{
// printTestDisabledMessage("bug 23464 ");
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_21() throws Exception{
// printTestDisabledMessage("must fix - consequence of fix for 23464");
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_22() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_23() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_24() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_25() throws Exception{
// printTestDisabledMessage("bug 23464 ");
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_26() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_27() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_28() throws Exception{
// printTestDisabledMessage("test for bug 23725");
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_29() throws Exception{
printTestDisabledMessage("test for bug 23724");
// validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_30() throws Exception{
// printTestDisabledMessage("test for bug 23715");
validatePassingTest("A", "Inner", "p", new String[]{"A"}, new String[]{"p"}, "a", true, true, false, true);
}
+ @Test
public void test_nonstatic_31() throws Exception{
// printTestDisabledMessage("test for bug 25537");
validatePassingTest("A", "Inner", "p", new String[]{"A"}, new String[]{"p"}, "a", true, true, true, true);
}
+ @Test
public void test_nonstatic_32() throws Exception{
// printTestDisabledMessage("test for bug 25537");
validatePassingTest("A", "Inner", "p", new String[]{"A"}, new String[]{"p"}, "a", true, true, true, true);
}
+ @Test
public void test_nonstatic_33() throws Exception{
// printTestDisabledMessage("test for bug 26252");
validatePassingTest("A", "I", "p", new String[]{"A"}, new String[]{"p"}, "a", true, true, false, true);
}
+ @Test
public void test_nonstatic_34() throws Exception{
// printTestDisabledMessage("test for bug 31861");
validatePassingTest("A", "Inner", "p", new String[]{"A"}, new String[]{"p"}, "a", true, true, true, true);
}
+ @Test
public void test_nonstatic_35() throws Exception{
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, false);
}
+ @Test
public void test_nonstatic_36() throws Exception{
// printTestDisabledMessage("test for bug 34591");
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, true);
}
+ @Test
public void test_nonstatic_37() throws Exception{
// printTestDisabledMessage("test for bug 38114");
validatePassingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", true, true);
}
+ @Test
public void test_nonstatic_38() throws Exception{
// printTestDisabledMessage("test for bug 37540");
validatePassingTest("A", "Inner", "p", new String[]{"A"}, new String[]{"p"}, "a", false, true, false, false);
}
+ @Test
public void test_nonstatic_39() throws Exception{
// printTestDisabledMessage("test for bug 37540");
validatePassingTest("A", "Inner", "p", new String[]{"A"}, new String[]{"p"}, "a", false, true, false, false);
}
+ @Test
public void test_nonstatic_40() throws Exception{
// printTestDisabledMessage("test for bug 77083");
validatePassingTest("A", "Inner", "p", new String[]{"A"}, new String[]{"p"}, "a", false, true, false, false);
}
+ @Test
public void test_nonstatic_41() throws Exception{
validatePassingTest("A", "Inner", "p", new String[]{"A"}, new String[]{"p"}, "a", false, true, false, false);
}
+ @Test
public void test_nonstatic_42() throws Exception{
printTestDisabledMessage("disabled due to missing support for statically imported methods");
// validatePassingTest("A", "Inner", "p", new String[]{"A"}, new String[]{"p"}, "a", false, true, false, false);
}
// Using member of enclosing type, non-static edition
+ @Test
public void test_nonstatic_43() throws Exception{
validatePassingTest("A", "Inner", "MoreInner", "p5", new String[]{"A"}, new String[]{"p5"}, "inner", true, true, true, true);
}
// Move inner class and create field; enclosing class must be changed to use default visibility.
+ @Test
public void test_nonstatic_44() throws Exception{
validatePassingTest("A", "Inner", "MoreInner", "p2", new String[]{"A"}, new String[]{"p2"}, "p", true, true, false, true);
}
+ @Test
public void test_nonstatic_45() throws Exception {
validatePassingTest("A", "B", "p", new String[] { "A" }, new String[] { "p" }, null, false, true, false, false);
}
+ @Test
public void test_nonstatic_46() throws Exception {
validatePassingTest("A", "B", "p", new String[] { "A" }, new String[] { "p" }, null, false, true, false, false);
}
+ @Test
public void test_nonstatic_47() throws Exception {
validatePassingTest("A", "B", "p", new String[] { "A" }, new String[] { "p" }, null, false, true, false, false);
}
+ @Test
public void test_nonstatic_48() throws Exception {
String fileCommentTemplate= "/** Copy right or wrong. */";
StubUtility.setCodeTemplate(CodeTemplateContextType.FILECOMMENT_ID, fileCommentTemplate, null);
@@ -597,20 +685,25 @@ public class MoveInnerToTopLevelTests extends RefactoringTest {
}
}
+ @Test
public void test_nonstatic_49() throws Exception {
validatePassingTest("A", "B", "p", new String[] { "A" }, new String[] { "p" }, "a", false, true, true, true);
}
+ @Test
public void testFail_nonstatic_0() throws Exception{
validateFailingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", RefactoringStatus.ERROR);
}
+ @Test
public void testFail_nonstatic_1() throws Exception{
validateFailingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", RefactoringStatus.ERROR);
}
+ @Test
public void testFail_nonstatic_2() throws Exception{
validateFailingTest("A", "Inner", new String[]{"A"}, new String[]{"p"}, "a", RefactoringStatus.ERROR);
}
+ @Test
public void testFail_nonstatic_3() throws Exception{
IType parentClas= getClassFromTestFile(getPackageP(), "A");
int offset= TextRangeUtil.getOffset(parentClas.getCompilationUnit(), 5, 25);
@@ -621,62 +714,75 @@ public class MoveInnerToTopLevelTests extends RefactoringTest {
}
// --- Secondary classes
+ @Test
public void test_secondary_0() throws Exception {
validatePassingTestSecondaryType("A", "Secondary", "p", new String[] { "A" }, new String[] { "p" }, null, false, false, false, false);
}
+ @Test
public void test_secondary_1() throws Exception {
validatePassingTestSecondaryType("A", "Secondary", "p", new String[] { "A" }, new String[] { "p" }, null, false, false, false, false);
}
+ @Test
public void test_secondary_2() throws Exception {
if (BUG_304827)
return;
validatePassingTestSecondaryType("A", "Secondary", "p", new String[] { "A" }, new String[] { "p" }, null, false, false, false, false);
}
+ @Test
public void test_secondary_3() throws Exception {
validatePassingTestSecondaryType("A", "Secondary", "p", new String[] { "A", "S" }, new String[] { "p", "q" }, null, false, false, false, false);
}
+ @Test
public void test_secondary_4() throws Exception {
if (BUG_304827)
return;
validatePassingTestSecondaryType("A", "Secondary", "p", new String[] { "A" }, new String[] { "p" }, null, false, false, false, false);
}
+ @Test
public void test_secondary_5() throws Exception {
if (BUG_304827)
return;
validatePassingTestSecondaryType("A", "Secondary", "p", new String[] { "A" }, new String[] { "p" }, null, false, false, false, false);
}
+ @Test
public void test_secondary_6() throws Exception {
if (BUG_304827)
return;
validatePassingTestSecondaryType("A", "Secondary", "p", new String[] { "A" }, new String[] { "p" }, null, false, false, false, false);
}
+ @Test
public void test_secondary_7() throws Exception {
validatePassingTestSecondaryType("A", "Secondary", "p", new String[] { "A", "S", "T" }, new String[] { "p", "q", "q" }, null, false, false, false, false);
}
+ @Test
public void test_secondary_8() throws Exception {
validatePassingTestSecondaryType("A", "Secondary", "p", new String[] { "A", "S", "T" }, new String[] { "p", "q", "q" }, null, false, false, false, false);
}
+ @Test
public void test_secondary_9() throws Exception {
validatePassingTestSecondaryType("A", "Secondary", "p", new String[] { "A" }, new String[] { "p" }, null, false, false, false, false);
}
+ @Test
public void test_secondary_10() throws Exception {
validatePassingTestSecondaryType("A", "Secondary", "p", new String[] { "A" }, new String[] { "p" }, null, false, false, false, false);
}
+ @Test
public void test_secondary_11() throws Exception {
validatePassingTestSecondaryType("A", "Secondary", "p", new String[] { "A" }, new String[] { "p" }, null, false, false, false, false);
}
+ @Test
public void test_secondary_12() throws Exception {
validatePassingTestSecondaryType("A", "Secondary", "p", new String[] { "A" }, new String[] { "p" }, null, false, false, false, false);
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests.java
index 4ba3cc3d61..21df21e868 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests.java
@@ -17,6 +17,13 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -34,16 +41,12 @@ import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor;
import org.eclipse.jdt.ui.tests.refactoring.infra.TextRangeUtil;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java15Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class MoveInstanceMethodTests extends RefactoringTest {
-
- private static final Class<MoveInstanceMethodTests> clazz= MoveInstanceMethodTests.class;
-
+public class MoveInstanceMethodTests extends GenericRefactoringTest {
public static final int FIELD= 1;
public static final int PARAMETER= 0;
@@ -69,13 +72,8 @@ public class MoveInstanceMethodTests extends RefactoringTest {
return (IMethod) jes[0];
}
- public static Test setUpTest(Test someTest) {
- return new Java15Setup(someTest);
- }
-
- public static Test suite() {
- return new Java15Setup(new TestSuite(clazz));
- }
+ @Rule
+ public RefactoringTestSetup fts= new Java15Setup();
private static boolean typeMatches(int newTargetType, IVariableBinding newTarget) {
return newTargetType == PARAMETER && !newTarget.isField() || newTargetType == FIELD && newTarget.isField();
@@ -83,10 +81,6 @@ public class MoveInstanceMethodTests extends RefactoringTest {
private boolean toSucceed;
- public MoveInstanceMethodTests(String name) {
- super(name);
- }
-
private ICompilationUnit[] createCUs(String[] qualifiedNames) throws Exception {
ICompilationUnit[] cus= new ICompilationUnit[qualifiedNames.length];
for (int i= 0; i < qualifiedNames.length; i++) {
@@ -129,7 +123,7 @@ public class MoveInstanceMethodTests extends RefactoringTest {
result.merge(ref.checkFinalConditions(new NullProgressMonitor()));
- assertTrue("precondition checking is expected to fail.", !result.isOK());
+ assertFalse("precondition checking is expected to fail.", result.isOK());
}
}
@@ -195,7 +189,7 @@ public class MoveInstanceMethodTests extends RefactoringTest {
preconditionResult.merge(ref.checkFinalConditions(new NullProgressMonitor()));
- assertTrue("precondition was supposed to pass", !preconditionResult.hasError());
+ assertFalse("precondition was supposed to pass", preconditionResult.hasError());
performChange(ref, false);
@@ -234,7 +228,7 @@ public class MoveInstanceMethodTests extends RefactoringTest {
preconditionResult.merge(ref.checkFinalConditions(new NullProgressMonitor()));
- assertTrue("precondition was supposed to pass", !preconditionResult.hasError());
+ assertFalse("precondition was supposed to pass", preconditionResult.hasError());
performChange(ref, false);
@@ -264,11 +258,13 @@ public class MoveInstanceMethodTests extends RefactoringTest {
// --- TESTS
// Move mA1 to parameter b, do not inline delegator
+ @Test
public void test0() throws Exception {
helper1(new String[] { "p1.A", "p2.B", "p3.C"}, "p1.A", 11, 17, 11, 20, PARAMETER, "b", false, false);
}
// Move mA1 to parameter b, inline delegator
+ @Test
public void test1() throws Exception {
// printTestDisabledMessage("not implemented yet");
helper1(new String[] { "p1.A", "p2.B", "p3.C"}, "p1.A", 11, 17, 11, 20, PARAMETER, "b", true, false);
@@ -276,431 +272,515 @@ public class MoveInstanceMethodTests extends RefactoringTest {
// multiple parameters, some left of new receiver parameter, some right of it,
// "this" is NOT passed as argument, (since it's not used in the method)
+ @Test
public void test10() throws Exception {
helper1(new String[] { "p1.A", "p2.B"}, "p1.A", 14, 17, 14, 17, PARAMETER, "b", false, false);
}
// move to field, method has parameters, choice of fields, some non-class type fields
// ("this" is passed as argument)
+ @Test
public void test11() throws Exception {
helper1(new String[] { "p1.A", "p2.B"}, "p1.A", 17, 17, 17, 17, FIELD, "fB", false, false);
}
// move to field - do not pass 'this' because it's unneeded
+ @Test
public void test12() throws Exception {
helper1(new String[] { "p1.A", "p2.B"}, "p1.A", 14, 17, 14, 20, FIELD, "fB", false, false);
}
// junit case
+ @Test
public void test13() throws Exception {
helper1(new String[] { "p1.TR", "p1.TC", "p1.P"}, "p1.TR", 9, 20, 9, 23, PARAMETER, "test", false, false);
}
// simplified junit case
+ @Test
public void test14() throws Exception {
helper1(new String[] { "p1.TR", "p1.TC"}, "p1.TR", 9, 20, 9, 23, PARAMETER, "test", false, false);
}
// move to type in same cu
+ @Test
public void test15() throws Exception {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=40120
helper1(new String[] { "p.A"}, "p.A", 17, 18, 17, 18, PARAMETER, "s", false, false);
}
// move to inner type in same cu
+ @Test
public void test16() throws Exception {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=40120
helper1(new String[] { "p.B"}, "p.B", 15, 17, 15, 22, PARAMETER, "s", false, false);
}
// don't generate parameter for unused field (bug 38310)
+ @Test
public void test17() throws Exception {
helper1(new String[] { "p.Shape", "p.Rectangle"}, "p.Shape", 11, 16, 11, 20, FIELD, "fBounds", false, false);
}
// generate parameter for used field (bug 38310)
+ @Test
public void test18() throws Exception {
helper1(new String[] { "p.Shape", "p.Rectangle"}, "p.Shape", 17, 22, 17, 22, FIELD, "fInnerBounds", false, false);
}
// generate parameter for used field (bug 38310)
+ @Test
public void test19() throws Exception {
helper1(new String[] { "p.Shape", "p.Rectangle"}, "p.Shape", 22, 20, 22, 33, PARAMETER, "rect", false, false);
}
// // Move mA1 to parameter b, inline delegator, remove delegator
+ @Test
public void test2() throws Exception {
// printTestDisabledMessage("not implemented yet");
helper1(new String[] { "p1.A", "p2.B", "p3.C"}, "p1.A", 12, 17, 12, 20, PARAMETER, "b", true, true);
}
// Can move if "super" is used in inner class
+ @Test
public void test20() throws Exception {
helper1(new String[] { "p.A", "p.B", "p.StarDecorator"}, "p.A", 14, 17, 14, 22, PARAMETER, "b", false, false);
}
// Arguments of method calls preserved in moved body (bug 41468)
+ @Test
public void test21() throws Exception {
helper1(new String[] { "p.A", "p.Second"}, "p.A", 5, 17, 5, 22, FIELD, "s", false, false);
}
// arguments of method calls preserved in moved body (bug 41468),
// use "this" instead of field (bug 38310)
+ @Test
public void test22() throws Exception {
helper1(new String[] { "p.A", "p.Second"}, "p.A", 5, 17, 5, 22, FIELD, "s", false, false);
}
// "this"-qualified field access: this.s -> this (bug 41597)
+ @Test
public void test23() throws Exception {
helper1(new String[] { "p.A", "p.Second"}, "p.A", 5, 17, 5, 22, FIELD, "s", false, false);
}
// move local class (41530)
+ @Test
public void test24() throws Exception {
helper1(new String[] { "p1.A", "p1.B", "p1.StarDecorator"}, "p1.A", 9, 17, 9, 22, PARAMETER, "b", false, false);
}
// extended junit case
+ @Test
public void test25() throws Exception {
helper1(new String[] { "p1.TR", "p1.TC", "p1.P"}, "p1.TR", 4, 20, 4, 23, PARAMETER, "test", false, false);
}
// extended junit case with generics (bug 77653)
+ @Test
public void test26() throws Exception {
helper1(new String[] { "p1.TR", "p1.TC", "p1.P"}, "p1.TR", 9, 20, 9, 23, PARAMETER, "test", false, false);
}
// extended junit case with generics and deprecation message
+ @Test
public void test27() throws Exception {
helper1(new String[] { "p1.TR", "p1.TC", "p1.P"}, "p1.TR", 9, 20, 9, 23, PARAMETER, "test", false, false, true);
}
// extended junit case with generics, enums and deprecation message
+ @Test
public void test28() throws Exception {
helper1(new String[] { "p1.TR", "p1.TC", "p1.P"}, "p1.TR", 9, 20, 9, 23, PARAMETER, "test", false, false, true);
}
// extended junit case with generics, enums and deprecation message
+ @Test
public void test29() throws Exception {
helper1(new String[] { "p1.TR", "p1.TC", "p1.P"}, "p1.TR", 9, 20, 9, 23, PARAMETER, "test", false, false, true);
}
// extended junit case with generics, enums, static imports and deprecation message
+ @Test
public void test30() throws Exception {
helper1(new String[] { "p1.TR", "p1.TC", "p1.P"}, "p1.TR", 10, 21, 10, 21, PARAMETER, "test", false, false, true);
}
// extended junit case with generics, enums, static imports and deprecation message
+ @Test
public void test31() throws Exception {
printTestDisabledMessage("disabled due to missing support for statically imported methods");
// helper1(new String[] { "p1.TR", "p1.TC", "p1.P"}, "p1.TR", 10, 21, 10, 21, PARAMETER, "test", false, false, true);
}
+ @Test
public void test32() throws Exception {
helper1(new String[] { "p1.A"}, "p1.A", 9, 25, 9, 26, PARAMETER, "p", true, true);
}
// Test visibility of a target field is not affected.
+ @Test
public void test33() throws Exception {
helper1(new String[] { "p.Foo", "p.Bar" }, "p.Foo", 6, 18, 6, 21, FIELD, "_bar", false, false);
}
// Test visibility of target field is changed to public
// in case a caller is in another package (bug 117465).
+ @Test
public void test34() throws Exception {
helper1(new String[] { "test1.TestTarget", "test1.Test1", "test2.Test2"}, "test1.Test1", 3, 21, 3, 33, FIELD, "target", true, true);
}
// Test visibility of target field is changed to default
// in case a caller is in the same package (bug 117465).
+ @Test
public void test35() throws Exception {
helper1(new String[] { "test1.TestTarget", "test1.Test1", "test1.Test2"}, "test1.Test1", 3, 21, 3, 33, FIELD, "target", true, true);
}
// Test search engine for secondary types (bug 108030).
+ @Test
public void test36() throws Exception {
helper1(new String[] { "p.A", "p.B" }, "p.A", 9, 17, 9, 27, FIELD, "fB", false, false);
}
// Test name conflicts in the moved method between fields and parameters (bug 227876)
+ @Test
public void test37() throws Exception {
helper1(new String[] { "p.A", "p.B" }, "p.A", 4, 17, 4, 42, FIELD, "destination", true, true);
}
// Test problem with parameter order (bug 165697)
+ @Test
public void test38() throws Exception {
helper1(new String[] { "p.A", "p.B" }, "p.A", 4, 17, 4, 35, FIELD, "target", true, true);
}
// Test problem with qualified accesses (bug 149316)
+ @Test
public void test39() throws Exception {
helper1(new String[] { "p.A", "p.B" }, "p.A", 4, 13, 4, 25, PARAMETER, "p", true, true);
}
// Test problem with qualified accesses (bug 149316)
+ @Test
public void test40() throws Exception {
helper1(new String[] { "p.A", "p.B" }, "p.A", 4, 13, 4, 25, PARAMETER, "p", true, true);
}
// Test problem with missing bindings (bug 328554)
+ @Test
public void test41() throws Exception {
helper1(new String[] { "p.A" }, "p.A", 4, 10, 4, 10, PARAMETER, "b", true, true);
}
// Test problem with parameterized nested class (bug 342074)
+ @Test
public void test42() throws Exception {
helper1(new String[] { "p.A", "p.B", "p.Outer" }, "p.A", 6, 17, 6, 20, PARAMETER, "b", true, true);
}
// Test problem with enum (bug 339980)
+ @Test
public void test43() throws Exception {
helper1(new String[] { "p.A" }, "p.A", 10, 10, 10, 20, PARAMETER, "fooBar", true, true);
}
// Test problem with enum (bug 339980)
+ @Test
public void test44() throws Exception {
helper1(new String[] { "p.A", "p.MyEnum" }, "p.A", 8, 10, 8, 20, PARAMETER, "fooBar", true, true);
}
// Test problem with enum (bug 339980)
+ @Test
public void test45() throws Exception {
helper1(new String[] { "p.A" }, "p.A", 8, 10, 8, 20, PARAMETER, "fooBar", true, true);
}
// bug 385989
+ @Test
public void test46() throws Exception {
helper1(new String[] { "p.A", "p.B" }, "p.A", 6, 10, 6, 13, PARAMETER, "b", true, true);
}
// bug 385550
+ @Test
public void test47() throws Exception {
helper1(new String[] { "p.A" }, "p.A", 8, 17, 8, 17, PARAMETER, "target", true, true);
}
// bug 411529
+ @Test
public void test48() throws Exception {
helper1(new String[] { "p.A", "p.B", "q.C" }, "p.B", 3, 17, 3, 17, PARAMETER, "c", true, true);
}
//bug 356687
+ @Test
public void test49() throws Exception {
helper1(new String[] {"p.A"}, "p.A", 5, 10, 5, 11, FIELD, "b", true, true);
}
//bug 356687
+ @Test
public void test50() throws Exception {
helper1(new String[] {"p.A"}, "p.A", 4, 10, 4, 11, PARAMETER, "b", true, true);
}
//bug 356687
+ @Test
public void test51() throws Exception {
helper1(new String[] {"p.A"}, "p.A", 4, 10, 4, 11, PARAMETER, "b", true, true);
}
//bug 356687
+ @Test
public void test52() throws Exception {
helper1(new String[] {"p.A"}, "p.A", 5, 10, 5, 11, FIELD, "b", true, true);
}
//bug 356687
+ @Test
public void test53() throws Exception {
helper1(new String[] {"p.A"}, "p.A", 4, 10, 4, 11, PARAMETER, "b", true, true);
}
//bug 356687
+ @Test
public void test54() throws Exception {
helper1(new String[] {"p.A"}, "p.A", 4, 15, 4, 16, PARAMETER, "b", false, false);
}
//bug 356687
+ @Test
public void test55() throws Exception {
helper1(new String[] {"p.A"}, "p.A", 4, 17, 4, 18, FIELD, "b", true, true);
}
//bug 356687
+ @Test
public void test56() throws Exception {
helper1(new String[] {"p.A"}, "p.A", 3, 17, 3, 18, PARAMETER, "b", true, true);
}
//bug 356687
+ @Test
public void test57() throws Exception {
helper1(new String[] { "p.A" }, "p.A", 5, 17, 5, 18, PARAMETER, "b", true, true);
}
//bug 217753
+ @Test
public void test58() throws Exception {
helper1(new String[] { "p.A", "p.B" }, "p.A", 8, 25, 8, 28, PARAMETER, "b", true, true);
}
// bug 217753
+ @Test
public void test59() throws Exception {
helper1(new String[] { "p.A", "p.B" }, "p.A", 5, 14, 5, 15, PARAMETER, "b", true, true);
}
// bug 217753
+ @Test
public void test60() throws Exception {
helper1(new String[] { "p.A" }, "p.A", 5, 14, 5, 15, PARAMETER, "b", true, true);
}
// bug 217753
+ @Test
public void test61() throws Exception {
helper1(new String[] { "p.A" }, "p.A", 5, 14, 5, 15, PARAMETER, "b", true, true);
}
// bug 217753
+ @Test
public void test62() throws Exception {
helper1(new String[] { "p.A", "q.B" }, "p.A", 8, 14, 8, 15, PARAMETER, "c", true, true);
}
// bug 217753
+ @Test
public void test63() throws Exception {
helper1(new String[] { "A" }, "A", 2, 10, 2, 11, PARAMETER, "b", true, true);
}
// bug 404477
+ @Test
public void test64() throws Exception {
helper1(new String[] { "A" }, "A", 3, 17, 3, 18, PARAMETER, "b", true, true);
}
// bug 404471
+ @Test
public void test65() throws Exception {
helper1(new String[] { "A" }, "A", 3, 17, 3, 18, PARAMETER, "c", false, false);
}
// bug 426112
+ @Test
public void test66() throws Exception {
helper1(new String[] { "A" }, "A", 2, 17, 2, 20, PARAMETER, "a", true, true);
}
// bug 436997 - references enclosing generic type
+ @Test
public void test67() throws Exception {
helper1(new String[] { "A" }, "A", 6, 14, 6, 15, FIELD, "b", true, true);
}
// bug 441217
+ @Test
public void test68() throws Exception {
helper1(new String[] { "A" }, "A", 6, 16, 6, 17, PARAMETER, "d", true, true);
}
// bug 486175
+ @Test
public void test69() throws Exception {
helper1(new String[] { "p1.A", "p2.B"}, "p1.A", 11, 17, 11, 23, FIELD, "b", true, true);
}
// Move mA1 to field fB, do not inline delegator
+ @Test
public void test3() throws Exception {
helper1(new String[] { "p1.A", "p2.B", "p3.C"}, "p1.A", 9, 17, 9, 20, FIELD, "fB", false, false);
}
// // Move mA1 to field fB, inline delegator, remove delegator
+ @Test
public void test4() throws Exception {
// printTestDisabledMessage("not implemented yet");
helper1(new String[] { "p1.A", "p2.B", "p3.C"}, "p1.A", 9, 17, 9, 20, FIELD, "fB", true, true);
}
// Move mA1 to field fB, unqualified static member references are qualified
+ @Test
public void test5() throws Exception {
helper1(new String[] { "p1.A", "p2.B"}, "p1.A", 15, 19, 15, 19, FIELD, "fB", false, false);
}
// class qualify referenced type name to top level, original receiver not used in method
+ @Test
public void test6() throws Exception {
helper1(new String[] { "p1.Nestor", "p2.B"}, "p1.Nestor", 11, 17, 11, 17, PARAMETER, "b", false, false);
}
+ @Test
public void test7() throws Exception {
helper1(new String[] { "p1.A", "p2.B", "p3.N1"}, "p1.A", 8, 17, 8, 18, PARAMETER, "b", false, false);
}
// access to fields, non-void return type
+ @Test
public void test8() throws Exception {
helper1(new String[] { "p1.A", "p2.B"}, "p1.A", 15, 19, 15, 20, PARAMETER, "b", false, false);
}
// multiple parameters, some left of new receiver parameter, some right of it,
// "this" is passed as argument
+ @Test
public void test9() throws Exception {
helper1(new String[] { "p1.A", "p2.B"}, "p1.A", 6, 17, 6, 17, PARAMETER, "b", false, false);
}
// Cannot move interface method declaration
+ @Test
public void testFail0() throws Exception {
failHelper1("p1.IA", 5, 17, 5, 20, PARAMETER, "b", true, true);
}
// Cannot move abstract method declaration
+ @Test
public void testFail1() throws Exception {
failHelper1("p1.A", 5, 26, 5, 29, PARAMETER, "b", true, true);
}
// Cannot move method if there's no new potential receiver
+ @Test
public void testFail10() throws Exception {
failHelper1(new String[] { "p1.A", "p2.B", "p3.C"}, "p1.A", 8, 17, 8, 20, PARAMETER, "b", true, true);
}
// Cannot move method - parameter name conflict
+ @Test
public void testFail11() throws Exception {
failHelper2(new String[] { "p1.A", "p2.B"}, "p1.A", 7, 17, 7, 20, PARAMETER, "b", "a", true, true);
}
// Cannot move method if there's no new potential receiver (because of null bindings here)
+ @Test
public void testFail12() throws Exception {
// printTestDisabledMessage("bug 39871");
failHelper1(new String[] { "p1.A"}, "p1.A", 5, 10, 5, 16, PARAMETER, "b", true, true);
}
// Cannot move method - annotations are not supported
+ @Test
public void testFail13() throws Exception {
printTestDisabledMessage("disabled - jcore does not have elements for annotation members");
// failHelper2(new String[] { "p1.A", "p2.B"}, "p1.A", 5, 12, 5, 13, PARAMETER, "b", "a", true, true);
}
// bug 404477 - target method already exists
+ @Test
public void testFail14() throws Exception {
failHelper1(new String[] { "A" }, "A", 2, 17, 2, 18, PARAMETER, "b", true, true);
}
// bug 404477 / bug 286221 - target method already exists
+ @Test
public void testFail15() throws Exception {
failHelper1(new String[] { "A" }, "A", 3, 17, 3, 18, FIELD, "fB", true, true);
}
// bug 436997 - references enclosing instance
+ @Test
public void testFail16() throws Exception {
failHelper1(new String[] { "p1.A", "p1.B"}, "p1.A", 8, 14, 8, 15, PARAMETER, "b", true, true);
}
// Cannot move static method
+ @Test
public void testFail2() throws Exception {
failHelper1(new String[] { "p1.A", "p2.B"}, "p1.A", 6, 23, 6, 24, PARAMETER, "b", true, true);
}
// Cannot move native method
+ @Test
public void testFail3() throws Exception {
failHelper1(new String[] { "p1.A", "p2.B"}, "p1.A", 6, 23, 6, 24, PARAMETER, "b", true, true);
}
// Cannot move method that references "super"
+ @Test
public void testFail4() throws Exception {
failHelper1(new String[] { "p1.A", "p2.B"}, "p1.A", 11, 20, 11, 21, PARAMETER, "b", true, true);
}
// Cannot move method that references an enclosing instance
+ @Test
public void testFail5() throws Exception {
failHelper1(new String[] { "p1.A", "p2.B"}, "p1.A", 8, 21, 8, 21, PARAMETER, "b", true, true);
}
// Cannot move potentially directly recursive method
+ @Test
public void testFail6() throws Exception {
failHelper1(new String[] { "p1.A", "p2.B"}, "p1.A", 6, 16, 6, 17, PARAMETER, "b", true, true);
}
// Cannot move synchronized method
+ @Test
public void testFail8() throws Exception {
failHelper1(new String[] { "p1.A", "p2.B"}, "p1.A", 6, 29, 6, 29, PARAMETER, "b", true, true);
}
// Cannot move method if there's no new potential receiver
+ @Test
public void testFail9() throws Exception {
failHelper1(new String[] { "p1.A", "p2.B", "p3.C"}, "p1.A", 7, 17, 7, 20, PARAMETER, "b", true, true);
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests1d8.java
index 615c64e548..73f48e0fd6 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveInstanceMethodTests1d8.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 IBM Corporation and others.
+ * Copyright (c) 2014, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -16,6 +16,10 @@ package org.eclipse.jdt.ui.tests.refactoring;
import java.util.Hashtable;
import java.util.Map;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.core.runtime.Path;
@@ -23,27 +27,23 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.ui.tests.core.Java18ProjectTestSetup;
-
-import junit.framework.Test;
-
-public class MoveInstanceMethodTests18 extends MoveInstanceMethodTests {
-
- private static final Class<MoveInstanceMethodTests18> clazz= MoveInstanceMethodTests18.class;
-
- public MoveInstanceMethodTests18(String name) {
- super(name);
- }
-
- public static Test suite() {
- return setUpTest(new NoSuperTestsSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new Java18Setup(someTest);
- }
+import org.eclipse.jdt.ui.tests.CustomBaseRunner;
+import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
+@IgnoreInheritedTests
+@RunWith(CustomBaseRunner.class)
+public class MoveInstanceMethodTests1d8 extends MoveInstanceMethodTests {
+ @Rule
+ public RefactoringTestSetup fts= new Java1d8Setup();
// test for bug 410056, move default method from interface to class
+ @Test
public void test18_1() throws Exception {
String[] cuQNames= new String[] { "p.A", "p.B" };
String selectionCuQName= "p.A";
@@ -52,6 +52,7 @@ public class MoveInstanceMethodTests18 extends MoveInstanceMethodTests {
}
// test for bug 410056, move default method from interface to interface
+ @Test
public void test18_2() throws Exception {
String[] cuQNames= new String[] { "p.A", "p.B" };
String selectionCuQName= "p.A";
@@ -59,6 +60,7 @@ public class MoveInstanceMethodTests18 extends MoveInstanceMethodTests {
}
// test for bug 410056, move default method from interface to interface(declared field)
+ @Test
public void test18_3() throws Exception {
String[] cuQNames= new String[] { "p.A", "p.B" };
String selectionCuQName= "p.A";
@@ -66,6 +68,7 @@ public class MoveInstanceMethodTests18 extends MoveInstanceMethodTests {
}
// test for bug 410056, move default method from interface to class(declared field)
+ @Test
public void test18_4() throws Exception {
String[] cuQNames= new String[] { "p.A", "p.B" };
String selectionCuQName= "p.A";
@@ -73,6 +76,7 @@ public class MoveInstanceMethodTests18 extends MoveInstanceMethodTests {
}
// test that no redundant @NonNull annotations are created
+ @Test
public void testNoRedundantNonNull1() throws Exception {
IJavaProject javaProject= getRoot().getJavaProject();
Map<String, String> originalOptions= javaProject.getOptions(false);
@@ -80,7 +84,7 @@ public class MoveInstanceMethodTests18 extends MoveInstanceMethodTests {
Hashtable<String, String> newOptions= new Hashtable<>(originalOptions);
newOptions.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
javaProject.setOptions(newOptions);
- JavaProjectHelper.addLibrary(javaProject, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(javaProject, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
String[] cuQNames= new String[] { "p.Source", "p.Target" };
String selectionCuQName= "p.Source";
@@ -90,6 +94,7 @@ public class MoveInstanceMethodTests18 extends MoveInstanceMethodTests {
}
}
// test required @NonNull annotations are still created where @NonNullByDefault({}) is in effect
+ @Test
public void testNoRedundantNonNull2() throws Exception {
IJavaProject javaProject= getRoot().getJavaProject();
Map<String, String> originalOptions= javaProject.getOptions(false);
@@ -97,7 +102,7 @@ public class MoveInstanceMethodTests18 extends MoveInstanceMethodTests {
Hashtable<String, String> newOptions= new Hashtable<>(originalOptions);
newOptions.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
javaProject.setOptions(newOptions);
- JavaProjectHelper.addLibrary(javaProject, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(javaProject, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
String[] cuQNames= new String[] { "p.Source", "p.Target" };
String selectionCuQName= "p.Source";
@@ -106,5 +111,4 @@ public class MoveInstanceMethodTests18 extends MoveInstanceMethodTests {
javaProject.setOptions(originalOptions);
}
}
-
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests.java
index 38d863efe1..aeae628e6e 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,12 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.MoveArguments;
@@ -34,26 +38,15 @@ import org.eclipse.jdt.internal.corext.refactoring.structure.MoveStaticMembersPr
import org.eclipse.jdt.internal.corext.refactoring.tagging.IDelegateUpdating;
import org.eclipse.jdt.ui.tests.refactoring.infra.DebugUtils;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
-public class MoveMembersTests extends RefactoringTest {
-
- private static final Class<MoveMembersTests> clazz= MoveMembersTests.class;
-
+public class MoveMembersTests extends GenericRefactoringTest {
private static final String REFACTORING_PATH= "MoveMembers/";
- public MoveMembersTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new RefactoringTestSetup(someTest);
- }
+ @Rule
+ public RefactoringTestSetup fts= new RefactoringTestSetup();
@Override
protected String getRefactoringPath() {
@@ -77,10 +70,10 @@ public class MoveMembersTests extends RefactoringTest {
}
@Override
- protected void setUp() throws Exception {
+ public void genericbefore() throws Exception {
if (fIsVerbose)
DebugUtils.dump("--------- " + getName() + " ---------------");
- super.setUp();
+ super.genericbefore();
fIsPreDeltaTest= true;
}
@@ -171,7 +164,7 @@ public class MoveMembersTests extends RefactoringTest {
MoveRefactoring ref= createRefactoring(merge(methods, fields, types), destinationTypeName);
if (ref == null){
- assertEquals(errorLevel, RefactoringStatus.FATAL);
+ assertEquals(RefactoringStatus.FATAL, errorLevel);
return;
}
@@ -196,224 +189,273 @@ public class MoveMembersTests extends RefactoringTest {
//---
+ @Test
public void test0() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test1() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test2() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test3() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test4() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test5() throws Exception{
fieldHelper_passing(new String[]{"f"});
}
+ @Test
public void test6() throws Exception{
fieldHelper_passing(new String[]{"f"});
}
+ @Test
public void test7() throws Exception{
fieldHelper_passing(new String[]{"f"});
}
+ @Test
public void test8() throws Exception{
// printTestDisabledMessage("36835");
IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null);
fieldMethodTypePackageHelper_passing(new String[]{"f"}, new String[0], new String[0][0], new String[0], getPackageP(), packageForB, false);
}
+ @Test
public void test9() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test10() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test11() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test12() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test13() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test14() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test15() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test16() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test17() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test18() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test19() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test20() throws Exception{
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test21() throws Exception{
printTestDisabledMessage("not currently handling visibility issues induced by moving more than one static member");
//fieldHelper_passing(new String[]{"F", "i"});
}
+ @Test
public void test22() throws Exception{
fieldHelper_passing(new String[]{"i"});
}
+ @Test
public void test23() throws Exception{
fieldHelper_passing(new String[]{"FRED"});
}
+ @Test
public void test24() throws Exception{
fieldHelper_passing(new String[]{"FRED"});
}
+ @Test
public void test25() throws Exception{
//printTestDisabledMessage("test for 27098");
fieldHelper_passing(new String[]{"FRED"});
}
+ @Test
public void test26() throws Exception{
IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null);
fieldMethodTypePackageHelper_passing(new String[0], new String[]{"n"}, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false);
}
+ @Test
public void test27() throws Exception{
IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null);
fieldMethodTypePackageHelper_passing(new String[0], new String[]{"n"}, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false);
}
+ @Test
public void test28() throws Exception{
methodHelper_passing(new String[]{"m", "n"}, new String[][]{new String[0], new String[0]});
}
+ @Test
public void test29() throws Exception{ //test for bug 41691
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test30() throws Exception{ //test for bug 41691
fieldHelper_passing(new String[]{"id"});
}
+ @Test
public void test31() throws Exception{ //test for bug 41691
fieldHelper_passing(new String[]{"odd"});
}
+ @Test
public void test32() throws Exception{ //test for bug 41734, 41691
printTestDisabledMessage("test for 41734");
//methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test33() throws Exception{ //test for bug 28022
fieldHelper_passing(new String[]{"i"});
}
+ @Test
public void test34() throws Exception{ //test for bug 28022
fieldHelper_passing(new String[]{"i"});
}
+ @Test
public void test35() throws Exception{ //test for bug 28022
fieldHelper_passing(new String[]{"i"});
}
//-- move types:
+ @Test
public void test36() throws Exception {
typeHelper_passing(new String[]{"I"});
}
+ @Test
public void test37() throws Exception {
printTestDisabledMessage("qualified access to source");
// typeHelper_passing(new String[] {"Inner"});
}
+ @Test
public void test38() throws Exception {
fieldMethodTypeABHelper_passing(new String[0], new String[0], new String[0][0], new String[]{"Inner"});
}
+ @Test
public void test39() throws Exception {
printTestDisabledMessage("complex imports - need more work");
// fieldMethodType3CUsHelper_passing(new String[0], new String[0], new String[0][0],
// new String[]{"Inner"});
}
+ @Test
public void test40() throws Exception{
fieldMethodTypeHelper_passing(new String[] {"f"}, new String[]{"m"}, new String[][]{new String[0]}, new String[0], false);
}
+ @Test
public void test41() throws Exception{
methodHelper_passing(new String[] {"m"}, new String[][]{new String[0]});
}
//-- Visibility issues in the moved member:
+ @Test
public void test42() throws Exception{
//former testFail9
//Tests move of public static method m, which references private method f, into same package.
methodHelper_passing(new String[] {"m"}, new String[][]{new String[0]});
}
+ @Test
public void test43() throws Exception{
//former testFail10
//Tests move of public static method m, which references private field F, into same package
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test44() throws Exception{
//former testFail11
//Tests move of public static field i, which references private field F, into same package
fieldHelper_passing(new String[]{"i"});
}
+ @Test
public void test45() throws Exception{
//former testFail12
//Tests move of public static field i, which references private method m, into same package
fieldHelper_passing(new String[]{"i"});
}
+ @Test
public void test46() throws Exception{
//former testFail13
//Tests move of public static method m, which gets referenced by a field, into same package
methodHelper_passing(new String[]{"m"}, new String[][]{new String[0]});
}
+ @Test
public void test47() throws Exception{
//former testFail14
//Tests move of public static field i, which gets referenced by a field, into same package
fieldHelper_passing(new String[]{"i"});
}
+ @Test
public void test48() throws Exception{
//Move private unused method which calls another private method into another package
IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null);
@@ -422,38 +464,45 @@ public class MoveMembersTests extends RefactoringTest {
// --- Visibility issues of the moved member itself
+ @Test
public void test49() throws Exception{
//Move protected used field into another package
IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null);
fieldMethodTypePackageHelper_passing(new String[]{"someVar"}, new String[0], new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false);
}
+ @Test
public void test50() throws Exception{
//Move private used method into subtype.
methodHelper_passing(new String[]{"foo"}, new String[][]{new String[0]});
}
+ @Test
public void test51() throws Exception {
//Move private static inner class with private field (but used in outer class)
//assure both class and field get their visibility increased
typeHelper_passing(new String[] { "Inner" });
}
+ @Test
public void test52() throws Exception {
// assure moved unused field keeps its visibility
fieldHelper_passing(new String[] { "a" });
}
+ @Test
public void test53() throws Exception {
// assure moved unusued class keeps its visibility
typeHelper_passing(new String[] { "C" });
}
+ @Test
public void test54() throws Exception {
// moved used method is changed in visibility
methodHelper_passing(new String[] { "b" }, new String[][]{new String[0]});
}
+ @Test
public void test55() throws Exception {
// moved used method is changed in visibility
typeHelper_passing(new String[] { "C" });
@@ -461,11 +510,13 @@ public class MoveMembersTests extends RefactoringTest {
// --- Visibility of members of the moved type
+ @Test
public void test56() throws Exception {
// Move an inner class with two USED members
typeHelper_passing(new String[] { "Inner" });
}
+ @Test
public void test57() throws Exception {
// Move an inner class with two UNUSED members
typeHelper_passing(new String[] { "Inner" });
@@ -473,18 +524,21 @@ public class MoveMembersTests extends RefactoringTest {
// --- Visibility of used outer members
+ @Test
public void test58() throws Exception {
// Move a type which references a field in an enclosing type
// and a field in a sibling
typeHelper_passing(new String[] { "Inner" });
}
+ @Test
public void test59() throws Exception {
// Move a type which references a field in an enclosing type,
// and the enclosing type is private
typeHelper_passing(new String[] { "SomeInner.Inner" });
}
+ @Test
public void test60() throws Exception{
// Move a static private "getter" of a static field into another class
// only the field should be changed to public (bug 122490)
@@ -492,6 +546,7 @@ public class MoveMembersTests extends RefactoringTest {
fieldMethodTypePackageHelper_passing(new String[0], new String[] { "getNAME" }, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, false);
}
+ @Test
public void test61() throws Exception{
// Move some method which references a field with a getter and a setter
// only the field should be changed to public (bug 122490)
@@ -502,6 +557,7 @@ public class MoveMembersTests extends RefactoringTest {
// parameterized type references
+ @Test
public void test62() throws Exception {
// Move a type which references a field in an enclosing type
// and a field in a sibling
@@ -509,6 +565,7 @@ public class MoveMembersTests extends RefactoringTest {
}
//---
+ @Test
public void testFail0() throws Exception{
fieldMethodTypeHelper_failing(new String[0],
new String[]{"m"}, new String[][]{new String[0]},
@@ -517,6 +574,7 @@ public class MoveMembersTests extends RefactoringTest {
}
+ @Test
public void testFail1() throws Exception{
fieldMethodTypeHelper_failing(new String[0],
new String[]{"m"}, new String[][]{new String[0]},
@@ -524,6 +582,7 @@ public class MoveMembersTests extends RefactoringTest {
RefactoringStatus.ERROR, "p.B.X");
}
+ @Test
public void testFail2() throws Exception{
fieldMethodTypeHelper_failing(new String[0],
new String[]{"m"}, new String[][]{new String[0]},
@@ -531,6 +590,7 @@ public class MoveMembersTests extends RefactoringTest {
RefactoringStatus.ERROR, "p.B");
}
+ @Test
public void testFail3() throws Exception{
fieldMethodTypeHelper_failing(new String[0],
new String[]{"m"}, new String[][]{new String[]{"I", "I"}},
@@ -538,6 +598,7 @@ public class MoveMembersTests extends RefactoringTest {
RefactoringStatus.ERROR, "p.B");
}
+ @Test
public void testFail4() throws Exception{
fieldMethodTypeHelper_failing(new String[0],
new String[]{"m"}, new String[][]{new String[]{"I", "I"}},
@@ -545,6 +606,7 @@ public class MoveMembersTests extends RefactoringTest {
RefactoringStatus.WARNING, "p.B");
}
+ @Test
public void testFail5() throws Exception{
fieldMethodTypeHelper_failing(new String[0],
new String[]{"m"}, new String[][]{new String[]{"I", "I"}},
@@ -552,27 +614,32 @@ public class MoveMembersTests extends RefactoringTest {
RefactoringStatus.WARNING, "p.B");
}
+ @Test
public void testFail6() throws Exception{
fieldMethodTypeHelper_failing(new String[]{"i"}, new String[0], new String[0][0], new String[0],
RefactoringStatus.ERROR, "p.B");
}
+ @Test
public void testFail7() throws Exception{
fieldMethodTypeHelper_failing(new String[]{"i"}, new String[0], new String[0][0], new String[0],
RefactoringStatus.ERROR, "p.B");
}
+ @Test
public void testFail8() throws Exception{
fieldMethodTypeHelper_failing(new String[]{"i"}, new String[0], new String[0][0], new String[0],
RefactoringStatus.ERROR, "p.B");
}
+ @Test
public void testFail15() throws Exception{
fieldMethodTypeHelper_failing(new String[0],
new String[]{"m"}, new String[][]{new String[0]}, new String[0],
RefactoringStatus.WARNING, "p.B");
}
+ @Test
public void testFail16() throws Exception{
IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null);
fieldMethodTypePackageHelper_failing(new String[]{"f"}, new String[0], new String[0][0], new String[0],
@@ -580,42 +647,50 @@ public class MoveMembersTests extends RefactoringTest {
getPackageP(), packageForB);
}
+ @Test
public void testFail17() throws Exception{
fieldMethodTypeHelper_failing(new String[0],
new String[]{"m"}, new String[][]{new String[0]}, new String[0],
RefactoringStatus.FATAL, "java.lang.Object");
}
+ @Test
public void testFail18() throws Exception{
fieldMethodTypeHelper_failing(new String[0],
new String[]{"m"}, new String[][]{new String[0]}, new String[0],
RefactoringStatus.FATAL, "p.DontExist");
}
+ @Test
public void testFail19() throws Exception{
fieldMethodTypeHelper_failing(new String[0],
new String[]{"m"}, new String[][]{new String[0]}, new String[0],
RefactoringStatus.ERROR, "p.B");
}
+ @Test
public void testFail20() throws Exception{
// was same as test19
}
+ @Test
public void testFail21() throws Exception{
fieldMethodTypeHelper_failing(new String[0],
new String[]{"m"}, new String[][]{new String[0]}, new String[0],
RefactoringStatus.FATAL, "p.B");
}
+ @Test
public void testFail22() throws Exception{
//free slot
}
+ @Test
public void testFail23() throws Exception{
//free slot
}
+ @Test
public void testFail24() throws Exception{
fieldMethodTypeHelper_failing(new String[0],
new String[]{"m"}, new String[][]{new String[0]}, new String[0],
@@ -624,42 +699,50 @@ public class MoveMembersTests extends RefactoringTest {
// Delegate creation
+ @Test
public void testDelegate01() throws Exception {
// simple delegate method
methodHelperDelegate_passing(new String[] { "foo" }, new String[][]{new String[0]});
}
+ @Test
public void testDelegate02() throws Exception {
// increase visibility
methodHelperDelegate_passing(new String[] { "foo" }, new String[][]{new String[0]});
}
+ @Test
public void testDelegate03() throws Exception {
// ensure imports are removed correctly
methodHelperDelegate_passing(new String[] { "foo" }, new String[][]{new String[0]});
}
+ @Test
public void testDelegate04() throws Exception{
// add import when moving to another package
IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null);
fieldMethodTypePackageHelper_passing(new String[0], new String[] { "foo" }, new String[][]{new String[0]}, new String[0], getPackageP(), packageForB, true);
}
+ @Test
public void testDelegate05() throws Exception {
// simple delegate field
fieldHelperDelegate_passing(new String[] { "FOO" });
}
+ @Test
public void testDelegate06() throws Exception {
// increase visibility
fieldHelperDelegate_passing(new String[] { "FOO" });
}
+ @Test
public void testDelegate07() throws Exception {
// remove imports correctly
fieldHelperDelegate_passing(new String[] { "FOO" });
}
+ @Test
public void testDelegate08() throws Exception{
// add import when moving to another package
IPackageFragment packageForB= getRoot().createPackageFragment("r", false, null);
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests1d8.java
index 82b056c32c..96c4a0f5ff 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveMembersTests1d8.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,34 +13,38 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
-
-public class MoveMembersTests18 extends MoveMembersTests {
-
- private static final Class<MoveMembersTests18> clazz= MoveMembersTests18.class;
-
- public MoveMembersTests18(String name) {
- super(name);
- }
-
- public static Test suite() {
- return setUpTest(new NoSuperTestsSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new Java18Setup(someTest);
- }
-
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.eclipse.jdt.ui.tests.CustomBaseRunner;
+import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
+@IgnoreInheritedTests
+@RunWith(CustomBaseRunner.class)
+public class MoveMembersTests1d8 extends MoveMembersTests {
+ @SuppressWarnings("hiding")
+ @Rule
+ public RefactoringTestSetup fts= new Java1d8Setup();
+
+ @Test
public void test18_1() throws Exception {
// move private static method from class to interface, update visibility
methodHelper_passing(new String[] { "m" }, new String[][] { new String[0] });
}
+ @Test
public void test18_2() throws Exception {
// move static method from interface to another interface
methodHelper_passing(new String[] { "m" }, new String[][] { new String[0] });
}
+ @Test
public void test18_3() throws Exception {
// move static method from interface to class, add 'public'
methodHelper_passing(new String[] { "m" }, new String[][] { new String[0] });
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveRenameResourceChangeTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveRenameResourceChangeTests.java
index 2a581ec95b..bad5e42fac 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveRenameResourceChangeTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/MoveRenameResourceChangeTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
+ * Copyright (c) 2019, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,6 +14,14 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -28,30 +36,19 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.resource.MoveRenameResourceChange;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class MoveRenameResourceChangeTests extends RefactoringTest {
-
- private static final Class<MoveRenameResourceChangeTests> clazz= MoveRenameResourceChangeTests.class;
- public MoveRenameResourceChangeTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
- public static Test setUpTest(Test test) {
- return new RefactoringTestSetup(test);
- }
+public class MoveRenameResourceChangeTests extends GenericRefactoringTest {
+ @Rule
+ public RefactoringTestSetup fts= new RefactoringTestSetup();
+ @Test
public void testFile0() throws Exception{
IFolder folder= (IFolder)getPackageP().getCorrespondingResource();
String newName= "b.txt";
String oldName= "a.txt";
IFile file= folder.getFile(oldName);
- assertTrue("should not exist", ! file.exists());
+ assertFalse("should not exist", file.exists());
String content= "aaaaaaaaa";
file.create(getStream(content), true, new NullProgressMonitor());
assertTrue("should exist", file.exists());
@@ -60,16 +57,17 @@ public class MoveRenameResourceChangeTests extends RefactoringTest {
change.initializeValidationData(new NullProgressMonitor());
performChange(change);
assertTrue("after: should exist", folder.getFile(newName).exists());
- assertTrue("after: old should not exist", ! folder.getFile(oldName).exists());
+ assertFalse("after: old should not exist", folder.getFile(oldName).exists());
}
+ @Test
public void testFile1() throws Exception{
IFolder folder= (IFolder)getPackageP().getCorrespondingResource();
String newName= "b.txt";
String oldName= "a.txt";
IFile file= folder.getFile(oldName);
- assertTrue("should not exist", ! file.exists());
+ assertFalse("should not exist", file.exists());
String content= "";
file.create(getStream(content), true, new NullProgressMonitor());
assertTrue("should exist", file.exists());
@@ -79,16 +77,17 @@ public class MoveRenameResourceChangeTests extends RefactoringTest {
change.initializeValidationData(new NullProgressMonitor());
performChange(change);
assertTrue("after: should exist", folder.getFile(newName).exists());
- assertTrue("after: old should not exist", ! folder.getFile(oldName).exists());
+ assertFalse("after: old should not exist", folder.getFile(oldName).exists());
}
@SuppressWarnings("null")
+ @Test
public void testFile2() throws Exception{
IFolder folder= (IFolder)getPackageP().getCorrespondingResource();
String oldName= "a.txt";
String newName= "b.txt";
IFile file= folder.getFile(oldName);
- assertTrue("should not exist", ! file.exists());
+ assertFalse("should not exist", file.exists());
String content= "aaaaaaaaa";
file.create(getStream(content), true, new NullProgressMonitor());
assertTrue("should exist", file.exists());
@@ -97,24 +96,25 @@ public class MoveRenameResourceChangeTests extends RefactoringTest {
change.initializeValidationData(new NullProgressMonitor());
Change undo= performChange(change);
assertTrue("after: should exist", folder.getFile(newName).exists());
- assertTrue("after: old should not exist", ! folder.getFile(oldName).exists());
+ assertFalse("after: old should not exist", folder.getFile(oldName).exists());
//------
- assertTrue("should be undoable", undo != null);
+ assertNotNull("should be undoable", undo);
undo.initializeValidationData(new NullProgressMonitor());
performChange(undo);
assertTrue("after undo: should exist", folder.getFile(oldName).exists());
- assertTrue("after undo: old should not exist", ! folder.getFile(newName).exists());
+ assertFalse("after undo: old should not exist", folder.getFile(newName).exists());
}
@SuppressWarnings("null")
+ @Test
public void testFile3() throws Exception{
IFolder folder= (IFolder)getPackageP().getCorrespondingResource();
IFolder folder2= (IFolder)getPackageQ().getCorrespondingResource();
String oldName= "a.txt";
String newName= "b.txt";
IFile file= folder.getFile(oldName);
- assertTrue("should not exist", ! file.exists());
+ assertFalse("should not exist", file.exists());
String content= "aaaaaaaaa";
file.create(getStream(content), true, new NullProgressMonitor());
assertTrue("should exist", file.exists());
@@ -123,23 +123,24 @@ public class MoveRenameResourceChangeTests extends RefactoringTest {
change.initializeValidationData(new NullProgressMonitor());
Change undo= performChange(change);
assertTrue("after: should exist", folder2.getFile(newName).exists());
- assertTrue("after: old should not exist", ! folder.getFile(oldName).exists());
+ assertFalse("after: old should not exist", folder.getFile(oldName).exists());
//------
- assertTrue("should be undoable", undo != null);
+ assertNotNull("should be undoable", undo);
undo.initializeValidationData(new NullProgressMonitor());
performChange(undo);
assertTrue("after undo: should exist", folder.getFile(oldName).exists());
- assertTrue("after undo: old should not exist", ! folder2.getFile(newName).exists());
+ assertFalse("after undo: old should not exist", folder2.getFile(newName).exists());
}
+ @Test
public void testFolder0() throws Exception{
IFolder folder= (IFolder)getPackageP().getCorrespondingResource();
String newName= "b";
String oldName= "a";
IFolder subFolder= folder.getFolder(oldName);
- assertTrue("should not exist", ! subFolder.exists());
+ assertFalse("should not exist", subFolder.exists());
subFolder.create(true, true, null);
assertTrue("should exist", subFolder.exists());
@@ -148,16 +149,17 @@ public class MoveRenameResourceChangeTests extends RefactoringTest {
change.initializeValidationData(new NullProgressMonitor());
performChange(change);
assertTrue("after: should exist", folder.getFolder(newName).exists());
- assertTrue("after: old should not exist", ! folder.getFolder(oldName).exists());
+ assertFalse("after: old should not exist", folder.getFolder(oldName).exists());
}
+ @Test
public void testFolder1() throws Exception{
IFolder folder= (IFolder)getPackageP().getCorrespondingResource();
String newName= "b";
String oldName= "a";
IFolder subFolder= folder.getFolder(oldName);
- assertTrue("should not exist", ! subFolder.exists());
+ assertFalse("should not exist", subFolder.exists());
subFolder.create(true, true, null);
IFile file1= subFolder.getFile("a.txt");
IFile file2= subFolder.getFile("b.txt");
@@ -172,16 +174,17 @@ public class MoveRenameResourceChangeTests extends RefactoringTest {
change.initializeValidationData(new NullProgressMonitor());
performChange(change);
assertTrue("after: should exist", folder.getFolder(newName).exists());
- assertTrue("after: old should not exist", ! folder.getFolder(oldName).exists());
+ assertFalse("after: old should not exist", folder.getFolder(oldName).exists());
assertEquals("after: child count", 2, folder.getFolder(newName).members().length);
}
+ @Test
public void testFolder2() throws Exception{
IFolder folder= (IFolder)getPackageP().getCorrespondingResource();
String oldName= "a";
String newName= "b";
IFolder subFolder= folder.getFolder(oldName);
- assertTrue("should not exist", ! subFolder.exists());
+ assertFalse("should not exist", subFolder.exists());
subFolder.create(true, true, null);
assertTrue("should exist", subFolder.exists());
@@ -190,24 +193,25 @@ public class MoveRenameResourceChangeTests extends RefactoringTest {
change.initializeValidationData(new NullProgressMonitor());
Change undo= performChange(change);
assertTrue("after: should exist", folder.getFolder(newName).exists());
- assertTrue("after: old should not exist", ! folder.getFolder(oldName).exists());
+ assertFalse("after: old should not exist", folder.getFolder(oldName).exists());
//---
- assertTrue("should be undoable", undo != null);
+ assertNotNull("should be undoable", undo);
undo.initializeValidationData(new NullProgressMonitor());
performChange(undo);
assertTrue("after undo: should exist", folder.getFolder(oldName).exists());
- assertTrue("after undo: old should not exist", ! folder.getFolder(newName).exists());
+ assertFalse("after undo: old should not exist", folder.getFolder(newName).exists());
}
@SuppressWarnings("null")
+ @Test
public void testFolder3() throws Exception{
IFolder folder= (IFolder)getPackageP().getCorrespondingResource();
IFolder folder2= (IFolder)getPackageQ().getCorrespondingResource();
String oldName= "a";
String newName= "b";
IFolder subFolder= folder.getFolder(oldName);
- assertTrue("should not exist", ! subFolder.exists());
+ assertFalse("should not exist", subFolder.exists());
subFolder.create(true, true, null);
assertTrue("should exist", subFolder.exists());
@@ -216,16 +220,17 @@ public class MoveRenameResourceChangeTests extends RefactoringTest {
change.initializeValidationData(new NullProgressMonitor());
Change undo= performChange(change);
assertTrue("after: should exist", folder2.getFolder(newName).exists());
- assertTrue("after: old should not exist", ! folder.getFolder(oldName).exists());
+ assertFalse("after: old should not exist", folder.getFolder(oldName).exists());
//---
- assertTrue("should be undoable", undo != null);
+ assertNotNull("should be undoable", undo);
undo.initializeValidationData(new NullProgressMonitor());
performChange(undo);
assertTrue("after undo: should exist", folder.getFolder(oldName).exists());
- assertTrue("after undo: old should not exist", ! folder2.getFolder(newName).exists());
+ assertFalse("after undo: old should not exist", folder2.getFolder(newName).exists());
}
+ @Test
public void testJavaProject01() throws Exception {
String oldName= "RenameResourceChangeTest";
String newName= "RenameResourceChangeTest2";
@@ -256,7 +261,5 @@ public class MoveRenameResourceChangeTests extends RefactoringTest {
if (project2.exists())
JavaProjectHelper.delete(project2);
}
-
}
}
-
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/NoSuperTestsSuite.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/NoSuperTestsSuite.java
deleted file mode 100644
index 1f622e3bae..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/NoSuperTestsSuite.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Test suite that only includes tests from the given test class, but not
- * tests from super classes.
- *
- * @since 3.7
- */
-public class NoSuperTestsSuite extends TestSuite {
- /**
- * This implementation creates unnecessary test objects for tests from super classes
- * (in {@link junit.framework.TestSuite#addTestMethod}).
- * Alternative would have been to copy most of the implementation of TestSuite.
- */
-
- private static final Class<? extends Test> WARNING_TEST_CLASS= warning(null).getClass();
-
- public NoSuperTestsSuite(Class<? extends Test> theClass) {
- super(theClass);
- }
-
- /**
- * Adds the given test to this suite, but only if the test was declared in
- * the test object's class (and not in a superclass).
- */
- @Override
- public void addTest(Test test) {
- if (test instanceof TestCase) {
- TestCase testCase= (TestCase) test;
- Class<? extends TestCase> testClass= testCase.getClass();
- try {
- testClass.getDeclaredMethod(testCase.getName());
- } catch (NoSuchMethodException e) {
- if (testClass != WARNING_TEST_CLASS)
- return;
- }
- super.addTest(test);
- }
- }
-
- @Override
- public void addTestSuite(Class<? extends TestCase> testClass) {
- super.addTest(new NoSuperTestsSuite(testClass));
- }
-}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PathTransformationTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PathTransformationTests.java
index 7bc840938b..78573729f8 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PathTransformationTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PathTransformationTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,23 +13,20 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-public class PathTransformationTests extends TestCase {
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
- private static final Class<PathTransformationTests> clazz= PathTransformationTests.class;
- public PathTransformationTests(String name) {
- super(name);
- }
+public class PathTransformationTests {
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
+ @Rule
+ public RefactoringTestSetup rts= new RefactoringTestSetup();
private IPath createIPath(String p){
return Path.EMPTY.append(p);
@@ -48,66 +45,82 @@ public class PathTransformationTests extends TestCase {
/************/
+ @Test
public void test0(){
check("/s/p", "A.java", "B.java");
}
+ @Test
public void test1(){
check("/s/p", "A.java", "A.java");
}
+ @Test
public void test2(){
check("/s/p", "A.txt", "B.txt");
}
+ @Test
public void test3(){
check("/s/p", "A", "B");
}
+ @Test
public void test4(){
check("/s/p/p", "A.java", "B.java");
}
+ @Test
public void test5(){
check("/s/p/p", "A.java", "A.java");
}
+ @Test
public void test6(){
check("/s/p/p", "A.txt", "B.txt");
}
+ @Test
public void test7(){
check("/s", "A", "B.java");
}
+ @Test
public void test8(){
check("/s", "A.java", "B.java");
}
+ @Test
public void test9(){
check("/s", "A.java", "A.java");
}
+ @Test
public void test10(){
check("/s", "A.txt", "B.txt");
}
+ @Test
public void test11(){
check("/s", "A", "B");
}
+ @Test
public void test12(){
check("", "A.java", "B.java");
}
+ @Test
public void test13(){
check("", "A.java", "A.java");
}
+ @Test
public void test14(){
check("", "A.txt", "B.txt");
}
+ @Test
public void test15(){
check("", "A", "B");
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PromoteTempToFieldTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PromoteTempToFieldTests.java
index 30ef07105f..1d238907ed 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PromoteTempToFieldTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PromoteTempToFieldTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,15 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.Hashtable;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
@@ -29,37 +36,24 @@ import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring;
import org.eclipse.jdt.ui.tests.refactoring.infra.TextRangeUtil;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class PromoteTempToFieldTests extends RefactoringTest{
-
+public class PromoteTempToFieldTests extends GenericRefactoringTest{
private static final boolean BUG_39363= true;
- private static final Class<PromoteTempToFieldTests> clazz= PromoteTempToFieldTests.class;
private static final String REFACTORING_PATH= "PromoteTempToField/";
private String fCompactPref;
- public PromoteTempToFieldTests(String name){
- super(name);
- }
+ @Rule
+ public RefactoringTestSetup fts= new RefactoringTestSetup();
@Override
protected String getRefactoringPath() {
return REFACTORING_PATH;
}
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new RefactoringTestSetup(someTest);
- }
-
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void genericbefore() throws Exception {
+ super.genericbefore();
Hashtable<String, String> options= JavaCore.getOptions();
String setting= DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR;
@@ -69,15 +63,13 @@ public class PromoteTempToFieldTests extends RefactoringTest{
}
@Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ public void genericafter() throws Exception {
+ super.genericafter();
Hashtable<String, String> options= JavaCore.getOptions();
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, fCompactPref);
JavaCore.setOptions(options);
}
-
-
private String getSimpleTestFileName(boolean canRename, boolean input){
String fileName = "A_" + getName();
if (canRename)
@@ -209,6 +201,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
///---------------------- tests -------------------------//
+ @Test
public void testEnablement0() throws Exception{
boolean expectedCanEnableInitInConstructors = true;
boolean expectedCanEnableInitInMethod = true;
@@ -226,6 +219,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
expectedCanEnableSettingFinal, expectedCanEnableSettingStatic, expectedCanEnableInitInField, expectedCanEnableInitInMethod, expectedCanEnableInitInConstructors);
}
+ @Test
public void testEnablement1() throws Exception{
boolean expectedCanEnableInitInConstructors = false;
boolean expectedCanEnableInitInMethod = false;
@@ -235,6 +229,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
enablementHelper1(5, 13, 5, 14, expectedCanEnableSettingFinal, expectedCanEnableSettingStatic, expectedCanEnableInitInField, expectedCanEnableInitInMethod, expectedCanEnableInitInConstructors);
}
+ @Test
public void testEnablement2() throws Exception{
boolean expectedCanEnableInitInConstructors = false;
boolean expectedCanEnableInitInMethod = false;
@@ -244,6 +239,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
enablementHelper1(5, 13, 5, 14, expectedCanEnableSettingFinal, expectedCanEnableSettingStatic, expectedCanEnableInitInField, expectedCanEnableInitInMethod, expectedCanEnableInitInConstructors);
}
+ @Test
public void testEnablement3() throws Exception{
boolean expectedCanEnableInitInConstructors = true;
boolean expectedCanEnableInitInMethod = true;
@@ -253,6 +249,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
enablementHelper1(5, 13, 5, 14, expectedCanEnableSettingFinal, expectedCanEnableSettingStatic, expectedCanEnableInitInField, expectedCanEnableInitInMethod, expectedCanEnableInitInConstructors);
}
+ @Test
public void testEnablement4() throws Exception{
boolean expectedCanEnableInitInConstructors = false;
boolean expectedCanEnableInitInMethod = true;
@@ -270,6 +267,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
expectedCanEnableSettingFinal, expectedCanEnableSettingStatic, expectedCanEnableInitInField, expectedCanEnableInitInMethod, expectedCanEnableInitInConstructors);
}
+ @Test
public void testEnablement5() throws Exception{
boolean expectedCanEnableInitInConstructors = false;
boolean expectedCanEnableInitInMethod = true;
@@ -287,6 +285,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
expectedCanEnableSettingFinal, expectedCanEnableSettingStatic, expectedCanEnableInitInField, expectedCanEnableInitInMethod, expectedCanEnableInitInConstructors);
}
+ @Test
public void testEnablement6() throws Exception{
boolean expectedCanEnableInitInConstructors = false;
boolean expectedCanEnableInitInMethod = false;
@@ -296,6 +295,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
enablementHelper1(7, 21, 7, 22, expectedCanEnableSettingFinal, expectedCanEnableSettingStatic, expectedCanEnableInitInField, expectedCanEnableInitInMethod, expectedCanEnableInitInConstructors);
}
+ @Test
public void testEnablement7() throws Exception{
boolean expectedCanEnableInitInConstructors = false;
boolean expectedCanEnableInitInMethod = true;
@@ -305,6 +305,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
enablementHelper1(5, 13, 5, 14, expectedCanEnableSettingFinal, expectedCanEnableSettingStatic, expectedCanEnableInitInField, expectedCanEnableInitInMethod, expectedCanEnableInitInConstructors);
}
+ @Test
public void testEnablement8() throws Exception{
boolean expectedCanEnableInitInConstructors = true;
boolean expectedCanEnableInitInMethod = true;
@@ -322,6 +323,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
expectedCanEnableSettingFinal, expectedCanEnableSettingStatic, expectedCanEnableInitInField, expectedCanEnableInitInMethod, expectedCanEnableInitInConstructors);
}
+ @Test
public void testEnablement9() throws Exception{
boolean expectedCanEnableInitInConstructors = false;
boolean expectedCanEnableInitInMethod = true;
@@ -339,6 +341,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
expectedCanEnableSettingFinal, expectedCanEnableSettingStatic, expectedCanEnableInitInField, expectedCanEnableInitInMethod, expectedCanEnableInitInConstructors);
}
+ @Test
public void testEnablement10() throws Exception{
boolean expectedCanEnableInitInConstructors = false;
boolean expectedCanEnableInitInMethod = true;
@@ -356,6 +359,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
expectedCanEnableSettingFinal, expectedCanEnableSettingStatic, expectedCanEnableInitInField, expectedCanEnableInitInMethod, expectedCanEnableInitInConstructors);
}
+ @Test
public void testEnablement11() throws Exception{
boolean expectedCanEnableInitInConstructors = false;
boolean expectedCanEnableInitInMethod = true;
@@ -373,6 +377,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
expectedCanEnableSettingFinal, expectedCanEnableSettingStatic, expectedCanEnableInitInField, expectedCanEnableInitInMethod, expectedCanEnableInitInConstructors);
}
+ @Test
public void testEnablement12() throws Exception{
boolean expectedCanEnableInitInConstructors = false;
boolean expectedCanEnableInitInMethod = true;
@@ -390,6 +395,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
expectedCanEnableSettingFinal, expectedCanEnableSettingStatic, expectedCanEnableInitInField, expectedCanEnableInitInMethod, expectedCanEnableInitInConstructors);
}
+ @Test
public void testEnablement13() throws Exception{
boolean expectedCanEnableInitInConstructors = false;
boolean expectedCanEnableInitInMethod = true;
@@ -410,32 +416,39 @@ public class PromoteTempToFieldTests extends RefactoringTest{
///---- test failing preconditions --------------
+ @Test
public void testFail0() throws Exception{
failHelper(3, 16, 3, 17, "i", false, false, PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD, Modifier.PRIVATE, RefactoringStatus.FATAL);
}
+ @Test
public void testFail1() throws Exception{
failHelper(5, 28, 5, 29, "i", false, false, PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD, Modifier.PRIVATE, RefactoringStatus.FATAL);
}
+ @Test
public void testFail2() throws Exception{
failHelper(5, 15, 5, 16, "i", false, false, PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD, Modifier.PRIVATE, RefactoringStatus.FATAL);
}
+ @Test
public void testFail4() throws Exception{
failHelper(7, 13, 7, 14, "i", false, false, PromoteTempToFieldRefactoring.INITIALIZE_IN_CONSTRUCTOR, Modifier.PRIVATE, RefactoringStatus.FATAL);
}
+ @Test
public void testFail5() throws Exception{
failHelper(6, 13, 6, 14, "i", false, false, PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD, Modifier.PRIVATE, RefactoringStatus.FATAL);
}
+ @Test
public void testFailGenerics1() throws Exception{
failHelper(6, 12, 6, 12, "fYou", false, false, PromoteTempToFieldRefactoring.INITIALIZE_IN_CONSTRUCTOR, Modifier.PRIVATE, RefactoringStatus.FATAL);
}
///----------- tests of transformation ------------
+ @Test
public void test0() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -444,6 +457,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(5, 13, 5, 14, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test1() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_FIELD;
@@ -452,6 +466,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(5, 13, 5, 14, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test2() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_CONSTRUCTOR;
@@ -460,6 +475,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(7, 13, 7, 14, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test3() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_CONSTRUCTOR;
@@ -468,6 +484,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(9, 13, 9, 14, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test4() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_CONSTRUCTOR;
@@ -476,6 +493,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(5, 13, 5, 14, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test5() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -484,6 +502,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(6, 21, 6, 22, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test6() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_FIELD;
@@ -492,6 +511,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(6, 21, 6, 22, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test7() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_FIELD;
@@ -500,6 +520,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(4, 13, 4, 14, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test8() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -508,6 +529,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(4, 13, 4, 14, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test9() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -516,6 +538,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(5, 13, 5, 14, "field", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test10() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_CONSTRUCTOR;
@@ -524,6 +547,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(7, 13, 7, 14, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test11() throws Exception{
int accessModifier= Modifier.PUBLIC;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -532,6 +556,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(7, 13, 7, 14, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test12() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -540,6 +565,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(5, 13, 5, 14, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test13() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -548,6 +574,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(5, 13, 5, 14, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test14() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -556,6 +583,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(5, 19, 5, 20, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test15() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -564,6 +592,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(5, 19, 5, 20, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test16() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_CONSTRUCTOR;
@@ -572,6 +601,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(10, 13, 10, 14, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test17() throws Exception{
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -580,6 +610,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(4, 13, 4, 14, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test18() throws Exception{
//printTestDisabledMessage("regression test for bug 39363");
if (BUG_39363)
@@ -591,6 +622,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(5, 13, 5, 14, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test19() throws Exception{ //test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=49840
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -599,6 +631,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(4, 13, 4, 22, "fSomeArray", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test20() throws Exception{ //test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=49840
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -607,6 +640,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(4, 24, 4, 24, "fDoubleDim", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test21() throws Exception{ //test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=47798
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_FIELD;
@@ -615,6 +649,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(4, 17, 4, 18, "fgX", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test22() throws Exception{ //test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=54444
ICompilationUnit cu= createCUfromTestFile(getPackageP(), true, true);
ISourceRange selection= TextRangeUtil.getSelection(cu, 4, 34, 4, 37);
@@ -623,6 +658,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
assertEquals("fSortByDefiningTypeAction", ref.guessFieldNames()[0]);
}
+ @Test
public void test23() throws Exception{ //syntax error
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_FIELD;
@@ -631,6 +667,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(5, 31, 5, 31, "fCount", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test24() throws Exception{ //syntax error
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -639,6 +676,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(4, 33, 4, 33, "fFinisheds", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void test25() throws Exception{ //test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=136911
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -647,6 +685,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(7, 22, 7, 22, "i", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void testGenerics01() throws Exception {
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_FIELD;
@@ -655,6 +694,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(9, 9, 9, 11, "fVt", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void testGenerics02() throws Exception {
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -663,6 +703,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(6, 12, 6, 12, "fMyT", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void testEnum1() throws Exception {
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_CONSTRUCTOR;
@@ -671,6 +712,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(6, 13, 6, 16, "fVar", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void testEnum2() throws Exception {
int accessModifier= Modifier.PUBLIC;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_FIELD;
@@ -679,6 +721,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(10, 21, 10, 21, "fM", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void testMultiVariableDeclFragment01() throws Exception {
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -687,6 +730,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(6, 29, 6, 29, "fA", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void testMultiVariableDeclFragment02() throws Exception {
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -695,6 +739,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(5, 29, 5, 29, "fB", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void testMultiVariableDeclFragment03() throws Exception {
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -703,6 +748,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(5, 72, 5, 72, "fC", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void testMultiVariableDeclFragment04() throws Exception {
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -711,6 +757,7 @@ public class PromoteTempToFieldTests extends RefactoringTest{
passHelper(5, 41, 5, 41, "fD", declareStatic, declareFinal, initializeIn, accessModifier);
}
+ @Test
public void testDeclaringMethodBindingUnavailable01() throws Exception {
int accessModifier= Modifier.PRIVATE;
int initializeIn= PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD;
@@ -718,5 +765,4 @@ public class PromoteTempToFieldTests extends RefactoringTest{
boolean declareStatic= false;
passHelper(9, 14, 9, 18, "fDate", declareStatic, declareFinal, initializeIn, accessModifier);
}
-
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PromoteTempToFieldTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PromoteTempToFieldTests1d8.java
index 0d1006aadc..1fe3a8ecf9 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PromoteTempToFieldTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PromoteTempToFieldTests1d8.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 IBM Corporation and others.
+ * Copyright (c) 2014, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,7 +13,9 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
@@ -21,27 +23,28 @@ import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.internal.corext.refactoring.code.PromoteTempToFieldRefactoring;
-public class PromoteTempToFieldTests18 extends PromoteTempToFieldTests {
- private static final Class<PromoteTempToFieldTests18> clazz= PromoteTempToFieldTests18.class;
-
- public PromoteTempToFieldTests18(String name) {
- super(name);
- }
-
- public static Test setUpTest(Test test) {
- return new Java18Setup(test);
- }
-
- public static Test suite() {
- return setUpTest(new NoSuperTestsSuite(clazz));
- }
-
+import org.eclipse.jdt.ui.tests.CustomBaseRunner;
+import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
+@IgnoreInheritedTests
+@RunWith(CustomBaseRunner.class)
+public class PromoteTempToFieldTests1d8 extends PromoteTempToFieldTests {
+ @SuppressWarnings("hiding")
+ @Rule
+ public RefactoringTestSetup fts= new Java1d8Setup();
+
+ @Test
public void testFailInterfaceMethods1() throws Exception {
failHelper(6, 13, 6, 14, "i", false, false, PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD, Modifier.PRIVATE, RefactoringStatus.FATAL);
}
+ @Test
public void testFailInterfaceMethods2() throws Exception {
failHelper(6, 13, 6, 14, "i", false, false, PromoteTempToFieldRefactoring.INITIALIZE_IN_METHOD, Modifier.PRIVATE, RefactoringStatus.FATAL);
}
-
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests.java
index 9b1a52dc85..1ea82f8a27 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,10 +14,17 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -42,30 +49,18 @@ import org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester
import org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor;
import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil;
-import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java15Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
-public class PullUpTests extends RefactoringTest {
+import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
+public class PullUpTests extends GenericRefactoringTest {
private static final boolean BUG_91542= true;
- private static final Class<PullUpTests> clazz= PullUpTests.class;
-
private static final String REFACTORING_PATH= "PullUp/";
- public PullUpTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new Java15Setup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new Java15Setup(someTest);
- }
+ @Rule
+ public RefactoringTestSetup fts= new Java15Setup();
@Override
protected String getRefactoringPath() {
@@ -104,7 +99,7 @@ public class PullUpTests extends RefactoringTest {
processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false)));
RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
- assertTrue("precondition was supposed to pass", !checkInputResult.hasError());
+ assertFalse("precondition was supposed to pass", checkInputResult.hasError());
performChange(ref, false);
String expected= getFileContents(getOutputTestFileName("A"));
@@ -137,7 +132,7 @@ public class PullUpTests extends RefactoringTest {
}
RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
- assertTrue("precondition was supposed to pass", !checkInputResult.hasError());
+ assertFalse("precondition was supposed to pass", checkInputResult.hasError());
performChange(ref, false);
String expected= getFileContents(getOutputTestFileName("A", "p/"));
@@ -205,7 +200,7 @@ public class PullUpTests extends RefactoringTest {
setTargetClass(processor, targetClassIndex);
RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
- assertTrue("precondition was supposed to pass", !checkInputResult.hasError());
+ assertFalse("precondition was supposed to pass", checkInputResult.hasError());
performChange(ref, false);
String expected= getFileContents(getOutputTestFileName("A"));
@@ -225,7 +220,7 @@ public class PullUpTests extends RefactoringTest {
setTargetClass(processor, targetClassIndex);
RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
- assertTrue("precondition was supposed to pass", !checkInputResult.hasError());
+ assertFalse("precondition was supposed to pass", checkInputResult.hasError());
performChange(ref, false);
String expected= getFileContents(getOutputTestFileName("A"));
@@ -245,7 +240,7 @@ public class PullUpTests extends RefactoringTest {
setTargetClass(processor, targetClassIndex);
RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
- assertTrue("precondition was supposed to fail", !checkInputResult.isOK());
+ assertFalse("precondition was supposed to fail", checkInputResult.isOK());
}
protected static IMethod[] getMethods(IMember[] members){
@@ -302,7 +297,7 @@ public class PullUpTests extends RefactoringTest {
deleteAllMatchingMethods, targetClassIndex, cu);
RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
- assertTrue("precondition was supposed to fail", !checkInputResult.isOK());
+ assertFalse("precondition was supposed to fail", checkInputResult.isOK());
}
protected void declareAbstractHelper(String[] selectedMethodNames, String[][] selectedMethodSignatures,
@@ -318,7 +313,7 @@ public class PullUpTests extends RefactoringTest {
deleteAllMatchingMethods, targetClassIndex, cu);
RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
- assertTrue("precondition was supposed to pass", !checkInputResult.hasError());
+ assertFalse("precondition was supposed to pass", checkInputResult.hasError());
performChange(ref, false);
String expected= getFileContents(getOutputTestFileName("A"));
@@ -344,7 +339,7 @@ public class PullUpTests extends RefactoringTest {
processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false)));
RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
- assertTrue("precondition was supposed to pass", !checkInputResult.hasError());
+ assertFalse("precondition was supposed to pass", checkInputResult.hasError());
performChange(ref, false);
String expected= getFileContents(getOutputTestFileName("A"));
@@ -369,7 +364,7 @@ public class PullUpTests extends RefactoringTest {
processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false)));
RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
- assertTrue("precondition was supposed to fail", !checkInputResult.isOK());
+ assertFalse("precondition was supposed to fail", checkInputResult.isOK());
}
private void helper3(String[] methodNames, String[][] signatures, boolean deleteAllInSourceType, boolean deleteAllMatchingMethods, int targetClassIndex, boolean shouldActivationCheckPass) throws Exception {
@@ -392,27 +387,32 @@ public class PullUpTests extends RefactoringTest {
processor.setDeletedMethods(getMethods(processor.getMatchingElements(new NullProgressMonitor(), false)));
RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
- assertTrue("precondition was supposed to fail", !checkInputResult.isOK());
+ assertFalse("precondition was supposed to fail", checkInputResult.isOK());
}
//------------------ tests -------------
+ @Test
public void test0() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test1() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test2() throws Exception {
helper1(new String[] { "mmm", "n" }, new String[][] { new String[0], new String[0] }, true, false, 0);
}
+ @Test
public void test3() throws Exception {
helper1(new String[] { "mmm", "n" }, new String[][] { new String[0], new String[0] }, true, true, 0);
}
+ @Test
public void test4() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B");
@@ -438,6 +438,7 @@ public class PullUpTests extends RefactoringTest {
assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B")));
}
+ @Test
public void test5() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B");
@@ -463,30 +464,37 @@ public class PullUpTests extends RefactoringTest {
assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B")));
}
+ @Test
public void test6() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test7() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test8() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test9() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test10() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test11() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test12() throws Exception {
//printTestDisabledMessage("bug#6779 searchDeclarationsOfReferencedTyped - missing exception types");
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
@@ -513,65 +521,79 @@ public class PullUpTests extends RefactoringTest {
assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B")));
}
+ @Test
public void test13() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test14() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test15() throws Exception {
printTestDisabledMessage("must fix - incorrect error");
// helper1(new String[]{"m"}, new String[][]{new String[0]}, true, false);
}
+ @Test
public void test16() throws Exception {
printTestDisabledMessage("must fix - incorrect error");
// helper1(new String[]{"m"}, new String[][]{new String[0]}, true, false);
}
+ @Test
public void test17() throws Exception {
printTestDisabledMessage("must fix - incorrect error with static method access");
// helper1(new String[]{"m"}, new String[][]{new String[0]}, true, false);
}
+ @Test
public void test18() throws Exception {
printTestDisabledMessage("must fix - incorrect error with static field access");
// helper1(new String[]{"m"}, new String[][]{new String[0]}, true, false);
}
+ @Test
public void test19() throws Exception {
// printTestDisabledMessage("bug 18438");
// printTestDisabledMessage("bug 23324 ");
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test20() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 1);
}
+ @Test
public void test21() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 1);
}
+ @Test
public void test22() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test23() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test24() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test25() throws Exception {
// printTestDisabledMessage("bug in ASTRewrite - extra dimensions 29553");
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void test26() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -590,6 +612,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void test27() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -608,6 +631,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void test28() throws Exception {
// printTestDisabledMessage("unimplemented (increase method visibility if declare abstract in superclass)");
String[] selectedMethodNames= { "m" };
@@ -627,6 +651,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void test29() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[] { "[I" } };
@@ -645,6 +670,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void test30() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[] { "[I" } };
@@ -663,6 +689,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void test31() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[] { "[I" } };
@@ -681,6 +708,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void test32() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -699,6 +727,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void test33() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -717,6 +746,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void test34() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -735,6 +765,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void test35() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -753,6 +784,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void test36() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -771,6 +803,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void test37() throws Exception {
String[] selectedMethodNames= { "m", "f" };
String[][] selectedMethodSignatures= { new String[0], new String[0] };
@@ -789,6 +822,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void test38() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -807,6 +841,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void test39() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -827,6 +862,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0);
}
+ @Test
public void test40() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -847,6 +883,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0);
}
+ @Test
public void test41() throws Exception {
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -867,6 +904,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0);
}
+ @Test
public void test42() throws Exception {
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -887,6 +925,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0);
}
+ @Test
public void test43() throws Exception {
// printTestDisabledMessage("bug 35562 Method pull up wrongly indents javadoc comment [refactoring]");
@@ -909,6 +948,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0);
}
+ @Test
public void test44() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -929,6 +969,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0);
}
+ @Test
public void test45() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -949,6 +990,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0);
}
+ @Test
public void test46() throws Exception {
// for bug 196635
@@ -971,6 +1013,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0);
}
+ @Test
public void test47() throws Exception {
// for bug 211491
@@ -993,6 +1036,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0);
}
+ @Test
public void test48() throws Exception {
// for bug 211491, but with a super class
@@ -1015,6 +1059,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, false, false, 0);
}
+ @Test
public void test49() throws Exception {
// for bug 228950
@@ -1037,6 +1082,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, false, 0);
}
+ @Test
public void test50() throws Exception {
// for bug 125326
@@ -1066,6 +1112,7 @@ public class PullUpTests extends RefactoringTest {
}
+ @Test
public void test51() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B");
@@ -1089,6 +1136,7 @@ public class PullUpTests extends RefactoringTest {
assertEqualLines("A", cuA.getSource(), getFileContents(getOutputTestFileName("A")));
}
+ @Test
public void test52() throws Exception {
String[] selectedMethodNames= new String[] { "baz1", "baz2", "baz3", "baz4" };
String[][] selectedMethodSignatures= new String[][] { new String[0], new String[0], new String[0], new String[0] };
@@ -1102,6 +1150,7 @@ public class PullUpTests extends RefactoringTest {
}
// bug 396524
+ @Test
public void test53() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -1120,6 +1169,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void test55() throws Exception {
// test for bug 355327
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
@@ -1148,31 +1198,37 @@ public class PullUpTests extends RefactoringTest {
assertEqualLines("C", getFileContents(getOutputTestFileName("C")), cuC.getSource());
}
+ @Test
public void testFail0() throws Exception {
// printTestDisabledMessage("6538: searchDeclarationsOf* incorrect");
helper2(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testFail1() throws Exception {
printTestDisabledMessage("overloading - current limitation");
// helper2(new String[]{"m"}, new String[][]{new String[0]}, true, false);
}
+ @Test
public void testFail2() throws Exception {
// printTestDisabledMessage("6538: searchDeclarationsOf* incorrect");
helper2(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testFail3() throws Exception {
// printTestDisabledMessage("6538: searchDeclarationsOf* incorrect");
helper2(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testFail4() throws Exception {
// printTestDisabledMessage("6538: searchDeclarationsOf* incorrect");
helper2(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testFail6() throws Exception {
String[] methodNames= new String[] { "m" };
String[][] signatures= new String[][] { new String[0] };
@@ -1182,6 +1238,7 @@ public class PullUpTests extends RefactoringTest {
helper3(methodNames, signatures, deleteAllInSourceType, deleteAllMatchingMethods, 0, true);
}
+ @Test
public void testFail7() throws Exception {
String[] methodNames= new String[] { "m" };
String[][] signatures= new String[][] { new String[0] };
@@ -1190,6 +1247,7 @@ public class PullUpTests extends RefactoringTest {
helper3(methodNames, signatures, deleteAllInSourceType, deleteAllMatchingMethods, 0, false);
}
+ @Test
public void testFail8() throws Exception {
String[] methodNames= new String[] { "m" };
String[][] signatures= new String[][] { new String[0] };
@@ -1198,6 +1256,7 @@ public class PullUpTests extends RefactoringTest {
helper3(methodNames, signatures, deleteAllInSourceType, deleteAllMatchingMethods, 0, true);
}
+ @Test
public void testFail9() throws Exception {
String[] methodNames= new String[] { "m" };
String[][] signatures= new String[][] { new String[0] };
@@ -1206,6 +1265,7 @@ public class PullUpTests extends RefactoringTest {
helper3(methodNames, signatures, deleteAllInSourceType, deleteAllMatchingMethods, 0, true);
}
+ @Test
public void testFail10() throws Exception {
String[] methodNames= new String[] { "m" };
String[][] signatures= new String[][] { new String[0] };
@@ -1214,6 +1274,7 @@ public class PullUpTests extends RefactoringTest {
helper3(methodNames, signatures, deleteAllInSourceType, deleteAllMatchingMethods, 0, false);
}
+ @Test
public void testFail11() throws Exception {
String[] methodNames= new String[] { "m" };
String[][] signatures= new String[][] { new String[0] };
@@ -1222,6 +1283,7 @@ public class PullUpTests extends RefactoringTest {
helper3(methodNames, signatures, deleteAllInSourceType, deleteAllMatchingMethods, 0, true);
}
+ @Test
public void testFail12() throws Exception {
printTestDisabledMessage("overloading - current limitation");
// String[] methodNames= new String[]{"m"};
@@ -1231,6 +1293,7 @@ public class PullUpTests extends RefactoringTest {
// helper3(methodNames, signatures, deleteAllInSourceType, deleteAllMatchingMethods);
}
+ @Test
public void testFail13() throws Exception {
String[] methodNames= new String[] { "m" };
String[][] signatures= new String[][] { new String[0] };
@@ -1239,10 +1302,12 @@ public class PullUpTests extends RefactoringTest {
helper2(methodNames, signatures, deleteAllInSourceType, deleteAllMatchingMethods, 0);
}
+ @Test
public void testFail14() throws Exception {
//removed - this (pulling up classes) is allowed now
}
+ @Test
public void testFail15() throws Exception {
String[] methodNames= new String[] { "m" };
String[][] signatures= new String[][] { new String[0] };
@@ -1251,6 +1316,7 @@ public class PullUpTests extends RefactoringTest {
helper2(methodNames, signatures, deleteAllInSourceType, deleteAllMatchingMethods, 1);
}
+ @Test
public void testFail16() throws Exception {
String[] methodNames= new String[] { "m" };
String[][] signatures= new String[][] { new String[0] };
@@ -1259,6 +1325,7 @@ public class PullUpTests extends RefactoringTest {
helper2(methodNames, signatures, deleteAllInSourceType, deleteAllMatchingMethods, 1);
}
+ @Test
public void testFail17() throws Exception {
printTestDisabledMessage("unimplemented test - see bug 29522");
// String[] methodNames= new String[]{"m"};
@@ -1268,6 +1335,7 @@ public class PullUpTests extends RefactoringTest {
// helper2(methodNames, signatures, deleteAllInSourceType, deleteAllMatchingMethods, 1);
}
+ @Test
public void testFail18() throws Exception {
printTestDisabledMessage("unimplemented test - see bug 29522");
// String[] methodNames= new String[]{"m"};
@@ -1277,6 +1345,7 @@ public class PullUpTests extends RefactoringTest {
// helper2(methodNames, signatures, deleteAllInSourceType, deleteAllMatchingMethods, 0);
}
+ @Test
public void testFail19() throws Exception {
String[] methodNames= new String[] { "m" };
String[][] signatures= new String[][] { new String[0] };
@@ -1285,6 +1354,7 @@ public class PullUpTests extends RefactoringTest {
helper2(methodNames, signatures, deleteAllInSourceType, deleteAllMatchingMethods, 1);
}
+ @Test
public void testFail20() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -1303,6 +1373,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void testFail21() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -1321,6 +1392,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void testFail22() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -1339,6 +1411,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void testFail23() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -1357,6 +1430,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void testFail24() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -1375,6 +1449,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, new String[0], true, true, 0);
}
+ @Test
public void testFail25() throws Exception {
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -1395,6 +1470,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0);
}
+ @Test
public void testFail26() throws Exception {
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -1415,6 +1491,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0);
}
+ @Test
public void testFail27() throws Exception {
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -1435,6 +1512,7 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0);
}
+ @Test
public void testFail28() throws Exception {
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -1455,51 +1533,62 @@ public class PullUpTests extends RefactoringTest {
signaturesOfMethodsToDeclareAbstract, namesOfTypesToPullUp, true, true, 0);
}
+ @Test
public void testFail29() throws Exception {
helper2(new String[] { "stop" }, new String[][] { new String[0] }, true, false, 0);
}
//----------------------------------------------------------
+ @Test
public void testField0() throws Exception {
fieldHelper1(new String[] { "i" }, 0);
}
+ @Test
public void testField1() throws Exception {
fieldHelper1b(new String[] { "x" }, 1);
}
+ @Test
public void testFieldFail0() throws Exception {
fieldHelper2(new String[] { "x" }, 0);
}
+ @Test
public void testFieldFail2() throws Exception {
fieldHelper2(new String[] { "f" }, 1);
}
//---------------------------------------------------------
+ @Test
public void testFieldMethod0() throws Exception {
// printTestDisabledMessage("bug 23324 ");
fieldMethodHelper1(new String[] { "f" }, new String[] { "m" }, new String[][] { new String[0] }, true, false);
}
//---------------------------------------------------------
+ @Test
public void testFieldMethod1() throws Exception {
fieldMethodHelper2(new String[] { "c" }, new String[] {}, new String[][] { new String[0] }, true, false);
}
+ @Test
public void testFieldMethod2() throws Exception {
fieldMethodHelper2(new String[] { "c" }, new String[] {}, new String[][] { new String[0] }, true, false);
}
+ @Test
public void testFieldMethod3() throws Exception {
fieldMethodHelper2(new String[] { "c" }, new String[] {}, new String[][] { new String[0] }, true, false);
}
+ @Test
public void testFieldMethod4() throws Exception {
fieldMethodHelper2(new String[] { "c" }, new String[] {}, new String[][] { new String[0] }, true, false);
}
//----
+ @Test
public void testAddingRequiredMembers0() throws Exception {
String[] fieldNames= {};
String[] methodNames= { "m" };
@@ -1511,6 +1600,7 @@ public class PullUpTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers1() throws Exception {
String[] fieldNames= {};
String[] methodNames= { "m" };
@@ -1522,6 +1612,7 @@ public class PullUpTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers2() throws Exception {
String[] fieldNames= {};
String[] methodNames= { "m" };
@@ -1533,6 +1624,7 @@ public class PullUpTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers3() throws Exception {
String[] fieldNames= {};
String[] methodNames= { "m" };
@@ -1544,6 +1636,7 @@ public class PullUpTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers4() throws Exception {
String[] fieldNames= {};
String[] methodNames= { "m" };
@@ -1555,6 +1648,7 @@ public class PullUpTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers5() throws Exception {
String[] fieldNames= { "y" };
String[] methodNames= {};
@@ -1566,6 +1660,7 @@ public class PullUpTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers6() throws Exception {
String[] fieldNames= {};
String[] methodNames= { "m" };
@@ -1577,6 +1672,7 @@ public class PullUpTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers7() throws Exception {
String[] fieldNames= {};
String[] methodNames= { "m" };
@@ -1588,6 +1684,7 @@ public class PullUpTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers8() throws Exception {
String[] fieldNames= {};
String[] methodNames= { "m" };
@@ -1599,6 +1696,7 @@ public class PullUpTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers9() throws Exception {
String[] fieldNames= { "m" };
String[] methodNames= {};
@@ -1610,6 +1708,7 @@ public class PullUpTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers10() throws Exception {
String[] fieldNames= { "m" };
String[] methodNames= {};
@@ -1621,6 +1720,7 @@ public class PullUpTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers11() throws Exception {
String[] fieldNames= { "m" };
String[] methodNames= {};
@@ -1632,6 +1732,7 @@ public class PullUpTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers12() throws Exception {
String[] fieldNames= {};
String[] methodNames= { "m" };
@@ -1643,6 +1744,7 @@ public class PullUpTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testEnablement0() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
@@ -1650,123 +1752,140 @@ public class PullUpTests extends RefactoringTest {
assertTrue("should be enabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement1() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
IType typeD= cu.getType("D");
IMember[] members= { typeB, typeD };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement2() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("Outer").getType("B");
IMember[] members= { typeB };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement3() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
IMember[] members= { typeB };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement4() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
IMember[] members= { typeB };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement5() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
IMember[] members= { typeB };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement6() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
IMember[] members= { typeB };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement7() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
IMember[] members= { typeB };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement8() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("Outer").getType("B");
IMember[] members= { typeB };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement9() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("Outer").getType("B");
IMember[] members= { typeB };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement10() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("Outer").getType("B");
IMember[] members= { typeB };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement11() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("Outer").getType("B");
IMember[] members= { typeB };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement12() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("Outer").getType("B");
IMember[] members= { typeB };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement13() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
IType typeD= cu.getType("D");
IMember[] members= { typeB, typeD };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement14() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
IType typeD= cu.getType("D");
IMember[] members= { typeB, typeD };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement15() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
IType typeD= cu.getType("D");
IMember[] members= { typeB, typeD };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement16() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
IType typeD= cu.getType("D");
IMember[] members= { typeB, typeD };
- assertTrue("should be disabled", !RefactoringAvailabilityTester.isPullUpAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement17() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
@@ -1774,6 +1893,7 @@ public class PullUpTests extends RefactoringTest {
assertTrue("should be enabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement18() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
@@ -1781,6 +1901,7 @@ public class PullUpTests extends RefactoringTest {
assertTrue("should be enabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement19() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
@@ -1788,6 +1909,7 @@ public class PullUpTests extends RefactoringTest {
assertTrue("should be enabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement20() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
@@ -1795,6 +1917,7 @@ public class PullUpTests extends RefactoringTest {
assertTrue("should be enabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement21() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
@@ -1802,6 +1925,7 @@ public class PullUpTests extends RefactoringTest {
assertTrue("should be enabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement22() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
@@ -1809,6 +1933,7 @@ public class PullUpTests extends RefactoringTest {
assertTrue("should be enabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement23() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
@@ -1816,6 +1941,7 @@ public class PullUpTests extends RefactoringTest {
assertTrue("should be enabled", RefactoringAvailabilityTester.isPullUpAvailable(members));
}
+ @Test
public void testEnablement24() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("B");
@@ -1825,6 +1951,7 @@ public class PullUpTests extends RefactoringTest {
//------------------ tests -------------
+ @Test
public void testStaticImports0() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B");
@@ -1850,6 +1977,7 @@ public class PullUpTests extends RefactoringTest {
assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B")));
}
+ @Test
public void testStaticImports1() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B");
@@ -1875,22 +2003,27 @@ public class PullUpTests extends RefactoringTest {
assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B")));
}
+ @Test
public void testGenerics0() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testGenerics1() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testGenerics2() throws Exception {
helper1(new String[] { "mmm", "n" }, new String[][] { new String[] { "QT;" }, new String[0] }, true, false, 0);
}
+ @Test
public void testGenerics3() throws Exception {
helper1(new String[] { "mmm", "n" }, new String[][] { new String[] { "QT;" }, new String[0] }, true, true, 0);
}
+ @Test
public void testGenerics4() throws Exception {
printTestDisabledMessage("see bug 75642");
@@ -1915,6 +2048,7 @@ public class PullUpTests extends RefactoringTest {
// assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B")));
}
+ @Test
public void testGenerics5() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B");
@@ -1940,10 +2074,12 @@ public class PullUpTests extends RefactoringTest {
assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B")));
}
+ @Test
public void testGenerics6() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testGenerics7() throws Exception {
printTestDisabledMessage("Disabled because of bug ");
@@ -1951,10 +2087,12 @@ public class PullUpTests extends RefactoringTest {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testGenerics8() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testGenerics9() throws Exception {
printTestDisabledMessage("Disabled because of bug ");
@@ -1962,14 +2100,17 @@ public class PullUpTests extends RefactoringTest {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testGenerics10() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testGenerics11() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testGenerics12() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B");
@@ -1995,26 +2136,32 @@ public class PullUpTests extends RefactoringTest {
assertEqualLines("B", cuB.getSource(), getFileContents(getOutputTestFileName("B")));
}
+ @Test
public void testGenerics13() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testGenerics14() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testGenerics15() throws Exception {
helper1(new String[] { "m" }, new String[][] { new String[0] }, true, false, 0);
}
+ @Test
public void testGenericsFail0() throws Exception {
helper2(new String[] { "m" }, new String[][] { new String[] { "QT;" } }, true, false, 0);
}
+ @Test
public void testGenericsFail1() throws Exception {
helper2(new String[] { "m" }, new String[][] { new String[] { "QS;" } }, true, false, 0);
}
+ @Test
public void testGenericsFail2() throws Exception {
helper2(new String[] { "m" }, new String[][] { new String[] { "QT;" } }, true, false, 0);
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests1d8.java
index c46fdb1c36..1d856d9d7b 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PullUpTests1d8.java
@@ -13,8 +13,15 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Hashtable;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -35,33 +42,29 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.corext.refactoring.structure.PullUpRefactoringProcessor;
import org.eclipse.jdt.ui.PreferenceConstants;
-import org.eclipse.jdt.ui.tests.core.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.CustomBaseRunner;
+import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
import org.eclipse.jdt.internal.ui.JavaPlugin;
-import junit.framework.Test;
-
-public class PullUpTests18 extends PullUpTests {
-
- private static final Class<PullUpTests18> clazz= PullUpTests18.class;
-
- public PullUpTests18(String name) {
- super(name);
- }
-
- public static Test suite() {
- return setUpTest(new NoSuperTestsSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new Java18Setup(someTest);
- }
-
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
+@IgnoreInheritedTests
+@RunWith(CustomBaseRunner.class)
+public class PullUpTests1d8 extends PullUpTests {
+ @SuppressWarnings("hiding")
+ @Rule
+ public RefactoringTestSetup fts= new Java1d8Setup();
+
+ @Test
public void test18_1() throws Exception {
-
String[] methodNames= new String[] { "getArea" };
String[][] signatures= new String[][] { new String[] { "QInteger;" } };
- JavaProjectHelper.addLibrary((IJavaProject) getPackageP().getAncestor(IJavaElement.JAVA_PROJECT), new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary((IJavaProject) getPackageP().getAncestor(IJavaElement.JAVA_PROJECT), new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B");
@@ -81,10 +84,10 @@ public class PullUpTests18 extends PullUpTests {
assertEqualLines("A", getFileContents(getOutputTestFileName("A")), cuA.getSource());
assertEqualLines("B", getFileContents(getOutputTestFileName("B")), cuB.getSource());
-
}
// bug 394551 comment 2
+ @Test
public void test18_2() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -104,6 +107,7 @@ public class PullUpTests18 extends PullUpTests {
}
// bug 394551 expect @java.lang.Override
+ @Test
public void test18_3() throws Exception {
String[] selectedMethodNames= { "m" };
String[][] selectedMethodSignatures= { new String[0] };
@@ -123,6 +127,7 @@ public class PullUpTests18 extends PullUpTests {
}
// bug 394551: no override annotation expected
+ @Test
public void test18_4() throws Exception {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
boolean previousValue= store.getBoolean(PreferenceConstants.CODEGEN_USE_OVERRIDE_ANNOTATION);
@@ -149,6 +154,7 @@ public class PullUpTests18 extends PullUpTests {
}
// bug 394551: no override annotation expected
+ @Test
public void test18_5() throws Exception {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
boolean previousValue= store.getBoolean(PreferenceConstants.CODEGEN_USE_OVERRIDE_ANNOTATION);
@@ -181,6 +187,7 @@ public class PullUpTests18 extends PullUpTests {
}
// bug 394551: override annotation expected
+ @Test
public void test18_6() throws Exception {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
boolean previousValue= store.getBoolean(PreferenceConstants.CODEGEN_USE_OVERRIDE_ANNOTATION);
@@ -212,6 +219,7 @@ public class PullUpTests18 extends PullUpTests {
}
// bug 497368
+ @Test
public void test54() throws Exception {
ICompilationUnit cuFoo= createCUfromTestFile(getPackageP(), "Foo");
ICompilationUnit cuIFoo= createCUfromTestFile(getPackageP(), "IFoo");
@@ -238,6 +246,7 @@ public class PullUpTests18 extends PullUpTests {
}
// bug 552377
+ @Test
public void testGenerics16() throws Exception {
ICompilationUnit cuIGeneric= createCUfromTestFile(getPackageP(), "IGeneric");
ICompilationUnit cuMainImpl= createCUfromTestFile(getPackageP(), "MainImpl");
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PushDownTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PushDownTests.java
index eb3521c864..a12e3f255b 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PushDownTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/PushDownTests.java
@@ -13,10 +13,17 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -35,26 +42,14 @@ import org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester
import org.eclipse.jdt.internal.corext.refactoring.structure.PushDownRefactoringProcessor;
import org.eclipse.jdt.internal.corext.refactoring.structure.PushDownRefactoringProcessor.MemberActionInfo;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class PushDownTests extends RefactoringTest {
-
- private static final Class<PushDownTests> clazz= PushDownTests.class;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java15Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+public class PushDownTests extends GenericRefactoringTest {
private static final String REFACTORING_PATH= "PushDown/";
- public PushDownTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new Java15Setup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new Java15Setup(someTest);
- }
+ @Rule
+ public RefactoringTestSetup fts= new Java15Setup();
@Override
protected String getRefactoringPath() {
@@ -93,11 +88,11 @@ public class PushDownTests extends RefactoringTest {
for (MemberActionInfo info : processor.getMemberActionInfos()) {
if (membersToPushDown.contains(info.getMember())) {
info.setAction(MemberActionInfo.PUSH_DOWN_ACTION);
- assertTrue(!methodsToDeclareAbstract.contains(info.getMember()));
+ assertFalse(methodsToDeclareAbstract.contains(info.getMember()));
}
if (methodsToDeclareAbstract.contains(info.getMember())) {
info.setAction(MemberActionInfo.PUSH_ABSTRACT_ACTION);
- assertTrue(!membersToPushDown.contains(info.getMember()));
+ assertFalse(membersToPushDown.contains(info.getMember()));
}
}
}
@@ -116,7 +111,7 @@ public class PushDownTests extends RefactoringTest {
namesOfFieldsToPullUp, namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, cuA);
RefactoringStatus checkInputResult= ref.checkFinalConditions(new NullProgressMonitor());
- assertTrue("precondition was supposed to pass but got " + checkInputResult.toString(), !checkInputResult.hasError());
+ assertFalse("precondition was supposed to pass but got " + checkInputResult.toString(), checkInputResult.hasError());
performChange(ref, false);
String expected= getFileContents(getOutputTestFileName("A"));
@@ -147,7 +142,7 @@ public class PushDownTests extends RefactoringTest {
IPackageFragment[] additionalPacks= new IPackageFragment[0];
if (additionalPackNames != null){
additionalPacks= new IPackageFragment[additionalPackNames.length];
- assertTrue(additionalPackNames.length == additionalCuNames.length);
+ assertEquals(additionalPackNames.length, additionalCuNames.length);
for (int i= 0; i < additionalPackNames.length; i++) {
additionalPacks[i]= getRoot().getPackageFragment(additionalPackNames[i]);
}
@@ -227,6 +222,7 @@ public class PushDownTests extends RefactoringTest {
//--------------------------------------------------------
+ @Test
public void test0() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -244,6 +240,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test1() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -261,6 +258,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test2() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -278,6 +276,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test3() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -295,6 +294,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test4() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -312,6 +312,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test5() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -329,6 +330,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test6() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -346,6 +348,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test7() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -363,6 +366,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test8() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -380,6 +384,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test9() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -397,6 +402,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test10() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -414,6 +420,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test11() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -431,6 +438,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test12() throws Exception{
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -448,6 +456,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test13() throws Exception{
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -465,6 +474,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test14() throws Exception{
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -482,6 +492,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test15() throws Exception{
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -499,6 +510,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test16() throws Exception{
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -516,6 +528,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test17() throws Exception{
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -533,6 +546,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test18() throws Exception{
String[] selectedMethodNames= {"f", "m"};
String[][] selectedMethodSignatures= {new String[0], new String[0]};
@@ -550,6 +564,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test19() throws Exception{
String[] selectedMethodNames= {"f", "m"};
String[][] selectedMethodSignatures= {new String[0], new String[0]};
@@ -567,6 +582,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test20() throws Exception{
String[] selectedMethodNames= {"f", "m"};
String[][] selectedMethodSignatures= {new String[0], new String[0]};
@@ -585,6 +601,7 @@ public class PushDownTests extends RefactoringTest {
new String[]{"B"}, new String[]{"p"});
}
+ @Test
public void test21() throws Exception{
String[] selectedMethodNames= {"f", "m"};
String[][] selectedMethodSignatures= {new String[0], new String[0]};
@@ -603,6 +620,7 @@ public class PushDownTests extends RefactoringTest {
new String[]{"B", "C"}, new String[]{"p", "p"});
}
+ @Test
public void test22() throws Exception{
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -620,6 +638,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test23() throws Exception{
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -637,6 +656,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test24() throws Exception{
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -654,6 +674,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test25() throws Exception{
String[] selectedMethodNames= {"foo"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -671,6 +692,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test26() throws Exception{
String[] selectedMethodNames= {"bar"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -688,6 +710,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test27() throws Exception{
String[] selectedMethodNames= {"bar"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -705,6 +728,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test28() throws Exception{
// if (true){
// printTestDisabledMessage("37175");
@@ -726,6 +750,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test29() throws Exception{
String[] selectedMethodNames= {"foo"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -743,6 +768,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test30() throws Exception{
String[] selectedMethodNames= {"foo"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -760,6 +786,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test31() throws Exception{
String[] selectedMethodNames= {"foo"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -777,6 +804,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test32() throws Exception{
String[] selectedMethodNames= {"foo"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -794,6 +822,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void test33() throws Exception{
String[] selectedMethodNames= {"f", "m"};
String[][] selectedMethodSignatures= {new String[0], new String[0]};
@@ -812,6 +841,7 @@ public class PushDownTests extends RefactoringTest {
new String[]{"B", "C"}, new String[]{"p", "p"});
}
+ @Test
public void test34() throws Exception{
printTestDisabledMessage("disabled due to missing support for statically imported methods");
@@ -832,6 +862,7 @@ public class PushDownTests extends RefactoringTest {
// new String[]{"B", "C"}, new String[]{"p", "p"});
}
+ @Test
public void test35() throws Exception{
String[] selectedMethodNames= {"foo"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -850,6 +881,7 @@ public class PushDownTests extends RefactoringTest {
}
+ @Test
public void testFail0() throws Exception {
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -860,6 +892,7 @@ public class PushDownTests extends RefactoringTest {
RefactoringStatus.FATAL);
}
+ @Test
public void testFail1() throws Exception {
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -870,6 +903,7 @@ public class PushDownTests extends RefactoringTest {
RefactoringStatus.FATAL);
}
+ @Test
public void testFail2() throws Exception {
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -888,6 +922,7 @@ public class PushDownTests extends RefactoringTest {
RefactoringStatus.ERROR);
}
+ @Test
public void testFail3() throws Exception {
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -906,6 +941,7 @@ public class PushDownTests extends RefactoringTest {
RefactoringStatus.ERROR);
}
+ @Test
public void testVisibility1() throws Exception {
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -923,6 +959,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testVisibility2() throws Exception {
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -940,6 +977,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testVisibility3() throws Exception {
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -957,6 +995,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testFail7() throws Exception {
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -975,6 +1014,7 @@ public class PushDownTests extends RefactoringTest {
RefactoringStatus.ERROR);
}
+ @Test
public void testFail8() throws Exception {
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -993,6 +1033,7 @@ public class PushDownTests extends RefactoringTest {
RefactoringStatus.ERROR);
}
+ @Test
public void testFail9() throws Exception {
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -1011,6 +1052,7 @@ public class PushDownTests extends RefactoringTest {
RefactoringStatus.ERROR);
}
+ @Test
public void testFail10() throws Exception {
String[] selectedMethodNames= {"foo"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1029,6 +1071,7 @@ public class PushDownTests extends RefactoringTest {
RefactoringStatus.ERROR);
}
+ @Test
public void testFail11() throws Exception {
String[] selectedMethodNames= {"foo"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1047,6 +1090,7 @@ public class PushDownTests extends RefactoringTest {
RefactoringStatus.ERROR);
}
+ @Test
public void testFail12() throws Exception {
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -1065,6 +1109,7 @@ public class PushDownTests extends RefactoringTest {
RefactoringStatus.ERROR);
}
+ @Test
public void testVisibility0() throws Exception {
String[] selectedMethodNames= {"foo"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1082,6 +1127,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testAddingRequiredMembers0() throws Exception{
String[] fieldNames= {};
String[] methodNames= {"m"};
@@ -1093,6 +1139,7 @@ public class PushDownTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers1() throws Exception{
String[] fieldNames= {};
String[] methodNames= {"m"};
@@ -1104,6 +1151,7 @@ public class PushDownTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers2() throws Exception{
String[] fieldNames= {};
String[] methodNames= {"m"};
@@ -1115,6 +1163,7 @@ public class PushDownTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers3() throws Exception{
String[] fieldNames= {};
String[] methodNames= {"m"};
@@ -1126,6 +1175,7 @@ public class PushDownTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers4() throws Exception{
String[] fieldNames= {};
String[] methodNames= {"m", "f"};
@@ -1137,6 +1187,7 @@ public class PushDownTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers5() throws Exception{
String[] fieldNames= {};
String[] methodNames= {"m"};
@@ -1148,6 +1199,7 @@ public class PushDownTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers6() throws Exception{
String[] fieldNames= {"f"};
String[] methodNames= {"m"};
@@ -1159,6 +1211,7 @@ public class PushDownTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers7() throws Exception{
String[] fieldNames= {"f"};
String[] methodNames= {};
@@ -1170,6 +1223,7 @@ public class PushDownTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers8() throws Exception{
String[] fieldNames= {"f"};
String[] methodNames= {};
@@ -1181,6 +1235,7 @@ public class PushDownTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testAddingRequiredMembers9() throws Exception{
String[] fieldNames= {"f"};
String[] methodNames= {};
@@ -1192,6 +1247,7 @@ public class PushDownTests extends RefactoringTest {
addRequiredMembersHelper(fieldNames, methodNames, methodSignatures, expectedFieldNames, expectedMethodNames, expectedMethodSignatures);
}
+ @Test
public void testEnablement0() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeA= cu.getType("A");
@@ -1199,28 +1255,32 @@ public class PushDownTests extends RefactoringTest {
assertTrue("should be enabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement1() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeA= cu.getType("A");
IMember[] members= {typeA};
- assertTrue("should be disabled", ! RefactoringAvailabilityTester.isPushDownAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement2() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("Outer").getType("B");
IMember[] members= {typeB};
- assertTrue("should be disabled", ! RefactoringAvailabilityTester.isPushDownAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement3() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeA= cu.getType("A");
IType typeB= cu.getType("B");
IMember[] members= {typeA, typeB};
- assertTrue("should be disabled", ! RefactoringAvailabilityTester.isPushDownAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement4() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeA= cu.getType("A");
@@ -1228,6 +1288,7 @@ public class PushDownTests extends RefactoringTest {
assertTrue("should be enabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement5() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeA= cu.getType("A");
@@ -1235,6 +1296,7 @@ public class PushDownTests extends RefactoringTest {
assertTrue("should be enabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement6() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeA= cu.getType("A");
@@ -1242,6 +1304,7 @@ public class PushDownTests extends RefactoringTest {
assertTrue("should be enabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement7() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeA= cu.getType("A");
@@ -1249,6 +1312,7 @@ public class PushDownTests extends RefactoringTest {
assertTrue("should be enabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement8() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeA= cu.getType("A");
@@ -1256,55 +1320,63 @@ public class PushDownTests extends RefactoringTest {
assertTrue("should be enabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement9() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeA= cu.getType("A");
IMember[] members= {typeA};
- assertTrue("should be disabled", ! RefactoringAvailabilityTester.isPushDownAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement10() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeA= cu.getType("A");
IMember[] members= {typeA};
- assertTrue("should be disabled", ! RefactoringAvailabilityTester.isPushDownAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement11() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeA= cu.getType("A");
IMember[] members= {typeA};
- assertTrue("should be disabled", ! RefactoringAvailabilityTester.isPushDownAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement12() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("Outer").getType("B");
IMember[] members= {typeB};
- assertTrue("should be disabled", ! RefactoringAvailabilityTester.isPushDownAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement13() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("Outer").getType("B");
IMember[] members= {typeB};
- assertTrue("should be disabled", ! RefactoringAvailabilityTester.isPushDownAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement14() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("Outer").getType("B");
IMember[] members= {typeB};
- assertTrue("should be disabled", ! RefactoringAvailabilityTester.isPushDownAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testEnablement15() throws Exception{
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType typeB= cu.getType("Outer").getType("B");
IMember[] members= {typeB};
- assertTrue("should be disabled", ! RefactoringAvailabilityTester.isPushDownAvailable(members));
+ assertFalse("should be disabled", RefactoringAvailabilityTester.isPushDownAvailable(members));
}
+ @Test
public void testGenerics0() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1322,6 +1394,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics1() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1339,6 +1412,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics2() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1356,6 +1430,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics3() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1373,6 +1448,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics4() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1390,6 +1466,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics5() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1407,6 +1484,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics6() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1424,6 +1502,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics7() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1441,6 +1520,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics8() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1458,6 +1538,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics9() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1475,6 +1556,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics10() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1492,6 +1574,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics11() throws Exception{
String[] selectedMethodNames= {"m"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1509,6 +1592,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics12() throws Exception{
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -1526,6 +1610,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics13() throws Exception{
String[] selectedMethodNames= {};
String[][] selectedMethodSignatures= {};
@@ -1543,6 +1628,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics14() throws Exception{
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1560,6 +1646,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics15() throws Exception{
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1577,6 +1664,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics16() throws Exception{
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1594,6 +1682,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics17() throws Exception{
String[] selectedMethodNames= {"f"};
String[][] selectedMethodSignatures= {new String[0]};
@@ -1611,6 +1700,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics18() throws Exception{
String[] selectedMethodNames= {"f", "m"};
String[][] selectedMethodSignatures= {new String[0], new String[] {"QT;"}};
@@ -1628,6 +1718,7 @@ public class PushDownTests extends RefactoringTest {
namesOfMethodsToDeclareAbstract, signaturesOfMethodsToDeclareAbstract, null, null);
}
+ @Test
public void testGenerics19() throws Exception{
String[] selectedMethodNames= {"f", "m"};
String[][] selectedMethodSignatures= {new String[0], new String[]{"QT;"}};
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringScannerTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringScannerTests.java
index 2225a2506a..2ed61a6f7d 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringScannerTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringScannerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,19 +13,21 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.Collections;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.jdt.internal.corext.refactoring.rename.RefactoringScanner;
import org.eclipse.jdt.internal.corext.refactoring.rename.RefactoringScanner.TextMatch;
import org.eclipse.jdt.ui.tests.refactoring.infra.TextRangeUtil;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class RefactoringScannerTests extends RefactoringTest{
-
+public class RefactoringScannerTests extends GenericRefactoringTest {
private static class Position {
private final int fLine;
private final int fColumn;
@@ -36,31 +38,25 @@ public class RefactoringScannerTests extends RefactoringTest{
}
- public RefactoringScannerTests(String name){
- super(name);
- }
+ @Rule
+ public RefactoringTestSetup fts= new RefactoringTestSetup();
private RefactoringScanner fScanner;
- private static Class<RefactoringScannerTests> clazz= RefactoringScannerTests.class;
@Override
protected String getRefactoringPath() {
return "RefactoringScanner/";
}
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
-
@Override
- protected void setUp() throws Exception {
- //no need to call super.setUp();
+ public void genericbefore() throws Exception {
+ //no need to call super.genericbefore();
fScanner= new RefactoringScanner("TestPattern", "org.eclipse");
}
@Override
- protected void tearDown() throws Exception {
- //no need to call super.tearDown();
+ public void genericafter() throws Exception {
+ //no need to call super.genericafter();
}
private void helper(String fileName, int expectedMatchCount) throws Exception{
@@ -86,20 +82,24 @@ public class RefactoringScannerTests extends RefactoringTest{
}
//-- tests
+ @Test
public void test0() throws Exception{
String text= "";
fScanner.scan(text);
assertEquals("results.length", 0, fScanner.getMatches().size());
}
+ @Test
public void test1() throws Exception{
helper("A.java", 8);
}
+ @Test
public void testWord1() throws Exception{
helper("B.java", 6);
}
+ @Test
public void testQualifier() throws Exception{
helper2("C.java", new Position[] {
new Position(4, 21),
@@ -115,4 +115,3 @@ public class RefactoringScannerTests extends RefactoringTest{
});
}
}
-
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringTest.java
deleted file mode 100644
index 9cd7f1fd45..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringTest.java
+++ /dev/null
@@ -1,636 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.ltk.core.refactoring.Change;
-import org.eclipse.ltk.core.refactoring.ChangeDescriptor;
-import org.eclipse.ltk.core.refactoring.CheckConditionsOperation;
-import org.eclipse.ltk.core.refactoring.CreateChangeOperation;
-import org.eclipse.ltk.core.refactoring.IUndoManager;
-import org.eclipse.ltk.core.refactoring.PerformChangeOperation;
-import org.eclipse.ltk.core.refactoring.Refactoring;
-import org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor;
-import org.eclipse.ltk.core.refactoring.RefactoringContribution;
-import org.eclipse.ltk.core.refactoring.RefactoringCore;
-import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
-import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.ISourceManipulation;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.refactoring.descriptors.JavaRefactoringDescriptor;
-
-import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil;
-import org.eclipse.jdt.internal.core.manipulation.util.Strings;
-
-import org.eclipse.jdt.ui.tests.refactoring.infra.RefactoringTestPlugin;
-
-public abstract class RefactoringTest extends TestCase {
-
- /**
- * If <code>true</code> a descriptor is created from the change.
- * The new descriptor is then used to create the refactoring again
- * and run the refactoring. As this is very time consuming this should
- * be <code>false</code> by default.
- */
- private static final boolean DESCRIPTOR_TEST= false;
-
- protected IPackageFragmentRoot fRoot;
- protected IPackageFragment fPackageP;
- protected IPackageFragment fPackageQ;
-
- public boolean fIsVerbose= false;
- public boolean fIsPreDeltaTest= false;
-
- public static final String TEST_PATH_PREFIX= "";
-
- protected static final String TEST_INPUT_INFIX= "/in/";
- protected static final String TEST_OUTPUT_INFIX= "/out/";
- protected static final String CONTAINER= "src";
-
- protected static final List<String> PROJECT_RESOURCE_CHILDREN= Arrays.asList(new String[] {
- ".project", ".classpath", ".settings" });
-
- public RefactoringTest(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- fRoot= RefactoringTestSetup.getDefaultSourceFolder();
- fPackageP= RefactoringTestSetup.getPackageP();
- fPackageQ= RefactoringTestSetup.getPackageQ();
- fIsPreDeltaTest= false;
-
- if (fIsVerbose){
- System.out.println("\n---------------------------------------------");
- System.out.println("\nTest:" + getClass() + "." + getName());
- }
- RefactoringCore.getUndoManager().flush();
- }
-
- protected void mustPerformDummySearch() throws Exception {
- JavaProjectHelper.mustPerformDummySearch(getPackageP());
- }
-
- protected void performDummySearch() throws Exception {
- JavaProjectHelper.performDummySearch(getPackageP());
- }
-
- /**
- * Removes contents of {@link #getPackageP()}, of {@link #getRoot()} (except for p) and of the
- * Java project (except for src and the JRE library).
- *
- * @throws Exception in case of errors
- */
- @Override
- protected void tearDown() throws Exception {
- refreshFromLocal();
- performDummySearch();
-
- final boolean pExists= getPackageP().exists();
- if (pExists) {
- tryDeletingAllJavaChildren(getPackageP());
- tryDeletingAllNonJavaChildResources(getPackageP());
- }
-
- final boolean qExists= getPackageQ().exists();
- if (qExists) {
- tryDeletingAllJavaChildren(getPackageQ());
- tryDeletingAllNonJavaChildResources(getPackageQ());
- }
-
- if (getRoot().exists()){
- for (IJavaElement p : getRoot().getChildren()) {
- IPackageFragment pack= (IPackageFragment) p;
- if (!pack.equals(getPackageP()) && !pack.equals(getPackageQ()) && pack.exists() && !pack.isReadOnly())
- if (pack.isDefaultPackage())
- JavaProjectHelper.deletePackage(pack); // also delete packages with subpackages
- else
- JavaProjectHelper.delete(pack.getResource()); // also delete packages with subpackages
- }
- // Restore package 'p'
- if (!pExists)
- getRoot().createPackageFragment("p", true, null);
- // Restore package 'q'
- if (!qExists)
- getRoot().createPackageFragment("q", true, null);
-
- tryDeletingAllNonJavaChildResources(getRoot());
- }
-
- restoreTestProject();
- }
-
- private void restoreTestProject() throws Exception {
- IJavaProject javaProject= getRoot().getJavaProject();
- if (javaProject.exists()) {
- IClasspathEntry srcEntry= getRoot().getRawClasspathEntry();
- IClasspathEntry jreEntry= RefactoringTestSetup.getJRELibrary().getRawClasspathEntry();
- ArrayList<IClasspathEntry> newCPEs= new ArrayList<>();
- boolean cpChanged= false;
- for (IClasspathEntry cpe : javaProject.getRawClasspath()) {
- if (cpe.equals(srcEntry) || cpe.equals(jreEntry)) {
- newCPEs.add(cpe);
- } else {
- cpChanged= true;
- }
- }
- if (cpChanged) {
- IClasspathEntry[] newCPEsArray= newCPEs.toArray(new IClasspathEntry[newCPEs.size()]);
- javaProject.setRawClasspath(newCPEsArray, null);
- }
-
- for (Object kid : javaProject.getNonJavaResources()) {
- if (kid instanceof IResource) {
- IResource resource= (IResource) kid;
- if (! PROJECT_RESOURCE_CHILDREN.contains(resource.getName())) {
- JavaProjectHelper.delete(resource);
- }
- }
- }
- }
- }
-
- private void refreshFromLocal() throws CoreException {
- if (getRoot().exists())
- getRoot().getResource().refreshLocal(IResource.DEPTH_INFINITE, null);
- else if (getPackageP().exists())//don't refresh package if root already refreshed
- getPackageP().getResource().refreshLocal(IResource.DEPTH_INFINITE, null);
- }
-
- private static void tryDeletingAllNonJavaChildResources(IPackageFragment pack) throws CoreException {
- for (Object nonJavaKid : pack.getNonJavaResources()) {
- if (nonJavaKid instanceof IResource) {
- IResource resource= (IResource) nonJavaKid;
- JavaProjectHelper.delete(resource);
- }
- }
- }
-
- private static void tryDeletingAllNonJavaChildResources(IPackageFragmentRoot root) throws CoreException {
- for (Object nonJavaKid : root.getNonJavaResources()) {
- if (nonJavaKid instanceof IResource) {
- IResource resource= (IResource) nonJavaKid;
- JavaProjectHelper.delete(resource);
- }
- }
- }
-
- private static void tryDeletingAllJavaChildren(IPackageFragment pack) throws CoreException {
- for (IJavaElement kid : pack.getChildren()) {
- if (kid instanceof ISourceManipulation) {
- if (kid.exists() && !kid.isReadOnly()) {
- JavaProjectHelper.delete(kid);
- }
- }
- }
- }
-
- protected IPackageFragmentRoot getRoot() {
- return fRoot;
- }
-
- protected IPackageFragment getPackageP() {
- return fPackageP;
- }
-
- protected IPackageFragment getPackageQ() {
- return fPackageQ;
- }
-
- protected final RefactoringStatus performRefactoring(RefactoringDescriptor descriptor) throws Exception {
- return performRefactoring(descriptor, true);
- }
-
- protected final RefactoringStatus performRefactoring(RefactoringDescriptor descriptor, boolean providesUndo) throws Exception {
- Refactoring refactoring= createRefactoring(descriptor);
- return performRefactoring(refactoring, providesUndo);
- }
-
- protected final Refactoring createRefactoring(RefactoringDescriptor descriptor) throws CoreException {
- RefactoringStatus status= new RefactoringStatus();
- Refactoring refactoring= descriptor.createRefactoring(status);
- assertNotNull("refactoring should not be null", refactoring);
- assertTrue("status should be ok", status.isOK());
- return refactoring;
- }
-
- protected final RefactoringStatus performRefactoring(Refactoring ref) throws Exception {
- return performRefactoring(ref, true);
- }
-
- protected final RefactoringStatus performRefactoring(Refactoring ref, boolean providesUndo) throws Exception {
- performDummySearch();
- IUndoManager undoManager= getUndoManager();
- if (DESCRIPTOR_TEST){
- final CreateChangeOperation create= new CreateChangeOperation(
- new CheckConditionsOperation(ref, CheckConditionsOperation.ALL_CONDITIONS),
- RefactoringStatus.FATAL);
- create.run(new NullProgressMonitor());
- RefactoringStatus checkingStatus= create.getConditionCheckingStatus();
- if (!checkingStatus.isOK())
- return checkingStatus;
- Change change= create.getChange();
- ChangeDescriptor descriptor= change.getDescriptor();
- if (descriptor instanceof RefactoringChangeDescriptor) {
- RefactoringChangeDescriptor rcd= (RefactoringChangeDescriptor) descriptor;
- RefactoringDescriptor refactoringDescriptor= rcd.getRefactoringDescriptor();
- if (refactoringDescriptor instanceof JavaRefactoringDescriptor) {
- JavaRefactoringDescriptor jrd= (JavaRefactoringDescriptor) refactoringDescriptor;
- RefactoringStatus validation= jrd.validateDescriptor();
- if (!validation.isOK())
- return validation;
- RefactoringStatus refactoringStatus= new RefactoringStatus();
- Class<? extends JavaRefactoringDescriptor> expected= jrd.getClass();
- RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(jrd.getID());
- jrd= (JavaRefactoringDescriptor) contribution.createDescriptor(jrd.getID(), jrd.getProject(), jrd.getDescription(), jrd.getComment(), contribution.retrieveArgumentMap(jrd), jrd.getFlags());
- assertEquals(expected, jrd.getClass());
- ref= jrd.createRefactoring(refactoringStatus);
- if (!refactoringStatus.isOK())
- return refactoringStatus;
- TestRenameParticipantSingle.reset();
- TestCreateParticipantSingle.reset();
- TestMoveParticipantSingle.reset();
- TestDeleteParticipantSingle.reset();
- }
- }
- }
- final CreateChangeOperation create= new CreateChangeOperation(
- new CheckConditionsOperation(ref, CheckConditionsOperation.ALL_CONDITIONS),
- RefactoringStatus.FATAL);
- final PerformChangeOperation perform= new PerformChangeOperation(create);
- perform.setUndoManager(undoManager, ref.getName());
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- if (fIsPreDeltaTest) {
- IResourceChangeListener listener= new IResourceChangeListener() {
- @Override
- public void resourceChanged(IResourceChangeEvent event) {
- if (create.getConditionCheckingStatus().isOK() && perform.changeExecuted()) {
- TestModelProvider.assertTrue(event.getDelta());
- }
- }
- };
- try {
- TestModelProvider.clearDelta();
- workspace.checkpoint(false);
- workspace.addResourceChangeListener(listener);
- executePerformOperation(perform, workspace);
- } finally {
- workspace.removeResourceChangeListener(listener);
- }
- } else {
- executePerformOperation(perform, workspace);
- }
- RefactoringStatus status= create.getConditionCheckingStatus();
- if (!status.isOK())
- return status;
- assertTrue("Change wasn't executed", perform.changeExecuted());
- Change undo= perform.getUndoChange();
- if (providesUndo) {
- assertNotNull("Undo doesn't exist", undo);
- assertTrue("Undo manager is empty", undoManager.anythingToUndo());
- } else {
- assertNull("Undo manager contains undo but shouldn't", undo);
- }
- return null;
- }
-
- protected void executePerformOperation(final PerformChangeOperation perform, IWorkspace workspace) throws CoreException {
- workspace.run(perform, new NullProgressMonitor());
- }
-
- public RefactoringStatus performRefactoringWithStatus(Refactoring ref) throws Exception, CoreException {
- RefactoringStatus status= performRefactoring(ref);
- if (status == null)
- return new RefactoringStatus();
- return status;
- }
-
- protected final Change performChange(Refactoring refactoring, boolean storeUndo) throws Exception {
- CreateChangeOperation create= new CreateChangeOperation(refactoring);
- PerformChangeOperation perform= new PerformChangeOperation(create);
- if (storeUndo) {
- perform.setUndoManager(getUndoManager(), refactoring.getName());
- }
- ResourcesPlugin.getWorkspace().run(perform, new NullProgressMonitor());
- assertTrue("Change wasn't executed", perform.changeExecuted());
- return perform.getUndoChange();
- }
-
- protected final Change performChange(final Change change) throws Exception {
- PerformChangeOperation perform= new PerformChangeOperation(change);
- ResourcesPlugin.getWorkspace().run(perform, new NullProgressMonitor());
- assertTrue("Change wasn't executed", perform.changeExecuted());
- return perform.getUndoChange();
- }
-
- protected IUndoManager getUndoManager() {
- IUndoManager undoManager= RefactoringCore.getUndoManager();
- undoManager.flush();
- return undoManager;
- }
-
- /* =================== helpers ================= */
- protected IType getType(ICompilationUnit cu, String name) throws JavaModelException {
- for (IType type : cu.getAllTypes()) {
- if (type.getTypeQualifiedName('.').equals(name) || type.getElementName().equals(name)) {
- return type;
- }
- }
- return null;
- }
-
- /*
- * subclasses override to inform about the location of their test cases
- */
- protected String getRefactoringPath() {
- return "";
- }
-
- /*
- * example "RenameType/"
- */
- protected String getTestPath() {
- return TEST_PATH_PREFIX + getRefactoringPath();
- }
-
- protected String createTestFileName(String cuName, String infix) {
- return getTestPath() + getName() + infix + cuName + ".java";
- }
-
- protected String getInputTestFileName(String cuName) {
- return createTestFileName(cuName, TEST_INPUT_INFIX);
- }
-
- /*
- * @param subDirName example "p/" or "org/eclipse/jdt/"
- */
- protected String getInputTestFileName(String cuName, String subDirName) {
- return createTestFileName(cuName, TEST_INPUT_INFIX + subDirName);
- }
-
- protected String getOutputTestFileName(String cuName) {
- return createTestFileName(cuName, TEST_OUTPUT_INFIX);
- }
-
- /*
- * @param subDirName example "p/" or "org/eclipse/jdt/"
- */
- protected String getOutputTestFileName(String cuName, String subDirName) {
- return createTestFileName(cuName, TEST_OUTPUT_INFIX + subDirName);
- }
-
- protected ICompilationUnit createCUfromTestFile(IPackageFragment pack, String cuName) throws Exception {
- return createCUfromTestFile(pack, cuName, true);
- }
-
- protected ICompilationUnit createCUfromTestFile(IPackageFragment pack, String cuName, String subDirName) throws Exception {
- return createCUfromTestFile(pack, cuName, subDirName, true);
- }
-
- protected ICompilationUnit createCUfromTestFile(IPackageFragment pack, String cuName, boolean input) throws Exception {
- String contents= input
- ? getFileContents(getInputTestFileName(cuName))
- : getFileContents(getOutputTestFileName(cuName));
- return createCU(pack, cuName + ".java", contents);
- }
-
- protected ICompilationUnit createCUfromTestFile(IPackageFragment pack, String cuName, String subDirName, boolean input) throws Exception {
- String contents= input
- ? getFileContents(getInputTestFileName(cuName, subDirName))
- : getFileContents(getOutputTestFileName(cuName, subDirName));
-
- return createCU(pack, cuName + ".java", contents);
- }
-
- protected void printTestDisabledMessage(String explanation){
- System.out.println("\n" +getClass().getName() + "::"+ getName() + " disabled (" + explanation + ")");
- }
-
- //-----------------------
- public static InputStream getStream(String content){
- return new ByteArrayInputStream(content.getBytes());
- }
-
- public static IPackageFragmentRoot getSourceFolder(IJavaProject javaProject, String name) throws JavaModelException{
- for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) {
- if (!root.isArchive() && root.getElementName().equals(name)) {
- return root;
- }
- }
- return null;
- }
-
- public String getFileContents(String fileName) throws IOException {
- return getContents(getFileInputStream(fileName));
- }
-
- public static String getContents(IFile file) throws IOException, CoreException {
- return getContents(file.getContents());
- }
-
- public static ICompilationUnit createCU(IPackageFragment pack, String name, String contents) throws Exception {
- assertTrue(!pack.getCompilationUnit(name).exists());
- ICompilationUnit cu= pack.createCompilationUnit(name, contents, true, null);
- cu.save(null, true);
- return cu;
- }
-
- public static String getContents(InputStream in) throws IOException {
- BufferedReader br= new BufferedReader(new InputStreamReader(in));
-
- StringBuilder sb= new StringBuilder(300);
- try {
- int read= 0;
- while ((read= br.read()) != -1)
- sb.append((char) read);
- } finally {
- br.close();
- }
- return sb.toString();
- }
-
- public static InputStream getFileInputStream(String fileName) throws IOException {
- return RefactoringTestPlugin.getDefault().getTestResourceStream(fileName);
- }
-
- public static String removeExtension(String fileName) {
- return fileName.substring(0, fileName.lastIndexOf('.'));
- }
-
- public static IMember[] merge(IMember[] a1, IMember[] a2, IMember[] a3){
- return JavaElementUtil.merge(JavaElementUtil.merge(a1, a2), a3);
- }
-
- public static IMember[] merge(IMember[] a1, IMember[] a2){
- return JavaElementUtil.merge(a1, a2);
- }
-
- public static IField[] getFields(IType type, String[] names) {
- if (names == null )
- return new IField[0];
- Set<IField> fields= new HashSet<>();
- for (String name : names) {
- IField field= type.getField(name);
- assertTrue("field " + field.getElementName() + " does not exist", field.exists());
- fields.add(field);
- }
- return fields.toArray(new IField[fields.size()]);
- }
-
- public static IType[] getMemberTypes(IType type, String[] names) {
- if (names == null )
- return new IType[0];
- Set<IType> memberTypes= new HashSet<>();
- for (String name : names) {
- IType memberType;
- if (name.indexOf('.') != -1) {
- String[] path= name.split("\\.");
- memberType= type.getType(path[0]);
- for (int j= 1; j < path.length; j++) {
- memberType= memberType.getType(path[j]);
- }
- } else {
- memberType= type.getType(name);
- }
- assertTrue("member type " + memberType.getElementName() + " does not exist", memberType.exists());
- memberTypes.add(memberType);
- }
- return memberTypes.toArray(new IType[memberTypes.size()]);
- }
-
- public static IMethod[] getMethods(IType type, String[] names, String[][] signatures) {
- if (names == null || signatures == null)
- return new IMethod[0];
- List<IMethod> methods= new ArrayList<>(names.length);
- for (int i = 0; i < names.length; i++) {
- IMethod method= type.getMethod(names[i], signatures[i]);
- assertTrue("method " + method.getElementName() + " does not exist", method.exists());
- if (!methods.contains(method))
- methods.add(method);
- }
- return methods.toArray(new IMethod[methods.size()]);
- }
-
- public static IType[] findTypes(IType[] types, String[] namesOfTypesToPullUp) {
- List<IType> found= new ArrayList<>(types.length);
- for (IType type : types) {
- for (String name : namesOfTypesToPullUp) {
- if (type.getElementName().equals(name))
- found.add(type);
- }
- }
- return found.toArray(new IType[found.size()]);
- }
-
- public static IField[] findFields(IField[] fields, String[] namesOfFieldsToPullUp) {
- List<IField> found= new ArrayList<>(fields.length);
- for (IField field : fields) {
- for (String name : namesOfFieldsToPullUp) {
- if (field.getElementName().equals(name))
- found.add(field);
- }
- }
- return found.toArray(new IField[found.size()]);
- }
-
- public static IMethod[] findMethods(IMethod[] selectedMethods, String[] namesOfMethods, String[][] signaturesOfMethods){
- List<IMethod> found= new ArrayList<>(selectedMethods.length);
- for (IMethod method : selectedMethods) {
- String[] paramTypes= method.getParameterTypes();
- for (int j= 0; j < namesOfMethods.length; j++) {
- String methodName= namesOfMethods[j];
- if (! methodName.equals(method.getElementName()))
- continue;
- String[] methodSig= signaturesOfMethods[j];
- if (! areSameSignatures(paramTypes, methodSig))
- continue;
- found.add(method);
- }
- }
- return found.toArray(new IMethod[found.size()]);
- }
-
- private static boolean areSameSignatures(String[] s1, String[] s2){
- if (s1.length != s2.length)
- return false;
- for (int i= 0; i < s1.length; i++) {
- if (! s1[i].equals(s2[i]))
- return false;
- }
- return true;
- }
-
- /**
- * Line-based version of junit.framework.Assert.assertEquals(String, String)
- * without considering line delimiters.
- * @param expected the expected value
- * @param actual the actual value
- */
- public static void assertEqualLines(String expected, String actual) {
- assertEqualLines("", expected, actual);
- }
-
- /**
- * Line-based version of junit.framework.Assert.assertEquals(String, String, String)
- * without considering line delimiters.
- * @param message the message
- * @param expected the expected value
- * @param actual the actual value
- */
- public static void assertEqualLines(String message, String expected, String actual) {
- String[] expectedLines= Strings.convertIntoLines(expected);
- String[] actualLines= Strings.convertIntoLines(actual);
-
- String expected2= (expectedLines == null ? null : Strings.concatenate(expectedLines, "\n"));
- String actual2= (actualLines == null ? null : Strings.concatenate(actualLines, "\n"));
- assertEquals(message, expected2, actual2);
- }
-
-}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringTestSetup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringTestSetup.java
deleted file mode 100644
index 2c628287ea..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RefactoringTestSetup.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-
-import org.eclipse.jdt.ui.tests.refactoring.infra.AbstractRefactoringTestSetup;
-
-import org.eclipse.jdt.internal.ui.JavaPlugin;
-
-/**
- * Sets up an 1.5 project with rtstubs15.jar and compiler, code formatting, code generation, and template options.
- */
-public class RefactoringTestSetup extends AbstractRefactoringTestSetup {
-
- public RefactoringTestSetup(Test test) {
- super(test);
- }
-
- public static final String CONTAINER= "src";
- private static IPackageFragmentRoot fgRoot;
- private static IPackageFragment fgPackageP;
- private static IPackageFragment fgPackageQ;
- private static IJavaProject fgJavaTestProject;
- private static IPackageFragmentRoot fgJRELibrary;
-
- public static IPackageFragmentRoot getDefaultSourceFolder() throws Exception {
- if (fgRoot != null)
- return fgRoot;
- throw new Exception(RefactoringTestSetup.class.getName() + " not initialized");
- }
-
- public static IPackageFragmentRoot getJRELibrary() throws Exception {
- if (fgJRELibrary != null)
- return fgJRELibrary;
- throw new Exception(RefactoringTestSetup.class.getName() + " not initialized");
- }
-
- public static IJavaProject getProject()throws Exception {
- if (fgJavaTestProject != null)
- return fgJavaTestProject;
- throw new Exception(RefactoringTestSetup.class.getName() + " not initialized");
- }
-
- public static IPackageFragment getPackageP()throws Exception {
- if (fgPackageP != null)
- return fgPackageP;
- throw new Exception(RefactoringTestSetup.class.getName() + " not initialized");
- }
-
- public static IPackageFragment getPackageQ()throws Exception {
- if (fgPackageQ != null)
- return fgPackageQ;
- throw new Exception(RefactoringTestSetup.class.getName() + " not initialized");
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- if (JavaPlugin.getActivePage() != null)
- JavaPlugin.getActivePage().close(); // Closed perspective is NOT restored in tearDown()!
-
- fgJavaTestProject= JavaProjectHelper.createJavaProject("TestProject"+System.currentTimeMillis(), "bin");
- fgJRELibrary= addRTJar(fgJavaTestProject);
- fgRoot= JavaProjectHelper.addSourceContainer(fgJavaTestProject, CONTAINER);
- fgPackageP= fgRoot.createPackageFragment("p", true, null);
- fgPackageQ= fgRoot.createPackageFragment("q", true, null);
- }
-
- protected IPackageFragmentRoot addRTJar(IJavaProject project) throws CoreException {
- return JavaProjectHelper.addRTJar(project);
- }
-
- @Override
- protected void tearDown() throws Exception {
- JavaProjectHelper.delete(fgJavaTestProject);
- super.tearDown();
- }
-}
-
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameRecordElementsTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameRecordElementsTests.java
index 69ff4e01c0..ab600d2906 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameRecordElementsTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameRecordElementsTests.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -100,8 +99,8 @@ public class RenameRecordElementsTests extends GenericRefactoringTest {
RenameRefactoring refactoring= (RenameRefactoring) createRefactoring(descriptor);
RenameFieldProcessor processor= (RenameFieldProcessor) refactoring.getProcessor();
- assertEquals("getter rename enabled", false, processor.canEnableGetterRenaming() == null);
- assertEquals("setter rename enabled", false, processor.canEnableSetterRenaming() == null);
+ assertNotNull("Getter rename should be enabled", processor.canEnableGetterRenaming());
+ assertNotNull("Setter rename should be enabled", processor.canEnableSetterRenaming());
List<IAnnotatable> elements= new ArrayList<>();
elements.add(field);
@@ -143,6 +142,74 @@ public class RenameRecordElementsTests extends GenericRefactoringTest {
}
}
+ private void renameRecordCompactConstructor2(String fieldName, String newFieldName, boolean updateReferences, boolean fail) throws Exception{
+ ParticipantTesting.reset();
+ ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
+ ICompilationUnit cu2= createCUfromTestFile(getPackageP(), "B");
+ ICompilationUnit cu3= createCUfromTestFile(getPackageP(), "C");
+ ICompilationUnit cu4= createCUfromTestFile(getPackageP(), "D");
+ IType recordA= getType(cu, "A");
+ IField field= recordA.getField(fieldName);
+ IMethod method= recordA.getMethod(fieldName, new String[] {});
+ RenameJavaElementDescriptor descriptor= RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_FIELD);
+ descriptor.setJavaElement(field);
+ descriptor.setNewName(newFieldName);
+ descriptor.setUpdateReferences(updateReferences);
+ descriptor.setUpdateTextualOccurrences(false);
+ descriptor.setRenameGetters(false);
+ descriptor.setRenameSetters(false);
+
+ RenameRefactoring refactoring= (RenameRefactoring) createRefactoring(descriptor);
+ RenameFieldProcessor processor= (RenameFieldProcessor) refactoring.getProcessor();
+ assertNotNull("getter rename enabled", processor.canEnableGetterRenaming());
+ assertNotNull("setter rename enabled", processor.canEnableSetterRenaming());
+
+ List<IAnnotatable> elements= new ArrayList<>();
+ elements.add(field);
+ List<RenameArguments> args= new ArrayList<>();
+ args.add(new RenameArguments(newFieldName, updateReferences));
+ if (method != null && method.exists()) {
+ elements.add(method);
+ args.add(new RenameArguments(newFieldName, updateReferences));
+ }
+
+
+ String[] renameHandles= ParticipantTesting.createHandles(elements.toArray());
+
+ RefactoringStatus result= performRefactoring(refactoring);
+ if (fail) {
+ assertNotNull("was supposed to fail", result);
+ } else {
+ assertNull("was supposed to pass", result);
+ assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("A")), cu.getSource());
+ assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("B")), cu2.getSource());
+ assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("C")), cu3.getSource());
+ assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("D")), cu4.getSource());
+
+ ParticipantTesting.testRename(
+ renameHandles,
+ args.toArray(new RenameArguments[args.size()]));
+
+ assertTrue("anythingToUndo", RefactoringCore.getUndoManager().anythingToUndo());
+ assertFalse("! anythingToRedo", RefactoringCore.getUndoManager().anythingToRedo());
+
+ RefactoringCore.getUndoManager().performUndo(null, new NullProgressMonitor());
+ assertEqualLines("invalid undo", getFileContents(getInputTestFileName("A")), cu.getSource());
+ assertEqualLines("invalid undo", getFileContents(getInputTestFileName("B")), cu2.getSource());
+ assertEqualLines("invalid undo", getFileContents(getInputTestFileName("C")), cu3.getSource());
+ assertEqualLines("invalid undo", getFileContents(getInputTestFileName("D")), cu4.getSource());
+
+ assertFalse("! anythingToUndo", RefactoringCore.getUndoManager().anythingToUndo());
+ assertTrue("anythingToRedo", RefactoringCore.getUndoManager().anythingToRedo());
+
+ RefactoringCore.getUndoManager().performRedo(null, new NullProgressMonitor());
+ assertEqualLines("invalid redo", getFileContents(getOutputTestFileName("A")), cu.getSource());
+ assertEqualLines("invalid redo", getFileContents(getOutputTestFileName("B")), cu2.getSource());
+ assertEqualLines("invalid redo", getFileContents(getOutputTestFileName("C")), cu3.getSource());
+ assertEqualLines("invalid redo", getFileContents(getOutputTestFileName("D")), cu4.getSource());
+ }
+ }
+
private void renameRecordExplicitAccessor(String methodName, String newMethodName, boolean updateReferences, boolean fail) throws Exception{
ParticipantTesting.reset();
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
@@ -244,6 +311,11 @@ public class RenameRecordElementsTests extends GenericRefactoringTest {
}
@Test
+ public void testRenameRecordCompactConstructorImplicitAccessor2() throws Exception{
+ renameRecordCompactConstructor2("f", "g", true, false);
+ }
+
+ @Test
public void testRenameRecordCompactConstructorExplicitAccessor() throws Exception{
renameRecordCompactConstructor("f", "g", true, false);
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameTempTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameTempTests.java
index 895ea50a6f..89b46b3d20 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameTempTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameTempTests.java
@@ -73,8 +73,8 @@ public class RenameTempTests extends GenericRefactoringTest{
private ISourceRange getSelection(ICompilationUnit cu) throws Exception{
String source= cu.getSource();
//Warning: this *includes* the SQUARE_BRACKET_OPEN!
- int offset= source.indexOf(AbstractSelectionTestCase.SQUARE_BRACKET_OPEN);
- int end= source.indexOf(AbstractSelectionTestCase.SQUARE_BRACKET_CLOSE);
+ int offset= source.indexOf(AbstractJunit4SelectionTestCase.SQUARE_BRACKET_OPEN);
+ int end= source.indexOf(AbstractJunit4SelectionTestCase.SQUARE_BRACKET_CLOSE);
return new SourceRange(offset, end - offset);
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameTests18.java
index b5718e2360..63a8918ee2 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenameTests18.java
@@ -53,15 +53,17 @@ import org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor;
import org.eclipse.jdt.internal.core.refactoring.descriptors.RefactoringSignatureDescriptorFactory;
-import org.eclipse.jdt.ui.tests.refactoring.rules.Java18Setup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java1d8Setup;
import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
public class RenameTests18 extends GenericRefactoringTest {
-
private static final String REFACTORING_PATH= "RenameTests18/";
@Rule
- public RefactoringTestSetup fts= new Java18Setup() {
+ public RefactoringTestSetup fts= new Java1d8Setup() {
@Override
public void before() throws Exception {
JavaProjectHelper.PERFORM_DUMMY_SEARCH++;
@@ -97,9 +99,9 @@ public class RenameTests18 extends GenericRefactoringTest {
private ISourceRange getSelection(ICompilationUnit cu) throws Exception {
String source= cu.getSource();
//Warning: this *includes* the SQUARE_BRACKET_OPEN!
- int offset= source.indexOf(AbstractSelectionTestCase.SQUARE_BRACKET_OPEN);
- int end= source.indexOf(AbstractSelectionTestCase.SQUARE_BRACKET_CLOSE);
- return new SourceRange(offset + AbstractSelectionTestCase.SQUARE_BRACKET_OPEN.length(), end - offset);
+ int offset= source.indexOf(AbstractJunit4SelectionTestCase.SQUARE_BRACKET_OPEN);
+ int end= source.indexOf(AbstractJunit4SelectionTestCase.SQUARE_BRACKET_CLOSE);
+ return new SourceRange(offset + AbstractJunit4SelectionTestCase.SQUARE_BRACKET_OPEN.length(), end - offset);
}
private void renameLocalVariable(String newFieldName, boolean updateReferences) throws Exception {
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenamingNameSuggestorTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenamingNameSuggestorTests.java
index 5ac9d77f11..315c0e2739 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenamingNameSuggestorTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RenamingNameSuggestorTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,18 +13,14 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
-import org.eclipse.jdt.internal.corext.refactoring.rename.RenamingNameSuggestor;
-
-public class RenamingNameSuggestorTests extends TestCase {
+import org.junit.Test;
- public static Test suite() {
- return new TestSuite(RenamingNameSuggestorTests.class);
- }
+import org.eclipse.jdt.internal.corext.refactoring.rename.RenamingNameSuggestor;
+public class RenamingNameSuggestorTests {
String[] fPrefixes;
String[] fSuffixes;
RenamingNameSuggestor fSuggestor;
@@ -42,7 +38,7 @@ public class RenamingNameSuggestorTests extends TestCase {
}
public void mhf(String orig, String oldT, String newT) {
- assertEquals(null, mHelper(orig, oldT, newT));
+ assertNull(mHelper(orig, oldT, newT));
}
public void fh(String orig, String changed, String oldT, String newT) {
@@ -50,15 +46,15 @@ public class RenamingNameSuggestorTests extends TestCase {
}
public void fhf(String orig, String oldT, String newT) {
- assertEquals(null, fHelper(orig, oldT, newT));
+ assertNull(fHelper(orig, oldT, newT));
}
public void setStrategy(int strategy) {
fSuggestor= new RenamingNameSuggestor(strategy);
}
+ @Test
public void testOnlyPrefix() {
-
fPrefixes= new String[] { "f", "q" };
fSuffixes= new String[0];
setStrategy(RenamingNameSuggestor.STRATEGY_EXACT);
@@ -74,11 +70,10 @@ public class RenamingNameSuggestorTests extends TestCase {
// Unrelated stuff
assertNull(fHelper("fSomeClass", "Unrelated", "Unrelated2"));
-
}
+ @Test
public void testPrefixAndSuffix() {
-
fPrefixes= new String[] { "f", "q" };
fSuffixes= new String[] { "Suf1" };
setStrategy(RenamingNameSuggestor.STRATEGY_EXACT);
@@ -94,8 +89,8 @@ public class RenamingNameSuggestorTests extends TestCase {
assertEquals("newJavaElement", fHelper("javaElement", "IJavaElement", "INewJavaElement"));
}
+ @Test
public void testOnlySuffix() {
-
fPrefixes= new String[0];
fSuffixes= new String[] { "Suf1" };
setStrategy(RenamingNameSuggestor.STRATEGY_EXACT);
@@ -107,11 +102,10 @@ public class RenamingNameSuggestorTests extends TestCase {
//Interface names
assertEquals("newJavaElementSuf1", fHelper("javaElementSuf1", "IJavaElement", "INewJavaElement"));
assertEquals("newJavaElement", fHelper("javaElement", "IJavaElement", "INewJavaElement"));
-
}
+ @Test
public void testVeryShortNames() {
-
fPrefixes= new String[] { "f", "q" };
fSuffixes= new String[] { "_" };
setStrategy(RenamingNameSuggestor.STRATEGY_SUFFIX);
@@ -123,11 +117,10 @@ public class RenamingNameSuggestorTests extends TestCase {
assertEquals("b_", fHelper("a_", "A", "B"));
fh("mAHahAHa", "mBHahAHa", "A", "B"); // match first occurrence
-
}
+ @Test
public void testEmbeddedMatching() {
-
fPrefixes= new String[0];
fSuffixes= new String[0];
setStrategy(RenamingNameSuggestor.STRATEGY_EMBEDDED);
@@ -150,8 +143,8 @@ public class RenamingNameSuggestorTests extends TestCase {
fhf("createelementsecondelementnomore", "Element", "Member");
}
+ @Test
public void testCamelCaseMatching() {
-
fPrefixes= new String[0];
fSuffixes= new String[0];
setStrategy(RenamingNameSuggestor.STRATEGY_SUFFIX);
@@ -207,11 +200,10 @@ public class RenamingNameSuggestorTests extends TestCase {
// avoid "silly" name suggestions
fhf("fElement", "SomeLongElement", "AnotherDifferentElement"); //-> don't suggest renaming fElement to fElement!
-
}
+ @Test
public void testUpperCaseCamelCaseMatching() {
-
fPrefixes= new String[] { "f" };
fSuffixes= new String[0];
@@ -269,7 +261,6 @@ public class RenamingNameSuggestorTests extends TestCase {
mh("createAST", "createAbstractSyntaxTree", "AST", "AbstractSyntaxTree");
// match new hunks
-
fh("fASTNode", "fMyASTNode", "ASTNode", "MyASTNode");
fh("fAstNode", "fMyAstNode", "ASTNode", "MyASTNode");
fh("fDifferentAstNode", "fDifferentMyAstNode", "ASTNode", "MyASTNode");
@@ -277,11 +268,10 @@ public class RenamingNameSuggestorTests extends TestCase {
// propagating lowercased front
fh("astNode", "myAstNode", "ASTNode", "MyASTNode");
-
}
+ @Test
public void testPluralS() {
-
fPrefixes= new String[0];
fSuffixes= new String[0];
setStrategy(RenamingNameSuggestor.STRATEGY_EXACT);
@@ -302,5 +292,4 @@ public class RenamingNameSuggestorTests extends TestCase {
fh("someHandiesOnLoan", "someMobilePhonesOnLoan", "Handy", "MobilePhone");
fh("somePhonesOnLoan", "someHandiesOnLoan", "MobilePhone", "Handy");
}
-
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ReplaceInvocationsTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ReplaceInvocationsTests.java
index 67a75f1e69..4a735d39cc 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ReplaceInvocationsTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ReplaceInvocationsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2016 IBM Corporation and others.
+ * Copyright (c) 2006, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,41 +13,35 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
+import static org.junit.Assert.assertTrue;
+
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.dom.Comment;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
import org.eclipse.jdt.internal.corext.refactoring.code.ReplaceInvocationsRefactoring;
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser;
-import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
-
-public class ReplaceInvocationsTests extends AbstractSelectionTestCase {
- private static RewriteMethodInvocationsTestSetup fgTestSetup;
+public class ReplaceInvocationsTests extends AbstractJunit4SelectionTestCase {
- public ReplaceInvocationsTests(String name) {
- super(name, true);
- }
-
- public static Test suite() {
- fgTestSetup= new RewriteMethodInvocationsTestSetup(new TestSuite(ReplaceInvocationsTests.class));
- return fgTestSetup;
- }
+ @Rule
+ public RewriteMethodInvocationsTestSetup fgTestSetup= new RewriteMethodInvocationsTestSetup();
- public static Test setUpTest(Test someTest) {
- fgTestSetup= new RewriteMethodInvocationsTestSetup(someTest);
- return fgTestSetup;
+ public ReplaceInvocationsTests() {
+ super(true);
}
@Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
fIsPreDeltaTest= true;
}
@@ -62,7 +56,7 @@ public class ReplaceInvocationsTests extends AbstractSelectionTestCase {
return Character.toUpperCase(name.charAt(0)) + name.substring(1) + ".java";
}
- private void performTestRewriteInvocations(IPackageFragment packageFragment, String id, int mode, String outputFolder) throws Exception {
+ private void performTestRewriteInvocations(IPackageFragment packageFragment, String id, TestMode mode, String outputFolder) throws Exception {
ICompilationUnit unit= createCU(packageFragment, id);
int[] selection= getSelection();
@@ -91,14 +85,17 @@ public class ReplaceInvocationsTests extends AbstractSelectionTestCase {
performTestRewriteInvocations(fgTestSetup.getRewritePackage(), getName(), COMPARE_WITH_OUTPUT, "rewrite_out");
}
+ @Test
public void testSwitchParameters() throws Exception {
performRewriteTest();
}
+ @Test
public void testClassFile() throws Exception {
performRewriteTest();
}
+ @Test
public void testMultiple() throws Exception {
performRewriteTest();
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RewriteMethodInvocationsTestSetup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RewriteMethodInvocationsTestSetup.java
index ad1761c0d4..c371619d80 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RewriteMethodInvocationsTestSetup.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RewriteMethodInvocationsTestSetup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,22 +13,18 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
-
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+
public class RewriteMethodInvocationsTestSetup extends RefactoringTestSetup {
private IPackageFragment fRewrite;
- public RewriteMethodInvocationsTestSetup(Test test) {
- super(test);
- }
-
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void before() throws Exception {
+ super.before();
IPackageFragmentRoot root= getDefaultSourceFolder();
fRewrite= root.createPackageFragment("rewrite_in", true, null);
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RippleMethodFinderTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RippleMethodFinderTests.java
index 5ec93096e7..c8f845979a 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RippleMethodFinderTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/RippleMethodFinderTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,13 +13,16 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -30,34 +33,24 @@ import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.internal.corext.refactoring.rename.RippleMethodFinder2;
-import org.eclipse.jdt.ui.tests.refactoring.infra.AbstractCUTestCase;
+import org.eclipse.jdt.ui.tests.refactoring.infra.AbstractJunit4CUTestCase;
import org.eclipse.jdt.ui.tests.refactoring.infra.RefactoringTestPlugin;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+public class RippleMethodFinderTests extends AbstractJunit4CUTestCase {
-public class RippleMethodFinderTests extends AbstractCUTestCase {
-
- private static final Class<RippleMethodFinderTests> clazz= RippleMethodFinderTests.class;
private static final String REFACTORING_PATH= "RippleMethodFinder/";
private static final String TARGET= "/*target*/";
private static final String RIPPLE= "/*ripple*/";
- public RippleMethodFinderTests(String name) {
- super(name);
- }
+ @Rule
+ public RefactoringTestSetup rts= new RefactoringTestSetup();
@Override
protected String getResourceLocation() {
return REFACTORING_PATH;
}
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new RefactoringTestSetup(someTest);
- }
-
@Override
protected InputStream getFileInputStream(String fileName) throws IOException {
return RefactoringTestPlugin.getDefault().getTestResourceStream(fileName);
@@ -94,39 +87,51 @@ public class RippleMethodFinderTests extends AbstractCUTestCase {
assertEquals("found wrong ripple methods: " + rippleMethods, 0, rippleMethods.size());
}
+ @Test
public void test1() throws Exception {
perform();
}
+ @Test
public void test2() throws Exception {
perform();
}
+ @Test
public void test3() throws Exception {
perform();
}
+ @Test
public void test4() throws Exception {
perform();
}
+ @Test
public void test5() throws Exception {
perform();
}
+ @Test
public void test6() throws Exception {
perform();
}
+ @Test
public void test7() throws Exception {
perform();
}
+ @Test
public void test8() throws Exception {
perform();
}
+ @Test
public void test9() throws Exception {
perform();
}
+ @Test
public void test10() throws Exception {
perform();
}
+ @Test
public void test11() throws Exception {
perform();
}
+ @Test
public void test12() throws Exception {
perform();
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SefTestSetup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SefTestSetup.java
index 93a08ba1a9..848287b433 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SefTestSetup.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SefTestSetup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,11 +13,11 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
-
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
+
public class SefTestSetup extends RefactoringTestSetup {
private IPackageFragment fBaseTypes;
@@ -27,13 +27,10 @@ public class SefTestSetup extends RefactoringTestSetup {
private IPackageFragment fStaticRef;
private IPackageFragment fExistingMethod;
- public SefTestSetup(Test test) {
- super(test);
- }
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void before() throws Exception {
+ super.before();
IPackageFragmentRoot root= getDefaultSourceFolder();
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SefTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SefTests.java
index 0e51ed454c..f263f4029e 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SefTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SefTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -17,8 +17,15 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.Hashtable;
+import org.junit.ClassRule;
+import org.junit.Test;
+
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
@@ -34,29 +41,13 @@ import org.eclipse.jdt.internal.corext.refactoring.Checks;
import org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester;
import org.eclipse.jdt.internal.corext.refactoring.sef.SelfEncapsulateFieldRefactoring;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class SefTests extends AbstractSelectionTestCase {
+public class SefTests extends AbstractJunit4SelectionTestCase {
- private static SefTestSetup fgTestSetup;
-
- public SefTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- fgTestSetup= new SefTestSetup(new TestSuite(SefTests.class));
- return fgTestSetup;
- }
-
- public static Test setUpTest(Test test) {
- fgTestSetup= new SefTestSetup(test);
- return fgTestSetup;
- }
+ @ClassRule
+ public static SefTestSetup fgTestSetup= new SefTestSetup();
@Override
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
super.setUp();
fIsPreDeltaTest= true;
}
@@ -134,14 +125,17 @@ public class SefTests extends AbstractSelectionTestCase {
// Invalid
//=====================================================================================
+ @Test
public void testPostfixExpression() throws Exception {
invalidTest("field");
}
+ @Test
public void testInvalidOverwrite() throws Exception {
invalidTest("field");
}
+ @Test
public void testAnnotation() throws Exception {
invalidTest("field");
}
@@ -150,30 +144,37 @@ public class SefTests extends AbstractSelectionTestCase {
// Primitiv Data Test
//=====================================================================================
+ @Test
public void testPrefixInt() throws Exception {
baseTest("field");
}
+ @Test
public void testPrefixBoolean() throws Exception {
baseTest("field");
}
+ @Test
public void testPostfixInt() throws Exception {
baseTest("field");
}
+ @Test
public void testThisExpression() throws Exception {
baseTest("field");
}
+ @Test
public void testThisExpressionInner() throws Exception {
baseTest("field");
}
+ @Test
public void testFinal() throws Exception {
baseTest("field");
}
+ @Test
public void testTwoFragments() throws Exception {
baseTest("field");
}
@@ -182,34 +183,42 @@ public class SefTests extends AbstractSelectionTestCase {
// Basic Object Test
//=====================================================================================
+ @Test
public void testSimpleRead() throws Exception {
objectTest("field");
}
+ @Test
public void testSimpleWrite() throws Exception {
objectTest("field");
}
+ @Test
public void testSimpleParenthesizedWrite() throws Exception {
objectTest("field");
}
+ @Test
public void testSimpleReadWrite() throws Exception {
objectTest("field");
}
+ @Test
public void testEnumRead() throws Exception {
objectTest("field");
}
+ @Test
public void testEnumReadWrite() throws Exception {
objectTest("field");
}
+ @Test
public void testNestedRead() throws Exception {
objectTest("field");
}
+ @Test
public void testArrayRead() throws Exception {
objectTest("field");
}
@@ -219,58 +228,72 @@ public class SefTests extends AbstractSelectionTestCase {
}
+ @Test
public void testSetterInAssignment() throws Exception {
objectTest("field");
}
+ @Test
public void testSetterInExpression() throws Exception {
objectTest("field");
}
+ @Test
public void testSetterInInitialization() throws Exception {
objectTest("field");
}
+ @Test
public void testSetterAsReceiver() throws Exception {
objectTest("field");
}
+ @Test
public void testCompoundParenthesizedWrite() throws Exception {
objectTest("field");
}
+ @Test
public void testCompoundWrite() throws Exception {
objectTest("field");
}
+ @Test
public void testCompoundWrite2() throws Exception {
objectTest("field");
}
+ @Test
public void testCompoundWrite3() throws Exception {
objectTest("field");
}
+ @Test
public void testCompoundWrite4() throws Exception {
objectTest("field");
}
+ @Test
public void testFinalField() throws Exception {
objectTest("field");
}
+ @Test
public void testGenericRead() throws Exception {
objectTest("field");
}
+ @Test
public void testGenericRead2() throws Exception {
objectTest("field");
}
+ @Test
public void testGenericReadWrite() throws Exception {
objectTest("field");
}
+ @Test
public void testArrayAnnotations() throws Exception {
objectTest("field");
}
@@ -295,18 +318,22 @@ public class SefTests extends AbstractSelectionTestCase {
compareSource(reference.getSource(), refContentOut);
}
+ @Test
public void testStaticImportRead() throws Exception {
performStaticImportTest("StaticImportReadReference");
}
+ @Test
public void testStaticImportWrite() throws Exception {
performStaticImportTest("StaticImportWriteReference");
}
+ @Test
public void testStaticImportReadWrite() throws Exception {
performStaticImportTest("StaticImportReadWriteReference");
}
+ @Test
public void testStaticImportNone() throws Exception {
performStaticImportTest("StaticImportNoReference");
}
@@ -315,14 +342,17 @@ public class SefTests extends AbstractSelectionTestCase {
// existing getter/setter
//=====================================================================================
+ @Test
public void testThisExpressionInnerWithSetter() throws Exception {
existingTest("field");
}
+ @Test
public void testThisExpressionWithGetterSetter() throws Exception {
existingTest("field");
}
+ @Test
public void testTwoFragmentsWithSetter() throws Exception {
existingTest("field");
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithResourcesTestSetup18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithResourcesTestSetup1d8.java
index 2e379201df..0b436583df 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithResourcesTestSetup18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithResourcesTestSetup1d8.java
@@ -9,18 +9,19 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- * Red Hat Inc. - initial implementation based on SurroundWithTestSetup18
+ * Red Hat Inc. - initial implementation based on SurroundWithTestSetup1d8
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
import java.util.Hashtable;
-import junit.extensions.TestSetup;
-import junit.framework.Test;
+import org.junit.rules.ExternalResource;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.TestOptions;
+import org.eclipse.core.runtime.CoreException;
+
import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.jdt.core.IJavaProject;
@@ -35,8 +36,10 @@ import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.util.CoreUtility;
-
-public class SurroundWithResourcesTestSetup18 extends TestSetup {
+/**
+ * This class is made to run tests on Java Spider 1.8 .
+ */
+public class SurroundWithResourcesTestSetup1d8 extends ExternalResource {
private IJavaProject fJavaProject;
@@ -46,17 +49,14 @@ public class SurroundWithResourcesTestSetup18 extends TestSetup {
private IPackageFragment fTryResourcesPackage;
- public SurroundWithResourcesTestSetup18(Test test) {
- super(test);
- }
+
public IPackageFragmentRoot getRoot() {
return fRoot;
}
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void before() throws Exception {
Hashtable<String, String> options= TestOptions.getDefaultOptions();
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB);
@@ -78,9 +78,12 @@ public class SurroundWithResourcesTestSetup18 extends TestSetup {
}
@Override
- protected void tearDown() throws Exception {
- super.tearDown();
- JavaProjectHelper.delete(fJavaProject);
+ public void after() {
+ try {
+ JavaProjectHelper.delete(fJavaProject);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
}
public IPackageFragment getTryCatchPackage() {
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithResourcesTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithResourcesTests1d8.java
index e06bd839de..a8982540a2 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithResourcesTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithResourcesTests1d8.java
@@ -9,35 +9,35 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- * Red Hat Inc. - initial implementation based on SurroundWithTests18
+ * Red Hat Inc. - initial implementation based on SurroundWithTests1d8
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.INVALID_SELECTION;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryWithResourcesRefactoring;
-import junit.framework.Test;
-
-public class SurroundWithResourcesTests18 extends AbstractSelectionTestCase {
-
- private static SurroundWithResourcesTestSetup18 fgTestSetup;
+import org.eclipse.jdt.ui.tests.CustomBaseRunner;
+import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
- public SurroundWithResourcesTests18(String name) {
- super(name);
- }
-
- public static Test suite() {
- fgTestSetup= new SurroundWithResourcesTestSetup18(new NoSuperTestsSuite(SurroundWithResourcesTests18.class));
- return fgTestSetup;
- }
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
+@IgnoreInheritedTests
+@RunWith(CustomBaseRunner.class)
+public class SurroundWithResourcesTests1d8 extends AbstractJunit4SelectionTestCase {
- public static Test setUpTest(Test someTest) {
- fgTestSetup= new SurroundWithResourcesTestSetup18(someTest);
- return fgTestSetup;
- }
+ @Rule
+ public SurroundWithResourcesTestSetup1d8 fgTestSetup=new SurroundWithResourcesTestSetup1d8();
protected IPackageFragmentRoot getRoot() {
return fgTestSetup.getRoot();
@@ -53,7 +53,7 @@ public class SurroundWithResourcesTests18 extends AbstractSelectionTestCase {
return Character.toUpperCase(name.charAt(0)) + name.substring(1) + ".java";
}
- protected void performTest(IPackageFragment packageFragment, String name, String outputFolder, int mode) throws Exception {
+ protected void performTest(IPackageFragment packageFragment, String name, String outputFolder, TestMode mode) throws Exception {
ICompilationUnit unit= createCU(packageFragment, name);
SurroundWithTryWithResourcesRefactoring refactoring= createRefactoring(unit);
String out= null;
@@ -74,82 +74,102 @@ public class SurroundWithResourcesTests18 extends AbstractSelectionTestCase {
performTest(fgTestSetup.getTryCatchPackage(), getName(), "tryresources18_out", COMPARE_WITH_OUTPUT);
}
+ @Test
public void testSimple1() throws Exception {
tryResourcesTest();
}
+ @Test
public void testSimple2() throws Exception {
tryResourcesTest();
}
+ @Test
public void testSimple3() throws Exception {
tryResourcesTest();
}
+ @Test
public void testSimple4() throws Exception {
tryResourcesTest();
}
+ @Test
public void testNonClosableInserted1() throws Exception {
tryResourcesTest();
}
+ @Test
public void testWithException1() throws Exception {
tryResourcesTest();
}
+ @Test
public void testWithException2() throws Exception {
tryResourcesTest();
}
+ @Test
public void testWithThrows1() throws Exception {
tryResourcesTest();
}
+ @Test
public void testInvalidStatement1() throws Exception {
tryResourcesInvalidTest();
}
+ @Test
public void testInvalidParent1() throws Exception {
tryResourcesInvalidTest();
}
+ @Test
public void testInvalidParent2() throws Exception {
tryResourcesInvalidTest();
}
+ @Test
public void testMethodThrowsException1() throws Exception {
tryResourcesTest();
}
+ @Test
public void testMethodThrowsException2() throws Exception {
tryResourcesTest();
}
+ @Test
public void testInvalidTryResources1() throws Exception {
tryResourcesInvalidTest();
}
+ @Test
public void testExceptionFilter1() throws Exception {
tryResourcesTest();
}
+ @Test
public void testLambda1() throws Exception {
tryResourcesTest();
}
+ @Test
public void testLambda2() throws Exception {
tryResourcesInvalidTest();
}
+ @Test
public void testLambda3() throws Exception {
tryResourcesTest();
}
+ @Test
public void testLambda4() throws Exception {
tryResourcesInvalidTest();
}
+ @Test
public void testMethodReference1() throws Exception {
tryResourcesInvalidTest();
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup.java
index 9cb4e82f53..b0c7e5085b 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,12 +15,13 @@ package org.eclipse.jdt.ui.tests.refactoring;
import java.util.Hashtable;
-import junit.extensions.TestSetup;
-import junit.framework.Test;
+import org.junit.rules.ExternalResource;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.TestOptions;
+import org.eclipse.core.runtime.CoreException;
+
import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.jdt.core.IJavaProject;
@@ -36,7 +37,7 @@ import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.util.CoreUtility;
-public class SurroundWithTestSetup extends TestSetup {
+public class SurroundWithTestSetup extends ExternalResource {
private IJavaProject fJavaProject;
private IPackageFragmentRoot fRoot;
@@ -44,17 +45,12 @@ public class SurroundWithTestSetup extends TestSetup {
private IPackageFragment fTryCatchPackage;
- public SurroundWithTestSetup(Test test) {
- super(test);
- }
-
public IPackageFragmentRoot getRoot() {
return fRoot;
}
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ protected void before() throws Exception {
Hashtable<String, String> options= TestOptions.getDefaultOptions();
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB);
@@ -76,9 +72,12 @@ public class SurroundWithTestSetup extends TestSetup {
}
@Override
- protected void tearDown() throws Exception {
- super.tearDown();
- JavaProjectHelper.delete(fJavaProject);
+ public void after() {
+ try {
+ JavaProjectHelper.delete(fJavaProject);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
}
public IPackageFragment getTryCatchPackage() {
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup17.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup17.java
index c170a511da..dc22eb17fa 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup17.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup17.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2011, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,12 +15,13 @@ package org.eclipse.jdt.ui.tests.refactoring;
import java.util.Hashtable;
-import junit.extensions.TestSetup;
-import junit.framework.Test;
+import org.junit.rules.ExternalResource;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.TestOptions;
+import org.eclipse.core.runtime.CoreException;
+
import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.jdt.core.IJavaProject;
@@ -35,26 +36,19 @@ import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.util.CoreUtility;
-
-public class SurroundWithTestSetup17 extends TestSetup {
-
+public class SurroundWithTestSetup17 extends ExternalResource {
private IJavaProject fJavaProject;
private IPackageFragmentRoot fRoot;
private static final String CONTAINER= "src";
private IPackageFragment fTryCatchPackage;
- public SurroundWithTestSetup17(Test test) {
- super(test);
- }
-
public IPackageFragmentRoot getRoot() {
return fRoot;
}
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void before() throws Exception {
Hashtable<String, String> options= TestOptions.getDefaultOptions();
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB);
@@ -76,13 +70,15 @@ public class SurroundWithTestSetup17 extends TestSetup {
}
@Override
- protected void tearDown() throws Exception {
- super.tearDown();
- JavaProjectHelper.delete(fJavaProject);
+ public void after() {
+ try {
+ JavaProjectHelper.delete(fJavaProject);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
}
public IPackageFragment getTryCatchPackage() {
return fTryCatchPackage;
}
}
-
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup1d8.java
index 9f98a3f630..b26ac549fc 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTestSetup1d8.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014, 2018 IBM Corporation and others.
+ * Copyright (c) 2014, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,12 +15,13 @@ package org.eclipse.jdt.ui.tests.refactoring;
import java.util.Hashtable;
-import junit.extensions.TestSetup;
-import junit.framework.Test;
+import org.junit.rules.ExternalResource;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.TestOptions;
+import org.eclipse.core.runtime.CoreException;
+
import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.jdt.core.IJavaProject;
@@ -35,9 +36,10 @@ import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.util.CoreUtility;
-
-public class SurroundWithTestSetup18 extends TestSetup {
-
+/**
+ * This class is made to run tests on Java Spider 1.8 .
+ */
+public class SurroundWithTestSetup1d8 extends ExternalResource {
private IJavaProject fJavaProject;
private IPackageFragmentRoot fRoot;
@@ -46,17 +48,12 @@ public class SurroundWithTestSetup18 extends TestSetup {
private IPackageFragment fTryCatchPackage;
- public SurroundWithTestSetup18(Test test) {
- super(test);
- }
-
public IPackageFragmentRoot getRoot() {
return fRoot;
}
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void before() throws Exception {
Hashtable<String, String> options= TestOptions.getDefaultOptions();
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB);
@@ -78,9 +75,12 @@ public class SurroundWithTestSetup18 extends TestSetup {
}
@Override
- protected void tearDown() throws Exception {
- super.tearDown();
- JavaProjectHelper.delete(fJavaProject);
+ public void after() {
+ try {
+ JavaProjectHelper.delete(fJavaProject);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
}
public IPackageFragment getTryCatchPackage() {
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests.java
index 2706c74aa1..50bcec2d7f 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,11 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.INVALID_SELECTION;
+
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
@@ -22,23 +25,10 @@ import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefactoring;
-public class SurroundWithTests extends AbstractSelectionTestCase {
-
- private static SurroundWithTestSetup fgTestSetup;
-
- public SurroundWithTests(String name) {
- super(name);
- }
+public class SurroundWithTests extends AbstractJunit4SelectionTestCase {
- public static Test suite() {
- fgTestSetup= new SurroundWithTestSetup(new TestSuite(SurroundWithTests.class));
- return fgTestSetup;
- }
-
- public static Test setUpTest(Test someTest) {
- fgTestSetup= new SurroundWithTestSetup(someTest);
- return fgTestSetup;
- }
+ @Rule
+ public SurroundWithTestSetup fgTestSetup=new SurroundWithTestSetup();
protected IPackageFragmentRoot getRoot() {
return fgTestSetup.getRoot();
@@ -54,7 +44,7 @@ public class SurroundWithTests extends AbstractSelectionTestCase {
return Character.toUpperCase(name.charAt(0)) + name.substring(1) + ".java";
}
- protected void performTest(IPackageFragment packageFragment, String name, String outputFolder, int mode) throws Exception {
+ protected void performTest(IPackageFragment packageFragment, String name, String outputFolder, TestMode mode) throws Exception {
ICompilationUnit unit= createCU(packageFragment, name);
SurroundWithTryCatchRefactoring refactoring= createRefactoring(unit);
String out= null;
@@ -75,146 +65,182 @@ public class SurroundWithTests extends AbstractSelectionTestCase {
performTest(fgTestSetup.getTryCatchPackage(), getName(), "trycatch_out", COMPARE_WITH_OUTPUT);
}
+ @Test
public void testNoException() throws Exception {
tryCatchTest();
}
+ @Test
public void testAlreadyCaught() throws Exception {
tryCatchTest();
}
+ @Test
public void testInvalidParent1() throws Exception {
tryCatchInvalidTest();
}
+ @Test
public void testInvalidParent2() throws Exception {
tryCatchInvalidTest();
}
+ @Test
public void testThisConstructorCall() throws Exception {
tryCatchInvalidTest();
}
+ @Test
public void testSuperConstructorCall() throws Exception {
tryCatchInvalidTest();
}
+ @Test
public void testSimple() throws Exception {
tryCatchTest();
}
+ @Test
public void testOneLine() throws Exception {
tryCatchTest();
}
+ @Test
public void testMultiLine() throws Exception {
tryCatchTest();
}
+ @Test
public void testExceptionOrder() throws Exception {
tryCatchTest();
}
+ @Test
public void testWrappedLocal1() throws Exception {
tryCatchTest();
}
+ @Test
public void testWrappedLocal2() throws Exception {
tryCatchTest();
}
+ @Test
public void testWrappedLocal3() throws Exception {
tryCatchTest();
}
+ @Test
public void testWrappedLocal4() throws Exception {
tryCatchTest();
}
+ @Test
public void testWrappedLocal5() throws Exception {
tryCatchTest();
}
+ @Test
public void testWrappedLocal6() throws Exception {
tryCatchTest();
}
+ @Test
public void testWrappedLocal7() throws Exception {
tryCatchTest();
}
+ @Test
public void testWrappedLocal8() throws Exception {
tryCatchTest();
}
+ @Test
public void testInitializerThrowsException() throws Exception {
tryCatchTest();
}
+ @Test
public void testThrowInCatch() throws Exception {
tryCatchTest();
}
+ @Test
public void testExpression() throws Exception {
tryCatchTest();
}
+ @Test
public void testExpressionStatement() throws Exception {
tryCatchTest();
}
+ @Test
public void testInitializer() throws Exception {
tryCatchTest();
}
+ @Test
public void testSuperCall() throws Exception {
tryCatchTest();
}
+ @Test
public void testRuntimeException1() throws Exception {
tryCatchTest();
}
+ @Test
public void testNested() throws Exception {
tryCatchTest();
}
+ @Test
public void testRuntimeException2() throws Exception {
tryCatchTest();
}
+ @Test
public void testStaticField() throws Exception {
tryCatchInvalidTest();
}
+ @Test
public void testDeclarationInitializer() throws Exception {
tryCatchTest();
}
+ @Test
public void testThenStatement() throws Exception {
tryCatchTest();
}
+ @Test
public void testEnum1() throws Exception {
tryCatchTest();
}
+ @Test
public void testEnum2() throws Exception {
tryCatchTest();
}
+ @Test
public void testGeneric1() throws Exception {
tryCatchTest();
}
+ @Test
public void testGeneric2() throws Exception {
tryCatchTest();
}
+ @Test
public void testMethodThrowsException() throws Exception {
tryCatchTest();
}
+ @Test
public void testMethodThrowsException1() throws Exception {
tryCatchTest();
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests17.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests1d7.java
index d6de131686..ff98269d3f 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests17.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests1d7.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 IBM Corporation and others.
+ * Copyright (c) 2011, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,30 +14,29 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.INVALID_SELECTION;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefactoring;
-public class SurroundWithTests17 extends SurroundWithTests {
-
- private static SurroundWithTestSetup17 fgTestSetup;
-
- public SurroundWithTests17(String name) {
- super(name);
- }
-
- public static Test suite() {
- fgTestSetup= new SurroundWithTestSetup17(new NoSuperTestsSuite(SurroundWithTests17.class));
- return fgTestSetup;
- }
+import org.eclipse.jdt.ui.tests.CustomBaseRunner;
+import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
- public static Test setUpTest(Test someTest) {
- fgTestSetup= new SurroundWithTestSetup17(someTest);
- return fgTestSetup;
- }
+/**
+ * Those tests should run on Java Dolphin 1.7 .
+ */
+@IgnoreInheritedTests
+@RunWith(CustomBaseRunner.class)
+public class SurroundWithTests1d7 extends SurroundWithTests {
+ @Rule
+ public SurroundWithTestSetup17 fgTestSetup= new SurroundWithTestSetup17();
@Override
protected IPackageFragmentRoot getRoot() {
@@ -59,16 +58,18 @@ public class SurroundWithTests17 extends SurroundWithTests {
performTest(fgTestSetup.getTryCatchPackage(), getName(), "trycatch17_out", COMPARE_WITH_OUTPUT);
}
+ @Test
public void testSimple1() throws Exception {
tryCatchTest();
}
+ @Test
public void testSimple2() throws Exception {
tryCatchTest();
}
+ @Test
public void testMultiTryCatch() throws Exception {
tryCatchTest();
}
-
-} \ No newline at end of file
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests18.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests1d8.java
index 5c11058bde..6a966a245b 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests18.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/SurroundWithTests1d8.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014, 2015 IBM Corporation and others.
+ * Copyright (c) 2014, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,30 +13,30 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.COMPARE_WITH_OUTPUT;
+import static org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase.TestMode.INVALID_SELECTION;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefactoring;
-import junit.framework.Test;
-
-public class SurroundWithTests18 extends SurroundWithTests {
-
- private static SurroundWithTestSetup18 fgTestSetup;
+import org.eclipse.jdt.ui.tests.CustomBaseRunner;
+import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
- public SurroundWithTests18(String name) {
- super(name);
- }
-
- public static Test suite() {
- fgTestSetup= new SurroundWithTestSetup18(new NoSuperTestsSuite(SurroundWithTests18.class));
- return fgTestSetup;
- }
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
+@IgnoreInheritedTests
+@RunWith(CustomBaseRunner.class)
+public class SurroundWithTests1d8 extends SurroundWithTests {
- public static Test setUpTest(Test someTest) {
- fgTestSetup= new SurroundWithTestSetup18(someTest);
- return fgTestSetup;
- }
+ @Rule
+ public SurroundWithTestSetup1d8 fgTestSetup=new SurroundWithTestSetup1d8();
@Override
protected IPackageFragmentRoot getRoot() {
@@ -58,46 +58,57 @@ public class SurroundWithTests18 extends SurroundWithTests {
performTest(fgTestSetup.getTryCatchPackage(), getName(), "trycatch18_out", COMPARE_WITH_OUTPUT);
}
+ @Test
public void testSimple1() throws Exception {
tryCatchTest();
}
+ @Test
public void testLambda1() throws Exception {
tryCatchTest();
}
+ @Test
public void testLambda2() throws Exception {
tryCatchInvalidTest();
}
+ @Test
public void testLambda3() throws Exception {
tryCatchTest();
}
+ @Test
public void testLambda4() throws Exception {
tryCatchTest();
}
+ @Test
public void testMethodReference1() throws Exception {
tryCatchTest();
}
+ @Test
public void testMethodReference2() throws Exception {
tryCatchTest();
}
+ @Test
public void testMethodReference3() throws Exception {
tryCatchInvalidTest();
}
+ @Test
public void testMethodReference4() throws Exception {
tryCatchTest();
}
+ @Test
public void testMethodReference5() throws Exception {
tryCatchInvalidTest();
}
+ @Test
public void testMethodReference6() throws Exception {
tryCatchTest();
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UndoManagerTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UndoManagerTests.java
index 9a47958887..9b2e3eace6 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UndoManagerTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UndoManagerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,12 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.After;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -22,20 +26,12 @@ import org.eclipse.ltk.core.refactoring.IUndoManager;
import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.ltk.internal.core.refactoring.UndoManager2;
-public class UndoManagerTests extends RefactoringTest {
-
- private static final Class<UndoManagerTests> clazz= UndoManagerTests.class;
- public UndoManagerTests(String name) {
- super(name);
- }
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
+public class UndoManagerTests extends GenericRefactoringTest {
- public static Test setUpTest(Test test) {
- return new RefactoringTestSetup(test);
- }
+ @Rule
+ public RefactoringTestSetup rts= new RefactoringTestSetup();
private void checkState(boolean undo, boolean redo, int undoCount, int redoCount){
checkState(0, undo, redo, undoCount, redoCount);
@@ -46,15 +42,14 @@ public class UndoManagerTests extends RefactoringTest {
return RefactoringCore.getUndoManager();
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void after() throws Exception {
RefactoringCore.getUndoManager().flush();
}
private void checkState(int iterationCount, boolean undo, boolean redo, int undoCount, int redoCount){
- assertTrue(iterationCount + " undo", undo == RefactoringCore.getUndoManager().anythingToUndo());
- assertTrue(iterationCount + " redo", redo == RefactoringCore.getUndoManager().anythingToRedo());
+ assertEquals(iterationCount + " undo", undo, RefactoringCore.getUndoManager().anythingToUndo());
+ assertEquals(iterationCount + " redo", redo, RefactoringCore.getUndoManager().anythingToRedo());
testCounts(iterationCount, undoCount, redoCount);
}
@@ -75,21 +70,25 @@ public class UndoManagerTests extends RefactoringTest {
RefactoringCore.getUndoManager().performRedo(null, new NullProgressMonitor());
}
+ @Test
public void test0() throws Exception{
checkState(false, false, 0, 0);
}
+ @Test
public void test1() throws Exception{
performRefactoring(new NullRefactoring());
checkState(true, false, 1, 0);
}
+ @Test
public void test2() throws Exception{
performRefactoring(new NullRefactoring());
performUndo();
checkState(false, true, 0, 1);
}
+ @Test
public void test3() throws Exception{
performRefactoring(new NullRefactoring());
performUndo();
@@ -97,6 +96,7 @@ public class UndoManagerTests extends RefactoringTest {
checkState(true, false, 1, 0);
}
+ @Test
public void test4() throws Exception{
performRefactoring(new NullRefactoring());
performUndo();
@@ -105,6 +105,7 @@ public class UndoManagerTests extends RefactoringTest {
checkState(false, true, 0, 1);
}
+ @Test
public void test5() throws Exception{
performRefactoring(new NullRefactoring());
performUndo();
@@ -113,6 +114,7 @@ public class UndoManagerTests extends RefactoringTest {
checkState(true, false, 2, 0);
}
+ @Test
public void test6() throws Exception{
performRefactoring(new NullRefactoring());
performUndo();
@@ -123,6 +125,7 @@ public class UndoManagerTests extends RefactoringTest {
checkState(false, true, 0, 2);
}
+ @Test
public void test7() throws Exception{
performRefactoring(new NullRefactoring());
performUndo();
@@ -132,6 +135,7 @@ public class UndoManagerTests extends RefactoringTest {
checkState(true, true, 1, 1);
}
+ @Test
public void test8() throws Exception{
// limit is 5 since the stack is limited to 5 entries
int limit= 5;
@@ -151,6 +155,7 @@ public class UndoManagerTests extends RefactoringTest {
}
+ @Test
public void test9() throws Exception{
performRefactoring(new NullRefactoring());
performUndo();
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UseSupertypeWherePossibleTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UseSupertypeWherePossibleTests.java
index c211f32f4c..d33859b603 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UseSupertypeWherePossibleTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/UseSupertypeWherePossibleTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,13 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -30,31 +35,22 @@ import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType;
import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.core.refactoring.descriptors.RefactoringSignatureDescriptorFactory;
-public class UseSupertypeWherePossibleTests extends RefactoringTest {
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
- private static final Class<UseSupertypeWherePossibleTests> clazz= UseSupertypeWherePossibleTests.class;
- private static final String REFACTORING_PATH= "UseSupertypeWherePossible/";
+public class UseSupertypeWherePossibleTests extends GenericRefactoringTest {
- public UseSupertypeWherePossibleTests(String name) {
- super(name);
- }
+ private static final String REFACTORING_PATH= "UseSupertypeWherePossible/";
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test test) {
- return new RefactoringTestSetup(test);
- }
+ @Rule
+ public RefactoringTestSetup rts= new RefactoringTestSetup();
@Override
protected String getRefactoringPath() {
return REFACTORING_PATH;
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void before() throws Exception {
StubUtility.setCodeTemplate(CodeTemplateContextType.NEWTYPE_ID,
"${package_declaration}" +
System.getProperty("line.separator", "\n") +
@@ -88,7 +84,7 @@ public class UseSupertypeWherePossibleTests extends RefactoringTest {
final Refactoring refactoring= descriptor.createRefactoring(status);
assertTrue("status should be ok", status.isOK());
assertNotNull("refactoring should not be null", refactoring);
- assertEquals("was supposed to pass", null, performRefactoring(refactoring));
+ assertNull("was supposed to pass", performRefactoring(refactoring));
for (int i= 0; i < units.length; i++) {
String expected= getFileContents(getOutputTestFileName(cuNames[i]));
@@ -104,175 +100,212 @@ public class UseSupertypeWherePossibleTests extends RefactoringTest {
//---------------tests ----------------------
+ @Test
public void testNew0() throws Exception{
validatePassingTest("A", new String[]{"A"}, "java.lang.Object");
}
+ @Test
public void testNew1() throws Exception{
// printTestDisabledMessage("bug 23597 ");
validatePassingTest("A", new String[]{"A"}, "java.lang.Object");
}
+ @Test
public void testNew2() throws Exception{
validatePassingTest("A", new String[]{"A"}, "java.lang.Object");
}
+ @Test
public void testNew3() throws Exception{
validatePassingTest("A", new String[]{"A"}, "java.lang.Object");
}
+ @Test
public void testNew4() throws Exception{
validatePassingTest("A", new String[]{"A", "Test"}, "java.lang.Object");
}
+ @Test
public void testNew5() throws Exception{
validatePassingTest("A", new String[]{"A", "Test"}, "java.lang.Object");
}
+ @Test
public void testNew6() throws Exception{
validatePassingTest("A", new String[]{"A", "Test"}, "java.lang.Object");
}
+ @Test
public void testNew7() throws Exception{
validatePassingTest("A", new String[]{"A", "Test", "B"}, "p.B");
}
+ @Test
public void testNew8() throws Exception{
validatePassingTest("A", new String[]{"A", "Test", "B"}, "p.B");
}
+ @Test
public void testNew9() throws Exception{
validatePassingTest("A", new String[]{"A", "Test"}, "java.lang.Object");
}
+ @Test
public void testNew10() throws Exception{
validatePassingTest("A", new String[]{"A", "Test", "B"}, "p.B");
}
+ @Test
public void testNew11() throws Exception{
validatePassingTest("A", new String[]{"A", "Test", "B"}, "p.B");
}
+ @Test
public void testNew12() throws Exception{
validatePassingTest("A", new String[]{"A", "Test", "B"}, "p.B");
}
+ @Test
public void testNew13() throws Exception{
validatePassingTest("A", new String[]{"A", "Test", "B"}, "p.B");
}
+ @Test
public void testNew14() throws Exception{
validatePassingTest("A", new String[]{"A", "Test", "B"}, "p.B");
}
+ @Test
public void testNew15() throws Exception{
validatePassingTest("A", new String[]{"A", "Test", "B"}, "p.B");
}
+ @Test
public void testNew16() throws Exception{
// printTestDisabledMessage("instanceof ");
validatePassingTest("A", new String[]{"A", "Test", "B"}, "p.B");
}
+ @Test
public void testNew17() throws Exception{
validatePassingTest("A", new String[]{"A"}, "p.C");
}
+ @Test
public void testNew18() throws Exception{
validatePassingTest("A", new String[]{"A"}, "p.B");
}
+ @Test
public void testNew19() throws Exception{
validatePassingTest("A", new String[]{"A"}, "p.I");
}
+ @Test
public void testNew20() throws Exception{
// printTestDisabledMessage("http://dev.eclipse.org/bugs/show_bug.cgi?id=23829");
validatePassingTest("A", new String[]{"A"}, "p.B");
}
+ @Test
public void testNew21() throws Exception{
validatePassingTest("A", new String[]{"A"}, "java.lang.Object");
}
+ @Test
public void testNew22() throws Exception{
validatePassingTest("A", new String[]{"A", "B", "Test"}, "p.B");
}
+ @Test
public void testNew23() throws Exception{
validatePassingTest("A", new String[]{"A", "B", "Test"}, "java.lang.Object");
}
+ @Test
public void testNew24() throws Exception{
validatePassingTest("A", new String[]{"A", "B"}, "java.lang.Object");
}
+ @Test
public void testNew25() throws Exception{
validatePassingTest("A", new String[]{"A", "B", "C"}, "java.lang.Object");
}
+ @Test
public void testNew26() throws Exception{
validatePassingTest("A", new String[]{"A", "B"}, "java.lang.Object");
}
+ @Test
public void testNew27() throws Exception{
validatePassingTest("A", new String[]{"A", "B"}, "p.B");
}
+ @Test
public void testNew28() throws Exception{
validatePassingTest("A", new String[]{"A", "B"}, "p.B");
}
+ @Test
public void testNew29() throws Exception{
// printTestDisabledMessage("bug 24278");
validatePassingTest("A", new String[]{"A"}, "p.B");
}
+ @Test
public void testNew30() throws Exception{
// printTestDisabledMessage("bug 24278");
validatePassingTest("A", new String[]{"A"}, "p.B");
}
+ @Test
public void testNew31() throws Exception{
// printTestDisabledMessage("bug 24278");
validatePassingTest("A", new String[]{"A"}, "p.B");
}
+ @Test
public void testNew32() throws Exception{
// printTestDisabledMessage();
validatePassingTest("A", new String[]{"A"}, "p.B");
}
-
+ @Test
public void testNew33() throws Exception{
// printTestDisabledMessage("bug 26282");
validatePassingTest("A", new String[]{"A"}, "java.util.Vector");
}
-
+ @Test
public void testNew34() throws Exception{
// printTestDisabledMessage("bug 26282");
validatePassingTest("A", new String[]{"A"}, "java.util.Vector");
}
-
+ @Test
public void testNew35() throws Exception{
// printTestDisabledMessage("bug 26282");
validatePassingTest("A", new String[]{"A"}, "java.util.Vector");
}
+ @Test
public void testNew36() throws Exception{
// printTestDisabledMessage("bug 26288");
validatePassingTest("A", new String[]{"A"}, "p.B");
}
+ @Test
public void testNew37() throws Exception{
// printTestDisabledMessage("bug 26288");
validatePassingTest("A", new String[]{"A"}, "p.B");
}
+ @Test
public void testNew38() throws Exception{
// printTestDisabledMessage("bug 40373");
validatePassingTest("A", new String[]{"A"}, "p.B");
}
+ @Test
public void testNew39() throws Exception{
// printTestDisabledMessage("bug 169608");
validatePassingTest("C", new String[]{"C"}, "p.B");
@@ -281,217 +314,288 @@ public class UseSupertypeWherePossibleTests extends RefactoringTest {
/* i had to rename tests 0-15 because of cvs problems*/
+ @Test
public void test0_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test1_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test2_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test3_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test4_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test5_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test6_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test7_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test8_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test9_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test10_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test11_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test12_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test13_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test14_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test15_() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test16() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test17() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test18() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test19() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test20() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test21() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test22() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test23() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test24() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test25() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test26() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test27() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test28() throws Exception{
// printTestDisabledMessage("bug 22883");
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test29() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test30() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test31() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test32() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test33() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test34() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test35() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test36() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test37() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test38() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test39() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test40() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test41() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test42() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test43() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test44() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test45() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test46() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test47() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test48() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test49() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test50() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test51() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test52() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test53() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test54() throws Exception{
validatePassingTest("A", new String[]{"A", "A1", "I"}, "p.I");
}
+ @Test
public void test55() throws Exception{
validatePassingTest("A", new String[]{"A", "A1", "I"}, "p.I");
}
+ @Test
public void test56() throws Exception{
validatePassingTest("A", new String[]{"A", "A1", "I"}, "p.I");
}
+ @Test
public void test57() throws Exception{
validatePassingTest("A", new String[]{"A", "A1", "I"}, "p.I");
}
+ @Test
public void test58() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test59() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test60() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test61() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test62() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test63() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test64() throws Exception{
validatePassingTest("A", new String[]{"A", "I", "Inter"}, "p.I");
}
+ @Test
public void test65() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test66() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test67() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
+ @Test
public void test68() throws Exception{
validatePassingTest("A", new String[]{"A", "As", "I"}, "p.I");
}
+ @Test
public void test69() throws Exception{
validatePassingTest("A", new String[]{"A", "As", "I"}, "p.I");
}
+ @Test
public void test70() throws Exception{
validatePassingTest("A", new String[]{"A", "I"}, "p.I");
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ValidateEditTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ValidateEditTests.java
index 76485c1f79..ba73f51b5b 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ValidateEditTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ValidateEditTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,11 +13,16 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.ByteArrayInputStream;
import java.util.Collection;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.team.core.RepositoryProvider;
@@ -40,45 +45,34 @@ import org.eclipse.jdt.core.refactoring.IJavaRefactorings;
import org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor;
import org.eclipse.jdt.internal.core.refactoring.descriptors.RefactoringSignatureDescriptorFactory;
+import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy.ICopyPolicy;
+import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy.IMovePolicy;
import org.eclipse.jdt.internal.corext.refactoring.reorg.JavaCopyProcessor;
import org.eclipse.jdt.internal.corext.refactoring.reorg.JavaMoveProcessor;
import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgDestinationFactory;
import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory;
-import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy.ICopyPolicy;
-import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy.IMovePolicy;
import org.eclipse.jdt.ui.tests.refactoring.ccp.MockReorgQueries;
import org.eclipse.jdt.ui.tests.refactoring.infra.RefactoringTestRepositoryProvider;
+import org.eclipse.jdt.ui.tests.refactoring.rules.Java15Setup;
-public class ValidateEditTests extends RefactoringTest {
-
- private static final Class<ValidateEditTests> clazz= ValidateEditTests.class;
+public class ValidateEditTests extends GenericRefactoringTest {
- public ValidateEditTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new Java15Setup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new Java15Setup(someTest);
- }
+ @Rule
+ public Java15Setup fgTestSetup= new Java15Setup();
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
RepositoryProvider.map(getRoot().getJavaProject().getProject(), RefactoringTestRepositoryProvider.PROVIDER_ID);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
RepositoryProvider.unmap(getRoot().getJavaProject().getProject());
- super.tearDown();
}
+ @Test
public void testPackageRename1() throws Exception {
IPackageFragment fragment= getRoot().createPackageFragment("org.test", true, null);
@@ -110,6 +104,7 @@ public class ValidateEditTests extends RefactoringTest {
assertTrue(validatedEditPaths.contains(cu2.getPath()));
}
+ @Test
public void testPackageRename2() throws Exception {
// A readonly and moved, B moved, C changes
@@ -152,6 +147,7 @@ public class ValidateEditTests extends RefactoringTest {
assertTrue(validatedEditPaths.contains(cu3.getPath()));
}
+ @Test
public void testPackageRenameWithResource() throws Exception {
// MyClass readonly and moved, x.properties readonly moved
@@ -183,6 +179,7 @@ public class ValidateEditTests extends RefactoringTest {
}
+ @Test
public void testPackageRenameWithResource2() throws Exception {
// MyClass readonly and moved, x.properties readonly moved
@@ -217,6 +214,7 @@ public class ValidateEditTests extends RefactoringTest {
assertTrue(validatedEditPaths.contains(file.getFullPath()));
}
+ @Test
public void testCURename() throws Exception {
IPackageFragment fragment= getRoot().createPackageFragment("org.test", true, null);
@@ -249,6 +247,7 @@ public class ValidateEditTests extends RefactoringTest {
assertTrue(validatedEditPaths.contains(cu2.getPath()));
}
+ @Test
public void testTypeRename() throws Exception {
IPackageFragment fragment= getRoot().createPackageFragment("org.test", true, null);
@@ -281,6 +280,7 @@ public class ValidateEditTests extends RefactoringTest {
assertTrue(validatedEditPaths.contains(cu2.getPath()));
}
+ @Test
public void testMoveCU2() throws Exception {
// Move CU and file: Only CU be validated as file doesn't change
@@ -322,6 +322,7 @@ public class ValidateEditTests extends RefactoringTest {
assertTrue(validatedEditPaths.contains(cu2.getPath())); // changed
}
+ @Test
public void testMoveFileWithReplace() throws Exception {
// Move file to a existing location
@@ -353,6 +354,7 @@ public class ValidateEditTests extends RefactoringTest {
assertTrue(validatedEditPaths.contains(file2.getFullPath())); // replaced
}
+ @Test
public void testMoveCuWithReplace() throws Exception {
// Move CU to an existing location
@@ -391,6 +393,7 @@ public class ValidateEditTests extends RefactoringTest {
assertTrue(validatedEditPaths.contains(cu2.getPath())); // replaced
}
+ @Test
public void testCopyCuWithReplace() throws Exception {
// Copy CU to a existing location
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/actions/StructureSelectionActionTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/actions/StructureSelectionActionTests.java
index 205e6b1e22..72ff5693b9 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/actions/StructureSelectionActionTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/actions/StructureSelectionActionTests.java
@@ -13,10 +13,12 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.actions;
+import static org.junit.Assert.assertEquals;
+
import java.io.IOException;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
@@ -24,37 +26,26 @@ import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.SourceRange;
-import org.eclipse.jdt.ui.tests.refactoring.AbstractSelectionTestCase;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup;
+import org.eclipse.jdt.ui.tests.refactoring.AbstractJunit4SelectionTestCase;
+import org.eclipse.jdt.ui.tests.refactoring.GenericRefactoringTest;
import org.eclipse.jdt.ui.tests.refactoring.infra.TextRangeUtil;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
import org.eclipse.jdt.internal.ui.javaeditor.selectionactions.StructureSelectEnclosingAction;
import org.eclipse.jdt.internal.ui.javaeditor.selectionactions.StructureSelectNextAction;
import org.eclipse.jdt.internal.ui.javaeditor.selectionactions.StructureSelectPreviousAction;
-public class StructureSelectionActionTests extends RefactoringTest{
-
- private static final Class<StructureSelectionActionTests> clazz= StructureSelectionActionTests.class;
+public class StructureSelectionActionTests extends GenericRefactoringTest {
private static final String REFACTORING_PATH= "StructureSelectionAction/";
- public StructureSelectionActionTests(String name){
- super(name);
- }
+ @Rule
+ public RefactoringTestSetup rts= new RefactoringTestSetup();
@Override
protected String getRefactoringPath() {
return REFACTORING_PATH;
}
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test test) {
- return new RefactoringTestSetup(test);
- }
-
private String getSimpleTestFileName(boolean input){
String fileName = "A_" + getName();
fileName += input ? "": "_out";
@@ -75,10 +66,10 @@ public class StructureSelectionActionTests extends RefactoringTest{
return createCU(pack, cuName, getFileContents(getTestFileName(input)));
}
- private ISourceRange getSelection(ICompilationUnit cu) throws Exception{
+ private ISourceRange getSelection(ICompilationUnit cu) throws Exception {
String source= cu.getSource();
- int offset= source.indexOf(AbstractSelectionTestCase.SQUARE_BRACKET_OPEN);
- int end= source.indexOf(AbstractSelectionTestCase.SQUARE_BRACKET_CLOSE);
+ int offset= source.indexOf(AbstractJunit4SelectionTestCase.SQUARE_BRACKET_OPEN);
+ int end= source.indexOf(AbstractJunit4SelectionTestCase.SQUARE_BRACKET_CLOSE);
return new SourceRange(offset, end - offset);
}
@@ -89,7 +80,7 @@ public class StructureSelectionActionTests extends RefactoringTest{
assertEqualLines("selection incorrect", expected, actual);
}
- private void helperSelectUp() throws Exception{
+ private void helperSelectUp() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), true);
ISourceRange selection= getSelection(cu);
@@ -98,7 +89,7 @@ public class StructureSelectionActionTests extends RefactoringTest{
check(cu, newRange);
}
- private void helperSelectUp(int startLine, int startColumn, int endLine, int endColumn) throws Exception{
+ private void helperSelectUp(int startLine, int startColumn, int endLine, int endColumn) throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), true);
ISourceRange selection= TextRangeUtil.getSelection(cu, startLine, startColumn, endLine, endColumn);
ISourceRange newRange= new StructureSelectEnclosingAction().getNewSelectionRange(selection, cu);
@@ -106,7 +97,7 @@ public class StructureSelectionActionTests extends RefactoringTest{
check(cu, newRange);
}
- private void helperSelectNext(int startLine, int startColumn, int endLine, int endColumn) throws Exception{
+ private void helperSelectNext(int startLine, int startColumn, int endLine, int endColumn) throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), true);
ISourceRange selection= TextRangeUtil.getSelection(cu, startLine, startColumn, endLine, endColumn);
@@ -114,7 +105,7 @@ public class StructureSelectionActionTests extends RefactoringTest{
check(cu, newRange);
}
- private void helperSelectPrevious(int startLine, int startColumn, int endLine, int endColumn) throws Exception{
+ private void helperSelectPrevious(int startLine, int startColumn, int endLine, int endColumn) throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), true);
ISourceRange selection= TextRangeUtil.getSelection(cu, startLine, startColumn, endLine, endColumn);
@@ -122,7 +113,7 @@ public class StructureSelectionActionTests extends RefactoringTest{
check(cu, newRange);
}
- private void helperZeroLength(int line, int column) throws Exception{
+ private void helperZeroLength(int line, int column) throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), true);
ISourceRange selection= new SourceRange(TextRangeUtil.getOffset(cu, line, column), 1);
@@ -132,7 +123,7 @@ public class StructureSelectionActionTests extends RefactoringTest{
check(cu, newRange);
}
- private void offsetTest(int line, int column, int expected) throws Exception{
+ private void offsetTest(int line, int column, int expected) throws Exception {
String filePath= TEST_PATH_PREFIX + getRefactoringPath() + "OffsetTest.java";
ICompilationUnit cu= createCU(getPackageP(), "OffsetTest.java", getFileContents(filePath));
assertEquals("incorrect offset", expected, TextRangeUtil.getOffset(cu, line, column));
@@ -141,237 +132,288 @@ public class StructureSelectionActionTests extends RefactoringTest{
// ---- tests ---
- public void test0() throws Exception{
+ @Test
+ public void test0() throws Exception {
helperSelectUp(4, 9, 4, 13);
}
- public void test1() throws Exception{
+ @Test
+ public void test1() throws Exception {
helperSelectUp();
}
- public void test2() throws Exception{
+ @Test
+ public void test2() throws Exception {
helperSelectUp(4, 16, 4, 21);
}
- public void test3() throws Exception{
+ @Test
+ public void test3() throws Exception {
helperSelectUp(4, 9, 4, 21);
}
- public void test4() throws Exception{
+ @Test
+ public void test4() throws Exception {
helperSelectUp();
}
- public void test5() throws Exception{
+ @Test
+ public void test5() throws Exception {
helperSelectUp();
}
- public void test6() throws Exception{
+ @Test
+ public void test6() throws Exception {
helperSelectUp();
}
- public void test7() throws Exception{
+ @Test
+ public void test7() throws Exception {
//helper1();
helperSelectUp(3, 10, 3, 14);
}
- public void test8() throws Exception{
+ @Test
+ public void test8() throws Exception {
helperSelectUp(3, 16, 3, 18);
}
- public void test9() throws Exception{
+ @Test
+ public void test9() throws Exception {
helperSelectUp(3, 10, 3, 11);
}
- public void test10() throws Exception{
+ @Test
+ public void test10() throws Exception {
helperSelectUp(4, 18, 4, 21);
}
- public void test11() throws Exception{
+ @Test
+ public void test11() throws Exception {
helperSelectUp(4, 20, 4, 21);
}
- public void test12() throws Exception{
+ @Test
+ public void test12() throws Exception {
helperSelectUp(4, 16, 4, 19);
}
- public void test13() throws Exception{
+ @Test
+ public void test13() throws Exception {
helperSelectUp(4, 13, 4, 16);
}
- public void test14() throws Exception{
+ @Test
+ public void test14() throws Exception {
helperSelectUp(4, 16, 4, 21);
}
- public void test15() throws Exception{
+ @Test
+ public void test15() throws Exception {
// identical to test9 ???
helperSelectUp(3, 10, 3, 11);
}
- public void test16() throws Exception{
+ @Test
+ public void test16() throws Exception {
helperSelectUp(3, 16, 3, 17);
}
- public void test17() throws Exception{
+ @Test
+ public void test17() throws Exception {
helperSelectUp(3, 5, 7, 6);
}
- public void test18() throws Exception{
+ @Test
+ public void test18() throws Exception {
helperSelectUp(3, 5, 4, 6);
}
- public void test19() throws Exception{
+ @Test
+ public void test19() throws Exception {
helperSelectUp(7, 14, 7, 16);
}
- public void test20() throws Exception{
+ @Test
+ public void test20() throws Exception {
helperSelectUp(4, 18, 4, 19);
}
- public void test21() throws Exception{
+ @Test
+ public void test21() throws Exception {
//regression test for bug#10182
//printTestDisabledMessage("regression test for bug#11151");
helperSelectNext(3, 21, 3, 28);
}
- public void test22() throws Exception{
+ @Test
+ public void test22() throws Exception {
//regression test for bug#10182
//printTestDisabledMessage("regression test for bug#11151");
helperSelectPrevious(3, 21, 3, 28);
}
- public void test23() throws Exception{
+ @Test
+ public void test23() throws Exception {
// printTestDisabledMessage("regression test for bug#10570");
helperSelectPrevious(5, 30, 7, 10);
}
- public void test24() throws Exception{
+ @Test
+ public void test24() throws Exception {
//regression test for bug#11424
helperSelectPrevious(3, 13, 5, 6);
}
- public void test25() throws Exception{
+ @Test
+ public void test25() throws Exception {
//regression test for bug#11879
helperSelectNext(5, 5, 6, 6);
}
- public void test26() throws Exception{
+ @Test
+ public void test26() throws Exception {
//regression test for bug#11879
helperSelectPrevious(5, 5, 6, 6);
}
- public void test27() throws Exception{
+ @Test
+ public void test27() throws Exception {
//regression test for bug#11879
helperSelectNext(4, 1, 4, 10);
}
- public void test28() throws Exception{
+ @Test
+ public void test28() throws Exception {
//regression test for bug#11879
helperSelectPrevious(4, 1, 4, 10);
}
- public void test29() throws Exception{
+ @Test
+ public void test29() throws Exception {
// printTestDisabledMessage("regression test for bug#16051");
helperSelectUp(5, 13, 5, 17);
}
- public void test30() throws Exception{
+ @Test
+ public void test30() throws Exception {
// printTestDisabledMessage("regression test for bug#80345 (not 22082)");
helperSelectUp(3, 10, 3, 10);
}
- public void test31() throws Exception{
+ @Test
+ public void test31() throws Exception {
// printTestDisabledMessage("regression test for bug#80345 (not 22082)");
helperSelectUp(3, 10, 3, 10);
}
- public void test32() throws Exception{
+ @Test
+ public void test32() throws Exception {
// printTestDisabledMessage("regression test for bug#22939");
helperSelectUp(4, 18, 4, 18);
}
- public void test33() throws Exception{
+ @Test
+ public void test33() throws Exception {
// printTestDisabledMessage("regression test for bug#22939");
helperSelectUp(5, 23, 5, 23);
}
- public void test34() throws Exception{
+ @Test
+ public void test34() throws Exception {
// printTestDisabledMessage("regression test for bug#23118");
helperSelectUp(5, 14, 5, 14);
}
- public void test35() throws Exception{
+ @Test
+ public void test35() throws Exception {
// printTestDisabledMessage("regression test for bug#23118");
helperSelectUp(5, 14, 5, 14);
}
- public void test36() throws Exception{
+ @Test
+ public void test36() throws Exception {
// printTestDisabledMessage("regression test for bug#23259");
helperSelectUp(5, 14, 5, 14);
}
- public void test37() throws Exception{
+ @Test
+ public void test37() throws Exception {
// printTestDisabledMessage("regression test for bug#23259");
helperSelectUp(7, 14, 7, 14);
}
- public void test38() throws Exception{
+ @Test
+ public void test38() throws Exception {
// printTestDisabledMessage("regression test for bug#23263");
helperSelectPrevious(4, 5, 5, 16);
}
- public void test39() throws Exception{
+ @Test
+ public void test39() throws Exception {
// printTestDisabledMessage("regression test for bug#23464");
helperSelectPrevious(6, 13, 6, 20);
}
- public void test40() throws Exception{
+ @Test
+ public void test40() throws Exception {
// printTestDisabledMessage("regression test for bug#23464 ");
helperSelectPrevious(7, 13, 7, 20);
}
- public void test41() throws Exception{
+ @Test
+ public void test41() throws Exception {
helperSelectPrevious(4, 1, 4, 29);
}
- public void test42() throws Exception{
+ @Test
+ public void test42() throws Exception {
helperSelectNext(4, 1, 4, 29);
}
- public void test43() throws Exception{
+ @Test
+ public void test43() throws Exception {
helperSelectNext(4, 1, 4, 32);
}
- public void testZeroLength0() throws Exception{
+ @Test
+ public void testZeroLength0() throws Exception {
//printTestDisabledMessage("");
helperZeroLength(4, 20);
}
- public void testZeroLength1() throws Exception{
+ @Test
+ public void testZeroLength1() throws Exception {
helperSelectNext(4, 16, 4, 16);
helperSelectPrevious(4, 17, 4, 17);
}
- public void testZeroLength2() throws Exception{
+ @Test
+ public void testZeroLength2() throws Exception {
helperSelectNext(4, 20, 4, 20);
helperSelectPrevious(4, 21, 4, 21);
}
- public void testZeroLength3() throws Exception{
+ @Test
+ public void testZeroLength3() throws Exception {
helperSelectNext(3, 10, 3, 10);
helperSelectPrevious(3, 11, 3, 11);
}
- public void testZeroLength4() throws Exception{
+ @Test
+ public void testZeroLength4() throws Exception {
helperSelectNext(4, 9, 4, 9);
helperSelectPrevious(4, 10, 4, 10);
}
- public void testZeroLength5() throws Exception{
+ @Test
+ public void testZeroLength5() throws Exception {
helperSelectNext(4, 11, 4, 11);
helperSelectPrevious(4, 14, 4, 14);
}
- public void testWholeCu() throws Exception{
+ @Test
+ public void testWholeCu() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), true);
ISourceRange selection= cu.getSourceRange();
@@ -384,36 +426,42 @@ public class StructureSelectionActionTests extends RefactoringTest{
//--- offset calculation tests
- public void testOffset0() throws Exception{
+ @Test
+ public void testOffset0() throws Exception {
offsetTest(4, 20, 44);
}
- public void testOffset1() throws Exception{
+ @Test
+ public void testOffset1() throws Exception {
offsetTest(5, 9, 49);
}
- public void testOffset2() throws Exception{
+ @Test
+ public void testOffset2() throws Exception {
offsetTest(7, 13, 75);
}
+ @Test
public void testTabCount0(){
int t= TextRangeUtil.calculateTabCountInLine("\t\t1", 9);
assertEquals(2, t);
}
+ @Test
public void testTabCount1(){
int t= TextRangeUtil.calculateTabCountInLine("\t\tint i= 1 + 1;", 20);
assertEquals(2, t);
}
+ @Test
public void testTabCount2(){
int t= TextRangeUtil.calculateTabCountInLine("\t\t\treturn;", 13);
assertEquals(3, t);
}
+ @Test
public void testTabCount3(){
int t= TextRangeUtil.calculateTabCountInLine("\tvoid m(){m();", 18);
assertEquals(1, t);
}
-
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyTest.java
index 7de95c59b9..b2c38fabfe 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyTest.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,10 +14,16 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.ccp;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
@@ -69,32 +75,20 @@ import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory;
import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgUtils;
import org.eclipse.jdt.internal.corext.util.JavaElementResourceMapping;
+import org.eclipse.jdt.ui.tests.refactoring.GenericRefactoringTest;
import org.eclipse.jdt.ui.tests.refactoring.ParticipantTesting;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup;
import org.eclipse.jdt.ui.tests.refactoring.TestModelProvider;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
-
-public class CopyTest extends RefactoringTest {
-
- private static final Class<CopyTest> clazz= CopyTest.class;
+public class CopyTest extends GenericRefactoringTest {
private static final String REFACTORING_PATH= "Copy/";
- public CopyTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test test) {
- return new RefactoringTestSetup(test);
- }
+ @Rule
+ public RefactoringTestSetup fts= new RefactoringTestSetup();
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void genericbefore() throws Exception {
+ super.genericbefore();
fIsPreDeltaTest= true;
}
@@ -118,8 +112,8 @@ public class CopyTest extends RefactoringTest {
}
private void verifyDisabled(IResource[] resources, IJavaElement[] javaElements) throws JavaModelException {
- assertTrue("copy should be disabled", ! RefactoringAvailabilityTester.isCopyAvailable(resources, javaElements));
- assertTrue(!ReorgPolicyFactory.createCopyPolicy(resources, javaElements).canEnable());
+ assertFalse("copy should be disabled", RefactoringAvailabilityTester.isCopyAvailable(resources, javaElements));
+ assertFalse(ReorgPolicyFactory.createCopyPolicy(resources, javaElements).canEnable());
}
private JavaCopyProcessor verifyEnabled(IResource[] resources, IJavaElement[] javaElements, INewNameQueries newNameQueries, IReorgQueries reorgQueries) throws JavaModelException {
@@ -274,7 +268,8 @@ public class CopyTest extends RefactoringTest {
//---------------
- public void test_field_declared_in_multi_yes_type() throws Exception{
+ @Test
+ public void test_field_declared_in_multi_yes_type() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IField field= cu.getType("A").getField("bar");
IType type= cu.getType("A");
@@ -283,7 +278,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements);
}
- public void test_fields_declared_in_multi_yes_type() throws Exception{
+ @Test
+ public void test_fields_declared_in_multi_yes_type() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IField field1= cu.getType("A").getField("bar");
IField field2= cu.getType("A").getField("baz");
@@ -293,7 +289,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements);
}
- public void test_fields_declared_in_multi_yes_type_1() throws Exception{
+ @Test
+ public void test_fields_declared_in_multi_yes_type_1() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IField field1= cu.getType("A").getField("var11");
IField field2= cu.getType("A").getField("var2");
@@ -304,30 +301,35 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements);
}
+ @Test
public void testDisabled_empty() throws Exception {
IJavaElement[] javaElements= {};
IResource[] resources= {};
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_null_element() throws Exception {
IJavaElement[] javaElements= {null};
IResource[] resources= {};
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_null_resource() throws Exception {
IJavaElement[] javaElements= {};
IResource[] resources= {null};
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_javaProject() throws Exception {
IJavaElement[] javaElements= {RefactoringTestSetup.getProject()};
IResource[] resources= {};
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_defaultPackage() throws Exception {
IPackageFragment defaultPackage= getRoot().getPackageFragment("");
assertTrue(defaultPackage.exists());
@@ -336,20 +338,23 @@ public class CopyTest extends RefactoringTest {
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_project() throws Exception {
IJavaElement[] javaElements= {};
IResource[] resources= {RefactoringTestSetup.getProject().getProject()};
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_notExistingElement() throws Exception {
ICompilationUnit notExistingCu= getPackageP().getCompilationUnit("NotMe.java");
- assertTrue(! notExistingCu.exists());
+ assertFalse(notExistingCu.exists());
IJavaElement[] javaElements= {notExistingCu};
IResource[] resources= {};
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_notExistingResource() throws Exception {
IFolder folder= (IFolder)getPackageP().getResource();
IFile notExistingFile= folder.getFile("a.txt");
@@ -359,12 +364,14 @@ public class CopyTest extends RefactoringTest {
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_noCommonParent0() throws Exception {
IJavaElement[] javaElements= {getPackageP(), getRoot()};
IResource[] resources= {};
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_noCommonParent1() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor());
IType classA= cu.getType("A");
@@ -382,6 +389,7 @@ public class CopyTest extends RefactoringTest {
// verifyDisabled(resources, javaElements);
// }
+ @Test
public void testDisabled_noCommonParent3() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= {cu, getPackageP()};
@@ -389,6 +397,7 @@ public class CopyTest extends RefactoringTest {
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_noCommonParent5() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= {cu, getRoot()};
@@ -396,6 +405,7 @@ public class CopyTest extends RefactoringTest {
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_noCommonParent6() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= {cu, getRoot()};
@@ -403,6 +413,7 @@ public class CopyTest extends RefactoringTest {
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_noCommonParent7() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{class Inner{}}", false, new NullProgressMonitor());
IType classA= cu.getType("A");
@@ -412,6 +423,7 @@ public class CopyTest extends RefactoringTest {
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_noCommonParent8() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IType classA= cu.getType("A");
@@ -421,6 +433,7 @@ public class CopyTest extends RefactoringTest {
verifyDisabled(resources, javaElements);
}
+ @Test
public void testEnabled_cu() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= { cu};
@@ -428,18 +441,21 @@ public class CopyTest extends RefactoringTest {
verifyEnabled(resources, javaElements, null, createReorgQueries());
}
+ @Test
public void testEnabled_package() throws Exception {
IJavaElement[] javaElements= { getPackageP()};
IResource[] resources= {};
verifyEnabled(resources, javaElements, null, createReorgQueries());
}
+ @Test
public void testEnabled_packageRoot() throws Exception {
IJavaElement[] javaElements= { getRoot()};
IResource[] resources= {};
verifyEnabled(resources, javaElements, null, createReorgQueries());
}
+ @Test
public void testEnabled_archivePackageRoot() throws Exception {
IJavaProject project= RefactoringTestSetup.getProject();
IProject projectFolder= project.getProject();
@@ -452,6 +468,7 @@ public class CopyTest extends RefactoringTest {
verifyEnabled(resources, javaElements, null, createReorgQueries());
}
+ @Test
public void testEnabled_file() throws Exception {
IFolder folder= (IFolder)getPackageP().getResource();
IFile file= folder.getFile("a.txt");
@@ -461,7 +478,8 @@ public class CopyTest extends RefactoringTest {
verifyEnabled(resources, javaElements, null, createReorgQueries());
}
- public void testEnabled_folder() throws Exception{
+ @Test
+ public void testEnabled_folder() throws Exception {
IFolder folder= (IFolder)getPackageP().getResource();
IJavaElement[] javaElements= {};
@@ -469,6 +487,7 @@ public class CopyTest extends RefactoringTest {
verifyEnabled(resources, javaElements, null, createReorgQueries());
}
+ @Test
public void testEnabled_fileFolder() throws Exception {
IFolder superFolder= (IFolder)getPackageP().getResource();
IFile file= superFolder.getFile("a.txt");
@@ -480,6 +499,7 @@ public class CopyTest extends RefactoringTest {
verifyEnabled(resources, javaElements, null, createReorgQueries());
}
+ @Test
public void testEnabled_fileFolderCu() throws Exception {
IFolder superFolder= (IFolder)getPackageP().getResource();
IFile file= superFolder.getFile("a.txt");
@@ -492,14 +512,16 @@ public class CopyTest extends RefactoringTest {
verifyEnabled(resources, javaElements, null, createReorgQueries());
}
- public void testDestination_package_no_1() throws Exception{
+ @Test
+ public void testDestination_package_no_1() throws Exception {
IJavaElement[] javaElements= { getPackageP()};
IResource[] resources= {};
JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries());
verifyInvalidDestination(ref, RefactoringTestSetup.getProject());
}
- public void testDestination_package_no_2() throws Exception{
+ @Test
+ public void testDestination_package_no_2() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= { getPackageP()};
@@ -510,7 +532,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_package_no_3() throws Exception{
+ @Test
+ public void testDestination_package_no_3() throws Exception {
IFolder superFolder= (IFolder)getPackageP().getResource();
IFile file= superFolder.getFile("a.txt");
file.create(getStream("123"), true, null);
@@ -523,7 +546,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_package_no_4() throws Exception{
+ @Test
+ public void testDestination_package_no_4() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
folder.create(true, true, null);
@@ -536,11 +560,12 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_cu_no_1() throws Exception{
+ @Test
+ public void testDestination_cu_no_1() throws Exception {
ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IProject closedProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject");
closedProject.create(null);
- assertTrue(! closedProject.isOpen());
+ assertFalse(closedProject.isOpen());
try {
IJavaElement[] javaElements= { cu1};
IResource[] resources= {};
@@ -553,7 +578,8 @@ public class CopyTest extends RefactoringTest {
}
}
- public void testDestination_folder_no_0() throws Exception{
+ @Test
+ public void testDestination_folder_no_0() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
folder.create(true, true, null);
@@ -565,7 +591,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_folder_no_1() throws Exception{
+ @Test
+ public void testDestination_folder_no_1() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
folder.create(true, true, null);
@@ -580,7 +607,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_folder_no_2() throws Exception{
+ @Test
+ public void testDestination_folder_no_2() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
folder.create(true, true, null);
@@ -595,14 +623,15 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_folder_no_3() throws Exception{
+ @Test
+ public void testDestination_folder_no_3() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
folder.create(true, true, null);
IProject simpleProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject");
simpleProject.create(null);
- assertTrue(! simpleProject.isOpen());
+ assertFalse(simpleProject.isOpen());
try {
IJavaElement[] javaElements= {};
IResource[] resources= {folder};
@@ -616,7 +645,8 @@ public class CopyTest extends RefactoringTest {
}
- public void testDestination_root_no_0() throws Exception{
+ @Test
+ public void testDestination_root_no_0() throws Exception {
IJavaElement[] javaElements= {getRoot()};
IResource[] resources= {};
JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries());
@@ -625,7 +655,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_root_no_1() throws Exception{
+ @Test
+ public void testDestination_root_no_1() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("B.java", "package p;class B{}", false, new NullProgressMonitor());
IJavaElement[] javaElements= { getRoot()};
@@ -636,7 +667,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_root_no_2() throws Exception{
+ @Test
+ public void testDestination_root_no_2() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("B.java", "package p;class B{}", false, new NullProgressMonitor());
IJavaElement[] javaElements= { getRoot()};
@@ -648,7 +680,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_root_no_3() throws Exception{
+ @Test
+ public void testDestination_root_no_3() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFile file= superFolder.getFile("a.txt");
file.create(getStream("123"), true, null);
@@ -661,7 +694,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_root_no_4() throws Exception{
+ @Test
+ public void testDestination_root_no_4() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
folder.create(true, true, null);
@@ -673,7 +707,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_cu_yes_0() throws Exception{
+ @Test
+ public void testDestination_cu_yes_0() throws Exception {
ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= { cu1};
IResource[] resources= {};
@@ -682,7 +717,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_cu_yes_1() throws Exception{
+ @Test
+ public void testDestination_cu_yes_1() throws Exception {
ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= { cu1};
IResource[] resources= {};
@@ -692,7 +728,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_cu_yes_2() throws Exception{
+ @Test
+ public void testDestination_cu_yes_2() throws Exception {
ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IPackageFragment otherPackage= getRoot().createPackageFragment("otherPackage", true, new NullProgressMonitor());
IJavaElement[] javaElements= { cu1};
@@ -703,7 +740,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_cu_yes_3() throws Exception{
+ @Test
+ public void testDestination_cu_yes_3() throws Exception {
ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= { cu1};
IResource[] resources= {};
@@ -713,7 +751,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_cu_yes_4() throws Exception{
+ @Test
+ public void testDestination_cu_yes_4() throws Exception {
ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= { cu1};
IResource[] resources= {};
@@ -723,7 +762,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_cu_yes_5() throws Exception{
+ @Test
+ public void testDestination_cu_yes_5() throws Exception {
ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IProject simpleProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject");
simpleProject.create(null);
@@ -740,7 +780,8 @@ public class CopyTest extends RefactoringTest {
}
}
- public void testDestination_cu_yes_6() throws Exception{
+ @Test
+ public void testDestination_cu_yes_6() throws Exception {
ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFile file= superFolder.getFile("a.txt");
@@ -753,7 +794,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_cu_yes_7() throws Exception{
+ @Test
+ public void testDestination_cu_yes_7() throws Exception {
ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
@@ -766,7 +808,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_cu_yes_8() throws Exception{
+ @Test
+ public void testDestination_cu_yes_8() throws Exception {
ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
ICompilationUnit cu2= getPackageP().createCompilationUnit("B.java", "package p;class B{}", false, new NullProgressMonitor());
IJavaElement[] javaElements= { cu1};
@@ -778,7 +821,8 @@ public class CopyTest extends RefactoringTest {
}
- public void testDestination_file_yes_0() throws Exception{
+ @Test
+ public void testDestination_file_yes_0() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFile file= superFolder.getFile("a.txt");
file.create(getStream("123"), true, null);
@@ -790,7 +834,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_file_yes_1() throws Exception{
+ @Test
+ public void testDestination_file_yes_1() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFile file= superFolder.getFile("a.txt");
file.create(getStream("123"), true, null);
@@ -806,7 +851,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_file_yes_3() throws Exception{
+ @Test
+ public void testDestination_file_yes_3() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFile file= superFolder.getFile("a.txt");
file.create(getStream("123"), true, null);
@@ -822,7 +868,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_file_yes_4() throws Exception{
+ @Test
+ public void testDestination_file_yes_4() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFile file= superFolder.getFile("a.txt");
file.create(getStream("123"), true, null);
@@ -836,7 +883,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_file_yes_5() throws Exception{
+ @Test
+ public void testDestination_file_yes_5() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFile file= superFolder.getFile("a.txt");
file.create(getStream("123"), true, null);
@@ -849,7 +897,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_file_yes_6() throws Exception{
+ @Test
+ public void testDestination_file_yes_6() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFile file= superFolder.getFile("a.txt");
file.create(getStream("123"), true, null);
@@ -862,7 +911,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_file_yes_7() throws Exception{
+ @Test
+ public void testDestination_file_yes_7() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFile file= superFolder.getFile("a.txt");
file.create(getStream("123"), true, null);
@@ -875,7 +925,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_file_yes_8() throws Exception{
+ @Test
+ public void testDestination_file_yes_8() throws Exception {
IFolder parentFolder= (IFolder) getPackageP().getResource();
IFile file= parentFolder.getFile("a.txt");
file.create(getStream("123"), true, null);
@@ -888,7 +939,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_file_yes_9() throws Exception{
+ @Test
+ public void testDestination_file_yes_9() throws Exception {
IFolder superFolder= (IFolder)getPackageP().getResource();
IFile file= superFolder.getFile("a.txt");
file.create(getStream("123"), true, null);
@@ -902,7 +954,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_folder_yes_0() throws Exception{
+ @Test
+ public void testDestination_folder_yes_0() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
folder.create(true, true, null);
@@ -918,7 +971,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_folder_yes_1() throws Exception{
+ @Test
+ public void testDestination_folder_yes_1() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
folder.create(true, true, null);
@@ -931,7 +985,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_folder_yes_2() throws Exception{
+ @Test
+ public void testDestination_folder_yes_2() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
folder.create(true, true, null);
@@ -944,7 +999,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_folder_yes_3() throws Exception{
+ @Test
+ public void testDestination_folder_yes_3() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
folder.create(true, true, null);
@@ -957,7 +1013,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_folder_yes_4() throws Exception{
+ @Test
+ public void testDestination_folder_yes_4() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
folder.create(true, true, null);
@@ -975,7 +1032,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_folder_yes_5() throws Exception{
+ @Test
+ public void testDestination_folder_yes_5() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
folder.create(true, true, null);
@@ -989,7 +1047,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_folder_yes_6() throws Exception{
+ @Test
+ public void testDestination_folder_yes_6() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
folder.create(true, true, null);
@@ -1009,7 +1068,8 @@ public class CopyTest extends RefactoringTest {
}
}
- public void testDestination_package_yes_0() throws Exception{
+ @Test
+ public void testDestination_package_yes_0() throws Exception {
IJavaElement[] javaElements= {getPackageP()};
IResource[] resources= {};
JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries());
@@ -1018,14 +1078,16 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_package_yes_1() throws Exception{
+ @Test
+ public void testDestination_package_yes_1() throws Exception {
IJavaElement[] javaElements= { getPackageP()};
IResource[] resources= {};
JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries());
verifyValidDestination(ref, getPackageP());
}
- public void testDestination_package_yes_2() throws Exception{
+ @Test
+ public void testDestination_package_yes_2() throws Exception {
IPackageFragment otherPackage= getRoot().createPackageFragment("other.pack", true, new NullProgressMonitor());
IJavaElement[] javaElements= { getPackageP()};
IResource[] resources= {};
@@ -1035,7 +1097,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_root_yes_0() throws Exception{
+ @Test
+ public void testDestination_root_yes_0() throws Exception {
IJavaElement[] javaElements= {getRoot()};
IResource[] resources= {};
JavaCopyProcessor ref= verifyEnabled(resources, javaElements, null, createReorgQueries());
@@ -1044,7 +1107,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_root_yes_1() throws Exception{
+ @Test
+ public void testDestination_root_yes_1() throws Exception {
IJavaProject otherJavaProject= JavaProjectHelper.createJavaProject("other", "bin");
IJavaElement[] javaElements= { getRoot()};
@@ -1055,7 +1119,8 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
- public void testDestination_method_no_package() throws Exception{
+ @Test
+ public void testDestination_method_no_package() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor());
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IJavaElement[] javaElements= { method };
@@ -1066,7 +1131,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_method_no_file() throws Exception{
+ @Test
+ public void testDestination_method_no_file() throws Exception {
IFolder parentFolder= (IFolder) getPackageP().getResource();
String fileName= "a.txt";
IFile file= parentFolder.getFile(fileName);
@@ -1082,7 +1148,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_method_no_folder() throws Exception{
+ @Test
+ public void testDestination_method_no_folder() throws Exception {
IProject parentFolder= RefactoringTestSetup.getProject().getProject();
String folderName= "folder";
IFolder folder= parentFolder.getFolder(folderName);
@@ -1098,7 +1165,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_method_no_root() throws Exception{
+ @Test
+ public void testDestination_method_no_root() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor());
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IJavaElement[] javaElements= { method };
@@ -1109,7 +1177,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_method_no_java_project() throws Exception{
+ @Test
+ public void testDestination_method_no_java_project() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor());
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IJavaElement[] javaElements= { method };
@@ -1120,7 +1189,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_method_no_simple_project() throws Exception{
+ @Test
+ public void testDestination_method_no_simple_project() throws Exception {
IProject simpleProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject");
simpleProject.create(null);
simpleProject.open(null);
@@ -1138,7 +1208,8 @@ public class CopyTest extends RefactoringTest {
}
}
- public void testDestination_method_no_import_container() throws Exception{
+ @Test
+ public void testDestination_method_no_import_container() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}}", false, new NullProgressMonitor());
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IJavaElement[] javaElements= { method };
@@ -1150,7 +1221,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_method_no_import_declaration() throws Exception{
+ @Test
+ public void testDestination_method_no_import_declaration() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}}", false, new NullProgressMonitor());
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IJavaElement[] javaElements= { method };
@@ -1162,7 +1234,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_method_no_package_declaration() throws Exception{
+ @Test
+ public void testDestination_method_no_package_declaration() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}}", false, new NullProgressMonitor());
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IJavaElement[] javaElements= { method };
@@ -1173,7 +1246,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void test_method_yes_itself() throws Exception{
+ @Test
+ public void test_method_yes_itself() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IJavaElement[] javaElements= { method };
@@ -1182,7 +1256,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements);
}
- public void test_method_yes_cu_with_main_type() throws Exception{
+ @Test
+ public void test_method_yes_cu_with_main_type() throws Exception {
ICompilationUnit otherCu= createCUfromTestFile(getPackageP(), "C");
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
@@ -1192,7 +1267,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu, otherCu}, destination, javaElements);
}
- public void test_method_yes_other_method() throws Exception{
+ @Test
+ public void test_method_yes_other_method() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IMethod otherMethod= cu.getType("A").getMethod("bar", new String[0]);
@@ -1202,7 +1278,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements);
}
- public void test_method_yes_other_method_back() throws Exception{
+ @Test
+ public void test_method_yes_other_method_back() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IMethod otherMethod= cu.getType("A").getMethod("bar", new String[0]);
@@ -1212,7 +1289,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements);
}
- public void test_method_yes_field() throws Exception{
+ @Test
+ public void test_method_yes_field() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IField field= cu.getType("A").getField("bar");
@@ -1221,7 +1299,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements);
}
- public void test_method_yes_field_back() throws Exception{
+ @Test
+ public void test_method_yes_field_back() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IField field= cu.getType("A").getField("bar");
@@ -1230,7 +1309,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements);
}
- public void test_method_yes_type() throws Exception{
+ @Test
+ public void test_method_yes_type() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IJavaElement[] javaElements= { method };
@@ -1239,7 +1319,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements);
}
- public void test_method_yes_initializer() throws Exception{
+ @Test
+ public void test_method_yes_initializer() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IJavaElement[] javaElements= { method };
@@ -1248,7 +1329,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements);
}
- public void test_method_yes_initializer_back() throws Exception{
+ @Test
+ public void test_method_yes_initializer_back() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IJavaElement[] javaElements= { method };
@@ -1257,7 +1339,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements);
}
- public void test_field_yes_field() throws Exception{
+ @Test
+ public void test_field_yes_field() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IField field= cu.getType("A").getField("bar");
IField otherField= cu.getType("A").getField("baz");
@@ -1266,7 +1349,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements);
}
- public void test_field_yes_field_back() throws Exception{
+ @Test
+ public void test_field_yes_field_back() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IField field= cu.getType("A").getField("bar");
IField otherField= cu.getType("A").getField("baz");
@@ -1275,7 +1359,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements);
}
- public void test_inner_type_yes_cu() throws Exception{
+ @Test
+ public void test_inner_type_yes_cu() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IType type= cu.getType("A").getType("Inner");
IJavaElement[] javaElements= { type };
@@ -1286,7 +1371,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{otherCu, cu}, destination, javaElements);
}
- public void test_type_yes_package() throws Exception{
+ @Test
+ public void test_type_yes_package() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{}", true, new NullProgressMonitor());
ParticipantTesting.reset();
IType type= cu.getType("A");
@@ -1300,7 +1386,7 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
assertTrue("source cu does not exist before copying", cu.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source cu does not exist after copying", cu.exists());
ICompilationUnit newCu= getPackageP().getCompilationUnit(MockNewNameQueries.NEW_CU_NAME + ".java");
assertTrue("new cu does not exist after copying", newCu.exists());
@@ -1315,7 +1401,8 @@ public class CopyTest extends RefactoringTest {
});
}
- public void test_type_canel_package() throws Exception{
+ @Test
+ public void test_type_canel_package() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{}", true, new NullProgressMonitor());
ParticipantTesting.reset();
IType type= cu.getType("A");
@@ -1340,7 +1427,8 @@ public class CopyTest extends RefactoringTest {
});
}
- public void test_type_yes_other_package() throws Exception{
+ @Test
+ public void test_type_yes_other_package() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{}", true, new NullProgressMonitor());
IPackageFragment otherPackage= getRoot().createPackageFragment("other", true, new NullProgressMonitor());
ParticipantTesting.reset();
@@ -1357,7 +1445,7 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
assertTrue("source cu does not exist before copying", cu.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source cu does not exist after copying", cu.exists());
ICompilationUnit newCu= otherPackage.getCompilationUnit(cu.getElementName());
assertTrue("new cu does not exist after copying", newCu.exists());
@@ -1371,7 +1459,8 @@ public class CopyTest extends RefactoringTest {
}
- public void testDestination_initializer_no_package() throws Exception{
+ @Test
+ public void testDestination_initializer_no_package() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}{}}", false, new NullProgressMonitor());
IInitializer initializer= cu.getType("A").getInitializer(1);
IJavaElement[] javaElements= { initializer };
@@ -1382,7 +1471,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void test_initializer_yes_type() throws Exception{
+ @Test
+ public void test_initializer_yes_type() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IInitializer initializer= cu.getType("A").getInitializer(1);
IJavaElement[] javaElements= { initializer };
@@ -1390,7 +1480,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, javaElements);
}
- public void test_initializer_yes_method() throws Exception{
+ @Test
+ public void test_initializer_yes_method() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IInitializer initializer= cu.getType("A").getInitializer(1);
IJavaElement[] javaElements= { initializer };
@@ -1399,7 +1490,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_AFTER, javaElements);
}
- public void test_initializer_yes_method_back() throws Exception{
+ @Test
+ public void test_initializer_yes_method_back() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IInitializer initializer= cu.getType("A").getInitializer(1);
IJavaElement[] javaElements= { initializer };
@@ -1408,7 +1500,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu}, destination, IReorgDestination.LOCATION_BEFORE, javaElements);
}
- public void testDestination_import_container_no_package() throws Exception{
+ @Test
+ public void testDestination_import_container_no_package() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "import java.util.*;package p;class A{void foo(){}{}}", false, new NullProgressMonitor());
IImportContainer container= cu.getImportContainer();
IJavaElement[] javaElements= { container };
@@ -1419,7 +1512,8 @@ public class CopyTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void test_import_container_yes_type_in_different_cu() throws Exception{
+ @Test
+ public void test_import_container_yes_type_in_different_cu() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit otherCu= createCUfromTestFile(getPackageP(), "C");
@@ -1429,7 +1523,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu, otherCu}, destination, javaElements);
}
- public void test_import_container_yes_method_in_different_cu() throws Exception{
+ @Test
+ public void test_import_container_yes_method_in_different_cu() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit otherCu= createCUfromTestFile(getPackageP(), "C");
@@ -1439,7 +1534,8 @@ public class CopyTest extends RefactoringTest {
verifyCopyingOfSubCuElements(new ICompilationUnit[]{cu, otherCu}, destination, javaElements);
}
- public void test_import_container_yes_cu() throws Exception{
+ @Test
+ public void test_import_container_yes_cu() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit otherCu= createCUfromTestFile(getPackageP(), "C");
@@ -1450,6 +1546,7 @@ public class CopyTest extends RefactoringTest {
}
+ @Test
public void testCopy_File_to_Folder() throws Exception {
ParticipantTesting.reset();
IFolder parentFolder= (IFolder) getPackageP().getResource();
@@ -1475,7 +1572,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", file.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", file.exists());
@@ -1488,6 +1585,7 @@ public class CopyTest extends RefactoringTest {
});
}
+ @Test
public void testCopy_File_to_Same_Folder() throws Exception {
ParticipantTesting.reset();
IFolder parentFolder= (IFolder) getPackageP().getResource();
@@ -1510,7 +1608,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", file.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", file.exists());
@@ -1525,6 +1623,7 @@ public class CopyTest extends RefactoringTest {
assertEquals("a2.txt", ((MockNewNameQueries)queries).getResourceInitialSuggestedName());
}
+ @Test
public void testCopy_File_to_Same_Folder_Cancel() throws Exception {
ParticipantTesting.reset();
IFolder parentFolder= (IFolder) getPackageP().getResource();
@@ -1557,6 +1656,7 @@ public class CopyTest extends RefactoringTest {
});
}
+ @Test
public void testCopy_File_to_Itself() throws Exception {
IFolder parentFolder= (IFolder) getPackageP().getResource();
String fileName= "a.txt";
@@ -1575,7 +1675,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", file.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", file.exists());
@@ -1583,22 +1683,27 @@ public class CopyTest extends RefactoringTest {
assertTrue("new file does not exist after copying", newFile.exists());
}
+ @Test
public void testCopy_File_to_Itself_2() throws Exception {
copy_File_to_Itself_impl("A.java", "A2.java", "A3.java");
}
+ @Test
public void testCopy_File_to_Itself_3() throws Exception {
copy_File_to_Itself_impl("A.B8.java", "A.B9.java", "A.B10.java");
}
+ @Test
public void testCopy_File_to_Itself_4() throws Exception {
copy_File_to_Itself_impl("fileNameWithoutAnyDot", "fileNameWithoutAnyDot2", "fileNameWithoutAnyDot3");
}
+ @Test
public void testCopy_File_to_Itself_5() throws Exception {
copy_File_to_Itself_impl(".fileNameStartingWithDot", ".fileNameStartingWithDot2", ".fileNameStartingWithDot3");
}
+ @Test
public void testCopy_File_to_Itself_6() throws Exception {
copy_File_to_Itself_impl("..fileNameStartingWithTwoDots", ".2.fileNameStartingWithTwoDots", ".3.fileNameStartingWithTwoDots");
}
@@ -1622,7 +1727,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", file.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", file.exists());
@@ -1631,6 +1736,7 @@ public class CopyTest extends RefactoringTest {
assertEquals(initialSuggestedName, ((MockNewNameQueries)queries).getResourceInitialSuggestedName());
}
+ @Test
public void testCopy_File_to_AnotherFile() throws Exception {
IFolder parentFolder= (IFolder) getPackageP().getResource();
String fileName= "a.txt";
@@ -1652,7 +1758,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", file.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", file.exists());
@@ -1660,6 +1766,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("new file does not exist after copying", newFile.exists());
}
+ @Test
public void testCopy_File_to_Package() throws Exception {
IFolder parentFolder= (IFolder) getPackageP().getResource();
String fileName= "a.txt";
@@ -1679,7 +1786,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", file.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", file.exists());
@@ -1687,6 +1794,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("new file does not exist after copying", newFile.exists());
}
+ @Test
public void testCopy_File_to_DefaultPackage() throws Exception {
IFolder parentFolder= (IFolder) getPackageP().getResource();
String fileName= "a.txt";
@@ -1708,7 +1816,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", file.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", file.exists());
@@ -1716,6 +1824,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("new file does not exist after copying", newFile.exists());
}
+ @Test
public void testCopy_File_to_SourceFolder() throws Exception {
IFolder parentFolder= (IFolder) getPackageP().getResource();
String fileName= "a.txt";
@@ -1734,7 +1843,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", file.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", file.exists());
@@ -1742,6 +1851,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("new file does not exist after copying", newFile.exists());
}
+ @Test
public void testCopy_File_to_JavaProject() throws Exception {
IFolder parentFolder= (IFolder) getPackageP().getResource();
String fileName= "a.txt";
@@ -1760,7 +1870,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", file.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", file.exists());
@@ -1768,6 +1878,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("new file does not exist after copying", newFile.exists());
}
+ @Test
public void testCopy_File_to_Cu() throws Exception {
IFolder parentFolder= (IFolder) getPackageP().getResource();
String fileName= "a.txt";
@@ -1787,7 +1898,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", file.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", file.exists());
@@ -1795,6 +1906,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("new file does not exist after copying", newFile.exists());
}
+ @Test
public void testCopy_File_to_SimpleProject() throws Exception {
IFolder parentFolder= (IFolder) getPackageP().getResource();
String fileName= "a.txt";
@@ -1817,7 +1929,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", file.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", file.exists());
@@ -1828,6 +1940,7 @@ public class CopyTest extends RefactoringTest {
}
}
+ @Test
public void testCopy_Cu_to_Folder() throws Exception {
String fileName= "A.java";
ICompilationUnit cu= getPackageP().createCompilationUnit(fileName, "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
@@ -1848,7 +1961,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source cu does not exist before copying", cu.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source cu does not exist after copying", cu.exists());
@@ -1856,6 +1969,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("new cu does not exist after copying", newFile.exists());
}
+ @Test
public void testCopy_Bug67124() throws Exception {
String fileName= "A.java";
ICompilationUnit cu= getPackageP().createCompilationUnit(fileName, "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
@@ -1881,7 +1995,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source cu does not exist before copying", cu.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source cu does not exist after copying", cu.exists());
@@ -1898,6 +2012,7 @@ public class CopyTest extends RefactoringTest {
}
}
+ @Test
public void testCopy_Cu_to_Same_Package() throws Exception {
ParticipantTesting.reset();
String fileName= "A.java";
@@ -1917,7 +2032,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source cu does not exist before copying", cu.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source cu does not exist after copying", cu.exists());
@@ -1934,6 +2049,7 @@ public class CopyTest extends RefactoringTest {
});
}
+ @Test
public void testCopy_Cu_to_Same_Package_Cancel() throws Exception {
ParticipantTesting.reset();
String fileName= "A.java";
@@ -1963,7 +2079,8 @@ public class CopyTest extends RefactoringTest {
});
}
- public void test_type_yes_type() throws Exception{
+ @Test
+ public void test_type_yes_type() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit otherCu= createCUfromTestFile(getPackageP(), "C");
@@ -1979,7 +2096,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source cu does not exist before copying", cu.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source cu does not exist after copying", cu.exists());
@@ -1987,6 +2104,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("new cu does not exist after copying", newCu.exists());
}
+ @Test
public void testCopy_Cu_to_Itself() throws Exception {
String fileName= "A.java";
ICompilationUnit cu= getPackageP().createCompilationUnit(fileName, "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
@@ -2003,7 +2121,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", cu.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", cu.exists());
@@ -2012,6 +2130,7 @@ public class CopyTest extends RefactoringTest {
assertEquals("A2", ((MockNewNameQueries)queries).getCuInitialSuggestedName());
}
+ @Test
public void testCopy_Cu_to_OtherPackage() throws Exception {
ParticipantTesting.reset();
String fileName= "A.java";
@@ -2032,7 +2151,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", cu.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", cu.exists());
@@ -2046,6 +2165,7 @@ public class CopyTest extends RefactoringTest {
});
}
+ @Test
public void testCopy_Cu_to_DefaultPackage() throws Exception {
ParticipantTesting.reset();
String fileName= "A.java";
@@ -2068,7 +2188,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", cu.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", cu.exists());
@@ -2082,6 +2202,7 @@ public class CopyTest extends RefactoringTest {
});
}
+ @Test
public void testCopy_Cu_to_SourceFolder() throws Exception {
String fileName= "A.java";
ICompilationUnit cu= getPackageP().createCompilationUnit(fileName, "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
@@ -2098,7 +2219,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", cu.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", cu.exists());
@@ -2106,6 +2227,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("new file does not exist after copying", newCu.exists());
}
+ @Test
public void testCopy_Cu_to_JavaProject() throws Exception {
String fileName= "A.java";
ICompilationUnit cu= getPackageP().createCompilationUnit(fileName, "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
@@ -2122,7 +2244,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", cu.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", cu.exists());
@@ -2130,6 +2252,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("new file does not exist after copying", newFile.exists());
}
+ @Test
public void testCopy_Cu_to_File_In_Package() throws Exception {
String fileName= "A.java";
ICompilationUnit cu= getPackageP().createCompilationUnit(fileName, "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
@@ -2151,7 +2274,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", cu.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", cu.exists());
@@ -2162,6 +2285,7 @@ public class CopyTest extends RefactoringTest {
assertEqualLines("source compare failed", expectedSource, newCu.getSource());
}
+ @Test
public void testCopy_Cu_to_File_In_Resource_Folder() throws Exception {
String fileName= "A.java";
ICompilationUnit cu= getPackageP().createCompilationUnit(fileName, "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
@@ -2182,7 +2306,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", cu.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", cu.exists());
@@ -2190,6 +2314,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("new file does not exist after copying", newFile.exists());
}
+ @Test
public void testCopy_Cu_to_SimpleProject() throws Exception {
String fileName= "A.java";
ICompilationUnit cu= getPackageP().createCompilationUnit(fileName, "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
@@ -2211,7 +2336,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source file does not exist before copying", cu.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source file does not exist after copying", cu.exists());
@@ -2222,6 +2347,7 @@ public class CopyTest extends RefactoringTest {
}
}
+ @Test
public void testCopy_Package_to_Its_Root() throws Exception {
ParticipantTesting.reset();
INewNameQueries queries= new MockNewNameQueries();
@@ -2238,7 +2364,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source package does not exist before copying", getPackageP().exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source package does not exist after copying", getPackageP().exists());
@@ -2255,6 +2381,7 @@ public class CopyTest extends RefactoringTest {
});
}
+ @Test
public void testCopy_Package_to_Its_Root_Cancel() throws Exception {
ParticipantTesting.reset();
INewNameQueries queries= new MockCancelNameQueries();
@@ -2282,6 +2409,7 @@ public class CopyTest extends RefactoringTest {
});
}
+ @Test
public void testCopy_Package_to_Itself() throws Exception {
ParticipantTesting.reset();
INewNameQueries queries= new MockNewNameQueries();
@@ -2298,7 +2426,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source package does not exist before copying", getPackageP().exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source package does not exist after copying", getPackageP().exists());
@@ -2315,6 +2443,7 @@ public class CopyTest extends RefactoringTest {
});
}
+ @Test
public void testCopy_Package_to_Another_Root() throws Exception {
IPackageFragmentRoot otherRoot= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "otherRoot");
String packageName= getPackageP().getElementName();
@@ -2330,7 +2459,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source package does not exist before copying", getPackageP().exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source package does not exist after copying", getPackageP().exists());
@@ -2338,6 +2467,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("new package does not exist after copying", newPackage.exists());
}
+ @Test
public void testCopy_Package_to_JavaProject_That_Is_Root() throws Exception {
IJavaProject otherProject= JavaProjectHelper.createJavaProject("otherProject", null);
JavaProjectHelper.addSourceContainer(otherProject, null);
@@ -2354,7 +2484,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source package does not exist before copying", getPackageP().exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source package does not exist after copying", getPackageP().exists());
@@ -2371,6 +2501,7 @@ public class CopyTest extends RefactoringTest {
}
}
+ @Test
public void testCopy_folder_to_other_folder() throws Exception {
ParticipantTesting.reset();
IProject superFolder= RefactoringTestSetup.getProject().getProject();
@@ -2392,7 +2523,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source does not exist before copying", folder.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source does not exist after copying", folder.exists());
assertTrue("copied folder does not exist after copying", otherFolder.getFolder(folderName).exists());
@@ -2404,6 +2535,7 @@ public class CopyTest extends RefactoringTest {
}
+ @Test
public void testCopy_folder_to_same_container() throws Exception {
ParticipantTesting.reset();
IProject superFolder= RefactoringTestSetup.getProject().getProject();
@@ -2423,7 +2555,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source does not exist before copying", folder.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source does not exist after copying", folder.exists());
IFolder newFolder= superFolder.getFolder(MockNewNameQueries.NEW_FOLDER_NAME);
@@ -2439,10 +2571,12 @@ public class CopyTest extends RefactoringTest {
}
+ @Test
public void testCopy_folder_to_same_container_2() throws Exception {
copy_folder_to_same_container_impl("folder.name.with.segments");
}
+ @Test
public void testCopy_folder_to_same_container_3() throws Exception {
copy_folder_to_same_container_impl(".folderNameStartingWithDot");
}
@@ -2468,7 +2602,7 @@ public class CopyTest extends RefactoringTest {
assertTrue("source does not exist before copying", folder.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source does not exist after copying", folder.exists());
IFolder newFolder= superFolder.getFolder(MockNewNameQueries.NEW_FOLDER_NAME);
@@ -2483,6 +2617,7 @@ public class CopyTest extends RefactoringTest {
}
+ @Test
public void testCopy_folder_to_same_container_cancel() throws Exception {
ParticipantTesting.reset();
IProject superFolder= RefactoringTestSetup.getProject().getProject();
@@ -2512,6 +2647,7 @@ public class CopyTest extends RefactoringTest {
}
+ @Test
public void testCopy_folder_Java_project() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
String folderName= "folder";
@@ -2527,13 +2663,14 @@ public class CopyTest extends RefactoringTest {
assertTrue("source does not exist before copying", folder.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source does not exist after copying", folder.exists());
assertTrue("copied folder does not exist after copying", RefactoringTestSetup.getProject().getProject().getFolder(folderName).exists());
}
+ @Test
public void testCopy_folder_to_source_folder() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
String folderName= "folder";
@@ -2549,13 +2686,14 @@ public class CopyTest extends RefactoringTest {
assertTrue("source does not exist before copying", folder.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source does not exist after copying", folder.exists());
assertTrue("copied folder does not exist after copying", ((IFolder)getRoot().getResource()).getFolder(folderName).exists());
}
+ @Test
public void testCopy_folder_to_package() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
String folderName= "folder";
@@ -2570,12 +2708,13 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
assertTrue("source does not exist before copying", folder.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source does not exist after copying", folder.exists());
assertTrue("copied folder does not exist after copying", ((IFolder)destination.getResource()).getFolder(folderName).exists());
}
+ @Test
public void testCopy_folder_to_cu() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
String folderName= "folder";
@@ -2591,12 +2730,13 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
assertTrue("source does not exist before copying", folder.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source does not exist after copying", folder.exists());
assertTrue("copied folder does not exist after copying", ((IFolder)getPackageP().getResource()).getFolder(folderName).exists());
}
+ @Test
public void testCopy_folder_to_simple_project() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
String folderName= "folder";
@@ -2615,7 +2755,7 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
assertTrue("source does not exist before copying", folder.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source does not exist after copying", folder.exists());
assertTrue("copied folder does not exist after copying", simpleProject.getFolder(folderName).exists());
@@ -2624,6 +2764,7 @@ public class CopyTest extends RefactoringTest {
}
}
+ @Test
public void testCopy_root_to_same_Java_project() throws Exception {
ParticipantTesting.reset();
// Delete the unnamed folder so that the delta is a ADD not a CHANGED
@@ -2642,7 +2783,7 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
assertTrue("source does not exist before copying", getRoot().exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source does not exist after copying", getRoot().exists());
String newName= MockNewNameQueries.NEW_PACKAGE_FRAGMENT_ROOT_NAME;
@@ -2659,6 +2800,7 @@ public class CopyTest extends RefactoringTest {
});
}
+ @Test
public void testCopy_root_to_same_Java_project_cancel() throws Exception {
ParticipantTesting.reset();
IJavaElement[] javaElements= { getRoot()};
@@ -2681,6 +2823,7 @@ public class CopyTest extends RefactoringTest {
});
}
+ @Test
public void testCopy_root_to_other_Java_project() throws Exception {
ParticipantTesting.reset();
IJavaProject otherJavaProject= JavaProjectHelper.createJavaProject("other", "bin");
@@ -2695,7 +2838,7 @@ public class CopyTest extends RefactoringTest {
verifyValidDestination(ref, destination);
assertTrue("source does not exist before copying", getRoot().exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
+ assertNull(status);
assertTrue("source does not exist after copying", getRoot().exists());
String newName= getRoot().getElementName();
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyToClipboardActionTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyToClipboardActionTest.java
index 01cd914f45..96a8334c0b 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyToClipboardActionTest.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/CopyToClipboardActionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,10 +13,18 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.ccp;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.TextTransfer;
@@ -38,30 +46,26 @@ import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.internal.core.manipulation.util.Strings;
import org.eclipse.jdt.internal.corext.refactoring.TypedSource;
import org.eclipse.jdt.internal.corext.refactoring.reorg.JavaElementTransfer;
import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgUtils;
-import org.eclipse.jdt.internal.core.manipulation.util.Strings;
import org.eclipse.jdt.ui.JavaElementLabelProvider;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup;
+import org.eclipse.jdt.ui.tests.refactoring.GenericRefactoringTest;
import org.eclipse.jdt.ui.tests.refactoring.infra.MockClipboard;
import org.eclipse.jdt.ui.tests.refactoring.infra.MockWorkbenchSite;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
import org.eclipse.jdt.internal.ui.refactoring.reorg.CopyToClipboardAction;
import org.eclipse.jdt.internal.ui.refactoring.reorg.TypedSourceTransfer;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-
-public class CopyToClipboardActionTest extends RefactoringTest{
+public class CopyToClipboardActionTest extends GenericRefactoringTest {
+ private static final String CU_A_NAME= "A";
+ private static final String CU_B_NAME= "B";
private ILabelProvider fLabelProvider;
- private static final Class<CopyToClipboardActionTest> clazz= CopyToClipboardActionTest.class;
-
private Clipboard fClipboard;
private ICompilationUnit fCuA;
@@ -69,22 +73,15 @@ public class CopyToClipboardActionTest extends RefactoringTest{
private IPackageFragment fPackageQ;
private IPackageFragment fPackageQ_R;
private IPackageFragment fDefaultPackage;
- private static final String CU_A_NAME= "A";
- private static final String CU_B_NAME= "B";
private IFile faTxt;
private IFolder fOlder;
- public CopyToClipboardActionTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
+ @Rule
+ public RefactoringTestSetup fts= new RefactoringTestSetup();
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void genericbefore() throws Exception {
+ super.genericbefore();
fClipboard= new MockClipboard(Display.getDefault());
fDefaultPackage= RefactoringTestSetup.getDefaultSourceFolder().createPackageFragment("", true, null);
@@ -125,8 +122,8 @@ public class CopyToClipboardActionTest extends RefactoringTest{
}
@Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ public void genericafter() throws Exception {
+ super.genericafter();
performDummySearch();
fClipboard.dispose();
fLabelProvider.dispose();
@@ -148,10 +145,10 @@ public class CopyToClipboardActionTest extends RefactoringTest{
CopyToClipboardAction copyAction= new CopyToClipboardAction(new MockWorkbenchSite(elements), fClipboard);
copyAction.setAutoRepeatOnFailure(true);
copyAction.update(copyAction.getSelection());
- assertTrue("action should be disabled", ! copyAction.isEnabled());
+ assertFalse("action should be disabled", copyAction.isEnabled());
}
- private void checkEnabled(Object[] elements) throws Exception{
+ private void checkEnabled(Object[] elements) throws Exception {
CopyToClipboardAction copyAction= new CopyToClipboardAction(new MockWorkbenchSite(elements), fClipboard);
copyAction.setAutoRepeatOnFailure(true);
copyAction.update(copyAction.getSelection());
@@ -214,7 +211,7 @@ public class CopyToClipboardActionTest extends RefactoringTest{
for (int i= 0; i < retreivedFromClipboard.length; i++) {
Object retreived= retreivedFromClipboard[i];
assertTrue("element does not exist", exists(retreived));
- assertTrue("different copied " + getName(copied[i]) + " retreived: " + getName(retreived) , copied[i].equals(retreivedFromClipboard[i]));
+ assertEquals("different copied " + getName(copied[i]) + " retreived: " + getName(retreived), copied[i], retreivedFromClipboard[i]);
}
}
@@ -223,7 +220,7 @@ public class CopyToClipboardActionTest extends RefactoringTest{
return ((IJavaElement)element).exists();
if (element instanceof IResource)
return ((IResource)element).exists();
- assertTrue(false);
+ fail();
return false;
}
@@ -326,70 +323,86 @@ public class CopyToClipboardActionTest extends RefactoringTest{
///---------tests
+ @Test
public void testDisabled0() {
Object[] elements= {};
checkDisabled(elements);
}
+ @Test
public void testDisabled1() throws Exception {
Object[] elements= {null};
checkDisabled(elements);
}
+ @Test
public void testDisabled2() throws Exception {
Object[] elements= {this};
checkDisabled(elements);
}
+ @Test
public void testDisabled3() throws Exception {
Object[] elements= {RefactoringTestSetup.getProject(), getPackageP()};
checkDisabled(elements);
}
- public void testDisabled4() throws Exception{
+ @Test
+ public void testDisabled4() throws Exception {
checkDisabled(new Object[]{getPackageP(), fCuA});
}
- public void testDisabled5() throws Exception{
+ @Test
+ public void testDisabled5() throws Exception {
checkDisabled(new Object[]{getRoot(), fCuA});
}
- public void testDisabled6() throws Exception{
+ @Test
+ public void testDisabled6() throws Exception {
checkDisabled(new Object[]{getRoot(), fPackageQ});
}
- public void testDisabled7() throws Exception{
+ @Test
+ public void testDisabled7() throws Exception {
checkDisabled(new Object[]{getRoot(), faTxt});
}
- public void testDisabled8() throws Exception{
+ @Test
+ public void testDisabled8() throws Exception {
checkDisabled(new Object[]{getRoot(), getRoot().getJavaProject()});
}
- public void testDisabled9() throws Exception{
+ @Test
+ public void testDisabled9() throws Exception {
checkDisabled(new Object[]{RefactoringTestSetup.getProject().getPackageFragmentRoots()});
}
- public void testDisabled10() throws Exception{
+ @Test
+ public void testDisabled10() throws Exception {
checkDisabled(new Object[]{fCuA, fCuB});
}
- public void testDisabled11() throws Exception{
+ @Test
+ public void testDisabled11() throws Exception {
checkDisabled(new Object[]{fDefaultPackage});
}
- public void testDisabled12() throws Exception{
+ @Test
+ public void testDisabled12() throws Exception {
checkDisabled(new Object[]{getRoot().getJavaProject(), fCuA});
}
- public void testDisabled13() throws Exception{
+ @Test
+ public void testDisabled13() throws Exception {
checkDisabled(new Object[]{getRoot().getJavaProject(), fPackageQ});
}
- public void testDisabled14() throws Exception{
+ @Test
+ public void testDisabled14() throws Exception {
checkDisabled(new Object[]{getRoot().getJavaProject(), faTxt});
}
+ @Test
public void testDisabled15() throws Exception {
Object fieldF= fCuA.getType("A").getField("f");
Object classA= fCuA.getType("A");
@@ -397,42 +410,49 @@ public class CopyToClipboardActionTest extends RefactoringTest{
checkDisabled(elements);
}
+ @Test
public void testDisabled16() throws Exception {
Object fieldF= fCuA.getType("A").getField("f");
Object[] elements= {fieldF, fCuA};
checkDisabled(elements);
}
+ @Test
public void testDisabled17() throws Exception {
Object fieldF= fCuA.getType("A").getField("f");
Object[] elements= {fieldF, fDefaultPackage};
checkDisabled(elements);
}
+ @Test
public void testDisabled18() throws Exception {
Object fieldF= fCuA.getType("A").getField("f");
Object[] elements= {fieldF, fPackageQ};
checkDisabled(elements);
}
+ @Test
public void testDisabled19() throws Exception {
Object fieldF= fCuA.getType("A").getField("f");
Object[] elements= {fieldF, faTxt};
checkDisabled(elements);
}
+ @Test
public void testDisabled20() throws Exception {
Object fieldF= fCuA.getType("A").getField("f");
Object[] elements= {fieldF, getRoot()};
checkDisabled(elements);
}
+ @Test
public void testDisabled21() throws Exception {
Object fieldF= fCuA.getType("A").getField("f");
Object[] elements= {fieldF, RefactoringTestSetup.getProject()};
checkDisabled(elements);
}
+ @Test
public void testDisabled22() throws Exception {
Object typeA= fCuA.getType("A");
Object typeB= fCuB.getType("B");
@@ -440,67 +460,81 @@ public class CopyToClipboardActionTest extends RefactoringTest{
checkDisabled(elements);
}
- public void testDisabled23() throws Exception{
+ @Test
+ public void testDisabled23() throws Exception {
checkDisabled(new Object[]{faTxt, fCuB});
}
+ @Test
public void testEnabled0() throws Exception {
Object[] elements= {RefactoringTestSetup.getProject()};
checkEnabled(elements);
}
+ @Test
public void testEnabled1() throws Exception {
Object[] elements= {getPackageP()};
checkEnabled(elements);
}
+ @Test
public void testEnabled2() throws Exception {
Object[] elements= {getRoot()};
checkEnabled(elements);
}
+ @Test
public void testEnabled3() throws Exception {
Object[] elements= {RefactoringTestSetup.getDefaultSourceFolder()};
checkEnabled(elements);
}
- public void testEnabled4() throws Exception{
+ @Test
+ public void testEnabled4() throws Exception {
checkEnabled(new Object[]{faTxt});
}
- public void testEnabled5() throws Exception{
+ @Test
+ public void testEnabled5() throws Exception {
checkEnabled(new Object[]{getRoot()});
}
- public void testEnabled6() throws Exception{
+ @Test
+ public void testEnabled6() throws Exception {
checkEnabled(new Object[]{fCuA});
}
- public void testEnabled7() throws Exception{
+ @Test
+ public void testEnabled7() throws Exception {
checkEnabled(new Object[]{getRoot().getJavaProject()});
}
- public void testEnabled8() throws Exception{
+ @Test
+ public void testEnabled8() throws Exception {
checkEnabled(new Object[]{getPackageP()});
}
- public void testEnabled9() throws Exception{
+ @Test
+ public void testEnabled9() throws Exception {
checkEnabled(new Object[]{getPackageP(), fPackageQ, fPackageQ_R});
}
- public void testEnabled10() throws Exception{
+ @Test
+ public void testEnabled10() throws Exception {
Object packDecl= fCuA.getPackageDeclarations()[0];
Object[] elements= {packDecl};
checkEnabled(elements);
}
- public void testEnabled11() throws Exception{
+ @Test
+ public void testEnabled11() throws Exception {
Object importD= fCuA.getImports()[0];
Object[] elements= {importD};
checkEnabled(elements);
}
- public void testEnabled12() throws Exception{
+ @Test
+ public void testEnabled12() throws Exception {
// printTestDisabledMessage("disabled due to bug 37750");
// if (true)
// return;
@@ -509,37 +543,43 @@ public class CopyToClipboardActionTest extends RefactoringTest{
checkEnabled(elements);
}
- public void testEnabled13() throws Exception{
+ @Test
+ public void testEnabled13() throws Exception {
Object classA= fCuA.getType("A");
Object[] elements= {classA};
checkEnabled(elements);
}
- public void testEnabled14() throws Exception{
+ @Test
+ public void testEnabled14() throws Exception {
Object methodFoo= fCuA.getType("A").getMethod("foo", new String[0]);
Object[] elements= {methodFoo};
checkEnabled(elements);
}
- public void testEnabled15() throws Exception{
+ @Test
+ public void testEnabled15() throws Exception {
Object fieldF= fCuA.getType("A").getField("f");
Object[] elements= {fieldF};
checkEnabled(elements);
}
- public void testEnabled16() throws Exception{
+ @Test
+ public void testEnabled16() throws Exception {
Object initializer= fCuA.getType("A").getInitializer(1);
Object[] elements= {initializer};
checkEnabled(elements);
}
- public void testEnabled17() throws Exception{
+ @Test
+ public void testEnabled17() throws Exception {
Object innerClass= fCuA.getType("A").getType("Inner");
Object[] elements= {innerClass};
checkEnabled(elements);
}
- public void testEnabled18() throws Exception{
+ @Test
+ public void testEnabled18() throws Exception {
Object fieldF= fCuA.getType("A").getField("f");
Object methodFoo= fCuA.getType("A").getMethod("foo", new String[0]);
Object innerClass= fCuA.getType("A").getType("Inner");
@@ -548,7 +588,8 @@ public class CopyToClipboardActionTest extends RefactoringTest{
checkEnabled(elements);
}
- public void testEnabled19() throws Exception{
+ @Test
+ public void testEnabled19() throws Exception {
// printTestDisabledMessage("disabled due to bug 37750");
// if (true)
// return;
@@ -560,15 +601,18 @@ public class CopyToClipboardActionTest extends RefactoringTest{
checkEnabled(elements);
}
- public void testEnabled20() throws Exception{
+ @Test
+ public void testEnabled20() throws Exception {
checkEnabled(new Object[]{faTxt, fCuA});
}
- public void testEnabled21() throws Exception{
+ @Test
+ public void testEnabled21() throws Exception {
checkEnabled(new Object[]{fOlder});
}
- public void testEnabled22() throws Exception{
+ @Test
+ public void testEnabled22() throws Exception {
// printTestDisabledMessage("bug 39410");
Object classA= fCuA.getType("A");
Object packDecl= fCuA.getPackageDeclarations()[0];
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/DeleteTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/DeleteTest.java
index 6e60881ae5..4e25f3fc3e 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/DeleteTest.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/DeleteTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,12 +13,22 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.ccp;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Enumeration;
import java.util.List;
-import java.util.TreeMap;
+
+import org.junit.Before;
+import org.junit.FixMethodOrder;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.JavaTestPlugin;
@@ -54,53 +64,23 @@ import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgQueries;
import org.eclipse.jdt.internal.corext.refactoring.reorg.JavaDeleteProcessor;
+import org.eclipse.jdt.ui.tests.refactoring.GenericRefactoringTest;
import org.eclipse.jdt.ui.tests.refactoring.ParticipantTesting;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
-public class DeleteTest extends RefactoringTest {
+//Last tests need to delete package p. Make sure they are really last to run:
+// Tests starting with "test_END_DeletePackageSub" should run last
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class DeleteTest extends GenericRefactoringTest {
private static final boolean BUG_55221= true;
- private static final Class<DeleteTest> clazz= DeleteTest.class;
private static final String REFACTORING_PATH= "Delete/";
- public DeleteTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite classSuite= new TestSuite(clazz);
+ @Rule
+ public RefactoringTestSetup fts= new RefactoringTestSetup();
- // Last tests need to delete package p. Make sure they are really last to run:
- TreeMap<String, TestCase> lastTests= new TreeMap<>(); // sorted by name
- TestSuite suite= new TestSuite(classSuite.getName());
- for (Enumeration<Test> e= classSuite.tests(); e.hasMoreElements(); ) {
- TestCase test= (TestCase) e.nextElement();
- String name= test.getName();
- if (name.startsWith("test_END_DeletePackageSub")) {
- lastTests.put(name, test);
- } else {
- suite.addTest(test);
- }
- }
- for (TestCase testCase : lastTests.values()) {
- suite.addTest(testCase);
- }
- return new RefactoringTestSetup(suite);
- }
-
- public static Test setUpTest(Test someTest) {
- return new RefactoringTestSetup(someTest);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
fIsPreDeltaTest= true;
}
@@ -112,7 +92,7 @@ public class DeleteTest extends RefactoringTest {
private void verifyDisabled(Object[] elements) throws CoreException {
JavaDeleteProcessor processor= new JavaDeleteProcessor(elements);
DeleteRefactoring ref= new DeleteRefactoring(processor);
- assertTrue("delete should be disabled", !ref.isApplicable());
+ assertFalse("delete should be disabled", ref.isApplicable());
}
private void verifyEnabled(Object[] elements) throws CoreException {
@@ -142,10 +122,10 @@ public class DeleteTest extends RefactoringTest {
DeleteRefactoring refactoring= createRefactoring(elems);
assertNotNull(refactoring);
RefactoringStatus status= performRefactoring(refactoring, true);
- assertEquals("precondition was supposed to pass", null, status);
+ assertNull("precondition was supposed to pass", status);
ICompilationUnit newCuA= getPackageP().getCompilationUnit(CU_NAME + ".java");
- assertTrue("A.java does not exist", newCuA.exists() == !deleteCu);
+ assertEquals("A.java does not exist", newCuA.exists(), !deleteCu);
if (! deleteCu)
assertEqualLines("incorrect content of A.java", getFileContents(getOutputTestFileName(CU_NAME)), newCuA.getSource());
}
@@ -207,7 +187,7 @@ public class DeleteTest extends RefactoringTest {
DeleteRefactoring ref= createRefactoring(markedForDelete);
((JavaDeleteProcessor)ref.getProcessor()).setDeleteSubPackages(deleteSubs);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals("expected to pass", null, status);
+ assertNull("expected to pass", status);
// assure participants got notified of everything.
ParticipantTesting.testDelete(deleteHandles);
@@ -241,16 +221,16 @@ public class DeleteTest extends RefactoringTest {
if (exists) {
assertTrue("expected to exist: " + resource.getFullPath(), resource.exists());
} else {
- assertTrue("expected NOT to exist: " + resource.getFullPath(), ! resource.exists());
+ assertFalse("expected NOT to exist: " + resource.getFullPath(), resource.exists());
}
} else if (resourceOrElement instanceof IJavaElement) {
IJavaElement javaElement= (IJavaElement) resourceOrElement;
if (exists) {
assertTrue("expected to exist: " + javaElement.getHandleIdentifier(), javaElement.exists());
} else {
- assertTrue("expected NOT to exist: " + javaElement.getHandleIdentifier(), ! javaElement.exists());
+ assertFalse("expected NOT to exist: " + javaElement.getHandleIdentifier(), javaElement.exists());
IResource resource= javaElement.getResource();
- assertTrue("expected NOT to exist: " + resource.getFullPath(), ! resource.exists());
+ assertFalse("expected NOT to exist: " + resource.getFullPath(), resource.exists());
}
}
}
@@ -261,15 +241,18 @@ public class DeleteTest extends RefactoringTest {
return new MockReorgQueries();
}
+ @Test
public void testDisabled_emptySelection() throws Exception{
verifyDisabled(new Object[] {});
}
+ @Test
public void testDisabled_projectAndNonProject() throws Exception{
IJavaElement[] javaElements= {RefactoringTestSetup.getProject(), getPackageP()};
verifyDisabled(javaElements);
}
+ @Test
public void testDisabled_nonExistingResource() throws Exception{
IFolder folder= (IFolder)getPackageP().getResource();
IFile file= folder.getFile("a.txt");
@@ -278,6 +261,7 @@ public class DeleteTest extends RefactoringTest {
verifyDisabled(resources);
}
+ @Test
public void testDisabled_nonExistingJavaElement() throws Exception{
IJavaElement notExistingCu= getPackageP().getCompilationUnit("V.java");
@@ -285,16 +269,19 @@ public class DeleteTest extends RefactoringTest {
verifyDisabled(javaElements);
}
+ @Test
public void testDisabled_nullResource() throws Exception{
Object[] elements= {RefactoringTestSetup.getProject(), null};
verifyDisabled(elements);
}
+ @Test
public void testDisabled_nullJavaElement() throws Exception{
Object[] elements= {getPackageP(), null};
verifyDisabled(elements);
}
+ @Test
public void testDisabled_archiveElement() throws Exception{
IPackageFragmentRoot archive= getArchiveRoot();
assertNotNull(archive);
@@ -303,6 +290,7 @@ public class DeleteTest extends RefactoringTest {
verifyDisabled(elements);
}
+ @Test
public void testDisabled_externalArchive() throws Exception{
IPackageFragmentRoot archive= getArchiveRoot();
assertNotNull(archive);
@@ -311,19 +299,23 @@ public class DeleteTest extends RefactoringTest {
verifyDisabled(elements);
}
+ @Test
public void testDisabled_archiveFromAnotherProject() throws Exception{
//TODO implement me
}
+ @Test
public void testDisabled_binaryMember() throws Exception{
//TODO implement me
}
+ @Test
public void testDisabled_javaProject() throws Exception{
Object[] elements= {RefactoringTestSetup.getProject()};
verifyDisabled(elements);
}
+ @Test
public void testDisabled_defaultPackage() throws Exception {
IPackageFragment defaultPackage= getRoot().getPackageFragment("");
defaultPackage.createCompilationUnit("A.java", "", false, new NullProgressMonitor());
@@ -332,11 +324,13 @@ public class DeleteTest extends RefactoringTest {
verifyDisabled(elements);
}
+ @Test
public void testDisabled_simpleProject() throws Exception{
Object[] elements= {RefactoringTestSetup.getProject().getProject()};
verifyDisabled(elements);
}
+ @Test
public void testEnabled_cu() throws Exception{
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "", false, new NullProgressMonitor());
@@ -344,6 +338,7 @@ public class DeleteTest extends RefactoringTest {
verifyEnabled(elements);
}
+ @Test
public void testEnabled_sourceReferences1() throws Exception{
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "", false, new NullProgressMonitor());
IJavaElement importD= cu.createImport("java.lang.*", null, new NullProgressMonitor());
@@ -354,6 +349,7 @@ public class DeleteTest extends RefactoringTest {
verifyEnabled(elements);
}
+ @Test
public void testEnabled_sourceReferences2() throws Exception{
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "", false, new NullProgressMonitor());
IType type= cu.createType("class A{}", null, false, new NullProgressMonitor());
@@ -367,6 +363,7 @@ public class DeleteTest extends RefactoringTest {
}
+ @Test
public void testEnabled_file() throws Exception{
IFolder folder= (IFolder)getPackageP().getResource();
IFile file= folder.getFile("a.txt");
@@ -375,6 +372,7 @@ public class DeleteTest extends RefactoringTest {
verifyEnabled(elements);
}
+ @Test
public void testEnabled_folder() throws Exception{
IFolder folder= (IFolder)getPackageP().getResource();
@@ -382,40 +380,49 @@ public class DeleteTest extends RefactoringTest {
verifyEnabled(elements);
}
+ @Test
public void testEnabled_readOnlyCu() throws Exception{
//TODO implement me
}
+ @Test
public void testEnabled_readOnlyFile() throws Exception{
//TODO implement me
}
+ @Test
public void testEnabled_package() throws Exception{
Object[] elements= {getPackageP()};
verifyEnabled(elements);
}
+ @Test
public void testEnabled_sourceFolder() throws Exception{
Object[] elements= {getRoot()};
verifyEnabled(elements);
}
+ @Test
public void testEnabled_linkedFile() throws Exception{
//TODO implement me
}
+ @Test
public void testEnabled_linkedFolder() throws Exception{
//TODO implement me
}
+ @Test
public void testEnabled_linkedPackage() throws Exception{
//TODO implement me
}
+ @Test
public void testEnabled_linkedSourceFolder() throws Exception{
//TODO implement me
}
+ @Test
public void testDeleteWithinCu0() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -426,6 +433,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu1() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -437,6 +445,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu2() throws Exception{
loadFileSetup();
ParticipantTesting.reset();
@@ -448,6 +457,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu3() throws Exception{
loadFileSetup();
ParticipantTesting.reset();
@@ -460,6 +470,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu4() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -472,6 +483,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu5() throws Exception{
loadFileSetup();
ParticipantTesting.reset();
@@ -483,6 +495,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu6() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -494,6 +507,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu7() throws Exception{
//exposes bug#9381 IPackageDeclaration is not ISourceManipulation
ParticipantTesting.reset();
@@ -506,6 +520,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu8() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -517,6 +532,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu9() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -528,6 +544,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu10() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -539,6 +556,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu11() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -550,6 +568,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu12() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -561,6 +580,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu13() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -573,6 +593,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu14() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -586,6 +607,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu15() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -599,6 +621,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu16() throws Exception{
if (BUG_55221) {
printTestDisabledMessage("testDeleteWithinCu16 disabled for bug#55221");
@@ -614,6 +637,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu17() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -625,6 +649,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu18() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -636,6 +661,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu19() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -647,6 +673,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu20() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -658,6 +685,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu21() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -669,6 +697,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu22() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -680,6 +709,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu23() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -694,6 +724,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu24() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -708,6 +739,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu25() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -722,6 +754,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteWithinCu26() throws Exception{
ParticipantTesting.reset();
loadFileSetup();
@@ -736,6 +769,7 @@ public class DeleteTest extends RefactoringTest {
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteFile() throws Exception{
ParticipantTesting.reset();
IFolder folder= (IFolder)getPackageP().getResource();
@@ -751,12 +785,12 @@ public class DeleteTest extends RefactoringTest {
DeleteRefactoring ref= createRefactoring(elem);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals("expected to pass", null, status);
- assertTrue("file not deleted", ! file.exists());
+ assertNull("expected to pass", status);
+ assertFalse("file not deleted", file.exists());
ParticipantTesting.testDelete(handles);
IUndoManager undoManager= RefactoringCore.getUndoManager();
- assertTrue(! undoManager.anythingToRedo());
+ assertFalse(undoManager.anythingToRedo());
assertTrue(undoManager.anythingToUndo());
undoManager.performUndo(null, new NullProgressMonitor());
assertTrue(file.exists());
@@ -764,9 +798,10 @@ public class DeleteTest extends RefactoringTest {
assertTrue(undoManager.anythingToRedo());
undoManager.performRedo(null, new NullProgressMonitor());
- assertTrue(! file.exists());
+ assertFalse(file.exists());
}
+ @Test
public void testDeleteFolder() throws Exception{
ParticipantTesting.reset();
IFolder folder= (IFolder)getPackageP().getResource();
@@ -781,11 +816,12 @@ public class DeleteTest extends RefactoringTest {
String[] handles= ParticipantTesting.createHandles(subFolder);
DeleteRefactoring ref= createRefactoring(elements);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals("expected to pass", null, status);
- assertTrue("folder not deleted", ! subFolder.exists());
+ assertNull("expected to pass", status);
+ assertFalse("folder not deleted", subFolder.exists());
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteNestedFolders() throws Exception{
ParticipantTesting.reset();
IFolder folder= (IFolder)getPackageP().getResource();
@@ -803,13 +839,13 @@ public class DeleteTest extends RefactoringTest {
String[] handles= ParticipantTesting.createHandles(subFolder);
DeleteRefactoring ref= createRefactoring(elements);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals("expected to pass", null, status);
- assertTrue("folder not deleted", ! subFolder.exists());
- assertTrue("folder not deleted", ! subsubFolder.exists());
+ assertNull("expected to pass", status);
+ assertFalse("folder not deleted", subFolder.exists());
+ assertFalse("folder not deleted", subsubFolder.exists());
ParticipantTesting.testDelete(handles);
IUndoManager undoManager= RefactoringCore.getUndoManager();
- assertTrue(! undoManager.anythingToRedo());
+ assertFalse(undoManager.anythingToRedo());
assertTrue(undoManager.anythingToUndo());
undoManager.performUndo(null, new NullProgressMonitor());
assertTrue(subFolder.exists());
@@ -817,10 +853,11 @@ public class DeleteTest extends RefactoringTest {
assertTrue(undoManager.anythingToRedo());
undoManager.performRedo(null, new NullProgressMonitor());
- assertTrue(! subFolder.exists());
- assertTrue(! subsubFolder.exists());
+ assertFalse(subFolder.exists());
+ assertFalse(subsubFolder.exists());
}
+ @Test
public void testDeleteCu() throws Exception{
ParticipantTesting.reset();
final String contents= "package p; class X{}";
@@ -835,15 +872,15 @@ public class DeleteTest extends RefactoringTest {
DeleteRefactoring ref= createRefactoring(elements);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals("expected to pass", null, status);
- assertTrue("cu not deleted", ! newCU.exists());
+ assertNull("expected to pass", status);
+ assertFalse("cu not deleted", newCU.exists());
ParticipantTesting.testDelete(handles);
IWorkbenchOperationSupport operationSupport= PlatformUI.getWorkbench().getOperationSupport();
IOperationHistory operationHistory= operationSupport.getOperationHistory();
IUndoContext undoContext= operationSupport.getUndoContext();
- assertTrue(! operationHistory.canRedo(undoContext));
+ assertFalse(operationHistory.canRedo(undoContext));
assertTrue(operationHistory.canUndo(undoContext));
operationHistory.undo(undoContext, null, null);
assertTrue(newCU.exists());
@@ -851,9 +888,10 @@ public class DeleteTest extends RefactoringTest {
assertTrue(operationHistory.canRedo(undoContext));
operationHistory.redo(undoContext, null, null);
- assertTrue(! newCU.exists());
+ assertFalse(newCU.exists());
}
+ @Test
public void testDeleteSourceFolder() throws Exception{
ParticipantTesting.reset();
IPackageFragmentRoot fredRoot= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "fred");
@@ -865,11 +903,12 @@ public class DeleteTest extends RefactoringTest {
String[] handles= ParticipantTesting.createHandles(fredRoot, fredRoot.getResource());
DeleteRefactoring ref= createRefactoring(elements);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals("expected to pass", null, status);
- assertTrue("not deleted", ! fredRoot.exists());
+ assertNull("expected to pass", status);
+ assertFalse("not deleted", fredRoot.exists());
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteInternalJAR() throws Exception{
ParticipantTesting.reset();
File lib= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.MYLIB);
@@ -883,15 +922,17 @@ public class DeleteTest extends RefactoringTest {
DeleteRefactoring ref= createRefactoring(elements);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals("expected to pass", null, status);
- assertTrue("not deleted", ! internalJAR.exists());
+ assertNull("expected to pass", status);
+ assertFalse("not deleted", internalJAR.exists());
ParticipantTesting.testDelete(handles);
}
+ @Test
public void testDeleteClassFile() throws Exception{
//TODO implement me - how do i get a handle to a class file?
}
+ @Test
public void testDeletePackage() throws Exception{
// newPackage <- delete
// newPackage.A
@@ -913,8 +954,8 @@ public class DeleteTest extends RefactoringTest {
DeleteRefactoring ref= createRefactoring(elements);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals("expected to pass", null, status);
- assertTrue("package not deleted", ! newPackage.exists());
+ assertNull("expected to pass", status);
+ assertFalse("package not deleted", newPackage.exists());
ParticipantTesting.testDelete(deleteHandles);
@@ -924,9 +965,10 @@ public class DeleteTest extends RefactoringTest {
assertTrue(file.exists());
assertEquals(cuContents, cu.getSource());
undoManager.performRedo(null, new NullProgressMonitor());
- assertTrue(! newPackage.exists());
+ assertFalse(newPackage.exists());
}
+ @Test
public void testDeletePackage2() throws Exception{
// p1 <- delete
// p1.A
@@ -949,13 +991,13 @@ public class DeleteTest extends RefactoringTest {
DeleteRefactoring ref= createRefactoring(elements);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals("expected to pass", null, status);
+ assertNull("expected to pass", status);
//Package is not delete since it had sub packages
assertTrue("package deleted", p1.exists());
assertEquals(0, p1.getChildren().length);
assertTrue(p1p2.exists());
- assertTrue(! file.exists());
- assertTrue(! cu.exists());
+ assertFalse(file.exists());
+ assertFalse(cu.exists());
ParticipantTesting.testDelete(deleteHandles);
@@ -967,10 +1009,11 @@ public class DeleteTest extends RefactoringTest {
assertEquals(cuContents, cu.getSource());
undoManager.performRedo(null, new NullProgressMonitor());
assertTrue(p1p2.exists());
- assertTrue(! file.exists());
- assertTrue(! cu.exists());
+ assertFalse(file.exists());
+ assertFalse(cu.exists());
}
+ @Test
public void testDeletePackage3() throws Exception {
// a0.a1.a2.a3 <- delete
// a0.a1.a2.a3.A
@@ -982,6 +1025,7 @@ public class DeleteTest extends RefactoringTest {
doTestUndoRedo(deleted, null);
}
+ @Test
public void testDeletePackage4() throws Exception {
// a0.a1.a2.a3 <- delete
// a0.a1.a2.a3.A <- delete
@@ -993,6 +1037,7 @@ public class DeleteTest extends RefactoringTest {
doTestUndoRedo(deleted, null);
}
+ @Test
public void testDeletePackage5() throws Exception {
// a0.a1.a2.A <- not deleted
// a0.a1.a2.a3.a4.a5 <- delete
@@ -1005,6 +1050,7 @@ public class DeleteTest extends RefactoringTest {
doTestUndoRedo(deleted, exist);
}
+ @Test
public void testDeletePackage6() throws Exception {
// a0.a1.a2.anotherPackage
// a0.a1.a2.a3.a4.a5 <- delete
@@ -1017,6 +1063,7 @@ public class DeleteTest extends RefactoringTest {
doTestUndoRedo(deleted, exist);
}
+ @Test
public void testDeletePackage7() throws Exception {
// a0.a1.a2.A <- delete
// a0.a1.a2.a3.a4.a5 <- delete
@@ -1029,6 +1076,7 @@ public class DeleteTest extends RefactoringTest {
doTestUndoRedo(deleted, exist);
}
+ @Test
public void testDeletePackage8() throws Exception {
// a0.a1.a2.A <- delete
// a0.a1.a2.a3.Z <- don't delete
@@ -1044,6 +1092,7 @@ public class DeleteTest extends RefactoringTest {
doTestUndoRedo(deleted, exist);
}
+ @Test
public void testDeletePackage9() throws Exception {
// a0.a1.a2.A <- delete
// a0.a1.a2.a3.Z <- delete
@@ -1059,6 +1108,7 @@ public class DeleteTest extends RefactoringTest {
doTestUndoRedo(deleted, exist);
}
+ @Test
public void testDeletePackage10() throws Exception {
// a0.a1.a2 <- delete
// a0.a1.a2.A <- delete
@@ -1076,7 +1126,7 @@ public class DeleteTest extends RefactoringTest {
mustPerformDummySearch();
DeleteRefactoring ref= createRefactoring(markedForDelete);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals("expected to pass", null, status);
+ assertNull("expected to pass", status);
// test handles (!! only the package, not the resource)
ParticipantTesting.testDelete(deleteHandles);
@@ -1086,6 +1136,7 @@ public class DeleteTest extends RefactoringTest {
doTestUndoRedo(deleted, exist);
}
+ @Test
public void testDeletePackage12() throws Exception {
// a0 <- delete
// a0.a1 <- delete
@@ -1098,6 +1149,7 @@ public class DeleteTest extends RefactoringTest {
doTestUndoRedo(deleted, exist);
}
+ @Test
public void testDeletePackageAndFolder() throws Exception {
// folder <- delete
// and
@@ -1124,9 +1176,9 @@ public class DeleteTest extends RefactoringTest {
DeleteRefactoring ref= createRefactoring(elements);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals("expected to pass", null, status);
- assertTrue("folder not deleted", !folder.exists());
- assertTrue("package not deleted", !newPackage.exists());
+ assertNull("expected to pass", status);
+ assertFalse("folder not deleted", folder.exists());
+ assertFalse("package not deleted", newPackage.exists());
ParticipantTesting.testDelete(deleteHandles);
@@ -1137,11 +1189,12 @@ public class DeleteTest extends RefactoringTest {
assertTrue(file.exists());
assertEquals(cuContents, cu.getSource());
undoManager.performRedo(null, new NullProgressMonitor());
- assertTrue(!folder.exists());
- assertTrue(!newPackage.exists());
+ assertFalse(folder.exists());
+ assertFalse(newPackage.exists());
}
- /* Don't rename! See #suite() */
+ /* Don't rename! See @FixMethodOrder(MethodSorters.NAME_ASCENDING) */
+ @Test
public void test_END_DeletePackageSub1() throws Exception {
// a0.a1.a2 <-delete with subs
// a0.a1.a2.a3
@@ -1159,7 +1212,8 @@ public class DeleteTest extends RefactoringTest {
doTestUndoRedo(deleted, exist);
}
- /* Don't rename! See #suite() */
+ /* Don't rename! See @FixMethodOrder(MethodSorters.NAME_ASCENDING) */
+ @Test
public void test_END_DeletePackageSub4() throws Exception {
// (default)
// a0 <- delete
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MoveTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MoveTest.java
index 01757168f8..578b35abbc 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MoveTest.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MoveTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,11 +13,17 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.ccp;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.util.Map;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
@@ -59,15 +65,13 @@ import org.eclipse.jdt.internal.corext.refactoring.reorg.JavaMoveProcessor;
import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgDestinationFactory;
import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory;
+import org.eclipse.jdt.ui.tests.refactoring.GenericRefactoringTest;
import org.eclipse.jdt.ui.tests.refactoring.ParticipantTesting;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
import org.eclipse.jdt.internal.ui.refactoring.reorg.CreateTargetQueries;
-
-public class MoveTest extends RefactoringTest {
-
+public class MoveTest extends GenericRefactoringTest {
private static final class ConfirmAllQuery implements IReorgQueries {
@Override
public IConfirmQuery createSkipQuery(String queryTitle, int queryID) {
@@ -156,24 +160,14 @@ public class MoveTest extends RefactoringTest {
}
}
- public MoveTest(String name) {
- super(name);
- }
-
- private static final Class<MoveTest> clazz= MoveTest.class;
private static final String REFACTORING_PATH= "Move/";
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new RefactoringTestSetup(someTest);
- }
+ @Rule
+ public RefactoringTestSetup fts= new RefactoringTestSetup();
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void genericbefore() throws Exception {
+ super.genericbefore();
fIsPreDeltaTest= true;
}
@@ -191,10 +185,10 @@ public class MoveTest extends RefactoringTest {
}
private void verifyDisabled(IResource[] resources, IJavaElement[] javaElements) throws JavaModelException {
- assertTrue("move should be disabled", ! RefactoringAvailabilityTester.isMoveAvailable(resources, javaElements));
+ assertFalse("move should be disabled", RefactoringAvailabilityTester.isMoveAvailable(resources, javaElements));
IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, javaElements);
JavaMoveProcessor processor= policy.canEnable() ? new JavaMoveProcessor(policy) : null;
- assertTrue(processor == null);
+ assertNull(processor);
}
private JavaMoveProcessor verifyEnabled(IResource[] resources, IJavaElement[] javaElements, IReorgQueries reorgQueries) throws JavaModelException {
@@ -223,30 +217,35 @@ public class MoveTest extends RefactoringTest {
assertEquals("destination was expected to be not valid", RefactoringStatus.FATAL, status.getSeverity());
}
+ @Test
public void testDisabled_empty() throws Exception {
IJavaElement[] javaElements= {};
IResource[] resources= {};
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_null_element() throws Exception {
IJavaElement[] javaElements= {null};
IResource[] resources= {};
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_null_resource() throws Exception {
IJavaElement[] javaElements= {};
IResource[] resources= {null};
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_javaProject() throws Exception {
IJavaElement[] javaElements= {RefactoringTestSetup.getProject()};
IResource[] resources= {};
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_defaultPackage() throws Exception {
IPackageFragment defaultPackage= getRoot().getPackageFragment("");
assertTrue(defaultPackage.exists());
@@ -255,20 +254,23 @@ public class MoveTest extends RefactoringTest {
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_project() throws Exception {
IJavaElement[] javaElements= {};
IResource[] resources= {RefactoringTestSetup.getProject().getProject()};
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_notExistingElement() throws Exception {
ICompilationUnit notExistingCu= getPackageP().getCompilationUnit("NotMe.java");
- assertTrue(! notExistingCu.exists());
+ assertFalse(notExistingCu.exists());
IJavaElement[] javaElements= {notExistingCu};
IResource[] resources= {};
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_notExistingResource() throws Exception {
IFolder folder= (IFolder)getPackageP().getResource();
IFile notExistingFile= folder.getFile("a.txt");
@@ -278,12 +280,14 @@ public class MoveTest extends RefactoringTest {
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_noCommonParent0() throws Exception {
IJavaElement[] javaElements= {getPackageP(), getRoot()};
IResource[] resources= {};
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_noCommonParent1() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor());
IType classA= cu.getType("A");
@@ -301,6 +305,7 @@ public class MoveTest extends RefactoringTest {
// verifyDisabled(resources, javaElements);
// }
+ @Test
public void testDisabled_noCommonParent3() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= {cu, getPackageP()};
@@ -308,6 +313,7 @@ public class MoveTest extends RefactoringTest {
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_noCommonParent5() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= {cu, getRoot()};
@@ -315,6 +321,7 @@ public class MoveTest extends RefactoringTest {
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_noCommonParent6() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= {cu, getRoot()};
@@ -322,6 +329,7 @@ public class MoveTest extends RefactoringTest {
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_noCommonParent7() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{class Inner{}}", false, new NullProgressMonitor());
IType classA= cu.getType("A");
@@ -331,6 +339,7 @@ public class MoveTest extends RefactoringTest {
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDisabled_noCommonParent8() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IType classA= cu.getType("A");
@@ -340,6 +349,7 @@ public class MoveTest extends RefactoringTest {
verifyDisabled(resources, javaElements);
}
+ @Test
public void testDestination_no_fileToItself() throws Exception {
IFolder superFolder= (IFolder)getPackageP().getResource();
IFile file= superFolder.getFile("a.txt");
@@ -353,6 +363,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_fileToSiblingFile() throws Exception {
IFolder superFolder= (IFolder)getPackageP().getResource();
IFile file1= superFolder.getFile("a.txt");
@@ -368,6 +379,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_folderToItsef() throws Exception {
IFolder superFolder= (IFolder)getPackageP().getResource();
IFolder folder= superFolder.getFolder("folder");
@@ -380,6 +392,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_cuToItsef() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= {cu};
@@ -390,6 +403,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_cuToSiblingCu() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
ICompilationUnit cu1= getPackageP().createCompilationUnit("B.java", "package p;class A{}", false, new NullProgressMonitor());
@@ -401,6 +415,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_cuToSiblingFile() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
@@ -416,6 +431,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_packageToItsef() throws Exception {
IJavaElement[] javaElements= {getPackageP()};
IResource[] resources= {};
@@ -425,6 +441,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_sourceFolderToItsef() throws Exception {
IJavaElement[] javaElements= {getRoot()};
IResource[] resources= {};
@@ -434,6 +451,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_methodToItsef() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
@@ -445,6 +463,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_fileToParentFolder() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
@@ -460,6 +479,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_fileToParentPackage() throws Exception {
IFolder superFolder= (IFolder)getPackageP().getResource();
IFile file= superFolder.getFile("a.txt");
@@ -473,6 +493,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_fileToParentSourceFolder() throws Exception {
IFolder superFolder= (IFolder)getRoot().getResource();
IFile file= superFolder.getFile("a.txt");
@@ -486,6 +507,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_fileToParentDefaultPackage() throws Exception {
IPackageFragment defaultPackage= getRoot().getPackageFragment("");
assertTrue(defaultPackage.exists());
@@ -500,6 +522,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_fileToParentDefaultPackage2() throws Exception {
IPackageFragment defaultPackage= getRoot().getPackageFragment("");
assertTrue(defaultPackage.exists());
@@ -515,6 +538,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_fileToParentSourceFolder2() throws Exception {
IPackageFragmentRoot root= getRoot();
assertTrue(root.exists());
@@ -529,6 +553,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_folderToParentFolder() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
@@ -545,6 +570,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_cuToParentPackage() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= {cu};
@@ -555,6 +581,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_packageToParentSourceFolder() throws Exception {
IJavaElement[] javaElements= {getPackageP()};
IResource[] resources= {};
@@ -564,6 +591,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_sourceFolderToParentProject() throws Exception {
IJavaElement[] javaElements= {getRoot()};
IResource[] resources= {};
@@ -573,6 +601,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_methodToParentType() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
@@ -584,6 +613,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_cuToMethod() throws Exception {
IPackageFragment pack1= getRoot().createPackageFragment("q", true, new NullProgressMonitor());
ICompilationUnit cu= pack1.createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
@@ -597,6 +627,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_packageToCu() throws Exception {
IPackageFragment pack1= getRoot().createPackageFragment("q", true, new NullProgressMonitor());
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
@@ -608,6 +639,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_packageToFile() throws Exception {
IPackageFragment pack1= getRoot().createPackageFragment("q", true, new NullProgressMonitor());
IFolder superFolder= (IFolder)getRoot().getResource();
@@ -622,6 +654,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_packageToFolder() throws Exception {
IPackageFragment pack1= getRoot().createPackageFragment("q", true, new NullProgressMonitor());
IFolder superFolder= (IFolder)getRoot().getResource();
@@ -636,6 +669,7 @@ public class MoveTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
+ @Test
public void testDestination_no_packageToSimpleProject() throws Exception {
IProject simpleProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject");
simpleProject.create(null);
@@ -670,6 +704,7 @@ public class MoveTest extends RefactoringTest {
// }
// }
+ @Test
public void testDestination_no_packageToSiblingPackage() throws Exception {
IPackageFragment pack1= getRoot().createPackageFragment("q", true, new NullProgressMonitor());
IJavaElement[] javaElements= {getPackageP()};
@@ -680,6 +715,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_sourceFolderToCu() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2");
@@ -691,6 +727,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_sourceFolderToPackage() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2");
IJavaElement[] javaElements= {sourceFolder};
@@ -701,6 +738,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_sourceFolderToFile() throws Exception {
IFolder superFolder= (IFolder)getRoot().getResource();
IFile file= superFolder.getFile("a.txt");
@@ -715,6 +753,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_sourceFolderToFolder() throws Exception {
IFolder superFolder= (IFolder)getRoot().getResource();
IFolder folder= superFolder.getFolder("folder");
@@ -729,6 +768,7 @@ public class MoveTest extends RefactoringTest {
verifyValidDestination(ref, destination);
}
+ @Test
public void testDestination_no_sourceFolderToSourceFolder() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2");
IJavaElement[] javaElements= {sourceFolder};
@@ -739,6 +779,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_sourceFolderToSimpleProject() throws Exception {
IPackageFragmentRoot sourceFolder= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src2");
IProject simpleProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject");
@@ -757,6 +798,7 @@ public class MoveTest extends RefactoringTest {
}
}
+ @Test
public void testDestination_no_sourceFolderToJavaProjecteWithNoSourceFolder() throws Exception {
IJavaProject otherProject= JavaProjectHelper.createJavaProject("otherProject", null);
JavaProjectHelper.addSourceContainer(otherProject, null);
@@ -774,6 +816,7 @@ public class MoveTest extends RefactoringTest {
}
}
+ @Test
public void testDestination_yes_methodToCu() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){/*impl*/}}", false, new NullProgressMonitor());
ICompilationUnit cu1= getPackageP().createCompilationUnit("B.java", "package p;class B{}", false, new NullProgressMonitor());
@@ -786,9 +829,9 @@ public class MoveTest extends RefactoringTest {
verifyValidDestination(ref, destination);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
+ assertNull(status);
- assertTrue("source method not moved", ! method.exists());
+ assertFalse("source method not moved", method.exists());
IType typeB= cu1.getType("B");
IMethod methodBfoo= typeB.getMethod("foo", new String[0]);
@@ -798,6 +841,7 @@ public class MoveTest extends RefactoringTest {
}
+ @Test
public void testDestination_no_methodToFile() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IFolder superFolder= (IFolder)getRoot().getResource();
@@ -813,6 +857,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_methodToFolder() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IFolder superFolder= (IFolder)getRoot().getResource();
@@ -828,6 +873,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_methodToPackage() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
@@ -839,6 +885,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_methodToSourceFolder() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
@@ -850,6 +897,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_methodToJavaProject() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
@@ -861,6 +909,7 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
+ @Test
public void testDestination_no_methodToSimpleProject() throws Exception {
ICompilationUnit cu= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IProject simpleProject= ResourcesPlugin.getWorkspace().getRoot().getProject("mySImpleProject");
@@ -879,7 +928,8 @@ public class MoveTest extends RefactoringTest {
}
}
- public void testDestination_no_cuToItself() throws Exception{
+ @Test
+ public void testDestination_no_cuToItself() throws Exception {
ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IJavaElement[] javaElements= { cu1};
IResource[] resources= {};
@@ -888,7 +938,8 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_yes_cuToOtherPackage() throws Exception{
+ @Test
+ public void testDestination_yes_cuToOtherPackage() throws Exception {
IPackageFragment otherPackage= getRoot().createPackageFragment("otherPackage", true, new NullProgressMonitor());
String oldSource= "package p;class A{void foo(){}class Inner{}}";
String newSource= "package otherPackage;class A{void foo(){}class Inner{}}";
@@ -904,8 +955,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file does not exist before moving", cu1.exists());
RefactoringStatus status= performRefactoring(processor, true);
- assertEquals(null, status);
- assertTrue("source file exists after moving", ! cu1.exists());
+ assertNull(status);
+ assertFalse("source file exists after moving", cu1.exists());
ICompilationUnit newCu= otherPackage.getCompilationUnit(cu1.getElementName());
assertTrue("new file does not exist after moving", newCu.exists());
assertEqualLines("source differs", newSource, newCu.getSource());
@@ -917,6 +968,7 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(otherPackage.getResource(), processor.getUpdateReferences())});
}
+ @Test
public void testDestination_yes_cuToOtherPackageBug549674() throws Exception {
ParticipantTesting.reset();
@@ -955,8 +1007,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file does not exist before moving", toMove.exists());
RefactoringStatus status= performRefactoring(processor, true);
- assertEquals(null, status);
- assertTrue("source file exists after moving", !toMove.exists());
+ assertNull(status);
+ assertFalse("source file exists after moving", toMove.exists());
ICompilationUnit newCu= getPackageQ().getCompilationUnit(toMove.getElementName());
assertTrue("new file does not exist after moving", newCu.exists());
@@ -980,6 +1032,7 @@ public class MoveTest extends RefactoringTest {
});
}
+ @Test
public void testDestination_yes_cuToOtherPackageBug21008() throws Exception {
ParticipantTesting.reset();
@@ -1016,8 +1069,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file does not exist before moving", toMove.exists());
RefactoringStatus status= performRefactoring(processor, true);
- assertEquals(null, status);
- assertTrue("source file exists after moving", !toMove.exists());
+ assertNull(status);
+ assertFalse("source file exists after moving", toMove.exists());
ICompilationUnit newCu= getPackageQ().getCompilationUnit(toMove.getElementName());
assertTrue("new file does not exist after moving", newCu.exists());
@@ -1039,6 +1092,7 @@ public class MoveTest extends RefactoringTest {
});
}
+ @Test
public void testDestination_yes_cuToOtherPackageWithMultiRoot() throws Exception {
ParticipantTesting.reset();
//regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=47788
@@ -1062,8 +1116,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file does not exist before moving", cuA.exists());
RefactoringStatus status= performRefactoring(processor, true);
- assertEquals(null, status);
- assertTrue("source file exists after moving", ! cuA.exists());
+ assertNull(status);
+ assertFalse("source file exists after moving", cuA.exists());
ICompilationUnit newCu= otherPackage.getCompilationUnit(cuA.getElementName());
assertTrue("new file does not exist after moving", newCu.exists());
assertEqualLines("source differs", newA, newCu.getSource());
@@ -1077,6 +1131,7 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(otherPackage.getResource(), processor.getUpdateReferences())});
}
+ @Test
public void testDestination_yes_cuToOtherPackageWithMultiRootBug109145() throws Exception {
ParticipantTesting.reset();
@@ -1103,8 +1158,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file does not exist before moving", toMove.exists());
RefactoringStatus status= performRefactoring(processor, true);
- assertEquals(null, status);
- assertTrue("source file exists after moving", !toMove.exists());
+ assertNull(status);
+ assertFalse("source file exists after moving", toMove.exists());
ICompilationUnit newCu= destination.getCompilationUnit(toMove.getElementName());
assertTrue("new file does not exist after moving", newCu.exists());
@@ -1128,7 +1183,8 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(destination, processor.getUpdateReferences()), new MoveArguments(destination.getResource(), processor.getUpdateReferences()) });
}
- public void testDestination_yes_cuToRoot() throws Exception{
+ @Test
+ public void testDestination_yes_cuToRoot() throws Exception {
ParticipantTesting.reset();
String newSource= "package p;class A{void foo(){}class Inner{}}";
String oldSource= "package p;class A{void foo(){}class Inner{}}";
@@ -1143,8 +1199,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file does not exist before moving", cu1.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
- assertTrue("source file exists after moving", ! cu1.exists());
+ assertNull(status);
+ assertFalse("source file exists after moving", cu1.exists());
ICompilationUnit newCu= destination.getPackageFragment("p").getCompilationUnit(cu1.getElementName());
assertTrue("new file does not exist after moving", newCu.exists());
assertEqualLines("source differs", newSource, newCu.getSource());
@@ -1158,7 +1214,8 @@ public class MoveTest extends RefactoringTest {
}
- public void testDestination_yes_cuFromRoot() throws Exception{
+ @Test
+ public void testDestination_yes_cuFromRoot() throws Exception {
ParticipantTesting.reset();
//import statement with type from default package - only <= java 1.3
@@ -1189,8 +1246,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file Default.java does not exist before moving", cuD.exists());
assertTrue("source file Reference.java does not exist before moving", cuRef.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
- assertTrue("source file Default.java exists after moving", ! cuD.exists());
+ assertNull(status);
+ assertFalse("source file Default.java exists after moving", cuD.exists());
assertTrue("new file Default.java does not exist after moving", newCuD.exists());
assertTrue("source file Reference.java does not exist after moving", cuRef.exists());
assertEqualLines("Default.java differs", newD, newCuD.getSource());
@@ -1207,7 +1264,8 @@ public class MoveTest extends RefactoringTest {
}
}
- public void testDestination_no_cuFromRoot() throws Exception{
+ @Test
+ public void testDestination_no_cuFromRoot() throws Exception {
//import statement with type from default package - only <= java 1.3
IJavaProject javaProject= getRoot().getJavaProject();
Map<String, String> originalOptions= javaProject.getOptions(false);
@@ -1236,7 +1294,7 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file Reference.java does not exist before moving", cuRef.exists());
RefactoringStatus status= performRefactoring(ref, false);
assertEquals(RefactoringStatus.ERROR, status.getSeverity());
- assertTrue("source file Default.java exists after moving", ! cuD.exists());
+ assertFalse("source file Default.java exists after moving", cuD.exists());
assertTrue("new file Default.java does not exist after moving", newCuD.exists());
assertTrue("source file Reference.java does not exist after moving", cuRef.exists());
assertEqualLines("Default.java differs", newD, newCuD.getSource());
@@ -1247,7 +1305,8 @@ public class MoveTest extends RefactoringTest {
}
}
- public void testDestination_yes_cuToProject() throws Exception{
+ @Test
+ public void testDestination_yes_cuToProject() throws Exception {
ParticipantTesting.reset();
String oldSource= "package p;class A{void foo(){}class Inner{}}";
String newSource= oldSource;
@@ -1263,8 +1322,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file does not exist before moving", cu1.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
- assertTrue("source file exists after moving", ! cu1.exists());
+ assertNull(status);
+ assertFalse("source file exists after moving", cu1.exists());
IFile newFile= project.getProject().getFile(cu1.getElementName());
assertEqualLines("source differs", newSource, getContents(newFile));
@@ -1276,7 +1335,8 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(project.getResource(), ref.getUpdateReferences())});
}
- public void testDestination_yes_cuToSimpleProject() throws Exception{
+ @Test
+ public void testDestination_yes_cuToSimpleProject() throws Exception {
ParticipantTesting.reset();
String oldSource= "package p;class A{void foo(){}class Inner{}}";
String newSource= oldSource;
@@ -1295,8 +1355,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file does not exist before moving", cu1.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
- assertTrue("source file exists after moving", ! cu1.exists());
+ assertNull(status);
+ assertFalse("source file exists after moving", cu1.exists());
IFile newFile= simpleProject.getFile(cu1.getElementName());
assertEqualLines("source differs", newSource, getContents(newFile));
@@ -1311,7 +1371,8 @@ public class MoveTest extends RefactoringTest {
}
}
- public void testDestination_yes_cuToFileInDifferentPackage() throws Exception{
+ @Test
+ public void testDestination_yes_cuToFileInDifferentPackage() throws Exception {
ParticipantTesting.reset();
ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IPackageFragment otherPackage= getRoot().createPackageFragment("other", true, new NullProgressMonitor());
@@ -1330,9 +1391,9 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file does not exist before", cu1.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
+ assertNull(status);
- assertTrue("source file not moved", ! cu1.exists());
+ assertFalse("source file not moved", cu1.exists());
ICompilationUnit newCu= otherPackage.getCompilationUnit(cu1.getElementName());
assertTrue("new file does not exist after", newCu.exists());
@@ -1348,7 +1409,8 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(otherPackage.getResource(), ref.getUpdateReferences())});
}
- public void testDestination_yes_cuToFolder() throws Exception{
+ @Test
+ public void testDestination_yes_cuToFolder() throws Exception {
ParticipantTesting.reset();
ICompilationUnit cu1= getPackageP().createCompilationUnit("A.java", "package p;class A{void foo(){}class Inner{}}", false, new NullProgressMonitor());
IProject superFolder= RefactoringTestSetup.getProject().getProject();
@@ -1367,9 +1429,9 @@ public class MoveTest extends RefactoringTest {
String expectedSource= cu1.getSource();
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
+ assertNull(status);
- assertTrue("source file not moved", ! cu1.exists());
+ assertFalse("source file not moved", cu1.exists());
IFile newFile= folder.getFile(cu1.getElementName());
assertTrue("new file does not exist after", newFile.exists());
@@ -1384,7 +1446,8 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(folder, ref.getUpdateReferences())});
}
- public void testDestination_yes_fileToSiblingFolder() throws Exception{
+ @Test
+ public void testDestination_yes_fileToSiblingFolder() throws Exception {
ParticipantTesting.reset();
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFile file= superFolder.getFile("a.txt");
@@ -1404,9 +1467,9 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file does not exist before", file.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
+ assertNull(status);
- assertTrue("source file not moved", ! file.exists());
+ assertFalse("source file not moved", file.exists());
IFile newFile= folder.getFile(file.getName());
assertTrue("new file does not exist after", newFile.exists());
@@ -1417,7 +1480,8 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(folder, ref.getUpdateReferences())});
}
- public void testDestination_yes_fileToCu() throws Exception{
+ @Test
+ public void testDestination_yes_fileToCu() throws Exception {
ParticipantTesting.reset();
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFile file= superFolder.getFile("a.txt");
@@ -1435,9 +1499,9 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file does not exist before", file.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
+ assertNull(status);
- assertTrue("source file not moved", ! file.exists());
+ assertFalse("source file not moved", file.exists());
IFile newFile= ((IFolder)cu1.getParent().getResource()).getFile(file.getName());
assertTrue("new file does not exist after", newFile.exists());
@@ -1448,7 +1512,8 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(getPackageP().getResource(), ref.getUpdateReferences())});
}
- public void testDestination_yes_fileToPackage() throws Exception{
+ @Test
+ public void testDestination_yes_fileToPackage() throws Exception {
ParticipantTesting.reset();
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFile file= superFolder.getFile("a.txt");
@@ -1465,9 +1530,9 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file does not exist before", file.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
+ assertNull(status);
- assertTrue("source file not moved", ! file.exists());
+ assertFalse("source file not moved", file.exists());
IFile newFile= ((IFolder)getPackageP().getResource()).getFile(file.getName());
assertTrue("new file does not exist after", newFile.exists());
@@ -1478,6 +1543,7 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(getPackageP().getResource(), ref.getUpdateReferences())});
}
+ @Test
public void testDestination_no_fileToMethod() throws Exception {
IFolder superFolder= (IFolder)getRoot().getResource();
IFile file= superFolder.getFile("a.txt");
@@ -1492,7 +1558,8 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_yes_fileToRoot() throws Exception{
+ @Test
+ public void testDestination_yes_fileToRoot() throws Exception {
ParticipantTesting.reset();
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFile file= superFolder.getFile("a.txt");
@@ -1509,9 +1576,9 @@ public class MoveTest extends RefactoringTest {
assertTrue("source file does not exist before", file.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
+ assertNull(status);
- assertTrue("source file not moved", ! file.exists());
+ assertFalse("source file not moved", file.exists());
IFile newFile= ((IFolder)getRoot().getResource()).getFile(file.getName());
assertTrue("new file does not exist after", newFile.exists());
@@ -1521,7 +1588,8 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(getRoot().getResource(), ref.getUpdateReferences())});
}
- public void testDestination_no_fileToParentProject() throws Exception{
+ @Test
+ public void testDestination_no_fileToParentProject() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFile file= superFolder.getFile("a.txt");
file.create(getStream("123"), true, null);
@@ -1534,7 +1602,8 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_yes_folderToSiblingFolder() throws Exception{
+ @Test
+ public void testDestination_yes_folderToSiblingFolder() throws Exception {
ParticipantTesting.reset();
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
@@ -1553,8 +1622,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("folder does not exist before", folder.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
- assertTrue("folder not moved", ! folder.exists());
+ assertNull(status);
+ assertFalse("folder not moved", folder.exists());
IFolder newFolder= otherFolder.getFolder(folder.getName());
assertTrue("new folder does not exist after", newFolder.exists());
ParticipantTesting.testMove(
@@ -1563,7 +1632,8 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(destination, ref.getUpdateReferences())});
}
- public void testDestination_no_folderToParentProject() throws Exception{
+ @Test
+ public void testDestination_no_folderToParentProject() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
folder.create(true, true, null);
@@ -1576,7 +1646,8 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_yes_folderToSiblingRoot() throws Exception{
+ @Test
+ public void testDestination_yes_folderToSiblingRoot() throws Exception {
ParticipantTesting.reset();
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
@@ -1592,8 +1663,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("folder does not exist before", folder.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
- assertTrue("folder not moved", ! folder.exists());
+ assertNull(status);
+ assertFalse("folder not moved", folder.exists());
IPackageFragment newPackage= getRoot().getPackageFragment(folder.getName());
assertTrue("new folder does not exist after", newPackage.exists());
ParticipantTesting.testMove(
@@ -1602,7 +1673,8 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(getRoot().getResource(), ref.getUpdateReferences())});
}
- public void testDestination_yes_folderToPackage() throws Exception{
+ @Test
+ public void testDestination_yes_folderToPackage() throws Exception {
ParticipantTesting.reset();
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
@@ -1618,8 +1690,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("folder does not exist before", folder.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
- assertTrue("folder not moved", ! folder.exists());
+ assertNull(status);
+ assertFalse("folder not moved", folder.exists());
IPackageFragment newPackage= getRoot().getPackageFragment(getPackageP().getElementName() + "." + folder.getName());
assertTrue("new package does not exist after", newPackage.exists());
ParticipantTesting.testMove(
@@ -1628,7 +1700,8 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(getPackageP().getResource(), ref.getUpdateReferences())});
}
- public void testDestination_yes_folderToFileInAnotherFolder() throws Exception{
+ @Test
+ public void testDestination_yes_folderToFileInAnotherFolder() throws Exception {
ParticipantTesting.reset();
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
@@ -1649,8 +1722,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("folder does not exist before", folder.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
- assertTrue("folder not moved", ! folder.exists());
+ assertNull(status);
+ assertFalse("folder not moved", folder.exists());
IFolder newFolder= otherFolder.getFolder(folder.getName());
assertTrue("new folder does not exist after", newFolder.exists());
ParticipantTesting.testMove(
@@ -1659,7 +1732,8 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(otherFolder, ref.getUpdateReferences())});
}
- public void testDestination_yes_folderToCu() throws Exception{
+ @Test
+ public void testDestination_yes_folderToCu() throws Exception {
ParticipantTesting.reset();
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
@@ -1677,8 +1751,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("folder does not exist before", folder.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
- assertTrue("folder not moved", ! folder.exists());
+ assertNull(status);
+ assertFalse("folder not moved", folder.exists());
IPackageFragment newPackage= getRoot().getPackageFragment(getPackageP().getElementName() + "." + folder.getName());
assertTrue("new package does not exist after", newPackage.exists());
ParticipantTesting.testMove(
@@ -1687,7 +1761,8 @@ public class MoveTest extends RefactoringTest {
new MoveArguments(cu.getParent().getResource(), ref.getUpdateReferences())});
}
- public void testDestination_yes_folderToSimpleProject() throws Exception{
+ @Test
+ public void testDestination_yes_folderToSimpleProject() throws Exception {
ParticipantTesting.reset();
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("folder");
@@ -1708,8 +1783,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("folder does not exist before", folder.exists());
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
- assertTrue("folder not moved", ! folder.exists());
+ assertNull(status);
+ assertFalse("folder not moved", folder.exists());
IFolder newFolder= simpleProject.getFolder(folder.getName());
assertTrue("new folder does not exist after", newFolder.exists());
ParticipantTesting.testMove(
@@ -1721,7 +1796,8 @@ public class MoveTest extends RefactoringTest {
}
}
- public void testDestination_yes_sourceFolderToOtherProject() throws Exception{
+ @Test
+ public void testDestination_yes_sourceFolderToOtherProject() throws Exception {
ParticipantTesting.reset();
IJavaProject otherJavaProject= JavaProjectHelper.createJavaProject("other", "bin");
@@ -1737,8 +1813,8 @@ public class MoveTest extends RefactoringTest {
assertTrue("folder does not exist before", oldRoot.exists());
RefactoringStatus status= performRefactoring(ref, false);
- assertEquals(null, status);
- assertTrue("folder not moved", ! oldRoot.exists());
+ assertNull(status);
+ assertFalse("folder not moved", oldRoot.exists());
IPackageFragmentRoot newRoot= getSourceFolder(otherJavaProject, oldRoot.getElementName());
assertTrue("new folder does not exist after", newRoot.exists());
ParticipantTesting.testMove(
@@ -1751,7 +1827,8 @@ public class MoveTest extends RefactoringTest {
}
}
- public void testDestination_no_methodToItself() throws Exception{
+ @Test
+ public void testDestination_no_methodToItself() throws Exception {
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
IJavaElement[] javaElements= { method };
@@ -1761,7 +1838,8 @@ public class MoveTest extends RefactoringTest {
verifyInvalidDestination(ref, destination);
}
- public void testDestination_yes_methodToOtherType() throws Exception{
+ @Test
+ public void testDestination_yes_methodToOtherType() throws Exception {
ParticipantTesting.reset();
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IMethod method= cu.getType("A").getMethod("foo", new String[0]);
@@ -1772,14 +1850,15 @@ public class MoveTest extends RefactoringTest {
Object destination= otherType;
verifyValidDestination(ref, destination);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
+ assertNull(status);
String expected= getFileContents(getOutputTestFileName(removeExtension(cu.getElementName())));
assertEqualLines("source differs", expected, cu.getSource());
ParticipantTesting.testMove(new String[] {},new MoveArguments[] {} );
}
- public void testDestination_yes_fieldToOtherType() throws Exception{
+ @Test
+ public void testDestination_yes_fieldToOtherType() throws Exception {
ParticipantTesting.reset();
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IField field= cu.getType("A").getField("f");
@@ -1790,14 +1869,15 @@ public class MoveTest extends RefactoringTest {
Object destination= otherType;
verifyValidDestination(ref, destination);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
+ assertNull(status);
String expected= getFileContents(getOutputTestFileName(removeExtension(cu.getElementName())));
assertEqualLines("source differs", expected, cu.getSource());
ParticipantTesting.testMove(new String[] {},new MoveArguments[] {} );
}
- public void testDestination_yes_initializerToOtherType() throws Exception{
+ @Test
+ public void testDestination_yes_initializerToOtherType() throws Exception {
ParticipantTesting.reset();
ICompilationUnit cu= createCUfromTestFile(getPackageP(), "A");
IInitializer initializer= cu.getType("A").getInitializer(1);
@@ -1808,14 +1888,15 @@ public class MoveTest extends RefactoringTest {
Object destination= otherType;
verifyValidDestination(ref, destination);
RefactoringStatus status= performRefactoring(ref, true);
- assertEquals(null, status);
+ assertNull(status);
String expected= getFileContents(getOutputTestFileName(removeExtension(cu.getElementName())));
assertEqualLines("source differs", expected, cu.getSource());
ParticipantTesting.testMove(new String[] {},new MoveArguments[] {} );
}
- public void testDestination_bug79318() throws Exception{
+ @Test
+ public void testDestination_bug79318() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder= superFolder.getFolder("bar");
folder.create(true, true, null);
@@ -1831,7 +1912,8 @@ public class MoveTest extends RefactoringTest {
assertIsParent(superFolder, folder);
}
- public void testDestination_bug196303() throws Exception{
+ @Test
+ public void testDestination_bug196303() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder folder1= superFolder.getFolder("bar");
folder1.create(true, true, null);
@@ -1850,6 +1932,7 @@ public class MoveTest extends RefactoringTest {
assertIsParent(superFolder, folder);
}
+ @Test
public void testDestination_fieldWithImport() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
IType typeA= cuA.getType("A");
@@ -1861,6 +1944,7 @@ public class MoveTest extends RefactoringTest {
compareContents("A");
}
+ @Test
public void testDestination_fieldWithImport_back() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
IType typeA= cuA.getType("A");
@@ -1872,6 +1956,7 @@ public class MoveTest extends RefactoringTest {
compareContents("A");
}
+ @Test
public void testDestination_fieldWithImportMoveAcross() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B");
@@ -1886,6 +1971,7 @@ public class MoveTest extends RefactoringTest {
compareContents("B");
}
+ @Test
public void testDestination_bug31125() throws Exception {
IProject superFolder= RefactoringTestSetup.getProject().getProject();
IFolder destination= superFolder.getFolder("folder");
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MultiMoveTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MultiMoveTest.java
index 814b46ceb8..44f1b7179a 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MultiMoveTest.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/MultiMoveTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,11 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.ccp;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
@@ -41,31 +44,19 @@ import org.eclipse.jdt.internal.corext.refactoring.reorg.JavaMoveProcessor;
import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgDestinationFactory;
import org.eclipse.jdt.internal.corext.refactoring.reorg.ReorgPolicyFactory;
+import org.eclipse.jdt.ui.tests.refactoring.GenericRefactoringTest;
import org.eclipse.jdt.ui.tests.refactoring.ParticipantTesting;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup;
-
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
-public class MultiMoveTest extends RefactoringTest {
-
- private static final Class<MultiMoveTest> clazz= MultiMoveTest.class;
+public class MultiMoveTest extends GenericRefactoringTest {
private static final String REFACTORING_PATH= "MultiMove/";
- public MultiMoveTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
-
- public static Test setUpTest(Test someTest) {
- return new RefactoringTestSetup(someTest);
- }
+ @Rule
+ public RefactoringTestSetup fts= new RefactoringTestSetup();
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void genericbefore() throws Exception {
+ super.genericbefore();
fIsPreDeltaTest= true;
}
@@ -75,16 +66,17 @@ public class MultiMoveTest extends RefactoringTest {
}
//---
- private IPackageFragment createPackage(String name) throws Exception{
+ private IPackageFragment createPackage(String name) throws Exception {
return getRoot().createPackageFragment(name, true, null);
}
- private ICompilationUnit createCu(IPackageFragment pack, String cuPath, String cuName) throws Exception{
+ private ICompilationUnit createCu(IPackageFragment pack, String cuPath, String cuName) throws Exception {
return createCU(pack, cuName, getFileContents(getRefactoringPath() + cuPath));
}
//--------
- public void test0() throws Exception{
+ @Test
+ public void test0() throws Exception {
ParticipantTesting.reset();
final String p1Name= "p1";
final String inDir= "/in/";
@@ -114,7 +106,7 @@ public class MultiMoveTest extends RefactoringTest {
RefactoringStatus status= performRefactoring(processor, true);
//-- checks
- assertEquals("status should be ok here", null, status);
+ assertNull("status should be ok here", status);
assertEquals("p1 files", 0, packP1.getChildren().length);
assertEquals("p2 files", 3, packP2.getChildren().length);
@@ -141,7 +133,8 @@ public class MultiMoveTest extends RefactoringTest {
}
- public void test1() throws Exception{
+ @Test
+ public void test1() throws Exception {
ParticipantTesting.reset();
final String p1Name= "p1";
final String inDir= "/in/";
@@ -171,7 +164,7 @@ public class MultiMoveTest extends RefactoringTest {
RefactoringStatus status= performRefactoring(processor, true);
//-- checks
- assertEquals("status should be ok here", null, status);
+ assertNull("status should be ok here", status);
assertEquals("p1 files", 0, packP1.getChildren().length);
assertEquals("p2 files", 3, packP2.getChildren().length);
@@ -196,7 +189,8 @@ public class MultiMoveTest extends RefactoringTest {
});
}
- public void test2() throws Exception{
+ @Test
+ public void test2() throws Exception {
ParticipantTesting.reset();
final String p1Name= "p1";
final String inDir= "/in/";
@@ -225,7 +219,7 @@ public class MultiMoveTest extends RefactoringTest {
RefactoringStatus status= performRefactoring(processor, true);
//-- checks
- assertEquals("status should be ok here", null, status);
+ assertNull("status should be ok here", status);
assertEquals("p1 files", 1, packP1.getChildren().length);
assertEquals("p2 files", 2, packP2.getChildren().length);
@@ -248,7 +242,8 @@ public class MultiMoveTest extends RefactoringTest {
});
}
- public void test3() throws Exception{
+ @Test
+ public void test3() throws Exception {
ParticipantTesting.reset();
final String p1Name= "p1";
final String p3Name= "p3";
@@ -278,7 +273,7 @@ public class MultiMoveTest extends RefactoringTest {
RefactoringStatus status= performRefactoring(processor, true);
//-- checks
- assertEquals("status should be ok here", null, status);
+ assertNull("status should be ok here", status);
assertEquals("p1 files", 0, packP1.getChildren().length);
assertEquals("p2 files", 1, packP2.getChildren().length);
@@ -299,6 +294,7 @@ public class MultiMoveTest extends RefactoringTest {
}
+ @Test
public void testPackageMoveParticipants() throws Exception {
ParticipantTesting.reset();
IPackageFragmentRoot r1= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src1");
@@ -319,7 +315,7 @@ public class MultiMoveTest extends RefactoringTest {
RefactoringStatus status= performRefactoring(processor, false);
//-- checks
- assertEquals("status should be ok here", null, status);
+ assertNull("status should be ok here", status);
ParticipantTesting.testMove(
moveHandes,
@@ -329,6 +325,7 @@ public class MultiMoveTest extends RefactoringTest {
});
}
+ @Test
public void testPackageMoveParticipants2() throws Exception {
fIsPreDeltaTest= false;
ParticipantTesting.reset();
@@ -353,7 +350,7 @@ public class MultiMoveTest extends RefactoringTest {
RefactoringStatus status= performRefactoring(processor, false);
//-- checks
- assertEquals("status should be ok here", null, status);
+ assertNull("status should be ok here", status);
IPath path= r2.getResource().getFullPath();
path= path.append(p1.getElementName().replace('.', '/'));
@@ -371,6 +368,7 @@ public class MultiMoveTest extends RefactoringTest {
});
}
+ @Test
public void testPackageMoveParticipants3() throws Exception {
ParticipantTesting.reset();
IPackageFragmentRoot r1= JavaProjectHelper.addSourceContainer(RefactoringTestSetup.getProject(), "src1");
@@ -393,7 +391,7 @@ public class MultiMoveTest extends RefactoringTest {
RefactoringStatus status= performRefactoring(processor, false);
//-- checks
- assertEquals("status should be ok here", null, status);
+ assertNull("status should be ok here", status);
IPath path= r2.getResource().getFullPath();
path= path.append(p1.getElementName().replace('.', '/'));
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/PasteActionTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/PasteActionTest.java
index 614045a66f..3618722dcf 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/PasteActionTest.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ccp/PasteActionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,13 +13,16 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.ccp;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Rule;
+import org.junit.Test;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.dnd.Clipboard;
@@ -48,30 +51,22 @@ import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.corext.refactoring.TypedSource;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup;
+import org.eclipse.jdt.ui.tests.refactoring.GenericRefactoringTest;
import org.eclipse.jdt.ui.tests.refactoring.infra.MockClipboard;
import org.eclipse.jdt.ui.tests.refactoring.infra.MockWorkbenchSite;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
import org.eclipse.jdt.internal.ui.refactoring.reorg.CopyToClipboardAction;
import org.eclipse.jdt.internal.ui.refactoring.reorg.PasteAction;
import org.eclipse.jdt.internal.ui.refactoring.reorg.TypedSourceTransfer;
-
-public class PasteActionTest extends RefactoringTest{
-
+public class PasteActionTest extends GenericRefactoringTest {
private static final boolean BUG_NOT_IMPLEMENTED_YET= true;
private Clipboard fClipboard;
- private static final Class<PasteActionTest> clazz= PasteActionTest.class;
private static final String REFACTORING_PATH= "Paste/";
- public PasteActionTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new RefactoringTestSetup(new TestSuite(clazz));
- }
+ @Rule
+ public RefactoringTestSetup fts= new RefactoringTestSetup();
@Override
protected String getRefactoringPath() {
@@ -79,13 +74,14 @@ public class PasteActionTest extends RefactoringTest{
}
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void genericbefore() throws Exception {
+ super.genericbefore();
fClipboard= new MockClipboard(Display.getDefault());
}
+
@Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ public void genericafter() throws Exception {
+ super.genericafter();
fClipboard.dispose();
}
@@ -122,18 +118,21 @@ public class PasteActionTest extends RefactoringTest{
return pasteAction;
}
+ @Test
public void testEnabled_javaProject() throws Exception {
IJavaElement[] javaElements= {RefactoringTestSetup.getProject()};
IResource[] resources= {};
verifyEnabled(resources, javaElements, new IResource[0], new IJavaElement[0]);
}
+ @Test
public void testEnabled_project() throws Exception {
IJavaElement[] javaElements= {};
IResource[] resources= {RefactoringTestSetup.getProject().getProject()};
verifyEnabled(resources, javaElements, new IResource[0], new IJavaElement[0]);
}
+ @Test
public void testEnabled_workingSet() throws Exception {
IWorkingSet ws= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSet("Test", new IAdaptable[] {});
try {
@@ -147,7 +146,8 @@ public class PasteActionTest extends RefactoringTest{
assertEqualLines(cuName, getFileContents(getOutputTestFileName(cuName)), getPackageP().getCompilationUnit(cuName + ".java").getSource());
}
- public void test0() throws Exception{
+ @Test
+ public void test0() throws Exception {
if (BUG_NOT_IMPLEMENTED_YET) {
printTestDisabledMessage("not implemented yet");
return;
@@ -172,7 +172,8 @@ public class PasteActionTest extends RefactoringTest{
compareContents("B");
}
- public void test2() throws Exception{
+ @Test
+ public void test2() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B");
@@ -192,7 +193,8 @@ public class PasteActionTest extends RefactoringTest{
compareContents("B");
}
- public void test3() throws Exception{
+ @Test
+ public void test3() throws Exception {
// printTestDisabledMessage("test for bug#19007");
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
ICompilationUnit cuB= createCUfromTestFile(getPackageP(), "B");
@@ -213,7 +215,8 @@ public class PasteActionTest extends RefactoringTest{
compareContents("B");
}
- public void test4() throws Exception{
+ @Test
+ public void test4() throws Exception {
// printTestDisabledMessage("test for bug 20151");
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
IJavaElement elem0= cuA.getType("A").getMethod("f", new String[0]);
@@ -231,6 +234,7 @@ public class PasteActionTest extends RefactoringTest{
compareContents("A");
}
+ @Test
public void testPastingJavaElementIntoWorkingSet() throws Exception {
IWorkingSet ws= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSet("Test", new IAdaptable[] {});
try {
@@ -245,6 +249,7 @@ public class PasteActionTest extends RefactoringTest{
}
}
+ @Test
public void testPastingResourceIntoWorkingSet() throws Exception {
IWorkingSet ws= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSet("Test", new IAdaptable[] {});
IFolder folder= RefactoringTestSetup.getProject().getProject().getFolder("folder");
@@ -261,6 +266,7 @@ public class PasteActionTest extends RefactoringTest{
}
}
+ @Test
public void testPastingJavaElementAsResourceIntoWorkingSet() throws Exception {
IWorkingSet ws= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSet("Test", new IAdaptable[] {});
try {
@@ -275,6 +281,7 @@ public class PasteActionTest extends RefactoringTest{
}
}
+ @Test
public void testPastingExistingElementIntoWorkingSet() throws Exception {
IWorkingSet ws= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSet("Test",
new IAdaptable[] {RefactoringTestSetup.getProject()});
@@ -290,6 +297,7 @@ public class PasteActionTest extends RefactoringTest{
}
}
+ @Test
public void testPastingChildJavaElementIntoWorkingSet() throws Exception {
IWorkingSet ws= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSet("Test",
new IAdaptable[] {RefactoringTestSetup.getProject()});
@@ -305,6 +313,7 @@ public class PasteActionTest extends RefactoringTest{
}
}
+ @Test
public void testPastingChildResourceIntoWorkingSet() throws Exception {
IFolder folder= RefactoringTestSetup.getProject().getProject().getFolder("folder");
folder.create(true, true, null);
@@ -324,6 +333,7 @@ public class PasteActionTest extends RefactoringTest{
}
}
+ @Test
public void testPastingChildResourceIntoWorkingSetContainingParent() throws Exception {
IWorkingSet ws= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSet("Test",
new IAdaptable[] {RefactoringTestSetup.getProject()});
@@ -361,6 +371,7 @@ public class PasteActionTest extends RefactoringTest{
pasteAction.run((IStructuredSelection)pasteAction.getSelection());
}
+ @Test
public void testPastingTypedResources0() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
IJavaElement methodM= cuA.getType("A").getMethod("m", new String[0]);
@@ -371,6 +382,7 @@ public class PasteActionTest extends RefactoringTest{
compareContents("A");
}
+ @Test
public void testPastingTypedResources1() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
IType typeA= cuA.getType("A");
@@ -382,6 +394,7 @@ public class PasteActionTest extends RefactoringTest{
compareContents("A");
}
+ @Test
public void testPastingTypedResources2() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
IType typeA= cuA.getType("A");
@@ -393,6 +406,7 @@ public class PasteActionTest extends RefactoringTest{
compareContents("A");
}
+ @Test
public void testPastingTypedResources3() throws Exception {
ICompilationUnit cuA= createCUfromTestFile(getPackageP(), "A");
IType typeA= cuA.getType("A");
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/AbstractCUTestCase.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/AbstractCUTestCase.java
deleted file mode 100644
index d04ae6ab1e..0000000000
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/AbstractCUTestCase.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.refactoring.infra;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IPackageFragment;
-
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest;
-
-public abstract class AbstractCUTestCase extends TestCase {
-
- public AbstractCUTestCase(String name) {
- super(name);
- }
-
- protected String getFileContents(InputStream in) throws IOException {
- BufferedReader br= new BufferedReader(new InputStreamReader(in));
-
- StringBuilder sb= new StringBuilder();
- try {
- int read= 0;
- while ((read= br.read()) != -1)
- sb.append((char) read);
- } finally {
- br.close();
- }
- return sb.toString();
- }
-
- protected ICompilationUnit createCU(IPackageFragment pack, String name, String contents) throws Exception {
- ICompilationUnit cu= pack.createCompilationUnit(name, contents, true, null);
- cu.save(null, true);
- return cu;
- }
-
- protected ICompilationUnit createCU(IPackageFragment pack, String name, InputStream contents) throws Exception {
- return createCU(pack, name, getFileContents(contents));
- }
-
- //--- creating a compilation unit from a resource folder relative to a plugin ----------------------------------
-
- protected abstract InputStream getFileInputStream(String fileName) throws IOException;
-
- protected String getResourceLocation() {
- return "";
- }
-
- protected ICompilationUnit createCU(IPackageFragment pack, String name) throws Exception {
- name= adaptName(name);
- return createCU(pack, name, getFileInputStream(getFilePath(pack, name)));
- }
-
- protected String adaptName(String name) {
- return name + ".java";
- }
-
- protected String getProofedContent(String folder, String name) throws Exception {
- name= adaptName(name);
- return getFileContents(getFileInputStream(getFilePath(folder, name)));
- }
-
- private String getFilePath(String path, String name) {
- return getResourceLocation() + path + "/" + name;
- }
-
- private String getFilePath(IPackageFragment pack, String name) {
- return getFilePath(pack.getElementName(), name);
- }
-
- //---- helper to compare two file without considering the package statement
-
- public static void compareSource(String refactored, String proofed) {
- compareSource(refactored, proofed, true);
- }
-
- public static void compareSource(String refactored, String proofed, boolean skipPackageDeclaration) {
- int index= skipPackageDeclaration ? refactored.indexOf(';'): 0;
- refactored= refactored.substring(index);
- index= skipPackageDeclaration ? proofed.indexOf(';') : 0;
- proofed= proofed.substring(index);
- RefactoringTest.assertEqualLines(proofed, refactored);
- }
-}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/RefactoringHeapTestCase.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/RefactoringHeapTestCase.java
index 622b16d944..4072579ed0 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/RefactoringHeapTestCase.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/RefactoringHeapTestCase.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.infra;
+import org.junit.Assert;
+
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.ltk.core.refactoring.CheckConditionsOperation;
@@ -42,9 +44,9 @@ public abstract class RefactoringHeapTestCase extends RefactoringPerformanceTest
startMeasuring();
ResourcesPlugin.getWorkspace().run(operation, null);
if (checkUndo)
- assertNotNull(operation.getUndoChange());
- assertEquals(true, operation.getConditionStatus().getSeverity() <= maxSeverity);
- assertEquals(true, operation.getValidationStatus().isOK());
+ Assert.assertNotNull(operation.getUndoChange());
+ Assert.assertTrue(operation.getConditionStatus().getSeverity() <= maxSeverity);
+ Assert.assertTrue(operation.getValidationStatus().isOK());
RefactoringCore.getUndoManager().flush();
System.gc();
if (measure)
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/RefactoringPerformanceTestCase.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/RefactoringPerformanceTestCase.java
index dcededfd22..93c926fa67 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/RefactoringPerformanceTestCase.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/RefactoringPerformanceTestCase.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.infra;
+import org.junit.Assert;
+
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.ltk.core.refactoring.CheckConditionsOperation;
@@ -53,10 +55,10 @@ public abstract class RefactoringPerformanceTestCase extends JdtPerformanceTestC
ResourcesPlugin.getWorkspace().run(operation, null);
if (measure)
finishMeasurements();
- assertEquals(true, operation.getConditionStatus().getSeverity() <= maxSeverity);
- assertEquals(true, operation.getValidationStatus().isOK());
+ Assert.assertTrue(operation.getConditionStatus().getSeverity() <= maxSeverity);
+ Assert.assertTrue(operation.getValidationStatus().isOK());
if (checkUndo) {
- assertNotNull(operation.getUndoChange());
+ Assert.assertNotNull(operation.getUndoChange());
}
RefactoringCore.getUndoManager().flush();
System.gc();
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/ZipTools.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/ZipTools.java
index dbbde2e6f1..c52e8ef163 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/ZipTools.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/infra/ZipTools.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.infra;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -20,15 +23,13 @@ import java.util.ArrayList;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import org.junit.Assert;
-
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest;
+import org.eclipse.jdt.ui.tests.refactoring.GenericRefactoringTest;
public class ZipTools {
@@ -73,7 +74,7 @@ public class ZipTools {
ICompilationUnit cu= pack.getCompilationUnit(sourceFileName);
String cuContents= cu.getSource();
- RefactoringTest.assertEqualLines(packageName + "/" + sourceFileName, zipContents, cuContents);
+ GenericRefactoringTest.assertEqualLines(packageName + "/" + sourceFileName, zipContents, cuContents);
} else {
//TODO: compare binary files
}
@@ -83,10 +84,10 @@ public class ZipTools {
IPackageFragment packageFragment= (IPackageFragment) javaelement;
for (ICompilationUnit cu : packageFragment.getCompilationUnits()) {
String cuDescr= packageFragment.getElementName() + "/" + cu.getElementName();
- Assert.assertTrue(cuDescr, zipCus.remove(cuDescr));
+ assertTrue(cuDescr, zipCus.remove(cuDescr));
}
}
- Assert.assertEquals(zipCus.toString(), 0, zipCus.size());
+ assertEquals(zipCus.toString(), 0, zipCus.size());
} finally {
zipInputStream.close();
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSHintHelperTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSHintHelperTest.java
index 68a0f85972..9181878721 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSHintHelperTest.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NLSHintHelperTest.java
@@ -198,7 +198,7 @@ public class NLSHintHelperTest {
fJProject.getProject().refreshLocal(IResource.DEPTH_ONE, null);
IFile existentFile= ResourcesPlugin.getWorkspace().getRoot().getFile(nonExistentPath);
- assertEquals(true, existentFile.exists());
+ assertTrue(existentFile.exists());
Properties properties= NLSHintHelper.getProperties(existentFile);
String newValue= properties.getProperty("newKey");
@@ -235,7 +235,7 @@ public class NLSHintHelperTest {
fJProject.getProject().refreshLocal(IResource.DEPTH_ONE, null);
IFile existentFile= ResourcesPlugin.getWorkspace().getRoot().getFile(nonExistentPath);
- assertEquals(true, existentFile.exists());
+ assertTrue(existentFile.exists());
Properties properties= NLSHintHelper.getProperties(existentFile);
String newValue= properties.getProperty("nonExistingValue");
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NlsRefactoringCreateChangeTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NlsRefactoringCreateChangeTest.java
index 2873523d85..2b4886099a 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NlsRefactoringCreateChangeTest.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/NlsRefactoringCreateChangeTest.java
@@ -45,7 +45,7 @@ import org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring;
import org.eclipse.jdt.internal.corext.refactoring.nls.NLSSubstitution;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest;
+import org.eclipse.jdt.ui.tests.refactoring.GenericRefactoringTest;
public class NlsRefactoringCreateChangeTest {
@Rule
@@ -78,7 +78,7 @@ public class NlsRefactoringCreateChangeTest {
buf.append("class Test {\n");
buf.append(" String hello=\"helloworld\";\n");
buf.append("}");
- ICompilationUnit cu= RefactoringTest.createCU(fHelper.getPackageFragment("/TestSetupProject/src1/p"), "Test.java", //$NON-NLS-1$//$NON-NLS-2$
+ ICompilationUnit cu= GenericRefactoringTest.createCU(fHelper.getPackageFragment("/TestSetupProject/src1/p"), "Test.java", //$NON-NLS-1$//$NON-NLS-2$
buf.toString());
NLSRefactoring nls= createDefaultNls(cu);
@@ -109,7 +109,7 @@ public class NlsRefactoringCreateChangeTest {
buf.append("class Test {");
buf.append(" String hello=\"helloworld\";\r\n");
buf.append("}");
- ICompilationUnit cu= RefactoringTest.createCU(fHelper.getPackageFragment("/TestSetupProject/src1/p"), "Test.java", buf.toString()); //$NON-NLS-1$ //$NON-NLS-2$
+ ICompilationUnit cu= GenericRefactoringTest.createCU(fHelper.getPackageFragment("/TestSetupProject/src1/p"), "Test.java", buf.toString()); //$NON-NLS-1$ //$NON-NLS-2$
NLSRefactoring nls= createDefaultNls(cu);
@@ -141,7 +141,7 @@ public class NlsRefactoringCreateChangeTest {
buf.append(" return \"\";\n");
buf.append(" }\n");
buf.append("}\n");
- RefactoringTest.createCU(fHelper.getPackageFragment("/TestSetupProject/src1/p"), "Accessor.java", buf.toString());
+ GenericRefactoringTest.createCU(fHelper.getPackageFragment("/TestSetupProject/src1/p"), "Accessor.java", buf.toString());
//class to NLS
buf= new StringBuffer();
@@ -151,7 +151,7 @@ public class NlsRefactoringCreateChangeTest {
buf.append(" String world=\"world\";\n");
buf.append("}\n");
fHelper.createPackageFragment("test", "/TestSetupProject/src1");
- ICompilationUnit testClass= RefactoringTest.createCU(fHelper.getPackageFragment("/TestSetupProject/src1/test"), "AClass.java", buf.toString());
+ ICompilationUnit testClass= GenericRefactoringTest.createCU(fHelper.getPackageFragment("/TestSetupProject/src1/test"), "AClass.java", buf.toString());
NLSRefactoring nls= NLSRefactoring.create(testClass);
@@ -193,7 +193,7 @@ public class NlsRefactoringCreateChangeTest {
buf.append(" return \"\";\n");
buf.append(" }\n");
buf.append("}\n");
- RefactoringTest.createCU(fHelper.getPackageFragment("/TestSetupProject/src1/p"), "Accessor.java", buf.toString());
+ GenericRefactoringTest.createCU(fHelper.getPackageFragment("/TestSetupProject/src1/p"), "Accessor.java", buf.toString());
//class to NLS
buf= new StringBuffer();
@@ -202,7 +202,7 @@ public class NlsRefactoringCreateChangeTest {
buf.append(" String hello=\"helloworld\";\n");
buf.append("}\n");
fHelper.createPackageFragment("test", "/TestSetupProject/src1");
- ICompilationUnit testClass= RefactoringTest.createCU(fHelper.getPackageFragment("/TestSetupProject/src1/test"), "AClass.java", buf.toString());
+ ICompilationUnit testClass= GenericRefactoringTest.createCU(fHelper.getPackageFragment("/TestSetupProject/src1/test"), "AClass.java", buf.toString());
NLSRefactoring nls= NLSRefactoring.create(testClass);
@@ -234,7 +234,7 @@ public class NlsRefactoringCreateChangeTest {
buf.append("class Test {\n");
buf.append(" String hello=\"helloworld\";\n");
buf.append("}");
- ICompilationUnit cu= RefactoringTest.createCU(fHelper.getPackageFragment("/TestSetupProject/src1/p"), "Test.java", //$NON-NLS-1$ //$NON-NLS-2$
+ ICompilationUnit cu= GenericRefactoringTest.createCU(fHelper.getPackageFragment("/TestSetupProject/src1/p"), "Test.java", //$NON-NLS-1$ //$NON-NLS-2$
buf.toString());
NLSRefactoring nls= createDefaultNls(cu);
@@ -775,13 +775,13 @@ public class NlsRefactoringCreateChangeTest {
}
private void checkContentOfCu(String message, ICompilationUnit cu, String content) throws Exception {
- RefactoringTest.assertEqualLines(message, content, cu.getBuffer().getContents());
+ GenericRefactoringTest.assertEqualLines(message, content, cu.getBuffer().getContents());
}
private void checkContentOfFile(String message, IFile file, String content) throws Exception {
try (InputStream in= file.getContents()) {
String realContent= copyToString(in);
- RefactoringTest.assertEqualLines(message, content, realContent);
+ GenericRefactoringTest.assertEqualLines(message, content, realContent);
}
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/PropertyFileDocumentModellTest.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/PropertyFileDocumentModellTest.java
index a6f11c613d..7cd9925216 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/PropertyFileDocumentModellTest.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/nls/PropertyFileDocumentModellTest.java
@@ -31,7 +31,7 @@ import org.eclipse.ltk.core.refactoring.DocumentChange;
import org.eclipse.jdt.internal.corext.refactoring.nls.KeyValuePair;
import org.eclipse.jdt.internal.corext.refactoring.nls.PropertyFileDocumentModel;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest;
+import org.eclipse.jdt.ui.tests.refactoring.GenericRefactoringTest;
public class PropertyFileDocumentModellTest {
private static void insert(IDocument document, String key, String value) throws CoreException {
@@ -57,7 +57,7 @@ public class PropertyFileDocumentModellTest {
insert(props, "key", "value");
- RefactoringTest.assertEqualLines(
+ GenericRefactoringTest.assertEqualLines(
"key=value\n", props.get());
}
@@ -332,7 +332,7 @@ public class PropertyFileDocumentModellTest {
insert(props, "key", "value!please escape");
- RefactoringTest.assertEqualLines(
+ GenericRefactoringTest.assertEqualLines(
"key=value\\!please escape\n", props.get());
}
@@ -342,7 +342,7 @@ public class PropertyFileDocumentModellTest {
insert(props, "key", "value1\nvalue2\r");
- RefactoringTest.assertEqualLines(
+ GenericRefactoringTest.assertEqualLines(
"key=value1\\nvalue2\\r\n", props.get());
}
@@ -352,7 +352,7 @@ public class PropertyFileDocumentModellTest {
insert(props, "key", "value1\tvalue2");
- RefactoringTest.assertEqualLines(
+ GenericRefactoringTest.assertEqualLines(
"key=value1\\tvalue2\n", props.get());
}
@@ -362,7 +362,7 @@ public class PropertyFileDocumentModellTest {
insert(props, "key", "value1\fvalue2");
- RefactoringTest.assertEqualLines(
+ GenericRefactoringTest.assertEqualLines(
"key=value1\\fvalue2\n", props.get());
}
@@ -372,7 +372,7 @@ public class PropertyFileDocumentModellTest {
insert(props, "key", "value1\bvalue2");
- RefactoringTest.assertEqualLines(
+ GenericRefactoringTest.assertEqualLines(
"key=value1\\u0008value2\n", props.get());
}
@@ -382,7 +382,7 @@ public class PropertyFileDocumentModellTest {
insert(props, "key", "c:\\demo\\demo.java");
- RefactoringTest.assertEqualLines(
+ GenericRefactoringTest.assertEqualLines(
"key=c:\\\\demo\\\\demo.java\n", props.get());
}
@@ -392,7 +392,7 @@ public class PropertyFileDocumentModellTest {
insert(props, "key", "\u00e4");
- RefactoringTest.assertEqualLines("key=ä\n", props.get());
+ GenericRefactoringTest.assertEqualLines("key=ä\n", props.get());
}
@Test
@@ -401,7 +401,7 @@ public class PropertyFileDocumentModellTest {
insert(props, "key", "\u0926");
- RefactoringTest.assertEqualLines("key=\\u0926\n", props.get());
+ GenericRefactoringTest.assertEqualLines("key=\\u0926\n", props.get());
}
@Test
@@ -410,6 +410,6 @@ public class PropertyFileDocumentModellTest {
insert(props, "key", " test");
- RefactoringTest.assertEqualLines("key=\\ \\ test\n", props.get());
+ GenericRefactoringTest.assertEqualLines("key=\\ \\ test\n", props.get());
}
}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java16Setup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java16Setup.java
index 17346303f4..8d5c2fc71f 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java16Setup.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java16Setup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java17Setup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java1d7Setup.java
index 63e8391edf..56b83d5178 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java17Setup.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java1d7Setup.java
@@ -20,7 +20,10 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
-public class Java17Setup extends RefactoringTestSetup {
+/**
+ * This class is used to run tests on Java Dolphin 1.7 .
+ */
+public class Java1d7Setup extends RefactoringTestSetup {
/*
* @see org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup#addRTJar(org.eclipse.jdt.core.IJavaProject)
*/
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java18Setup.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java1d8Setup.java
index eeeec95297..484c41c660 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java18Setup.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/rules/Java1d8Setup.java
@@ -20,7 +20,10 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
-public class Java18Setup extends RefactoringTestSetup {
+/**
+ * This class is made to run tests on Java Spider 1.8 .
+ */
+public class Java1d8Setup extends RefactoringTestSetup {
/*
* @see org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup#addRTJar(org.eclipse.jdt.core.IJavaProject)
*/
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/typeconstraints/TypeEnvironmentTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/typeconstraints/TypeEnvironmentTests.java
index d68dfcb250..e41f62b968 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/typeconstraints/TypeEnvironmentTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/typeconstraints/TypeEnvironmentTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,11 +13,19 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.refactoring.typeconstraints;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
+import org.junit.Rule;
+import org.junit.Test;
+
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
@@ -38,26 +46,21 @@ import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType;
import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TypeEnvironment;
-import org.eclipse.jdt.ui.tests.refactoring.RefactoringTestSetup;
-import org.eclipse.jdt.ui.tests.refactoring.infra.AbstractCUTestCase;
+import org.eclipse.jdt.ui.tests.refactoring.infra.AbstractJunit4CUTestCase;
import org.eclipse.jdt.ui.tests.refactoring.infra.RefactoringTestPlugin;
+import org.eclipse.jdt.ui.tests.refactoring.rules.RefactoringTestSetup;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class TypeEnvironmentTests extends AbstractCUTestCase {
+public class TypeEnvironmentTests extends AbstractJunit4CUTestCase {
private static final boolean BUG_83616_core_wildcard_assignments= true;
private static class MyTestSetup extends RefactoringTestSetup {
private static IPackageFragment fSignaturePackage;
private static IPackageFragment fGenericPackage;
- public MyTestSetup(Test test) {
- super(test);
- }
+
@Override
- protected void setUp() throws Exception {
- super.setUp();
+ public void before() throws Exception {
+ super.before();
fSignaturePackage= getDefaultSourceFolder().createPackageFragment("signature", true, null);
fGenericPackage= getDefaultSourceFolder().createPackageFragment("generic", true, null);
}
@@ -89,7 +92,7 @@ public class TypeEnvironmentTests extends AbstractCUTestCase {
assertNotNull("Refactoring type is null", refType);
assertEquals("Not same name", type.getName(), refType.getName());
assertEquals("Not same signature", PrettySignatures.get(type), refType.getPrettySignature());
- assertTrue("Not same type", refType == fTypeEnvironment.create(type));
+ assertSame("Not same type", refType, fTypeEnvironment.create(type));
}
}
@Override
@@ -158,18 +161,8 @@ public class TypeEnvironmentTests extends AbstractCUTestCase {
}
}
-
- public TypeEnvironmentTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- return new MyTestSetup(new TestSuite(TypeEnvironmentTests.class));
- }
-
- public static Test setUpTest(Test someTest) {
- return new MyTestSetup(someTest);
- }
+ @Rule
+ public MyTestSetup mts=new MyTestSetup();
@Override
protected InputStream getFileInputStream(String fileName) throws IOException {
@@ -202,30 +195,37 @@ public class TypeEnvironmentTests extends AbstractCUTestCase {
createAST(MyTestSetup.getSignaturePackage()).accept(new CreationChecker());
}
+ @Test
public void testArrays() throws Exception {
performCreationTest();
}
+ @Test
public void testStandardTypes() throws Exception {
performCreationTest();
}
+ @Test
public void testRawTypes() throws Exception {
performCreationTest();
}
+ @Test
public void testGenericTypes() throws Exception {
performCreationTest();
}
+ @Test
public void testWildcardTypes() throws Exception {
performCreationTest();
}
+ @Test
public void testPrimitiveTypes() throws Exception {
performCreationTest();
}
+ @Test
public void testTypeVariables() throws Exception {
performCreationTest();
}
@@ -251,7 +251,7 @@ public class TypeEnvironmentTests extends AbstractCUTestCase {
testFlags(bindings[i], types[i]);
assertTrue("Not same erasure", types[i].getErasure().isEqualTo(bindings[i].getErasure()));
assertTrue("Not same type declaration", types[i].getTypeDeclaration().isEqualTo(bindings[i].getTypeDeclaration()));
- assertTrue("Not same type", types[i] == environment.create(bindings[i]));
+ assertSame("Not same type", types[i], environment.create(bindings[i]));
}
for (int o= 0; o < bindings.length; o++) {
@@ -261,7 +261,7 @@ public class TypeEnvironmentTests extends AbstractCUTestCase {
}
TypeEnvironment secondEnvironment= new TypeEnvironment();
for (int i= 0; i < bindings.length; i++) {
- assertTrue("Equal to second environment", types[i].equals(secondEnvironment.create(bindings[i])));
+ assertEquals("Equal to second environment", types[i], secondEnvironment.create(bindings[i]));
}
ITypeBinding[] restoredBindings= TypeEnvironment.createTypeBindings(types, RefactoringTestSetup.getProject());
assertEquals("Not same length", restoredBindings.length, bindings.length);
@@ -317,18 +317,22 @@ public class TypeEnvironmentTests extends AbstractCUTestCase {
assertEquals("Different anonymous flag", binding.isAnonymous(), type.isAnonymous());
}
+ @Test
public void testStandardAssignments() throws Exception {
performGenericAssignmentTest();
}
+ @Test
public void testWildcardAssignments() throws Exception {
performGenericAssignmentTest();
}
+ @Test
public void testTypeVariableAssignments() throws Exception {
performGenericAssignmentTest();
}
+ @Test
public void testCaptureAssignments() throws Exception {
ASTNode node= createAST(MyTestSetup.getGenericPackage());
CaptureTypeBindingCollector collector= new CaptureTypeBindingCollector();
diff --git a/org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF
index cc3e9ee0fd..8ec1444805 100644
--- a/org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.ui.tests/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.ui.tests
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.jdt.ui.tests; singleton:=true
-Bundle-Version: 3.13.1000.qualifier
+Bundle-Version: 3.13.1100.qualifier
Bundle-Activator: org.eclipse.jdt.testplugin.JavaTestPlugin
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
diff --git a/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ChkpiiTests.java b/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ChkpiiTests.java
index 36cdd6a49a..665cf30d49 100644
--- a/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ChkpiiTests.java
+++ b/org.eclipse.jdt.ui.tests/chkpii/org/eclipse/jdt/ui/tests/chkpii/ChkpiiTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.chkpii;
+import static org.junit.Assert.assertTrue;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -25,17 +27,21 @@ import java.net.URL;
import java.nio.charset.Charset;
import java.util.StringTokenizer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+
import org.eclipse.osgi.service.environment.Constants;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class ChkpiiTests extends TestCase {
+public class ChkpiiTests {
+ @Rule
+ public TestName tn= new TestName();
private String fLogDirectoryName;
@@ -59,6 +65,7 @@ public class ChkpiiTests extends TestCase {
return fName.toUpperCase();
}
}
+
private static class StreamConsumer extends Thread {
StringBuffer fStrBuffer;
BufferedReader fReader;
@@ -114,18 +121,17 @@ public class ChkpiiTests extends TestCase {
private final FileCategory PROPERTIES= new FileCategory("PROPERTIES");
private final FileCategory XML= new FileCategory("XML");
- public static Test suite() {
- return new TestSuite(ChkpiiTests.class);
- }
-
+ @Test
public void testHTMLFiles() {
assertChkpii(HTML);
}
+ @Test
public void testXMLFiles() {
assertChkpii(XML);
}
+ @Test
public void testPropertiesFiles() {
assertChkpii(PROPERTIES);
}
@@ -177,7 +183,7 @@ public class ChkpiiTests extends TestCase {
}
}
int res= process.exitValue();
- System.out.println("ChkpiiTests#" + getName() + "() exit value: " + res);
+ System.out.println("ChkpiiTests#" + tn.getMethodName() + "() exit value: " + res);
return true;
}
@@ -350,10 +356,8 @@ public class ChkpiiTests extends TestCase {
/**
* Constructor for EmptyDirectoriesTest.
*
- * @param name the test name
*/
- public ChkpiiTests(String name) {
- super(name);
+ public ChkpiiTests() {
fLogDirectoryName= getPluginDirectory() + "chkpiiResults" + File.separator; //$NON-NLS-1$
new File(PROPERTIES.getOutputFile()).delete();
new File(HTML.getOutputFile()).delete();
@@ -363,18 +367,16 @@ public class ChkpiiTests extends TestCase {
/*
* @see TestCase#setUp()
*/
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
new File(fLogDirectoryName).mkdirs();
}
/*
* @see TestCase#tearDown()
*/
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
fLogDirectoryName= null;
}
}
diff --git a/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/ASTRewriteSnippet.java b/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/ASTRewriteSnippet.java
index 7a5fffc003..57c7b763b6 100644
--- a/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/ASTRewriteSnippet.java
+++ b/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/ASTRewriteSnippet.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2016 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,10 +13,12 @@
*******************************************************************************/
package org.eclipse.jdt.ui.examples;
+import static org.junit.Assert.assertEquals;
+
import java.util.HashMap;
import java.util.Map;
-import junit.framework.TestCase;
+import org.junit.Test;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
@@ -44,12 +46,13 @@ import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.jdt.launching.JavaRuntime;
-
import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
-public class ASTRewriteSnippet extends TestCase {
+import org.eclipse.jdt.launching.JavaRuntime;
+
+public class ASTRewriteSnippet {
+ @Test
public void testASTRewriteExample() throws Exception {
// create a new project
IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject("Test");
diff --git a/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/CheckBoxExample.java b/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/CheckBoxExample.java
index 500376af97..6de49d5a70 100644
--- a/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/CheckBoxExample.java
+++ b/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/CheckBoxExample.java
@@ -94,13 +94,15 @@ public class CheckBoxExample {
case 0:
list.addElement("element-" + (fgRandom.nextInt() % 1000));
break;
+
case 2:
System.out.println("---- printing all");
List<String> checked= list.getCheckedElements();
- for (int i= 0; i < checked.size(); i++) {
- System.out.println(checked.get(i).toString());
+ for (String checkedElement : checked) {
+ System.out.println(checkedElement);
}
break;
+
default:
list.setChecked(list.getElement(0), true);
break;
diff --git a/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyRenameTypeParticipant.java b/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyRenameTypeParticipant.java
index ca5b5ec477..4f4733669a 100644
--- a/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyRenameTypeParticipant.java
+++ b/org.eclipse.jdt.ui.tests/examples/org/eclipse/jdt/ui/examples/MyRenameTypeParticipant.java
@@ -14,7 +14,6 @@
package org.eclipse.jdt.ui.examples;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.CoreException;
@@ -128,8 +127,8 @@ public class MyRenameTypeParticipant extends RenameParticipant {
return null;
CompositeChange result= new CompositeChange("My special file updates"); //$NON-NLS-1$
- for (Iterator<TextFileChange> iter= changes.values().iterator(); iter.hasNext();) {
- result.add(iter.next());
+ for (TextFileChange textFileChange : changes.values()) {
+ result.add(textFileChange);
}
return result;
}
diff --git a/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/LeakTestSetup.java b/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/LeakTestSetup.java
deleted file mode 100644
index cdd5ce2387..0000000000
--- a/org.eclipse.jdt.ui.tests/leaks/org/eclipse/jdt/ui/leaktest/LeakTestSetup.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.leaktest;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.intro.IIntroManager;
-
-/**
- *
- */
-public class LeakTestSetup extends TestSetup {
-
- private static LeakTestSetup fgCurrentSetup= null;
-
- public LeakTestSetup(Test test) {
- super(test);
- if (fgCurrentSetup == null) {
- fgCurrentSetup= this;
- }
- }
-
- @Override
- protected void setUp() throws Exception {
- if (fgCurrentSetup != this) {
- return;
- }
- IIntroManager introManager= PlatformUI.getWorkbench().getIntroManager();
- introManager.closeIntro(introManager.getIntro());
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (fgCurrentSetup != this) {
- return;
- }
- // nothing done at the moment
- }
-}
diff --git a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/FileTool.java b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/FileTool.java
index 75b667a62a..aa048b98f3 100644
--- a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/FileTool.java
+++ b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/FileTool.java
@@ -168,9 +168,9 @@ public class FileTool {
public static void copy(File src, File dst) throws IOException {
if(src.isDirectory()){
String[] srcChildren = src.list();
- for(int i = 0; i < srcChildren.length; ++i){
- File srcChild= new File(src, srcChildren[i]);
- File dstChild= new File(dst, srcChildren[i]);
+ for (String element : srcChildren) {
+ File srcChild= new File(src, element);
+ File dstChild= new File(dst, element);
copy(srcChild, dstChild);
}
} else
diff --git a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/PerformanceTestSuite.java b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/PerformanceTestSuite.java
index 89ed8ec2dd..1272355c56 100644
--- a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/PerformanceTestSuite.java
+++ b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/PerformanceTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,15 +14,14 @@
package org.eclipse.jdt.ui.tests.performance;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
import org.eclipse.jdt.ui.tests.performance.views.TypeHierarchyPerfTest;
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TypeHierarchyPerfTest.class
+})
public class PerformanceTestSuite {
- public static Test suite() {
- TestSuite suite= new TestSuite(PerformanceTestSuite.class.getName());
- suite.addTest(TypeHierarchyPerfTest.suite());
- return suite;
- }
}
diff --git a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java
index ac453220d0..e95a5907e1 100644
--- a/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java
+++ b/org.eclipse.jdt.ui.tests/performance/org/eclipse/jdt/ui/tests/performance/views/CleanUpPerfTest.java
@@ -19,6 +19,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.junit.Assert;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.JavaTestPlugin;
import org.eclipse.test.OrderedTestSuite;
@@ -87,7 +89,7 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase {
@Override
protected void setUp() throws Exception {
fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
- assertTrue("rt not found", JavaProjectHelper.addRTJar(fJProject1) != null);
+ Assert.assertNotNull("rt not found", JavaProjectHelper.addRTJar(fJProject1));
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
JavaProjectHelper.addSourceContainerWithImport(fJProject1, SRC_CONTAINER, junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
}
@@ -470,10 +472,10 @@ public class CleanUpPerfTest extends JdtPerformanceTestCase {
ResourcesPlugin.getWorkspace().run(operation, null);
if (measure)
stopMeasuring();
- assertEquals(true, operation.getConditionStatus().getSeverity() <= maxSeverity);
- assertEquals(true, operation.getValidationStatus().isOK());
+ Assert.assertTrue(operation.getConditionStatus().getSeverity() <= maxSeverity);
+ Assert.assertTrue(operation.getValidationStatus().isOK());
if (checkUndo) {
- assertNotNull(operation.getUndoChange());
+ Assert.assertNotNull(operation.getUndoChange());
}
//undo the change, to have same code for each run
RefactoringCore.getUndoManager().performUndo(null, null);
diff --git a/org.eclipse.jdt.ui.tests/pom.xml b/org.eclipse.jdt.ui.tests/pom.xml
index ccadd12518..852c18f2e7 100644
--- a/org.eclipse.jdt.ui.tests/pom.xml
+++ b/org.eclipse.jdt.ui.tests/pom.xml
@@ -15,12 +15,12 @@
<parent>
<artifactId>tests-pom</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
<relativePath>../tests-pom/</relativePath>
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.ui.tests</artifactId>
- <version>3.13.1000-SNAPSHOT</version>
+ <version>3.13.1100-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<defaultSigning-excludeInnerJars>true</defaultSigning-excludeInnerJars>
diff --git a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java
index cd71c50403..358d085054 100644
--- a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java
+++ b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/JavaProjectHelper.java
@@ -1140,5 +1140,8 @@ public class JavaProjectHelper {
while (display.readAndDispatch()) { /*loop*/ }
}
}
+
+ private JavaProjectHelper() {
+ }
}
diff --git a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java
index c3aeb7948c..f2307d9fab 100644
--- a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java
+++ b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/TestOptions.java
@@ -64,6 +64,9 @@ public class TestOptions {
project.setOptions(options);
}
+ private TestOptions() {
+ }
+
}
class TestFormatterOptions {
diff --git a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/HelloWorld.java b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/HelloWorld.java
index d6bb629013..e53e086d0b 100644
--- a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/HelloWorld.java
+++ b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/HelloWorld.java
@@ -13,6 +13,13 @@
*******************************************************************************/
package org.eclipse.jdt.testplugin.test;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.core.runtime.Path;
@@ -22,46 +29,29 @@ import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IOrdinaryClassFile;
import org.eclipse.jdt.core.IType;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-
-public class HelloWorld extends TestCase {
-
+public class HelloWorld {
private IJavaProject fJProject;
-
- public static Test suite() {
- TestSuite suite= new TestSuite();
- suite.addTest(new HelloWorld("test1"));
- return suite;
- }
-
- public HelloWorld(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
fJProject= JavaProjectHelper.createJavaProject("TestProject1", "bin");
}
-
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
JavaProjectHelper.delete(fJProject);
}
+ @Test
public void test1() throws Exception {
if (JavaProjectHelper.addRTJar(fJProject) == null) {
- assertTrue("jdk not found", false);
+ fail("jdk not found");
return;
}
String name= "java/util/Vector.java";
IOrdinaryClassFile classfile= (IOrdinaryClassFile) fJProject.findElement(new Path(name));
- assertTrue("classfile not found", classfile != null);
+ assertNotNull("classfile not found", classfile);
IType type= classfile.getType();
System.out.println("methods of Vector");
@@ -69,5 +59,4 @@ public class HelloWorld extends TestCase {
System.out.println(method.getElementName());
}
}
-
}
diff --git a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/JavaTestCase.java b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/JavaTestCase.java
index aaeedfd50d..c06fa528fc 100644
--- a/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/JavaTestCase.java
+++ b/org.eclipse.jdt.ui.tests/test plugin/org/eclipse/jdt/testplugin/test/JavaTestCase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,9 +13,12 @@
*******************************************************************************/
package org.eclipse.jdt.testplugin.test;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
@@ -28,28 +31,16 @@ import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
-
-public class JavaTestCase extends TestCase {
-
+public class JavaTestCase {
private IJavaProject fJavaProject;
- public JavaTestCase(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite= new TestSuite();
- suite.addTest(new JavaTestCase("doTest1"));
- return suite;
- }
-
/**
* Creates a new test Java project.
*
* @throws Exception in case of any problem
*/
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
fJavaProject= JavaProjectHelper.createJavaProject("HelloWorldProject", "bin");
IPackageFragmentRoot root= JavaProjectHelper.addSourceContainer(fJavaProject, "src");
@@ -66,29 +57,27 @@ public class JavaTestCase extends TestCase {
*
* @throws Exception in case of any problem
*/
- @Override
- protected void tearDown () throws Exception {
+ @After
+ public void tearDown () throws Exception {
JavaProjectHelper.delete(fJavaProject);
}
/*
* Basic test: Checks for created methods.
*/
+ @Test
public void doTest1() throws Exception {
-
String name= "ibm/util/A.java";
ICompilationUnit cu= (ICompilationUnit) fJavaProject.findElement(new Path(name));
- assertTrue("A.java must exist", cu != null);
+ assertNotNull("A.java must exist", cu);
IType type= cu.getType("A");
- assertTrue("Type A must exist", type != null);
+ assertNotNull("Type A must exist", type);
System.out.println("methods of A");
IMethod[] methods= type.getMethods();
for (IMethod method : methods) {
System.out.println(method.getElementName());
}
- assertTrue("Should contain 2 methods", methods.length == 2);
+ assertEquals("Should contain 2 methods", 2, methods.length);
}
-
-
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/JUnitWorkspaceTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/JUnitWorkspaceTestSetup.java
deleted file mode 100644
index 83707bebe8..0000000000
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/JUnitWorkspaceTestSetup.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2020 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.junit.tests;
-
-import org.eclipse.jdt.junit.JUnitCore;
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-import org.eclipse.jdt.testplugin.JavaTestPlugin;
-
-import org.eclipse.core.resources.IFolder;
-
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-/**
- *
- * @Deprecated use org.eclipse.jdt.ui.tests.core.rules.JUnitWorkspaceTestSetup as @Rule instead
- *
- */
-public class JUnitWorkspaceTestSetup extends TestSetup {
-
- public static final String WORKSPACE_PATH= "testresources/JUnitWorkspace/";
-
- private static final String PROJECT_NAME_3= "JUnitTests";
- private static final String PROJECT_NAME_4= "JUnit4Tests";
- private static final String SRC_NAME= "src";
-
- private boolean fJUnit4;
- private static IJavaProject fgProject;
- private static IPackageFragmentRoot fgRoot;
-
- public JUnitWorkspaceTestSetup(Test test, boolean jUnit4) {
- super(test);
- fJUnit4= jUnit4;
- }
-
- public static IJavaProject getJavaProject() {
- return fgProject;
- }
-
- public static IPackageFragmentRoot getRoot() {
- return fgRoot;
- }
-
- public static String getProjectPath() {
- return WORKSPACE_PATH + fgProject.getElementName() + '/';
- }
-
- @Override
- protected void setUp() throws Exception {
- if (fJUnit4) {
- fgProject= JavaProjectHelper.createJavaProject(PROJECT_NAME_4, "bin");
- JavaProjectHelper.addRTJar(fgProject);
- IClasspathEntry cpe= JavaCore.newContainerEntry(JUnitCore.JUNIT4_CONTAINER_PATH);
- JavaProjectHelper.addToClasspath(fgProject, cpe);
-
- } else {
- fgProject= JavaProjectHelper.createJavaProject(PROJECT_NAME_3, "bin");
- JavaProjectHelper.addRTJar13(fgProject);
- IClasspathEntry cpe= JavaCore.newContainerEntry(JUnitCore.JUNIT3_CONTAINER_PATH);
- JavaProjectHelper.addToClasspath(fgProject, cpe);
- }
- fgRoot= JavaProjectHelper.addSourceContainer(fgProject, SRC_NAME);
- JavaProjectHelper.importResources((IFolder) fgRoot.getResource(), JavaTestPlugin.getDefault().getBundle(), getProjectPath() + SRC_NAME);
- }
-
- @Override
- protected void tearDown() throws Exception {
- JavaProjectHelper.delete(fgProject);
- fgProject= null;
- fgRoot= null;
- }
-
-}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestPriorization.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestPriorization.java
index d41b23528c..6f81d457e0 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestPriorization.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/junit/tests/TestPriorization.java
@@ -286,9 +286,9 @@ public class TestPriorization extends TestCase {
collectOrder(reordered, order);
// can't check for exact order, since order of Class.getDeclaredMethods() is unspecified (bug 144503)
- List<String> suiteTests= new ArrayList<>(Arrays.asList(new String[] { "testX", "testY", "testZ" }));
- List<String> suite1Tests= new ArrayList<>(Arrays.asList(new String[] { "testA", "testB", "testC" }));
- List<String> suite2Tests= new ArrayList<>(Arrays.asList(new String[] { "testD", "testE", "testF" }));
+ List<String> suiteTests= new ArrayList<>(Arrays.asList("testX", "testY", "testZ"));
+ List<String> suite1Tests= new ArrayList<>(Arrays.asList("testA", "testB", "testC"));
+ List<String> suite2Tests= new ArrayList<>(Arrays.asList("testD", "testE", "testF"));
assertEquals("testF", order.get(0));
assertEquals("testZ", order.get(6));
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/UIInteractiveSuite.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/UIInteractiveSuite.java
index e147d6bda4..a6632211fa 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/UIInteractiveSuite.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/UIInteractiveSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,8 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
import org.eclipse.jdt.ui.tests.dialogs.DialogsTest;
import org.eclipse.jdt.ui.tests.dialogs.PreferencesTest;
@@ -23,21 +23,11 @@ import org.eclipse.jdt.ui.tests.dialogs.WizardsTest;
/**
* Test all areas of the UI.
*/
-public class UIInteractiveSuite extends TestSuite {
-
- /**
- * @return Returns the suite. This is required to
- * use the JUnit Launcher.
- */
- public static Test suite() {
- return new UIInteractiveSuite();
- }
-
- public UIInteractiveSuite() {
- super(UIInteractiveSuite.class.getName());
- addTest(PreferencesTest.suite());
- addTest(WizardsTest.suite());
- addTest(DialogsTest.suite());
- }
-
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ PreferencesTest.class,
+ WizardsTest.class,
+ DialogsTest.class
+ })
+public class UIInteractiveSuite {
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests.java
index cc4b776fc6..dbb545d795 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests.java
@@ -13,8 +13,11 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.browsing;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
@@ -50,9 +53,7 @@ import org.eclipse.jdt.internal.ui.browsing.LogicalPackage;
import org.eclipse.jdt.internal.ui.util.CoreUtility;
import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement;
-
public class PackagesViewContentProviderTests {
-
private IJavaProject fJProject1;
private IJavaProject fJProject2;
@@ -95,14 +96,14 @@ public class PackagesViewContentProviderTests {
//---------Test for getChildren-------------------
@Test
- public void testGetChildrenProjectWithSourceFolders() throws Exception{
+ public void testGetChildrenProjectWithSourceFolders() throws Exception {
- //create a logical package for packages with name "pack3"
+ // Create a logical package for packages with name "pack3"
LogicalPackage cp= new LogicalPackage(fPack31);
cp.add(fPack32);
cp.add(fInternalPack3);
- //create a logical package for default package
+ // Create a logical package for default package
LogicalPackage defaultCp= new LogicalPackage(fPackDefault1);
defaultCp.add(fPackDefault2);
defaultCp.add(fInternalPackDefault);
@@ -114,58 +115,55 @@ public class PackagesViewContentProviderTests {
@Test
- public void testGetChildrentMidLevelFragmentNotLogicalPackage() throws Exception{
- //initialise map
+ public void testGetChildrentMidLevelFragmentNotLogicalPackage() throws Exception {
+ // Initialize map
fProvider.getChildren(fJProject2);
Object[] expectedChildren= new Object[]{fPack17};
- Object[] children= fProvider.getChildren(fPack12);
- assertTrue("Wrong children found for PackageFragment",compareArrays(children, expectedChildren));//$NON-NLS-1$
+ Object[] actualChildren= fProvider.getChildren(fPack12);
+ assertTrue("Wrong children found for PackageFragment", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
}
@Test
- public void testGetChildrenBottomLevelFragment() throws Exception{
+ public void testGetChildrenBottomLevelFragment() throws Exception {
Object[] expectedChildren= new Object[]{};
- Object[] children= fProvider.getChildren(fPack21);
- assertTrue("Wrong children found for PackageFragment",compareArrays(children, expectedChildren));//$NON-NLS-1$
+ Object[] actualChildren= fProvider.getChildren(fPack21);
+ assertTrue("Wrong children found for PackageFragment", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
}
@Test
- public void testGetChildrenLogicalPackage() throws Exception{
-
- //create a logical package for packages with name "pack3"
+ public void testGetChildrenLogicalPackage() throws Exception {
+ // Create a logical package for packages with name "pack3"
LogicalPackage cp= new LogicalPackage(fPack31);
cp.add(fPack32);
cp.add(fInternalPack3);
- //create a logical package for packages with name "pack3.pack4"
- LogicalPackage ChildCp1= new LogicalPackage(fPack41);
- ChildCp1.add(fPack42);
- ChildCp1.add(fInternalPack4);
+ // Create a logical package for packages with name "pack3.pack4"
+ LogicalPackage childCp1= new LogicalPackage(fPack41);
+ childCp1.add(fPack42);
+ childCp1.add(fInternalPack4);
- //create a logical package for packages with name "pack3.pack5"
- LogicalPackage ChildCp2= new LogicalPackage(fPack51);
- ChildCp2.add(fPack52);
- ChildCp2.add(fInternalPack5);
+ // Create a logical package for packages with name "pack3.pack5"
+ LogicalPackage childCp2= new LogicalPackage(fPack51);
+ childCp2.add(fPack52);
+ childCp2.add(fInternalPack5);
- //initialize Map
+ // Initialize Map
fProvider.getChildren(fJProject2);
- Object[] expectedChildren= new Object[]{fPack81, ChildCp1, ChildCp2};
- Object[] children= fProvider.getChildren(cp);
- assertTrue("Wrong children found for project", compareArrays(children, expectedChildren)); //$NON-NLS-1$
-
+ Object[] expectedChildren= new Object[]{fPack81, childCp1, childCp2};
+ Object[] actualChildren= fProvider.getChildren(cp);
+ assertTrue("Wrong children found for project", compareArrays(actualChildren, expectedChildren)); //$NON-NLS-1$
}
@Test
- public void testGetChildrenLogicalPackage2() throws Exception{
-
- //create a logical package for packages with name "pack3.pack4"
+ public void testGetChildrenLogicalPackage2() throws Exception {
+ // Create a logical package for packages with name "pack3.pack4"
LogicalPackage cp= new LogicalPackage(fPack41);
cp.add(fPack42);
cp.add(fInternalPack4);
- //create a logical package for packages with name "pack3"
+ // Create a logical package for packages with name "pack3"
LogicalPackage cp3= new LogicalPackage(fPack31);
cp3.add(fPack32);
cp3.add(fInternalPack3);
@@ -174,100 +172,94 @@ public class PackagesViewContentProviderTests {
fProvider.getChildren(cp3);
Object[] expectedChildren= new Object[]{fPack91, fInternalPack10};
- Object[] children= fProvider.getChildren(cp);
- assertTrue("Wrong children found for project", compareArrays(children, expectedChildren));//$NON-NLS-1$
+ Object[] actualChildren= fProvider.getChildren(cp);
+ assertTrue("Wrong children found for project", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
}
-
-
@Test
- public void testGetChildrenMidLevelFragmentInArchive() throws Exception{
- //initialise map
+ public void testGetChildrenMidLevelFragmentInArchive() throws Exception {
+ // Initialize map
fProvider.getChildren(fArchiveFragmentRoot);
fProvider.getChildren(fPackJunit);
Object[] expectedChildren= new Object[]{fPackJunitSamplesMoney};
- Object[] children= fProvider.getChildren(fPackJunitSamples);
- assertTrue("wrong children found for a NON bottom PackageFragment in PackageFragmentRoot Archive", compareArrays(children, expectedChildren));//$NON-NLS-1$
+ Object[] actualChildren= fProvider.getChildren(fPackJunitSamples);
+ assertTrue("wrong children found for a NON bottom PackageFragment in PackageFragmentRoot Archive", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
}
@Test
- public void testGetChildrenBottomLevelFragmentInArchive() throws Exception{
+ public void testGetChildrenBottomLevelFragmentInArchive() throws Exception {
Object[] expectedChildren= new Object[]{};
- Object[] children= fProvider.getChildren(fPackJunitSamplesMoney);
- assertTrue("wrong children found for a bottom PackageFragment in PackageFragmentRoot Archive", compareArrays(children, expectedChildren)); //$NON-NLS-1$
+ Object[] actualChildren= fProvider.getChildren(fPackJunitSamplesMoney);
+ assertTrue("wrong children found for a bottom PackageFragment in PackageFragmentRoot Archive", compareArrays(actualChildren, expectedChildren)); //$NON-NLS-1$
}
@Test
public void testGetChildrenSourceFolder() throws Exception {
Object[] expectedChildren = new Object[] {fPack21, fPack31, fPackDefault1};
- Object[] children = fProvider.getChildren(fRoot1);
- assertTrue("Wrong children found for PackageFragmentRoot", compareArrays(children, expectedChildren));//$NON-NLS-1$
+ Object[] actualChildren = fProvider.getChildren(fRoot1);
+ assertTrue("Wrong children found for PackageFragmentRoot", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
}
@Test
- public void testGetChildrenArchive(){
- Object[] expectedChildren= new Object[]{fPackJunit, fArchiveFragmentRoot.getPackageFragment("")};//$NON-NLS-1$
- Object[] children= fProvider.getChildren(fArchiveFragmentRoot);
- assertTrue("Wrong child found for PackageFragmentRoot Archive", compareArrays(children,expectedChildren));//$NON-NLS-1$
+ public void testGetChildrenArchive() {
+ Object[] expectedChildren= new Object[] {fPackJunit, fArchiveFragmentRoot.getPackageFragment("")};//$NON-NLS-1$
+ Object[] actualChildren= fProvider.getChildren(fArchiveFragmentRoot);
+ assertTrue("Wrong child found for PackageFragmentRoot Archive", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
}
//---------------Get Parent Tests-----------------------------
@Test
- public void testGetParentArchive() throws Exception{
- Object parent= fProvider.getParent(fArchiveFragmentRoot);
- assertTrue("Wrong parent found for PackageFragmentRoot Archive", parent==null);//$NON-NLS-1$
+ public void testGetParentArchive() throws Exception {
+ Object actualParent= fProvider.getParent(fArchiveFragmentRoot);
+ assertNull("Wrong parent found for PackageFragmentRoot Archive", actualParent);//$NON-NLS-1$
}
@Test
- public void testGetParentMidLevelFragmentInArchive() throws Exception{
-
- //initialise Map
+ public void testGetParentMidLevelFragmentInArchive() throws Exception {
+ // Initialize Map
fProvider.getChildren(fArchiveFragmentRoot);
fProvider.getChildren(fPackJunit);
fProvider.getChildren(fPackJunitSamples);
Object expectedParent= fPackJunitSamples;
- Object parent= fProvider.getParent(fPackJunitSamplesMoney);
- assertTrue("Wrong parent found for a NON top level PackageFragment in an Archive", expectedParent.equals(parent));//$NON-NLS-1$
+ Object actualParent= fProvider.getParent(fPackJunitSamplesMoney);
+ assertEquals("Wrong parent found for a NON top level PackageFragment in an Archive", expectedParent, actualParent);//$NON-NLS-1$
}
@Test
- public void testGetParentTopLevelFragmentInArchive() throws Exception{
+ public void testGetParentTopLevelFragmentInArchive() throws Exception {
Object expectedParent= fPackJunit;
- Object parent= fProvider.getParent(fPackJunitSamples);
- assertTrue("Wrong parent found for a top level PackageFragment in an Archive", expectedParent.equals(parent)); //$NON-NLS-1$
+ Object actualParent= fProvider.getParent(fPackJunitSamples);
+ assertEquals("Wrong parent found for a top level PackageFragment in an Archive", expectedParent, actualParent); //$NON-NLS-1$
}
@Test
- public void testGetParentTopLevelLogicalPackage() throws Exception{
-
+ public void testGetParentTopLevelLogicalPackage() throws Exception {
LogicalPackage cp= new LogicalPackage(fPack31);
cp.add(fPack32);
cp.add(fInternalPack3);
- Object parent= fProvider.getParent(cp);
- assertTrue("Wrong parent found for a top level LogicalPackage", fJProject2.equals(parent));//$NON-NLS-1$
+ Object actualParent= fProvider.getParent(cp);
+ assertEquals("Wrong parent found for a top level LogicalPackage", fJProject2, actualParent);//$NON-NLS-1$
}
@Test
- public void testGetParentPackageFragmentWithLogicalPackageParent() throws Exception{
-
+ public void testGetParentPackageFragmentWithLogicalPackageParent() throws Exception {
LogicalPackage cp= new LogicalPackage(fPack31);
cp.add(fPack32);
cp.add(fInternalPack3);
- //initialize map
+ // Initialize map
fProvider.getChildren(fJProject2);
Object parent= fProvider.getParent(fPack81);
- assertTrue("Wrong parent found for a top level LogicalPackage", cp.equals(parent));//$NON-NLS-1$
+ assertEquals("Wrong parent found for a top level LogicalPackage", cp, parent);//$NON-NLS-1$
}
@Test
- public void testGetParentOfLogicalPackagetWithLogicalPackageParent() throws Exception{
-
+ public void testGetParentOfLogicalPackagetWithLogicalPackageParent() throws Exception {
LogicalPackage cp= new LogicalPackage(fPack41);
cp.add(fPack42);
cp.add(fInternalPack4);
@@ -276,11 +268,11 @@ public class PackagesViewContentProviderTests {
parentCp.add(fPack32);
parentCp.add(fInternalPack3);
- //initialize map
+ // Initialize map
fProvider.getChildren(fJProject2);
Object parent= fProvider.getParent(cp);
- assertTrue("Wrong parent found for a top level LogicalPackage", parentCp.equals(parent));//$NON-NLS-1$
+ assertEquals("Wrong parent found for a top level LogicalPackage", parentCp, parent);//$NON-NLS-1$
}
// public void testGetParentWithPFRootFocus(){
@@ -307,14 +299,14 @@ public class PackagesViewContentProviderTests {
cp.add(fInternalPack3);
Object parent= fProvider.getParent(fPack41);
- assertTrue("Wrong parent found for a mid level Fragment with Root Focus", cp.equals(parent)); //$NON-NLS-1$
+ assertEquals("Wrong parent found for a mid level Fragment with Root Focus", cp, parent); //$NON-NLS-1$
}
@Test
public void testGetParentWithRootFocusAfterProjectFocus(){
//set up map with project focus
- Object[] children= fProvider.getChildren(fJProject2);
- for (Object object : children) {
+ Object[] actualChildren= fProvider.getChildren(fJProject2);
+ for (Object object : actualChildren) {
fProvider.getChildren(object);
}
@@ -329,7 +321,7 @@ public class PackagesViewContentProviderTests {
Object[] expectedChildren= new Object[]{fPack21, fPack12, cp, defaultCp};
- assertTrue("expected children of project with focus", compareArrays(children, expectedChildren));//$NON-NLS-1$
+ assertTrue("expected children of project with focus", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
//set up map with root focus
for (Object object : fProvider.getChildren(fRoot1)) {
@@ -340,18 +332,18 @@ public class PackagesViewContentProviderTests {
}
@Test
- public void testGetParentTopLevelFragment() throws Exception{
- Object parent= fProvider.getParent(fPack21);
+ public void testGetParentTopLevelFragment() throws Exception {
+ Object actualParent= fProvider.getParent(fPack21);
Object expectedParent= fRoot1;
- assertTrue("Wrong parent found for a top level PackageFragment", expectedParent.equals(parent)); //$NON-NLS-1$
+ assertEquals("Wrong parent found for a top level PackageFragment", expectedParent, actualParent); //$NON-NLS-1$
}
@Test
- public void testGetParentMidLevelFragment() throws Exception{
+ public void testGetParentMidLevelFragment() throws Exception {
Object expectedParent= fPack12;
- Object parent= fProvider.getParent(fPack17);
- assertTrue("Wrong parent found for a NON top level PackageFragment", expectedParent.equals(parent)); //$NON-NLS-1$
+ Object actualParent= fProvider.getParent(fPack17);
+ assertEquals("Wrong parent found for a NON top level PackageFragment", expectedParent, actualParent); //$NON-NLS-1$
}
@@ -363,8 +355,8 @@ public class PackagesViewContentProviderTests {
element.setAttribute(CPListElement.INCLUSION, new IPath[] {new Path("pack3/pack5/")});
fJProject2.setRawClasspath(new IClasspathEntry[] {rawClasspath[0], element.getClasspathEntry(), rawClasspath[2]}, null);
Object[] expectedChildren= new Object[]{fPack12.getResource(), fPack32.getResource()};
- Object[] children= fProvider.getChildren(fRoot2);
- assertTrue("Wrong children found for project", compareArrays(children, expectedChildren));//$NON-NLS-1$
+ Object[] actualChildren= fProvider.getChildren(fRoot2);
+ assertTrue("Wrong children found for project", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
}
@Test
@@ -375,8 +367,8 @@ public class PackagesViewContentProviderTests {
element.setAttribute(CPListElement.INCLUSION, new IPath[] {new Path("pack3/pack5/")});
fJProject2.setRawClasspath(new IClasspathEntry[] {rawClasspath[0], element.getClasspathEntry(), rawClasspath[2]}, null);
Object[] expectedChildren= new Object[]{fPack42.getResource(), fPack52};
- Object[] children= fProvider.getChildren(fPack32.getResource());
- assertTrue("Wrong children found for project", compareArrays(children, expectedChildren));//$NON-NLS-1$
+ Object[] actualChildren= fProvider.getChildren(fPack32.getResource());
+ assertTrue("Wrong children found for project", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
}
/*
@@ -402,14 +394,15 @@ public class PackagesViewContentProviderTests {
//------------set up project #1 : External Jar and zip file-------
IPackageFragmentRoot jdk= JavaProjectHelper.addVariableRTJar(fJProject1, "JRE_LIB_TEST", null, null);//$NON-NLS-1$
- assertTrue("jdk not found", jdk != null);//$NON-NLS-1$
+ assertNotNull("jdk not found", jdk);//$NON-NLS-1$
//---Create zip file-------------------
java.io.File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());//$NON-NLS-1$
+ assertNotNull("junit src not found", junitSrcArchive);//$NON-NLS-1$
+ assertTrue("junit src not found", junitSrcArchive.exists());//$NON-NLS-1$
fArchiveFragmentRoot= JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);//$NON-NLS-1$
@@ -432,7 +425,8 @@ public class PackagesViewContentProviderTests {
//----------------Set up internal jar----------------------------
File myInternalJar= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/compoundtest.jar"));//$NON-NLS-1$
- assertTrue("lib not found", myInternalJar != null && myInternalJar.exists());//$NON-NLS-1$
+ assertNotNull("lib not found", myInternalJar);//$NON-NLS-1$
+ assertTrue("lib not found", myInternalJar.exists());//$NON-NLS-1$
fInternalJarRoot= JavaProjectHelper.addLibraryWithImport(fJProject2, Path.fromOSString(myInternalJar.getPath()), null, null);
@@ -481,7 +475,7 @@ public class PackagesViewContentProviderTests {
setUpMockView();
}
- public void setUpMockView() throws Exception{
+ public void setUpMockView() throws Exception {
fWorkbench= PlatformUI.getWorkbench();
assertNotNull(fWorkbench);
@@ -497,7 +491,7 @@ public class PackagesViewContentProviderTests {
//create map and set listener
fProvider.inputChanged(null,null,fJProject2);
} else {
- assertTrue("Unable to get view",false);//$NON-NLS-1$
+ fail("Unable to get view");//$NON-NLS-1$
}
assertNotNull(fProvider);
@@ -508,7 +502,6 @@ public class PackagesViewContentProviderTests {
*/
@After
public void tearDown() throws Exception {
-
JavaProjectHelper.delete(fJProject1);
JavaProjectHelper.delete(fJProject2);
fProvider.inputChanged(null, null, null);
@@ -516,13 +509,12 @@ public class PackagesViewContentProviderTests {
if (fEnableAutoBuildAfterTesting)
CoreUtility.setAutoBuilding(true);
-
-
}
private boolean compareArrays(Object[] children, Object[] expectedChildren) {
if(children.length!=expectedChildren.length)
return false;
+
for (Object child : children) {
if (child instanceof IJavaElement) {
IJavaElement el= (IJavaElement) child;
@@ -538,6 +530,7 @@ public class PackagesViewContentProviderTests {
return false;
}
}
+
return true;
}
@@ -549,6 +542,7 @@ public class PackagesViewContentProviderTests {
return true;
}
}
+
return false;
}
@@ -560,6 +554,7 @@ public class PackagesViewContentProviderTests {
return true;
}
}
+
return false;
}
@@ -571,7 +566,7 @@ public class PackagesViewContentProviderTests {
return true;
}
}
+
return false;
}
-
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests2.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests2.java
index 425b9bc4d2..e8ec8a86e0 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests2.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewContentProviderTests2.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.browsing;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -176,11 +178,12 @@ public class PackagesViewContentProviderTests2 {
fMyPart.pushDisplay();
//assert remove happened (delta worked)
- assertTrue("Refresh happened", fMyPart.hasRemoveHappened() && fMyPart.hasAddHappened()); //$NON-NLS-1$
+ assertTrue("Refresh happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$
+ assertTrue("Refresh happened", fMyPart.hasAddHappened()); //$NON-NLS-1$
Object addedObject= fMyPart.getAddedObject().get(0);
Object removedObject= fMyPart.getRemovedObject().get(0);
assertTrue("Correct guy removed", canFindEqualCompoundElement(cp10, new Object[] { removedObject })); //$NON-NLS-1$
- assertTrue("Correct guy added", fInternalPack10.equals(addedObject)); //$NON-NLS-1$
+ assertEquals("Correct guy added", fInternalPack10, addedObject); //$NON-NLS-1$
}
@Test
@@ -200,7 +203,7 @@ public class PackagesViewContentProviderTests2 {
fMyPart.pushDisplay();
//assert remove happened (delta worked)
- assertTrue("Refresh did not happened", !fMyPart.hasRefreshHappened()); //$NON-NLS-1$
+ assertFalse("Refresh did not happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$
}
@Test
@@ -226,10 +229,8 @@ public class PackagesViewContentProviderTests2 {
private void assertPack81RefreshedOnce() {
assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$
- if (! fMyPart.getRefreshedObject().contains(fPack81))
- fail("fPack81 not refreshed:\n" + fMyPart.getRefreshedObject());
- if (fMyPart.getRefreshedObject().size() != 1)
- fail("Too many refreshes (" + fMyPart.getRefreshedObject().size() + "):\n" + fMyPart.getRefreshedObject());
+ assertTrue("fPack81 not refreshed:\n" + fMyPart.getRefreshedObject(), fMyPart.getRefreshedObject().contains(fPack81));
+ assertEquals("Too many refreshes (" + fMyPart.getRefreshedObject().size() + "):\n" + fMyPart.getRefreshedObject(), 1, fMyPart.getRefreshedObject().size());
}
@Test
@@ -251,10 +252,8 @@ public class PackagesViewContentProviderTests2 {
assertPack81RefreshedOnce();
assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$
- if (! fMyPart.getRefreshedObject().contains(fPack81))
- fail("fPack81 not refreshed:\n" + fMyPart.getRefreshedObject());
- if (fMyPart.getRefreshedObject().size() != 1)
- fail("Too many refreshes (" + fMyPart.getRefreshedObject().size() + "):\n" + fMyPart.getRefreshedObject());
+ assertTrue("fPack81 not refreshed:\n" + fMyPart.getRefreshedObject(), fMyPart.getRefreshedObject().contains(fPack81));
+ assertEquals("Too many refreshes (" + fMyPart.getRefreshedObject().size() + "):\n" + fMyPart.getRefreshedObject(), 1, fMyPart.getRefreshedObject().size());
}
@Test
@@ -277,7 +276,7 @@ public class PackagesViewContentProviderTests2 {
fMyPart.pushDisplay();
//make sure no refresh happened
- assertTrue("Refresh did not happened", !fMyPart.hasRefreshHappened()); //$NON-NLS-1$
+ assertFalse("Refresh did not happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$
}
@Test
@@ -323,11 +322,12 @@ public class PackagesViewContentProviderTests2 {
fMyPart.pushDisplay();
//assert remove and add happened (delta worked)
- assertTrue("Remove and add happened", fMyPart.hasRemoveHappened() && fMyPart.hasAddHappened()); //$NON-NLS-1$
+ assertTrue("Remove and add happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$
+ assertTrue("Remove and add happened", fMyPart.hasAddHappened()); //$NON-NLS-1$
Object addedObject= fMyPart.getAddedObject().get(0);
Object removedObject= fMyPart.getRemovedObject().get(0);
- assertTrue("Correct guy removed", fPack12.equals(removedObject)); //$NON-NLS-1$
- assertTrue("Correct guy added", lp1.equals(addedObject) ); //$NON-NLS-1$
+ assertEquals("Correct guy removed", fPack12, removedObject); //$NON-NLS-1$
+ assertEquals("Correct guy added", lp1, addedObject); //$NON-NLS-1$
}
@@ -355,14 +355,15 @@ public class PackagesViewContentProviderTests2 {
//------------set up project #1 : External Jar and zip file-------
IPackageFragmentRoot jdk= JavaProjectHelper.addVariableRTJar(fJProject1, "JRE_LIB_TEST", null, null);//$NON-NLS-1$
- assertTrue("jdk not found", jdk != null);//$NON-NLS-1$
+ assertNotNull("jdk not found", jdk);//$NON-NLS-1$
//---Create zip file-------------------
java.io.File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());//$NON-NLS-1$
+ assertNotNull("junit src not found", junitSrcArchive);//$NON-NLS-1$
+ assertTrue("junit src not found", junitSrcArchive.exists());//$NON-NLS-1$
fArchiveFragmentRoot= JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);//$NON-NLS-1$
@@ -385,7 +386,8 @@ public class PackagesViewContentProviderTests2 {
//----------------Set up internal jar----------------------------
File myInternalJar= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/compoundtest.jar"));//$NON-NLS-1$
- assertTrue("lib not found", myInternalJar != null && myInternalJar.exists());//$NON-NLS-1$
+ assertNotNull("lib not found", myInternalJar);//$NON-NLS-1$
+ assertTrue("lib not found", myInternalJar.exists());//$NON-NLS-1$
fInternalJarRoot= JavaProjectHelper.addLibraryWithImport(fJProject2, Path.fromOSString(myInternalJar.getPath()), null, null);
@@ -453,7 +455,7 @@ public class PackagesViewContentProviderTests2 {
fProvider.inputChanged(null,null,fJProject2);
JavaCore.removeElementChangedListener((IElementChangedListener) fProvider);
} else {
- assertTrue("Unable to get view",false);//$NON-NLS-1$
+ fail("Unable to get view");//$NON-NLS-1$
}
assertNotNull(fProvider);
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewDeltaTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewDeltaTests.java
index e6fe4fd693..0215213bc6 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewDeltaTests.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/browsing/PackagesViewDeltaTests.java
@@ -14,8 +14,10 @@
package org.eclipse.jdt.ui.tests.browsing;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
@@ -53,9 +55,7 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.ui.browsing.LogicalPackage;
import org.eclipse.jdt.internal.ui.util.CoreUtility;
-
public class PackagesViewDeltaTests {
-
private IJavaProject fJProject;
private IPackageFragmentRoot fRoot1;
@@ -92,13 +92,12 @@ public class PackagesViewDeltaTests {
@Test
public void testRemoveTopLevelFragmentNotLogicalPackage() throws Exception {
-
- //create a logical package for packages with name "pack3"
+ // Create a logical package for packages with name "pack3"
LogicalPackage cp3= new LogicalPackage(fPack31);
cp3.add(fPack32);
cp3.add(fInternalPack3);
- //initialise Map
+ // Initialize Map
fMyPart.fViewer.setInput(fJProject);
fProvider.getChildren(cp3);
@@ -108,7 +107,7 @@ public class PackagesViewDeltaTests {
IJavaElementDelta delta= new TestDelta(IJavaElementDelta.REMOVED, fPack12);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
fMyPart.pushDisplay();
assertTrue("Remove happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$
@@ -117,8 +116,7 @@ public class PackagesViewDeltaTests {
@Test
public void testRemoveBottomLevelFragmentNotLogicalPackage() throws Exception {
-
- //initialise Map
+ // Initialize Map
fMyPart.fViewer.setInput(fJProject);
fMyPart.clear();
@@ -127,147 +125,142 @@ public class PackagesViewDeltaTests {
IJavaElementDelta delta= new TestDelta(IJavaElementDelta.REMOVED, fPack42);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
fMyPart.pushDisplay();
- assertTrue("No remove happened, in Logical Package", !fMyPart.hasRemoveHappened()); //$NON-NLS-1$
+ assertFalse("No remove happened, in Logical Package", fMyPart.hasRemoveHappened()); //$NON-NLS-1$
}
- //This is a bogus test because this situation could never occure
+ //This is a bogus test because this situation could never occur
//while fPack42 exists you cannot remove fPack32 still it tests
- //correct delta handeling.
+ //correct delta handling.
@Test
public void testRemoveFragmentInMultiFragmentLogicalPackage() throws Exception {
-
- //initialise the map
+ // Initialize the map
fMyPart.fViewer.setInput(fJProject);
for (Object object : fProvider.getChildren(fJProject)) {
fProvider.getChildren(object);
}
- //create a logical package with name "pack3"
+ // Create a logical package with name "pack3"
LogicalPackage expectedParent= new LogicalPackage(fPack31);
expectedParent.add(fInternalPack3);
- //create a logical package with name "pack3.pack4"
+ // Create a logical package with name "pack3.pack4"
LogicalPackage ChildCp1= new LogicalPackage(fPack41);
ChildCp1.add(fPack42);
ChildCp1.add(fInternalPack4);
fMyPart.clear();
- //delete a fragment
+ // Delete a fragment
IElementChangedListener listener= (IElementChangedListener) fProvider;
IJavaElementDelta delta= new TestDelta(IJavaElementDelta.REMOVED, fPack32);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
fMyPart.pushDisplay();
- //assert remove happened
- assertTrue("Refresh happened", !fMyPart.hasRemoveHappened() && !fMyPart.hasRefreshHappened()); //$NON-NLS-1$
+ // Assert remove happened
+ assertFalse("Remove happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$
+ assertFalse("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$
- //test life cycle of Logical Package
+ // Test life cycle of Logical Package
Object parent= fProvider.getParent(ChildCp1);
- if (!(parent instanceof LogicalPackage)) {
- assertTrue("wrong parent found for logical package after remove", false); //$NON-NLS-1$
- }
+ assertTrue("wrong parent found for logical package after remove", parent instanceof LogicalPackage);
LogicalPackage lp= (LogicalPackage) parent;
- assertTrue("PackageFragment removed from logical package", lp.equals(expectedParent)); //$NON-NLS-1$
-
+ assertEquals("PackageFragment removed from logical package", expectedParent, lp); //$NON-NLS-1$
}
@Test
public void testRemoveBottomLevelFragmentInMultiFragmentLogicalPackage() throws Exception {
-
- //delete a fragment
+ // Delete a fragment
fPack62.delete(true, null);
- //create a logical package child of cp with name "pack3.pack5.pack6"
+ // Create a logical package child of cp with name "pack3.pack5.pack6"
LogicalPackage expectedChild= new LogicalPackage(fPack61);
expectedChild.add(fInternalPack6);
- //create a logical package child of cp with name "pack3.pack5"
+ // Create a logical package child of cp with name "pack3.pack5"
LogicalPackage ParentCp5= new LogicalPackage(fPack51);
ParentCp5.add(fPack52);
ParentCp5.add(fInternalPack5);
- //create a logical package for packages with name "pack3"
+ // Create a logical package for packages with name "pack3"
LogicalPackage cp3= new LogicalPackage(fPack31);
cp3.add(fPack32);
cp3.add(fInternalPack3);
- //initialise map
+ // Initialize map
fProvider.getChildren(fJProject);
fProvider.getChildren(cp3);
fProvider.getChildren(ParentCp5);
fMyPart.clear();
- //send a delta indicating fragment deleted
+ // Send a delta indicating fragment deleted
IElementChangedListener listener= (IElementChangedListener) fProvider;
IJavaElementDelta delta= new TestDelta(IJavaElementDelta.REMOVED, fPack62);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
fMyPart.pushDisplay();
- //assert delta correct (no remove or refresh, only change to logicalpackage)
- assertTrue("Refresh happened", !fMyPart.hasRefreshHappened() && !fMyPart.hasRemoveHappened()); //$NON-NLS-1$
+ // Assert delta correct (no remove or refresh, only change to logicalpackage)
+ assertFalse("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$
+ assertFalse("Refresh happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$
- //test life cycle of LogicalPackage
+ // Test life cycle of LogicalPackage
Object[] child= fProvider.getChildren(ParentCp5);
- if ((child.length != 1) || (!(child[0] instanceof LogicalPackage))) {
- assertTrue("wrong parent found for logical package after remove", false); //$NON-NLS-1$
- }
+ assertTrue("wrong parent found for logical package after remove", (child.length == 1) && (child[0] instanceof LogicalPackage)); //$NON-NLS-1$
LogicalPackage lp= (LogicalPackage) child[0];
- assertTrue("PackageFragment removed from logical package", lp.equals(expectedChild)); //$NON-NLS-1$
+ assertEquals("PackageFragment removed from logical package", expectedChild, lp); //$NON-NLS-1$
}
@Test
public void testRemoveFragmentInTwoFragmentLogicalPackage() throws Exception {
-
- //create a logical package child of cp
+ // Create a logical package child of cp
LogicalPackage ParentCp4= new LogicalPackage(fPack41);
ParentCp4.add(fPack42);
ParentCp4.add(fInternalPack4);
- //create a logical package for packages with name "pack3"
+ // Create a logical package for packages with name "pack3"
LogicalPackage cp3= new LogicalPackage(fPack31);
cp3.add(fPack32);
cp3.add(fInternalPack3);
- //initialise map
+ // Initialize map
fProvider.getChildren(fJProject);
fProvider.getChildren(cp3);
fProvider.getChildren(ParentCp4);
- //create logical package with name "pack3.pack4.pack10"
+ // Create logical package with name "pack3.pack4.pack10"
LogicalPackage cp10= new LogicalPackage(fInternalPack10);
- //delete fragment
+ // Delete fragment
fPack102.delete(true, null);
fMyPart.clear();
- //send a delta indicating fragment deleted
+ // Send a delta indicating fragment deleted
IElementChangedListener listener= (IElementChangedListener) fProvider;
IJavaElementDelta delta= new TestDelta(IJavaElementDelta.REMOVED, fPack102);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
fMyPart.pushDisplay();
- //assert remove happened (delta worked)
- assertTrue("Refresh happened", fMyPart.hasRemoveHappened() && fMyPart.hasAddHappened()); //$NON-NLS-1$
+ // Assert remove happened (delta worked)
+ assertTrue("Refresh happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$
+ assertTrue("Refresh happened", fMyPart.hasAddHappened()); //$NON-NLS-1$
Object addedObject= fMyPart.getAddedObject().get(0);
Object removedObject= fMyPart.getRemovedObject().get(0);
- assertTrue("Correct guy removed", cp10.equals(removedObject)); //$NON-NLS-1$
- assertTrue("Correct guy added", fInternalPack10.equals(addedObject)); //$NON-NLS-1$
+ assertEquals("Correct guy removed", cp10, removedObject); //$NON-NLS-1$
+ assertEquals("Correct guy added", fInternalPack10, addedObject); //$NON-NLS-1$
- //assert correct children gotten
+ // Assert correct children gotten
Object[] children= fProvider.getChildren(ParentCp4);
assertTrue("PackageFragment removed from logial package", compareArrays(children, new Object[] { fPack91, fInternalPack10 })); //$NON-NLS-1$
}
@@ -275,8 +268,7 @@ public class PackagesViewDeltaTests {
//-----------------------Add delta test cases----------------------------------
@Test
public void testAddTopLevelFragmentNotLogicalPackage() throws Exception {
-
- //initialise Map
+ // Initialize Map
fMyPart.fViewer.setInput(fJProject);
fMyPart.clear();
@@ -286,7 +278,7 @@ public class PackagesViewDeltaTests {
IJavaElementDelta delta= new TestDelta(IJavaElementDelta.ADDED, test);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
fMyPart.pushDisplay();
assertTrue("Add happened", fMyPart.hasAddHappened()); //$NON-NLS-1$
@@ -295,39 +287,37 @@ public class PackagesViewDeltaTests {
@Test
public void testAddFragmentToLogicalPackage() throws Exception {
-
- //create a logical package with name "pack3.pack4"
+ // Create a logical package with name "pack3.pack4"
LogicalPackage cp4= new LogicalPackage(fPack41);
cp4.add(fPack42);
cp4.add(fInternalPack4);
- //initialise Map
+ // Initialize Map
fProvider.getChildren(cp4);
- //send delta
+ // Send delta
IPackageFragment pack101= fRoot1.createPackageFragment("pack3.pack4.pack10", true, null); //$NON-NLS-1$
IElementChangedListener listener= (IElementChangedListener) fProvider;
IJavaElementDelta delta= new TestDelta(IJavaElementDelta.ADDED, pack101);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
fMyPart.pushDisplay();
- //make sure no refresh happened
- assertTrue("Refresh did not happened", !fMyPart.hasRefreshHappened()); //$NON-NLS-1$
+ // Make sure no refresh happened
+ assertFalse("Refresh did not happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$
}
@Test
public void testAddCUFromFragmentNotLogicalPackageVisible() throws Exception {
-
- //create a logical package for packages with name "pack3"
+ // Create a logical package for packages with name "pack3"
LogicalPackage cp3= new LogicalPackage(fPack31);
cp3.add(fPack32);
cp3.add(fInternalPack3);
ICompilationUnit cu= fPack81.createCompilationUnit("Object.java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
- //initialise Map
+ // Initialize Map
fMyPart.fViewer.setInput(fJProject);
fProvider.getChildren(cp3);
@@ -339,7 +329,7 @@ public class PackagesViewDeltaTests {
IJavaElementDelta delta= TestDelta.createCUDelta(new ICompilationUnit[] { cu }, fPack81, IJavaElementDelta.ADDED);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
fMyPart.pushDisplay();
assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$
@@ -349,15 +339,14 @@ public class PackagesViewDeltaTests {
@Test
public void testAddCUFromFragmentNotLogicalPackageNotVisible() throws Exception {
-
- //create a logical package for packages with name "pack3"
+ // Create a logical package for packages with name "pack3"
LogicalPackage cp3= new LogicalPackage(fPack31);
cp3.add(fPack32);
cp3.add(fInternalPack3);
ICompilationUnit cu= fPack81.createCompilationUnit("Object.java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
- //initialise Map
+ // Initialize Map
fMyPart.fViewer.setInput(fJProject);
fProvider.getChildren(cp3);
@@ -367,7 +356,7 @@ public class PackagesViewDeltaTests {
IJavaElementDelta delta= TestDelta.createCUDelta(new ICompilationUnit[] { cu }, fPack81, IJavaElementDelta.ADDED);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
fMyPart.pushDisplay();
assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$
@@ -377,19 +366,18 @@ public class PackagesViewDeltaTests {
@Test
public void testRemoveCUFromFragmentNotLogicalPackage() throws Exception {
-
- //create a logical package for packages with name "pack3"
+ // Create a logical package for packages with name "pack3"
LogicalPackage cp3= new LogicalPackage(fPack31);
cp3.add(fPack32);
cp3.add(fInternalPack3);
- //initialise Map
+ // Initialize Map
fMyPart.fViewer.setInput(fJProject);
fProvider.getChildren(cp3);
ICompilationUnit cu= fPack81.createCompilationUnit("Object.java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
- //make sure parent is visible
+ // Make sure parent is visible
fMyPart.fViewer.setInput(fJProject);
fMyPart.fViewer.reveal(fPack81);
@@ -399,7 +387,7 @@ public class PackagesViewDeltaTests {
IJavaElementDelta delta= TestDelta.createCUDelta(new ICompilationUnit[] { cu }, fPack81, IJavaElementDelta.REMOVED);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
fMyPart.pushDisplay();
assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$
@@ -409,13 +397,12 @@ public class PackagesViewDeltaTests {
@Test
public void testRemoveCUFromFragmentNotLogicalPackageWithParentNotVisible() throws Exception {
-
- //create a logical package for packages with name "pack3"
+ // Create a logical package for packages with name "pack3"
LogicalPackage cp3= new LogicalPackage(fPack31);
cp3.add(fPack32);
cp3.add(fInternalPack3);
- //initialise Map
+ // Initialize Map
fMyPart.fViewer.setInput(fJProject);
fProvider.getChildren(cp3);
@@ -427,7 +414,7 @@ public class PackagesViewDeltaTests {
IJavaElementDelta delta= TestDelta.createCUDelta(new ICompilationUnit[] { cu }, fPack81, IJavaElementDelta.REMOVED);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
fMyPart.pushDisplay();
assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$
@@ -437,13 +424,12 @@ public class PackagesViewDeltaTests {
@Test
public void testAddBottomLevelFragmentNotLogicalPackage() throws Exception {
-
- //create a logical package for packages with name "pack3"
+ // Create a logical package for packages with name "pack3"
LogicalPackage cp3= new LogicalPackage(fPack31);
cp3.add(fPack32);
cp3.add(fInternalPack3);
- //initialise Map
+ // Initialize Map
fMyPart.fViewer.setInput(fJProject);
fProvider.getChildren(cp3);
@@ -454,12 +440,13 @@ public class PackagesViewDeltaTests {
IJavaElementDelta delta= new TestDelta(IJavaElementDelta.ADDED, test);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
fMyPart.pushDisplay();
assertTrue("Add happened", fMyPart.hasAddHappened()); //$NON-NLS-1$
assertTrue("Corrent package added", fMyPart.getAddedObject().contains(test)); //$NON-NLS-1$
}
+
/*
* @see TestCase#setUp()
*/
@@ -479,7 +466,8 @@ public class PackagesViewDeltaTests {
//----------------Set up internal jar----------------------------
File myInternalJar= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/compoundtest.jar")); //$NON-NLS-1$
- assertTrue("lib not found", myInternalJar != null && myInternalJar.exists()); //$NON-NLS-1$
+ assertNotNull("lib not found", myInternalJar); //$NON-NLS-1$
+ assertTrue("lib not found", myInternalJar.exists()); //$NON-NLS-1$
fInternalJarRoot= JavaProjectHelper.addLibraryWithImport(fJProject, Path.fromOSString(myInternalJar.getPath()), null, null);
fInternalJarRoot.getPackageFragment(""); //$NON-NLS-1$
fInternalPack3= fInternalJarRoot.getPackageFragment("pack3"); //$NON-NLS-1$
@@ -503,12 +491,12 @@ public class PackagesViewDeltaTests {
fPack12.createCompilationUnit("Object.java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
fPack62.createCompilationUnit("Object.java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
- //so that fPack52 won't get deleted when we delete fPack62 in certain tests
+ // So that fPack52 won't get deleted when we delete fPack62 in certain tests
fPack52.createCompilationUnit("Object.java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
- //so that fPack42 won't get deleted when we delete fPack102 in certain tests
+ // So that fPack42 won't get deleted when we delete fPack102 in certain tests
fPack42.createCompilationUnit("Object.java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
- //set up project #2: file system structure with in a source folder
+ // Set up project #2: file system structure with in a source folder
// JavaProjectHelper.addVariableEntry(fJProject2, new Path("JRE_LIB_TEST"), null, null);
@@ -527,11 +515,11 @@ public class PackagesViewDeltaTests {
fPack21.createCompilationUnit("Object.java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
fPack61.createCompilationUnit("Object.java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
- //set up the mock view
+ // Set up the mock view
setUpMockView();
}
- public void setUpMockView() throws Exception {
+ public void setUpMockView() throws Exception {
fWorkbench= PlatformUI.getWorkbench();
assertNotNull(fWorkbench);
@@ -545,7 +533,7 @@ public class PackagesViewDeltaTests {
fProvider= (ITreeContentProvider) fMyPart.getTreeViewer().getContentProvider();
JavaCore.removeElementChangedListener((IElementChangedListener) fProvider);
} else {
- assertTrue("Unable to get view", false); //$NON-NLS-1$
+ fail("Unable to get view"); //$NON-NLS-1$
}
assertNotNull(fProvider);
@@ -556,7 +544,6 @@ public class PackagesViewDeltaTests {
*/
@After
public void tearDown() throws Exception {
-
JavaProjectHelper.delete(fJProject);
fProvider.inputChanged(null, null, null);
fPage.hideView(fMyPart);
@@ -575,6 +562,7 @@ public class PackagesViewDeltaTests {
private boolean compareArrays(Object[] children, Object[] expectedChildren) {
if (children.length != expectedChildren.length)
return false;
+
for (Object child : children) {
if (child instanceof IJavaElement) {
IJavaElement el= (IJavaElement) child;
@@ -590,6 +578,7 @@ public class PackagesViewDeltaTests {
return false;
}
}
+
return true;
}
@@ -601,6 +590,7 @@ public class PackagesViewDeltaTests {
return true;
}
}
+
return false;
}
@@ -612,6 +602,7 @@ public class PackagesViewDeltaTests {
return true;
}
}
+
return false;
}
@@ -623,6 +614,7 @@ public class PackagesViewDeltaTests {
return true;
}
}
+
return false;
}
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/callhierarchy/CallHierarchyContentProviderTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/callhierarchy/CallHierarchyContentProviderTest.java
index 39d5c622ed..9b60b84e32 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/callhierarchy/CallHierarchyContentProviderTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/callhierarchy/CallHierarchyContentProviderTest.java
@@ -15,6 +15,7 @@
package org.eclipse.jdt.ui.tests.callhierarchy;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -75,17 +76,17 @@ public class CallHierarchyContentProviderTest{
assertEquals("Wrong number of children", 1, children.length);
helper.assertCalls(new IMember[] { helper.getMethod4()}, children);
assertEquals("Wrong method", helper.getMethod4(), ((MethodWrapper) children[0]).getMember());
- assertEquals("root's hasChildren", true, fProvider.hasChildren(root));
+ assertTrue("root's hasChildren", fProvider.hasChildren(root));
Object[] secondLevelChildren= fProvider.getChildren(children[0]);
helper.assertCalls(new IMember[] { helper.getMethod3()}, secondLevelChildren);
assertCalleeMethodWrapperChildren(secondLevelChildren);
- assertEquals("second level hasChildren", true, fProvider.hasChildren(children[0]));
+ assertTrue("second level hasChildren", fProvider.hasChildren(children[0]));
Object[] thirdLevelChildren= fProvider.getChildren(secondLevelChildren[0]);
helper.assertCalls(new IMember[] { helper.getMethod1(), helper.getMethod2()}, thirdLevelChildren);
assertCalleeMethodWrapperChildren(thirdLevelChildren);
- assertEquals("third level hasChildren", true, fProvider.hasChildren(secondLevelChildren[0]));
+ assertTrue("third level hasChildren", fProvider.hasChildren(secondLevelChildren[0]));
MethodWrapper fourthLevelMethodWrapper= helper.findMethodWrapper(helper.getMethod1(), thirdLevelChildren);
assertNotNull("method1 not found", fourthLevelMethodWrapper);
@@ -94,7 +95,7 @@ public class CallHierarchyContentProviderTest{
0,
fProvider.getChildren(fourthLevelMethodWrapper).length);
// hasChildren should be true even if the node doesn't have children (for performance reasons)
- assertEquals("fourth level hasChildren", true, fProvider.hasChildren(fourthLevelMethodWrapper));
+ assertTrue("fourth level hasChildren", fProvider.hasChildren(fourthLevelMethodWrapper));
}
/**
@@ -110,23 +111,23 @@ public class CallHierarchyContentProviderTest{
TreeRoot root= wrapCallerRoot(helper.getMethod1());
Object[] children= fProvider.getChildren(root);
helper.assertCalls(new IMember[] { helper.getMethod1()}, children);
- assertEquals("root's hasChildren", true, fProvider.hasChildren(root));
+ assertTrue("root's hasChildren", fProvider.hasChildren(root));
Object[] secondLevelChildren= fProvider.getChildren(children[0]);
helper.assertCalls(new IMember[] { helper.getMethod2(), helper.getMethod3()}, secondLevelChildren);
assertCallerMethodWrapperChildren(secondLevelChildren);
- assertEquals("second level hasChildren", true, fProvider.hasChildren(children[0]));
+ assertTrue("second level hasChildren", fProvider.hasChildren(children[0]));
MethodWrapper thirdLevelMethodWrapper= helper.findMethodWrapper(helper.getMethod3(), secondLevelChildren);
assertNotNull("method3() not found", thirdLevelMethodWrapper);
Object[] thirdLevelChildren= fProvider.getChildren(thirdLevelMethodWrapper);
helper.assertCalls(new IMember[] { helper.getMethod4()}, thirdLevelChildren);
assertCallerMethodWrapperChildren(thirdLevelChildren);
- assertEquals("third level hasChildren", true, fProvider.hasChildren(thirdLevelMethodWrapper));
+ assertTrue("third level hasChildren", fProvider.hasChildren(thirdLevelMethodWrapper));
assertEquals("Wrong number of fourth level children", 0, fProvider.getChildren(thirdLevelChildren[0]).length);
// hasChildren should be true even if the node doesn't have children (for performance reasons)
- assertEquals("fourth level hasChildren", true, fProvider.hasChildren(thirdLevelChildren[0]));
+ assertTrue("fourth level hasChildren", fProvider.hasChildren(thirdLevelChildren[0]));
}
/**
@@ -144,23 +145,23 @@ public class CallHierarchyContentProviderTest{
TreeRoot root= wrapCallerRoot(helper.getMethod1());
Object[] children= fProvider.getChildren(root);
helper.assertCalls(new IMember[] { helper.getMethod1()}, children);
- assertEquals("root's hasChildren", true, fProvider.hasChildren(root));
+ assertTrue("root's hasChildren", fProvider.hasChildren(root));
Object[] secondLevelChildren= fProvider.getChildren(children[0]);
helper.assertCalls(new IMember[] { helper.getMethod2(), helper.getMethod3()}, secondLevelChildren);
assertCallerMethodWrapperChildren(secondLevelChildren);
- assertEquals("second level hasChildren", true, fProvider.hasChildren(children[0]));
+ assertTrue("second level hasChildren", fProvider.hasChildren(children[0]));
MethodWrapper thirdLevelMethodWrapper= helper.findMethodWrapper(helper.getMethod3(), secondLevelChildren);
assertNotNull("method3() not found", thirdLevelMethodWrapper);
Object[] thirdLevelChildren= fProvider.getChildren(thirdLevelMethodWrapper);
helper.assertCalls(new IMember[] { helper.getMethod4()}, thirdLevelChildren);
assertCallerMethodWrapperChildren(thirdLevelChildren);
- assertEquals("third level hasChildren", true, fProvider.hasChildren(thirdLevelMethodWrapper));
+ assertTrue("third level hasChildren", fProvider.hasChildren(thirdLevelMethodWrapper));
assertEquals("Wrong number of fourth level children", 0, fProvider.getChildren(thirdLevelChildren[0]).length);
// hasChildren should be false since the maximum depth has been reached
- assertEquals("fourth level hasChildren", false, fProvider.hasChildren(thirdLevelChildren[0]));
+ assertFalse("fourth level hasChildren", fProvider.hasChildren(thirdLevelChildren[0]));
}
/**
@@ -180,17 +181,17 @@ public class CallHierarchyContentProviderTest{
assertEquals("Wrong number of children", 1, children.length);
helper.assertCalls(new IMember[] { helper.getMethod4()}, children);
assertEquals("Wrong method", helper.getMethod4(), ((MethodWrapper) children[0]).getMember());
- assertEquals("root's hasChildren", true, fProvider.hasChildren(root));
+ assertTrue("root's hasChildren", fProvider.hasChildren(root));
Object[] secondLevelChildren= fProvider.getChildren(children[0]);
helper.assertCalls(new IMember[] { helper.getMethod3()}, secondLevelChildren);
assertCalleeMethodWrapperChildren(secondLevelChildren);
- assertEquals("second level hasChildren", true, fProvider.hasChildren(children[0]));
+ assertTrue("second level hasChildren", fProvider.hasChildren(children[0]));
Object[] thirdLevelChildren= fProvider.getChildren(secondLevelChildren[0]);
helper.assertCalls(new IMember[] { helper.getMethod1(), helper.getMethod2()}, thirdLevelChildren);
assertCalleeMethodWrapperChildren(thirdLevelChildren);
- assertEquals("third level hasChildren", true, fProvider.hasChildren(secondLevelChildren[0]));
+ assertTrue("third level hasChildren", fProvider.hasChildren(secondLevelChildren[0]));
MethodWrapper fourthLevelMethodWrapper= helper.findMethodWrapper(helper.getMethod1(), thirdLevelChildren);
assertNotNull("method1 not found", fourthLevelMethodWrapper);
@@ -199,7 +200,7 @@ public class CallHierarchyContentProviderTest{
0,
fProvider.getChildren(fourthLevelMethodWrapper).length);
// hasChildren should be false since the maximum depth has been reached
- assertEquals("fourth level hasChildren", false, fProvider.hasChildren(thirdLevelChildren[0]));
+ assertFalse("fourth level hasChildren", fProvider.hasChildren(thirdLevelChildren[0]));
}
/**
@@ -215,12 +216,12 @@ public class CallHierarchyContentProviderTest{
TreeRoot root= wrapCalleeRoot(helper.getRecursiveMethod1());
Object[] children= fProvider.getChildren(root);
helper.assertCalls(new IMember[] { helper.getRecursiveMethod1()}, children);
- assertEquals("root's hasChildren", true, fProvider.hasChildren(root));
+ assertTrue("root's hasChildren", fProvider.hasChildren(root));
Object[] secondLevelChildren= fProvider.getChildren(children[0]);
helper.assertCalls(new IMember[] { helper.getRecursiveMethod2()}, secondLevelChildren);
assertCalleeMethodWrapperChildren(secondLevelChildren);
- assertEquals("second level hasChildren", true, fProvider.hasChildren(children[0]));
+ assertTrue("second level hasChildren", fProvider.hasChildren(children[0]));
MethodWrapper thirdLevelMethodWrapper= (MethodWrapper) secondLevelChildren[0];
Object[] thirdLevelChildren= fProvider.getChildren(thirdLevelMethodWrapper);
@@ -228,7 +229,7 @@ public class CallHierarchyContentProviderTest{
assertCalleeMethodWrapperChildren(thirdLevelChildren);
// A recursion should have occurred, resulting in hasChildren = false
- assertEquals("third level hasChildren", false, fProvider.hasChildren(thirdLevelChildren[0]));
+ assertFalse("third level hasChildren", fProvider.hasChildren(thirdLevelChildren[0]));
}
/**
@@ -244,12 +245,12 @@ public class CallHierarchyContentProviderTest{
TreeRoot root= wrapCallerRoot(helper.getRecursiveMethod1());
Object[] children= fProvider.getChildren(root);
helper.assertCalls(new IMember[] { helper.getRecursiveMethod1()}, children);
- assertEquals("root's hasChildren", true, fProvider.hasChildren(root));
+ assertTrue("root's hasChildren", fProvider.hasChildren(root));
Object[] secondLevelChildren= fProvider.getChildren(children[0]);
helper.assertCalls(new IMember[] { helper.getRecursiveMethod2()}, secondLevelChildren);
assertCallerMethodWrapperChildren(secondLevelChildren);
- assertEquals("second level hasChildren", true, fProvider.hasChildren(children[0]));
+ assertTrue("second level hasChildren", fProvider.hasChildren(children[0]));
MethodWrapper thirdLevelMethodWrapper= (MethodWrapper) secondLevelChildren[0];
Object[] thirdLevelChildren= fProvider.getChildren(thirdLevelMethodWrapper);
@@ -257,7 +258,7 @@ public class CallHierarchyContentProviderTest{
assertCallerMethodWrapperChildren(thirdLevelChildren);
// A recursion should have occurred, resulting in hasChildren = false
- assertEquals("third level hasChildren", false, fProvider.hasChildren(thirdLevelChildren[0]));
+ assertFalse("third level hasChildren", fProvider.hasChildren(thirdLevelChildren[0]));
}
private void assertCalleeMethodWrapperChildren(Object[] children) {
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/AbstractBindingLabelsTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/AbstractBindingLabelsTest.java
index e7632eeda6..bbb4fd7bd3 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/AbstractBindingLabelsTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/AbstractBindingLabelsTest.java
@@ -14,6 +14,7 @@
package org.eclipse.jdt.ui.tests.core;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import java.net.URI;
@@ -35,12 +36,11 @@ import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLinks;
public abstract class AbstractBindingLabelsTest extends CoreTests {
-
-
protected IJavaProject fJProject1;
protected boolean fHaveSource= true;
@@ -112,7 +112,7 @@ public abstract class AbstractBindingLabelsTest extends CoreTests {
// matching plain text:
String expected= expectedMarkup.substring(patternPos, open);
int end= label.indexOf("<a class", labelPos);
- assertTrue("next anchor not found ("+fragmentCount+")", end != -1);
+ assertNotEquals("next anchor not found ("+fragmentCount+")", -1, end);
assertEquals("plain text ("+fragmentCount+")", escape(expected), label.substring(labelPos, end));
fragmentCount++;
@@ -127,17 +127,17 @@ public abstract class AbstractBindingLabelsTest extends CoreTests {
if (linkTitle != null) {
// match linkTitle & linkText:
int start= label.indexOf("' title='", labelPos);
- assertTrue("title start not found", start != -1);
+ assertNotEquals("title start not found", -1, start);
start += "' title='".length();
int end= label.indexOf('\'', start);
- assertTrue("title end not found", end != -1);
+ assertNotEquals("title end not found", -1, end);
assertEquals("title ("+fragmentCount+")", linkTitle, label.substring(start, end));
fragmentCount++;
start= label.indexOf("'>", end) + 2;
- assertTrue("link text start not found", start != -1);
+ assertNotEquals("link text start not found", -1, start);
end= label.indexOf("</a>", start);
- assertTrue("link text end not found", end != -1);
+ assertNotEquals("link text end not found", -1, end);
assertEquals("link text ("+fragmentCount+")", escape(linkText), label.substring(start, end));
fragmentCount++;
@@ -145,9 +145,9 @@ public abstract class AbstractBindingLabelsTest extends CoreTests {
} else {
// match only linkText
int start= label.indexOf("'>", labelPos) + 2;
- assertTrue("link text start not found", start != -1);
+ assertNotEquals("link text start not found", -1, start);
int end= label.indexOf("</a>", start+1);
- assertTrue("link text end not found", end != -1);
+ assertNotEquals("link text end not found", -1, end);
assertEquals("link text ("+fragmentCount+")", escape(linkText), label.substring(start, end));
fragmentCount++;
@@ -173,5 +173,4 @@ public abstract class AbstractBindingLabelsTest extends CoreTests {
int end= label.indexOf('\'', start+1);
return new URI(label.substring(start+1, end));
}
-
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/BindingLabels18Test.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/BindingLabels18Test.java
index 3ba47a560b..62c3b165a2 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/BindingLabels18Test.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/BindingLabels18Test.java
@@ -48,19 +48,19 @@ import org.eclipse.jdt.internal.core.manipulation.dom.ASTResolving;
import org.eclipse.jdt.ui.JavaElementLabels;
import org.eclipse.jdt.ui.PreferenceConstants;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLinks;
public class BindingLabels18Test extends AbstractBindingLabelsTest {
@Rule
- public Java18ProjectTestSetup j18p= new Java18ProjectTestSetup();
+ public Java1d8ProjectTestSetup j18p= new Java1d8ProjectTestSetup();
@Override
@Before
public void setUp() throws Exception {
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
IPreferenceStore store= PreferenceConstants.getPreferenceStore();
store.setValue(PreferenceConstants.APPEARANCE_COMPRESS_PACKAGE_NAMES, false);
}
@@ -68,7 +68,7 @@ public class BindingLabels18Test extends AbstractBindingLabelsTest {
@Override
@After
public void tearDown() throws Exception {
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
@Test
@@ -250,7 +250,7 @@ public class BindingLabels18Test extends AbstractBindingLabelsTest {
IJavaElement lambdaType= lambdaMethod.getParent();
lab= getBindingLabel(lambdaType, JavaElementLabels.T_POST_QUALIFIED);
-// Bindings don't have the split identity of a lambda as expected from JavaElementLabelsTest18
+// Bindings don't have the split identity of a lambda as expected from JavaElementLabelsTest1d8
assertLinkMatch(lab, "accept(...) - {{org.test.C}}.{{org.test.C|c}}.() -> {...} {{java.util.function|IntConsumer}}");
// assertLinkMatch(lab, "() -> {...} IntConsumer - org.test.C.c");
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ClassPathDetectorTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ClassPathDetectorTest.java
index adfade6925..8918376964 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ClassPathDetectorTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ClassPathDetectorTest.java
@@ -140,12 +140,14 @@ public class ClassPathDetectorTest {
// source folder & internal JAR
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("junit src not found", junitSrcArchive);
+ assertTrue("junit src not found", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
File mylibJar= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.MYLIB);
- assertTrue("lib not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("lib not found", junitSrcArchive);
+ assertTrue("lib not found", junitSrcArchive.exists());
JavaProjectHelper.addLibraryWithImport(fJProject1, Path.fromOSString(mylibJar.getPath()), null, null);
@@ -176,7 +178,8 @@ public class ClassPathDetectorTest {
// 2 source folders
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("junit src not found", junitSrcArchive);
+ assertTrue("junit src not found", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src1", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
@@ -218,7 +221,8 @@ public class ClassPathDetectorTest {
// 2 nested source folders
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("junit src not found", junitSrcArchive);
+ assertTrue("junit src not found", junitSrcArchive.exists());
IPath[] exclusionFilter= new IPath[] { new Path("src2/") };
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src1", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING, exclusionFilter);
@@ -262,7 +266,8 @@ public class ClassPathDetectorTest {
// source folder & internal JAR
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("junit src not found", junitSrcArchive);
+ assertTrue("junit src not found", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
for (IClasspathEntry jreEntry : PreferenceConstants.getDefaultJRELibrary()) {
@@ -303,7 +308,8 @@ public class ClassPathDetectorTest {
pack1.createCompilationUnit("E.java", buf.toString(), false, null);
File lib= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.MYLIB);
- assertTrue("lib not found", lib != null && lib.exists());
+ assertNotNull("lib not found", lib);
+ assertTrue("lib not found", lib.exists());
IPackageFragmentRoot cfroot= JavaProjectHelper.addClassFolderWithImport(fJProject1, "cf", null, null, lib);
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CoreTestSuite.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CoreTestSuite.java
index 14d81c22b1..9467cb223d 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CoreTestSuite.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/CoreTestSuite.java
@@ -32,15 +32,15 @@ CodeFormatterTest9.class,
CodeFormatterMigrationTest.class,
HierarchicalASTVisitorTest.class,
ImportOrganizeTest.class,
-ImportOrganizeTest18.class,
+ImportOrganizeTest1d8.class,
JavaElementLabelsTest.class,
-JavaElementLabelsTest18.class,
+JavaElementLabelsTest1d8.class,
BindingLabelsTest.class,
BindingLabels18Test.class,
JavaElementPropertyTesterTest.class,
JavaModelUtilTest.class,
MethodOverrideTest.class,
-MethodOverrideTest18.class,
+MethodOverrideTest1d8.class,
NameProposerTest.class,
OverrideTest.class,
PartialASTTest.class,
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/HierarchicalASTVisitorTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/HierarchicalASTVisitorTest.java
index 3c86f95ac3..ecc5572904 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/HierarchicalASTVisitorTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/HierarchicalASTVisitorTest.java
@@ -384,18 +384,12 @@ public class HierarchicalASTVisitorTest {
try {
Method method= TestHierarchicalASTVisitor.class.getMethod(isLeaf ? getVisitMethodName(isEndVisit) : "superVisit", new Class[] { clazz });
method.invoke(this, new Object[] { null });
- } catch (NoSuchMethodException e) {
- /* This should have already been discovered by
+ } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
+ /* NoSuchMethodException should have already been discovered by
* hasRequiredMethodsForNonLeaf(..)
*/
e.printStackTrace();
Assert.isTrue(false);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- Assert.isTrue(false);
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- Assert.isTrue(false);
}
/*
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest.java
index 3fbadedcdd..7c7bee9823 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest.java
@@ -79,10 +79,10 @@ public class ImportOrganizeTest extends CoreTests {
return new IChooseImportQuery() {
@Override
public TypeNameMatch[] chooseImports(TypeNameMatch[][] openChoices, ISourceRange[] ranges) {
- assertTrue(name + "-query-nchoices1", choices.length == openChoices.length);
- assertTrue(name + "-query-nchoices2", nEntries.length == openChoices.length);
+ assertEquals(name + "-query-nchoices1", choices.length, openChoices.length);
+ assertEquals(name + "-query-nchoices2", nEntries.length, openChoices.length);
for (int i= 0; i < nEntries.length; i++) {
- assertTrue(name + "-query-cnt" + i, openChoices[i].length == nEntries[i]);
+ assertEquals(name + "-query-cnt" + i, openChoices[i].length, nEntries[i]);
}
TypeNameMatch[] res= new TypeNameMatch[openChoices.length];
for (int i= 0; i < openChoices.length; i++) {
@@ -114,7 +114,8 @@ public class ImportOrganizeTest extends CoreTests {
@Test
public void test1() throws Exception {
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("junit src not found", junitSrcArchive);
+ assertTrue("junit src not found", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
@@ -159,7 +160,8 @@ public class ImportOrganizeTest extends CoreTests {
@Test
public void test1WithOrder() throws Exception {
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("junit src not found", junitSrcArchive);
+ assertTrue("junit src not found", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
@@ -205,7 +207,8 @@ public class ImportOrganizeTest extends CoreTests {
@Test
public void test2() throws Exception {
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("junit src not found", junitSrcArchive);
+ assertTrue("junit src not found", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
@@ -229,7 +232,8 @@ public class ImportOrganizeTest extends CoreTests {
@Test
public void test3() throws Exception {
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("junit src not found", junitSrcArchive);
+ assertTrue("junit src not found", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
@@ -254,7 +258,8 @@ public class ImportOrganizeTest extends CoreTests {
@Test
public void test4() throws Exception {
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("junit src not found", junitSrcArchive);
+ assertTrue("junit src not found", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
@@ -982,7 +987,7 @@ public class ImportOrganizeTest extends CoreTests {
// unrelated project, to fill the all types cache
IJavaProject project2 = JavaProjectHelper.createJavaProject("TestProject2", "bin");
try {
- assertTrue("rt not found", JavaProjectHelper.addRTJar(project2) != null);
+ assertNotNull("rt not found", JavaProjectHelper.addRTJar(project2));
IPackageFragmentRoot sourceFolder2= JavaProjectHelper.addSourceContainer(project2, "src");
IPackageFragment pack22= sourceFolder2.createPackageFragment("packx", false, null);
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest1d8.java
index acf7a45781..4886ec2d73 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest18.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/ImportOrganizeTest1d8.java
@@ -32,17 +32,20 @@ import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.jdt.core.manipulation.OrganizeImportsOperation;
import org.eclipse.jdt.core.manipulation.OrganizeImportsOperation.IChooseImportQuery;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
-public class ImportOrganizeTest18 extends ImportOrganizeTest {
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
+public class ImportOrganizeTest1d8 extends ImportOrganizeTest {
@Rule
- public Java18ProjectTestSetup j18p= new Java18ProjectTestSetup();
+ public Java1d8ProjectTestSetup j18p= new Java1d8ProjectTestSetup();
private IJavaProject fJProject1;
@Before
public void before() throws Exception {
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
Hashtable<String, String> options= TestOptions.getDefaultOptions();
options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, String.valueOf(99));
@@ -53,7 +56,7 @@ public class ImportOrganizeTest18 extends ImportOrganizeTest {
@After
public void after() throws Exception {
setOrganizeImportSettings(null, 99, 99, fJProject1);
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
@Test
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JDTFlagsTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JDTFlagsTest18.java
index b1f6c13595..00d001f921 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JDTFlagsTest18.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JDTFlagsTest18.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.core;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -57,26 +58,28 @@ import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
import org.eclipse.jdt.internal.corext.refactoring.structure.ASTNodeSearchUtil;
import org.eclipse.jdt.internal.corext.util.JdtFlags;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
public class JDTFlagsTest18 {
-
private IJavaProject fJProject1;
private IPackageFragmentRoot fSourceFolder;
@Rule
- public Java18ProjectTestSetup j18p= new Java18ProjectTestSetup();
+ public Java1d8ProjectTestSetup j18p= new Java1d8ProjectTestSetup();
@Before
public void setUp() throws Exception {
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
@After
public void tearDown() throws Exception {
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
protected CompilationUnit getCompilationUnitNode(String source) {
@@ -249,7 +252,8 @@ public class JDTFlagsTest18 {
@Test
public void testIsStaticInBinaryFile() throws Exception {
File clsJarPath= JavaTestPlugin.getDefault().getFileInPlugin(new Path("/testresources/JDTFlagsTest18.zip"));
- assertTrue("lib not found", clsJarPath != null && clsJarPath.exists());//$NON-NLS-1$
+ assertNotNull("lib not found", clsJarPath);//$NON-NLS-1$
+ assertTrue("lib not found", clsJarPath.exists());
IPackageFragmentRoot jarRoot= JavaProjectHelper.addLibraryWithImport(fJProject1, new Path(clsJarPath.getAbsolutePath()), null, null);
fJProject1.open(null);
fJProject1.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
@@ -297,7 +301,8 @@ public class JDTFlagsTest18 {
@Test
public void testIsDefaultInBinaryFile() throws Exception {
File clsJarPath= JavaTestPlugin.getDefault().getFileInPlugin(new Path("/testresources/JDTFlagsTest18.zip"));
- assertTrue("lib not found", clsJarPath != null && clsJarPath.exists());//$NON-NLS-1$
+ assertNotNull("lib not found", clsJarPath);//$NON-NLS-1$
+ assertTrue("lib not found", clsJarPath.exists());//$NON-NLS-1$
IPackageFragmentRoot jarRoot= JavaProjectHelper.addLibraryWithImport(fJProject1, new Path(clsJarPath.getAbsolutePath()), null, null);
fJProject1.open(null);
fJProject1.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
@@ -423,7 +428,8 @@ public class JDTFlagsTest18 {
@Test
public void testExplicitAbstractInBinaryFile() throws Exception {
File clsJarPath= JavaTestPlugin.getDefault().getFileInPlugin(new Path("/testresources/JDTFlagsTest18.zip"));
- assertTrue("lib not found", clsJarPath != null && clsJarPath.exists());//$NON-NLS-1$
+ assertNotNull("lib not found", clsJarPath);//$NON-NLS-1$
+ assertTrue("lib not found", clsJarPath.exists());//$NON-NLS-1$
IPackageFragmentRoot jarRoot= JavaProjectHelper.addLibraryWithImport(fJProject1, new Path(clsJarPath.getAbsolutePath()), null, null);
fJProject1.open(null);
fJProject1.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
@@ -441,7 +447,8 @@ public class JDTFlagsTest18 {
@Test
public void testImplicitAbstractInBinaryFile() throws Exception {
File clsJarPath= JavaTestPlugin.getDefault().getFileInPlugin(new Path("/testresources/JDTFlagsTest18.zip"));
- assertTrue("lib not found", clsJarPath != null && clsJarPath.exists());//$NON-NLS-1$
+ assertNotNull("lib not found", clsJarPath);//$NON-NLS-1$
+ assertTrue("lib not found", clsJarPath.exists());//$NON-NLS-1$
IPackageFragmentRoot jarRoot= JavaProjectHelper.addLibraryWithImport(fJProject1, new Path(clsJarPath.getAbsolutePath()), null, null);
fJProject1.open(null);
fJProject1.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java10ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java10ProjectTestSetup.java
deleted file mode 100644
index c8326729b7..0000000000
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java10ProjectTestSetup.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2018 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.core;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-
-import org.eclipse.jdt.internal.core.ClasspathEntry;
-
-import junit.framework.Test;
-
-public class Java10ProjectTestSetup extends ProjectTestSetup {
-
- public static final String PROJECT_NAME10= "TestSetupProject10";
-
- public static IJavaProject getProject() {
- IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME10);
- return JavaCore.create(project);
- }
-
- public static IClasspathEntry[] getDefaultClasspath() throws CoreException {
- IPath[] rtJarPath= JavaProjectHelper.findRtJar(JavaProjectHelper.RT_STUBS_10);
- IClasspathAttribute[] extraAttributes= { JavaCore.newClasspathAttribute(IClasspathAttribute.MODULE, Boolean.TRUE.toString()) };
- return new IClasspathEntry[] { JavaCore.newLibraryEntry(rtJarPath[0], rtJarPath[1], rtJarPath[2], ClasspathEntry.NO_ACCESS_RULES, extraAttributes, true) };
- }
-
- public Java10ProjectTestSetup(Test test) {
- super(test);
- }
-
- @Override
- protected boolean projectExists() {
- return getProject().exists();
- }
-
- @Override
- protected IJavaProject createAndInitializeProject() throws CoreException {
- IJavaProject javaProject= JavaProjectHelper.createJavaProject(PROJECT_NAME10, "bin");
- javaProject.setRawClasspath(getDefaultClasspath(), null);
- JavaProjectHelper.set10CompilerOptions(javaProject);
- return javaProject;
- }
-
-}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java12ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java12ProjectTestSetup.java
deleted file mode 100644
index 673aa95798..0000000000
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java12ProjectTestSetup.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.core;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-
-import org.eclipse.jdt.internal.core.ClasspathEntry;
-
-import junit.framework.Test;
-
-public class Java12ProjectTestSetup extends ProjectTestSetup {
-
- public static final String PROJECT_NAME12= "TestSetupProject12";
-
- private boolean enable_preview_feature;
-
- public static IJavaProject getProject() {
- IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME12);
- return JavaCore.create(project);
- }
-
- public static IClasspathEntry[] getDefaultClasspath() throws CoreException {
- IPath[] rtJarPath= JavaProjectHelper.findRtJar(JavaProjectHelper.RT_STUBS_12);
- IClasspathAttribute[] extraAttributes= { JavaCore.newClasspathAttribute(IClasspathAttribute.MODULE, Boolean.TRUE.toString()) };
- return new IClasspathEntry[] { JavaCore.newLibraryEntry(rtJarPath[0], rtJarPath[1], rtJarPath[2], ClasspathEntry.NO_ACCESS_RULES, extraAttributes, true) };
- }
-
- public Java12ProjectTestSetup(Test test, boolean enable_preview_feature) {
- super(test);
- this.enable_preview_feature= enable_preview_feature;
- }
-
- @Override
- protected boolean projectExists() {
- return getProject().exists();
- }
-
- @Override
- protected IJavaProject createAndInitializeProject() throws CoreException {
- IJavaProject javaProject= JavaProjectHelper.createJavaProject(PROJECT_NAME12, "bin");
- javaProject.setRawClasspath(getDefaultClasspath(), null);
- JavaProjectHelper.set12CompilerOptions(javaProject, enable_preview_feature);
- return javaProject;
- }
-
-}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java13ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java13ProjectTestSetup.java
deleted file mode 100644
index 69643a50b2..0000000000
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java13ProjectTestSetup.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.core;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-
-import org.eclipse.jdt.internal.core.ClasspathEntry;
-
-import junit.framework.Test;
-
-public class Java13ProjectTestSetup extends ProjectTestSetup {
-
- public static final String PROJECT_NAME13= "TestSetupProject13";
-
- private boolean enable_preview_feature;
-
- public static IJavaProject getProject() {
- IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME13);
- return JavaCore.create(project);
- }
-
- public static IClasspathEntry[] getDefaultClasspath() throws CoreException {
- IPath[] rtJarPath= JavaProjectHelper.findRtJar(JavaProjectHelper.RT_STUBS13);
- IClasspathAttribute[] extraAttributes= { JavaCore.newClasspathAttribute(IClasspathAttribute.MODULE, Boolean.TRUE.toString()) };
- return new IClasspathEntry[] { JavaCore.newLibraryEntry(rtJarPath[0], rtJarPath[1], rtJarPath[2], ClasspathEntry.NO_ACCESS_RULES, extraAttributes, true) };
- }
-
- public Java13ProjectTestSetup(Test test, boolean enable_preview_feature) {
- super(test);
- this.enable_preview_feature= enable_preview_feature;
- }
-
- @Override
- protected boolean projectExists() {
- return getProject().exists();
- }
-
- @Override
- protected IJavaProject createAndInitializeProject() throws CoreException {
- IJavaProject javaProject= JavaProjectHelper.createJavaProject(PROJECT_NAME13, "bin");
- javaProject.setRawClasspath(getDefaultClasspath(), null);
- JavaProjectHelper.set12CompilerOptions(javaProject, enable_preview_feature);
- return javaProject;
- }
-
-}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java14ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java14ProjectTestSetup.java
deleted file mode 100644
index d569d0cb5a..0000000000
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java14ProjectTestSetup.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.core;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-
-import org.eclipse.jdt.internal.core.ClasspathEntry;
-
-import junit.framework.Test;
-
-public class Java14ProjectTestSetup extends ProjectTestSetup {
-
- public static final String PROJECT_NAME14= "TestSetupProject14";
-
- private boolean enable_preview_feature;
-
- public static IJavaProject getProject() {
- IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME14);
- return JavaCore.create(project);
- }
-
- public static IClasspathEntry[] getDefaultClasspath() throws CoreException {
- IPath[] rtJarPath= JavaProjectHelper.findRtJar(JavaProjectHelper.RT_STUBS14);
- IClasspathAttribute[] extraAttributes= { JavaCore.newClasspathAttribute(IClasspathAttribute.MODULE, Boolean.TRUE.toString()) };
- return new IClasspathEntry[] { JavaCore.newLibraryEntry(rtJarPath[0], rtJarPath[1], rtJarPath[2], ClasspathEntry.NO_ACCESS_RULES, extraAttributes, true) };
- }
-
- public Java14ProjectTestSetup(Test test, boolean enable_preview_feature) {
- super(test);
- this.enable_preview_feature= enable_preview_feature;
- }
-
- @Override
- protected boolean projectExists() {
- return getProject().exists();
- }
-
- @Override
- protected IJavaProject createAndInitializeProject() throws CoreException {
- IJavaProject javaProject= JavaProjectHelper.createJavaProject(PROJECT_NAME14, "bin");
- javaProject.setRawClasspath(getDefaultClasspath(), null);
- JavaProjectHelper.set14CompilerOptions(javaProject, enable_preview_feature);
- return javaProject;
- }
-
-}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java18ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java18ProjectTestSetup.java
deleted file mode 100644
index ac7ef9dbc6..0000000000
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java18ProjectTestSetup.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.core;
-
-import java.io.File;
-import java.io.IOException;
-
-import junit.framework.Test;
-
-import org.osgi.framework.Bundle;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-
-import org.eclipse.jdt.internal.ui.JavaPlugin;
-
-public class Java18ProjectTestSetup extends ProjectTestSetup {
-
- public static final String PROJECT_NAME18= "TestSetupProject18";
-
- public static IJavaProject getProject() {
- IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME18);
- return JavaCore.create(project);
- }
-
- public static IClasspathEntry[] getDefaultClasspath() throws CoreException {
- IPath[] rtJarPath= JavaProjectHelper.findRtJar(JavaProjectHelper.RT_STUBS_18);
- return new IClasspathEntry[] { JavaCore.newLibraryEntry(rtJarPath[0], rtJarPath[1], rtJarPath[2], true) };
- }
-
- public static String getJdtAnnotations20Path() throws IOException {
- Bundle[] annotationsBundles= JavaPlugin.getDefault().getBundles("org.eclipse.jdt.annotation", "2.0.0"); //$NON-NLS-1$
- File bundleFile= FileLocator.getBundleFile(annotationsBundles[0]);
- String path= bundleFile.getPath();
- if (bundleFile.isDirectory()) {
- path= bundleFile.getPath() + "/bin";
- }
- return path;
- }
-
- public Java18ProjectTestSetup(Test test) {
- super(test);
- }
-
- @Override
- protected boolean projectExists() {
- return getProject().exists();
- }
-
- @Override
- protected IJavaProject createAndInitializeProject() throws CoreException {
- IJavaProject javaProject= JavaProjectHelper.createJavaProject(PROJECT_NAME18, "bin");
- javaProject.setRawClasspath(getDefaultClasspath(), null);
- JavaProjectHelper.set18CompilerOptions(javaProject);
- return javaProject;
- }
-
-}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java1d5ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java1d5ProjectTestSetup.java
deleted file mode 100644
index c9efed0b48..0000000000
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java1d5ProjectTestSetup.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2019 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Fabrice TIERCELIN - Split the tests
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.core;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-
-/**
- * Setups the tests related to Java 5.
- */
-public class Java1d5ProjectTestSetup extends ProjectTestSetup {
- public static final String PROJECT_NAME1d5= "TestSetupProject1d5";
-
- public static IJavaProject getProject() {
- IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME1d5);
- return JavaCore.create(project);
- }
-
- public static IClasspathEntry[] getDefaultClasspath() throws CoreException {
- IPath[] rtJarPath= JavaProjectHelper.findRtJar(JavaProjectHelper.RT_STUBS_15);
- return new IClasspathEntry[] { JavaCore.newLibraryEntry(rtJarPath[0], rtJarPath[1], rtJarPath[2], true) };
- }
-
- public Java1d5ProjectTestSetup(Test test) {
- super(test);
- }
-
- @Override
- protected boolean projectExists() {
- return getProject().exists();
- }
-
- @Override
- protected IJavaProject createAndInitializeProject() throws CoreException {
- IJavaProject javaProject= JavaProjectHelper.createJavaProject(PROJECT_NAME1d5, "bin");
- javaProject.setRawClasspath(getDefaultClasspath(), null);
- JavaProjectHelper.set15CompilerOptions(javaProject);
- return javaProject;
- }
-}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java1d7ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java1d7ProjectTestSetup.java
deleted file mode 100644
index 0d98012de6..0000000000
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java1d7ProjectTestSetup.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.core;
-
-import junit.framework.Test;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-
-public class Java1d7ProjectTestSetup extends ProjectTestSetup {
-
- public static final String PROJECT_NAME1D7= "TestSetupProject1d7";
-
- public static IJavaProject getProject() {
- IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME1D7);
- return JavaCore.create(project);
- }
-
- public static IClasspathEntry[] getDefaultClasspath() throws CoreException {
- IPath[] rtJarPath= JavaProjectHelper.findRtJar(JavaProjectHelper.RT_STUBS_17);
- return new IClasspathEntry[] { JavaCore.newLibraryEntry(rtJarPath[0], rtJarPath[1], rtJarPath[2], true) };
- }
-
- public Java1d7ProjectTestSetup(Test test) {
- super(test);
- }
-
- @Override
- protected boolean projectExists() {
- return getProject().exists();
- }
-
- @Override
- protected IJavaProject createAndInitializeProject() throws CoreException {
- IJavaProject javaProject= JavaProjectHelper.createJavaProject(PROJECT_NAME1D7, "bin");
- javaProject.setRawClasspath(getDefaultClasspath(), null);
- JavaProjectHelper.set17CompilerOptions(javaProject);
- return javaProject;
- }
-
-}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java9ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java9ProjectTestSetup.java
deleted file mode 100644
index e23a486007..0000000000
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java9ProjectTestSetup.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.core;
-
-import org.eclipse.jdt.testplugin.JavaProjectHelper;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-
-import junit.framework.Test;
-
-public class Java9ProjectTestSetup extends ProjectTestSetup {
-
- public static final String PROJECT_NAME9= "TestSetupProject9";
-
- public static IJavaProject getProject() {
- IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME9);
- return JavaCore.create(project);
- }
-
- public static IClasspathEntry[] getDefaultClasspath() throws CoreException {
- IPath[] rtJarPath= JavaProjectHelper.findRtJar(JavaProjectHelper.RT_STUBS_9);
- return new IClasspathEntry[] { JavaCore.newLibraryEntry(rtJarPath[0], rtJarPath[1], rtJarPath[2],
- null,
- new IClasspathAttribute[] {JavaCore.newClasspathAttribute(IClasspathAttribute.MODULE, "true")},
- true) };
- }
-
- public Java9ProjectTestSetup(Test test) {
- super(test);
- }
-
- @Override
- protected boolean projectExists() {
- return getProject().exists();
- }
-
- @Override
- protected IJavaProject createAndInitializeProject() throws CoreException {
- IJavaProject javaProject= JavaProjectHelper.createJavaProject(PROJECT_NAME9, "bin");
- javaProject.setRawClasspath(getDefaultClasspath(), null);
- JavaProjectHelper.set9CompilerOptions(javaProject);
- return javaProject;
- }
-
-}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementLabelsTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementLabelsTest1d8.java
index cea2820c31..5772c4c040 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementLabelsTest18.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementLabelsTest1d8.java
@@ -36,18 +36,20 @@ import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.ui.JavaElementLabels;
import org.eclipse.jdt.ui.PreferenceConstants;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
-
-public class JavaElementLabelsTest18 extends CoreTests {
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
+public class JavaElementLabelsTest1d8 extends CoreTests {
@Rule
- public Java18ProjectTestSetup j18p= new Java18ProjectTestSetup();
+ public Java1d8ProjectTestSetup j18p= new Java1d8ProjectTestSetup();
private IJavaProject fJProject1;
@Before
public void setUp() throws Exception {
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
IPreferenceStore store= PreferenceConstants.getPreferenceStore();
store.setValue(PreferenceConstants.APPEARANCE_COMPRESS_PACKAGE_NAMES, false);
@@ -55,7 +57,7 @@ public class JavaElementLabelsTest18 extends CoreTests {
@After
public void tearDown() throws Exception {
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
@Test
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementPropertyTesterTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementPropertyTesterTest.java
index 86d5a82a22..f18609e6e5 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementPropertyTesterTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaElementPropertyTesterTest.java
@@ -80,7 +80,8 @@ public class JavaElementPropertyTesterTest {
fCU= fPack.createCompilationUnit("A.java", "package org.test; class A { }", true, null);
File file= JavaTestPlugin.getDefault().getFileInPlugin(LIB);
- assertTrue("lib not found", file != null && file.exists());
+ assertNotNull("lib not found", file);
+ assertTrue("lib not found", file.exists());
fLocalArchive= JavaProjectHelper.addLibraryWithImport(fJProject1, Path.fromOSString(file.getPath()), null, null);
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaModelUtilTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaModelUtilTest.java
index 2f1cb610ef..baef4e14ce 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaModelUtilTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/JavaModelUtilTest.java
@@ -81,12 +81,14 @@ public class JavaModelUtilTest {
assertNotNull("jdk not found", jdk);
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("junit src not found", junitSrcArchive);
+ assertTrue("junit src not found", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
File mylibJar= JavaTestPlugin.getDefault().getFileInPlugin(LIB);
- assertTrue("lib not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("lib not found", junitSrcArchive);
+ assertTrue("lib not found", junitSrcArchive.exists());
JavaProjectHelper.addLibraryWithImport(fJProject1, Path.fromOSString(mylibJar.getPath()), null, null);
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/MethodOverrideTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/MethodOverrideTest1d8.java
index a12e52777c..7854ad0595 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/MethodOverrideTest18.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/MethodOverrideTest1d8.java
@@ -36,18 +36,21 @@ import org.eclipse.jdt.core.dom.LambdaExpression;
import org.eclipse.jdt.core.dom.NodeFinder;
import org.eclipse.jdt.core.dom.TypeDeclaration;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
-public class MethodOverrideTest18 extends MethodOverrideTest {
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
+public class MethodOverrideTest1d8 extends MethodOverrideTest {
@Rule
- public Java18ProjectTestSetup j18p= new Java18ProjectTestSetup();
+ public Java1d8ProjectTestSetup j18p= new Java1d8ProjectTestSetup();
private IJavaProject fJProject1;
private IPackageFragmentRoot fSrc;
@Before
public void before() throws Exception {
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
fSrc= JavaProjectHelper.addSourceContainer(fJProject1, "src");
Hashtable<String, String> options= TestOptions.getDefaultOptions();
@@ -56,7 +59,7 @@ public class MethodOverrideTest18 extends MethodOverrideTest {
@After
public void after() throws Exception {
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
@Test
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/NoSuperTestsSuite.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/NoSuperTestsSuite.java
deleted file mode 100644
index c0c7684688..0000000000
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/NoSuperTestsSuite.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.core;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Test suite that only includes tests from the given test class, but not tests from super classes.
- *
- * @since 3.10
- */
-public class NoSuperTestsSuite extends TestSuite {
- /**
- * This implementation creates unnecessary test objects for tests from super classes
- * (in {@link junit.framework.TestSuite#addTestMethod}).
- * Alternative would have been to copy most of the implementation of TestSuite.
- */
-
- private static final Class<? extends Test> WARNING_TEST_CLASS= warning(null).getClass();
-
- public NoSuperTestsSuite(Class<? extends Test> theClass) {
- super(theClass);
- }
-
- /**
- * Adds the given test to this suite, but only if the test was declared in
- * the test object's class (and not in a superclass).
- */
- @Override
- public void addTest(Test test) {
- if (test instanceof TestCase) {
- TestCase testCase= (TestCase) test;
- Class<? extends TestCase> testClass= testCase.getClass();
- try {
- testClass.getDeclaredMethod(testCase.getName());
- } catch (NoSuchMethodException e) {
- if (testClass != WARNING_TEST_CLASS)
- return;
- }
- super.addTest(test);
- }
- }
-
- @Override
- public void addTestSuite(Class<? extends TestCase> testClass) {
- super.addTest(new NoSuperTestsSuite(testClass));
- }
-}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java
index 7ce490faea..c92bf7a88d 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeInfoTest.java
@@ -77,7 +77,8 @@ public class TypeInfoTest {
// add Junit source to project 2
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("Junit source", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("Junit source", junitSrcArchive);
+ assertTrue("Junit source", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject2, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
// source folder
IPackageFragmentRoot root1= JavaProjectHelper.addSourceContainer(fJProject1, "src");
@@ -152,7 +153,8 @@ public class TypeInfoTest {
// add Junit source to project 2
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("Junit source", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("Junit source", junitSrcArchive);
+ assertTrue("Junit source", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject2, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java18ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d8ProjectTestSetup.java
index eebd08c570..224f354119 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java18ProjectTestSetup.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/rules/Java1d8ProjectTestSetup.java
@@ -37,8 +37,10 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.ui.JavaPlugin;
-public class Java18ProjectTestSetup extends ProjectTestSetup {
-
+/**
+ * This class is made to run tests on Java Spider 1.8 .
+ */
+public class Java1d8ProjectTestSetup extends ProjectTestSetup {
public static final String PROJECT_NAME18= "TestSetupProject18";
public static IJavaProject getProject() {
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/AddUnimplementedMethodsTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/AddUnimplementedMethodsTest1d8.java
index 4c7d23c8a5..a9e1a0b328 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/AddUnimplementedMethodsTest18.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/source/AddUnimplementedMethodsTest1d8.java
@@ -47,12 +47,14 @@ import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
-
-public class AddUnimplementedMethodsTest18 {
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
+public class AddUnimplementedMethodsTest1d8 {
@Rule
- public Java18ProjectTestSetup j18p= new Java18ProjectTestSetup();
+ public Java1d8ProjectTestSetup j18p= new Java1d8ProjectTestSetup();
private IJavaProject fJavaProject;
@@ -60,14 +62,14 @@ public class AddUnimplementedMethodsTest18 {
@Before
public void setUp() throws Exception {
- fJavaProject= Java18ProjectTestSetup.getProject();
+ fJavaProject= Java1d8ProjectTestSetup.getProject();
IPackageFragmentRoot root= JavaProjectHelper.addSourceContainer(fJavaProject, "src");
fPackage= root.createPackageFragment("ibm.util", true, null);
}
@After
public void tearDown() throws Exception {
- JavaProjectHelper.clear(fJavaProject, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJavaProject, Java1d8ProjectTestSetup.getDefaultClasspath());
fJavaProject= null;
fPackage= null;
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/dialogs/DialogsTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/dialogs/DialogsTest.java
index 683f4e3b61..3a33319822 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/dialogs/DialogsTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/dialogs/DialogsTest.java
@@ -185,7 +185,7 @@ public class DialogsTest extends TestCase {
dialog.setMessage("Message");
dialog.setEmptyListMessage("empty messgae");
dialog.setElements(elements);
- dialog.setInitialSelections(new Object[] {Integer.valueOf(7)});
+ dialog.setInitialSelections(Integer.valueOf(7));
DialogCheck.assertDialog(dialog);
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/hover/PackageJavadocTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/hover/PackageJavadocTests.java
index 471faa067d..3d0c65f76a 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/hover/PackageJavadocTests.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/hover/PackageJavadocTests.java
@@ -20,7 +20,6 @@ import java.io.File;
import java.net.URL;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -59,7 +58,6 @@ import org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover;
* @since 3.9
*/
public class PackageJavadocTests extends CoreTests {
-
@Rule
public ProjectTestSetup pts= new ProjectTestSetup();
@@ -67,10 +65,10 @@ public class PackageJavadocTests extends CoreTests {
@Test
public void testGetDocFromPackageHtml_src() throws Exception {
-
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/PackageJavadocTests/JavadocHover_src.zip"));
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("JUnit src should be found", junitSrcArchive);
+ assertTrue("JUnit src should exist", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("junit/javadochoverhtml/JavaDocHoverTest.java"));
@@ -82,16 +80,16 @@ public class PackageJavadocTests extends CoreTests {
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(elements, cu, new Region(21, 16), null);
String actualHtmlContent= hoverInfo.getHtml();
- //checking for some part of the expected Javadoc which could be retrieved.
- Assert.assertTrue(actualHtmlContent, actualHtmlContent.contains("Test package documentation in package.html"));
+ // Checking for some part of the expected Javadoc which could be retrieved.
+ assertTrue(actualHtmlContent, actualHtmlContent.contains("Test package documentation in package.html"));
}
-
@Test
public void testGetDocFromPackageInfoJava_src() throws Exception {
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/PackageJavadocTests/JavadocHover_src.zip"));
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("JUnit src should be found", junitSrcArchive);
+ assertTrue("JUnit src should exist", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("junit/javadochover/Activator.java"));
@@ -103,15 +101,15 @@ public class PackageJavadocTests extends CoreTests {
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(elements, cu, new Region(21, 12), null);
String actualHtmlContent= hoverInfo.getHtml();
- Assert.assertTrue(actualHtmlContent, actualHtmlContent.contains("This is the test content"));
+ assertTrue(actualHtmlContent, actualHtmlContent.contains("This is the test content"));
}
@Test
public void testGetDocFromPackageHtml_archive() throws Exception {
-
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/PackageJavadocTests/JavadocHover_src.zip"));
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("JUnit src should be found", junitSrcArchive);
+ assertTrue("JUnit src should exist", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("junit/javadochoverhtml/JavaDocHoverTest.java"));
@@ -123,12 +121,15 @@ public class PackageJavadocTests extends CoreTests {
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(elements, cu, new Region(67, 10), null);
String actualHtmlContent= hoverInfo.getHtml();
- Assert.assertTrue(actualHtmlContent, actualHtmlContent.contains("Test package documentation in package.html"));
+ assertTrue(actualHtmlContent, actualHtmlContent.contains("Test package documentation in package.html"));
}
+
@Test
public void testGetDocFromPackageInfoJava_archive() throws Exception {
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/PackageJavadocTests/JavadocHover_src.zip"));
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("JUnit src should be found", junitSrcArchive);
+ assertTrue("JUnit src should exist", junitSrcArchive.exists());
+
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("junit/javadochoverhtml/JavaDocHoverTest.java"));
assertNotNull("JavaDocHoverTest.java", cu);
@@ -142,27 +143,29 @@ public class PackageJavadocTests extends CoreTests {
IPackageFragmentRoot jarRoot= this.fJProject1.getPackageFragmentRoot(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/TestSetupProject/testData.zip")));
IPackageFragment packageFragment= jarRoot.getPackageFragment("org.eclipse.jdt.ui.tests");
assertNotNull(packageFragment);
+
IPath sourceAttachmentPath= jarRoot.getSourceAttachmentPath();
- Assert.assertNotNull(sourceAttachmentPath);
+ assertNotNull(sourceAttachmentPath);
int offset= cu.getSource().indexOf("org.eclipse.jdt.ui.tests");
int length= "org.eclipse.jdt.ui.tests".length();
IJavaElement[] codeSelect= cu.codeSelect(offset, length);
- Assert.assertNotNull(codeSelect);
- Assert.assertTrue("No package found !", codeSelect.length > 0);
+ assertNotNull(codeSelect);
+ assertTrue("No package found !", codeSelect.length > 0);
+
packageFragment= (IPackageFragment)codeSelect[0];
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(new IJavaElement[] { packageFragment }, cu, new Region(offset, length), null);
String actualHtmlContent= hoverInfo.getHtml();
- Assert.assertTrue(actualHtmlContent, actualHtmlContent.contains("This is the package documentation for org.eclipse.jdt.ui.tests"));
-
+ assertTrue(actualHtmlContent, actualHtmlContent.contains("This is the package documentation for org.eclipse.jdt.ui.tests"));
}
-
@Test
public void testGetDocFromSourceAttachmentRootPath() throws Exception {
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/PackageJavadocTests/JavadocHover_src.zip"));
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("JUnit src should be found", junitSrcArchive);
+ assertTrue("JUnit src should exist", junitSrcArchive.exists());
+
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("junit/javadochoverhtml/JavaDocHoverTest.java"));
assertNotNull("JavaDocHoverTest.java", cu);
@@ -174,33 +177,37 @@ public class PackageJavadocTests extends CoreTests {
JavaProjectHelper.addLibraryWithImport(fJProject1, new Path(clsJarPath.getAbsolutePath()), new Path(srcJarPath.getAbsolutePath()), new Path("src"));
fJProject1.open(null);
IPackageFragmentRoot jarRoot= this.fJProject1.getPackageFragmentRoot(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/TestSetupProject/testData.zip")));
- Assert.assertTrue(jarRoot != null && jarRoot.exists());
+ assertNotNull(jarRoot);
+ assertTrue(jarRoot.exists());
+
IPackageFragment packageFragment= jarRoot.getPackageFragment("org.eclipse.jdt.ui.tests.html");
- Assert.assertTrue(packageFragment != null && packageFragment.exists());
+ assertNotNull(packageFragment);
+ assertTrue(packageFragment.exists());
+
IPath sourceAttachmentPath= jarRoot.getSourceAttachmentPath();
- Assert.assertNotNull(sourceAttachmentPath);
+ assertNotNull(sourceAttachmentPath);
int offset= cu.getSource().indexOf("org.eclipse.jdt.ui.tests.html");
int length= "org.eclipse.jdt.ui.tests.html".length();
IJavaElement[] codeSelect= cu.codeSelect(offset, length);
- Assert.assertNotNull(codeSelect);
- Assert.assertTrue("No package found !", codeSelect.length > 0);
+
+ assertNotNull(codeSelect);
+ assertTrue("No package found !", codeSelect.length > 0);
+
packageFragment= (IPackageFragment)codeSelect[0];
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(new IJavaElement[] { packageFragment }, cu, new Region(offset, length), null);
String actualHtmlContent= hoverInfo.getHtml();
-
- Assert.assertTrue(actualHtmlContent, actualHtmlContent.contains("This is the package documentation for org.eclipse.jdt.ui.tests.html."));
-
+ assertTrue(actualHtmlContent, actualHtmlContent.contains("This is the package documentation for org.eclipse.jdt.ui.tests.html."));
}
-
@Test
public void testGetPackageAttacheddoc() throws Exception {
// https://docs.oracle.com/javase/8/docs/api/
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/PackageJavadocTests/JavadocHover_src.zip"));
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("JUnit src should be found", junitSrcArchive);
+ assertTrue("JUnit src should exist", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("junit/javadochoverhtml/JavaDocHoverTest.java"));
@@ -222,26 +229,25 @@ public class PackageJavadocTests extends CoreTests {
int offset= cu.getSource().indexOf("java.math");
int length= "java.math".length();
IJavaElement[] codeSelect= cu.codeSelect(offset, length);
- Assert.assertNotNull(codeSelect);
- Assert.assertTrue("No package found !", codeSelect.length > 0);
+ assertNotNull(codeSelect);
+ assertTrue("No package found !", codeSelect.length > 0);
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(codeSelect, cu, new Region(offset, length), null);
String actualHtmlContent= hoverInfo.getHtml();
- Assert.assertNotNull(actualHtmlContent, actualHtmlContent);
+ assertNotNull(actualHtmlContent, actualHtmlContent);
String connectionTestUrl= "https://docs.oracle.com/";
try {
- //trying to connect to the internet. Exception will be thrown if there is no net connection.
+ // Trying to connect to the internet. Exception will be thrown if there is no net connection.
new URL(connectionTestUrl).openConnection().connect();
- Assert.assertTrue(actualHtmlContent, actualHtmlContent.contains("Provides classes for performing arbitrary-precision integer"));
+ assertTrue(actualHtmlContent, actualHtmlContent.contains("Provides classes for performing arbitrary-precision integer"));
} catch (Exception e) {
System.out.println("PackageJavadocTests.testGetPackageAttacheddoc(): no internet connection to access docs at " + connectionTestUrl);
e.printStackTrace(System.out);
- //there is no internet connection, so the Javadoc cannot be retrieved.
- Assert.assertTrue(actualHtmlContent, actualHtmlContent.contains(CorextMessages.JavaDocLocations_noAttachedSource) || actualHtmlContent.contains(CorextMessages.JavaDocLocations_error_gettingJavadoc)
+ // There is no internet connection, so the Javadoc cannot be retrieved.
+ assertTrue(actualHtmlContent, actualHtmlContent.contains(CorextMessages.JavaDocLocations_noAttachedSource) || actualHtmlContent.contains(CorextMessages.JavaDocLocations_error_gettingJavadoc)
|| actualHtmlContent.contains(CorextMessages.JavaDocLocations_error_gettingAttachedJavadoc));
}
-
}
/**
@@ -252,10 +258,10 @@ public class PackageJavadocTests extends CoreTests {
*/
@Test
public void testPackageInfoWithReferenceLinks() throws Exception {
-
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/PackageJavadocTests/JavadocHover_src.zip"));
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("JUnit src should be found", junitSrcArchive);
+ assertTrue("JUnit src should exist", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("junit/checkPackageInfo/TestNPEHover.java"));
@@ -267,13 +273,15 @@ public class PackageJavadocTests extends CoreTests {
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(elements, cu, new Region(21, 12), null);
String actualHtmlContent= hoverInfo.getHtml();
- Assert.assertTrue(actualHtmlContent, actualHtmlContent.contains("The pack is a test package. This doc contains references"));
+ assertTrue(actualHtmlContent, actualHtmlContent.contains("The pack is a test package. This doc contains references"));
}
@Test
public void testPackageWithNoJavadoc() throws Exception {
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/PackageJavadocTests/JavadocHover_src.zip"));
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("JUnit src should be found", junitSrcArchive);
+ assertTrue("JUnit src should exist", junitSrcArchive.exists());
+
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("junit/javadochoverhtml/JavaDocHoverTest.java"));
assertNotNull("JavaDocHoverTest.java", cu);
@@ -285,35 +293,41 @@ public class PackageJavadocTests extends CoreTests {
JavaProjectHelper.addLibraryWithImport(fJProject1, new Path(clsJarPath.getAbsolutePath()), new Path(srcJarPath.getAbsolutePath()), new Path("src"));
fJProject1.open(null);
IPackageFragmentRoot jarRoot= this.fJProject1.getPackageFragmentRoot(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/TestSetupProject/testData.zip")));
- Assert.assertTrue(jarRoot != null && jarRoot.exists());
+ assertNotNull(jarRoot);
+ assertTrue(jarRoot.exists());
+
IPackageFragment packageFragment= jarRoot.getPackageFragment("org.eclipse.jdt.ui.tests.noJavadoc");
- Assert.assertTrue(packageFragment != null && packageFragment.exists());
+ assertNotNull(packageFragment);
+ assertTrue(packageFragment.exists());
+
IPath sourceAttachmentPath= jarRoot.getSourceAttachmentPath();
- Assert.assertNotNull(sourceAttachmentPath);
+ assertNotNull(sourceAttachmentPath);
int offset= cu.getSource().indexOf("org.eclipse.jdt.ui.tests.noJavadoc");
int length= "org.eclipse.jdt.ui.tests.noJavadoc".length();
IJavaElement[] codeSelect= cu.codeSelect(offset, length);
- Assert.assertNotNull(codeSelect);
- Assert.assertTrue("No package found !", codeSelect.length > 0);
+ assertNotNull(codeSelect);
+ assertTrue("No package found !", codeSelect.length > 0);
+
packageFragment= (IPackageFragment)codeSelect[0];
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(new IJavaElement[] { packageFragment }, cu, new Region(offset, length), null);
String actualHtmlContent= hoverInfo.getHtml();
- Assert.assertTrue(actualHtmlContent, actualHtmlContent.contains(CorextMessages.JavaDocLocations_noAttachedJavadoc));
+ assertTrue(actualHtmlContent, actualHtmlContent.contains(CorextMessages.JavaDocLocations_noAttachedJavadoc));
}
@Test
public void testFailToAccessAttachedJavadoc() throws Exception {
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/PackageJavadocTests/JavadocHover_src.zip"));
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());
+ assertNotNull("JUnit src should be found", junitSrcArchive);
+ assertTrue("JUnit src should exist", junitSrcArchive.exists());
JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);
ICompilationUnit cu= (ICompilationUnit)fJProject1.findElement(new Path("junit/javadochoverhtml/JavaDocHoverTest.java"));
assertNotNull("JavaDocHoverTest.java", cu);
- //set a wrong Javadoc location URL
+ // Set a wrong Javadoc location URL
IClasspathAttribute attribute=
JavaCore.newClasspathAttribute(
IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
@@ -329,17 +343,16 @@ public class PackageJavadocTests extends CoreTests {
int offset= cu.getSource().indexOf("java.math");
int length= "java.math".length();
IJavaElement[] codeSelect= cu.codeSelect(offset, length);
- Assert.assertNotNull(codeSelect);
- Assert.assertTrue("No package found !", codeSelect.length > 0);
+ assertNotNull(codeSelect);
+ assertTrue("No package found !", codeSelect.length > 0);
JavadocBrowserInformationControlInput hoverInfo= JavadocHover.getHoverInfo(codeSelect, cu, new Region(offset, length), null);
String actualHtmlContent= hoverInfo.getHtml();
- Assert.assertNotNull(actualHtmlContent);
+ assertNotNull(actualHtmlContent);
// Need to check both conditions for now. See https://bugs.eclipse.org/403036 and https://bugs.eclipse.org/403154 for details.
- Assert.assertTrue(actualHtmlContent,
+ assertTrue(actualHtmlContent,
actualHtmlContent.contains(CorextMessages.JavaDocLocations_error_gettingAttachedJavadoc) || actualHtmlContent.contains(CorextMessages.JavaDocLocations_noAttachedSource));
-
}
@Before
@@ -348,10 +361,8 @@ public class PackageJavadocTests extends CoreTests {
}
-
@After
public void tearDown() throws Exception {
JavaProjectHelper.clear(fJProject1, ProjectTestSetup.getDefaultClasspath());
}
-
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/FatJarExportTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/FatJarExportTests.java
index 559a77db32..608ad3f2b9 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/FatJarExportTests.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/FatJarExportTests.java
@@ -249,14 +249,17 @@ public class FatJarExportTests {
// get loader entry
ZipEntry loaderClassEntry= generatedArchive.getEntry("org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader.class"); //$NON-NLS-1$
assertNotNull(loaderClassEntry);
- // check version of class file JarRsrcLoader (jdk 1.6 = version 50.0)
- InputStream in = generatedArchive.getInputStream(loaderClassEntry);
- int magic = 0;
- for (int i= 0; i < 4; i++)
- magic = (magic << 8) + in.read();
- int minorVersion = ((in.read() << 8) + in.read());
- int majorVersion = ((in.read() << 8) + in.read());
- in.close();
+ int magic;
+ int minorVersion;
+ int majorVersion;
+ try ( // check version of class file JarRsrcLoader (jdk 1.6 = version 50.0)
+ InputStream in = generatedArchive.getInputStream(loaderClassEntry)) {
+ magic = 0;
+ for (int i= 0; i < 4; i++)
+ magic = (magic << 8) + in.read();
+ minorVersion = ((in.read() << 8) + in.read());
+ majorVersion = ((in.read() << 8) + in.read());
+ }
assertEquals("loader is a class file", 0xCAFEBABE, magic); //$NON-NLS-1$
assertEquals("loader compiled with JDK 1.6", "50.0", majorVersion + "." + minorVersion); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/PlainJarExportTests.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/PlainJarExportTests.java
index cc7ae2e7ad..4fe92ea55b 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/PlainJarExportTests.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/jarexport/PlainJarExportTests.java
@@ -14,6 +14,7 @@
package org.eclipse.jdt.ui.tests.jarexport;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -117,12 +118,7 @@ public class PlainJarExportTests {
try (ZipFile jar= createArchive(data)) {
entries= getSortedEntries(jar);
}
- List<String> expected= Arrays.asList(new String[] {
- "META-INF/MANIFEST.MF\n",
- "org/eclipse/jdt/ui/test/Main$1.class\n",
- "org/eclipse/jdt/ui/test/Main$MainInner.class\n",
- "org/eclipse/jdt/ui/test/Main.class\n",
- });
+ List<String> expected= Arrays.asList("META-INF/MANIFEST.MF\n", "org/eclipse/jdt/ui/test/Main$1.class\n", "org/eclipse/jdt/ui/test/Main$MainInner.class\n", "org/eclipse/jdt/ui/test/Main.class\n");
assertEquals(expected.toString(), entries.toString());
}
@@ -137,9 +133,7 @@ public class PlainJarExportTests {
try (ZipFile jar= createArchive(data)) {
entries= getSortedEntries(jar);
}
- List<String> expected= Arrays.asList(new String[] { "META-INF/MANIFEST.MF\n", "org/eclipse/jdt/ui/test/Main$1.class\n",
- "org/eclipse/jdt/ui/test/Main$MainInner.class\n",
- "org/eclipse/jdt/ui/test/Main.class\n", });
+ List<String> expected= Arrays.asList("META-INF/MANIFEST.MF\n", "org/eclipse/jdt/ui/test/Main$1.class\n", "org/eclipse/jdt/ui/test/Main$MainInner.class\n", "org/eclipse/jdt/ui/test/Main.class\n");
assertEquals(expected.toString(), entries.toString());
}
@@ -150,7 +144,8 @@ public class PlainJarExportTests {
JarPackageData data= createJarPackageData();
File classFolder= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/externalClassFolder/"));//$NON-NLS-1$
- assertTrue("class folder not found", classFolder != null && classFolder.exists());//$NON-NLS-1$
+ assertNotNull("class folder not found", classFolder);//$NON-NLS-1$
+ assertTrue("class folder not found", classFolder.exists());//$NON-NLS-1$
IPackageFragmentRoot externalRoot= JavaProjectHelper.addLibrary(fProject, Path.fromOSString(classFolder.getPath()), null, null);
@@ -161,11 +156,7 @@ public class PlainJarExportTests {
try (ZipFile jar= createArchive(data)) {
entries= getSortedEntries(jar);
}
- List<String> expected= Arrays.asList(new String[] {
- "META-INF/MANIFEST.MF\n",
- "org/eclipse/jdt/ui/test/Main$1.class\n",
- "org/eclipse/jdt/ui/test/Main$MainInner.class\n",
- "org/eclipse/jdt/ui/test/Main.class\n", });
+ List<String> expected= Arrays.asList("META-INF/MANIFEST.MF\n", "org/eclipse/jdt/ui/test/Main$1.class\n", "org/eclipse/jdt/ui/test/Main$MainInner.class\n", "org/eclipse/jdt/ui/test/Main.class\n");
assertEquals(expected.toString(), entries.toString());
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests1.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests1.java
index 384509d78d..1db35abd6a 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests1.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests1.java
@@ -4,7 +4,7 @@
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
+ * https:// Www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
@@ -15,7 +15,9 @@ package org.eclipse.jdt.ui.tests.packageview;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.junit.After;
import org.junit.Before;
@@ -55,16 +57,13 @@ import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.internal.ui.util.CoreUtility;
import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement;
-
/**
* Tests for the PackageExplorerContentProvider.
*
* @since 2.1
*/
@RunWith(JUnit4.class)
-public class ContentProviderTests1{
-
-
+public class ContentProviderTests1 {
private IJavaProject fJProject1;
private IJavaProject fJProject2;
@@ -104,99 +103,97 @@ public class ContentProviderTests1{
//---------Test for getChildren-------------------
@Test
- public void testGetChildrenProjectWithSourceFolders() throws Exception{
+ public void testGetChildrenProjectWithSourceFolders() throws Exception {
Object[] expectedChildren= new Object[]{fRoot1, fDotClasspathFile, fDotProjectFile};
- Object[] children= fProvider.getChildren(fJProject2);
- assertTrue("Wrong children found for project", compareArrays(children, expectedChildren));//$NON-NLS-1$
+ Object[] actualChildren= fProvider.getChildren(fJProject2);
+ assertTrue("Wrong children found for project", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
}
@Test
- public void testGetChildrentMidLevelFragment() throws Exception{
+ public void testGetChildrentMidLevelFragment() throws Exception {
Object[] expectedChildren= new Object[]{fPack4, fPack5};
- Object[] children= fProvider.getChildren(fPack3);
- assertTrue("Wrong children found for PackageFragment",compareArrays(children, expectedChildren));//$NON-NLS-1$
+ Object[] actualChildren= fProvider.getChildren(fPack3);
+ assertTrue("Wrong children found for PackageFragment", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
}
@Test
- public void testGetChildrenBottomLevelFragment() throws Exception{
+ public void testGetChildrenBottomLevelFragment() throws Exception {
Object[] expectedChildren= new Object[]{fCU1};
- Object[] children= fProvider.getChildren(fPack2);
- assertTrue("Wrong children found for PackageFragment",compareArrays(children, expectedChildren));//$NON-NLS-1$
+ Object[] actualChildren= fProvider.getChildren(fPack2);
+ assertTrue("Wrong children found for PackageFragment", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
}
@Test
- public void testGetChildrenMidLevelFragmentInArchive() throws Exception{
+ public void testGetChildrenMidLevelFragmentInArchive() throws Exception {
Object[] expectedChildren= new Object[]{fPackJunitSamplesMoney, fCUAllTests, fCUSimpleTest, fCUVectorTest };
- Object[] children= fProvider.getChildren(fPackJunitSamples);
- assertTrue("wrong chidren found for mid level PackageFragment in Archive", compareArrays(children, expectedChildren));//$NON-NLS-1$
+ Object[] actualChildren= fProvider.getChildren(fPackJunitSamples);
+ assertTrue("wrong chidren found for mid level PackageFragment in Archive", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
}
@Test
- public void testGetChildrenBottomLevelFragmentInArchive() throws Exception{
+ public void testGetChildrenBottomLevelFragmentInArchive() throws Exception {
Object[] expectedChildren= new Object[]{fCUIMoney, fCUMoney, fCUMoneyBag, fCUMoneyTest};
- Object[] children= fProvider.getChildren(fPackJunitSamplesMoney);
- assertTrue("wrong children found for a bottom PackageFragment in PackageFragmentRoot Archive", compareArrays(children, expectedChildren)); //$NON-NLS-1$
+ Object[] actualChildren= fProvider.getChildren(fPackJunitSamplesMoney);
+ assertTrue("wrong children found for a bottom PackageFragment in PackageFragmentRoot Archive", compareArrays(actualChildren, expectedChildren)); //$NON-NLS-1$
}
@Test
public void testGetChildrenSourceFolder() throws Exception {
Object[] expectedChildren = new Object[] { fPack1, fPack2, fPack3, fRoot1.getPackageFragment("")};//$NON-NLS-1$
- Object[] children = fProvider.getChildren(fRoot1);
- assertTrue("Wrong children found for PackageFragmentRoot", compareArrays(children, expectedChildren));//$NON-NLS-1$
+ Object[] actualChildren = fProvider.getChildren(fRoot1);
+ assertTrue("Wrong children found for PackageFragmentRoot", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
}
@Test
public void testGetChildrenArchive(){ Object[] expectedChildren= new Object[]{fPackJunit, fArchiveFragmentRoot.getPackageFragment("")};//$NON-NLS-1$
- Object[] children= fProvider.getChildren(fArchiveFragmentRoot);
- assertTrue("Wrong child found for PackageFragmentRoot Archive", compareArrays(children,expectedChildren));//$NON-NLS-1$
+ Object[] actualChildren= fProvider.getChildren(fArchiveFragmentRoot);
+ assertTrue("Wrong child found for PackageFragmentRoot Archive", compareArrays(actualChildren, expectedChildren));//$NON-NLS-1$
}
//---------------Get Parent Tests-----------------------------
@Test
- public void testGetParentArchive() throws Exception{
+ public void testGetParentArchive() throws Exception {
Object parent= fProvider.getParent(fArchiveFragmentRoot);
- assertTrue("Wrong parent found for PackageFragmentRoot Archive", parent==fJProject1);//$NON-NLS-1$
+ assertSame("Wrong parent found for PackageFragmentRoot Archive", parent, fJProject1);//$NON-NLS-1$
}
@Test
- public void testGetParentMidLevelFragmentInArchive() throws Exception{
+ public void testGetParentMidLevelFragmentInArchive() throws Exception {
Object expectedParent= fPackJunitSamples;
- Object parent= fProvider.getParent(fPackJunitSamplesMoney);
- assertTrue("Wrong parent found for a NON top level PackageFragment in an Archive", expectedParent.equals(parent));//$NON-NLS-1$
+ Object actualParent= fProvider.getParent(fPackJunitSamplesMoney);
+ assertEquals("Wrong parent found for a NON top level PackageFragment in an Archive", expectedParent, actualParent);//$NON-NLS-1$
}
@Test
- public void testGetParentTopLevelFragmentInArchive() throws Exception{
+ public void testGetParentTopLevelFragmentInArchive() throws Exception {
Object expectedParent= fPackJunit;
- Object parent= fProvider.getParent(fPackJunitSamples);
- assertTrue("Wrong parent found for a top level PackageFragment in an Archive", expectedParent.equals(parent)); //$NON-NLS-1$
+ Object actualParent= fProvider.getParent(fPackJunitSamples);
+ assertEquals("Wrong parent found for a top level PackageFragment in an Archive", expectedParent, actualParent); //$NON-NLS-1$
}
@Test
- public void testGetParentTopLevelFragment() throws Exception{
+ public void testGetParentTopLevelFragment() throws Exception {
Object expectedParent= fRoot1;
- Object parent= fProvider.getParent(fPack3);
- assertTrue("Wrong parent found for a top level PackageFragment", expectedParent.equals(parent));//$NON-NLS-1$
+ Object actualParent= fProvider.getParent(fPack3);
+ assertEquals("Wrong parent found for a top level PackageFragment", expectedParent, actualParent);//$NON-NLS-1$
}
@Test
- public void testGetParentMidLevelFragment() throws Exception{
+ public void testGetParentMidLevelFragment() throws Exception {
Object expectedParent= fPack3;
- Object parent= fProvider.getParent(fPack4);
- assertTrue("Wrong parent found for a NON top level PackageFragment", expectedParent.equals(parent));//$NON-NLS-1$
+ Object actualParent= fProvider.getParent(fPack4);
+ assertEquals("Wrong parent found for a NON top level PackageFragment", expectedParent, actualParent);//$NON-NLS-1$
}
-
@Test
- public void testDeleteBottomLevelFragment() throws Exception{
-
- //send a delta indicating fragment deleted
+ public void testDeleteBottomLevelFragment() throws Exception {
+ // Send a delta indicating fragment deleted
IElementChangedListener listener= (IElementChangedListener)fProvider;
IJavaElementDelta delta= TestDelta.createDelta(fPack2, IJavaElementDelta.REMOVED);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from dispaly
+ // Force events from dispaly
while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {}
assertTrue("Remove happened", fMyPart.hasRemoveHappened());//$NON-NLS-1$
@@ -208,55 +205,54 @@ public class ContentProviderTests1{
public void testAddBottomLevelFragment() throws Exception {
IPackageFragment test= fRoot1.createPackageFragment("test", true, null);//$NON-NLS-1$
- //send a delta indicating fragment deleted
+ // Send a delta indicating fragment deleted
IElementChangedListener listener= (IElementChangedListener) fProvider;
IJavaElementDelta delta= TestDelta.createDelta(test, IJavaElementDelta.ADDED);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from dispaly
+ // Force events from dispaly
while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {}
assertTrue("Add happened", fMyPart.hasAddHappened()); //$NON-NLS-1$
- assertTrue("Correct Add", test.equals(fMyPart.getAddedObject())); //$NON-NLS-1$
+ assertEquals("Correct Add", test, fMyPart.getAddedObject()); //$NON-NLS-1$
assertEquals("No refreshes", 0, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$
}
@Test
public void testChangedTopLevelPackageFragment() throws Exception {
- //send a delta indicating fragment deleted
+ // Send a delta indicating fragment deleted
IElementChangedListener listener= (IElementChangedListener) fProvider;
IJavaElementDelta delta= TestDelta.createDelta(fPack3, IJavaElementDelta.CHANGED);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {}
assertEquals("No refresh happened", 0, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$
}
@Test
- public void testChangeBottomLevelPackageFragment() throws Exception{
- //send a delta indicating fragment deleted
+ public void testChangeBottomLevelPackageFragment() throws Exception {
+ // Send a delta indicating fragment deleted
fMyPart.clear();
IElementChangedListener listener= (IElementChangedListener) fProvider;
IJavaElementDelta delta= TestDelta.createDelta(fPack6, IJavaElementDelta.CHANGED);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {}
assertEquals("No refresh happened", 0, fMyPart.getRefreshedObject().size());//$NON-NLS-1$
}
@Test
- public void testRemoveCUsFromPackageFragment() throws Exception{
-
- //send a delta indicating fragment deleted
+ public void testRemoveCUsFromPackageFragment() throws Exception {
+ // Send a delta indicating fragment deleted
IElementChangedListener listener= (IElementChangedListener) fProvider;
IJavaElementDelta delta= TestDelta.createCUDelta(new ICompilationUnit[] { fCU2, fCU3 }, fPack6, IJavaElementDelta.REMOVED);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {}
// removing more than one CU now results in a refresh.
@@ -265,13 +261,12 @@ public class ContentProviderTests1{
@Test
public void testRemoveCUFromPackageFragment() throws Exception {
-
- //send a delta indicating fragment deleted
+ // Send a delta indicating fragment deleted
IElementChangedListener listener= (IElementChangedListener) fProvider;
IJavaElementDelta delta= TestDelta.createCUDelta(new ICompilationUnit[]{fCU2}, fPack6, IJavaElementDelta.REMOVED);
listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
- //force events from display
+ // Force events from display
while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {}
assertTrue("Remove happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$
@@ -296,7 +291,7 @@ public class ContentProviderTests1{
}
// public void testAddWorkingCopyCU() throws Exception {
-// //test for bug 106452: Paste of source into container doesn't refresh package explorer
+// // Test for bug 106452: Paste of source into container doesn't refresh package explorer
// ICompilationUnit cu= fPack6.createCompilationUnit("New.java","class New {}", true, null);//$NON-NLS-1$//$NON-NLS-2$
// cu.becomeWorkingCopy(null, null);
//
@@ -305,7 +300,7 @@ public class ContentProviderTests1{
// fMyPart.getTreeViewer().reveal(fCU2);
// ((PackageExplorerContentProvider) fMyPart.getTreeViewer().getContentProvider()).setProvideMembers(false);
//
-// //force events from display
+// // Force events from display
// while (fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {
// }
//
@@ -313,7 +308,7 @@ public class ContentProviderTests1{
// IJavaElementDelta delta= TestDelta.createCUDelta(new ICompilationUnit[] { cu }, fPack6, IJavaElementDelta.ADDED);
// listener.elementChanged(new ElementChangedEvent(delta, ElementChangedEvent.POST_CHANGE));
//
-// //force events from display
+// // Force events from display
// while (fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {
// }
//
@@ -331,7 +326,6 @@ public class ContentProviderTests1{
@Before
public void setUp() throws Exception {
-
fWorkspace= ResourcesPlugin.getWorkspace();
assertNotNull(fWorkspace);
IWorkspaceDescription workspaceDesc= fWorkspace.getDescription();
@@ -361,12 +355,13 @@ public class ContentProviderTests1{
assertNotNull(fDotClasspathFile);
assertNotNull(fDotProjectFile);
- //set up project #1 : External Jar and zip file
+ // Set up project #1 : External Jar and zip file
IPackageFragmentRoot jdk= JavaProjectHelper.addVariableRTJar(fJProject1, "JRE_LIB_TEST", null, null);//$NON-NLS-1$
- assertTrue("jdk not found", jdk != null);//$NON-NLS-1$
+ assertNotNull("jdk not found", jdk);//$NON-NLS-1$
java.io.File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());//$NON-NLS-1$
+ assertNotNull("junit src not found", junitSrcArchive);//$NON-NLS-1$
+ assertTrue("junit src not found", junitSrcArchive.exists());//$NON-NLS-1$
fArchiveFragmentRoot= JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);//$NON-NLS-1$
assertTrue("Unable to create zipfile archive",fArchiveFragmentRoot.exists());//$NON-NLS-1$
@@ -387,7 +382,7 @@ public class ContentProviderTests1{
fCUAllTests= fPackJunitSamples.getCompilationUnit("AllTests.java");//$NON-NLS-1$
fCUVectorTest= fPackJunitSamples.getCompilationUnit("VectorTest.java");//$NON-NLS-1$
fCUSimpleTest= fPackJunitSamples.getCompilationUnit("SimpleTest.java");//$NON-NLS-1$
- //set up project #2: file system structure with in a source folder
+ // Set up project #2: file system structure with in a source folder
// JavaProjectHelper.addVariableEntry(fJProject2, new Path("JRE_LIB_TEST"), null, null);
@@ -403,19 +398,18 @@ public class ContentProviderTests1{
fCU2= fPack6.createCompilationUnit("Object.java","", true, null);//$NON-NLS-1$//$NON-NLS-2$
fCU3= fPack6.createCompilationUnit("Jen.java","", true,null);//$NON-NLS-1$//$NON-NLS-2$
- //set up the mock view
+ // Set up the mock view
setUpMockView();
}
- public void setUpMockView() throws Exception{
-
+ public void setUpMockView() throws Exception {
fWorkbench= PlatformUI.getWorkbench();
assertNotNull(fWorkbench);
page= fWorkbench.getActiveWorkbenchWindow().getActivePage();
assertNotNull(page);
- //just testing to make sure my part can be created
+ // Just testing to make sure my part can be created
IViewPart myPart= new MockPluginView();
assertNotNull(myPart);
@@ -424,10 +418,10 @@ public class ContentProviderTests1{
fMyPart= (MockPluginView) myPart;
fMyPart.setFolding(false);
fMyPart.setFlatLayout(false);
- // above call might cause a property change event being sent
+ // Above call might cause a property change event being sent
fMyPart.clear();
fProvider= (ITreeContentProvider)fMyPart.getTreeViewer().getContentProvider();
- }else assertTrue("Unable to get view",false);//$NON-NLS-1$
+ }else fail("Unable to get view");//$NON-NLS-1$
assertNotNull(fProvider);
}
@@ -442,7 +436,6 @@ public class ContentProviderTests1{
if (fEnableAutoBuildAfterTesting)
CoreUtility.setAutoBuilding(true);
-
}
/**
@@ -466,8 +459,10 @@ public class ContentProviderTests1{
}
}
}
+
return true;
}
+
/**
* Method contains.
* @param res
@@ -482,6 +477,7 @@ public class ContentProviderTests1{
return true;
}
}
+
return false;
}
@@ -499,7 +495,7 @@ public class ContentProviderTests1{
return true;
}
}
+
return false;
}
-
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests2.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests2.java
index 7637c8ce5f..f2066bf123 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests2.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests2.java
@@ -13,8 +13,11 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.packageview;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
@@ -158,35 +161,35 @@ public class ContentProviderTests2{
@Test
public void testGetParentArchive() throws Exception{
Object parent= fProvider.getParent(fInternalRoot1);
- assertTrue("Wrong parent found for PackageFragmentRoot Archive", parent==fJProject3); //$NON-NLS-1$
+ assertSame("Wrong parent found for PackageFragmentRoot Archive", parent, fJProject3); //$NON-NLS-1$
}
@Test
public void testGetParentMidLevelFragmentInArchive() throws Exception{
Object expectedParent= fB;
Object parent= fProvider.getParent(fC);
- assertTrue("Wrong parent found for a NON top level PackageFragment in an Archive", expectedParent.equals(parent)); //$NON-NLS-1$
+ assertEquals("Wrong parent found for a NON top level PackageFragment in an Archive", expectedParent, parent); //$NON-NLS-1$
}
@Test
public void testGetParentTopLevelFragmentInArchive() throws Exception{
Object expectedParent= fInternalRoot1;
Object parent= fProvider.getParent(fA);
- assertTrue("Wrong parent found for a top level PackageFragment in an Archive", expectedParent.equals(parent)); //$NON-NLS-1$
+ assertEquals("Wrong parent found for a top level PackageFragment in an Archive", expectedParent, parent); //$NON-NLS-1$
}
@Test
public void testGetParentTopLevelFragment() throws Exception{
Object expectedParent= fJProject3;
Object parent= fProvider.getParent(fPack3);
- assertTrue("Wrong parent found for a top level PackageFragment", expectedParent.equals(parent)); //$NON-NLS-1$
+ assertEquals("Wrong parent found for a top level PackageFragment", expectedParent, parent); //$NON-NLS-1$
}
@Test
public void testGetParentMidLevelFragment() throws Exception{
Object expectedParent= fPack3;
Object parent= fProvider.getParent(fPack5);
- assertTrue("Wrong parent found for a NON top level PackageFragment", expectedParent.equals(parent)); //$NON-NLS-1$
+ assertEquals("Wrong parent found for a NON top level PackageFragment", expectedParent, parent); //$NON-NLS-1$
}
@@ -220,7 +223,7 @@ public class ContentProviderTests2{
//add rt.jar
jdk= JavaProjectHelper.addVariableRTJar(fJProject3, "JRE_LIB_TEST", null, null); //$NON-NLS-1$
- assertTrue("jdk not found", jdk != null); //$NON-NLS-1$
+ assertNotNull("jdk not found", jdk); //$NON-NLS-1$
//create the PackageFragmentRoot that represents the project as source folder
fRoot1= JavaProjectHelper.addSourceContainer(fJProject3, ""); //$NON-NLS-1$
@@ -229,7 +232,8 @@ public class ContentProviderTests2{
//set up project #3: file system structure with project as source folder
//add an internal jar
File myInternalLibJar= JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/myinternallib.jar")); //$NON-NLS-1$
- assertTrue("lib not found", myInternalLibJar != null && myInternalLibJar.exists()); //$NON-NLS-1$
+ assertNotNull("lib not found", myInternalLibJar); //$NON-NLS-1$
+ assertTrue("lib not found", myInternalLibJar.exists()); //$NON-NLS-1$
fInternalRoot1= JavaProjectHelper.addLibraryWithImport(fJProject3, Path.fromOSString(myInternalLibJar.getPath()), null, null);
//create internal PackageFragments
@@ -280,7 +284,7 @@ public class ContentProviderTests2{
fMyPart.clear();
fProvider = (ITreeContentProvider) fMyPart.getTreeViewer().getContentProvider();
} else
- assertTrue("Unable to get view", false); //$NON-NLS-1$
+ fail("Unable to get view"); //$NON-NLS-1$
assertNotNull(fProvider);
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests3.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests3.java
index a7d2a6dcea..de38ce997b 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests3.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests3.java
@@ -14,8 +14,11 @@
package org.eclipse.jdt.ui.tests.packageview;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
@@ -162,28 +165,28 @@ public class ContentProviderTests3{
@Test
public void testGetParentArchive() throws Exception{
Object parent= fProvider.getParent(fArchiveFragmentRoot);
- assertTrue("Wrong parent found for PackageFragmentRoot Archive with folding", parent==fJProject1);//$NON-NLS-1$
+ assertSame("Wrong parent found for PackageFragmentRoot Archive with folding", parent, fJProject1);//$NON-NLS-1$
}
@Test
public void testGetParentTopLevelFragmentInArchive() throws Exception{
Object expectedParent= fPackJunit;
Object parent= fProvider.getParent(fPackJunitSamples);
- assertTrue("Wrong parent found for a top level PackageFragment in an Archive with folding", expectedParent.equals(parent)); //$NON-NLS-1$
+ assertEquals("Wrong parent found for a top level PackageFragment in an Archive with folding", expectedParent, parent); //$NON-NLS-1$
}
@Test
public void testGetParentTopLevelFragment() throws Exception{
Object expectedParent= fRoot1;
Object parent= fProvider.getParent(fPack3);
- assertTrue("Wrong parent found for a top level PackageFragment with folding", expectedParent.equals(parent)); //$NON-NLS-1$
+ assertEquals("Wrong parent found for a top level PackageFragment with folding", expectedParent, parent); //$NON-NLS-1$
}
@Test
public void testGetParentFoldedBottomFragment() throws Exception{
Object expectedParent= fRoot1;
Object parent= fProvider.getParent(fPack3);
- assertTrue("Wrong parent found for a top level PackageFragment with folding", expectedParent.equals(parent));//$NON-NLS-1$
+ assertEquals("Wrong parent found for a top level PackageFragment with folding", expectedParent, parent);//$NON-NLS-1$
}
@@ -191,7 +194,7 @@ public class ContentProviderTests3{
public void testGetParentMidLevelFragment() throws Exception{
Object expectedParent= fPack3;
Object parent= fProvider.getParent(fPack4);
- assertTrue("Wrong parent found for a NON top level PackageFragment with folding", expectedParent.equals(parent));//$NON-NLS-1$
+ assertEquals("Wrong parent found for a NON top level PackageFragment with folding", expectedParent, parent);//$NON-NLS-1$
}
@Test
@@ -207,7 +210,7 @@ public class ContentProviderTests3{
assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$
assertTrue("Correct Refresh", fMyPart.wasObjectRefreshed(fRoot1)); //$NON-NLS-1$
- assertTrue("Single refresh", fMyPart.getRefreshedObject().size() == 1); //$NON-NLS-1$
+ assertEquals("Single refresh", 1, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$
}
@Test
@@ -223,10 +226,10 @@ public class ContentProviderTests3{
while(fMyPart.getTreeViewer().getControl().getDisplay().readAndDispatch()) {
}
- assertTrue("No add happened", !fMyPart.hasAddHappened()); //$NON-NLS-1$
+ assertFalse("No add happened", fMyPart.hasAddHappened()); //$NON-NLS-1$
assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$
assertTrue("Correct Refresh", fMyPart.wasObjectRefreshed(fRoot1)); //$NON-NLS-1$
- assertTrue("Single refresh", fMyPart.getRefreshedObject().size() == 1); //$NON-NLS-1$
+ assertEquals("Single refresh", 1, fMyPart.getRefreshedObject().size()); //$NON-NLS-1$
}
@Test
@@ -324,11 +327,12 @@ public class ContentProviderTests3{
//set up project #1 : External Jar and zip file
jdk= JavaProjectHelper.addVariableRTJar(fJProject1, "JRE_LIB_TEST", null, null);//$NON-NLS-1$
- assertTrue("jdk not found", jdk != null);//$NON-NLS-1$
+ assertNotNull("jdk not found", jdk);//$NON-NLS-1$
File junitSrcArchive= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
- assertTrue("junit src not found", junitSrcArchive != null && junitSrcArchive.exists());//$NON-NLS-1$
+ assertNotNull("junit src not found", junitSrcArchive);//$NON-NLS-1$
+ assertTrue("junit src not found", junitSrcArchive.exists());//$NON-NLS-1$
fArchiveFragmentRoot= JavaProjectHelper.addSourceContainerWithImport(fJProject1, "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);//$NON-NLS-1$
@@ -358,7 +362,8 @@ public class ContentProviderTests3{
fCUMoneyTest= fPackJunitSamplesMoney.getCompilationUnit("MoneyTest.java");//$NON-NLS-1$
File mylibJar= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.MYLIB);
- assertTrue("lib not found", mylibJar != null && mylibJar.exists());//$NON-NLS-1$
+ assertNotNull("lib not found", mylibJar);//$NON-NLS-1$
+ assertTrue("lib not found", mylibJar.exists());//$NON-NLS-1$
JavaProjectHelper.addLibraryWithImport(fJProject1, Path.fromOSString(mylibJar.getPath()), null, null);
//set up project #2: file system structure with in a source folder
@@ -407,7 +412,7 @@ public class ContentProviderTests3{
fMyPart.clear();
fProvider= (ITreeContentProvider)fMyPart.getTreeViewer().getContentProvider();
- }else assertTrue("Unable to get view",false);//$NON-NLS-1$
+ }else fail("Unable to get view");//$NON-NLS-1$
assertNotNull(fProvider);
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests4.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests4.java
index 4953f2c656..048db8de7b 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests4.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/packageview/ContentProviderTests4.java
@@ -13,8 +13,11 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.packageview;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
@@ -162,42 +165,42 @@ public class ContentProviderTests4{
@Test
public void testGetParentArchive() throws Exception{
Object parent= fProvider.getParent(fInternalRoot1);
- assertTrue("Wrong parent found for PackageFragmentRoot Archive with folding", parent==fJProject3);//$NON-NLS-1$
+ assertSame("Wrong parent found for PackageFragmentRoot Archive with folding", parent, fJProject3);//$NON-NLS-1$
}
@Test
public void testGetParentMidLevelFragmentInArchive() throws Exception{
Object expectedParent= fA;
Object parent= fProvider.getParent(fC);
- assertTrue("Wrong parent found for a NON top level PackageFragment in an Archive with folding", expectedParent.equals(parent));//$NON-NLS-1$
+ assertEquals("Wrong parent found for a NON top level PackageFragment in an Archive with folding", expectedParent, parent);//$NON-NLS-1$
}
@Test
public void testGetParentTopLevelFragmentInArchive() throws Exception{
Object expectedParent= fInternalRoot1;
Object parent= fProvider.getParent(fA);
- assertTrue("Wrong parent found for a top level PackageFragment in an Archive with folding", expectedParent.equals(parent)); //$NON-NLS-1$
+ assertEquals("Wrong parent found for a top level PackageFragment in an Archive with folding", expectedParent, parent); //$NON-NLS-1$
}
@Test
public void testGetParentTopLevelFragment() throws Exception{
Object expectedParent= fJProject3;
Object parent= fProvider.getParent(fPack3);
- assertTrue("Wrong parent found for a top level PackageFragment with folding", expectedParent.equals(parent));//$NON-NLS-1$
+ assertEquals("Wrong parent found for a top level PackageFragment with folding", expectedParent, parent);//$NON-NLS-1$
}
@Test
public void testGetParentMidLevelFragment() throws Exception{
Object expectedParent= fPack3;
Object parent= fProvider.getParent(fPack6);
- assertTrue("Wrong parent found for a NON top level PackageFragment with folding", expectedParent.equals(parent));//$NON-NLS-1$
+ assertEquals("Wrong parent found for a NON top level PackageFragment with folding", expectedParent, parent);//$NON-NLS-1$
}
@Test
public void testGetParentMidLevelFragment2() throws Exception{
Object expectedParent= fPack3;
Object parent= fProvider.getParent(fPack5);
- assertTrue("Wrong parent found for a NON top level PackageFragment with folding", expectedParent.equals(parent));//$NON-NLS-1$
+ assertEquals("Wrong parent found for a NON top level PackageFragment with folding", expectedParent, parent);//$NON-NLS-1$
}
@@ -229,7 +232,7 @@ public class ContentProviderTests4{
//add rt.jar
jdk= JavaProjectHelper.addVariableRTJar(fJProject3, "JRE_LIB_TEST", null, null);//$NON-NLS-1$
- assertTrue("jdk not found", jdk != null);//$NON-NLS-1$
+ assertNotNull("jdk not found", jdk);//$NON-NLS-1$
//create the PackageFragmentRoot that represents the project as source folder
fRoot1= JavaProjectHelper.addSourceContainer(fJProject3, "");//$NON-NLS-1$
@@ -241,7 +244,8 @@ public class ContentProviderTests4{
//set up project #3: file system structure with project as source folder
//add an internal jar
myInternalLibJar = JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/myinternallib.jar"));//$NON-NLS-1$
- assertTrue("lib not found", myInternalLibJar != null && myInternalLibJar.exists()); //$NON-NLS-1$
+ assertNotNull("lib not found", myInternalLibJar); //$NON-NLS-1$
+ assertTrue("lib not found", myInternalLibJar.exists()); //$NON-NLS-1$
fInternalRoot1= JavaProjectHelper.addLibraryWithImport(fJProject3, Path.fromOSString(myInternalLibJar.getPath()), null, null);
//create internal PackageFragments
@@ -293,7 +297,7 @@ public class ContentProviderTests4{
fMyPart.clear();
fProvider = (ITreeContentProvider) fMyPart.getTreeViewer().getContentProvider();
} else
- assertTrue("Unable to get view", false);//$NON-NLS-1$
+ fail("Unable to get view");//$NON-NLS-1$
assertNotNull(fProvider);
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/preferences/OptionsConfigurationBlockTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/preferences/OptionsConfigurationBlockTest.java
index de8222fcb4..527eee976d 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/preferences/OptionsConfigurationBlockTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/preferences/OptionsConfigurationBlockTest.java
@@ -85,7 +85,7 @@ public class OptionsConfigurationBlockTest {
*/
@Deprecated
private void removeUnusedOptions(HashMap<String, String> coreFieldLookup) {
- coreFieldLookup.keySet().removeAll(Arrays.asList(new String[] {
+ coreFieldLookup.keySet().removeAll(Arrays.asList(
JavaCore.COMPILER_PB_INCONSISTENT_NULL_CHECK,
JavaCore.COMPILER_PB_INVALID_IMPORT,
JavaCore.COMPILER_PB_UNREACHABLE_CODE,
@@ -105,8 +105,7 @@ public class OptionsConfigurationBlockTest {
JavaCore.COMPILER_PB_DEAD_CODE_IN_TRIVIAL_IF_STATEMENT, // default is good (don't flag trivial 'if (DEBUG)')
JavaCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, // is on the Type Filters page now, see https://bugs.eclipse.org/218487
- JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, // is on the Type Filters page now, see https://bugs.eclipse.org/218487
- }));
+ JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK)); // is on the Type Filters page now, see https://bugs.eclipse.org/218487
}
private void checkConfigurationBlock(Class<?> configurationBlock, HashMap<String, String> coreFieldLookup) throws Exception {
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest17.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d7.java
index a34409addd..002e833a48 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest17.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d7.java
@@ -49,8 +49,11 @@ import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.correction.AssistContext;
import org.eclipse.jdt.internal.ui.text.correction.CorrectionMessages;
+/**
+ * Those tests should run on Java Dolphin 1.7 .
+ */
@RunWith(JUnit4.class)
-public class AdvancedQuickAssistTest17 extends QuickFixTest {
+public class AdvancedQuickAssistTest1d7 extends QuickFixTest {
@Rule
public ProjectTestSetup projectsetup = new Java1d7ProjectTestSetup();
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d8.java
index 024421407f..d80bba0d54 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest18.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AdvancedQuickAssistTest1d8.java
@@ -39,7 +39,7 @@ import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType;
import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.ui.PreferenceConstants;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
@@ -47,11 +47,13 @@ import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.correction.AssistContext;
import org.eclipse.jdt.internal.ui.text.correction.CorrectionMessages;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@RunWith(JUnit4.class)
-public class AdvancedQuickAssistTest18 extends QuickFixTest {
-
+public class AdvancedQuickAssistTest1d8 extends QuickFixTest {
@Rule
- public ProjectTestSetup projectsetup = new Java18ProjectTestSetup();
+ public ProjectTestSetup projectsetup = new Java1d8ProjectTestSetup();
private IJavaProject fJProject1;
@@ -71,15 +73,14 @@ public class AdvancedQuickAssistTest18 extends QuickFixTest {
StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null);
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
-
@After
public void tearDown() throws Exception {
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
@Test
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d8.java
index 658d8d0929..59192896d3 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest18.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AnnotateAssistTest1d8.java
@@ -36,25 +36,28 @@ import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.JavaUI;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@RunWith(JUnit4.class)
-public class AnnotateAssistTest18 extends AbstractAnnotateAssistTests {
+public class AnnotateAssistTest1d8 extends AbstractAnnotateAssistTests {
@Rule
- public ProjectTestSetup projectsetup = new Java18ProjectTestSetup();
+ public ProjectTestSetup projectsetup = new Java1d8ProjectTestSetup();
protected static final String ANNOTATION_PATH= "annots";
- protected static final Class<?> THIS= AnnotateAssistTest18.class;
+ protected static final Class<?> THIS= AnnotateAssistTest1d8.class;
@Before
public void setUp() throws Exception {
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
fJProject1.getProject().getFolder(ANNOTATION_PATH).create(true, true, null);
fJProject1.setOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
}
@@ -390,7 +393,7 @@ public class AnnotateAssistTest18 extends AbstractAnnotateAssistTests {
* An entry with annotation on the outer array already exists and will be amended.
* Apply the second proposal and check the effect.
*
- * Cf. {@link AnnotateAssistTest18#testAnnotateParameter_Array3()}
+ * Cf. {@link AnnotateAssistTest1d8#testAnnotateParameter_Array3()}
* @throws Exception multiple causes
*/
@Test
@@ -465,7 +468,7 @@ public class AnnotateAssistTest18 extends AbstractAnnotateAssistTests {
* An entry with annotation on the inner array already exists and will be amended.
* Apply the second proposal and check the effect.
*
- * Cf. {@link AnnotateAssistTest18#testAnnotateParameter_Array3()}
+ * Cf. {@link AnnotateAssistTest1d8#testAnnotateParameter_Array3()}
* @throws Exception multiple causes
*/
@Test
@@ -685,7 +688,7 @@ public class AnnotateAssistTest18 extends AbstractAnnotateAssistTests {
* Assert two proposals ("@NonNull" and "@Nullable") on the array representing the varargs ellipsis
* Apply the second proposal and check the effect.
*
- * Cf. {@link AnnotateAssistTest18#testAnnotateParameter_Array3()}
+ * Cf. {@link AnnotateAssistTest1d8#testAnnotateParameter_Array3()}
* @throws Exception multiple causes
*/
@Test
@@ -759,7 +762,7 @@ public class AnnotateAssistTest18 extends AbstractAnnotateAssistTests {
* An entry with annotation on the inner array already exists and will be amended.
* Apply the second proposal and check the effect.
*
- * Cf. {@link AnnotateAssistTest18#testAnnotateParameter_Varargs1()}
+ * Cf. {@link AnnotateAssistTest1d8#testAnnotateParameter_Varargs1()}
* @throws Exception multiple causes
*/
@Test
@@ -833,7 +836,7 @@ public class AnnotateAssistTest18 extends AbstractAnnotateAssistTests {
* Assert two proposals ("@NonNull" and "@Nullable") on the element type of a varargs type
* Apply the second proposal and check the effect.
*
- * Cf. {@link AnnotateAssistTest18#testAnnotateParameter_Array3()}
+ * Cf. {@link AnnotateAssistTest1d8#testAnnotateParameter_Array3()}
* @throws Exception multiple causes
*/
@Test
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java
index d1e2c626d9..4d8bf23d46 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java
@@ -68,7 +68,6 @@ import org.eclipse.jdt.internal.ui.text.correction.proposals.RenameRefactoringPr
@RunWith(JUnit4.class)
public class AssistQuickFixTest extends QuickFixTest {
-
@Rule
public ProjectTestSetup projectsetup = new ProjectTestSetup();
@@ -3070,6 +3069,146 @@ public class AssistQuickFixTest extends QuickFixTest {
}
@Test
+ public void testSplitDeclaration8() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" for (long i = 2, j = 1; i < j; i++) {\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
+
+ String str= "=";
+ AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
+ List<IJavaCompletionProposal> proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview= getPreviewContent(proposal);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" long i, j;\n");
+ buf.append(" for (i = 2, j = 1; i < j; i++) {\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ assertEqualString(preview, buf.toString());
+ }
+
+ @Test
+ public void testSplitDeclaration9() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" for (/*1*/long i = 2/*2*/, j/*3*/; i < 1; i++) {\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
+
+ String str= "=";
+ AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
+ List<IJavaCompletionProposal> proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview= getPreviewContent(proposal);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" /*1*/long i, j;\n");
+ buf.append(" for (i = 2/*2*/, j/*3*/ = 0; i < 1; i++) {\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ assertEqualString(preview, buf.toString());
+ }
+
+ @Test
+ public void testSplitDeclaration10() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" for (/*1*/boolean i = true/*2*/, j/*3*/; i != true; ) {\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
+
+ String str= "=";
+ AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
+ List<IJavaCompletionProposal> proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview= getPreviewContent(proposal);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" /*1*/boolean i, j;\n");
+ buf.append(" for (i = true/*2*/, j/*3*/ = false; i != true; ) {\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ assertEqualString(preview, buf.toString());
+ }
+
+ @Test
+ public void testSplitDeclaration11() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" for (/*1*/Object i = null/*2*/, j/*3*/; i == null; ) {\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
+
+ String str= "=";
+ AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
+ List<IJavaCompletionProposal> proposals= collectAssists(context, false);
+
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview= getPreviewContent(proposal);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public void foo() {\n");
+ buf.append(" /*1*/Object i, j;\n");
+ buf.append(" for (i = null/*2*/, j/*3*/ = null; i == null; ) {\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ assertEqualString(preview, buf.toString());
+ }
+
+ @Test
public void testJoinDeclaration1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
@@ -4727,7 +4866,7 @@ public class AssistQuickFixTest extends QuickFixTest {
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
- buf.append(" \"a\".equals((\"a\"));\n");
+ buf.append(" \"a\".equals(((\"a\")));\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
@@ -4746,7 +4885,7 @@ public class AssistQuickFixTest extends QuickFixTest {
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
- buf.append(" (\"a\").equals(\"a\");\n");
+ buf.append(" ((\"a\")).equals(\"a\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest17.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java
index 653c805b7b..6d4a24ec2e 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest17.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d7.java
@@ -50,8 +50,11 @@ import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.correction.AssistContext;
import org.eclipse.jdt.internal.ui.text.correction.CorrectionMessages;
+/**
+ * Those tests should run on Java Dolphin 1.7 .
+ */
@RunWith(JUnit4.class)
-public class AssistQuickFixTest17 extends QuickFixTest {
+public class AssistQuickFixTest1d7 extends QuickFixTest {
@Rule
public ProjectTestSetup projectsetup = new Java1d7ProjectTestSetup();
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d8.java
index 38edb615e2..752a301d39 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest18.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest1d8.java
@@ -48,7 +48,7 @@ import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.corext.fix.FixMessages;
import org.eclipse.jdt.ui.PreferenceConstants;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
@@ -57,18 +57,20 @@ import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.correction.AssistContext;
import org.eclipse.jdt.internal.ui.text.correction.CorrectionMessages;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@RunWith(JUnit4.class)
-public class AssistQuickFixTest18 extends QuickFixTest {
-
+public class AssistQuickFixTest1d8 extends QuickFixTest {
@Rule
- public ProjectTestSetup projectsetup = new Java18ProjectTestSetup();
+ public ProjectTestSetup projectsetup = new Java1d8ProjectTestSetup();
private IJavaProject fJProject1;
private IPackageFragmentRoot fSourceFolder;
// public static Test setUpTest() {
-// return new Java18ProjectTestSetup() {
+// return new Java1d8ProjectTestSetup() {
// @Override
// protected void setUp() throws Exception {
// JavaProjectHelper.PERFORM_DUMMY_SEARCH++;
@@ -94,13 +96,13 @@ public class AssistQuickFixTest18 extends QuickFixTest {
StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null);
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
@After
public void tearDown() throws Exception {
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
@Test
@@ -4888,7 +4890,7 @@ public class AssistQuickFixTest18 extends QuickFixTest {
Hashtable<String, String> options= JavaCore.getOptions();
options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
@@ -4988,7 +4990,7 @@ public class AssistQuickFixTest18 extends QuickFixTest {
Hashtable<String, String> options= JavaCore.getOptions();
options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
@@ -5096,7 +5098,7 @@ public class AssistQuickFixTest18 extends QuickFixTest {
Hashtable<String, String> options= JavaCore.getOptions();
options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
@@ -5208,7 +5210,7 @@ public class AssistQuickFixTest18 extends QuickFixTest {
Hashtable<String, String> options= JavaCore.getOptions();
options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java
index 9ef397e4e9..ccdf64cda1 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java
@@ -5127,6 +5127,352 @@ public class CleanUpTest extends CleanUpTestCase {
}
@Test
+ public void testMergeConditionalBlocks() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ String sample= "" //
+ + "package test1;\n" //
+ + "\n" //
+ + "public class E1 {\n" //
+ + "\n" //
+ + " /** Duplicate if and else if code, merge it */\n" //
+ + " public void duplicateIfAndElseIf(int i) {\n" //
+ + " // Keep this comment\n" //
+ + " if (i == 0) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else if (i == 1) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate if and else if code, merge it */\n" //
+ + " public void mergeTwoStructures(int a, int b) {\n" //
+ + " // Keep this comment\n" //
+ + " if (a == 0) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else if (a == 1) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + "\n" //
+ + " // Keep this comment\n" //
+ + " if (b == 0) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else if (b == 1) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate if and else code, merge it */\n" //
+ + " public void duplicateIfAndElse(int j) {\n" //
+ + " // Keep this comment\n" //
+ + " if (j == 0) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else if (j == 1) {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " } else {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate if and else if code, merge it */\n" //
+ + " public void duplicateIfAndElseIfWithoutElse(int k) {\n" //
+ + " // Keep this comment\n" //
+ + " if (k == 0) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else if (k == 1) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate else if codes, merge it */\n" //
+ + " public void duplicateIfAndElseIfAmongOther(int m) {\n" //
+ + " // Keep this comment\n" //
+ + " if (m == 0) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"A given code\");\n" //
+ + " } if (m == 1) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else if (m == 2) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate if and else if code, merge it */\n" //
+ + " public void duplicateSingleStatement(int n) {\n" //
+ + " // Keep this comment\n" //
+ + " if (n == 0)\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " else if (n == 1)\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " else\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate if and else if code, merge it */\n" //
+ + " public void numerousDuplicateIfAndElseIf(int o) {\n" //
+ + " // Keep this comment\n" //
+ + " if (o == 0) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else if (o == 1) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else if (o == 2)\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " else if (o == 3) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate if and else if code, merge it */\n" //
+ + " public void complexIfAndElseIf(int p) {\n" //
+ + " // Keep this comment\n" //
+ + " if (p == 0) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate \");\n" //
+ + " } else if (p == 1 || p == 2) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate \");\n" //
+ + " } else if (p > 10) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate \");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate if and else if code, merge it */\n" //
+ + " public void longIfAndElseIf(int q) {\n" //
+ + " // Keep this comment\n" //
+ + " if (q == 0) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " System.out.println(\"code\");\n" //
+ + " } else if (q == 1) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " System.out.println(\"code\");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "}\n";
+ ICompilationUnit cu1= pack1.createCompilationUnit("E1.java", sample, false, null);
+
+ enable(CleanUpConstants.MERGE_CONDITIONAL_BLOCKS);
+
+ sample= "" //
+ + "package test1;\n" //
+ + "\n" //
+ + "public class E1 {\n" //
+ + "\n" //
+ + " /** Duplicate if and else if code, merge it */\n" //
+ + " public void duplicateIfAndElseIf(int i) {\n" //
+ + " // Keep this comment\n" //
+ + " if ((i == 0) || (i == 1)) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate if and else if code, merge it */\n" //
+ + " public void mergeTwoStructures(int a, int b) {\n" //
+ + " // Keep this comment\n" //
+ + " if ((a == 0) || (a == 1)) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + "\n" //
+ + " // Keep this comment\n" //
+ + " if ((b == 0) || (b == 1)) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate if and else code, merge it */\n" //
+ + " public void duplicateIfAndElse(int j) {\n" //
+ + " // Keep this comment\n" //
+ + " if ((j == 0) || !(j == 1)) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate if and else if code, merge it */\n" //
+ + " public void duplicateIfAndElseIfWithoutElse(int k) {\n" //
+ + " // Keep this comment\n" //
+ + " if ((k == 0) || (k == 1)) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate else if codes, merge it */\n" //
+ + " public void duplicateIfAndElseIfAmongOther(int m) {\n" //
+ + " // Keep this comment\n" //
+ + " if (m == 0) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"A given code\");\n" //
+ + " } if ((m == 1) || (m == 2)) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate if and else if code, merge it */\n" //
+ + " public void duplicateSingleStatement(int n) {\n" //
+ + " // Keep this comment\n" //
+ + " if ((n == 0) || (n == 1))\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " else\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate if and else if code, merge it */\n" //
+ + " public void numerousDuplicateIfAndElseIf(int o) {\n" //
+ + " // Keep this comment\n" //
+ + " if ((o == 0) || (o == 1) || (o == 2)\n" //
+ + " || (o == 3)) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate if and else if code, merge it */\n" //
+ + " public void complexIfAndElseIf(int p) {\n" //
+ + " // Keep this comment\n" //
+ + " if ((p == 0) || (p == 1 || p == 2) || (p > 10)) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate \");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Duplicate if and else if code, merge it */\n" //
+ + " public void longIfAndElseIf(int q) {\n" //
+ + " // Keep this comment\n" //
+ + " if ((q == 0) || (q == 1)) {\n" //
+ + " // Keep this comment too\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " System.out.println(\"code\");\n" //
+ + " } else {\n" //
+ + " // Keep this comment also\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "}\n";
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { sample });
+ }
+
+ @Test
+ public void testDoNotMergeConditionalBlocks() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ String sample= "" //
+ + "package test1;\n" //
+ + "\n" //
+ + "public class E1 {\n" //
+ + " /** 5 operands, not easily readable */\n" //
+ + " public void doNotMergeMoreThanFourOperands(int i) {\n" //
+ + " if ((i == 0) || (i == 1 || i == 2)) {\n" //
+ + " System.out.println(\"Duplicate \");\n" //
+ + " } else if (i > 10 && i < 100) {\n" //
+ + " System.out.println(\"Duplicate \");\n" //
+ + " } else {\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Different if and else if code, leave it */\n" //
+ + " public void doNotMergeAdditionalCode(int i) {\n" //
+ + " if (i == 0) {\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else if (i == 1) {\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " System.out.println(\"but not only\");\n" //
+ + " } else {\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "\n" //
+ + " /** Different code in the middle, leave it */\n" //
+ + " public void doNotMergeIntruderCode(int i) {\n" //
+ + " if (i == 0) {\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else if (i == 1) {\n" //
+ + " System.out.println(\"Intruder\");\n" //
+ + " } else if (i == 2) {\n" //
+ + " System.out.println(\"Duplicate\");\n" //
+ + " } else {\n" //
+ + " System.out.println(\"Different\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "}\n";
+ ICompilationUnit cu1= pack1.createCompilationUnit("E1.java", sample, false, null);
+
+ enable(CleanUpConstants.MERGE_CONDITIONAL_BLOCKS);
+
+ assertRefactoringHasNoChange(new ICompilationUnit[] { cu1 });
+ }
+
+ @Test
public void testMapMethodRatherThanKeySetMethod() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
String sample= "" //
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest18.java
deleted file mode 100644
index ea641075d0..0000000000
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest18.java
+++ /dev/null
@@ -1,1034 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2020 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Fabrice TIERCELIN - Lambda expression cleanup
- *******************************************************************************/
-package org.eclipse.jdt.ui.tests.quickfix;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-
-import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType;
-import org.eclipse.jdt.internal.core.manipulation.StubUtility;
-import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
-
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
-import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
-
-@RunWith(JUnit4.class)
-public class CleanUpTest18 extends CleanUpTestCase {
-
- @Rule
- public ProjectTestSetup projectsetup = new Java18ProjectTestSetup();
-
- @Override
- @Before
- public void setUp() throws Exception {
- super.setUp();
- StubUtility.setCodeTemplate(CodeTemplateContextType.OVERRIDECOMMENT_ID, "", null);
- }
-
- @Override
- protected IJavaProject getProject() {
- return Java18ProjectTestSetup.getProject();
- }
-
- @Override
- protected IClasspathEntry[] getDefaultClasspath() throws CoreException {
- return Java18ProjectTestSetup.getDefaultClasspath();
- }
-
- @Test
- public void testConvertToLambda01() throws Exception {
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class E {\n");
- buf.append(" void foo(){\n");
- buf.append(" Runnable r = new Runnable() {\n");
- buf.append(" @Override\n");
- buf.append(" public void run() {\n");
- buf.append(" System.out.println(\"do something\");\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" };\n");
- buf.append("}\n");
- String original= buf.toString();
- ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_LAMBDA);
-
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class E {\n");
- buf.append(" void foo(){\n");
- buf.append(" Runnable r = () -> System.out.println(\"do something\");\n");
- buf.append(" };\n");
- buf.append("}\n");
- String expected1= buf.toString();
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
-
- disable(CleanUpConstants.USE_LAMBDA);
- enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
- }
-
- @Test
- public void testConvertToLambda02() throws Exception {
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class E {\n");
- buf.append(" void foo(){\n");
- buf.append(" Runnable r1 = new Runnable() {\n");
- buf.append(" @Override\n");
- buf.append(" public void run() {\n");
- buf.append(" System.out.println(\"do something\");\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" Runnable r2 = new Runnable() {\n");
- buf.append(" @Override\n");
- buf.append(" public void run() {\n");
- buf.append(" System.out.println(\"do one thing\");\n");
- buf.append(" System.out.println(\"do another thing\");\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" };\n");
- buf.append("}\n");
- String original= buf.toString();
- ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_LAMBDA);
-
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class E {\n");
- buf.append(" void foo(){\n");
- buf.append(" Runnable r1 = () -> System.out.println(\"do something\");\n");
- buf.append(" Runnable r2 = () -> {\n");
- buf.append(" System.out.println(\"do one thing\");\n");
- buf.append(" System.out.println(\"do another thing\");\n");
- buf.append(" };\n");
- buf.append(" };\n");
- buf.append("}\n");
- String expected1= buf.toString();
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
-
- disable(CleanUpConstants.USE_LAMBDA);
- enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
- }
-
- @Test
- public void testConvertToLambda03() throws Exception {
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("import java.util.function.Supplier;\n");
- buf.append("class E {\n");
- buf.append(" Supplier<Supplier<String>> s= new Supplier<Supplier<String>>() {\n");
- buf.append(" @Override\n");
- buf.append(" public Supplier<String> get() {\n");
- buf.append(" return new Supplier<String>() {\n");
- buf.append(" @Override\n");
- buf.append(" public String get() {\n");
- buf.append(" return \"a\";\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append("}\n");
- String original= buf.toString();
- ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_LAMBDA);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("import java.util.function.Supplier;\n");
- buf.append("class E {\n");
- buf.append(" Supplier<Supplier<String>> s= () -> () -> \"a\";\n");
- buf.append("}\n");
- String expected1= buf.toString();
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
-
- disable(CleanUpConstants.USE_LAMBDA);
- enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
- }
-
- @Test
- public void testConvertToLambdaNestedWithImports() throws Exception {
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("import java.util.concurrent.Callable;\n");
- buf.append("import java.util.concurrent.Executors;\n");
- buf.append("public class E {\n");
- buf.append(" void foo() {\n");
- buf.append(" new Thread(new Runnable() {\n");
- buf.append(" @Override\n");
- buf.append(" public void run() {\n");
- buf.append(" Executors.newSingleThreadExecutor().submit(new Callable<String>() {\n");
- buf.append(" @Override\n");
- buf.append(" public String call() throws Exception {\n");
- buf.append(" return \"hi\";\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append("}\n");
- String original= buf.toString();
- ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_LAMBDA);
-
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("import java.util.concurrent.Executors;\n");
- buf.append("public class E {\n");
- buf.append(" void foo() {\n");
- buf.append(" new Thread(() -> Executors.newSingleThreadExecutor().submit(() -> \"hi\"));\n");
- buf.append(" }\n");
- buf.append("}\n");
- String expected1= buf.toString();
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
-
- disable(CleanUpConstants.USE_LAMBDA);
- enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
- }
-
- // fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=434507#c5
- @Test
- public void testConvertToLambdaAmbiguous01() throws Exception {
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("\n");
- buf.append("interface ISuper {\n");
- buf.append(" void foo(FI1 fi1);\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("interface ISub extends ISuper {\n");
- buf.append(" void foo(FI2 fi2);\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("@FunctionalInterface\n");
- buf.append("interface FI1 {\n");
- buf.append(" void abc();\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("@FunctionalInterface\n");
- buf.append("interface FI2 {\n");
- buf.append(" void xyz();\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("class Test1 {\n");
- buf.append(" private void test1() {\n");
- buf.append(" f1().foo(new FI1() {\n");
- buf.append(" @Override\n");
- buf.append(" public void abc() {\n");
- buf.append(" System.out.println();\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append("\n");
- buf.append(" }\n");
- buf.append(" \n");
- buf.append(" private ISub f1() {\n");
- buf.append(" return null;\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("abstract class Test2 implements ISub {\n");
- buf.append(" private void test2() {\n");
- buf.append(" foo(new FI1() {\n");
- buf.append(" @Override\n");
- buf.append(" public void abc() {\n");
- buf.append(" System.out.println();\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("class Test3 {\n");
- buf.append(" void foo(FI1 fi1) {}\n");
- buf.append(" void foo(FI2 fi2) {}\n");
- buf.append(" private void test3() {\n");
- buf.append(" foo(new FI1() {\n");
- buf.append(" @Override\n");
- buf.append(" public void abc() {\n");
- buf.append(" System.out.println();\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("class Outer {\n");
- buf.append(" class Test4 {\n");
- buf.append(" {\n");
- buf.append(" bar(0, new FI1() {\n");
- buf.append(" @Override\n");
- buf.append(" public void abc() {\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append(" void bar(int i, FI1 fi1) {}\n");
- buf.append(" void bar(int s, FI2 fi2) {}\n");
- buf.append("}\n");
- String original= buf.toString();
- ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_LAMBDA);
-
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("\n");
- buf.append("interface ISuper {\n");
- buf.append(" void foo(FI1 fi1);\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("interface ISub extends ISuper {\n");
- buf.append(" void foo(FI2 fi2);\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("@FunctionalInterface\n");
- buf.append("interface FI1 {\n");
- buf.append(" void abc();\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("@FunctionalInterface\n");
- buf.append("interface FI2 {\n");
- buf.append(" void xyz();\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("class Test1 {\n");
- buf.append(" private void test1() {\n");
- buf.append(" f1().foo((FI1) () -> System.out.println());\n");
- buf.append("\n");
- buf.append(" }\n");
- buf.append(" \n");
- buf.append(" private ISub f1() {\n");
- buf.append(" return null;\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("abstract class Test2 implements ISub {\n");
- buf.append(" private void test2() {\n");
- buf.append(" foo((FI1) () -> System.out.println());\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("class Test3 {\n");
- buf.append(" void foo(FI1 fi1) {}\n");
- buf.append(" void foo(FI2 fi2) {}\n");
- buf.append(" private void test3() {\n");
- buf.append(" foo((FI1) () -> System.out.println());\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("class Outer {\n");
- buf.append(" class Test4 {\n");
- buf.append(" {\n");
- buf.append(" bar(0, (FI1) () -> {\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append(" void bar(int i, FI1 fi1) {}\n");
- buf.append(" void bar(int s, FI2 fi2) {}\n");
- buf.append("}\n");
- String expected1= buf.toString();
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
-
- disable(CleanUpConstants.USE_LAMBDA);
- enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
- }
-
- // fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=434507#c5
- @Test
- public void testConvertToLambdaAmbiguous02() throws Exception {
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("\n");
- buf.append("@FunctionalInterface\n");
- buf.append("interface FI1 {\n");
- buf.append(" void abc();\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("@FunctionalInterface\n");
- buf.append("interface FI2 {\n");
- buf.append(" void xyz();\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("class Outer {\n");
- buf.append(" void outer(FI1 fi1) {}\n");
- buf.append("}\n");
- buf.append("class OuterSub extends Outer {\n");
- buf.append(" OuterSub() {\n");
- buf.append(" super.outer(new FI1() {\n");
- buf.append(" @Override\n");
- buf.append(" public void abc() {\n");
- buf.append(" System.out.println();\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append(" class Test1 {\n");
- buf.append(" private void test1() {\n");
- buf.append(" OuterSub.super.outer(new FI1() {\n");
- buf.append(" @Override\n");
- buf.append(" public void abc() {\n");
- buf.append(" System.out.println();\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" OuterSub.this.outer(new FI1() {\n");
- buf.append(" @Override\n");
- buf.append(" public void abc() {\n");
- buf.append(" System.out.println();\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" outer(new FI1() {\n");
- buf.append(" @Override\n");
- buf.append(" public void abc() {\n");
- buf.append(" System.out.println();\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append(" @Override\n");
- buf.append(" void outer(FI1 fi1) {}\n");
- buf.append(" void outer(FI2 fi2) {}\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("class OuterSub2 extends OuterSub {\n");
- buf.append(" OuterSub2() {\n");
- buf.append(" super.outer(new FI1() {\n");
- buf.append(" @Override\n");
- buf.append(" public void abc() {\n");
- buf.append(" System.out.println();\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append(" class Test2 {\n");
- buf.append(" private void test2() {\n");
- buf.append(" OuterSub2.super.outer(new FI1() {\n");
- buf.append(" @Override\n");
- buf.append(" public void abc() {\n");
- buf.append(" System.out.println();\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" OuterSub2.this.outer(new FI1() {\n");
- buf.append(" @Override\n");
- buf.append(" public void abc() {\n");
- buf.append(" System.out.println();\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" outer(new FI1() {\n");
- buf.append(" @Override\n");
- buf.append(" public void abc() {\n");
- buf.append(" System.out.println();\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append("}\n");
- String original= buf.toString();
- ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_LAMBDA);
-
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("\n");
- buf.append("@FunctionalInterface\n");
- buf.append("interface FI1 {\n");
- buf.append(" void abc();\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("@FunctionalInterface\n");
- buf.append("interface FI2 {\n");
- buf.append(" void xyz();\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("class Outer {\n");
- buf.append(" void outer(FI1 fi1) {}\n");
- buf.append("}\n");
- buf.append("class OuterSub extends Outer {\n");
- buf.append(" OuterSub() {\n");
- buf.append(" super.outer(() -> System.out.println());\n");
- buf.append(" }\n");
- buf.append(" class Test1 {\n");
- buf.append(" private void test1() {\n");
- buf.append(" OuterSub.super.outer(() -> System.out.println());\n");
- buf.append(" OuterSub.this.outer((FI1) () -> System.out.println());\n");
- buf.append(" outer((FI1) () -> System.out.println());\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append(" @Override\n");
- buf.append(" void outer(FI1 fi1) {}\n");
- buf.append(" void outer(FI2 fi2) {}\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("class OuterSub2 extends OuterSub {\n");
- buf.append(" OuterSub2() {\n");
- buf.append(" super.outer((FI1) () -> System.out.println());\n");
- buf.append(" }\n");
- buf.append(" class Test2 {\n");
- buf.append(" private void test2() {\n");
- buf.append(" OuterSub2.super.outer((FI1) () -> System.out.println());\n");
- buf.append(" OuterSub2.this.outer((FI1) () -> System.out.println());\n");
- buf.append(" outer((FI1) () -> System.out.println());\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append("}\n");
- String expected1= buf.toString();
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
-
- disable(CleanUpConstants.USE_LAMBDA);
- enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
- }
-
- // fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=434507#c2
- @Test
- public void testConvertToLambdaAmbiguous03() throws Exception {
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public interface E {\n");
- buf.append(" default void m() {\n");
- buf.append(" bar(0, new FI() {\n");
- buf.append(" @Override\n");
- buf.append(" public int foo(int x) {\n");
- buf.append(" return x++;\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" baz(0, new ZI() {\n");
- buf.append(" @Override\n");
- buf.append(" public int zoo() {\n");
- buf.append(" return 1;\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append("\n");
- buf.append(" void bar(int i, FI fi);\n");
- buf.append(" void bar(int i, FV fv);\n");
- buf.append("\n");
- buf.append(" void baz(int i, ZI zi);\n");
- buf.append(" void baz(int i, ZV zv);\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("@FunctionalInterface interface FI { int foo(int a); }\n");
- buf.append("@FunctionalInterface interface FV { void foo(int a); }\n");
- buf.append("\n");
- buf.append("@FunctionalInterface interface ZI { int zoo(); }\n");
- buf.append("@FunctionalInterface interface ZV { void zoo(); }\n");
- String original= buf.toString();
- ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_LAMBDA);
-
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public interface E {\n");
- buf.append(" default void m() {\n");
- buf.append(" bar(0, (FI) x -> x++);\n");
- buf.append(" baz(0, () -> 1);\n");
- buf.append(" }\n");
- buf.append("\n");
- buf.append(" void bar(int i, FI fi);\n");
- buf.append(" void bar(int i, FV fv);\n");
- buf.append("\n");
- buf.append(" void baz(int i, ZI zi);\n");
- buf.append(" void baz(int i, ZV zv);\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("@FunctionalInterface interface FI { int foo(int a); }\n");
- buf.append("@FunctionalInterface interface FV { void foo(int a); }\n");
- buf.append("\n");
- buf.append("@FunctionalInterface interface ZI { int zoo(); }\n");
- buf.append("@FunctionalInterface interface ZV { void zoo(); }\n");
- String expected1= buf.toString();
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
-
- disable(CleanUpConstants.USE_LAMBDA);
- enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
- }
-
- @Test
- public void testConvertToLambdaConflictingNames() throws Exception {
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("\n");
- buf.append("interface FI {\n");
- buf.append(" void run(int x);\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("public class Test {\n");
- buf.append(" {\n");
- buf.append(" int e;\n");
- buf.append(" FI fi = new FI() {\n");
- buf.append(" @Override\n");
- buf.append(" public void run(int e) {\n");
- buf.append(" class C1 {\n");
- buf.append(" void init1() {\n");
- buf.append(" m(new FI() {\n");
- buf.append(" @Override\n");
- buf.append(" public void run(int e) {\n");
- buf.append(" FI fi = new FI() {\n");
- buf.append(" @Override\n");
- buf.append(" public void run(int e) {\n");
- buf.append(" FI fi = new FI() {\n");
- buf.append(" @Override\n");
- buf.append(" public void run(int e) {\n");
- buf.append(" return;\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append("\n");
- buf.append(" void init2() {\n");
- buf.append(" m(new FI() {\n");
- buf.append(" @Override\n");
- buf.append(" public void run(int e) {\n");
- buf.append(" new FI() {\n");
- buf.append(" @Override\n");
- buf.append(" public void run(int e3) {\n");
- buf.append(" FI fi = new FI() {\n");
- buf.append(" @Override\n");
- buf.append(" public void run(int e) {\n");
- buf.append(" return;\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" }\n");
- buf.append("\n");
- buf.append(" void m(FI fi) {\n");
- buf.append(" };\n");
- buf.append("}\n");
- String original= buf.toString();
- ICompilationUnit cu1= pack1.createCompilationUnit("Test.java", original, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_LAMBDA);
-
- buf= new StringBuffer();
- buf.append("package test1;\n");
- buf.append("\n");
- buf.append("interface FI {\n");
- buf.append(" void run(int x);\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("public class Test {\n");
- buf.append(" {\n");
- buf.append(" int e;\n");
- buf.append(" FI fi = e4 -> {\n");
- buf.append(" class C1 {\n");
- buf.append(" void init1() {\n");
- buf.append(" m(e3 -> {\n");
- buf.append(" FI fi2 = e2 -> {\n");
- buf.append(" FI fi1 = e1 -> {\n");
- buf.append(" return;\n");
- buf.append(" };\n");
- buf.append(" };\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append("\n");
- buf.append(" void init2() {\n");
- buf.append(" m(e2 -> new FI() {\n");
- buf.append(" @Override\n");
- buf.append(" public void run(int e3) {\n");
- buf.append(" FI fi = e1 -> {\n");
- buf.append(" return;\n");
- buf.append(" };\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" }\n");
- buf.append("\n");
- buf.append(" void m(FI fi) {\n");
- buf.append(" };\n");
- buf.append("}\n");
- String expected1= buf.toString();
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
- }
-
- @Test
- public void testConvertToLambdaWithMethodAnnotations() throws Exception {
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class C1 {\n");
- buf.append(" Runnable r1 = new Runnable() {\n");
- buf.append(" @Override @A @Deprecated\n");
- buf.append(" public void run() {\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" Runnable r2 = new Runnable() {\n");
- buf.append(" @Override @Deprecated\n");
- buf.append(" public void run() {\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append("}\n");
- buf.append("@interface A {}\n");
- String original= buf.toString();
- ICompilationUnit cu1= pack1.createCompilationUnit("C1.java", original, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_LAMBDA);
-
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class C1 {\n");
- buf.append(" Runnable r1 = new Runnable() {\n");
- buf.append(" @Override @A @Deprecated\n");
- buf.append(" public void run() {\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" Runnable r2 = () -> {\n");
- buf.append(" };\n");
- buf.append("}\n");
- buf.append("@interface A {}\n");
- String expected1= buf.toString();
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
- }
-
- @Test
- public void testConvertToAnonymousWithWildcards() throws Exception {
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("import java.util.*;\n");
- buf.append("public class E {\n");
- buf.append(" void foo(Integer[] ints){\n");
- buf.append(" Arrays.sort(ints, (i1, i2) -> i1 - i2);\n");
- buf.append(" Comparator<?> cw = (w1, w2) -> 0;\n");
- buf.append(" Comparator cr = (r1, r2) -> 0;\n");
- buf.append(" Comparator<? extends Number> ce = (n1, n2) -> -0;\n");
- buf.append(" };\n");
- buf.append("}\n");
- String original= buf.toString();
- ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
-
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("import java.util.*;\n");
- buf.append("public class E {\n");
- buf.append(" void foo(Integer[] ints){\n");
- buf.append(" Arrays.sort(ints, new Comparator<Integer>() {\n");
- buf.append(" @Override\n");
- buf.append(" public int compare(Integer i1, Integer i2) {\n");
- buf.append(" return i1 - i2;\n");
- buf.append(" }\n");
- buf.append(" });\n");
- buf.append(" Comparator<?> cw = new Comparator<Object>() {\n");
- buf.append(" @Override\n");
- buf.append(" public int compare(Object w1, Object w2) {\n");
- buf.append(" return 0;\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" Comparator cr = new Comparator() {\n");
- buf.append(" @Override\n");
- buf.append(" public int compare(Object r1, Object r2) {\n");
- buf.append(" return 0;\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" Comparator<? extends Number> ce = new Comparator<Number>() {\n");
- buf.append(" @Override\n");
- buf.append(" public int compare(Number n1, Number n2) {\n");
- buf.append(" return -0;\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" };\n");
- buf.append("}\n");
- String expected1= buf.toString();
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
-
- disable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
- enable(CleanUpConstants.USE_LAMBDA);
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
- }
-
- @Test
- public void testConvertToAnonymousWithWildcards1() throws Exception {
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("\n");
- buf.append("interface I<M> {\n");
- buf.append(" M run(M x);\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("class Test {\n");
- buf.append(" I<?> li = s -> null;\n");
- buf.append("}\n");
- String original= buf.toString();
- ICompilationUnit cu1= pack1.createCompilationUnit("Test.java", original, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
-
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("\n");
- buf.append("interface I<M> {\n");
- buf.append(" M run(M x);\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("class Test {\n");
- buf.append(" I<?> li = new I<Object>() {\n");
- buf.append(" @Override\n");
- buf.append(" public Object run(Object s) {\n");
- buf.append(" return null;\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append("}\n");
- String expected1= buf.toString();
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
-
- disable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
- enable(CleanUpConstants.USE_LAMBDA);
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
- }
-
- @Test
- public void testConvertToAnonymousWithJoinedSAM() throws Exception {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=428526#c1 and #c6
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("\n");
- buf.append("interface Foo<T, N extends Number> {\n");
- buf.append(" void m(T t);\n");
- buf.append(" void m(N n);\n");
- buf.append("}\n");
- buf.append("interface Baz extends Foo<Integer, Integer> {}\n");
- buf.append("class Test {\n");
- buf.append(" Baz baz = x -> { return; };\n");
- buf.append("}\n");
- String original= buf.toString();
- ICompilationUnit cu1= pack1.createCompilationUnit("Test.java", original, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
-
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("\n");
- buf.append("interface Foo<T, N extends Number> {\n");
- buf.append(" void m(T t);\n");
- buf.append(" void m(N n);\n");
- buf.append("}\n");
- buf.append("interface Baz extends Foo<Integer, Integer> {}\n");
- buf.append("class Test {\n");
- buf.append(" Baz baz = new Baz() {\n");
- buf.append(" @Override\n");
- buf.append(" public void m(Integer x) { return; }\n");
- buf.append(" };\n");
- buf.append("}\n");
- String expected1= buf.toString();
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
-
- disable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
- enable(CleanUpConstants.USE_LAMBDA);
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
- }
-
- @Test
- public void testConvertToLambdaWithNonFunctionalTargetType() throws Exception {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=468457
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- StringBuffer buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("\n");
- buf.append("public class Snippet {\n");
- buf.append(" void test(Interface context) {\n");
- buf.append(" context.set(\"bar\", new Runnable() {\n");
- buf.append(" @Override\n");
- buf.append(" public void run() {}\n");
- buf.append(" });\n");
- buf.append(" \n");
- buf.append(" } \n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("interface Interface {\n");
- buf.append(" public void set(String name, Object value);\n");
- buf.append("}\n");
- String original= buf.toString();
- ICompilationUnit cu1= pack1.createCompilationUnit("Snippet.java", original, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_LAMBDA);
-
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("\n");
- buf.append("public class Snippet {\n");
- buf.append(" void test(Interface context) {\n");
- buf.append(" context.set(\"bar\", (Runnable) () -> {});\n");
- buf.append(" \n");
- buf.append(" } \n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("interface Interface {\n");
- buf.append(" public void set(String name, Object value);\n");
- buf.append("}\n");
- String expected1= buf.toString();
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
-
- enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
- disable(CleanUpConstants.USE_LAMBDA);
-
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
- }
-
- @Test
- public void testConvertToLambdaWithSynchronizedOrStrictfp() throws Exception {
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- StringBuilder buf= new StringBuilder();
- buf.append("package test;\n");
- buf.append("public class C1 {\n");
- buf.append(" Runnable run1 = new Runnable() {\n");
- buf.append(" @Override\n");
- buf.append(" public synchronized void run() {\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" Runnable run2 = new Runnable() {\n");
- buf.append(" @Override\n");
- buf.append(" public strictfp void run() {\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append("}\n");
- String original= buf.toString();
- ICompilationUnit cu= pack1.createCompilationUnit("C1.java", original, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_LAMBDA);
-
- assertRefactoringHasNoChange(new ICompilationUnit[] { cu });
- }
-
- // fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=560018
- @Test
- public void testConvertToLambdaInFieldInitializerWithFinalFieldReference() throws Exception {
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- String buf= ""
- + "package test;\n"
- + "public class C1 {\n"
- + " final String s;\n"
- + " Runnable run1 = new Runnable() {\n"
- + " @Override\n"
- + " public void run() {\n"
- + " System.out.println(s\n"
- + " }\n"
- + " };\n"
- + " public C1() {\n"
- + " s = \"abc\";\n"
- + " };\n"
- + "}\n";
- ICompilationUnit cu= pack1.createCompilationUnit("C1.java", buf, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_LAMBDA);
-
- assertRefactoringHasNoChange(new ICompilationUnit[] { cu });
- }
-
- // fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=560018
- @Test
- public void testConvertToLambdaInFieldInitializerWithFinalFieldReference2() throws Exception {
- IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
- String buf= ""
- + "package test;\n"
- + "public class C1 {\n"
- + " final String s = \"abc\";\n"
- + " Runnable run1 = new Runnable() {\n"
- + " @Override\n"
- + " public void run() {\n"
- + " System.out.println(s);\n"
- + " }\n"
- + " };\n"
- + "}\n";
- ICompilationUnit cu= pack1.createCompilationUnit("C1.java", buf, false, null);
-
- enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
- enable(CleanUpConstants.USE_LAMBDA);
-
- String expected1= ""
- + "package test;\n"
- + "public class C1 {\n"
- + " final String s = \"abc\";\n"
- + " Runnable run1 = () -> System.out.println(s);\n"
- + "}\n";
- assertRefactoringResultAsExpected(new ICompilationUnit[] { cu }, new String[] { expected1 });
- }
-}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d5.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d5.java
index 64030d4b04..dfe1554d02 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d5.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d5.java
@@ -627,6 +627,55 @@ public class CleanUpTest1d5 extends CleanUpTestCase {
}
@Test
+ public void testJava50ForBug560431_1() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ String sample= "" //
+ + "package test1;\n" //
+ + "import java.util.ArrayList;\n" //
+ + "import java.util.Iterator;\n" //
+ + "import java.util.List;\n" //
+ + "public class E1 {\n" //
+ + " public void foo() {\n" //
+ + " List<E1> list= new ArrayList<E1>();\n" //
+ + " for (Iterator<E1> iter = list.iterator(); iter.hasNext();) {\n" //
+ + " E1 e = iter.next();\n" //
+ + " System.out.println(\"here\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + "}\n";
+ ICompilationUnit cu1= pack1.createCompilationUnit("E1.java", sample, false, null);
+
+ enable(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED);
+ enable(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_ONLY_IF_LOOP_VAR_USED);
+
+ assertRefactoringHasNoChange(new ICompilationUnit[] { cu1 });
+ }
+
+ @Test
+ public void testJava50ForBug560431_2() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ String sample= "" //
+ + "package test1;\n" //
+ + "public class E1 {\n" //
+ + " public void foo() {\n" //
+ + " int[] array={1,2,3,4};\n" //
+ + " for (int i=0;i<array.length;i++) {\n" //
+ + " String[] strs={\"1\",\"2\"};\n" //
+ + " for (int j = 0; j < strs.length; j++) {\n" //
+ + " System.out.println(\"here\");\n" //
+ + " }\n" //
+ + " }\n" //
+ + " }\n" //
+ + "}\n";
+ ICompilationUnit cu1= pack1.createCompilationUnit("E1.java", sample, false, null);
+
+ enable(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED);
+ enable(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_ONLY_IF_LOOP_VAR_USED);
+
+ assertRefactoringHasNoChange(new ICompilationUnit[] { cu1 });
+ }
+
+ @Test
public void testBug550726() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
String sample= "" //
@@ -2336,13 +2385,17 @@ public class CleanUpTest1d5 extends CleanUpTestCase {
+ "package test;\n" //
+ "\n" //
+ "import java.util.Arrays;\n" //
+ + "\n" //
+ "public final class X2 {\n" //
+ " public static class Y {\n" //
+ " public int foo(String x, String ...y) { return y.length + 1; }\n" //
+ " }\n" //
+ " public static class Z extends Y {\n" //
+ " public int foo2() {\n" //
- + " List<String> list= Arrays.asList(new String[] {\"one\", \"two\", \"three\"});\n" //
+ + " List<String> list= Arrays.asList(new String[] {\"one\"/* 1 */\n" //
+ + " + \"one\", \"two\"/* 2 */\n" //
+ + " + \"two\", \"three\"/* 3 */\n" //
+ + " + \"three\"});\n" //
+ " return super.foo(\"x\", new String[] {\"y\", \"z\"});\n" //
+ " }\n" //
+ "}\n";
@@ -2352,13 +2405,17 @@ public class CleanUpTest1d5 extends CleanUpTestCase {
+ "package test;\n" //
+ "\n" //
+ "import java.util.Arrays;\n" //
+ + "\n" //
+ "public final class X2 {\n" //
+ " public static class Y {\n" //
+ " public int foo(String x, String ...y) { return y.length + 1; }\n" //
+ " }\n" //
+ " public static class Z extends Y {\n" //
+ " public int foo2() {\n" //
- + " List<String> list= Arrays.asList(\"one\", \"two\", \"three\");\n" //
+ + " List<String> list= Arrays.asList(\"one\"/* 1 */\n" //
+ + " + \"one\", \"two\"/* 2 */\n" //
+ + " + \"two\", \"three\"/* 3 */\n" //
+ + " + \"three\");\n" //
+ " return super.foo(\"x\", \"y\", \"z\");\n" //
+ " }\n" //
+ "}\n";
@@ -2367,4 +2424,25 @@ public class CleanUpTest1d5 extends CleanUpTestCase {
enable(CleanUpConstants.REMOVE_UNNECESSARY_ARRAY_CREATION);
assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1, cu2 }, new String[] { expected1, expected2 });
}
+
+ @Test
+ public void testUnnecessaryArrayBug562091() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ String sample= "" //
+ + "package test1;\n" //
+ + "\n" //
+ + "import java.lang.reflect.Method;\n" //
+ + "\n" //
+ + "public class A {\n" //
+ + " public void foo() throws Throwable {\n" //
+ + " Method method= A.class.getMethod(\"bah\", A.class);\n" //
+ + " method.invoke(this, new Object[] {null});\n" //
+ + " }\n" //
+ + "}\n";
+ ICompilationUnit cu= pack1.createCompilationUnit("A.java", sample, false, null);
+
+ enable(CleanUpConstants.REMOVE_UNNECESSARY_ARRAY_CREATION);
+
+ assertRefactoringHasNoChange(new ICompilationUnit[] { cu });
+ }
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d8.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d8.java
index 851f9d57f9..3838e62df9 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d8.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest1d8.java
@@ -30,13 +30,13 @@ import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType;
import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
@RunWith(JUnit4.class)
public class CleanUpTest1d8 extends CleanUpTestCase {
@Rule
- public ProjectTestSetup projectsetup= new Java18ProjectTestSetup();
+ public ProjectTestSetup projectsetup= new Java1d8ProjectTestSetup();
@Override
@Before
@@ -47,12 +47,987 @@ public class CleanUpTest1d8 extends CleanUpTestCase {
@Override
protected IJavaProject getProject() {
- return Java18ProjectTestSetup.getProject();
+ return Java1d8ProjectTestSetup.getProject();
}
@Override
protected IClasspathEntry[] getDefaultClasspath() throws CoreException {
- return Java18ProjectTestSetup.getDefaultClasspath();
+ return Java1d8ProjectTestSetup.getDefaultClasspath();
+ }
+
+ @Test
+ public void testConvertToLambda01() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test;\n" //
+ + "public class E {\n" //
+ + " void foo(){\n" //
+ + " Runnable r = new Runnable() {\n" //
+ + " @Override\n" //
+ + " public void run() {\n" //
+ + " System.out.println(\"do something\");\n" //
+ + " }\n" //
+ + " };\n" //
+ + " };\n" //
+ + "}\n";
+ String original= sample;
+ ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ sample= "" //
+ + "package test;\n" //
+ + "public class E {\n" //
+ + " void foo(){\n" //
+ + " Runnable r = () -> System.out.println(\"do something\");\n" //
+ + " };\n" //
+ + "}\n";
+ String expected1= sample;
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
+
+ disable(CleanUpConstants.USE_LAMBDA);
+ enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
+ }
+
+ @Test
+ public void testConvertToLambda02() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test;\n" //
+ + "public class E {\n" //
+ + " void foo(){\n" //
+ + " Runnable r1 = new Runnable() {\n" //
+ + " @Override\n" //
+ + " public void run() {\n" //
+ + " System.out.println(\"do something\");\n" //
+ + " }\n" //
+ + " };\n" //
+ + " Runnable r2 = new Runnable() {\n" //
+ + " @Override\n" //
+ + " public void run() {\n" //
+ + " System.out.println(\"do one thing\");\n" //
+ + " System.out.println(\"do another thing\");\n" //
+ + " }\n" //
+ + " };\n" //
+ + " };\n" //
+ + "}\n";
+ String original= sample;
+ ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ sample= "" //
+ + "package test;\n" //
+ + "public class E {\n" //
+ + " void foo(){\n" //
+ + " Runnable r1 = () -> System.out.println(\"do something\");\n" //
+ + " Runnable r2 = () -> {\n" //
+ + " System.out.println(\"do one thing\");\n" //
+ + " System.out.println(\"do another thing\");\n" //
+ + " };\n" //
+ + " };\n" //
+ + "}\n";
+ String expected1= sample;
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
+
+ disable(CleanUpConstants.USE_LAMBDA);
+ enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
+ }
+
+ @Test
+ public void testConvertToLambda03() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test1;\n" //
+ + "import java.util.function.Supplier;\n" //
+ + "class E {\n" //
+ + " Supplier<Supplier<String>> s= new Supplier<Supplier<String>>() {\n" //
+ + " @Override\n" //
+ + " public Supplier<String> get() {\n" //
+ + " return new Supplier<String>() {\n" //
+ + " @Override\n" //
+ + " public String get() {\n" //
+ + " return \"a\";\n" //
+ + " }\n" //
+ + " };\n" //
+ + " }\n" //
+ + " };\n" //
+ + "}\n";
+ String original= sample;
+ ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ sample= "" //
+ + "package test1;\n" //
+ + "import java.util.function.Supplier;\n" //
+ + "class E {\n" //
+ + " Supplier<Supplier<String>> s= () -> () -> \"a\";\n" //
+ + "}\n";
+ String expected1= sample;
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
+
+ disable(CleanUpConstants.USE_LAMBDA);
+ enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
+ }
+
+ @Test
+ public void testConvertToLambdaNestedWithImports() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test;\n" //
+ + "import java.util.concurrent.Callable;\n" //
+ + "import java.util.concurrent.Executors;\n" //
+ + "public class E {\n" //
+ + " void foo() {\n" //
+ + " new Thread(new Runnable() {\n" //
+ + " @Override\n" //
+ + " public void run() {\n" //
+ + " Executors.newSingleThreadExecutor().submit(new Callable<String>() {\n" //
+ + " @Override\n" //
+ + " public String call() throws Exception {\n" //
+ + " return \"hi\";\n" //
+ + " }\n" //
+ + " });\n" //
+ + " }\n" //
+ + " });\n" //
+ + " }\n" //
+ + "}\n";
+ String original= sample;
+ ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ sample= "" //
+ + "package test;\n" //
+ + "import java.util.concurrent.Executors;\n" //
+ + "public class E {\n" //
+ + " void foo() {\n" //
+ + " new Thread(() -> Executors.newSingleThreadExecutor().submit(() -> \"hi\"));\n" //
+ + " }\n" //
+ + "}\n";
+ String expected1= sample;
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
+
+ disable(CleanUpConstants.USE_LAMBDA);
+ enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
+ }
+
+ // fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=434507#c5
+ @Test
+ public void testConvertToLambdaAmbiguous01() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test;\n" //
+ + "\n" //
+ + "interface ISuper {\n" //
+ + " void foo(FI1 fi1);\n" //
+ + "}\n" //
+ + "\n" //
+ + "interface ISub extends ISuper {\n" //
+ + " void foo(FI2 fi2);\n" //
+ + "}\n" //
+ + "\n" //
+ + "@FunctionalInterface\n" //
+ + "interface FI1 {\n" //
+ + " void abc();\n" //
+ + "}\n" //
+ + "\n" //
+ + "@FunctionalInterface\n" //
+ + "interface FI2 {\n" //
+ + " void xyz();\n" //
+ + "}\n" //
+ + "\n" //
+ + "class Test1 {\n" //
+ + " private void test1() {\n" //
+ + " f1().foo(new FI1() {\n" //
+ + " @Override\n" //
+ + " public void abc() {\n" //
+ + " System.out.println();\n" //
+ + " }\n" //
+ + " });\n" //
+ + "\n" //
+ + " }\n" //
+ + " \n" //
+ + " private ISub f1() {\n" //
+ + " return null;\n" //
+ + " }\n" //
+ + "}\n" //
+ + "\n" //
+ + "abstract class Test2 implements ISub {\n" //
+ + " private void test2() {\n" //
+ + " foo(new FI1() {\n" //
+ + " @Override\n" //
+ + " public void abc() {\n" //
+ + " System.out.println();\n" //
+ + " }\n" //
+ + " });\n" //
+ + " }\n" //
+ + "}\n" //
+ + "\n" //
+ + "class Test3 {\n" //
+ + " void foo(FI1 fi1) {}\n" //
+ + " void foo(FI2 fi2) {}\n" //
+ + " private void test3() {\n" //
+ + " foo(new FI1() {\n" //
+ + " @Override\n" //
+ + " public void abc() {\n" //
+ + " System.out.println();\n" //
+ + " }\n" //
+ + " });\n" //
+ + " }\n" //
+ + "}\n" //
+ + "\n" //
+ + "class Outer {\n" //
+ + " class Test4 {\n" //
+ + " {\n" //
+ + " bar(0, new FI1() {\n" //
+ + " @Override\n" //
+ + " public void abc() {\n" //
+ + " }\n" //
+ + " });\n" //
+ + " }\n" //
+ + " }\n" //
+ + " void bar(int i, FI1 fi1) {}\n" //
+ + " void bar(int s, FI2 fi2) {}\n" //
+ + "}\n";
+ String original= sample;
+ ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ sample= "" //
+ + "package test;\n" //
+ + "\n" //
+ + "interface ISuper {\n" //
+ + " void foo(FI1 fi1);\n" //
+ + "}\n" //
+ + "\n" //
+ + "interface ISub extends ISuper {\n" //
+ + " void foo(FI2 fi2);\n" //
+ + "}\n" //
+ + "\n" //
+ + "@FunctionalInterface\n" //
+ + "interface FI1 {\n" //
+ + " void abc();\n" //
+ + "}\n" //
+ + "\n" //
+ + "@FunctionalInterface\n" //
+ + "interface FI2 {\n" //
+ + " void xyz();\n" //
+ + "}\n" //
+ + "\n" //
+ + "class Test1 {\n" //
+ + " private void test1() {\n" //
+ + " f1().foo((FI1) () -> System.out.println());\n" //
+ + "\n" //
+ + " }\n" //
+ + " \n" //
+ + " private ISub f1() {\n" //
+ + " return null;\n" //
+ + " }\n" //
+ + "}\n" //
+ + "\n" //
+ + "abstract class Test2 implements ISub {\n" //
+ + " private void test2() {\n" //
+ + " foo((FI1) () -> System.out.println());\n" //
+ + " }\n" //
+ + "}\n" //
+ + "\n" //
+ + "class Test3 {\n" //
+ + " void foo(FI1 fi1) {}\n" //
+ + " void foo(FI2 fi2) {}\n" //
+ + " private void test3() {\n" //
+ + " foo((FI1) () -> System.out.println());\n" //
+ + " }\n" //
+ + "}\n" //
+ + "\n" //
+ + "class Outer {\n" //
+ + " class Test4 {\n" //
+ + " {\n" //
+ + " bar(0, (FI1) () -> {\n" //
+ + " });\n" //
+ + " }\n" //
+ + " }\n" //
+ + " void bar(int i, FI1 fi1) {}\n" //
+ + " void bar(int s, FI2 fi2) {}\n" //
+ + "}\n";
+ String expected1= sample;
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
+
+ disable(CleanUpConstants.USE_LAMBDA);
+ enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
+ }
+
+ // fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=434507#c5
+ @Test
+ public void testConvertToLambdaAmbiguous02() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test;\n" //
+ + "\n" //
+ + "@FunctionalInterface\n" //
+ + "interface FI1 {\n" //
+ + " void abc();\n" //
+ + "}\n" //
+ + "\n" //
+ + "@FunctionalInterface\n" //
+ + "interface FI2 {\n" //
+ + " void xyz();\n" //
+ + "}\n" //
+ + "\n" //
+ + "class Outer {\n" //
+ + " void outer(FI1 fi1) {}\n" //
+ + "}\n" //
+ + "class OuterSub extends Outer {\n" //
+ + " OuterSub() {\n" //
+ + " super.outer(new FI1() {\n" //
+ + " @Override\n" //
+ + " public void abc() {\n" //
+ + " System.out.println();\n" //
+ + " }\n" //
+ + " });\n" //
+ + " }\n" //
+ + " class Test1 {\n" //
+ + " private void test1() {\n" //
+ + " OuterSub.super.outer(new FI1() {\n" //
+ + " @Override\n" //
+ + " public void abc() {\n" //
+ + " System.out.println();\n" //
+ + " }\n" //
+ + " });\n" //
+ + " OuterSub.this.outer(new FI1() {\n" //
+ + " @Override\n" //
+ + " public void abc() {\n" //
+ + " System.out.println();\n" //
+ + " }\n" //
+ + " });\n" //
+ + " outer(new FI1() {\n" //
+ + " @Override\n" //
+ + " public void abc() {\n" //
+ + " System.out.println();\n" //
+ + " }\n" //
+ + " });\n" //
+ + " }\n" //
+ + " }\n" //
+ + " @Override\n" //
+ + " void outer(FI1 fi1) {}\n" //
+ + " void outer(FI2 fi2) {}\n" //
+ + "}\n" //
+ + "\n" //
+ + "class OuterSub2 extends OuterSub {\n" //
+ + " OuterSub2() {\n" //
+ + " super.outer(new FI1() {\n" //
+ + " @Override\n" //
+ + " public void abc() {\n" //
+ + " System.out.println();\n" //
+ + " }\n" //
+ + " });\n" //
+ + " }\n" //
+ + " class Test2 {\n" //
+ + " private void test2() {\n" //
+ + " OuterSub2.super.outer(new FI1() {\n" //
+ + " @Override\n" //
+ + " public void abc() {\n" //
+ + " System.out.println();\n" //
+ + " }\n" //
+ + " });\n" //
+ + " OuterSub2.this.outer(new FI1() {\n" //
+ + " @Override\n" //
+ + " public void abc() {\n" //
+ + " System.out.println();\n" //
+ + " }\n" //
+ + " });\n" //
+ + " outer(new FI1() {\n" //
+ + " @Override\n" //
+ + " public void abc() {\n" //
+ + " System.out.println();\n" //
+ + " }\n" //
+ + " });\n" //
+ + " }\n" //
+ + " }\n" //
+ + "}\n";
+ String original= sample;
+ ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ sample= "" //
+ + "package test;\n" //
+ + "\n" //
+ + "@FunctionalInterface\n" //
+ + "interface FI1 {\n" //
+ + " void abc();\n" //
+ + "}\n" //
+ + "\n" //
+ + "@FunctionalInterface\n" //
+ + "interface FI2 {\n" //
+ + " void xyz();\n" //
+ + "}\n" //
+ + "\n" //
+ + "class Outer {\n" //
+ + " void outer(FI1 fi1) {}\n" //
+ + "}\n" //
+ + "class OuterSub extends Outer {\n" //
+ + " OuterSub() {\n" //
+ + " super.outer(() -> System.out.println());\n" //
+ + " }\n" //
+ + " class Test1 {\n" //
+ + " private void test1() {\n" //
+ + " OuterSub.super.outer(() -> System.out.println());\n" //
+ + " OuterSub.this.outer((FI1) () -> System.out.println());\n" //
+ + " outer((FI1) () -> System.out.println());\n" //
+ + " }\n" //
+ + " }\n" //
+ + " @Override\n" //
+ + " void outer(FI1 fi1) {}\n" //
+ + " void outer(FI2 fi2) {}\n" //
+ + "}\n" //
+ + "\n" //
+ + "class OuterSub2 extends OuterSub {\n" //
+ + " OuterSub2() {\n" //
+ + " super.outer((FI1) () -> System.out.println());\n" //
+ + " }\n" //
+ + " class Test2 {\n" //
+ + " private void test2() {\n" //
+ + " OuterSub2.super.outer((FI1) () -> System.out.println());\n" //
+ + " OuterSub2.this.outer((FI1) () -> System.out.println());\n" //
+ + " outer((FI1) () -> System.out.println());\n" //
+ + " }\n" //
+ + " }\n" //
+ + "}\n";
+ String expected1= sample;
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
+
+ disable(CleanUpConstants.USE_LAMBDA);
+ enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
+ }
+
+ // fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=434507#c2
+ @Test
+ public void testConvertToLambdaAmbiguous03() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test;\n" //
+ + "public interface E {\n" //
+ + " default void m() {\n" //
+ + " bar(0, new FI() {\n" //
+ + " @Override\n" //
+ + " public int foo(int x) {\n" //
+ + " return x++;\n" //
+ + " }\n" //
+ + " });\n" //
+ + " baz(0, new ZI() {\n" //
+ + " @Override\n" //
+ + " public int zoo() {\n" //
+ + " return 1;\n" //
+ + " }\n" //
+ + " });\n" //
+ + " }\n" //
+ + "\n" //
+ + " void bar(int i, FI fi);\n" //
+ + " void bar(int i, FV fv);\n" //
+ + "\n" //
+ + " void baz(int i, ZI zi);\n" //
+ + " void baz(int i, ZV zv);\n" //
+ + "}\n" //
+ + "\n" //
+ + "@FunctionalInterface interface FI { int foo(int a); }\n" //
+ + "@FunctionalInterface interface FV { void foo(int a); }\n" //
+ + "\n" //
+ + "@FunctionalInterface interface ZI { int zoo(); }\n" //
+ + "@FunctionalInterface interface ZV { void zoo(); }\n";
+ String original= sample;
+ ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ sample= "" //
+ + "package test;\n" //
+ + "public interface E {\n" //
+ + " default void m() {\n" //
+ + " bar(0, (FI) x -> x++);\n" //
+ + " baz(0, () -> 1);\n" //
+ + " }\n" //
+ + "\n" //
+ + " void bar(int i, FI fi);\n" //
+ + " void bar(int i, FV fv);\n" //
+ + "\n" //
+ + " void baz(int i, ZI zi);\n" //
+ + " void baz(int i, ZV zv);\n" //
+ + "}\n" //
+ + "\n" //
+ + "@FunctionalInterface interface FI { int foo(int a); }\n" //
+ + "@FunctionalInterface interface FV { void foo(int a); }\n" //
+ + "\n" //
+ + "@FunctionalInterface interface ZI { int zoo(); }\n" //
+ + "@FunctionalInterface interface ZV { void zoo(); }\n";
+ String expected1= sample;
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
+
+ disable(CleanUpConstants.USE_LAMBDA);
+ enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
+ }
+
+ @Test
+ public void testConvertToLambdaConflictingNames() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test1;\n" //
+ + "\n" //
+ + "interface FI {\n" //
+ + " void run(int x);\n" //
+ + "}\n" //
+ + "\n" //
+ + "public class Test {\n" //
+ + " {\n" //
+ + " int e;\n" //
+ + " FI fi = new FI() {\n" //
+ + " @Override\n" //
+ + " public void run(int e) {\n" //
+ + " class C1 {\n" //
+ + " void init1() {\n" //
+ + " m(new FI() {\n" //
+ + " @Override\n" //
+ + " public void run(int e) {\n" //
+ + " FI fi = new FI() {\n" //
+ + " @Override\n" //
+ + " public void run(int e) {\n" //
+ + " FI fi = new FI() {\n" //
+ + " @Override\n" //
+ + " public void run(int e) {\n" //
+ + " return;\n" //
+ + " }\n" //
+ + " };\n" //
+ + " }\n" //
+ + " };\n" //
+ + " }\n" //
+ + " });\n" //
+ + " }\n" //
+ + "\n" //
+ + " void init2() {\n" //
+ + " m(new FI() {\n" //
+ + " @Override\n" //
+ + " public void run(int e) {\n" //
+ + " new FI() {\n" //
+ + " @Override\n" //
+ + " public void run(int e3) {\n" //
+ + " FI fi = new FI() {\n" //
+ + " @Override\n" //
+ + " public void run(int e) {\n" //
+ + " return;\n" //
+ + " }\n" //
+ + " };\n" //
+ + " }\n" //
+ + " };\n" //
+ + " }\n" //
+ + " });\n" //
+ + " }\n" //
+ + " }\n" //
+ + " }\n" //
+ + " };\n" //
+ + " }\n" //
+ + "\n" //
+ + " void m(FI fi) {\n" //
+ + " };\n" //
+ + "}\n";
+ String original= sample;
+ ICompilationUnit cu1= pack1.createCompilationUnit("Test.java", original, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ sample= "" //
+ + "package test1;\n" //
+ + "\n" //
+ + "interface FI {\n" //
+ + " void run(int x);\n" //
+ + "}\n" //
+ + "\n" //
+ + "public class Test {\n" //
+ + " {\n" //
+ + " int e;\n" //
+ + " FI fi = e4 -> {\n" //
+ + " class C1 {\n" //
+ + " void init1() {\n" //
+ + " m(e3 -> {\n" //
+ + " FI fi2 = e2 -> {\n" //
+ + " FI fi1 = e1 -> {\n" //
+ + " return;\n" //
+ + " };\n" //
+ + " };\n" //
+ + " });\n" //
+ + " }\n" //
+ + "\n" //
+ + " void init2() {\n" //
+ + " m(e2 -> new FI() {\n" //
+ + " @Override\n" //
+ + " public void run(int e3) {\n" //
+ + " FI fi = e1 -> {\n" //
+ + " return;\n" //
+ + " };\n" //
+ + " }\n" //
+ + " });\n" //
+ + " }\n" //
+ + " }\n" //
+ + " };\n" //
+ + " }\n" //
+ + "\n" //
+ + " void m(FI fi) {\n" //
+ + " };\n" //
+ + "}\n";
+ String expected1= sample;
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
+ }
+
+ @Test
+ public void testConvertToLambdaWithMethodAnnotations() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test;\n" //
+ + "public class C1 {\n" //
+ + " Runnable r1 = new Runnable() {\n" //
+ + " @Override @A @Deprecated\n" //
+ + " public void run() {\n" //
+ + " }\n" //
+ + " };\n" //
+ + " Runnable r2 = new Runnable() {\n" //
+ + " @Override @Deprecated\n" //
+ + " public void run() {\n" //
+ + " }\n" //
+ + " };\n" //
+ + "}\n" //
+ + "@interface A {}\n";
+ String original= sample;
+ ICompilationUnit cu1= pack1.createCompilationUnit("C1.java", original, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ sample= "" //
+ + "package test;\n" //
+ + "public class C1 {\n" //
+ + " Runnable r1 = new Runnable() {\n" //
+ + " @Override @A @Deprecated\n" //
+ + " public void run() {\n" //
+ + " }\n" //
+ + " };\n" //
+ + " Runnable r2 = () -> {\n" //
+ + " };\n" //
+ + "}\n" //
+ + "@interface A {}\n";
+ String expected1= sample;
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
+ }
+
+ @Test
+ public void testConvertToAnonymousWithWildcards() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test;\n" //
+ + "import java.util.*;\n" //
+ + "public class E {\n" //
+ + " void foo(Integer[] ints){\n" //
+ + " Arrays.sort(ints, (i1, i2) -> i1 - i2);\n" //
+ + " Comparator<?> cw = (w1, w2) -> 0;\n" //
+ + " Comparator cr = (r1, r2) -> 0;\n" //
+ + " Comparator<? extends Number> ce = (n1, n2) -> -0;\n" //
+ + " };\n" //
+ + "}\n";
+ String original= sample;
+ ICompilationUnit cu1= pack1.createCompilationUnit("E.java", original, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
+
+ sample= "" //
+ + "package test;\n" //
+ + "import java.util.*;\n" //
+ + "public class E {\n" //
+ + " void foo(Integer[] ints){\n" //
+ + " Arrays.sort(ints, new Comparator<Integer>() {\n" //
+ + " @Override\n" //
+ + " public int compare(Integer i1, Integer i2) {\n" //
+ + " return i1 - i2;\n" //
+ + " }\n" //
+ + " });\n" //
+ + " Comparator<?> cw = new Comparator<Object>() {\n" //
+ + " @Override\n" //
+ + " public int compare(Object w1, Object w2) {\n" //
+ + " return 0;\n" //
+ + " }\n" //
+ + " };\n" //
+ + " Comparator cr = new Comparator() {\n" //
+ + " @Override\n" //
+ + " public int compare(Object r1, Object r2) {\n" //
+ + " return 0;\n" //
+ + " }\n" //
+ + " };\n" //
+ + " Comparator<? extends Number> ce = new Comparator<Number>() {\n" //
+ + " @Override\n" //
+ + " public int compare(Number n1, Number n2) {\n" //
+ + " return -0;\n" //
+ + " }\n" //
+ + " };\n" //
+ + " };\n" //
+ + "}\n";
+ String expected1= sample;
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
+
+ disable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
+ }
+
+ @Test
+ public void testConvertToAnonymousWithWildcards1() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test;\n" //
+ + "\n" //
+ + "interface I<M> {\n" //
+ + " M run(M x);\n" //
+ + "}\n" //
+ + "\n" //
+ + "class Test {\n" //
+ + " I<?> li = s -> null;\n" //
+ + "}\n";
+ String original= sample;
+ ICompilationUnit cu1= pack1.createCompilationUnit("Test.java", original, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
+
+ sample= "" //
+ + "package test;\n" //
+ + "\n" //
+ + "interface I<M> {\n" //
+ + " M run(M x);\n" //
+ + "}\n" //
+ + "\n" //
+ + "class Test {\n" //
+ + " I<?> li = new I<Object>() {\n" //
+ + " @Override\n" //
+ + " public Object run(Object s) {\n" //
+ + " return null;\n" //
+ + " }\n" //
+ + " };\n" //
+ + "}\n";
+ String expected1= sample;
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
+
+ disable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
+ }
+
+ @Test
+ public void testConvertToAnonymousWithJoinedSAM() throws Exception {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=428526#c1 and #c6
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test;\n" //
+ + "\n" //
+ + "interface Foo<T, N extends Number> {\n" //
+ + " void m(T t);\n" //
+ + " void m(N n);\n" //
+ + "}\n" //
+ + "interface Baz extends Foo<Integer, Integer> {}\n" //
+ + "class Test {\n" //
+ + " Baz baz = x -> { return; };\n" //
+ + "}\n";
+ String original= sample;
+ ICompilationUnit cu1= pack1.createCompilationUnit("Test.java", original, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
+
+ sample= "" //
+ + "package test;\n" //
+ + "\n" //
+ + "interface Foo<T, N extends Number> {\n" //
+ + " void m(T t);\n" //
+ + " void m(N n);\n" //
+ + "}\n" //
+ + "interface Baz extends Foo<Integer, Integer> {}\n" //
+ + "class Test {\n" //
+ + " Baz baz = new Baz() {\n" //
+ + " @Override\n" //
+ + " public void m(Integer x) { return; }\n" //
+ + " };\n" //
+ + "}\n";
+ String expected1= sample;
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
+
+ disable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
+ }
+
+ @Test
+ public void testConvertToLambdaWithNonFunctionalTargetType() throws Exception {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=468457
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test;\n" //
+ + "\n" //
+ + "public class Snippet {\n" //
+ + " void test(Interface context) {\n" //
+ + " context.set(\"bar\", new Runnable() {\n" //
+ + " @Override\n" //
+ + " public void run() {}\n" //
+ + " });\n" //
+ + " \n" //
+ + " } \n" //
+ + "}\n" //
+ + "\n" //
+ + "interface Interface {\n" //
+ + " public void set(String name, Object value);\n" //
+ + "}\n";
+ String original= sample;
+ ICompilationUnit cu1= pack1.createCompilationUnit("Snippet.java", original, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ sample= "" //
+ + "package test;\n" //
+ + "\n" //
+ + "public class Snippet {\n" //
+ + " void test(Interface context) {\n" //
+ + " context.set(\"bar\", (Runnable) () -> {});\n" //
+ + " \n" //
+ + " } \n" //
+ + "}\n" //
+ + "\n" //
+ + "interface Interface {\n" //
+ + " public void set(String name, Object value);\n" //
+ + "}\n";
+ String expected1= sample;
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
+
+ enable(CleanUpConstants.USE_ANONYMOUS_CLASS_CREATION);
+ disable(CleanUpConstants.USE_LAMBDA);
+
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { original });
+ }
+
+ @Test
+ public void testConvertToLambdaWithSynchronizedOrStrictfp() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test;\n" //
+ + "public class C1 {\n" //
+ + " Runnable run1 = new Runnable() {\n" //
+ + " @Override\n" //
+ + " public synchronized void run() {\n" //
+ + " }\n" //
+ + " };\n" //
+ + " Runnable run2 = new Runnable() {\n" //
+ + " @Override\n" //
+ + " public strictfp void run() {\n" //
+ + " }\n" //
+ + " };\n" //
+ + "}\n";
+ String original= sample;
+ ICompilationUnit cu= pack1.createCompilationUnit("C1.java", original, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ assertRefactoringHasNoChange(new ICompilationUnit[] { cu });
+ }
+
+ // fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=560018
+ @Test
+ public void testConvertToLambdaInFieldInitializerWithFinalFieldReference() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= ""
+ + "package test;\n"
+ + "public class C1 {\n"
+ + " final String s;\n"
+ + " Runnable run1 = new Runnable() {\n"
+ + " @Override\n"
+ + " public void run() {\n"
+ + " System.out.println(s\n"
+ + " }\n"
+ + " };\n"
+ + " public C1() {\n"
+ + " s = \"abc\";\n"
+ + " };\n"
+ + "}\n";
+ ICompilationUnit cu= pack1.createCompilationUnit("C1.java", sample, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ assertRefactoringHasNoChange(new ICompilationUnit[] { cu });
+ }
+
+ // fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=560018
+ @Test
+ public void testConvertToLambdaInFieldInitializerWithFinalFieldReference2() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= ""
+ + "package test;\n"
+ + "public class C1 {\n"
+ + " final String s = \"abc\";\n"
+ + " Runnable run1 = new Runnable() {\n"
+ + " @Override\n"
+ + " public void run() {\n"
+ + " System.out.println(s);\n"
+ + " }\n"
+ + " };\n"
+ + "}\n";
+ ICompilationUnit cu= pack1.createCompilationUnit("C1.java", sample, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ String expected1= ""
+ + "package test;\n"
+ + "public class C1 {\n"
+ + " final String s = \"abc\";\n"
+ + " Runnable run1 = () -> System.out.println(s);\n"
+ + "}\n";
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu }, new String[] { expected1 });
}
@Test
@@ -73,7 +1048,7 @@ public class CleanUpTest1d8 extends CleanUpTestCase {
+ "\n"
+ " static final String classField = \"abc\";\n"
+ " final String instanceField = \"abc\";\n"
- + " public void getString() {\n"
+ + " public String getString() {\n"
+ " return \"\";\n"
+ " }\n"
+ "}\n";
@@ -92,7 +1067,51 @@ public class CleanUpTest1d8 extends CleanUpTestCase {
+ "\n"
+ " static final String classField = \"abc\";\n"
+ " final String instanceField = \"abc\";\n"
- + " public void getString() {\n"
+ + " public String getString() {\n"
+ + " return \"\";\n"
+ + " }\n"
+ + "}\n";
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu }, new String[] { expected });
+ }
+
+ @Test
+ public void testConvertToLambdaWithQualifiedField() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= ""
+ + "package test;\n"
+ + "\n"
+ + "public class C1 {\n"
+ + " static final String previousField = \"abc\";\n"
+ + "\n"
+ + " Runnable run1 = new Runnable() {\n"
+ + " @Override\n"
+ + " public void run() {\n"
+ + " System.out.println(C1.previousField + C1.this.instanceField + C1.classField + C1.this.getString());\n"
+ + " }\n"
+ + " };\n"
+ + "\n"
+ + " static final String classField = \"def\";\n"
+ + " final String instanceField = \"abc\";\n"
+ + " public String getString() {\n"
+ + " return \"\";\n"
+ + " }\n"
+ + "}\n";
+ ICompilationUnit cu= pack1.createCompilationUnit("C1.java", sample, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ String expected= ""
+ + "package test;\n"
+ + "\n"
+ + "public class C1 {\n"
+ + " static final String previousField = \"abc\";\n"
+ + "\n"
+ + " Runnable run1 = () -> System.out.println(C1.previousField + C1.this.instanceField + C1.classField + C1.this.getString());\n"
+ + "\n"
+ + " static final String classField = \"def\";\n"
+ + " final String instanceField = \"abc\";\n"
+ + " public String getString() {\n"
+ " return \"\";\n"
+ " }\n"
+ "}\n";
@@ -398,4 +1417,97 @@ public class CleanUpTest1d8 extends CleanUpTestCase {
assertRefactoringResultAsExpected(new ICompilationUnit[] { cu1 }, new String[] { expected1 });
}
+
+ @Test
+ public void testConvertToLambdaWithRecursion() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= ""
+ + "import java.util.function.Function;\n" //
+ + "public class C1 {\n" //
+ + "\n" //
+ + " public interface I1 {\n" //
+ + " public int add(int a);\n" //
+ + " }\n" //
+ + "\n" //
+ + " I1 k = new I1() {\n" //
+ + " @Override\n" //
+ + " public int add(int a) {\n" //
+ + " if (a == 2) {\n" //
+ + " return add(3);\n" //
+ + " }\n" //
+ + " return a + 7;\n" //
+ + " }\n" //
+ + " };\n" //
+ + "\n" //
+ + " public static I1 j = new I1() {\n" //
+ + " @Override\n" //
+ + " public int add(int a) {\n" //
+ + " if (a == 2) {\n" //
+ + " return add(4);\n" //
+ + " }\n" //
+ + " return a + 8;\n" //
+ + " }\n" //
+ + " };\n" //
+ + "}\n"; //
+ ICompilationUnit cu= pack1.createCompilationUnit("C1.java", sample, false, null);
+
+ enable(CleanUpConstants.CONVERT_FUNCTIONAL_INTERFACES);
+ enable(CleanUpConstants.USE_LAMBDA);
+
+ String expected= ""
+ + "import java.util.function.Function;\n" //
+ + "public class C1 {\n" //
+ + "\n" //
+ + " public interface I1 {\n" //
+ + " public int add(int a);\n" //
+ + " }\n" //
+ + "\n" //
+ + " I1 k = a -> {\n" //
+ + " if (a == 2) {\n" //
+ + " return this.k.add(3);\n" //
+ + " }\n" //
+ + " return a + 7;\n" //
+ + " };\n" //
+ + "\n" //
+ + " public static I1 j = a -> {\n" //
+ + " if (a == 2) {\n" //
+ + " return C1.j.add(4);\n" //
+ + " }\n" //
+ + " return a + 8;\n" //
+ + " };\n" //
+ + "}\n"; //
+ assertRefactoringResultAsExpected(new ICompilationUnit[] { cu }, new String[] { expected });
+ }
+
+ @Test
+ public void testDoNotConvertLocalRecursiveClass() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ String sample= "" //
+ + "import java.util.function.Function;\n" //
+ + "\n" //
+ + "public class C2 {\n" //
+ + "\n" //
+ + " public interface I1 {\n" //
+ + " public int add(int a);\n" //
+ + " }\n" //
+ + "\n" //
+ + " public int foo() {\n" //
+ + " I1 doNotConvert = new I1() {\n" //
+ + " @Override\n" //
+ + " public int add(int a) {\n" //
+ + " if (a == 2) {\n" //
+ + " return add(5);\n" //
+ + " }\n" //
+ + " return a + 9;\n" //
+ + " }\n" //
+ + " };\n" //
+ + " return n.add(9);\n" //
+ + " }\n" //
+ + "}\n"; //
+ ICompilationUnit cu= pack1.createCompilationUnit("C2.java", sample, false, null);
+
+ enable(CleanUpConstants.SIMPLIFY_LAMBDA_EXPRESSION_AND_METHOD_REF);
+
+ assertRefactoringHasNoChange(new ICompilationUnit[] { cu });
+ }
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java
index 5266b4a209..958ae0c995 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTestCase.java
@@ -64,7 +64,7 @@ import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.cleanup.CleanUpOptions;
import org.eclipse.jdt.ui.cleanup.ICleanUp;
-import org.eclipse.jdt.ui.tests.core.ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
@@ -74,7 +74,6 @@ import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.CustomPr
import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.Profile;
import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileStore;
-
@RunWith(Suite.class)
@Suite.SuiteClasses({
CleanUpStressTest.class,
@@ -82,15 +81,13 @@ import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileStore;
CleanUpTest1d5.class,
CleanUpTest1d7.class,
CleanUpTest1d8.class,
- CleanUpTest18.class,
CleanUpTest1d10.class,
CleanUpAnnotationTest.class,
SaveParticipantTest.class,
CleanUpActionTest.class,
- NullAnnotationsCleanUpTest18.class
+ NullAnnotationsCleanUpTest1d8.class
})
public class CleanUpTestCase extends QuickFixTest {
-
protected static final String FIELD_COMMENT= "/* Test */";
protected IPackageFragmentRoot fSourceFolder;
@@ -265,5 +262,4 @@ public class CleanUpTestCase extends QuickFixTest {
private void executePerformOperation(final PerformChangeOperation perform, IWorkspace workspace) throws CoreException {
workspace.run(perform, new NullProgressMonitor());
}
-
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertForLoopQuickFixTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertForLoopQuickFixTest.java
index 86212f7883..458f791153 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertForLoopQuickFixTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertForLoopQuickFixTest.java
@@ -63,10 +63,10 @@ import org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionPropos
public class ConvertForLoopQuickFixTest extends QuickFixTest {
@Rule
- public ProjectTestSetup projectsetup = new ProjectTestSetup();
+ public ProjectTestSetup projectsetup= new ProjectTestSetup();
private IJavaProject fJProject1;
- private IPackageFragmentRoot fSourceFolder;
+ IPackageFragmentRoot fSourceFolder;
private FixCorrectionProposal fConvertLoopProposal;
@Before
@@ -2940,6 +2940,92 @@ public class ConvertForLoopQuickFixTest extends QuickFixTest {
assertEqualString(preview2, expected);
}
+ @Test
+ public void testBug562291_1() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuilder buf= new StringBuilder();
+ buf.append(
+ "package test1;\n" +
+ "import java.io.Serializable;\n" +
+ "public class A {\n" +
+ " public void test() {\n" +
+ " Object[] foo= new Object[5];\n" +
+ " for (int i= 0; i < foo.length; i++) {\n" +
+ " if (!(foo[i] instanceof Serializable)) {\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("A.java", buf.toString(), false, null);
+
+ List<IJavaCompletionProposal> proposals= fetchConvertingProposal(buf, cu);
+
+ assertNotNull(fConvertLoopProposal);
+
+ assertCorrectLabels(proposals);
+
+ String preview1= getPreviewContent(fConvertLoopProposal);
+
+ buf= new StringBuilder();
+ buf.append(
+ "package test1;\n" +
+ "import java.io.Serializable;\n" +
+ "public class A {\n" +
+ " public void test() {\n" +
+ " Object[] foo= new Object[5];\n" +
+ " for (Object element : foo) {\n" +
+ " if (!(element instanceof Serializable)) {\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n");
+ String expected= buf.toString();
+ assertEqualString(preview1, expected);
+ }
+
+ @Test
+ public void testBug562291_2() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuilder buf= new StringBuilder();
+ buf.append(
+ "package test1;\n" +
+ "import java.io.Serializable;\n" +
+ "public class A {\n" +
+ " public void test() {\n" +
+ " boolean[] foo= new boolean[5];\n" +
+ " for (int i= 0; i < foo.length; i++) {\n" +
+ " if (!foo[i]) {\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("A.java", buf.toString(), false, null);
+
+ List<IJavaCompletionProposal> proposals= fetchConvertingProposal(buf, cu);
+
+ assertNotNull(fConvertLoopProposal);
+
+ assertCorrectLabels(proposals);
+
+ String preview1= getPreviewContent(fConvertLoopProposal);
+
+ buf= new StringBuilder();
+ buf.append(
+ "package test1;\n" +
+ "import java.io.Serializable;\n" +
+ "public class A {\n" +
+ " public void test() {\n" +
+ " boolean[] foo= new boolean[5];\n" +
+ " for (boolean element : foo) {\n" +
+ " if (!element) {\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n");
+ String expected= buf.toString();
+ assertEqualString(preview1, expected);
+ }
+
private boolean satisfiesPrecondition(ICompilationUnit cu) {
ForStatement statement= getForStatement(cu);
ConvertLoopOperation op= new ConvertForLoopOperation(statement);
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertIterableLoopQuickFixTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertIterableLoopQuickFixTest.java
index 6190ac0b48..f976665aff 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertIterableLoopQuickFixTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertIterableLoopQuickFixTest.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.ui.tests.quickfix;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -140,6 +141,36 @@ public final class ConvertIterableLoopQuickFixTest extends QuickFixTest {
assertEqualString(preview, expected);
}
+ @Test
+ public void testWrongInitializer() throws Exception {
+ IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
+ String sample= "" //
+ + "package test;\n" //
+ + "\n" //
+ + "import java.util.Collection;\n" //
+ + "import java.util.Iterator;\n" //
+ + "\n" //
+ + "public class A {\n" //
+ + " Iterator<String> otherIterator;\n" //
+ + " Iterator<String> anotherIterator;\n" //
+ + " Collection<String> c;\n" //
+ + "\n" //
+ + " public A() {\n" //
+ + " for (final Iterator<String> iterator= (c.iterator() == null) ? otherIterator : anotherIterator; iterator.hasNext();) {\n" //
+ + " String test= iterator.next();\n" //
+ + " System.out.println(test);\n" //
+ + " }\n" //
+ + " }\n" //
+ + "}";
+ ICompilationUnit unit= pack.createCompilationUnit("A.java", sample, false, null);
+
+ List<IJavaCompletionProposal> proposals= fetchConvertingProposal(sample, unit);
+
+ assertNull(fConvertLoopProposal);
+
+ assertCorrectLabels(proposals);
+ }
+
@Ignore
@Test
public void testKeepComment() throws Exception {
@@ -187,7 +218,7 @@ public final class ConvertIterableLoopQuickFixTest extends QuickFixTest {
/**
* quickfix creates strange indentation because of the return in the start statement
* see https://bugs.eclipse.org/bugs/show_bug.cgi?id=553635
- * @throws Exception
+ * @throws Exception Any exception
*/
@Ignore("Bug 553635")
@Test
@@ -1023,7 +1054,8 @@ public final class ConvertIterableLoopQuickFixTest extends QuickFixTest {
List<IJavaCompletionProposal> proposals= fetchConvertingProposal(sample, unit);
- assertTrue(fConvertLoopProposal.getFixStatus() != null && fConvertLoopProposal.getFixStatus().getCode() == IStatus.WARNING);
+ assertNotNull(fConvertLoopProposal.getFixStatus());
+ assertEquals(IStatus.WARNING, fConvertLoopProposal.getFixStatus().getCode());
assertCorrectLabels(proposals);
@@ -1083,7 +1115,8 @@ public final class ConvertIterableLoopQuickFixTest extends QuickFixTest {
List<IJavaCompletionProposal> proposals= fetchConvertingProposal(sample, unit);
- assertTrue(fConvertLoopProposal.getFixStatus() != null && fConvertLoopProposal.getFixStatus().getCode() == IStatus.WARNING);
+ assertNotNull(fConvertLoopProposal.getFixStatus());
+ assertEquals(IStatus.WARNING, fConvertLoopProposal.getFixStatus().getCode());
assertCorrectLabels(proposals);
@@ -1144,7 +1177,8 @@ public final class ConvertIterableLoopQuickFixTest extends QuickFixTest {
List<IJavaCompletionProposal> proposals= fetchConvertingProposal(sample, unit);
- assertTrue(fConvertLoopProposal.getFixStatus() != null && fConvertLoopProposal.getFixStatus().isOK());
+ assertNotNull(fConvertLoopProposal.getFixStatus());
+ assertTrue(fConvertLoopProposal.getFixStatus().isOK());
assertCorrectLabels(proposals);
@@ -1196,7 +1230,8 @@ public final class ConvertIterableLoopQuickFixTest extends QuickFixTest {
List<IJavaCompletionProposal> proposals= fetchConvertingProposal(sample, unit);
- assertTrue(fConvertLoopProposal.getFixStatus() != null && fConvertLoopProposal.getFixStatus().isOK());
+ assertNotNull(fConvertLoopProposal.getFixStatus());
+ assertTrue(fConvertLoopProposal.getFixStatus().isOK());
assertCorrectLabels(proposals);
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/JarUtil.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/JarUtil.java
index d1ca0886ae..609189177a 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/JarUtil.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/JarUtil.java
@@ -743,4 +743,7 @@ private static void zip(File dir, ZipOutputStream zip, int rootPathLength) throw
}
}
}
+
+ private JarUtil() {
+ }
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/JavadocQuickFixTest14.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/JavadocQuickFixTest14.java
new file mode 100644
index 0000000000..c6cef7617a
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/JavadocQuickFixTest14.java
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * Copyright (c) 2020 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Red Hat Inc. - new Javadoc quickfix test based on QuickFixTest9
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.quickfix;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+import org.eclipse.jdt.testplugin.TestOptions;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
+
+import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType;
+import org.eclipse.jdt.internal.core.manipulation.StubUtility;
+
+import org.eclipse.jdt.ui.tests.core.rules.Java14ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
+
+@RunWith(JUnit4.class)
+public class JavadocQuickFixTest14 extends QuickFixTest {
+
+ @Rule
+ public ProjectTestSetup projectsetup = new Java14ProjectTestSetup(true);
+
+ private IJavaProject fJProject1;
+
+ private IPackageFragmentRoot fSourceFolder;
+
+ @Before
+ public void setUp() throws Exception {
+ Hashtable<String, String> options= TestOptions.getDefaultOptions();
+ options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC, JavaCore.ERROR);
+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS, JavaCore.ENABLED);
+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_METHOD_TYPE_PARAMETERS, JavaCore.ENABLED);
+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS, JavaCore.ERROR);
+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, JavaCore.ERROR);
+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING, JavaCore.ENABLED);
+ JavaCore.setOptions(options);
+
+ StringBuilder comment= new StringBuilder();
+ comment.append("/**\n");
+ comment.append(" * A record comment.\n");
+ comment.append(" *\n");
+ comment.append(" * ${tags}\n");
+ comment.append(" */");
+ String res= comment.toString();
+ StubUtility.setCodeTemplate(CodeTemplateContextType.TYPECOMMENT_ID, res, null);
+
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ JavaProjectHelper.set14CompilerOptions(fJProject1, true);
+ JavaProjectHelper.addRequiredModularProject(fJProject1, Java14ProjectTestSetup.getProject());
+
+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ JavaProjectHelper.clear(fJProject1, ProjectTestSetup.getDefaultClasspath());
+ }
+
+ @Test
+ public void testMissingRecordComment() throws Exception {
+ IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
+ StringBuilder buf= new StringBuilder();
+ buf.append("package test;\n\n");
+ buf.append("public record Rec1(int a, int b) {\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack.createCompilationUnit("Rec1.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot);
+
+ assertNumberOfProposals(proposals, 2);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview1= getPreviewContent(proposal);
+
+ buf= new StringBuilder();
+ buf.append("package test;\n\n");
+ buf.append("/**\n");
+ buf.append(" * A record comment.\n");
+ buf.append(" *\n");
+ buf.append(" * @param a\n");
+ buf.append(" * @param b\n");
+ buf.append(" */\n");
+ buf.append("public record Rec1(int a, int b) {\n");
+ buf.append("}\n");
+
+ String expected= buf.toString();
+ assertEqualString(preview1, expected);
+ }
+
+ @Test
+ public void testMissingRecordCommentWithTypeParam() throws Exception {
+ IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
+ StringBuilder buf= new StringBuilder();
+ buf.append("package test;\n\n");
+ buf.append("public record Rec1<N>(int a, int b) {\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack.createCompilationUnit("Rec1.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot);
+
+ assertNumberOfProposals(proposals, 2);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview1= getPreviewContent(proposal);
+
+ buf= new StringBuilder();
+ buf.append("package test;\n\n");
+ buf.append("/**\n");
+ buf.append(" * A record comment.\n");
+ buf.append(" *\n");
+ buf.append(" * @param <N>\n");
+ buf.append(" * @param a\n");
+ buf.append(" * @param b\n");
+ buf.append(" */\n");
+ buf.append("public record Rec1<N>(int a, int b) {\n");
+ buf.append("}\n");
+
+ String expected= buf.toString();
+ assertEqualString(preview1, expected);
+ }
+
+ @Test
+ public void testMissingRecordCommentTag() throws Exception {
+ IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
+ StringBuilder buf= new StringBuilder();
+ buf.append("package test;\n\n");
+ buf.append("/**\n");
+ buf.append(" * A record comment.\n");
+ buf.append(" *\n");
+ buf.append(" * @param a\n");
+ buf.append(" */\n");
+ buf.append("public record Rec1(int a, int b) {\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack.createCompilationUnit("Rec1.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot);
+
+ assertNumberOfProposals(proposals, 3);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview1= getPreviewContent(proposal);
+
+ buf= new StringBuilder();
+ buf.append("package test;\n\n");
+ buf.append("/**\n");
+ buf.append(" * A record comment.\n");
+ buf.append(" *\n");
+ buf.append(" * @param a\n");
+ buf.append(" * @param b \n");
+ buf.append(" */\n");
+ buf.append("public record Rec1(int a, int b) {\n");
+ buf.append("}\n");
+
+ String expected= buf.toString();
+ assertEqualString(preview1, expected);
+ }
+
+
+ @Test
+ public void testMissingAllRecordCommentTags() throws Exception {
+ IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
+ StringBuilder buf= new StringBuilder();
+ buf.append("package test;\n\n");
+ buf.append("/**\n");
+ buf.append(" * A record comment.\n");
+ buf.append(" *\n");
+ buf.append(" */\n");
+ buf.append("public record Rec1(int a, int b) {\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack.createCompilationUnit("Rec1.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 2);
+
+ assertNumberOfProposals(proposals, 3);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(1);
+ String preview1= getPreviewContent(proposal);
+
+ buf= new StringBuilder();
+ buf.append("package test;\n\n");
+ buf.append("/**\n");
+ buf.append(" * A record comment.\n");
+ buf.append(" * @param a \n");
+ buf.append(" * @param b \n");
+ buf.append(" *\n");
+ buf.append(" */\n");
+ buf.append("public record Rec1(int a, int b) {\n");
+ buf.append("}\n");
+
+ String expected= buf.toString();
+ assertEqualString(preview1, expected);
+ }
+
+ @Test
+ public void testMissingTypeParamTag() throws Exception {
+ IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
+ StringBuilder buf= new StringBuilder();
+ buf.append("package test;\n\n");
+ buf.append("/**\n");
+ buf.append(" * A record comment.\n");
+ buf.append(" * @param a \n");
+ buf.append(" * @param b \n");
+ buf.append(" *\n");
+ buf.append(" */\n");
+ buf.append("public record Rec1<N>(int a, int b) {\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack.createCompilationUnit("Rec1.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot);
+
+ assertNumberOfProposals(proposals, 3);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(1);
+ String preview1= getPreviewContent(proposal);
+
+ buf= new StringBuilder();
+ buf.append("package test;\n\n");
+ buf.append("/**\n");
+ buf.append(" * A record comment.\n");
+ buf.append(" * @param <N> \n");
+ buf.append(" * @param a \n");
+ buf.append(" * @param b \n");
+ buf.append(" *\n");
+ buf.append(" */\n");
+ buf.append("public record Rec1<N>(int a, int b) {\n");
+ buf.append("}\n");
+
+ String expected= buf.toString();
+ assertEqualString(preview1, expected);
+ }
+}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java
index ff0a6a190c..854a904daf 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java
@@ -2496,10 +2496,6 @@ public class LocalCorrectionsQuickFixTest extends QuickFixTest {
buf.append("}\n");
String expected1= buf.toString();
- proposals= collectCorrections(cu, problems[1], null);
- assertNumberOfProposals(proposals, 1);
- assertCorrectLabels(proposals);
-
assertEqualStringsIgnoreOrder(
new String[] { preview1 },
new String[] { expected1 });
@@ -2550,16 +2546,352 @@ public class LocalCorrectionsQuickFixTest extends QuickFixTest {
buf.append("}\n");
String expected1= buf.toString();
- proposals= collectCorrections(cu, problems[0], null);
- assertNumberOfProposals(proposals, 1);
- assertCorrectLabels(proposals);
-
assertEqualStringsIgnoreOrder(
new String[] { preview1 },
new String[] { expected1 });
}
@Test
+ public void testUninitializedField_4() throws Exception {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=37872
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final int foo;\n");
+ buf.append(" public E(String bar) {\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ IProblem[] problems= astRoot.getProblems();
+ assertNumberOfProblems(1, problems);
+
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, problems[0], null);
+ assertNumberOfProposals(proposals, 2);
+ assertCorrectLabels(proposals);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final int foo;\n");
+ buf.append(" public E(String bar, int foo) {\n");
+ buf.append(" this.foo = foo;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ String expected1= buf.toString();
+
+ assertExpectedExistInProposals(proposals, new String[] { expected1 });
+ }
+
+ @Test
+ public void testUninitializedField_5() throws Exception {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=37872
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final Object foo;\n");
+ buf.append(" public E(String foo) {\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ IProblem[] problems= astRoot.getProblems();
+ assertNumberOfProblems(1, problems);
+
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, problems[0], null);
+ assertNumberOfProposals(proposals, 2);
+ assertCorrectLabels(proposals);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final Object foo;\n");
+ buf.append(" public E(String foo, Object foo2) {\n");
+ buf.append(" this.foo = foo2;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ String expected1= buf.toString();
+
+ assertExpectedExistInProposals(proposals, new String[] { expected1 });
+ }
+
+ @Test
+ public void testUninitializedField_6() throws Exception {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=37872
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final int foo1;\n");
+ buf.append(" public final int foo2;\n");
+ buf.append(" public E(String bar) {\n");
+ buf.append(" String a;\n");
+ buf.append(" this.foo1 = 0;\n");
+ buf.append(" String b;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ IProblem[] problems= astRoot.getProblems();
+ assertNumberOfProblems(1, problems);
+
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, problems[0], null);
+ assertNumberOfProposals(proposals, 2);
+ assertCorrectLabels(proposals);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final int foo1;\n");
+ buf.append(" public final int foo2;\n");
+ buf.append(" public E(String bar) {\n");
+ buf.append(" String a;\n");
+ buf.append(" this.foo1 = 0;\n");
+ buf.append(" this.foo2 = 0;\n");
+ buf.append(" String b;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ String expected1= buf.toString();
+
+ assertExpectedExistInProposals(proposals, new String[] { expected1 });
+ }
+
+ @Test
+ public void testUninitializedField_7() throws Exception {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=37872
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final int foo1;\n");
+ buf.append(" public E() {\n");
+ buf.append(" }\n");
+ buf.append(" public E(String bar) {\n");
+ buf.append(" foo1 = 0;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ IProblem[] problems= astRoot.getProblems();
+ assertNumberOfProblems(1, problems);
+
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, problems[0], null);
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final int foo1;\n");
+ buf.append(" public E() {\n");
+ buf.append(" this.foo1 = 0;\n");
+ buf.append(" }\n");
+ buf.append(" public E(String bar) {\n");
+ buf.append(" foo1 = 0;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ String expected1= buf.toString();
+
+ assertExpectedExistInProposals(proposals, new String[] { expected1 });
+ }
+
+ @Test
+ public void testUninitializedField_8() throws Exception {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=37872
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final int foo1;\n");
+ buf.append(" public E() {\n");
+ buf.append(" int a = 0;\n");
+ buf.append(" int b = foo1;\n");
+ buf.append(" }\n");
+ buf.append(" public E(String bar) {\n");
+ buf.append(" foo1 = 0;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ IProblem[] problems= astRoot.getProblems();
+ assertNumberOfProblems(2, problems);
+
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, problems[0], null);
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final int foo1;\n");
+ buf.append(" public E() {\n");
+ buf.append(" this.foo1 = 0;\n");
+ buf.append(" int a = 0;\n");
+ buf.append(" int b = foo1;\n");
+ buf.append(" }\n");
+ buf.append(" public E(String bar) {\n");
+ buf.append(" foo1 = 0;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ String expected1= buf.toString();
+
+ assertExpectedExistInProposals(proposals, new String[] { expected1 });
+ }
+
+ @Test
+ public void testUninitializedField_9() throws Exception {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=37872
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final int a;\n");
+ buf.append(" public final int b;\n");
+ buf.append(" public E(int a) {\n");
+ buf.append(" a = b;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ IProblem[] problems= astRoot.getProblems();
+ assertNumberOfProblems(3, problems);
+
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, problems[0], null);
+ assertNumberOfProposals(proposals, 2);
+ assertCorrectLabels(proposals);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final int a;\n");
+ buf.append(" public final int b;\n");
+ buf.append(" public E(int a) {\n");
+ buf.append(" this.a = 0;\n");
+ buf.append(" a = b;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ String expected1= buf.toString();
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final int a;\n");
+ buf.append(" public final int b;\n");
+ buf.append(" public E(int a, int a2) {\n");
+ buf.append(" this.a = a2;\n");
+ buf.append(" a = b;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ String expected2= buf.toString();
+
+ assertExpectedExistInProposals(proposals, new String[] { expected1, expected2 });
+ }
+
+ @Test
+ public void testUninitializedField_10() throws Exception {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=37872
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final int b;\n");
+ buf.append(" public E(int a) {\n");
+ buf.append(" int b = 0;\n");
+ buf.append(" a = b;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ IProblem[] problems= astRoot.getProblems();
+ assertNumberOfProblems(1, problems);
+
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, problems[0], null);
+ assertNumberOfProposals(proposals, 2);
+ assertCorrectLabels(proposals);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final int b;\n");
+ buf.append(" public E(int a) {\n");
+ buf.append(" this.b = 0;\n");
+ buf.append(" int b = 0;\n");
+ buf.append(" a = b;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ String expected1= buf.toString();
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public class E {\n");
+ buf.append(" public final int b;\n");
+ buf.append(" public E(int a, int b2) {\n");
+ buf.append(" this.b = b2;\n");
+ buf.append(" int b = 0;\n");
+ buf.append(" a = b;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ String expected2= buf.toString();
+
+ assertExpectedExistInProposals(proposals, new String[] { expected1, expected2 });
+ }
+
+ @Test
+ public void testUninitializedField_11() throws Exception {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=563285
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public enum E {\n");
+ buf.append(" a, b, c;\n");
+ buf.append(" private final int foo1;\n");
+ buf.append(" private final int foo2;\n");
+ buf.append(" private E(int i1, int i2) {\n");
+ buf.append(" this.foo1 = i1;\n");
+ buf.append(" this.foo2 = i2;\n");
+ buf.append(" }\n");
+ buf.append(" E() {\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ IProblem[] problems= astRoot.getProblems();
+ assertNumberOfProblems(2, problems);
+
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, problems[0], null);
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ buf= new StringBuffer();
+ buf.append("package test1;\n");
+ buf.append("public enum E {\n");
+ buf.append(" a, b, c;\n");
+ buf.append(" private final int foo1;\n");
+ buf.append(" private final int foo2;\n");
+ buf.append(" private E(int i1, int i2) {\n");
+ buf.append(" this.foo1 = i1;\n");
+ buf.append(" this.foo2 = i2;\n");
+ buf.append(" }\n");
+ buf.append(" E() {\n");
+ buf.append(" this.foo1 = 0;\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ String expected1= buf.toString();
+
+ assertExpectedExistInProposals(proposals, new String[] { expected1 });
+ }
+
+ @Test
public void testUnimplementedMethods() throws Exception {
IPackageFragment pack2= fSourceFolder.createPackageFragment("test2", false, null);
StringBuffer buf= new StringBuffer();
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest17.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest1d7.java
index 4cd322f9e9..d9fd7bb447 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest17.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest1d7.java
@@ -47,8 +47,11 @@ import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
import org.eclipse.jdt.internal.ui.JavaPlugin;
+/**
+ * Those tests should run on Java Dolphin 1.7 .
+ */
@RunWith(JUnit4.class)
-public class LocalCorrectionsQuickFixTest17 extends QuickFixTest {
+public class LocalCorrectionsQuickFixTest1d7 extends QuickFixTest {
@Rule
public ProjectTestSetup projectsetup = new Java1d7ProjectTestSetup();
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest1d8.java
index c5c1c0011b..0a147dc11d 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest18.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest1d8.java
@@ -41,18 +41,21 @@ import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType;
import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.ui.PreferenceConstants;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.correction.CorrectionMessages;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@RunWith(JUnit4.class)
-public class LocalCorrectionsQuickFixTest18 extends QuickFixTest {
+public class LocalCorrectionsQuickFixTest1d8 extends QuickFixTest {
@Rule
- public ProjectTestSetup projectsetup = new Java18ProjectTestSetup();
+ public ProjectTestSetup projectsetup = new Java1d8ProjectTestSetup();
private IJavaProject fJProject1;
@@ -78,7 +81,7 @@ public class LocalCorrectionsQuickFixTest18 extends QuickFixTest {
StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);
StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
@@ -86,7 +89,7 @@ public class LocalCorrectionsQuickFixTest18 extends QuickFixTest {
@After
public void tearDown() throws Exception {
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
@Test
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest17.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest1d7.java
index a966923546..a4531f35ae 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest17.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ModifierCorrectionsQuickFixTest1d7.java
@@ -47,8 +47,11 @@ import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.correction.CorrectionMessages;
+/**
+ * Those tests should run on Java Dolphin 1.7 .
+ */
@RunWith(JUnit4.class)
-public class ModifierCorrectionsQuickFixTest17 extends QuickFixTest {
+public class ModifierCorrectionsQuickFixTest1d7 extends QuickFixTest {
@Rule
public ProjectTestSetup projectsetup = new Java1d7ProjectTestSetup();
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsCleanUpTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsCleanUpTest1d8.java
index 56773ccbee..9860af5ffc 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsCleanUpTest18.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsCleanUpTest1d8.java
@@ -42,16 +42,19 @@ import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring;
import org.eclipse.jdt.ui.cleanup.ICleanUp;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.internal.ui.fix.NullAnnotationsCleanUp;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@RunWith(JUnit4.class)
-public class NullAnnotationsCleanUpTest18 extends CleanUpTestCase {
+public class NullAnnotationsCleanUpTest1d8 extends CleanUpTestCase {
@Rule
- public ProjectTestSetup projectsetup = new Java18ProjectTestSetup();
+ public ProjectTestSetup projectsetup = new Java1d8ProjectTestSetup();
private String ANNOTATION_JAR_PATH;
@@ -91,12 +94,12 @@ public class NullAnnotationsCleanUpTest18 extends CleanUpTestCase {
@Override
protected IJavaProject getProject() {
- return Java18ProjectTestSetup.getProject();
+ return Java1d8ProjectTestSetup.getProject();
}
@Override
protected IClasspathEntry[] getDefaultClasspath() throws CoreException {
- return Java18ProjectTestSetup.getDefaultClasspath();
+ return Java1d8ProjectTestSetup.getDefaultClasspath();
}
@Test
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsQuickFixTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsQuickFixTest1d8.java
index 0d82841ae3..c635ab6b21 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsQuickFixTest18.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsQuickFixTest1d8.java
@@ -53,18 +53,21 @@ import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType;
import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.ui.PreferenceConstants;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
import org.eclipse.jdt.internal.ui.JavaPlugin;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@RunWith(JUnit4.class)
-public class NullAnnotationsQuickFixTest18 extends QuickFixTest {
+public class NullAnnotationsQuickFixTest1d8 extends QuickFixTest {
@Rule
- public ProjectTestSetup projectsetup = new Java18ProjectTestSetup();
+ public ProjectTestSetup projectsetup = new Java1d8ProjectTestSetup();
private IJavaProject fJProject1;
private IPackageFragmentRoot fSourceFolder;
@@ -97,7 +100,7 @@ public class NullAnnotationsQuickFixTest18 extends QuickFixTest {
StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);
StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
if (this.ANNOTATION_JAR_PATH == null) {
String version= "[2.0.0,3.0.0)"; // tests run at 1.8, need the "new" null annotations
Bundle[] bundles= Platform.getBundles("org.eclipse.jdt.annotation", version);
@@ -114,7 +117,7 @@ public class NullAnnotationsQuickFixTest18 extends QuickFixTest {
@After
public void tearDown() throws Exception {
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
/*
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsQuickFixTest18Mix.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsQuickFixTest1d8Mix.java
index 498ce7e1b3..8052d8d48f 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsQuickFixTest18Mix.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/NullAnnotationsQuickFixTest1d8Mix.java
@@ -46,19 +46,22 @@ import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType;
import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.ui.PreferenceConstants;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
import org.eclipse.jdt.internal.ui.JavaPlugin;
-/** Tests against projects with 1.8 compliance and "old" declaration null annotations. */
+/**
+ * Tests against projects with 1.8 compliance and "old" declaration null annotations.
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@RunWith(JUnit4.class)
-public class NullAnnotationsQuickFixTest18Mix extends QuickFixTest {
+public class NullAnnotationsQuickFixTest1d8Mix extends QuickFixTest {
@Rule
- public ProjectTestSetup projectsetup = new Java18ProjectTestSetup();
+ public ProjectTestSetup projectsetup = new Java1d8ProjectTestSetup();
private IJavaProject fJProject1;
private IPackageFragmentRoot fSourceFolder;
@@ -91,7 +94,7 @@ public class NullAnnotationsQuickFixTest18Mix extends QuickFixTest {
StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);
StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
if (ANNOTATION_JAR_PATH == null) {
String version= "[1.1.0,2.0.0)"; // tests run at 1.8, but still use "old" null annotations
@@ -109,7 +112,7 @@ public class NullAnnotationsQuickFixTest18Mix extends QuickFixTest {
@After
public void tearDown() throws Exception {
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
// ==== Problem: unchecked conversion, type elided lambda arg
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest.java
index 6026179d36..c1a8b87191 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
@@ -47,8 +48,12 @@ import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IProblemRequestor;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.WorkingCopyOwner;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
@@ -85,7 +90,7 @@ import org.eclipse.jdt.internal.ui.text.template.contentassist.SurroundWithTempl
@RunWith(Suite.class)
@Suite.SuiteClasses({
QuickFixTest9.class,
- QuickFixTest18.class,
+ QuickFixTest1d8.class,
QuickFixTest14.class,
QuickFixTest15.class,
SerialVersionQuickFixTest.class,
@@ -93,20 +98,20 @@ import org.eclipse.jdt.internal.ui.text.template.contentassist.SurroundWithTempl
UnresolvedTypesQuickFixTest.class,
UnresolvedVariablesQuickFixTest.class,
UnresolvedMethodsQuickFixTest.class,
- UnresolvedMethodsQuickFixTest18.class,
+ UnresolvedMethodsQuickFixTest1d8.class,
ReturnTypeQuickFixTest.class,
LocalCorrectionsQuickFixTest.class,
- LocalCorrectionsQuickFixTest17.class,
- LocalCorrectionsQuickFixTest18.class,
+ LocalCorrectionsQuickFixTest1d7.class,
+ LocalCorrectionsQuickFixTest1d8.class,
TypeMismatchQuickFixTests.class,
ReorgQuickFixTest.class,
ModifierCorrectionsQuickFixTest.class,
- ModifierCorrectionsQuickFixTest17.class,
+ ModifierCorrectionsQuickFixTest1d7.class,
ModifierCorrectionsQuickFixTest9.class,
GetterSetterQuickFixTest.class,
AssistQuickFixTest.class,
- AssistQuickFixTest17.class,
- AssistQuickFixTest18.class,
+ AssistQuickFixTest1d7.class,
+ AssistQuickFixTest1d8.class,
AssistQuickFixTest12.class,
ChangeNonStaticToStaticTest.class,
MarkerResolutionTest.class,
@@ -116,18 +121,18 @@ import org.eclipse.jdt.internal.ui.text.template.contentassist.SurroundWithTempl
ConvertForLoopQuickFixTest.class,
ConvertIterableLoopQuickFixTest.class,
AdvancedQuickAssistTest.class,
- AdvancedQuickAssistTest17.class,
- AdvancedQuickAssistTest18.class,
+ AdvancedQuickAssistTest1d7.class,
+ AdvancedQuickAssistTest1d8.class,
CleanUpTestCase.class,
QuickFixEnablementTest.class,
SurroundWithTemplateTest.class,
TypeParameterMismatchTest.class,
PropertiesFileQuickAssistTest.class,
NullAnnotationsQuickFixTest.class,
- NullAnnotationsQuickFixTest18.class,
- NullAnnotationsQuickFixTest18Mix.class,
+ NullAnnotationsQuickFixTest1d8.class,
+ NullAnnotationsQuickFixTest1d8Mix.class,
AnnotateAssistTest1d5.class,
- AnnotateAssistTest18.class,
+ AnnotateAssistTest1d8.class,
TypeAnnotationQuickFixTest.class
})
@@ -483,7 +488,7 @@ public class QuickFixTest {
protected static String[] getAllDisplayStrings(ArrayList<IJavaCompletionProposal> proposals) {
return proposals.stream()
- .map(proposal -> proposal.getDisplayString())
+ .map(IJavaCompletionProposal::getDisplayString)
.filter(displayString -> displayString != null && !displayString.isEmpty())
.toArray(String[]::new);
}
@@ -661,4 +666,33 @@ public class QuickFixTest {
assertEquals("Unexpected choice", expectedChoices[i], sortedChoices.get(i));
}
}
+/**
+ * Computes the number of warnings the java file "filename" has.
+ * Then check if the "preview" source code has the same number of warnings.
+ * Throw error if the number changes.
+ *
+ * @param pack
+ * @param preview
+ * @param className
+ * @param filename
+ * @param fSourceFolder
+ * @throws JavaModelException
+ */
+ protected void assertNoAdditionalProblems(IPackageFragment pack, String preview, String className, String filename, IPackageFragmentRoot fSourceFolder) throws JavaModelException {
+ Hashtable<String, String> options= JavaCore.getOptions();
+ options.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR);
+ JavaCore.setOptions(options);
+
+ ICompilationUnit cu= pack.getCompilationUnit(filename);
+ CompilationUnit astRoot= getASTRoot(cu);
+ IProblem[] problems= astRoot.getProblems();
+ int nrofproblems= problems.length;
+
+ pack.delete(true, null);
+ pack= fSourceFolder.createPackageFragment(className, false, null);
+ cu= pack.createCompilationUnit(filename, preview, false, null);
+ astRoot= getASTRoot(cu);
+ problems= astRoot.getProblems();
+ assertNumberOfProblems(nrofproblems, problems);
+ }
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest14.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest14.java
index 9ce5ed10c9..1233ebd6a1 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest14.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest14.java
@@ -14,6 +14,7 @@
package org.eclipse.jdt.ui.tests.quickfix;
import java.util.ArrayList;
+import java.util.Map;
import org.junit.After;
import org.junit.Rule;
@@ -27,13 +28,18 @@ import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.internal.corext.util.Messages;
+
import org.eclipse.jdt.ui.tests.core.rules.Java14ProjectTestSetup;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
+import org.eclipse.jdt.internal.ui.text.correction.CorrectionMessages;
+
@RunWith(JUnit4.class)
public class QuickFixTest14 extends QuickFixTest {
@@ -46,6 +52,10 @@ public class QuickFixTest14 extends QuickFixTest {
private IPackageFragmentRoot fSourceFolder;
+ private static String MODULE_INFO_FILE_CONTENT = ""
+ + "module test {\n"
+ + "}\n";
+
@After
public void tearDown() throws Exception {
if (fJProject1 != null) {
@@ -54,34 +64,73 @@ public class QuickFixTest14 extends QuickFixTest {
}
@Test
+ public void testRecordSuppressWarningsProposals() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ fJProject1.setRawClasspath(Java14ProjectTestSetup.getDefaultClasspath(), null);
+ JavaProjectHelper.set14CompilerOptions(fJProject1, true);
+
+ Map<String, String> options= fJProject1.getOptions(false);
+ options.put(JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES, JavaCore.WARNING);
+ fJProject1.setOptions(options);
+
+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
+
+
+ IPackageFragment def= fSourceFolder.createPackageFragment("", false, null);
+ def.createCompilationUnit("module-info.java", MODULE_INFO_FILE_CONTENT, false, null);
+
+ IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
+ String test= ""
+ + "package test;\n"
+ + "public record Rec1() {\n"
+ + "}\n";
+ ICompilationUnit cu= pack.createCompilationUnit("Rec1.java", test, false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 1, null);
+
+ assertNumberOfProposals(proposals, 2);
+ String label= Messages.format(CorrectionMessages.SuppressWarningsSubProcessor_suppress_warnings_label, new String[] { "preview", "Rec1" });
+ assertProposalExists(proposals, label);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview= getPreviewContent(proposal);
+
+ String expected= ""
+ + "package test;\n"
+ + "@SuppressWarnings(\"preview\")\n"
+ + "public record Rec1() {\n"
+ + "}\n";
+
+ assertEqualStringsIgnoreOrder(new String[] { preview }, new String[] { expected });
+ }
+
+ @Test
public void testAddDefaultCaseSwitchStatement1() throws Exception {
fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
fJProject1.setRawClasspath(Java14ProjectTestSetup.getDefaultClasspath(), null);
JavaProjectHelper.set14CompilerOptions(fJProject1, false);
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- StringBuffer buf= new StringBuffer();
- buf.append("module test {\n");
- buf.append("}\n");
IPackageFragment def= fSourceFolder.createPackageFragment("", false, null);
- def.createCompilationUnit("module-info.java", buf.toString(), false, null);
+ def.createCompilationUnit("module-info.java", MODULE_INFO_FILE_CONTENT, false, null);
IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class Cls {\n");
- buf.append(" public static void foo(Day day) {\n");
- buf.append(" switch (day) {\n");
- buf.append(" case SATURDAY, SUNDAY -> System.out.println(\"Weekend\");\n");
- buf.append(" case MONDAY, TUESDAY, WEDNESDAY -> System.out.println(\"Weekday\");\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("enum Day {\n");
- buf.append(" MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n");
- buf.append("}\n");
- ICompilationUnit cu= pack.createCompilationUnit("Cls.java", buf.toString(), false, null);
+ String test= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public static void foo(Day day) {\n"
+ + " switch (day) {\n"
+ + " case SATURDAY, SUNDAY -> System.out.println(\"Weekend\");\n"
+ + " case MONDAY, TUESDAY, WEDNESDAY -> System.out.println(\"Weekday\");\n"
+ + " }\n"
+ + " }\n"
+ + "}\n"
+ + "\n"
+ + "enum Day {\n"
+ + " MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n"
+ + "}\n";
+ ICompilationUnit cu= pack.createCompilationUnit("Cls.java", test, false, null);
CompilationUnit astRoot= getASTRoot(cu);
ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 2);
@@ -91,22 +140,21 @@ public class QuickFixTest14 extends QuickFixTest {
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(1);
String preview= getPreviewContent(proposal);
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class Cls {\n");
- buf.append(" public static void foo(Day day) {\n");
- buf.append(" switch (day) {\n");
- buf.append(" case SATURDAY, SUNDAY -> System.out.println(\"Weekend\");\n");
- buf.append(" case MONDAY, TUESDAY, WEDNESDAY -> System.out.println(\"Weekday\");\n");
- buf.append(" default -> throw new IllegalArgumentException(\"Unexpected value: \" + day);\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("enum Day {\n");
- buf.append(" MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n");
- buf.append("}\n");
- String expected= buf.toString();
+ String expected= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public static void foo(Day day) {\n"
+ + " switch (day) {\n"
+ + " case SATURDAY, SUNDAY -> System.out.println(\"Weekend\");\n"
+ + " case MONDAY, TUESDAY, WEDNESDAY -> System.out.println(\"Weekday\");\n"
+ + " default -> throw new IllegalArgumentException(\"Unexpected value: \" + day);\n"
+ + " }\n"
+ + " }\n"
+ + "}\n"
+ + "\n"
+ + "enum Day {\n"
+ + " MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n"
+ + "}\n";
assertEqualStringsIgnoreOrder(new String[] { preview }, new String[] { expected });
}
@@ -118,28 +166,25 @@ public class QuickFixTest14 extends QuickFixTest {
JavaProjectHelper.set14CompilerOptions(fJProject1, false);
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- StringBuffer buf= new StringBuffer();
- buf.append("module test {\n");
- buf.append("}\n");
IPackageFragment def= fSourceFolder.createPackageFragment("", false, null);
- def.createCompilationUnit("module-info.java", buf.toString(), false, null);
+ def.createCompilationUnit("module-info.java", MODULE_INFO_FILE_CONTENT, false, null);
IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class Cls {\n");
- buf.append(" public static void foo(Day day) {\n");
- buf.append(" switch (day) {\n");
- buf.append(" case SATURDAY, SUNDAY: System.out.println(\"Weekend\");\n");
- buf.append(" case MONDAY, TUESDAY, WEDNESDAY: System.out.println(\"Weekday\");\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("enum Day {\n");
- buf.append(" MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n");
- buf.append("}\n");
- ICompilationUnit cu= pack.createCompilationUnit("Cls.java", buf.toString(), false, null);
+ String test= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public static void foo(Day day) {\n"
+ + " switch (day) {\n"
+ + " case SATURDAY, SUNDAY: System.out.println(\"Weekend\");\n"
+ + " case MONDAY, TUESDAY, WEDNESDAY: System.out.println(\"Weekday\");\n"
+ + " }\n"
+ + " }\n"
+ + "}\n"
+ + "\n"
+ + "enum Day {\n"
+ + " MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n"
+ + "}\n";
+ ICompilationUnit cu= pack.createCompilationUnit("Cls.java", test, false, null);
CompilationUnit astRoot= getASTRoot(cu);
ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 2);
@@ -149,23 +194,22 @@ public class QuickFixTest14 extends QuickFixTest {
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(1);
String preview= getPreviewContent(proposal);
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class Cls {\n");
- buf.append(" public static void foo(Day day) {\n");
- buf.append(" switch (day) {\n");
- buf.append(" case SATURDAY, SUNDAY: System.out.println(\"Weekend\");\n");
- buf.append(" case MONDAY, TUESDAY, WEDNESDAY: System.out.println(\"Weekday\");\n");
- buf.append(" default :\n");
- buf.append(" break;\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("enum Day {\n");
- buf.append(" MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n");
- buf.append("}\n");
- String expected= buf.toString();
+ String expected= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public static void foo(Day day) {\n"
+ + " switch (day) {\n"
+ + " case SATURDAY, SUNDAY: System.out.println(\"Weekend\");\n"
+ + " case MONDAY, TUESDAY, WEDNESDAY: System.out.println(\"Weekday\");\n"
+ + " default :\n"
+ + " break;\n"
+ + " }\n"
+ + " }\n"
+ + "}\n"
+ + "\n"
+ + "enum Day {\n"
+ + " MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n"
+ + "}\n";
assertEqualStringsIgnoreOrder(new String[] { preview }, new String[] { expected });
}
@@ -177,26 +221,23 @@ public class QuickFixTest14 extends QuickFixTest {
JavaProjectHelper.set14CompilerOptions(fJProject1, false);
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- StringBuffer buf= new StringBuffer();
- buf.append("module test {\n");
- buf.append("}\n");
IPackageFragment def= fSourceFolder.createPackageFragment("", false, null);
- def.createCompilationUnit("module-info.java", buf.toString(), false, null);
+ def.createCompilationUnit("module-info.java", MODULE_INFO_FILE_CONTENT, false, null);
IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class Cls {\n");
- buf.append(" public static void foo(Day day) {\n");
- buf.append(" switch (day) {\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("enum Day {\n");
- buf.append(" MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n");
- buf.append("}\n");
- ICompilationUnit cu= pack.createCompilationUnit("Cls.java", buf.toString(), false, null);
+ String test= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public static void foo(Day day) {\n"
+ + " switch (day) {\n"
+ + " }\n"
+ + " }\n"
+ + "}\n"
+ + "\n"
+ + "enum Day {\n"
+ + " MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n"
+ + "}\n";
+ ICompilationUnit cu= pack.createCompilationUnit("Cls.java", test, false, null);
CompilationUnit astRoot= getASTRoot(cu);
ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 7);
@@ -206,21 +247,20 @@ public class QuickFixTest14 extends QuickFixTest {
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(1);
String preview= getPreviewContent(proposal);
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class Cls {\n");
- buf.append(" public static void foo(Day day) {\n");
- buf.append(" switch (day) {\n");
- buf.append(" default :\n");
- buf.append(" break;\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("\n");
- buf.append("enum Day {\n");
- buf.append(" MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n");
- buf.append("}\n");
- String expected= buf.toString();
+ String expected= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public static void foo(Day day) {\n"
+ + " switch (day) {\n"
+ + " default :\n"
+ + " break;\n"
+ + " }\n"
+ + " }\n"
+ + "}\n"
+ + "\n"
+ + "enum Day {\n"
+ + " MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n"
+ + "}\n";
assertEqualStringsIgnoreOrder(new String[] { preview }, new String[] { expected });
}
@@ -232,28 +272,25 @@ public class QuickFixTest14 extends QuickFixTest {
JavaProjectHelper.set14CompilerOptions(fJProject1, false);
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- StringBuffer buf= new StringBuffer();
- buf.append("module test {\n");
- buf.append("}\n");
IPackageFragment def= fSourceFolder.createPackageFragment("", false, null);
- def.createCompilationUnit("module-info.java", buf.toString(), false, null);
+ def.createCompilationUnit("module-info.java", MODULE_INFO_FILE_CONTENT, false, null);
IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class Cls {\n");
- buf.append(" public void bar1(Day day) {\n");
- buf.append(" switch (day) {\n");
- buf.append(" case MONDAY, FRIDAY -> System.out.println(Day.SUNDAY);\n");
- buf.append(" case TUESDAY -> System.out.println(7);\n");
- buf.append(" case THURSDAY, SATURDAY -> System.out.println(8);\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("enum Day {\n");
- buf.append(" MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n");
- buf.append("}\n");
- ICompilationUnit cu= pack.createCompilationUnit("Cls.java", buf.toString(), false, null);
+ String test= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public void bar1(Day day) {\n"
+ + " switch (day) {\n"
+ + " case MONDAY, FRIDAY -> System.out.println(Day.SUNDAY);\n"
+ + " case TUESDAY -> System.out.println(7);\n"
+ + " case THURSDAY, SATURDAY -> System.out.println(8);\n"
+ + " }\n"
+ + " }\n"
+ + "}\n"
+ + "enum Day {\n"
+ + " MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n"
+ + "}\n";
+ ICompilationUnit cu= pack.createCompilationUnit("Cls.java", test, false, null);
CompilationUnit astRoot= getASTRoot(cu);
ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 2);
@@ -263,24 +300,23 @@ public class QuickFixTest14 extends QuickFixTest {
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class Cls {\n");
- buf.append(" public void bar1(Day day) {\n");
- buf.append(" switch (day) {\n");
- buf.append(" case MONDAY, FRIDAY -> System.out.println(Day.SUNDAY);\n");
- buf.append(" case TUESDAY -> System.out.println(7);\n");
- buf.append(" case THURSDAY, SATURDAY -> System.out.println(8);\n");
- buf.append(" case SUNDAY -> throw new UnsupportedOperationException(\"Unimplemented case: \" + day);\n");
- buf.append(" case WEDNESDAY -> throw new UnsupportedOperationException(\"Unimplemented case: \" + day);\n");
- buf.append(" default -> throw new IllegalArgumentException(\"Unexpected value: \" + day);\n");
- buf.append(" }\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("enum Day {\n");
- buf.append(" MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n");
- buf.append("}\n");
- String expected= buf.toString();
+ String expected= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public void bar1(Day day) {\n"
+ + " switch (day) {\n"
+ + " case MONDAY, FRIDAY -> System.out.println(Day.SUNDAY);\n"
+ + " case TUESDAY -> System.out.println(7);\n"
+ + " case THURSDAY, SATURDAY -> System.out.println(8);\n"
+ + " case SUNDAY -> throw new UnsupportedOperationException(\"Unimplemented case: \" + day);\n"
+ + " case WEDNESDAY -> throw new UnsupportedOperationException(\"Unimplemented case: \" + day);\n"
+ + " default -> throw new IllegalArgumentException(\"Unexpected value: \" + day);\n"
+ + " }\n"
+ + " }\n"
+ + "}\n"
+ + "enum Day {\n"
+ + " MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n"
+ + "}\n";
assertEqualStringsIgnoreOrder(new String[] { preview }, new String[] { expected });
}
@@ -292,28 +328,25 @@ public class QuickFixTest14 extends QuickFixTest {
JavaProjectHelper.set14CompilerOptions(fJProject1, false);
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- StringBuffer buf= new StringBuffer();
- buf.append("module test {\n");
- buf.append("}\n");
IPackageFragment def= fSourceFolder.createPackageFragment("", false, null);
- def.createCompilationUnit("module-info.java", buf.toString(), false, null);
+ def.createCompilationUnit("module-info.java", MODULE_INFO_FILE_CONTENT, false, null);
IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class Cls {\n");
- buf.append(" public static void bar3(int input) {\n");
- buf.append(" int num = switch (input) {\n");
- buf.append(" case 60, 600 -> 6;\n");
- buf.append(" case 70 -> 7;\n");
- buf.append(" case 80 -> 8;\n");
- buf.append(" case 90, 900 -> {\n");
- buf.append(" yield 9;\n");
- buf.append(" }\n");
- buf.append(" };\n");
- buf.append(" }\n");
- buf.append("}\n");
- ICompilationUnit cu= pack.createCompilationUnit("Cls.java", buf.toString(), false, null);
+ String test= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public static void bar3(int input) {\n"
+ + " int num = switch (input) {\n"
+ + " case 60, 600 -> 6;\n"
+ + " case 70 -> 7;\n"
+ + " case 80 -> 8;\n"
+ + " case 90, 900 -> {\n"
+ + " yield 9;\n"
+ + " }\n"
+ + " };\n"
+ + " }\n"
+ + "}\n";
+ ICompilationUnit cu= pack.createCompilationUnit("Cls.java", test, false, null);
CompilationUnit astRoot= getASTRoot(cu);
ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 1);
@@ -323,22 +356,21 @@ public class QuickFixTest14 extends QuickFixTest {
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class Cls {\n");
- buf.append(" public static void bar3(int input) {\n");
- buf.append(" int num = switch (input) {\n");
- buf.append(" case 60, 600 -> 6;\n");
- buf.append(" case 70 -> 7;\n");
- buf.append(" case 80 -> 8;\n");
- buf.append(" case 90, 900 -> {\n");
- buf.append(" yield 9;\n");
- buf.append(" }\n");
- buf.append(" default -> throw new IllegalArgumentException(\"Unexpected value: \" + input);\n");
- buf.append(" };\n");
- buf.append(" }\n");
- buf.append("}\n");
- String expected= buf.toString();
+ String expected= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public static void bar3(int input) {\n"
+ + " int num = switch (input) {\n"
+ + " case 60, 600 -> 6;\n"
+ + " case 70 -> 7;\n"
+ + " case 80 -> 8;\n"
+ + " case 90, 900 -> {\n"
+ + " yield 9;\n"
+ + " }\n"
+ + " default -> throw new IllegalArgumentException(\"Unexpected value: \" + input);\n"
+ + " };\n"
+ + " }\n"
+ + "}\n";
assertEqualStringsIgnoreOrder(new String[] { preview }, new String[] { expected });
}
@@ -350,30 +382,27 @@ public class QuickFixTest14 extends QuickFixTest {
JavaProjectHelper.set14CompilerOptions(fJProject1, false);
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- StringBuffer buf= new StringBuffer();
- buf.append("module test {\n");
- buf.append("}\n");
IPackageFragment def= fSourceFolder.createPackageFragment("", false, null);
- def.createCompilationUnit("module-info.java", buf.toString(), false, null);
+ def.createCompilationUnit("module-info.java", MODULE_INFO_FILE_CONTENT, false, null);
IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class Cls {\n");
- buf.append(" public static void bar4(int input) {\n");
- buf.append(" int num = switch (input) {\n");
- buf.append(" case 60, 600:\n");
- buf.append(" yield 6;\n");
- buf.append(" case 70:\n");
- buf.append(" yield 7;\n");
- buf.append(" case 80:\n");
- buf.append(" yield 8;\n");
- buf.append(" case 90, 900:\n");
- buf.append(" yield 9;\n");
- buf.append(" };\n");
- buf.append(" }\n");
- buf.append("}\n");
- ICompilationUnit cu= pack.createCompilationUnit("Cls.java", buf.toString(), false, null);
+ String test= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public static void bar4(int input) {\n"
+ + " int num = switch (input) {\n"
+ + " case 60, 600:\n"
+ + " yield 6;\n"
+ + " case 70:\n"
+ + " yield 7;\n"
+ + " case 80:\n"
+ + " yield 8;\n"
+ + " case 90, 900:\n"
+ + " yield 9;\n"
+ + " };\n"
+ + " }\n"
+ + "}\n";
+ ICompilationUnit cu= pack.createCompilationUnit("Cls.java", test, false, null);
CompilationUnit astRoot= getASTRoot(cu);
ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 1);
@@ -383,26 +412,25 @@ public class QuickFixTest14 extends QuickFixTest {
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class Cls {\n");
- buf.append(" public static void bar4(int input) {\n");
- buf.append(" int num = switch (input) {\n");
- buf.append(" case 60, 600:\n");
- buf.append(" yield 6;\n");
- buf.append(" case 70:\n");
- buf.append(" yield 7;\n");
- buf.append(" case 80:\n");
- buf.append(" yield 8;\n");
- buf.append(" case 90, 900:\n");
- buf.append(" yield 9;\n");
- buf.append(" default :\n");
- buf.append(" throw new IllegalArgumentException(\n");
- buf.append(" \"Unexpected value: \" + input);\n");
- buf.append(" };\n");
- buf.append(" }\n");
- buf.append("}\n");
- String expected= buf.toString();
+ String expected= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public static void bar4(int input) {\n"
+ + " int num = switch (input) {\n"
+ + " case 60, 600:\n"
+ + " yield 6;\n"
+ + " case 70:\n"
+ + " yield 7;\n"
+ + " case 80:\n"
+ + " yield 8;\n"
+ + " case 90, 900:\n"
+ + " yield 9;\n"
+ + " default :\n"
+ + " throw new IllegalArgumentException(\n"
+ + " \"Unexpected value: \" + input);\n"
+ + " };\n"
+ + " }\n"
+ + "}\n";
assertEqualStringsIgnoreOrder(new String[] { preview }, new String[] { expected });
}
@@ -414,31 +442,28 @@ public class QuickFixTest14 extends QuickFixTest {
JavaProjectHelper.set14CompilerOptions(fJProject1, false);
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
- StringBuffer buf= new StringBuffer();
- buf.append("module test {\n");
- buf.append("}\n");
IPackageFragment def= fSourceFolder.createPackageFragment("", false, null);
- def.createCompilationUnit("module-info.java", buf.toString(), false, null);
+ def.createCompilationUnit("module-info.java", MODULE_INFO_FILE_CONTENT, false, null);
IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class Cls {\n");
- buf.append(" public void bar1(Day day) {\n");
- buf.append(" int len = switch (day) {\n");
- buf.append(" case MONDAY, FRIDAY:\n");
- buf.append(" yield 6;\n");
- buf.append(" case TUESDAY:\n");
- buf.append(" yield 7;\n");
- buf.append(" case THURSDAY, SATURDAY:\n");
- buf.append(" yield 8;\n");
- buf.append(" };\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("enum Day {\n");
- buf.append(" MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n");
- buf.append("}\n");
- ICompilationUnit cu= pack.createCompilationUnit("Cls.java", buf.toString(), false, null);
+ String test= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public void bar1(Day day) {\n"
+ + " int len = switch (day) {\n"
+ + " case MONDAY, FRIDAY:\n"
+ + " yield 6;\n"
+ + " case TUESDAY:\n"
+ + " yield 7;\n"
+ + " case THURSDAY, SATURDAY:\n"
+ + " yield 8;\n"
+ + " };\n"
+ + " }\n"
+ + "}\n"
+ + "enum Day {\n"
+ + " MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n"
+ + "}\n";
+ ICompilationUnit cu= pack.createCompilationUnit("Cls.java", test, false, null);
CompilationUnit astRoot= getASTRoot(cu);
ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot, 2);
@@ -448,35 +473,92 @@ public class QuickFixTest14 extends QuickFixTest {
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
- buf= new StringBuffer();
- buf.append("package test;\n");
- buf.append("public class Cls {\n");
- buf.append(" public void bar1(Day day) {\n");
- buf.append(" int len = switch (day) {\n");
- buf.append(" case MONDAY, FRIDAY:\n");
- buf.append(" yield 6;\n");
- buf.append(" case TUESDAY:\n");
- buf.append(" yield 7;\n");
- buf.append(" case THURSDAY, SATURDAY:\n");
- buf.append(" yield 8;\n");
- buf.append(" case SUNDAY :\n");
- buf.append(" throw new UnsupportedOperationException(\n");
- buf.append(" \"Unimplemented case: \" + day);\n");
- buf.append(" case WEDNESDAY :\n");
- buf.append(" throw new UnsupportedOperationException(\n");
- buf.append(" \"Unimplemented case: \" + day);\n");
- buf.append(" default :\n");
- buf.append(" throw new IllegalArgumentException(\n");
- buf.append(" \"Unexpected value: \" + day);\n");
- buf.append(" };\n");
- buf.append(" }\n");
- buf.append("}\n");
- buf.append("enum Day {\n");
- buf.append(" MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n");
- buf.append("}\n");
- String expected= buf.toString();
+ String expected= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public void bar1(Day day) {\n"
+ + " int len = switch (day) {\n"
+ + " case MONDAY, FRIDAY:\n"
+ + " yield 6;\n"
+ + " case TUESDAY:\n"
+ + " yield 7;\n"
+ + " case THURSDAY, SATURDAY:\n"
+ + " yield 8;\n"
+ + " case SUNDAY :\n"
+ + " throw new UnsupportedOperationException(\n"
+ + " \"Unimplemented case: \" + day);\n"
+ + " case WEDNESDAY :\n"
+ + " throw new UnsupportedOperationException(\n"
+ + " \"Unimplemented case: \" + day);\n"
+ + " default :\n"
+ + " throw new IllegalArgumentException(\n"
+ + " \"Unexpected value: \" + day);\n"
+ + " };\n"
+ + " }\n"
+ + "}\n"
+ + "enum Day {\n"
+ + " MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;\n"
+ + "}\n";
assertEqualStringsIgnoreOrder(new String[] { preview }, new String[] { expected });
}
+ @Test
+ public void testReplaceIncorrectReturnInSwitchExpressionWithYieldStatement() throws Exception {
+ fJProject1= JavaProjectHelper.createJavaProject("TestProject1", "bin");
+ fJProject1.setRawClasspath(Java14ProjectTestSetup.getDefaultClasspath(), null);
+ JavaProjectHelper.set14CompilerOptions(fJProject1, false);
+ fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
+
+ IPackageFragment def= fSourceFolder.createPackageFragment("", false, null);
+ def.createCompilationUnit("module-info.java", MODULE_INFO_FILE_CONTENT, false, null);
+
+ IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
+ String test= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public static int process(int i) {\n"
+ + " var t = switch (i) {\n"
+ + " case 0 -> {\n"
+ + " return 99;\n"
+ + " }\n"
+ + " default ->100;\n"
+ + " };\n"
+ + " return t;\n"
+ + " }\n\n"
+ + " public static void main(String[] args) {\n"
+ + " System.out.println(process(1));\n"
+ + " System.out.println(process(0));\n"
+ + " }\n"
+ + "}";
+ ICompilationUnit cu= pack.createCompilationUnit("Cls.java", test, false, null);
+
+ CompilationUnit astRoot= getASTRoot(cu);
+ ArrayList<IJavaCompletionProposal> proposals= collectCorrections(cu, astRoot);
+ assertNumberOfProposals(proposals, 1);
+ assertCorrectLabels(proposals);
+
+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
+ String preview= getPreviewContent(proposal);
+
+ String expected= ""
+ + "package test;\n"
+ + "public class Cls {\n"
+ + " public static int process(int i) {\n"
+ + " var t = switch (i) {\n"
+ + " case 0 -> {\n"
+ + " yield 99;\n"
+ + " }\n"
+ + " default ->100;\n"
+ + " };\n"
+ + " return t;\n"
+ + " }\n\n"
+ + " public static void main(String[] args) {\n"
+ + " System.out.println(process(1));\n"
+ + " System.out.println(process(0));\n"
+ + " }\n"
+ + "}";
+
+ assertEqualStringsIgnoreOrder(new String[] { preview }, new String[] { expected });
+ }
}
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest1d8.java
index 3e504f13e1..b6986b14ea 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest18.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/QuickFixTest1d8.java
@@ -23,6 +23,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.jdt.testplugin.TestOptions;
@@ -45,7 +46,7 @@ import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType;
import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.ui.PreferenceConstants;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
@@ -53,11 +54,13 @@ import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.correction.AssistContext;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@RunWith(JUnit4.class)
-public class QuickFixTest18 extends QuickFixTest {
-
+public class QuickFixTest1d8 extends QuickFixTest {
@Rule
- public ProjectTestSetup projectsetup = new Java18ProjectTestSetup();
+ public ProjectTestSetup projectsetup = new Java1d8ProjectTestSetup();
private IJavaProject fJProject1;
@@ -76,7 +79,7 @@ public class QuickFixTest18 extends QuickFixTest {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);
StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);
@@ -84,10 +87,9 @@ public class QuickFixTest18 extends QuickFixTest {
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
-
@After
public void tearDown() throws Exception {
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
@Test
@@ -202,7 +204,7 @@ public class QuickFixTest18 extends QuickFixTest {
// bug 420116 : test for annotated varargs and return type
@Test
public void testUnimplementedMethods3() throws Exception {
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack2= fSourceFolder.createPackageFragment("test2", false, null);
@@ -289,7 +291,7 @@ public class QuickFixTest18 extends QuickFixTest {
// bug 420116 : test for annotated varargs and return type
@Test
public void testUnimplementedMethods4() throws Exception {
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack2= fSourceFolder.createPackageFragment("test1", false, null);
@@ -1233,7 +1235,7 @@ public class QuickFixTest18 extends QuickFixTest {
options.put(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION, JavaCore.WARNING);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
@@ -1281,7 +1283,7 @@ public class QuickFixTest18 extends QuickFixTest {
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, JavaCore.INSERT);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
@@ -1330,7 +1332,7 @@ public class QuickFixTest18 extends QuickFixTest {
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, JavaCore.INSERT);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
@@ -1380,7 +1382,7 @@ public class QuickFixTest18 extends QuickFixTest {
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, JavaCore.INSERT);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
@@ -1434,7 +1436,7 @@ public class QuickFixTest18 extends QuickFixTest {
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, JavaCore.INSERT);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
@@ -1476,7 +1478,7 @@ public class QuickFixTest18 extends QuickFixTest {
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, JavaCore.INSERT);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
@@ -1524,7 +1526,7 @@ public class QuickFixTest18 extends QuickFixTest {
options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
@@ -1558,7 +1560,7 @@ public class QuickFixTest18 extends QuickFixTest {
Hashtable<String, String> options= JavaCore.getOptions();
options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
@@ -1655,7 +1657,7 @@ public class QuickFixTest18 extends QuickFixTest {
Hashtable<String, String> options= JavaCore.getOptions();
options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
@@ -1865,7 +1867,7 @@ public class QuickFixTest18 extends QuickFixTest {
Hashtable<String, String> options= JavaCore.getOptions();
options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
@@ -2069,7 +2071,7 @@ public class QuickFixTest18 extends QuickFixTest {
// bug 420116 : create parameter quickfix should be offered
@Test
public void testBug496103_createParam() throws Exception {
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack2= fSourceFolder.createPackageFragment("test1", false, null);
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ReorgQuickFixTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ReorgQuickFixTest.java
index 11b4b7c2a3..1fa469f756 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ReorgQuickFixTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ReorgQuickFixTest.java
@@ -14,6 +14,7 @@
package org.eclipse.jdt.ui.tests.quickfix;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -981,7 +982,8 @@ public class ReorgQuickFixTest extends QuickFixTest {
IJavaProject otherProject= JavaProjectHelper.createJavaProject("other", "bin");
try {
File lib= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.MYLIB);
- assertTrue("lib does not exist", lib != null && lib.exists());
+ assertNotNull("lib does not exist", lib);
+ assertTrue("lib does not exist", lib.exists());
IPackageFragmentRoot otherRoot= JavaProjectHelper.addLibraryWithImport(otherProject, Path.fromOSString(lib.getPath()), null, null);
MultiStatus status= new MultiStatus(JavaUI.ID_PLUGIN, IStatus.OK, "", null);
@@ -1018,7 +1020,8 @@ public class ReorgQuickFixTest extends QuickFixTest {
IJavaProject otherProject= JavaProjectHelper.createJavaProject("other", "bin");
try {
File lib= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.MYLIB);
- assertTrue("lib does not exist", lib != null && lib.exists());
+ assertNotNull("lib does not exist", lib);
+ assertTrue("lib does not exist", lib.exists());
IPath path= Path.fromOSString(lib.getPath());
@@ -1053,7 +1056,8 @@ public class ReorgQuickFixTest extends QuickFixTest {
IJavaProject otherProject= JavaProjectHelper.createJavaProject("other", "bin");
try {
File lib= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.MYLIB);
- assertTrue("lib does not exist", lib != null && lib.exists());
+ assertNotNull("lib does not exist", lib);
+ assertTrue("lib does not exist", lib.exists());
IPath path= Path.fromOSString(lib.getPath());
final IClasspathEntry[] entries= { JavaCore.newLibraryEntry(path, null, null) };
final IPath containerPath= new Path(JavaCore.USER_LIBRARY_CONTAINER_ID).append("MyUserLibrary");
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/TypeAnnotationQuickFixTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/TypeAnnotationQuickFixTest.java
index 36ce3f5a99..5c0d1b35a4 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/TypeAnnotationQuickFixTest.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/TypeAnnotationQuickFixTest.java
@@ -42,7 +42,7 @@ import org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType;
import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.ui.PreferenceConstants;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
@@ -53,7 +53,7 @@ import org.eclipse.jdt.internal.ui.JavaPlugin;
public class TypeAnnotationQuickFixTest extends QuickFixTest {
@Rule
- public ProjectTestSetup projectsetup = new Java18ProjectTestSetup();
+ public ProjectTestSetup projectsetup = new Java1d8ProjectTestSetup();
private IJavaProject fJProject1;
@@ -72,7 +72,7 @@ public class TypeAnnotationQuickFixTest extends QuickFixTest {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null);
StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);
@@ -83,7 +83,7 @@ public class TypeAnnotationQuickFixTest extends QuickFixTest {
@After
public void tearDown() throws Exception {
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
public void runQuickFixTest(String testCaseSpecificInput, String... testCaseSpecificOutputs) throws Exception {
@@ -98,7 +98,7 @@ public class TypeAnnotationQuickFixTest extends QuickFixTest {
options.put(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION, JavaCore.WARNING);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
String prefix= "package test;\n" +
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/UnresolvedMethodsQuickFixTest18.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/UnresolvedMethodsQuickFixTest1d8.java
index 35ff5668d7..2b0d3ab7f7 100644
--- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/UnresolvedMethodsQuickFixTest18.java
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/UnresolvedMethodsQuickFixTest1d8.java
@@ -46,7 +46,7 @@ import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.corext.util.Messages;
import org.eclipse.jdt.ui.PreferenceConstants;
-import org.eclipse.jdt.ui.tests.core.rules.Java18ProjectTestSetup;
+import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
import org.eclipse.jdt.ui.tests.core.rules.ProjectTestSetup;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal;
@@ -55,11 +55,14 @@ import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.correction.AssistContext;
import org.eclipse.jdt.internal.ui.text.correction.CorrectionMessages;
+/**
+ * Those tests are made to run on Java Spider 1.8 .
+ */
@RunWith(JUnit4.class)
-public class UnresolvedMethodsQuickFixTest18 extends QuickFixTest {
+public class UnresolvedMethodsQuickFixTest1d8 extends QuickFixTest {
@Rule
- public ProjectTestSetup projectsetup = new Java18ProjectTestSetup();
+ public ProjectTestSetup projectsetup = new Java1d8ProjectTestSetup();
private IJavaProject fJProject1;
@@ -78,7 +81,7 @@ public class UnresolvedMethodsQuickFixTest18 extends QuickFixTest {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
- fJProject1= Java18ProjectTestSetup.getProject();
+ fJProject1= Java1d8ProjectTestSetup.getProject();
StubUtility.setCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, "", null);
StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null);
@@ -89,7 +92,7 @@ public class UnresolvedMethodsQuickFixTest18 extends QuickFixTest {
@After
public void tearDown() throws Exception {
- JavaProjectHelper.clear(fJProject1, Java18ProjectTestSetup.getDefaultClasspath());
+ JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
}
@Test
@@ -410,7 +413,7 @@ public class UnresolvedMethodsQuickFixTest18 extends QuickFixTest {
Hashtable<String, String> options= JavaCore.getOptions();
options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
@@ -512,7 +515,7 @@ public class UnresolvedMethodsQuickFixTest18 extends QuickFixTest {
Hashtable<String, String> options= JavaCore.getOptions();
options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED);
JavaCore.setOptions(options);
- JavaProjectHelper.addLibrary(fJProject1, new Path(Java18ProjectTestSetup.getJdtAnnotations20Path()));
+ JavaProjectHelper.addLibrary(fJProject1, new Path(Java1d8ProjectTestSetup.getJdtAnnotations20Path()));
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
diff --git a/org.eclipse.jdt.ui/.settings/.api_filters b/org.eclipse.jdt.ui/.settings/.api_filters
index 9eeb4b4732..449ebef4db 100644
--- a/org.eclipse.jdt.ui/.settings/.api_filters
+++ b/org.eclipse.jdt.ui/.settings/.api_filters
@@ -155,6 +155,75 @@
</message_arguments>
</filter>
</resource>
+ <resource path="ui/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessor.java" type="org.eclipse.jdt.internal.ui.text.correction.JavadocTagsSubProcessor">
+ <filter comment="For Java 14 Enable Preview feature" id="623939596">
+ <message_arguments>
+ <message_argument value="RecordDeclaration"/>
+ <message_argument value="JavadocTagsSubProcessor"/>
+ <message_argument value="RECORD_COMPONENTS_PROPERTY"/>
+ </message_arguments>
+ </filter>
+ <filter comment="For Java 14 Enable Preview feature" id="623939596">
+ <message_arguments>
+ <message_argument value="RecordDeclaration"/>
+ <message_argument value="JavadocTagsSubProcessor"/>
+ <message_argument value="TYPE_PARAMETERS_PROPERTY"/>
+ </message_arguments>
+ </filter>
+ <filter comment="For Java 14 Enable Preview feature" id="640712815">
+ <message_arguments>
+ <message_argument value="RecordDeclaration"/>
+ <message_argument value="JavadocTagsSubProcessor"/>
+ <message_argument value="recordComponents()"/>
+ </message_arguments>
+ </filter>
+ <filter comment="For Java 14 Enable Preview feature" id="640712815">
+ <message_arguments>
+ <message_argument value="RecordDeclaration"/>
+ <message_argument value="JavadocTagsSubProcessor"/>
+ <message_argument value="typeParameters()"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="ui/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessor.java" type="org.eclipse.jdt.internal.ui.text.correction.JavadocTagsSubProcessor$AddAllMissingJavadocTagsProposal">
+ <filter comment="For Java 14 Enable Preview feature" id="640712815">
+ <message_arguments>
+ <message_argument value="ASTNode"/>
+ <message_argument value="AddAllMissingJavadocTagsProposal"/>
+ <message_argument value="getAST()"/>
+ </message_arguments>
+ </filter>
+ <filter comment="For Java 14 Enable Preview feature" id="640712815">
+ <message_arguments>
+ <message_argument value="BodyDeclaration"/>
+ <message_argument value="AddAllMissingJavadocTagsProposal"/>
+ <message_argument value="getJavadoc()"/>
+ </message_arguments>
+ </filter>
+ <filter comment="For Java 14 Enable Preview feature" id="640712815">
+ <message_arguments>
+ <message_argument value="RecordDeclaration"/>
+ <message_argument value="AddAllMissingJavadocTagsProposal"/>
+ <message_argument value="recordComponents()"/>
+ </message_arguments>
+ </filter>
+ <filter comment="For Java 14 Enable Preview feature" id="640712815">
+ <message_arguments>
+ <message_argument value="RecordDeclaration"/>
+ <message_argument value="AddAllMissingJavadocTagsProposal"/>
+ <message_argument value="typeParameters()"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="ui/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessor.java" type="org.eclipse.jdt.internal.ui.text.correction.JavadocTagsSubProcessor$AddMissingJavadocTagProposal">
+ <filter comment="For Java 14 Enable Preview feature" id="640712815">
+ <message_arguments>
+ <message_argument value="RecordDeclaration"/>
+ <message_argument value="AddMissingJavadocTagProposal"/>
+ <message_argument value="typeParameters()"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java" type="org.eclipse.jdt.internal.ui.text.correction.LocalCorrectionsSubProcessor">
<filter comment="For Java 13 Enable Preview feature" id="623939596">
<message_arguments>
@@ -243,6 +312,22 @@
</message_arguments>
</filter>
</resource>
+ <resource path="ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java" type="org.eclipse.jdt.internal.ui.text.correction.SuppressWarningsSubProcessor">
+ <filter comment="For Java 14 Enable Preview feature" id="623939596">
+ <message_arguments>
+ <message_argument value="RecordDeclaration"/>
+ <message_argument value="SuppressWarningsSubProcessor"/>
+ <message_argument value="MODIFIERS2_PROPERTY"/>
+ </message_arguments>
+ </filter>
+ <filter comment="For Java 14 Enable Preview feature" id="640712815">
+ <message_arguments>
+ <message_argument value="AbstractTypeDeclaration"/>
+ <message_argument value="SuppressWarningsSubProcessor"/>
+ <message_argument value="getName()"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java" type="org.eclipse.jdt.internal.ui.text.correction.UnresolvedElementsSubProcessor">
<filter comment="For Java 13 Enable Preview feature" id="640712815">
<message_arguments>
diff --git a/org.eclipse.jdt.ui/META-INF/MANIFEST.MF b/org.eclipse.jdt.ui/META-INF/MANIFEST.MF
index 7666b21778..fcff0ca8bf 100644
--- a/org.eclipse.jdt.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.ui/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.ui
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.ui; singleton:=true
-Bundle-Version: 3.21.100.qualifier
+Bundle-Version: 3.21.200.qualifier
Bundle-Activator: org.eclipse.jdt.internal.ui.JavaPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/Corext.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/Corext.java
index 561bfcb15f..b9ff4a44b3 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/Corext.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/Corext.java
@@ -23,4 +23,7 @@ public class Corext {
public static String getPluginId() {
return JavaPlugin.getPluginId();
}
+
+ private Corext() {
+ }
}
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/TypeAnnotationRewrite.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/TypeAnnotationRewrite.java
index 40aa05967e..14356afa03 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/TypeAnnotationRewrite.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/TypeAnnotationRewrite.java
@@ -124,4 +124,7 @@ public class TypeAnnotationRewrite {
}
return typeUseSeen && !otherSeen;
}
+
+ private TypeAnnotationRewrite() {
+ }
}
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstantsOptions.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstantsOptions.java
index be788d2416..d4f3436a09 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstantsOptions.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpConstantsOptions.java
@@ -50,6 +50,7 @@ public class CleanUpConstantsOptions extends CleanUpConstants {
options.setOption(CONTROL_STATMENTS_USE_BLOCKS_NEVER, CleanUpOptions.FALSE);
options.setOption(CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED, CleanUpOptions.FALSE);
+ options.setOption(CONTROL_STATMENTS_CONVERT_FOR_LOOP_ONLY_IF_LOOP_VAR_USED, CleanUpOptions.FALSE);
//Expressions
options.setOption(EXPRESSIONS_USE_PARENTHESES, CleanUpOptions.FALSE);
@@ -89,6 +90,7 @@ public class CleanUpConstantsOptions extends CleanUpConstants {
options.setOption(USE_AUTOBOXING, CleanUpOptions.FALSE);
options.setOption(USE_UNBOXING, CleanUpOptions.FALSE);
options.setOption(PUSH_DOWN_NEGATION, CleanUpOptions.FALSE);
+ options.setOption(MERGE_CONDITIONAL_BLOCKS, CleanUpOptions.FALSE);
options.setOption(USE_DIRECTLY_MAP_METHOD, CleanUpOptions.FALSE);
options.setOption(REMOVE_REDUNDANT_MODIFIERS, CleanUpOptions.FALSE);
options.setOption(REMOVE_REDUNDANT_SEMICOLONS, CleanUpOptions.FALSE);
@@ -149,6 +151,7 @@ public class CleanUpConstantsOptions extends CleanUpConstants {
options.setOption(CONTROL_STATMENTS_USE_BLOCKS_NEVER, CleanUpOptions.FALSE);
options.setOption(CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED, CleanUpOptions.FALSE);
+ options.setOption(CONTROL_STATMENTS_CONVERT_FOR_LOOP_ONLY_IF_LOOP_VAR_USED, CleanUpOptions.FALSE);
//Expressions
options.setOption(EXPRESSIONS_USE_PARENTHESES, CleanUpOptions.FALSE);
@@ -188,6 +191,7 @@ public class CleanUpConstantsOptions extends CleanUpConstants {
options.setOption(USE_AUTOBOXING, CleanUpOptions.FALSE);
options.setOption(USE_UNBOXING, CleanUpOptions.FALSE);
options.setOption(PUSH_DOWN_NEGATION, CleanUpOptions.FALSE);
+ options.setOption(MERGE_CONDITIONAL_BLOCKS, CleanUpOptions.FALSE);
options.setOption(USE_DIRECTLY_MAP_METHOD, CleanUpOptions.FALSE);
options.setOption(REMOVE_REDUNDANT_MODIFIERS, CleanUpOptions.FALSE);
options.setOption(REMOVE_REDUNDANT_SEMICOLONS, CleanUpOptions.FALSE);
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpPreferenceUtil.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpPreferenceUtil.java
index f49de9d063..6d4c300782 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpPreferenceUtil.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpPreferenceUtil.java
@@ -209,4 +209,7 @@ public class CleanUpPreferenceUtil {
return result;
}
+ private CleanUpPreferenceUtil() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopFix.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopFix.java
index d741dba049..062fb59963 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopFix.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ConvertLoopFix.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2019 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -31,7 +31,8 @@ import org.eclipse.jdt.ui.cleanup.ICleanUpFix;
public class ConvertLoopFix extends CompilationUnitRewriteOperationsFix {
- public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean convertForLoops, boolean convertIterableForLoops, boolean makeFinal) {
+ public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean convertForLoops, boolean convertIterableForLoops,
+ boolean makeFinal, boolean checkLoopVarUsed) {
if (!JavaModelUtil.is50OrHigher(compilationUnit.getJavaElement().getJavaProject()))
return null;
@@ -39,7 +40,8 @@ public class ConvertLoopFix extends CompilationUnitRewriteOperationsFix {
return null;
List<ConvertLoopOperation> operations= new ArrayList<>();
- ConvertLoopFixCore.ControlStatementFinder finder= new ConvertLoopFixCore.ControlStatementFinder(convertForLoops, convertIterableForLoops, makeFinal, operations);
+ ConvertLoopFixCore.ControlStatementFinder finder= new ConvertLoopFixCore.ControlStatementFinder(convertForLoops, convertIterableForLoops, makeFinal,
+ checkLoopVarUsed, operations);
compilationUnit.accept(finder);
if (operations.isEmpty())
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ExternalNullAnnotationChangeProposals.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ExternalNullAnnotationChangeProposals.java
index ee4afbc2b5..3a6a30bf6f 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ExternalNullAnnotationChangeProposals.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ExternalNullAnnotationChangeProposals.java
@@ -796,8 +796,7 @@ public class ExternalNullAnnotationChangeProposals {
@Override
public boolean visit(ArrayType array) {
- @SuppressWarnings("rawtypes")
- List dimensions= array.dimensions();
+ List<?> dimensions= array.dimensions();
boolean annotated= false;
for (Object dimension2 : dimensions) {
fBuffer.append('[');
@@ -872,4 +871,7 @@ public class ExternalNullAnnotationChangeProposals {
return type.getBinaryName().replace('.', '/');
}
}
+
+ private ExternalNullAnnotationChangeProposals() {
+ }
}
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/Java50Fix.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/Java50Fix.java
index ee3706d6db..8846034c99 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/Java50Fix.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/Java50Fix.java
@@ -372,20 +372,18 @@ public class Java50Fix extends CompilationUnitRewriteOperationsFix {
}
CategorizedProblem categorizedProblem= (CategorizedProblem) problem;
int categoryID= categorizedProblem.getCategoryID();
- if (categoryID == CategorizedProblem.CAT_BUILDPATH)
- return true;
- if (categoryID == CategorizedProblem.CAT_SYNTAX)
- return true;
- if (categoryID == CategorizedProblem.CAT_IMPORT)
- return true;
- if (categoryID == CategorizedProblem.CAT_TYPE)
- return true;
- if (categoryID == CategorizedProblem.CAT_MEMBER)
- return true;
- if (categoryID == CategorizedProblem.CAT_INTERNAL)
- return true;
- if (categoryID == CategorizedProblem.CAT_MODULE)
- return true;
+ switch (categoryID) {
+ case CategorizedProblem.CAT_BUILDPATH:
+ case CategorizedProblem.CAT_SYNTAX:
+ case CategorizedProblem.CAT_IMPORT:
+ case CategorizedProblem.CAT_TYPE:
+ case CategorizedProblem.CAT_MEMBER:
+ case CategorizedProblem.CAT_INTERNAL:
+ case CategorizedProblem.CAT_MODULE:
+ return true;
+ default:
+ break;
+ }
}
}
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/NullAnnotationsRewriteOperations.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/NullAnnotationsRewriteOperations.java
index b2d8eadc73..43e0cbc1ef 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/NullAnnotationsRewriteOperations.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/NullAnnotationsRewriteOperations.java
@@ -841,4 +841,7 @@ public class NullAnnotationsRewriteOperations {
return null;
}
}
+
+ private NullAnnotationsRewriteOperations() {
+ }
}
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/TypeAnnotationRewriteOperations.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/TypeAnnotationRewriteOperations.java
index 40d27aeae8..f31df4cb16 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/TypeAnnotationRewriteOperations.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/TypeAnnotationRewriteOperations.java
@@ -177,4 +177,7 @@ public class TypeAnnotationRewriteOperations {
listRewrite.insertLast(newAnnotation, group);
}
}
+
+ private TypeAnnotationRewriteOperations() {
+ }
}
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/UnnecessaryArrayCreationFix.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/UnnecessaryArrayCreationFix.java
index b654e025f3..0ed2fe23e3 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/UnnecessaryArrayCreationFix.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/UnnecessaryArrayCreationFix.java
@@ -25,17 +25,17 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.Expression;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.MethodInvocation;
+import org.eclipse.jdt.core.dom.NullLiteral;
import org.eclipse.jdt.core.dom.SuperMethodInvocation;
+import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.dom.GenericVisitor;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.ui.cleanup.ICleanUpFix;
public class UnnecessaryArrayCreationFix extends CompilationUnitRewriteOperationsFix {
-
public final static class UnnecessaryArrayCreationFinder extends GenericVisitor {
-
private final List<CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation> fResult;
private final boolean fRemoveUnnecessaryArrayCreation;
@@ -44,40 +44,50 @@ public class UnnecessaryArrayCreationFix extends CompilationUnitRewriteOperation
fResult= resultingCollection;
}
- @SuppressWarnings("rawtypes")
@Override
public boolean visit(ArrayCreation node) {
- if (fRemoveUnnecessaryArrayCreation) {
+ ArrayInitializer initializer= node.getInitializer();
+
+ if (fRemoveUnnecessaryArrayCreation
+ && node.getType().getDimensions() == 1
+ && initializer != null
+ && initializer.expressions() != null) {
+ if (initializer.expressions().size() == 1) {
+ NullLiteral nullLiteral= ASTNodes.as((Expression) initializer.expressions().get(0), NullLiteral.class);
+
+ if (nullLiteral != null) {
+ return true;
+ }
+ }
+
ASTNode parent= node.getParent();
+
if (parent instanceof MethodInvocation) {
- MethodInvocation m= (MethodInvocation)parent;
- List arguments= m.arguments();
- ArrayInitializer initializer= node.getInitializer();
- if (arguments.size() > 0 && arguments.get(arguments.size() - 1) == node
- && node.getType().getDimensions() == 1
- && initializer != null && initializer.expressions() != null) {
- IMethodBinding binding= m.resolveMethodBinding();
- if (binding != null && binding.isVarargs() && binding.getParameterTypes().length == arguments.size()) {
- fResult.add(new UnwrapNewArrayOperation(node, m));
- }
+ MethodInvocation m= (MethodInvocation) parent;
+
+ if (isUselessArrayCreation(node, m.arguments(), m.resolveMethodBinding())) {
+ fResult.add(new UnwrapNewArrayOperation(node, m));
}
} else if (parent instanceof SuperMethodInvocation) {
- SuperMethodInvocation m= (SuperMethodInvocation)parent;
- List arguments= m.arguments();
- ArrayInitializer initializer= node.getInitializer();
- if (arguments.size() > 0 && arguments.get(arguments.size() - 1) == node
- && node.getType().getDimensions() == 1
- && initializer != null && initializer.expressions() != null) {
- IMethodBinding binding= m.resolveMethodBinding();
- if (binding != null && binding.isVarargs() && binding.getParameterTypes().length == arguments.size()) {
- fResult.add(new UnwrapNewArrayOperation(node, m));
- }
+ SuperMethodInvocation m= (SuperMethodInvocation) parent;
+
+ if (isUselessArrayCreation(node, m.arguments(), m.resolveMethodBinding())) {
+ fResult.add(new UnwrapNewArrayOperation(node, m));
}
}
}
+
return true;
}
+ private boolean isUselessArrayCreation(ArrayCreation node, List<?> arguments, IMethodBinding binding) {
+ return arguments.size() > 0
+ && arguments.get(arguments.size() - 1) == node
+ && binding != null
+ && binding.isVarargs()
+ && binding.getParameterTypes().length == arguments.size();
+ }
+
}
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean removeUnnecessaryArrayCreation) {
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/UnusedCodeFix.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/UnusedCodeFix.java
index 94791b69ad..dcf38dbc53 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/UnusedCodeFix.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/UnusedCodeFix.java
@@ -25,10 +25,10 @@ import org.eclipse.jdt.core.dom.CastExpression;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.ImportDeclaration;
-import org.eclipse.jdt.core.dom.ParenthesizedExpression;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.manipulation.ICleanUpFixCore;
+import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.fix.UnusedCodeFixCore.RemoveCastOperation;
import org.eclipse.jdt.internal.corext.fix.UnusedCodeFixCore.RemoveUnusedMemberOperation;
@@ -113,18 +113,13 @@ public class UnusedCodeFix extends CompilationUnitRewriteOperationsFix {
if (problem.getProblemId() != IProblem.UnnecessaryCast)
return null;
- ASTNode selectedNode= problem.getCoveringNode(compilationUnit);
+ ASTNode selectedNode= ASTNodes.getUnparenthesedExpression(problem.getCoveringNode(compilationUnit));
- ASTNode curr= selectedNode;
- while (curr instanceof ParenthesizedExpression) {
- curr= ((ParenthesizedExpression) curr).getExpression();
- }
-
- if (!(curr instanceof CastExpression))
+ if (!(selectedNode instanceof CastExpression))
return null;
return new UnusedCodeFix(FixMessages.UnusedCodeFix_RemoveCast_description, compilationUnit,
- new CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation[] {new RemoveCastOperation((CastExpression)curr)});
+ new CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation[] {new RemoveCastOperation((CastExpression)selectedNode)});
}
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit,
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/javadoc/JavaDocLocations.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/javadoc/JavaDocLocations.java
index 45a0d2cb67..95b2c1c1a8 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/javadoc/JavaDocLocations.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/javadoc/JavaDocLocations.java
@@ -77,9 +77,6 @@ public class JavaDocLocations {
private static IClasspathEntry getConvertedEntry(IClasspathEntry entry, IJavaProject project, Map<IPath, String> oldLocationMap) {
IPath path= null;
switch (entry.getEntryKind()) {
- case IClasspathEntry.CPE_SOURCE:
- case IClasspathEntry.CPE_PROJECT:
- return null;
case IClasspathEntry.CPE_CONTAINER:
convertContainer(entry, project, oldLocationMap);
return null;
@@ -89,6 +86,8 @@ public class JavaDocLocations {
case IClasspathEntry.CPE_VARIABLE:
path= JavaCore.getResolvedVariablePath(entry.getPath());
break;
+ case IClasspathEntry.CPE_SOURCE:
+ case IClasspathEntry.CPE_PROJECT:
default:
return null;
}
@@ -597,4 +596,7 @@ public class JavaDocLocations {
return new File(url.getFile());
}
}
+
+ private JavaDocLocations() {
+ }
}
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/ActualTypeResolver.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/ActualTypeResolver.java
index dfc5e8292a..d9efb23947 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/ActualTypeResolver.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/ActualTypeResolver.java
@@ -15,11 +15,11 @@ package org.eclipse.jdt.internal.corext.template.java;
import java.util.List;
-import org.eclipse.jdt.internal.corext.template.java.TypeResolver;
-import org.eclipse.jdt.internal.ui.text.template.contentassist.MultiVariable;
import org.eclipse.jface.text.templates.TemplateContext;
import org.eclipse.jface.text.templates.TemplateVariable;
+import org.eclipse.jdt.internal.ui.text.template.contentassist.MultiVariable;
+
/**
* This class is responsible for resolving a given type or the type of another variable to its
* actual type.
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaDocContext.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaDocContext.java
index 4f9d8cabea..ecd0d9b23e 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaDocContext.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaDocContext.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -29,8 +29,8 @@ import org.eclipse.jface.text.templates.TemplateTranslator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.core.manipulation.JavaManipulationPlugin;
import org.eclipse.jdt.internal.core.manipulation.util.Strings;
import org.eclipse.jdt.ui.PreferenceConstants;
@@ -88,7 +88,7 @@ public class JavaDocContext extends CompilationUnitContext {
String key= getKey().toLowerCase();
if (template.matches(key, getContextType().getId()) && key.length() != 0) {
String templateName= template.getName().toLowerCase();
- return JavaCore.ENABLED.equals(JavaCore.getOption(JavaCore.CODEASSIST_SUBSTRING_MATCH))
+ return JavaManipulationPlugin.CODEASSIST_SUBSTRING_MATCH_ENABLED
? templateName.contains(key)
: templateName.startsWith(key);
}
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaPostfixContext.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaPostfixContext.java
index b9248f0684..185cf9cebe 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaPostfixContext.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaPostfixContext.java
@@ -26,6 +26,19 @@ import java.util.regex.Pattern;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.text.edits.MalformedTreeException;
+import org.eclipse.text.edits.TextEdit;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateBuffer;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateVariable;
+
import org.eclipse.jdt.core.CompletionContext;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
@@ -35,6 +48,7 @@ import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.ArrayAccess;
import org.eclipse.jdt.core.dom.Assignment;
import org.eclipse.jdt.core.dom.BodyDeclaration;
import org.eclipse.jdt.core.dom.BooleanLiteral;
@@ -64,32 +78,16 @@ import org.eclipse.jdt.core.dom.WildcardType;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.internal.core.manipulation.StubUtility;
+import org.eclipse.jdt.internal.core.manipulation.dom.ASTResolving;
import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory;
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
-import org.eclipse.jdt.internal.corext.template.java.JavaContext;
-
-import org.eclipse.jdt.internal.core.manipulation.dom.ASTResolving;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.TemplateBuffer;
-import org.eclipse.jface.text.templates.TemplateContextType;
-import org.eclipse.jface.text.templates.TemplateException;
-import org.eclipse.jface.text.templates.TemplateVariable;
-
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.TextEdit;
/**
* This class is an extension to the existing {@link JavaContext} and includes/provides additional
* information on the current node which the code completion was invoked on.
*/
public class JavaPostfixContext extends JavaContext {
-
private static final Object CONTEXT_TYPE_ID= "postfix"; //$NON-NLS-1$
private static final String OBJECT_SIGNATURE= "java.lang.Object"; //$NON-NLS-1$
@@ -419,11 +417,8 @@ public class JavaPostfixContext extends JavaContext {
int[] outOfRangeOffsets= variableOutOfRangeOffsets.get(tv);
if (outOfRangeOffsets != null && outOfRangeOffsets.length > 0) {
int[] offsets= tv.getOffsets();
- int[] newOffsets= new int[outOfRangeOffsets.length + offsets.length];
- System.arraycopy(offsets, 0, newOffsets, 0, offsets.length);
- for (int i= 0; i < outOfRangeOffsets.length; i++) {
- newOffsets[i + offsets.length]= outOfRangeOffsets[i];
- }
+ int[] newOffsets= Arrays.copyOf(offsets, offsets.length + outOfRangeOffsets.length);
+ System.arraycopy(outOfRangeOffsets, 0, newOffsets, offsets.length, outOfRangeOffsets.length);
tv.setOffsets(newOffsets);
}
}
@@ -684,6 +679,12 @@ public class JavaPostfixContext extends JavaContext {
res[0]= n.resolveTypeBinding();
return false;
}
+
+ @Override
+ public boolean visit(ArrayAccess n) {
+ res[0]= n.resolveTypeBinding();
+ return false;
+ }
});
return res[0] != null ? res[0] : null;
@@ -770,4 +771,17 @@ public class JavaPostfixContext extends JavaContext {
// If the dom is not initialized yet (template preview) we return a dummy name
return new String[] { "newField" }; //$NON-NLS-1$
}
+
+ @Override
+ public String[] suggestVariableNames(String type) throws IllegalArgumentException {
+ List<String> res= new ArrayList<>();
+ if (selectedNode instanceof Expression) {
+ ITypeBinding tb= resolveNodeToBinding(selectedNode);
+ List<String> excludes= Arrays.asList(computeExcludes());
+ String[] names= StubUtility.getVariableNameSuggestions(NamingConventions.VK_LOCAL, getJavaProject(), tb, (Expression)selectedNode, excludes);
+ res.addAll(Arrays.asList(names));
+ }
+ res.addAll(Arrays.asList(super.suggestVariableNames(type)));
+ return res.toArray(new String [0]);
+ }
}
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/CollectionsUtil.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/CollectionsUtil.java
index 35757155a6..211aa5ee8d 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/CollectionsUtil.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/CollectionsUtil.java
@@ -37,4 +37,7 @@ public class CollectionsUtil {
A[] typedArray= collection.toArray((A[]) array);
return typedArray;
}
+
+ private CollectionsUtil() {
+ }
}
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/IOCloser.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/IOCloser.java
index d34cd7245c..917cf9f152 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/IOCloser.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/IOCloser.java
@@ -38,5 +38,8 @@ public class IOCloser {
return;
}
}
+
+ private IOCloser() {
+ }
}
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/InfoFilesUtil.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/InfoFilesUtil.java
index 154d78ce3f..3173ffb1d8 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/InfoFilesUtil.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/InfoFilesUtil.java
@@ -117,4 +117,7 @@ public class InfoFilesUtil {
return CodeGeneration.getModuleComment(cu, moduleName, new String[0], new String[0], lineDelimiterUsed);
}
+ private InfoFilesUtil() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringAvailabilityTester.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringAvailabilityTester.java
index f166c02ff9..d6a9321a3c 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringAvailabilityTester.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringAvailabilityTester.java
@@ -295,22 +295,27 @@ public final class RefactoringAvailabilityTester {
IJavaElement javaElement= (IJavaElement)element;
if (javaElement.exists() && !javaElement.isReadOnly()) {
int elementType= javaElement.getElementType();
- if (elementType == IJavaElement.PACKAGE_FRAGMENT) {
- return true;
- } else if (elementType == IJavaElement.PACKAGE_FRAGMENT_ROOT) {
- IPackageFragmentRoot root= (IPackageFragmentRoot)javaElement;
- if (!root.isExternal() && !ReorgUtils.isClassFolder(root))
- return true;
- } else if (elementType == IJavaElement.JAVA_PROJECT) {
- return true;
- } else if (elementType == IJavaElement.COMPILATION_UNIT) {
- ICompilationUnit cu= (ICompilationUnit)javaElement;
- if (cu.exists())
- return true;
- } else if (elementType == IJavaElement.TYPE) {
- IJavaElement parent= ((IType) element).getParent();
- if (parent instanceof ICompilationUnit && parent.exists())
+ switch (elementType) {
+ case IJavaElement.PACKAGE_FRAGMENT:
+ case IJavaElement.JAVA_PROJECT:
return true;
+ case IJavaElement.PACKAGE_FRAGMENT_ROOT:
+ IPackageFragmentRoot root= (IPackageFragmentRoot)javaElement;
+ if (!root.isExternal() && !ReorgUtils.isClassFolder(root))
+ return true;
+ break;
+ case IJavaElement.COMPILATION_UNIT:
+ ICompilationUnit cu= (ICompilationUnit)javaElement;
+ if (cu.exists())
+ return true;
+ break;
+ case IJavaElement.TYPE:
+ IJavaElement parent= ((IType) element).getParent();
+ if (parent instanceof ICompilationUnit && parent.exists())
+ return true;
+ break;
+ default:
+ break;
}
}
} else if (element instanceof IWorkingSet) {
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/TypeContextChecker.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/TypeContextChecker.java
index a505e01216..624b9ca8ca 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/TypeContextChecker.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/TypeContextChecker.java
@@ -834,4 +834,7 @@ public class TypeContextChecker {
}
return result;
}
+
+ private TypeContextChecker() {
+ }
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractConstantRefactoring.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractConstantRefactoring.java
index c255ebc8ef..7f8e982cef 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractConstantRefactoring.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractConstantRefactoring.java
@@ -585,9 +585,9 @@ public class ExtractConstantRefactoring extends Refactoring {
comment.addSetting(RefactoringCoreMessages.ExtractConstantRefactoring_qualify_references);
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fCu));
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fConstantName);
- arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.valueOf(fSelectionStart).toString() + " " + Integer.valueOf(fSelectionLength).toString()); //$NON-NLS-1$
- arguments.put(ATTRIBUTE_REPLACE, Boolean.valueOf(fReplaceAllOccurrences).toString());
- arguments.put(ATTRIBUTE_QUALIFY, Boolean.valueOf(fQualifyReferencesWithDeclaringClassName).toString());
+ arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.toString(fSelectionStart) + " " + Integer.toString(fSelectionLength)); //$NON-NLS-1$
+ arguments.put(ATTRIBUTE_REPLACE, Boolean.toString(fReplaceAllOccurrences));
+ arguments.put(ATTRIBUTE_QUALIFY, Boolean.toString(fQualifyReferencesWithDeclaringClassName));
arguments.put(ATTRIBUTE_VISIBILITY, Integer.valueOf(JdtFlags.getVisibilityCode(fVisibility)).toString());
ExtractConstantDescriptor descriptor= RefactoringSignatureDescriptorFactory.createExtractConstantDescriptor(project, description, comment.asString(), arguments, flags);
@@ -850,9 +850,9 @@ public class ExtractConstantRefactoring extends Refactoring {
int length= -1;
final StringTokenizer tokenizer= new StringTokenizer(selection);
if (tokenizer.hasMoreTokens())
- offset= Integer.valueOf(tokenizer.nextToken()).intValue();
+ offset= Integer.parseInt(tokenizer.nextToken());
if (tokenizer.hasMoreTokens())
- length= Integer.valueOf(tokenizer.nextToken()).intValue();
+ length= Integer.parseInt(tokenizer.nextToken());
if (offset >= 0 && length >= 0) {
fSelectionStart= offset;
fSelectionLength= length;
@@ -886,12 +886,12 @@ public class ExtractConstantRefactoring extends Refactoring {
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME));
final String replace= arguments.getAttribute(ATTRIBUTE_REPLACE);
if (replace != null) {
- fReplaceAllOccurrences= Boolean.valueOf(replace).booleanValue();
+ fReplaceAllOccurrences= Boolean.parseBoolean(replace);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_REPLACE));
final String declareFinal= arguments.getAttribute(ATTRIBUTE_QUALIFY);
if (declareFinal != null) {
- fQualifyReferencesWithDeclaringClassName= Boolean.valueOf(declareFinal).booleanValue();
+ fQualifyReferencesWithDeclaringClassName= Boolean.parseBoolean(declareFinal);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_QUALIFY));
return new RefactoringStatus();
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodAnalyzer.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodAnalyzer.java
index f2b26226c1..132519e456 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodAnalyzer.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodAnalyzer.java
@@ -637,7 +637,7 @@ import org.eclipse.jdt.internal.ui.viewsupport.BindingLabelProvider;
affectedLocals.append('\n');
}
}
- String message= MessageFormat.format(RefactoringCoreMessages.ExtractMethodAnalyzer_assignments_to_local, new Object[] { affectedLocals.toString() });
+ String message= MessageFormat.format(RefactoringCoreMessages.ExtractMethodAnalyzer_assignments_to_local, affectedLocals.toString());
status.addFatalError(message, JavaStatusContext.create(fCUnit, getSelection()));
return;
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java
index 7ee2dbcbce..d63540b3e8 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java
@@ -675,12 +675,12 @@ public class ExtractMethodRefactoring extends Refactoring {
final ExtractMethodDescriptor descriptor= RefactoringSignatureDescriptorFactory.createExtractMethodDescriptor(project, description, comment.asString(), arguments, flags);
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fCUnit));
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fMethodName);
- arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.valueOf(fSelectionStart).toString() + " " + Integer.valueOf(fSelectionLength).toString()); //$NON-NLS-1$
- arguments.put(ATTRIBUTE_VISIBILITY, Integer.valueOf(fVisibility).toString());
- arguments.put(ATTRIBUTE_DESTINATION, Integer.valueOf(fDestinationIndex).toString());
- arguments.put(ATTRIBUTE_EXCEPTIONS, Boolean.valueOf(fThrowRuntimeExceptions).toString());
- arguments.put(ATTRIBUTE_COMMENTS, Boolean.valueOf(fGenerateJavadoc).toString());
- arguments.put(ATTRIBUTE_REPLACE, Boolean.valueOf(fReplaceDuplicates).toString());
+ arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.toString(fSelectionStart) + " " + Integer.toString(fSelectionLength)); //$NON-NLS-1$
+ arguments.put(ATTRIBUTE_VISIBILITY, Integer.toString(fVisibility));
+ arguments.put(ATTRIBUTE_DESTINATION, Integer.toString(fDestinationIndex));
+ arguments.put(ATTRIBUTE_EXCEPTIONS, Boolean.toString(fThrowRuntimeExceptions));
+ arguments.put(ATTRIBUTE_COMMENTS, Boolean.toString(fGenerateJavadoc));
+ arguments.put(ATTRIBUTE_REPLACE, Boolean.toString(fReplaceDuplicates));
return descriptor;
}
@@ -1043,9 +1043,8 @@ public class ExtractMethodRefactoring extends Refactoring {
ASTNode[] callNodes= createCallNodes(duplicate, modifiers);
ASTNode[] duplicateNodes= duplicate.getNodes();
for (int i= 0; i < duplicateNodes.length; i++) {
- ASTNode parent= duplicateNodes[i].getParent();
- if (parent instanceof ParenthesizedExpression) {
- duplicateNodes[i]= parent;
+ while (duplicateNodes[i].getParent() instanceof ParenthesizedExpression) {
+ duplicateNodes[i]= duplicateNodes[i].getParent();
}
}
new StatementRewrite(fRewriter, duplicateNodes).replace(callNodes, description);
@@ -1228,15 +1227,17 @@ public class ExtractMethodRefactoring extends Refactoring {
ITypeBinding binding= fAnalyzer.getExpressionBinding();
if (binding != null && (!binding.isPrimitive() || !"void".equals(binding.getName()))) { //$NON-NLS-1$
ReturnStatement rs= fAST.newReturnStatement();
- rs.setExpression((Expression)fRewriter.createMoveTarget(selectedNodes[0] instanceof ParenthesizedExpression
- ? ((ParenthesizedExpression)selectedNodes[0]).getExpression()
- : selectedNodes[0]));
+ rs.setExpression((Expression)fRewriter.createMoveTarget(ASTNodes.getUnparenthesedExpression(selectedNodes[0])));
statements.insertLast(rs, null);
} else {
ExpressionStatement st= fAST.newExpressionStatement((Expression)fRewriter.createMoveTarget(selectedNodes[0]));
statements.insertLast(st, null);
}
- fRewriter.replace(selectedNodes[0].getParent() instanceof ParenthesizedExpression ? selectedNodes[0].getParent() : selectedNodes[0], replacementNode, substitute);
+ ASTNode parenthesizedNode= selectedNodes[0];
+ while (parenthesizedNode.getParent() instanceof ParenthesizedExpression) {
+ parenthesizedNode= parenthesizedNode.getParent();
+ }
+ fRewriter.replace(parenthesizedNode, replacementNode, substitute);
} else {
boolean isReturnVoid= selectedNodes[selectedNodes.length - 1] instanceof ReturnStatement &&
fAnalyzer.getReturnTypeBinding().equals(fAST.resolveWellKnownType("void")); //$NON-NLS-1$
@@ -1306,9 +1307,9 @@ public class ExtractMethodRefactoring extends Refactoring {
int length= -1;
final StringTokenizer tokenizer= new StringTokenizer(selection);
if (tokenizer.hasMoreTokens())
- offset= Integer.valueOf(tokenizer.nextToken()).intValue();
+ offset= Integer.parseInt(tokenizer.nextToken());
if (tokenizer.hasMoreTokens())
- length= Integer.valueOf(tokenizer.nextToken()).intValue();
+ length= Integer.parseInt(tokenizer.nextToken());
if (offset < 0 || length < 0)
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_illegal_argument, new Object[] { selection, JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION}));
@@ -1354,19 +1355,19 @@ public class ExtractMethodRefactoring extends Refactoring {
if (replace == null)
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_REPLACE));
- fReplaceDuplicates= Boolean.valueOf(replace).booleanValue();
+ fReplaceDuplicates= Boolean.parseBoolean(replace);
final String comments= arguments.getAttribute(ATTRIBUTE_COMMENTS);
if (comments == null)
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_COMMENTS));
- fGenerateJavadoc= Boolean.valueOf(comments).booleanValue();
+ fGenerateJavadoc= Boolean.parseBoolean(comments);
final String exceptions= arguments.getAttribute(ATTRIBUTE_EXCEPTIONS);
if (exceptions == null)
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_EXCEPTIONS));
- fThrowRuntimeExceptions= Boolean.valueOf(exceptions).booleanValue();
+ fThrowRuntimeExceptions= Boolean.parseBoolean(exceptions);
return new RefactoringStatus();
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java
index adac190d97..6897099ca4 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java
@@ -549,10 +549,10 @@ public class ExtractTempRefactoring extends Refactoring {
final ExtractLocalDescriptor descriptor= RefactoringSignatureDescriptorFactory.createExtractLocalDescriptor(project, description, comment.asString(), arguments, RefactoringDescriptor.NONE);
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fCu));
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fTempName);
- arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.valueOf(fSelectionStart).toString() + " " + Integer.valueOf(fSelectionLength).toString()); //$NON-NLS-1$
- arguments.put(ATTRIBUTE_REPLACE, Boolean.valueOf(fReplaceAllOccurrences).toString());
- arguments.put(ATTRIBUTE_FINAL, Boolean.valueOf(fDeclareFinal).toString());
- arguments.put(ATTRIBUTE_TYPE_VAR, Boolean.valueOf(fDeclareVarType).toString());
+ arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.toString(fSelectionStart) + " " + Integer.toString(fSelectionLength)); //$NON-NLS-1$
+ arguments.put(ATTRIBUTE_REPLACE, Boolean.toString(fReplaceAllOccurrences));
+ arguments.put(ATTRIBUTE_FINAL, Boolean.toString(fDeclareFinal));
+ arguments.put(ATTRIBUTE_TYPE_VAR, Boolean.toString(fDeclareVarType));
return descriptor;
}
@@ -1066,9 +1066,9 @@ public class ExtractTempRefactoring extends Refactoring {
int length= -1;
final StringTokenizer tokenizer= new StringTokenizer(selection);
if (tokenizer.hasMoreTokens())
- offset= Integer.valueOf(tokenizer.nextToken()).intValue();
+ offset= Integer.parseInt(tokenizer.nextToken());
if (tokenizer.hasMoreTokens())
- length= Integer.valueOf(tokenizer.nextToken()).intValue();
+ length= Integer.parseInt(tokenizer.nextToken());
if (offset >= 0 && length >= 0) {
fSelectionStart= offset;
fSelectionLength= length;
@@ -1092,17 +1092,17 @@ public class ExtractTempRefactoring extends Refactoring {
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME));
final String replace= arguments.getAttribute(ATTRIBUTE_REPLACE);
if (replace != null) {
- fReplaceAllOccurrences= Boolean.valueOf(replace).booleanValue();
+ fReplaceAllOccurrences= Boolean.parseBoolean(replace);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_REPLACE));
final String declareFinal= arguments.getAttribute(ATTRIBUTE_FINAL);
if (declareFinal != null) {
- fDeclareFinal= Boolean.valueOf(declareFinal).booleanValue();
+ fDeclareFinal= Boolean.parseBoolean(declareFinal);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_FINAL));
final String declareVarType= arguments.getAttribute(ATTRIBUTE_TYPE_VAR);
if (declareVarType != null) {
- fDeclareVarType= Boolean.valueOf(declareVarType).booleanValue();
+ fDeclareVarType= Boolean.parseBoolean(declareVarType);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_TYPE_VAR));
return new RefactoringStatus();
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceFactoryRefactoring.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceFactoryRefactoring.java
index 29d196683f..81e0cfdad9 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceFactoryRefactoring.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceFactoryRefactoring.java
@@ -1162,8 +1162,8 @@ public class IntroduceFactoryRefactoring extends Refactoring {
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fCUHandle));
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fNewMethodName);
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + 1, JavaRefactoringDescriptorUtil.elementToHandle(project, binding.getJavaElement()));
- arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.valueOf(fSelectionStart).toString() + " " + Integer.valueOf(fSelectionLength).toString()); //$NON-NLS-1$
- arguments.put(ATTRIBUTE_PROTECT, Boolean.valueOf(fProtectConstructor).toString());
+ arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.toString(fSelectionStart) + " " + Integer.toString(fSelectionLength)); //$NON-NLS-1$
+ arguments.put(ATTRIBUTE_PROTECT, Boolean.toString(fProtectConstructor));
final DynamicValidationStateChange result= new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.IntroduceFactory_name);
boolean hitInFactoryClass= false;
boolean hitInCtorClass= false;
@@ -1353,9 +1353,9 @@ public class IntroduceFactoryRefactoring extends Refactoring {
int length= -1;
final StringTokenizer tokenizer= new StringTokenizer(selection);
if (tokenizer.hasMoreTokens())
- offset= Integer.valueOf(tokenizer.nextToken()).intValue();
+ offset= Integer.parseInt(tokenizer.nextToken());
if (tokenizer.hasMoreTokens())
- length= Integer.valueOf(tokenizer.nextToken()).intValue();
+ length= Integer.parseInt(tokenizer.nextToken());
if (offset >= 0 && length >= 0) {
fSelectionStart= offset;
fSelectionLength= length;
@@ -1392,7 +1392,7 @@ public class IntroduceFactoryRefactoring extends Refactoring {
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME));
final String protect= arguments.getAttribute(ATTRIBUTE_PROTECT);
if (protect != null) {
- fProtectConstructor= Boolean.valueOf(protect).booleanValue();
+ fProtectConstructor= Boolean.parseBoolean(protect);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_PROTECT));
return new RefactoringStatus();
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceIndirectionRefactoring.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceIndirectionRefactoring.java
index c715f198b3..7340238726 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceIndirectionRefactoring.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceIndirectionRefactoring.java
@@ -764,7 +764,7 @@ public class IntroduceIndirectionRefactoring extends Refactoring {
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fTargetMethod));
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fIntermediaryMethodName);
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + 1, JavaRefactoringDescriptorUtil.elementToHandle(project, fIntermediaryType));
- arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES, Boolean.valueOf(fUpdateReferences).toString());
+ arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES, Boolean.toString(fUpdateReferences));
return new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.IntroduceIndirectionRefactoring_introduce_indirection, fTextChangeManager.getAllChanges());
}
@@ -1392,7 +1392,7 @@ public class IntroduceIndirectionRefactoring extends Refactoring {
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + 1));
final String references= arguments.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES);
if (references != null) {
- fUpdateReferences= Boolean.valueOf(references).booleanValue();
+ fUpdateReferences= Boolean.parseBoolean(references);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES));
final String name= arguments.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME);
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceParameterRefactoring.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceParameterRefactoring.java
index 3c6e5c8f7b..3d95b5380a 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceParameterRefactoring.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceParameterRefactoring.java
@@ -70,6 +70,7 @@ import org.eclipse.jdt.core.refactoring.IJavaRefactorings;
import org.eclipse.jdt.core.refactoring.descriptors.ChangeMethodSignatureDescriptor;
import org.eclipse.jdt.core.refactoring.descriptors.IntroduceParameterDescriptor;
+import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
import org.eclipse.jdt.internal.core.refactoring.descriptors.RefactoringSignatureDescriptorFactory;
import org.eclipse.jdt.internal.corext.Corext;
@@ -101,8 +102,6 @@ import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.actions.SelectionConverter;
import org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileManager;
-import org.eclipse.jdt.internal.core.manipulation.StubUtility;
-
public class IntroduceParameterRefactoring extends Refactoring implements IDelegateUpdating {
@@ -275,7 +274,7 @@ public class IntroduceParameterRefactoring extends Refactoring implements IDeleg
private void addParameterInfo(CompilationUnitRewrite cuRewrite) throws JavaModelException {
ITypeBinding typeBinding= Bindings.normalizeForDeclarationUse(fSelectedExpression.resolveTypeBinding(), fSelectedExpression.getAST());
String name= fParameterName != null ? fParameterName : guessedParameterName();
- Expression expression= fSelectedExpression instanceof ParenthesizedExpression ? ((ParenthesizedExpression)fSelectedExpression).getExpression() : fSelectedExpression;
+ Expression expression= ASTNodes.getUnparenthesedExpression(fSelectedExpression);
ImportRewrite importRewrite= cuRewrite.getImportRewrite();
ImportRewriteContext importRewriteContext= new ContextSensitiveImportRewriteContext(fSelectedExpression, importRewrite);
@@ -570,7 +569,7 @@ public class IntroduceParameterRefactoring extends Refactoring implements IDeleg
final Map<String, String> arguments= new HashMap<>();
arguments.put(ATTRIBUTE_ARGUMENT, fParameter.getNewName());
- arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.valueOf(fSelectionStart).toString() + " " + Integer.valueOf(fSelectionLength).toString()); //$NON-NLS-1$
+ arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.toString(fSelectionStart) + " " + Integer.toString(fSelectionLength)); //$NON-NLS-1$
arguments.putAll(argumentsMap);
String signature= fChangeSignatureProcessor.getMethodName();
try {
@@ -596,9 +595,9 @@ public class IntroduceParameterRefactoring extends Refactoring implements IDeleg
int length= -1;
final StringTokenizer tokenizer= new StringTokenizer(selection);
if (tokenizer.hasMoreTokens())
- offset= Integer.valueOf(tokenizer.nextToken()).intValue();
+ offset= Integer.parseInt(tokenizer.nextToken());
if (tokenizer.hasMoreTokens())
- length= Integer.valueOf(tokenizer.nextToken()).intValue();
+ length= Integer.parseInt(tokenizer.nextToken());
if (offset >= 0 && length >= 0) {
fSelectionStart= offset;
fSelectionLength= length;
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ReplaceInvocationsRefactoring.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ReplaceInvocationsRefactoring.java
index 7e2ec8b825..480ede458e 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ReplaceInvocationsRefactoring.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ReplaceInvocationsRefactoring.java
@@ -453,8 +453,8 @@ public class ReplaceInvocationsRefactoring extends Refactoring {
comment.addSetting(RefactoringCoreMessages.ReplaceInvocationsRefactoring_replace_references);
final JavaRefactoringDescriptor descriptor= new JavaRefactoringDescriptor(ID_REPLACE_INVOCATIONS, project, description, comment.asString(), arguments, flags){}; //REVIEW Unregistered ID!
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fSelectionTypeRoot));
- arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.valueOf(fSelectionStart).toString() + " " + Integer.valueOf(fSelectionLength).toString()); //$NON-NLS-1$
- arguments.put(ATTRIBUTE_MODE, Integer.valueOf(fTargetProvider.isSingle() ? 0 : 1).toString());
+ arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.toString(fSelectionStart) + " " + Integer.toString(fSelectionLength)); //$NON-NLS-1$
+ arguments.put(ATTRIBUTE_MODE, Integer.toString(fTargetProvider.isSingle() ? 0 : 1));
return new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.ReplaceInvocationsRefactoring_change_name, fChangeManager.getAllChanges());
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/generics/InferTypeArgumentsRefactoring.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/generics/InferTypeArgumentsRefactoring.java
index dbf65796e8..96370910ed 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/generics/InferTypeArgumentsRefactoring.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/generics/InferTypeArgumentsRefactoring.java
@@ -553,8 +553,8 @@ public class InferTypeArgumentsRefactoring extends Refactoring {
final InferTypeArgumentsDescriptor descriptor= RefactoringSignatureDescriptorFactory.createInferTypeArgumentsDescriptor(name, description, comment.asString(), arguments, RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE);
for (int index= 0; index < fElements.length; index++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (index + 1), JavaRefactoringDescriptorUtil.elementToHandle(name, fElements[index]));
- arguments.put(ATTRIBUTE_CLONE, Boolean.valueOf(fAssumeCloneReturnsSameType).toString());
- arguments.put(ATTRIBUTE_LEAVE, Boolean.valueOf(fLeaveUnconstrainedRaw).toString());
+ arguments.put(ATTRIBUTE_CLONE, Boolean.toString(fAssumeCloneReturnsSameType));
+ arguments.put(ATTRIBUTE_LEAVE, Boolean.toString(fLeaveUnconstrainedRaw));
return new RefactoringChangeDescriptor(descriptor);
}
};
@@ -581,12 +581,12 @@ public class InferTypeArgumentsRefactoring extends Refactoring {
private RefactoringStatus initialize(JavaRefactoringArguments arguments) {
final String clone= arguments.getAttribute(ATTRIBUTE_CLONE);
if (clone != null) {
- fAssumeCloneReturnsSameType= Boolean.valueOf(clone).booleanValue();
+ fAssumeCloneReturnsSameType= Boolean.parseBoolean(clone);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_CLONE));
final String leave= arguments.getAttribute(ATTRIBUTE_LEAVE);
if (leave != null) {
- fLeaveUnconstrainedRaw= Boolean.valueOf(leave).booleanValue();
+ fLeaveUnconstrainedRaw= Boolean.parseBoolean(leave);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_LEAVE));
int count= 1;
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSPropertyFileModifier.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSPropertyFileModifier.java
index 77724dd811..f7ba5cf972 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSPropertyFileModifier.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSPropertyFileModifier.java
@@ -252,4 +252,7 @@ public class NLSPropertyFileModifier {
}
}
+ private NLSPropertyFileModifier() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/participants/RefactoringProcessors.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/participants/RefactoringProcessors.java
index a72eb83c8c..26ea41259b 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/participants/RefactoringProcessors.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/participants/RefactoringProcessors.java
@@ -31,4 +31,7 @@ public class RefactoringProcessors {
}
return result.toArray(new String[result.size()]);
}
+
+ private RefactoringProcessors() {
+ }
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameEnumConstProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameEnumConstProcessor.java
index bbbe027d36..fa44b102f6 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameEnumConstProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameEnumConstProcessor.java
@@ -165,12 +165,12 @@ public final class RenameEnumConstProcessor extends RenameFieldProcessor {
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME));
final String references= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES);
if (references != null) {
- setUpdateReferences(Boolean.valueOf(references).booleanValue());
+ setUpdateReferences(Boolean.parseBoolean(references));
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES));
final String matches= extended.getAttribute(ATTRIBUTE_TEXTUAL_MATCHES);
if (matches != null) {
- setUpdateTextualMatches(Boolean.valueOf(matches).booleanValue());
+ setUpdateTextualMatches(Boolean.parseBoolean(matches));
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_TEXTUAL_MATCHES));
return new RefactoringStatus();
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameFieldProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameFieldProcessor.java
index 17ab1be158..521f77a84a 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameFieldProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameFieldProcessor.java
@@ -871,7 +871,8 @@ public class RenameFieldProcessor extends JavaRenameProcessor implements IRefere
Assert.isTrue(fField.exists());
IJavaSearchScope scope= RefactoringScopeFactory.create(fField.getDeclaringType());
- SearchPattern pattern= SearchPattern.createPattern(fField.getElementName(), IJavaSearchConstants.METHOD,
+ String patternStr= getCurrentElementQualifier() + '.' + fField.getElementName();
+ SearchPattern pattern= SearchPattern.createPattern(patternStr, IJavaSearchConstants.METHOD,
IJavaSearchConstants.REFERENCES, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE | SearchPattern.R_ERASURE_MATCH);
SearchResultGroup[] groupedResults= RefactoringSearchEngine.search(
pattern, scope, new MethodOccurenceCollector(fField.getElementName()), pm, status);
@@ -999,32 +1000,32 @@ public class RenameFieldProcessor extends JavaRenameProcessor implements IRefere
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME));
final String references= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES);
if (references != null) {
- fUpdateReferences= Boolean.valueOf(references).booleanValue();
+ fUpdateReferences= Boolean.parseBoolean(references);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES));
final String matches= extended.getAttribute(ATTRIBUTE_TEXTUAL_MATCHES);
if (matches != null) {
- fUpdateTextualMatches= Boolean.valueOf(matches).booleanValue();
+ fUpdateTextualMatches= Boolean.parseBoolean(matches);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_TEXTUAL_MATCHES));
final String getters= extended.getAttribute(ATTRIBUTE_RENAME_GETTER);
if (getters != null)
- fRenameGetter= Boolean.valueOf(getters).booleanValue();
+ fRenameGetter= Boolean.parseBoolean(getters);
else
fRenameGetter= false;
final String setters= extended.getAttribute(ATTRIBUTE_RENAME_SETTER);
if (setters != null)
- fRenameSetter= Boolean.valueOf(setters).booleanValue();
+ fRenameSetter= Boolean.parseBoolean(setters);
else
fRenameSetter= false;
final String delegate= extended.getAttribute(ATTRIBUTE_DELEGATE);
if (delegate != null) {
- fDelegateUpdating= Boolean.valueOf(delegate).booleanValue();
+ fDelegateUpdating= Boolean.parseBoolean(delegate);
} else
fDelegateUpdating= false;
final String deprecate= extended.getAttribute(ATTRIBUTE_DEPRECATE);
if (deprecate != null) {
- fDelegateDeprecation= Boolean.valueOf(deprecate).booleanValue();
+ fDelegateDeprecation= Boolean.parseBoolean(deprecate);
} else
fDelegateDeprecation= false;
return new RefactoringStatus();
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameJavaProjectProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameJavaProjectProcessor.java
index c438005b7a..92de099b13 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameJavaProjectProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameJavaProjectProcessor.java
@@ -248,7 +248,7 @@ public final class RenameJavaProjectProcessor extends JavaRenameProcessor implem
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME));
final String references= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES);
if (references != null) {
- fUpdateReferences= Boolean.valueOf(references).booleanValue();
+ fUpdateReferences= Boolean.parseBoolean(references);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES));
return new RefactoringStatus();
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameLocalVariableProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameLocalVariableProcessor.java
index bde66afbb7..c1521234bb 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameLocalVariableProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameLocalVariableProcessor.java
@@ -431,9 +431,9 @@ public class RenameLocalVariableProcessor extends JavaRenameProcessor implements
int length= -1;
final StringTokenizer tokenizer= new StringTokenizer(selection);
if (tokenizer.hasMoreTokens())
- offset= Integer.valueOf(tokenizer.nextToken()).intValue();
+ offset= Integer.parseInt(tokenizer.nextToken());
if (tokenizer.hasMoreTokens())
- length= Integer.valueOf(tokenizer.nextToken()).intValue();
+ length= Integer.parseInt(tokenizer.nextToken());
if (offset >= 0 && length >= 0) {
try {
final IJavaElement[] elements= fCu.codeSelect(offset, length);
@@ -457,7 +457,7 @@ public class RenameLocalVariableProcessor extends JavaRenameProcessor implements
}
final String references= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES);
if (references != null) {
- fUpdateReferences= Boolean.valueOf(references).booleanValue();
+ fUpdateReferences= Boolean.parseBoolean(references);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES));
return new RefactoringStatus();
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodProcessor.java
index 253ef0a71d..09c96fafe2 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodProcessor.java
@@ -906,17 +906,17 @@ public abstract class RenameMethodProcessor extends JavaRenameProcessor implemen
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME));
final String references= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES);
if (references != null) {
- fUpdateReferences= Boolean.valueOf(references).booleanValue();
+ fUpdateReferences= Boolean.parseBoolean(references);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES));
final String delegate= extended.getAttribute(ATTRIBUTE_DELEGATE);
if (delegate != null) {
- fDelegateUpdating= Boolean.valueOf(delegate).booleanValue();
+ fDelegateUpdating= Boolean.parseBoolean(delegate);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_DELEGATE));
final String deprecate= extended.getAttribute(ATTRIBUTE_DEPRECATE);
if (deprecate != null) {
- fDelegateDeprecation= Boolean.valueOf(deprecate).booleanValue();
+ fDelegateDeprecation= Boolean.parseBoolean(deprecate);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_DEPRECATE));
return new RefactoringStatus();
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenamePackageProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenamePackageProcessor.java
index fbf6a62756..09fb576eb1 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenamePackageProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenamePackageProcessor.java
@@ -1121,22 +1121,22 @@ public class RenamePackageProcessor extends JavaRenameProcessor implements
fFilePatterns= ""; //$NON-NLS-1$
final String references= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES);
if (references != null) {
- fUpdateReferences= Boolean.valueOf(references).booleanValue();
+ fUpdateReferences= Boolean.parseBoolean(references);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES));
final String matches= extended.getAttribute(ATTRIBUTE_TEXTUAL_MATCHES);
if (matches != null) {
- fUpdateTextualMatches= Boolean.valueOf(matches).booleanValue();
+ fUpdateTextualMatches= Boolean.parseBoolean(matches);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_TEXTUAL_MATCHES));
final String qualified= extended.getAttribute(ATTRIBUTE_QUALIFIED);
if (qualified != null) {
- fUpdateQualifiedNames= Boolean.valueOf(qualified).booleanValue();
+ fUpdateQualifiedNames= Boolean.parseBoolean(qualified);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_QUALIFIED));
final String hierarchical= extended.getAttribute(ATTRIBUTE_HIERARCHICAL);
if (hierarchical != null) {
- fRenameSubpackages= Boolean.valueOf(hierarchical).booleanValue();
+ fRenameSubpackages= Boolean.parseBoolean(hierarchical);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_HIERARCHICAL));
return new RefactoringStatus();
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeParameterProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeParameterProcessor.java
index cba6d7ae51..1d63d25b39 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeParameterProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeParameterProcessor.java
@@ -402,7 +402,7 @@ public class RenameTypeParameterProcessor extends JavaRenameProcessor implements
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME));
String references= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES);
if (references != null) {
- fUpdateReferences= Boolean.valueOf(references).booleanValue();
+ fUpdateReferences= Boolean.parseBoolean(references);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES));
return new RefactoringStatus();
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeProcessor.java
index 6fa8668903..f38e0b63ad 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeProcessor.java
@@ -1237,28 +1237,28 @@ public class RenameTypeProcessor extends JavaRenameProcessor implements ITextUpd
fFilePatterns= patterns;
final String references= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES);
if (references != null) {
- fUpdateReferences= Boolean.valueOf(references).booleanValue();
+ fUpdateReferences= Boolean.parseBoolean(references);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES));
final String matches= extended.getAttribute(ATTRIBUTE_TEXTUAL_MATCHES);
if (matches != null) {
- fUpdateTextualMatches= Boolean.valueOf(matches).booleanValue();
+ fUpdateTextualMatches= Boolean.parseBoolean(matches);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_TEXTUAL_MATCHES));
final String qualified= extended.getAttribute(ATTRIBUTE_QUALIFIED);
if (qualified != null) {
- fUpdateQualifiedNames= Boolean.valueOf(qualified).booleanValue();
+ fUpdateQualifiedNames= Boolean.parseBoolean(qualified);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_QUALIFIED));
final String similarDeclarations= extended.getAttribute(ATTRIBUTE_SIMILAR_DECLARATIONS);
if (similarDeclarations != null)
- fUpdateSimilarElements= Boolean.valueOf(similarDeclarations).booleanValue();
+ fUpdateSimilarElements= Boolean.parseBoolean(similarDeclarations);
else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_SIMILAR_DECLARATIONS));
final String similarDeclarationsMatchingStrategy= extended.getAttribute(ATTRIBUTE_MATCHING_STRATEGY);
if (similarDeclarationsMatchingStrategy != null) {
try {
- fRenamingStrategy= Integer.valueOf(similarDeclarationsMatchingStrategy).intValue();
+ fRenamingStrategy= Integer.parseInt(similarDeclarationsMatchingStrategy);
} catch (NumberFormatException e) {
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_illegal_argument, new String[] { similarDeclarationsMatchingStrategy,
ATTRIBUTE_QUALIFIED }));
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RippleMethodFinder2.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RippleMethodFinder2.java
index cdc772a54a..1d43300241 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RippleMethodFinder2.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RippleMethodFinder2.java
@@ -436,7 +436,7 @@ public class RippleMethodFinder2 {
}
private void createHierarchyOfDeclarations(IProgressMonitor pm, WorkingCopyOwner owner) throws JavaModelException {
- Stream<IType> types= fDeclarations.stream().map(method -> method.getDeclaringType());
+ Stream<IType> types= fDeclarations.stream().map(IMethod::getDeclaringType);
fHierarchy= createHierarchyOfTypes(pm, owner, types);
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/DeleteChangeCreator.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/DeleteChangeCreator.java
index abe3cbf844..7e6c89f2ec 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/DeleteChangeCreator.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/DeleteChangeCreator.java
@@ -176,9 +176,6 @@ class DeleteChangeCreator {
return createDeleteChange(((IClassFile)javaElement).getResource());
case IJavaElement.JAVA_MODEL: //cannot be done
- Assert.isTrue(false);
- return null;
-
case IJavaElement.JAVA_PROJECT: //handled differently
Assert.isTrue(false);
return null;
@@ -190,11 +187,9 @@ class DeleteChangeCreator {
case IJavaElement.PACKAGE_DECLARATION:
case IJavaElement.IMPORT_CONTAINER:
case IJavaElement.IMPORT_DECLARATION:
+ default://there's no more kinds
Assert.isTrue(false);//not done here
return new NullChange();
- default:
- Assert.isTrue(false);//there's no more kinds
- return new NullChange();
}
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/JavaDeleteProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/JavaDeleteProcessor.java
index e84cad43b7..37e426dd3c 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/JavaDeleteProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/JavaDeleteProcessor.java
@@ -642,12 +642,12 @@ public final class JavaDeleteProcessor extends DeleteProcessor {
if (fAccessorsDeleted)
comment.addSetting(RefactoringCoreMessages.JavaDeleteProcessor_delete_accessors);
final DeleteDescriptor descriptor= RefactoringSignatureDescriptorFactory.createDeleteDescriptor(project, description, comment.asString(), arguments, flags);
- arguments.put(ATTRIBUTE_DELETE_SUBPACKAGES, Boolean.valueOf(fDeleteSubPackages).toString());
- arguments.put(ATTRIBUTE_SUGGEST_ACCESSORS, Boolean.valueOf(fSuggestGetterSetterDeletion).toString());
- arguments.put(ATTRIBUTE_RESOURCES, Integer.valueOf(fResources.length).toString());
+ arguments.put(ATTRIBUTE_DELETE_SUBPACKAGES, Boolean.toString(fDeleteSubPackages));
+ arguments.put(ATTRIBUTE_SUGGEST_ACCESSORS, Boolean.toString(fSuggestGetterSetterDeletion));
+ arguments.put(ATTRIBUTE_RESOURCES, Integer.toString(fResources.length));
for (int offset= 0; offset < fResources.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + 1), JavaRefactoringDescriptorUtil.resourceToHandle(project, fResources[offset]));
- arguments.put(ATTRIBUTE_ELEMENTS, Integer.valueOf(fJavaElements.length).toString());
+ arguments.put(ATTRIBUTE_ELEMENTS, Integer.toString(fJavaElements.length));
for (int offset= 0; offset < fJavaElements.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + fResources.length + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fJavaElements[offset]));
return new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.DeleteRefactoring_7, new Change[] { fDeleteChange});
@@ -827,12 +827,12 @@ public final class JavaDeleteProcessor extends DeleteProcessor {
final RefactoringStatus status= new RefactoringStatus();
final String subPackages= extended.getAttribute(ATTRIBUTE_DELETE_SUBPACKAGES);
if (subPackages != null) {
- fDeleteSubPackages= Boolean.valueOf(subPackages).booleanValue();
+ fDeleteSubPackages= Boolean.parseBoolean(subPackages);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_DELETE_SUBPACKAGES));
final String suggest= extended.getAttribute(ATTRIBUTE_SUGGEST_ACCESSORS);
if (suggest != null) {
- fSuggestGetterSetterDeletion= Boolean.valueOf(suggest).booleanValue();
+ fSuggestGetterSetterDeletion= Boolean.parseBoolean(suggest);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_SUGGEST_ACCESSORS));
int resourceCount= 0;
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgDestinationFactory.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgDestinationFactory.java
index 0da4c9fc85..9a4ab4e1f6 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgDestinationFactory.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgDestinationFactory.java
@@ -89,4 +89,7 @@ public class ReorgDestinationFactory {
return null;
}
+ private ReorgDestinationFactory() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgPolicyFactory.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgPolicyFactory.java
index 84b9693e60..b15bc84fa5 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgPolicyFactory.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgPolicyFactory.java
@@ -941,13 +941,13 @@ public final class ReorgPolicyFactory {
int flags= JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE;
final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header);
arguments.put(ATTRIBUTE_POLICY, getPolicyId());
- arguments.put(ATTRIBUTE_FILES, Integer.valueOf(fFiles.length).toString());
+ arguments.put(ATTRIBUTE_FILES, Integer.toString(fFiles.length));
for (int offset= 0; offset < fFiles.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + 1), JavaRefactoringDescriptorUtil.resourceToHandle(project, fFiles[offset]));
- arguments.put(ATTRIBUTE_FOLDERS, Integer.valueOf(fFolders.length).toString());
+ arguments.put(ATTRIBUTE_FOLDERS, Integer.toString(fFolders.length));
for (int offset= 0; offset < fFolders.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + fFiles.length + 1), JavaRefactoringDescriptorUtil.resourceToHandle(project, fFolders[offset]));
- arguments.put(ATTRIBUTE_UNITS, Integer.valueOf(fCus.length).toString());
+ arguments.put(ATTRIBUTE_UNITS, Integer.toString(fCus.length));
for (int offset= 0; offset < fCus.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + fFolders.length + fFiles.length + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fCus[offset]));
arguments.putAll(getRefactoringArguments(project));
@@ -1595,8 +1595,8 @@ public final class ReorgPolicyFactory {
arguments.putAll(super.getRefactoringArguments(project));
if (fFilePatterns != null && !"".equals(fFilePatterns)) //$NON-NLS-1$
arguments.put(ATTRIBUTE_PATTERNS, fFilePatterns);
- arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES, Boolean.valueOf(fUpdateReferences).toString());
- arguments.put(ATTRIBUTE_QUALIFIED, Boolean.valueOf(fUpdateQualifiedNames).toString());
+ arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES, Boolean.toString(fUpdateReferences));
+ arguments.put(ATTRIBUTE_QUALIFIED, Boolean.toString(fUpdateQualifiedNames));
return arguments;
}
@@ -1639,12 +1639,12 @@ public final class ReorgPolicyFactory {
fFilePatterns= ""; //$NON-NLS-1$
final String references= arguments.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES);
if (references != null) {
- fUpdateReferences= Boolean.valueOf(references).booleanValue();
+ fUpdateReferences= Boolean.parseBoolean(references);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_REFERENCES));
final String qualified= arguments.getAttribute(ATTRIBUTE_QUALIFIED);
if (qualified != null) {
- fUpdateQualifiedNames= Boolean.valueOf(qualified).booleanValue();
+ fUpdateQualifiedNames= Boolean.parseBoolean(qualified);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_QUALIFIED));
return super.initialize(arguments);
@@ -2945,7 +2945,7 @@ public final class ReorgPolicyFactory {
int flags= RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE;
final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header);
arguments.put(ATTRIBUTE_POLICY, getPolicyId());
- arguments.put(ATTRIBUTE_ROOTS, Integer.valueOf(fPackageFragmentRoots.length).toString());
+ arguments.put(ATTRIBUTE_ROOTS, Integer.toString(fPackageFragmentRoots.length));
for (int offset= 0; offset < fPackageFragmentRoots.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fPackageFragmentRoots[offset]));
arguments.putAll(getRefactoringArguments(project));
@@ -3178,7 +3178,7 @@ public final class ReorgPolicyFactory {
int flags= JavaRefactoringDescriptor.JAR_REFACTORING | JavaRefactoringDescriptor.JAR_MIGRATION | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE;
final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header);
arguments.put(ATTRIBUTE_POLICY, getPolicyId());
- arguments.put(ATTRIBUTE_FRAGMENTS, Integer.valueOf(fPackageFragments.length).toString());
+ arguments.put(ATTRIBUTE_FRAGMENTS, Integer.toString(fPackageFragments.length));
for (int offset= 0; offset < fPackageFragments.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fPackageFragments[offset]));
arguments.putAll(getRefactoringArguments(project));
@@ -3923,7 +3923,7 @@ public final class ReorgPolicyFactory {
int flags= JavaRefactoringDescriptor.JAR_REFACTORING | JavaRefactoringDescriptor.JAR_MIGRATION | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE;
final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header);
arguments.put(ATTRIBUTE_POLICY, getPolicyId());
- arguments.put(ATTRIBUTE_MEMBERS, Integer.valueOf(fJavaElements.length).toString());
+ arguments.put(ATTRIBUTE_MEMBERS, Integer.toString(fJavaElements.length));
for (int offset= 0; offset < fJavaElements.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fJavaElements[offset]));
arguments.putAll(getRefactoringArguments(project));
@@ -4380,14 +4380,14 @@ public final class ReorgPolicyFactory {
if (element == null)
element= JavaRefactoringDescriptorUtil.handleToResource(arguments.getProject(), value);
if (tokenizer.hasMoreTokens()) {
- final boolean processed= Boolean.valueOf(tokenizer.nextToken()).booleanValue();
+ final boolean processed= Boolean.parseBoolean(tokenizer.nextToken());
if (processed) {
log.markAsProcessed(element);
if (element instanceof IJavaElement)
log.markAsProcessed(JavaElementResourceMapping.create((IJavaElement) element));
}
if (tokenizer.hasMoreTokens()) {
- final boolean renamed= Boolean.valueOf(tokenizer.nextToken()).booleanValue();
+ final boolean renamed= Boolean.parseBoolean(tokenizer.nextToken());
if (renamed && tokenizer.hasMoreTokens()) {
final String name= tokenizer.nextToken();
log.setNewName(element, name);
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/scripting/InlineMethodRefactoringContribution.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/scripting/InlineMethodRefactoringContribution.java
index a0669a3d84..d1d6e623b9 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/scripting/InlineMethodRefactoringContribution.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/scripting/InlineMethodRefactoringContribution.java
@@ -66,9 +66,9 @@ public final class InlineMethodRefactoringContribution extends JavaUIRefactoring
int length= -1;
final StringTokenizer tokenizer= new StringTokenizer(selection);
if (tokenizer.hasMoreTokens())
- offset= Integer.valueOf(tokenizer.nextToken()).intValue();
+ offset= Integer.parseInt(tokenizer.nextToken());
if (tokenizer.hasMoreTokens())
- length= Integer.valueOf(tokenizer.nextToken()).intValue();
+ length= Integer.parseInt(tokenizer.nextToken());
if (offset >= 0 && length >= 0) {
selectionStart= offset;
selectionLength= length;
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/sef/SelfEncapsulateFieldRefactoring.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/sef/SelfEncapsulateFieldRefactoring.java
index 4b59786fa9..d24cfcfba8 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/sef/SelfEncapsulateFieldRefactoring.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/sef/SelfEncapsulateFieldRefactoring.java
@@ -471,16 +471,16 @@ public class SelfEncapsulateFieldRefactoring extends Refactoring {
comment.addSetting(RefactoringCoreMessages.SelfEncapsulateField_generate_comments);
final EncapsulateFieldDescriptor descriptor= RefactoringSignatureDescriptorFactory.createEncapsulateFieldDescriptor(project, description, comment.asString(), arguments, flags);
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fField));
- arguments.put(ATTRIBUTE_VISIBILITY, Integer.valueOf(fVisibility).toString());
- arguments.put(ATTRIBUTE_INSERTION, Integer.valueOf(fInsertionIndex).toString());
+ arguments.put(ATTRIBUTE_VISIBILITY, Integer.toString(fVisibility));
+ arguments.put(ATTRIBUTE_INSERTION, Integer.toString(fInsertionIndex));
if (fCreateSetter) {
arguments.put(ATTRIBUTE_SETTER, fSetterName);
}
if (fCreateGetter) {
arguments.put(ATTRIBUTE_GETTER, fGetterName);
}
- arguments.put(ATTRIBUTE_COMMENTS, Boolean.valueOf(fGenerateJavadoc).toString());
- arguments.put(ATTRIBUTE_DECLARING, Boolean.valueOf(fEncapsulateDeclaringClass).toString());
+ arguments.put(ATTRIBUTE_COMMENTS, Boolean.toString(fGenerateJavadoc));
+ arguments.put(ATTRIBUTE_DECLARING, Boolean.toString(fEncapsulateDeclaringClass));
final DynamicValidationRefactoringChange result= new DynamicValidationRefactoringChange(descriptor, getName());
TextChange[] changes= fChangeManager.getAllChanges();
pm.beginTask(NO_NAME, changes.length);
@@ -796,12 +796,12 @@ public class SelfEncapsulateFieldRefactoring extends Refactoring {
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_SETTER));
final String encapsulate= arguments.getAttribute(ATTRIBUTE_DECLARING);
if (encapsulate != null) {
- fEncapsulateDeclaringClass= Boolean.valueOf(encapsulate).booleanValue();
+ fEncapsulateDeclaringClass= Boolean.parseBoolean(encapsulate);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_DECLARING));
final String matches= arguments.getAttribute(ATTRIBUTE_COMMENTS);
if (matches != null) {
- fGenerateJavadoc= Boolean.valueOf(matches).booleanValue();
+ fGenerateJavadoc= Boolean.parseBoolean(matches);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_COMMENTS));
final String visibility= arguments.getAttribute(ATTRIBUTE_VISIBILITY);
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeSignatureProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeSignatureProcessor.java
index e8a7b0db7d..5a77bacad4 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeSignatureProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeSignatureProcessor.java
@@ -1254,13 +1254,13 @@ public class ChangeSignatureProcessor extends RefactoringProcessor implements ID
descriptor= RefactoringSignatureDescriptorFactory.createChangeMethodSignatureDescriptor(project, description, comment.asString(), arguments, getDescriptorFlags());
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project,fMethod));
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fMethodName);
- arguments.put(ATTRIBUTE_DELEGATE, Boolean.valueOf(fDelegateUpdating).toString());
- arguments.put(ATTRIBUTE_DEPRECATE, Boolean.valueOf(fDelegateDeprecation).toString());
+ arguments.put(ATTRIBUTE_DELEGATE, Boolean.toString(fDelegateUpdating));
+ arguments.put(ATTRIBUTE_DEPRECATE, Boolean.toString(fDelegateDeprecation));
if (fReturnTypeInfo.isTypeNameChanged())
arguments.put(ATTRIBUTE_RETURN, fReturnTypeInfo.getNewTypeName());
try {
if (!isVisibilitySameAsInitial())
- arguments.put(ATTRIBUTE_VISIBILITY, Integer.valueOf(fVisibility).toString());
+ arguments.put(ATTRIBUTE_VISIBILITY, Integer.toString(fVisibility));
} catch (JavaModelException exception) {
JavaPlugin.log(exception);
}
@@ -1299,7 +1299,7 @@ public class ChangeSignatureProcessor extends RefactoringProcessor implements ID
count= 1;
for (ExceptionInfo info : fExceptionInfos) {
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + count, JavaRefactoringDescriptorUtil.elementToHandle(project,info.getElement()));
- arguments.put(ATTRIBUTE_KIND + count, Integer.valueOf(info.getKind()).toString());
+ arguments.put(ATTRIBUTE_KIND + count, Integer.toString(info.getKind()));
count++;
}
} catch (JavaModelException exception) {
@@ -2541,7 +2541,7 @@ public class ChangeSignatureProcessor extends RefactoringProcessor implements ID
* <code>tagName</code>, or <code>null</code>.
*/
private TagElement findTagElementToInsertAfter(List<TagElement> tags, String tagName) {
- List<String> tagOrder= Arrays.asList(new String[] {
+ List<String> tagOrder= Arrays.asList(
TagElement.TAG_AUTHOR,
TagElement.TAG_VERSION,
TagElement.TAG_PARAM,
@@ -2555,7 +2555,7 @@ public class ChangeSignatureProcessor extends RefactoringProcessor implements ID
TagElement.TAG_SERIALDATA,
TagElement.TAG_DEPRECATED,
TagElement.TAG_VALUE
- });
+ );
int goalOrdinal= tagOrder.indexOf(tagName);
if (goalOrdinal == -1) // unknown tag -> to end
return (tags.isEmpty()) ? null : (TagElement) tags.get(tags.size());
@@ -2818,7 +2818,7 @@ public class ChangeSignatureProcessor extends RefactoringProcessor implements ID
info= new ParameterInfo(oldTypeName, oldName, index);
info.setNewTypeName(newTypeName);
info.setNewName(newName);
- if (Boolean.valueOf(deleted).booleanValue())
+ if (Boolean.parseBoolean(deleted))
info.markAsDeleted();
}
fParameterInfos.add(info);
@@ -2840,7 +2840,7 @@ public class ChangeSignatureProcessor extends RefactoringProcessor implements ID
return JavaRefactoringDescriptorUtil.createInputFatalStatus(element, getProcessorName(), IJavaRefactorings.CHANGE_METHOD_SIGNATURE);
else {
try {
- info= new ExceptionInfo(element, Integer.valueOf(kind).intValue(), null);
+ info= new ExceptionInfo(element, Integer.parseInt(kind), null);
} catch (NumberFormatException exception) {
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_illegal_argument, new Object[] { kind, ATTRIBUTE_KIND }));
}
@@ -2853,12 +2853,12 @@ public class ChangeSignatureProcessor extends RefactoringProcessor implements ID
}
final String deprecate= arguments.getAttribute(ATTRIBUTE_DEPRECATE);
if (deprecate != null) {
- fDelegateDeprecation= Boolean.valueOf(deprecate).booleanValue();
+ fDelegateDeprecation= Boolean.parseBoolean(deprecate);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_DEPRECATE));
final String delegate= arguments.getAttribute(ATTRIBUTE_DELEGATE);
if (delegate != null) {
- fDelegateUpdating= Boolean.valueOf(delegate).booleanValue();
+ fDelegateUpdating= Boolean.parseBoolean(delegate);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_DELEGATE));
return new RefactoringStatus();
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeTypeRefactoring.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeTypeRefactoring.java
index f0e0240f61..163a0f7672 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeTypeRefactoring.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeTypeRefactoring.java
@@ -513,7 +513,7 @@ public class ChangeTypeRefactoring extends Refactoring {
comment.addSetting(Messages.format(RefactoringCoreMessages.ChangeTypeRefactoring_refactored_type_pattern, BindingLabelProvider.getBindingLabel(fSelectedType, JavaElementLabels.ALL_FULLY_QUALIFIED)));
final GeneralizeTypeDescriptor descriptor= RefactoringSignatureDescriptorFactory.createGeneralizeTypeDescriptor(project, description, comment.asString(), arguments, (RefactoringDescriptor.STRUCTURAL_CHANGE | JavaRefactoringDescriptor.JAR_REFACTORING | JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT));
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fCu));
- arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.valueOf(fSelectionStart).toString() + " " + Integer.valueOf(fSelectionLength).toString()); //$NON-NLS-1$
+ arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, Integer.toString(fSelectionStart) + " " + Integer.toString(fSelectionLength)); //$NON-NLS-1$
arguments.put(ATTRIBUTE_TYPE, fSelectedType.getQualifiedName());
final DynamicValidationRefactoringChange result= new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.ChangeTypeRefactoring_allChanges);
for (Map.Entry<ICompilationUnit, Set<ConstraintVariable>> entry : relevantVarsByUnit.entrySet()) {
@@ -1651,9 +1651,9 @@ public class ChangeTypeRefactoring extends Refactoring {
int length= -1;
final StringTokenizer tokenizer= new StringTokenizer(selection);
if (tokenizer.hasMoreTokens())
- offset= Integer.valueOf(tokenizer.nextToken()).intValue();
+ offset= Integer.parseInt(tokenizer.nextToken());
if (tokenizer.hasMoreTokens())
- length= Integer.valueOf(tokenizer.nextToken()).intValue();
+ length= Integer.parseInt(tokenizer.nextToken());
if (offset >= 0 && length >= 0) {
fSelectionStart= offset;
fSelectionLength= length;
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceProcessor.java
index 53ea44bddf..ea7d89c832 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceProcessor.java
@@ -363,9 +363,9 @@ public final class ExtractInterfaceProcessor extends SuperTypeRefactoringProcess
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fSuperName);
for (int index= 0; index < fMembers.length; index++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (index + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fMembers[index]));
- arguments.put(ATTRIBUTE_COMMENTS, Boolean.valueOf(fComments).toString());
- arguments.put(ATTRIBUTE_REPLACE, Boolean.valueOf(fReplace).toString());
- arguments.put(ATTRIBUTE_INSTANCEOF, Boolean.valueOf(fInstanceOf).toString());
+ arguments.put(ATTRIBUTE_COMMENTS, Boolean.toString(fComments));
+ arguments.put(ATTRIBUTE_REPLACE, Boolean.toString(fReplace));
+ arguments.put(ATTRIBUTE_INSTANCEOF, Boolean.toString(fInstanceOf));
final DynamicValidationRefactoringChange change= new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.ExtractInterfaceRefactoring_name, fChangeManager.getAllChanges());
final IFile file= ResourceUtil.getFile(fSubType.getCompilationUnit());
if (fSuperSource != null && fSuperSource.length() > 0)
@@ -873,17 +873,17 @@ public final class ExtractInterfaceProcessor extends SuperTypeRefactoringProcess
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME));
final String comment= extended.getAttribute(ATTRIBUTE_COMMENTS);
if (comment != null) {
- fComments= Boolean.valueOf(comment).booleanValue();
+ fComments= Boolean.parseBoolean(comment);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_COMMENTS));
final String instance= extended.getAttribute(ATTRIBUTE_INSTANCEOF);
if (instance != null) {
- fInstanceOf= Boolean.valueOf(instance).booleanValue();
+ fInstanceOf= Boolean.parseBoolean(instance);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_INSTANCEOF));
final String replace= extended.getAttribute(ATTRIBUTE_REPLACE);
if (replace != null) {
- fReplace= Boolean.valueOf(replace).booleanValue();
+ fReplace= Boolean.parseBoolean(replace);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_REPLACE));
int count= 1;
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractSupertypeProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractSupertypeProcessor.java
index 0e29246f5e..4165844a16 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractSupertypeProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractSupertypeProcessor.java
@@ -307,19 +307,19 @@ public final class ExtractSupertypeProcessor extends PullUpRefactoringProcessor
final ExtractSuperclassDescriptor descriptor= RefactoringSignatureDescriptorFactory.createExtractSuperclassDescriptor(project, description, comment.asString(), arguments, flags);
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fTypeName);
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, getDeclaringType()));
- arguments.put(ATTRIBUTE_REPLACE, Boolean.valueOf(fReplace).toString());
- arguments.put(ATTRIBUTE_INSTANCEOF, Boolean.valueOf(fInstanceOf).toString());
- arguments.put(ATTRIBUTE_STUBS, Boolean.valueOf(fCreateMethodStubs).toString());
- arguments.put(ATTRIBUTE_EXTRACT, Integer.valueOf(fMembersToMove.length).toString());
+ arguments.put(ATTRIBUTE_REPLACE, Boolean.toString(fReplace));
+ arguments.put(ATTRIBUTE_INSTANCEOF, Boolean.toString(fInstanceOf));
+ arguments.put(ATTRIBUTE_STUBS, Boolean.toString(fCreateMethodStubs));
+ arguments.put(ATTRIBUTE_EXTRACT, Integer.toString(fMembersToMove.length));
for (int offset= 0; offset < fMembersToMove.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fMembersToMove[offset]));
- arguments.put(ATTRIBUTE_DELETE, Integer.valueOf(fDeletedMethods.length).toString());
+ arguments.put(ATTRIBUTE_DELETE, Integer.toString(fDeletedMethods.length));
for (int offset= 0; offset < fDeletedMethods.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + fMembersToMove.length + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fDeletedMethods[offset]));
- arguments.put(ATTRIBUTE_ABSTRACT, Integer.valueOf(fAbstractMethods.length).toString());
+ arguments.put(ATTRIBUTE_ABSTRACT, Integer.toString(fAbstractMethods.length));
for (int offset= 0; offset < fAbstractMethods.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + fMembersToMove.length + fDeletedMethods.length + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fAbstractMethods[offset]));
- arguments.put(ATTRIBUTE_TYPES, Integer.valueOf(fTypesToExtract.length).toString());
+ arguments.put(ATTRIBUTE_TYPES, Integer.toString(fTypesToExtract.length));
for (int offset= 0; offset < fTypesToExtract.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + fMembersToMove.length + fDeletedMethods.length + fAbstractMethods.length + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fTypesToExtract[offset]));
final DynamicValidationRefactoringChange change= new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.ExtractSupertypeProcessor_extract_supertype, fChangeManager.getAllChanges());
@@ -967,17 +967,17 @@ public final class ExtractSupertypeProcessor extends PullUpRefactoringProcessor
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT));
final String stubs= extended.getAttribute(ATTRIBUTE_STUBS);
if (stubs != null) {
- fCreateMethodStubs= Boolean.valueOf(stubs).booleanValue();
+ fCreateMethodStubs= Boolean.parseBoolean(stubs);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_STUBS));
final String instance= extended.getAttribute(ATTRIBUTE_INSTANCEOF);
if (instance != null) {
- fInstanceOf= Boolean.valueOf(instance).booleanValue();
+ fInstanceOf= Boolean.parseBoolean(instance);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_INSTANCEOF));
final String replace= extended.getAttribute(ATTRIBUTE_REPLACE);
if (replace != null) {
- fReplace= Boolean.valueOf(replace).booleanValue();
+ fReplace= Boolean.parseBoolean(replace);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_REPLACE));
int extractCount= 0;
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoringProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoringProcessor.java
index eae08d5560..e46d6026d4 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoringProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoringProcessor.java
@@ -1082,16 +1082,16 @@ public class PullUpRefactoringProcessor extends HierarchyProcessor {
addSuperTypeSettings(comment, true);
final PullUpDescriptor descriptor= RefactoringSignatureDescriptorFactory.createPullUpDescriptor(project, description, comment.asString(), arguments, flags);
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fDestinationType));
- arguments.put(ATTRIBUTE_REPLACE, Boolean.valueOf(fReplace).toString());
- arguments.put(ATTRIBUTE_INSTANCEOF, Boolean.valueOf(fInstanceOf).toString());
- arguments.put(ATTRIBUTE_STUBS, Boolean.valueOf(fCreateMethodStubs).toString());
- arguments.put(ATTRIBUTE_PULL, Integer.valueOf(fMembersToMove.length).toString());
+ arguments.put(ATTRIBUTE_REPLACE, Boolean.toString(fReplace));
+ arguments.put(ATTRIBUTE_INSTANCEOF, Boolean.toString(fInstanceOf));
+ arguments.put(ATTRIBUTE_STUBS, Boolean.toString(fCreateMethodStubs));
+ arguments.put(ATTRIBUTE_PULL, Integer.toString(fMembersToMove.length));
for (int offset= 0; offset < fMembersToMove.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fMembersToMove[offset]));
- arguments.put(ATTRIBUTE_DELETE, Integer.valueOf(fDeletedMethods.length).toString());
+ arguments.put(ATTRIBUTE_DELETE, Integer.toString(fDeletedMethods.length));
for (int offset= 0; offset < fDeletedMethods.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + fMembersToMove.length + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fDeletedMethods[offset]));
- arguments.put(ATTRIBUTE_ABSTRACT, Integer.valueOf(fAbstractMethods.length).toString());
+ arguments.put(ATTRIBUTE_ABSTRACT, Integer.toString(fAbstractMethods.length));
for (int offset= 0; offset < fAbstractMethods.length; offset++)
arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (offset + fMembersToMove.length + fDeletedMethods.length + 1), JavaRefactoringDescriptorUtil.elementToHandle(project, fAbstractMethods[offset]));
return new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.PullUpRefactoring_Pull_Up, fChangeManager.getAllChanges());
@@ -1748,17 +1748,17 @@ public class PullUpRefactoringProcessor extends HierarchyProcessor {
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT));
final String stubs= extended.getAttribute(ATTRIBUTE_STUBS);
if (stubs != null) {
- fCreateMethodStubs= Boolean.valueOf(stubs).booleanValue();
+ fCreateMethodStubs= Boolean.parseBoolean(stubs);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_STUBS));
final String instance= extended.getAttribute(ATTRIBUTE_INSTANCEOF);
if (instance != null) {
- fInstanceOf= Boolean.valueOf(instance).booleanValue();
+ fInstanceOf= Boolean.parseBoolean(instance);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_INSTANCEOF));
final String replace= extended.getAttribute(ATTRIBUTE_REPLACE);
if (replace != null) {
- fReplace= Boolean.valueOf(replace).booleanValue();
+ fReplace= Boolean.parseBoolean(replace);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_REPLACE));
int pullCount= 0;
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/UseSuperTypeProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/UseSuperTypeProcessor.java
index fca2acbe0e..1f9997c715 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/UseSuperTypeProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/UseSuperTypeProcessor.java
@@ -406,7 +406,7 @@ public final class UseSuperTypeProcessor extends SuperTypeRefactoringProcessor {
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + 1));
final String instance= extended.getAttribute(ATTRIBUTE_INSTANCEOF);
if (instance != null) {
- fInstanceOf= Boolean.valueOf(instance).booleanValue();
+ fInstanceOf= Boolean.parseBoolean(instance);
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_INSTANCEOF));
return new RefactoringStatus();
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeRefactoringProcessor.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeRefactoringProcessor.java
index 414685c2c9..c31315441d 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeRefactoringProcessor.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeRefactoringProcessor.java
@@ -71,6 +71,7 @@ import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.NodeFinder;
+import org.eclipse.jdt.core.dom.ParameterizedType;
import org.eclipse.jdt.core.dom.QualifiedName;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
@@ -859,8 +860,22 @@ public abstract class SuperTypeRefactoringProcessor extends RefactoringProcessor
}
} else if (node instanceof ArrayType) {
final ASTNode type= node;
- while (node != null && !(node instanceof MethodDeclaration) && !(node instanceof VariableDeclarationFragment))
+ FieldDeclaration fieldDeclaration= ASTNodes.getParent(node, FieldDeclaration.class);
+ if (fieldDeclaration != null) {
+ binding= ((VariableDeclaration) fieldDeclaration.fragments().get(0)).resolveBinding();
+ node= target.findDeclaringNode(binding.getKey());
+ fieldDeclaration= ASTNodes.getParent(node, FieldDeclaration.class);
+ Type elementType= ((ArrayType) fieldDeclaration.getType()).getElementType();
+ ASTNode changeNode= NodeFinder.perform(target, elementType.getStartPosition(), elementType.getLength());
+ if (changeNode instanceof SimpleName || changeNode instanceof ParameterizedType) {
+ rewriteTypeOccurrence(estimate, rewrite, changeNode, group);
+ }
+ return;
+ }
+
+ while (node != null && !(node instanceof MethodDeclaration) && !(node instanceof VariableDeclarationFragment)) {
node= node.getParent();
+ }
if (node != null) {
final int delta= node.getStartPosition() + node.getLength() - type.getStartPosition();
if (node instanceof MethodDeclaration)
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeSet.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeSet.java
index 34a0c36410..a4cb1463ee 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeSet.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeSet.java
@@ -311,4 +311,7 @@ public abstract class SuperTypeSet implements ITypeSet {
public static ITypeSet getUniverse() {
return fgUniverse;
}
+
+ private SuperTypeSet() {
+ }
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/SurroundWithTryWithResourcesAnalyzer.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/SurroundWithTryWithResourcesAnalyzer.java
index eaf9914767..d3c0872923 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/SurroundWithTryWithResourcesAnalyzer.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/SurroundWithTryWithResourcesAnalyzer.java
@@ -14,8 +14,8 @@
package org.eclipse.jdt.internal.corext.refactoring.surround;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -76,8 +76,8 @@ public class SurroundWithTryWithResourcesAnalyzer extends SurroundWithAnalyzer {
List<ITypeBinding> exceptions= new ArrayList<>();
if (fEnclosingNode.getNodeType() == ASTNode.METHOD_DECLARATION) {
List<Type> thrownExceptions= ((MethodDeclaration) fEnclosingNode).thrownExceptionTypes();
- for (Iterator<Type> thrown= thrownExceptions.iterator(); thrown.hasNext();) {
- ITypeBinding thrownException= thrown.next().resolveBinding();
+ for (Type type : thrownExceptions) {
+ ITypeBinding thrownException= type.resolveBinding();
if (thrownException != null) {
exceptions.add(thrownException);
}
@@ -92,9 +92,7 @@ public class SurroundWithTryWithResourcesAnalyzer extends SurroundWithAnalyzer {
if (typeBinding != null) {
IMethodBinding methodBinding= typeBinding.getFunctionalInterfaceMethod();
if (methodBinding != null) {
- for (ITypeBinding thrownException : methodBinding.getExceptionTypes()) {
- exceptions.add(thrownException);
- }
+ Collections.addAll(exceptions, methodBinding.getExceptionTypes());
}
}
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/SurroundWithTryWithResourcesRefactoring.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/SurroundWithTryWithResourcesRefactoring.java
index 9d94647b3c..7f003925a4 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/SurroundWithTryWithResourcesRefactoring.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/SurroundWithTryWithResourcesRefactoring.java
@@ -272,8 +272,7 @@ public class SurroundWithTryWithResourcesRefactoring extends Refactoring {
}
}
List<VariableDeclarationFragment> fragments= copy.fragments();
- for (Iterator<VariableDeclarationFragment> iter= fragments.iterator(); iter.hasNext();) {
- VariableDeclarationFragment fragment= iter.next();
+ for (VariableDeclarationFragment fragment : fragments) {
fragment.setInitializer(null);
}
@@ -301,8 +300,7 @@ public class SurroundWithTryWithResourcesRefactoring extends Refactoring {
fragments= statement.fragments();
if (!fragments.isEmpty()) {
List<ExpressionStatement> newExpressionStatements= new ArrayList<>();
- for (Iterator<VariableDeclarationFragment> iter= fragments.iterator(); iter.hasNext();) {
- VariableDeclarationFragment fragment= iter.next();
+ for (VariableDeclarationFragment fragment : fragments) {
Expression initializer= fragment.getInitializer();
if (initializer != null) {
Assignment assignment= ast.newAssignment();
@@ -643,8 +641,7 @@ public class SurroundWithTryWithResourcesRefactoring extends Refactoring {
for (Iterator<ITypeBinding> subtypeIterator= filteredExceptions.iterator(); subtypeIterator.hasNext();) {
ITypeBinding iTypeBinding= subtypeIterator.next();
- for (Iterator<ITypeBinding> supertypeIterator= filteredExceptions.iterator(); supertypeIterator.hasNext();) {
- ITypeBinding superTypeBinding= supertypeIterator.next();
+ for (ITypeBinding superTypeBinding : filteredExceptions) {
if (!iTypeBinding.equals(superTypeBinding) && iTypeBinding.isSubTypeCompatible(superTypeBinding)) {
subtypeIterator.remove();
break;
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/typeconstraints/ConstraintOperator.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/typeconstraints/ConstraintOperator.java
index d4097204a5..4c20875719 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/typeconstraints/ConstraintOperator.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/typeconstraints/ConstraintOperator.java
@@ -34,7 +34,7 @@ public final class ConstraintOperator {
private static final String STRING_EQUALS= "==";//$NON-NLS-1$
private static final String STRING_DEFINES= "=^=";//$NON-NLS-1$
private static final String STRING_STRICT_SUBTYPE= "<";//$NON-NLS-1$
- private static final Collection<String> fgOperatorStrings= new HashSet<>(Arrays.asList(new String[] {STRING_SUBTYPE, STRING_EQUALS, STRING_DEFINES, STRING_STRICT_SUBTYPE}));
+ private static final Collection<String> fgOperatorStrings= new HashSet<>(Arrays.asList(STRING_SUBTYPE, STRING_EQUALS, STRING_DEFINES, STRING_STRICT_SUBTYPE));
private static final ConstraintOperator fgSubtype= new ConstraintOperator(STRING_SUBTYPE, CODE_SUBTYPE);
private static final ConstraintOperator fgEquals= new ConstraintOperator(STRING_EQUALS, CODE_EQUALS);
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/Changes.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/Changes.java
index dcd8938c79..e2782c17c3 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/Changes.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/Changes.java
@@ -45,4 +45,7 @@ public class Changes {
}
}
}
+
+ private Changes() {
+ }
}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/QualifiedNameFinder.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/QualifiedNameFinder.java
index e439a7ba10..3b04158c04 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/QualifiedNameFinder.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/QualifiedNameFinder.java
@@ -122,7 +122,7 @@ public class QualifiedNameFinder {
}
}
- public QualifiedNameFinder() {
+ private QualifiedNameFinder() {
}
public static void process(QualifiedNameSearchResult result, String pattern, String newValue, String filePatterns, IProject root, IProgressMonitor monitor) {
diff --git a/org.eclipse.jdt.ui/dictionaries/en_GB.dictionary b/org.eclipse.jdt.ui/dictionaries/en_GB.dictionary
index 2981e1fad2..2b4a8f623b 100644
--- a/org.eclipse.jdt.ui/dictionaries/en_GB.dictionary
+++ b/org.eclipse.jdt.ui/dictionaries/en_GB.dictionary
@@ -45746,6 +45746,7 @@ virgin's
virginity
virgins
virtual
+virtualize
virtually
virtue
virtue's
diff --git a/org.eclipse.jdt.ui/dictionaries/en_US.dictionary b/org.eclipse.jdt.ui/dictionaries/en_US.dictionary
index 178ef0cfc8..6ffda7190d 100644
--- a/org.eclipse.jdt.ui/dictionaries/en_US.dictionary
+++ b/org.eclipse.jdt.ui/dictionaries/en_US.dictionary
@@ -45745,6 +45745,7 @@ virgin's
virginity
virgins
virtual
+virtualize
virtually
virtue
virtue's
diff --git a/org.eclipse.jdt.ui/forceQualifierUpdate.txt b/org.eclipse.jdt.ui/forceQualifierUpdate.txt
index 2cb383f7c2..e8c92b0a15 100644
--- a/org.eclipse.jdt.ui/forceQualifierUpdate.txt
+++ b/org.eclipse.jdt.ui/forceQualifierUpdate.txt
@@ -2,4 +2,5 @@
Bug 509973 - Comparator errors in I20170105-0320
Bug 530709 - Comparator errors in jdt debug and jdt ui in I20180204-2000
Adopt changed return type of JavaManipulation.setPreferenceNodeId(String) (bug 506239)
-Bug 561135 - Comparator errors due to lambda generation order in build I20200315-2240 \ No newline at end of file
+Bug 561135 - Comparator errors due to lambda generation order in build I20200315-2240
+Bug 564006 - Comparator Errors in I20200605-1230 \ No newline at end of file
diff --git a/org.eclipse.jdt.ui/internal compatibility/org/eclipse/jdt/internal/ui/dialogs/TypeSelectionDialog2.java b/org.eclipse.jdt.ui/internal compatibility/org/eclipse/jdt/internal/ui/dialogs/TypeSelectionDialog2.java
index 8fff8bac0d..385a723346 100644
--- a/org.eclipse.jdt.ui/internal compatibility/org/eclipse/jdt/internal/ui/dialogs/TypeSelectionDialog2.java
+++ b/org.eclipse.jdt.ui/internal compatibility/org/eclipse/jdt/internal/ui/dialogs/TypeSelectionDialog2.java
@@ -233,7 +233,7 @@ public class TypeSelectionDialog2 extends SelectionStatusDialog {
String text= ((ITextSelection)selection).getText();
if (text != null) {
text= text.trim();
- if (text.length() > 0 && JavaConventions.validateJavaTypeName(text, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3).isOK()) {
+ if (text.length() > 0 && JavaConventions.validateJavaTypeName(text, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3, null).isOK()) {
fInitialFilter= text;
fSelectionMode= FULL_SELECTION;
}
diff --git a/org.eclipse.jdt.ui/jar in jar loader/org/eclipse/jdt/internal/jarinjarloader/JIJConstants.java b/org.eclipse.jdt.ui/jar in jar loader/org/eclipse/jdt/internal/jarinjarloader/JIJConstants.java
index fc6b6c8ca2..ef818351e0 100644
--- a/org.eclipse.jdt.ui/jar in jar loader/org/eclipse/jdt/internal/jarinjarloader/JIJConstants.java
+++ b/org.eclipse.jdt.ui/jar in jar loader/org/eclipse/jdt/internal/jarinjarloader/JIJConstants.java
@@ -36,4 +36,7 @@ final class JIJConstants {
static final String CURRENT_DIR = "./"; //$NON-NLS-1$
static final String UTF8_ENCODING = "UTF-8"; //$NON-NLS-1$
static final String RUNTIME = "#runtime"; //$NON-NLS-1$
+
+ private JIJConstants() {
+ }
}
diff --git a/org.eclipse.jdt.ui/jar in jar loader/org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader.java b/org.eclipse.jdt.ui/jar in jar loader/org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader.java
index 77a2f3432c..24737b06b6 100644
--- a/org.eclipse.jdt.ui/jar in jar loader/org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader.java
+++ b/org.eclipse.jdt.ui/jar in jar loader/org/eclipse/jdt/internal/jarinjarloader/JarRsrcLoader.java
@@ -57,8 +57,8 @@ public class JarRsrcLoader {
ClassLoader jceClassLoader = new URLClassLoader(rsrcUrls, getParentClassLoader());
Thread.currentThread().setContextClassLoader(jceClassLoader);
Class c = Class.forName(mi.rsrcMainClass, true, jceClassLoader);
- Method main = c.getMethod(JIJConstants.MAIN_METHOD_NAME, new Class[]{args.getClass()});
- main.invoke((Object)null, new Object[]{args});
+ Method main = c.getMethod(JIJConstants.MAIN_METHOD_NAME, args.getClass());
+ main.invoke((Object) null, args);
}
private static ClassLoader getParentClassLoader() throws InvocationTargetException, IllegalAccessException {
diff --git a/org.eclipse.jdt.ui/plugin.properties b/org.eclipse.jdt.ui/plugin.properties
index ecbf3fb515..ec53c554d8 100644
--- a/org.eclipse.jdt.ui/plugin.properties
+++ b/org.eclipse.jdt.ui/plugin.properties
@@ -520,6 +520,11 @@ GenerateJavadocAction.label= &Generate Javadoc...
create.module.info.label= Create module-info.java
##########################################################################
+# Preview Support
+##########################################################################
+enable.preview.features.label= Enable preview features
+
+##########################################################################
# Java Working Set Support
##########################################################################
JavaWorkingSetPage.name= Java
diff --git a/org.eclipse.jdt.ui/plugin.xml b/org.eclipse.jdt.ui/plugin.xml
index 4c4bb04764..2eb4ddc080 100644
--- a/org.eclipse.jdt.ui/plugin.xml
+++ b/org.eclipse.jdt.ui/plugin.xml
@@ -7154,9 +7154,14 @@
runAfter="org.eclipse.jdt.ui.cleanup.unboxing">
</cleanUp>
<cleanUp
+ class="org.eclipse.jdt.internal.ui.fix.MergeConditionalBlocksCleanUp"
+ id="org.eclipse.jdt.ui.cleanup.merge_conditional_blocks"
+ runAfter="org.eclipse.jdt.ui.cleanup.push_down_negation">
+ </cleanUp>
+ <cleanUp
class="org.eclipse.jdt.internal.ui.fix.MapMethodCleanUp"
id="org.eclipse.jdt.ui.cleanup.use_directly_map_method"
- runAfter="org.eclipse.jdt.ui.cleanup.push_down_negation">
+ runAfter="org.eclipse.jdt.ui.cleanup.merge_conditional_blocks">
</cleanUp>
</extension>
@@ -7317,6 +7322,31 @@
</action>
</objectContribution>
</extension>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IProject"
+ adaptable="true"
+ id="org.eclipse.jdt.ui.enable.preview.features">
+ <visibility>
+ <and>
+ <objectState
+ name="projectNature"
+ value="org.eclipse.jdt.core.javanature"/>
+ <objectState
+ name="open"
+ value="true"/>
+ </and>
+ </visibility>
+ <action
+ label="%enable.preview.features.label"
+ class="org.eclipse.jdt.internal.ui.actions.EnablePreviewFeaturesAction"
+ menubarPath="org.eclipse.ui.projectConfigure/additions"
+ enablesFor="1"
+ id="org.eclipse.jdt.ui.enable.preview.features.action">
+ </action>
+ </objectContribution>
+ </extension>
<extension
point="org.eclipse.core.expressions.propertyTesters">
diff --git a/org.eclipse.jdt.ui/pom.xml b/org.eclipse.jdt.ui/pom.xml
index 4c9c954752..8b4ce12bc4 100644
--- a/org.eclipse.jdt.ui/pom.xml
+++ b/org.eclipse.jdt.ui/pom.xml
@@ -14,11 +14,11 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.ui</artifactId>
- <version>3.21.100-SNAPSHOT</version>
+ <version>3.21.200-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<properties>
<code.ignoredWarnings>-warn:-deprecation,unavoidableGenericProblems</code.ignoredWarnings>
diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/DelegateUIHelper.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/DelegateUIHelper.java
index 9191f38fef..1e12ce00c8 100644
--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/DelegateUIHelper.java
+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/DelegateUIHelper.java
@@ -112,7 +112,7 @@ public class DelegateUIHelper {
private static boolean getBooleanSetting(String key, boolean defaultValue) {
String update= JavaPlugin.getDefault().getDialogSettings().get(key);
if (update != null)
- return Boolean.valueOf(update).booleanValue();
+ return Boolean.parseBoolean(update);
else
return defaultValue;
}
diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ExtractClassWizard.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ExtractClassWizard.java
index d01bec0199..02f9d586af 100644
--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ExtractClassWizard.java
+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ExtractClassWizard.java
@@ -515,7 +515,7 @@ public class ExtractClassWizard extends RefactoringWizard {
protected boolean getBooleanSetting(String key, boolean defaultValue) {
String update= getRefactoringSettings().get(key);
if (update != null)
- return Boolean.valueOf(update).booleanValue();
+ return Boolean.parseBoolean(update);
else
return defaultValue;
}
diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ExtractConstantWizard.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ExtractConstantWizard.java
index 686d2888f4..1a88ad9226 100644
--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ExtractConstantWizard.java
+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ExtractConstantWizard.java
@@ -188,15 +188,21 @@ public class ExtractConstantWizard extends RefactoringWizard {
if (fContentAssistProcessor == null)
return;
- int flags;
- if (fAccessModifier == JdtFlags.VISIBILITY_STRING_PRIVATE) {
- flags= Flags.AccPrivate;
- } else if (fAccessModifier == JdtFlags.VISIBILITY_STRING_PROTECTED) {
- flags= Flags.AccProtected;
- } else if (fAccessModifier == JdtFlags.VISIBILITY_STRING_PUBLIC) {
- flags= Flags.AccPublic;
- } else {
- flags= Flags.AccDefault;
+ int flags= Flags.AccDefault;
+ if (fAccessModifier != null) {
+ switch (fAccessModifier) {
+ case JdtFlags.VISIBILITY_STRING_PRIVATE:
+ flags= Flags.AccPrivate;
+ break;
+ case JdtFlags.VISIBILITY_STRING_PROTECTED:
+ flags= Flags.AccProtected;
+ break;
+ case JdtFlags.VISIBILITY_STRING_PUBLIC:
+ flags= Flags.AccPublic;
+ break;
+ default:
+ break;
+ }
}
ImageDescriptor imageDesc= JavaElementImageProvider.getFieldImageDescriptor(false, flags);
imageDesc= new JavaElementImageDescriptor(imageDesc, JavaElementImageDescriptor.STATIC | JavaElementImageDescriptor.FINAL, JavaElementImageProvider.BIG_SIZE);
@@ -310,7 +316,7 @@ public class ExtractConstantWizard extends RefactoringWizard {
private boolean getBooleanSetting(String key, boolean defaultValue) {
String update= getRefactoringSettings().get(key);
if (update != null)
- return Boolean.valueOf(update).booleanValue();
+ return Boolean.parseBoolean(update);
else
return defaultValue;
}
diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/IntroduceParameterObjectWizard.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/IntroduceParameterObjectWizard.java
index fd005bd218..4b2e3b79a3 100644
--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/IntroduceParameterObjectWizard.java
+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/IntroduceParameterObjectWizard.java
@@ -250,6 +250,8 @@ public class IntroduceParameterObjectWizard extends RefactoringWizard {
IJavaProject project= fProcessor.getMethod().getJavaProject();
String sourceLevel= project.getOption(JavaCore.COMPILER_SOURCE, true);
String compliance= project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
+ String previewEnabled= project.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+
for (ParameterInfo pi : fProcessor.getParameterInfos()) {
if (names.contains(pi.getNewName())) {
setErrorMessage(Messages.format(RefactoringMessages.IntroduceParameterObjectWizard_parametername_check_notunique, BasicElementLabels.getJavaElementName(pi.getNewName())));
@@ -268,7 +270,7 @@ public class IntroduceParameterObjectWizard extends RefactoringWizard {
setPageComplete(false);
return;
}
- IStatus validateJavaTypeName= JavaConventions.validateJavaTypeName(fProcessor.getClassName(), sourceLevel, compliance);
+ IStatus validateJavaTypeName= JavaConventions.validateJavaTypeName(fProcessor.getClassName(), sourceLevel, compliance, previewEnabled);
if (isErrorMessage(validateJavaTypeName))
return;
if (fProcessor.getClassName().indexOf('.') != -1) {
@@ -715,7 +717,7 @@ public class IntroduceParameterObjectWizard extends RefactoringWizard {
protected boolean getBooleanSetting(String key, boolean defaultValue) {
String update= getRefactoringSettings().get(key);
if (update != null)
- return Boolean.valueOf(update).booleanValue();
+ return Boolean.parseBoolean(update);
else
return defaultValue;
}
diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/MoveMembersWizard.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/MoveMembersWizard.java
index 5194a7b29d..e00f380d31 100644
--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/MoveMembersWizard.java
+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/MoveMembersWizard.java
@@ -112,7 +112,7 @@ public class MoveMembersWizard extends RefactoringWizard {
String label= JavaElementLabels.getElementLabel(getMoveProcessor().getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED);
String message= membersToMoveCount == 1 ? Messages.format(RefactoringMessages.MoveMembersInputPage_descriptionKey_singular, new String[] {
JavaElementLabels.getTextLabel(membersToMove[0], JavaElementLabels.ALL_FULLY_QUALIFIED), label }) : Messages.format(
- RefactoringMessages.MoveMembersInputPage_descriptionKey_plural, new String[] { Integer.valueOf(membersToMoveCount).toString(), label });
+ RefactoringMessages.MoveMembersInputPage_descriptionKey_plural, new String[] { Integer.toString(membersToMoveCount), label });
setDescription(message);
}
super.setVisible(visible);
diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/RefactoringSavePreferences.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/RefactoringSavePreferences.java
index 47db751543..a732130e3e 100644
--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/RefactoringSavePreferences.java
+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/RefactoringSavePreferences.java
@@ -33,4 +33,7 @@ public class RefactoringSavePreferences {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setValue(PREF_SAVE_ALL_EDITORS, save);
}
+
+ private RefactoringSavePreferences() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/UserInterfaceManager.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/UserInterfaceManager.java
index 2d0bec8d81..d24bba59fc 100644
--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/UserInterfaceManager.java
+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/UserInterfaceManager.java
@@ -50,8 +50,8 @@ public class UserInterfaceManager {
try {
UserInterfaceStarter starter= tuple.starter.newInstance();
Class<? extends RefactoringWizard> wizardClass= tuple.wizard;
- Constructor<? extends RefactoringWizard> constructor= wizardClass.getConstructor(new Class[] {Refactoring.class});
- RefactoringWizard wizard= constructor.newInstance(new Object[] {refactoring});
+ Constructor<? extends RefactoringWizard> constructor= wizardClass.getConstructor(Refactoring.class);
+ RefactoringWizard wizard= constructor.newInstance(refactoring);
starter.initialize(wizard);
return starter;
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException | IllegalArgumentException | InvocationTargetException e) {
diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/actions/RefactoringActions.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/actions/RefactoringActions.java
index e089a5df1c..b71832e06e 100644
--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/actions/RefactoringActions.java
+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/actions/RefactoringActions.java
@@ -85,4 +85,7 @@ public class RefactoringActions {
element= element.getAncestor(IJavaElement.TYPE);
return (IType)element;
}
+
+ private RefactoringActions() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/contentassist/ControlContentAssistHelper.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/contentassist/ControlContentAssistHelper.java
index 54113b4047..c8779c2220 100644
--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/contentassist/ControlContentAssistHelper.java
+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/contentassist/ControlContentAssistHelper.java
@@ -70,4 +70,7 @@ public class ControlContentAssistHelper {
return contentAssistant;
}
+ private ControlContentAssistHelper() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/contentassist/JavaTypeCompletionProcessor.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/contentassist/JavaTypeCompletionProcessor.java
index 53d54e89c1..2b5a7a0a51 100644
--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/contentassist/JavaTypeCompletionProcessor.java
+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/contentassist/JavaTypeCompletionProcessor.java
@@ -120,8 +120,7 @@ public class JavaTypeCompletionProcessor extends CUPositionCompletionProcessor {
protected static class TypeCompletionRequestor extends CUPositionCompletionRequestor {
private static final String VOID= "void"; //$NON-NLS-1$
- private static final List<String> BASE_TYPES= Arrays.asList(
- new String[] {"boolean", "byte", "char", "double", "float", "int", "long", "short"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
+ private static final List<String> BASE_TYPES= Arrays.asList("boolean", "byte", "char", "double", "float", "int", "long", "short"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
private boolean fEnableBaseTypes;
private boolean fEnableVoid;
diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/search/SearchBrokenNLSKeysUtil.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/search/SearchBrokenNLSKeysUtil.java
index 63961983c3..ff27eff1e7 100644
--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/search/SearchBrokenNLSKeysUtil.java
+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/search/SearchBrokenNLSKeysUtil.java
@@ -28,4 +28,7 @@ public class SearchBrokenNLSKeysUtil {
NewSearchUI.runQueryInBackground(query);
}
+ private SearchBrokenNLSKeysUtil() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/DeleteAction.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/DeleteAction.java
index 616358e303..edd773d9fa 100644
--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/DeleteAction.java
+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/DeleteAction.java
@@ -116,9 +116,9 @@ public class DeleteAction extends SelectionDispatchAction {
final String workingSetID= workingSet.getId();
String dialogMessage;
if (isDefaultWorkingSet(workingSetID))
- dialogMessage= MessageFormat.format(ReorgMessages.DeleteWorkingSet_hideworkingset_single, new Object[] { workingSet.getLabel() });
+ dialogMessage= MessageFormat.format(ReorgMessages.DeleteWorkingSet_hideworkingset_single, workingSet.getLabel());
else
- dialogMessage= MessageFormat.format(ReorgMessages.DeleteWorkingSet_removeorhideworkingset_single, new Object[] { workingSet.getLabel() });
+ dialogMessage= MessageFormat.format(ReorgMessages.DeleteWorkingSet_removeorhideworkingset_single, workingSet.getLabel());
dialog= new MessageDialog(getShell(), ReorgMessages.DeleteWorkingSet_single, null, dialogMessage, MessageDialog.QUESTION, new String[] { ReorgMessages.DeleteWorkingSet_Hide,
ReorgMessages.DeleteWorkingSet_Remove,
@@ -136,8 +136,7 @@ public class DeleteAction extends SelectionDispatchAction {
}
};
} else {
- dialog= new MessageDialog(getShell(), ReorgMessages.DeleteWorkingSet_multiple, null, MessageFormat.format(ReorgMessages.DeleteWorkingSet_removeorhideworkingset_multiple,
- new Object[] { Integer.valueOf(selection.size()) }),
+ dialog= new MessageDialog(getShell(), ReorgMessages.DeleteWorkingSet_multiple, null, MessageFormat.format(ReorgMessages.DeleteWorkingSet_removeorhideworkingset_multiple, Integer.valueOf(selection.size())),
MessageDialog.QUESTION, new String[] { ReorgMessages.DeleteWorkingSet_Hide, ReorgMessages.DeleteWorkingSet_Remove,
IDialogConstants.CANCEL_LABEL }, 0);
}
diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/RenameInputWizardPage.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/RenameInputWizardPage.java
index 01e997ae88..f5d8918db7 100644
--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/RenameInputWizardPage.java
+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/RenameInputWizardPage.java
@@ -301,7 +301,7 @@ abstract class RenameInputWizardPage extends TextInputWizardPage {
protected boolean getBooleanSetting(String key, boolean defaultValue) {
String update= getRefactoringSettings().get(key);
if (update != null)
- return Boolean.valueOf(update).booleanValue();
+ return Boolean.parseBoolean(update);
else
return defaultValue;
}
diff --git a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/ReorgQueries.java b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/ReorgQueries.java
index cc0e05f714..0189764802 100644
--- a/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/ReorgQueries.java
+++ b/org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/ReorgQueries.java
@@ -376,19 +376,18 @@ public class ReorgQueries implements IReorgQueries {
}
private boolean getResult(int[] result) throws OperationCanceledException {
- switch(result[0]){
- // skip button
- case 0:
- return false;
- // skip all button
+ switch(result[0]) {
case 1:
fSkipAll= true;
return false;
- // Cancel button
+ // Cancel button
case 2:
throw new OperationCanceledException();
+ // skip button
+ case 0:
default:
return false;
+ // skip all button
}
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/InterfaceIndicatorLabelDecorator.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/InterfaceIndicatorLabelDecorator.java
index 46ec913c75..91fa5e8087 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/InterfaceIndicatorLabelDecorator.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/InterfaceIndicatorLabelDecorator.java
@@ -253,9 +253,6 @@ public class InterfaceIndicatorLabelDecorator extends AbstractJavaElementLabelDe
return;
processChildrenDelta(delta, result);
return;
- case IJavaElement.TYPE:
- case IJavaElement.CLASS_FILE:
- return;
case IJavaElement.JAVA_MODEL:
processChildrenDelta(delta, result);
return;
@@ -272,8 +269,9 @@ public class InterfaceIndicatorLabelDecorator extends AbstractJavaElementLabelDe
result.add(elem);
}
return;
- default:
- // fields, methods, imports ect
+ case IJavaElement.TYPE:
+ case IJavaElement.CLASS_FILE:
+ default:// fields, methods, imports ect
return;
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java
index 622b77f081..6a746ce160 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java
@@ -794,4 +794,7 @@ public class JavaPluginImages {
}
return null;
}
+
+ private JavaPluginImages() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java
index 4bdd1b34a5..cda075e4c3 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.java
@@ -458,6 +458,10 @@ public final class ActionMessages extends NLS {
public static String CreateModuleInfoAction_dialog_finish_button_label;
public static String CreateModuleInfoAction_dialog_cancel_button_label;
+ public static String EnablePreviewFeaturesAction_convert_message_compliance;
+ public static String EnablePreviewFeaturesAction_error_message_compliance;
+ public static String EnablePreviewFeaturesAction_error_title;
+
public static String GenerateToStringAction_label;
public static String GenerateToStringAction_description;
public static String GenerateToStringAction_tooltip;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties
index 3e778de0d8..05466768f4 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/ActionMessages.properties
@@ -488,6 +488,9 @@ CreateModuleInfoAction_question_message_overwrite_module_info=The module-info.ja
CreateModuleInfoAction_dialog_finish_button_label=&Create
CreateModuleInfoAction_dialog_cancel_button_label=&Don't Create
+EnablePreviewFeaturesAction_convert_message_compliance=Preview features are supported only for the compliance level {0}. Do you want to change project compliance and JRE to {0}?
+EnablePreviewFeaturesAction_error_message_compliance=Preview features are supported only for the compliance level {0}.
+EnablePreviewFeaturesAction_error_title=Enable preview features
# DO NOT REMOVE, used in a product, see https://bugs.eclipse.org/296836
OrganizeImportsAction_summary_added={0} import(s) added.
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CleanUpAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CleanUpAction.java
index cc68fe08b7..5760a43430 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CleanUpAction.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CleanUpAction.java
@@ -41,6 +41,7 @@ import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
import org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.Messages;
@@ -53,7 +54,6 @@ import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.browsing.LogicalPackage;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.util.ElementValidator;
-import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
import org.eclipse.jdt.internal.ui.workingsets.IWorkingSetIDs;
public abstract class CleanUpAction extends SelectionDispatchAction {
@@ -139,16 +139,13 @@ public abstract class CleanUpAction extends SelectionDispatchAction {
case IJavaElement.TYPE:
return elem.getParent().getElementType() == IJavaElement.COMPILATION_UNIT; // for browsing perspective
case IJavaElement.COMPILATION_UNIT:
- return true;
case IJavaElement.IMPORT_CONTAINER:
+ case IJavaElement.JAVA_PROJECT: // https://bugs.eclipse.org/bugs/show_bug.cgi?id=65638
return true;
case IJavaElement.PACKAGE_FRAGMENT:
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
IPackageFragmentRoot root= (IPackageFragmentRoot)elem.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
return (root.getKind() == IPackageFragmentRoot.K_SOURCE);
- case IJavaElement.JAVA_PROJECT:
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=65638
- return true;
}
}
} else if (s instanceof LogicalPackage) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/EnablePreviewFeaturesAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/EnablePreviewFeaturesAction.java
new file mode 100644
index 0000000000..b07cd16b6d
--- /dev/null
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/EnablePreviewFeaturesAction.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2020 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.ui.actions;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+import org.eclipse.core.resources.IProject;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+
+import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
+import org.eclipse.jdt.internal.corext.util.Messages;
+
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
+
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.internal.ui.preferences.CompliancePreferencePage;
+import org.eclipse.jdt.internal.ui.text.correction.PreviewFeaturesSubProcessor;
+import org.eclipse.jdt.internal.ui.util.ClasspathVMUtil;
+
+public class EnablePreviewFeaturesAction implements IObjectActionDelegate {
+
+ private ISelection fSelection;
+
+ private IJavaProject fJavaProject;
+
+ @Override
+ public void selectionChanged(IAction action, ISelection selection) {
+ fSelection= selection;
+ fJavaProject= getJavaProject();
+ action.setEnabled(!PreviewFeaturesSubProcessor.isPreviewFeatureEnabled(fJavaProject));
+ }
+
+ @Override
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ // not used
+ }
+
+ @Override
+ public void run(IAction action) {
+ if (fJavaProject != null) {
+ try {
+
+ if (!JavaModelUtil.isLatestOrHigherJavaVersion(fJavaProject)) {
+ String latestSupportedJavaVersion= JavaCore.latestSupportedJavaVersion();
+ IVMInstall install= ClasspathVMUtil.findRequiredOrGreaterVMInstall(latestSupportedJavaVersion, true, true);
+ if (install == null) {
+ MessageDialog.openError(getDisplay().getActiveShell(), ActionMessages.EnablePreviewFeaturesAction_error_title,
+ Messages.format(ActionMessages.EnablePreviewFeaturesAction_error_message_compliance, latestSupportedJavaVersion));
+ return;
+ } else {
+ String compliance= ClasspathVMUtil.getVMInstallCompliance(install, false);
+ if (compliance != null) {
+ boolean val= MessageDialog.openQuestion(getDisplay().getActiveShell(), ActionMessages.EnablePreviewFeaturesAction_error_title,
+ Messages.format(ActionMessages.EnablePreviewFeaturesAction_convert_message_compliance, compliance));
+ if (!val) {
+ return;
+ } else {
+ updateJRE(fJavaProject, compliance);
+ updateComplianceSettings(fJavaProject, compliance);
+ }
+ } else {
+ MessageDialog.openError(getDisplay().getActiveShell(), ActionMessages.EnablePreviewFeaturesAction_error_title,
+ Messages.format(ActionMessages.EnablePreviewFeaturesAction_error_message_compliance, compliance));
+ return;
+ }
+ }
+ }
+
+ Map<String, String> map= fJavaProject.getOptions(false);
+ map.put(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ fJavaProject.setOptions(map);
+
+ Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ Map<String, Object> data= new HashMap<>();
+ data.put(CompliancePreferencePage.DATA_SELECT_OPTION_KEY, JavaCore.COMPILER_PB_REPORT_PREVIEW_FEATURES);
+ data.put(CompliancePreferencePage.DATA_SELECT_OPTION_QUALIFIER, JavaCore.PLUGIN_ID);
+ data.put(CompliancePreferencePage.USE_PROJECT_SPECIFIC_OPTIONS, Boolean.TRUE);
+ PreferencesUtil.createPropertyDialogOn(shell, fJavaProject, CompliancePreferencePage.PROP_ID, null, data).open();
+
+ } catch (CoreException e) {
+ JavaPlugin.log(e);
+ }
+ }
+ }
+
+ private IJavaProject getJavaProject() {
+ IJavaProject javaProject= null;
+
+ if (fSelection instanceof IStructuredSelection) {
+ Object selectedElement= ((IStructuredSelection) fSelection).getFirstElement();
+
+ if (selectedElement instanceof IProject) {
+ javaProject= JavaCore.create((IProject) selectedElement);
+ } else if (selectedElement instanceof IJavaProject) {
+ javaProject= (IJavaProject) selectedElement;
+ }
+ }
+
+ return javaProject;
+ }
+
+ private Display getDisplay() {
+ Display display= Display.getCurrent();
+ if (display == null)
+ display= Display.getDefault();
+ return display;
+ }
+
+ private boolean updateJRE(IJavaProject project, String compliance) throws CoreException, JavaModelException {
+ IExecutionEnvironment bestEE= ClasspathVMUtil.findBestMatchingEE(compliance);
+ if (bestEE != null) {
+ IPath newPath= JavaRuntime.newJREContainerPath(bestEE);
+ boolean classpathUpdated= ClasspathVMUtil.updateClasspath(newPath, project, new NullProgressMonitor());
+ return !classpathUpdated;
+ }
+ return true;
+ }
+
+ private void updateComplianceSettings(IJavaProject project, String compliance) {
+ HashMap<String, String> defaultOptions= new HashMap<>();
+ JavaCore.setComplianceOptions(compliance, defaultOptions);
+ Iterator<Map.Entry<String, String>> it= defaultOptions.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, String> pair= it.next();
+ project.setOption(pair.getKey(), pair.getValue());
+ }
+ }
+}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/FindBrokenNLSKeysAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/FindBrokenNLSKeysAction.java
index 62909e06d9..1a42cc89ac 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/FindBrokenNLSKeysAction.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/FindBrokenNLSKeysAction.java
@@ -207,6 +207,7 @@ public class FindBrokenNLSKeysAction extends SelectionDispatchAction {
}
return false;
case IJavaElement.COMPILATION_UNIT:
+ case IJavaElement.JAVA_PROJECT:
return true;
case IJavaElement.IMPORT_CONTAINER:
return false;
@@ -214,8 +215,6 @@ public class FindBrokenNLSKeysAction extends SelectionDispatchAction {
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
IPackageFragmentRoot root= (IPackageFragmentRoot) elem.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
return (root.getKind() == IPackageFragmentRoot.K_SOURCE);
- case IJavaElement.JAVA_PROJECT:
- return true;
}
}
} else if (s instanceof LogicalPackage) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/OpenBrowserUtil.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/OpenBrowserUtil.java
index 8e6ce534ae..ea397d5ee5 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/OpenBrowserUtil.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/OpenBrowserUtil.java
@@ -97,4 +97,7 @@ public class OpenBrowserUtil {
open(url, display);
}
+ private OpenBrowserUtil() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/PackagesViewFlatContentProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/PackagesViewFlatContentProvider.java
index 21c7556267..85ba4f3b13 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/PackagesViewFlatContentProvider.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/PackagesViewFlatContentProvider.java
@@ -159,25 +159,27 @@ public class PackagesViewFlatContentProvider extends LogicalPackagesProvider imp
if (element instanceof IPackageFragment) {
final IPackageFragment frag= (IPackageFragment) element;
- if (kind == IJavaElementDelta.REMOVED) {
- removeElement(frag);
-
- } else if (kind == IJavaElementDelta.ADDED) {
- addElement(frag);
-
- } else if (kind == IJavaElementDelta.CHANGED) {
- //just refresh
- Object toBeRefreshed= element;
-
- IPackageFragment pkgFragment= (IPackageFragment) element;
- LogicalPackage logicalPkg= findLogicalPackage(pkgFragment);
- //deal with packages that have been filtered and are now visible
- if (logicalPkg != null)
- toBeRefreshed= findElementToRefresh(logicalPkg);
- else
- toBeRefreshed= findElementToRefresh(pkgFragment);
-
- postRefresh(toBeRefreshed);
+ switch (kind) {
+ case IJavaElementDelta.REMOVED:
+ removeElement(frag);
+ break;
+ case IJavaElementDelta.ADDED:
+ addElement(frag);
+ break;
+ case IJavaElementDelta.CHANGED:
+ //just refresh
+ Object toBeRefreshed= element;
+ IPackageFragment pkgFragment= (IPackageFragment) element;
+ LogicalPackage logicalPkg= findLogicalPackage(pkgFragment);
+ //deal with packages that have been filtered and are now visible
+ if (logicalPkg != null)
+ toBeRefreshed= findElementToRefresh(logicalPkg);
+ else
+ toBeRefreshed= findElementToRefresh(pkgFragment);
+ postRefresh(toBeRefreshed);
+ break;
+ default:
+ break;
}
//in this view there will be no children of PackageFragment to refresh
return;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/PackagesViewHierarchicalContentProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/PackagesViewHierarchicalContentProvider.java
index 88070e0093..6fa1823ead 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/PackagesViewHierarchicalContentProvider.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/PackagesViewHierarchicalContentProvider.java
@@ -454,25 +454,25 @@ class PackagesViewHierarchicalContentProvider extends LogicalPackagesProvider im
//if fragment was in LogicalPackage refresh,
//otherwise just remove
- if (kind == IJavaElementDelta.REMOVED) {
- removeElement(frag);
- return;
-
- } else if (kind == IJavaElementDelta.ADDED) {
-
- Object parent= getParent(frag);
- addElement(frag, parent);
- return;
-
- } else if (kind == IJavaElementDelta.CHANGED) {
- //just refresh
- LogicalPackage logicalPkg= findLogicalPackage(frag);
- //in case changed object is filtered out
- if (logicalPkg != null)
- postRefresh(findElementToRefresh(logicalPkg));
- else
- postRefresh(findElementToRefresh(frag));
- return;
+ switch (kind) {
+ case IJavaElementDelta.REMOVED:
+ removeElement(frag);
+ return;
+ case IJavaElementDelta.ADDED:
+ Object parent= getParent(frag);
+ addElement(frag, parent);
+ return;
+ case IJavaElementDelta.CHANGED:
+ //just refresh
+ LogicalPackage logicalPkg= findLogicalPackage(frag);
+ //in case changed object is filtered out
+ if (logicalPkg != null)
+ postRefresh(findElementToRefresh(logicalPkg));
+ else
+ postRefresh(findElementToRefresh(frag));
+ return;
+ default:
+ break;
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsConfigurationBlock.java
index aa8c2b3553..fb00b15033 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsConfigurationBlock.java
@@ -247,7 +247,7 @@ public class ExpandWithConstructorsConfigurationBlock extends OptionsConfigurati
if (newText.length() == 0) {
status.setError(""); //$NON-NLS-1$
} else {
- IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
+ IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3, null);
if (val.matches(IStatus.ERROR)) {
if (fIsEditingMember)
status.setError(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_error_invalidMemberName);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchUtil.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchUtil.java
index 75f36a43d2..28d669485f 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchUtil.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchUtil.java
@@ -141,4 +141,7 @@ public class SearchUtil {
}
return result;
}
+
+ private SearchUtil() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SelectFieldModeAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SelectFieldModeAction.java
index f8fb4593b0..ce7c09cd25 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SelectFieldModeAction.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SelectFieldModeAction.java
@@ -29,19 +29,24 @@ public class SelectFieldModeAction extends Action {
private int fMode;
public SelectFieldModeAction(CallHierarchyViewPart v, int mode) {
- super(null, AS_RADIO_BUTTON);
- if (mode == IJavaSearchConstants.REFERENCES) {
- setText(CallHierarchyMessages.SelectFieldModeAction_all_references_label);
- setDescription(CallHierarchyMessages.SelectFieldModeAction_all_references_description);
- } else if (mode == IJavaSearchConstants.READ_ACCESSES) {
- setText(CallHierarchyMessages.SelectFieldModeAction_read_accesses_label);
- setDescription(CallHierarchyMessages.SelectFieldModeAction_read_accesses_description);
- } else if (mode == IJavaSearchConstants.WRITE_ACCESSES) {
- setText(CallHierarchyMessages.SelectFieldModeAction_write_accesses_label);
- setDescription(CallHierarchyMessages.SelectFieldModeAction_write_accesses_description);
- } else {
- Assert.isTrue(false);
- }
+ super(null, AS_RADIO_BUTTON);
+ switch (mode) {
+ case IJavaSearchConstants.REFERENCES:
+ setText(CallHierarchyMessages.SelectFieldModeAction_all_references_label);
+ setDescription(CallHierarchyMessages.SelectFieldModeAction_all_references_description);
+ break;
+ case IJavaSearchConstants.READ_ACCESSES:
+ setText(CallHierarchyMessages.SelectFieldModeAction_read_accesses_label);
+ setDescription(CallHierarchyMessages.SelectFieldModeAction_read_accesses_description);
+ break;
+ case IJavaSearchConstants.WRITE_ACCESSES:
+ setText(CallHierarchyMessages.SelectFieldModeAction_write_accesses_label);
+ setDescription(CallHierarchyMessages.SelectFieldModeAction_write_accesses_description);
+ break;
+ default:
+ Assert.isTrue(false);
+ break;
+ }
fView= v;
fMode= mode;
// FIXME(stephan) adjust/create new help context
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/TreeTermination.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/TreeTermination.java
index db7bb9ea41..687f7b33a5 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/TreeTermination.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/TreeTermination.java
@@ -17,4 +17,7 @@ package org.eclipse.jdt.internal.ui.callhierarchy;
final class TreeTermination {
public static final Object SEARCH_CANCELED = new Object();
+
+ private TreeTermination() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/compare/JavaCompareUtilities.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/compare/JavaCompareUtilities.java
index b2740d41f4..ed15866655 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/compare/JavaCompareUtilities.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/compare/JavaCompareUtilities.java
@@ -475,4 +475,7 @@ public class JavaCompareUtilities {
public static boolean isCompareEditorInput(IEditorInput input) {
return input instanceof CompareEditorInput;
}
+
+ private JavaCompareUtilities() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java
index 20af32b563..42bc4cb4c4 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java
@@ -90,6 +90,7 @@ import org.eclipse.jdt.core.search.TypeNameMatch;
import org.eclipse.jdt.core.search.TypeNameMatchRequestor;
import org.eclipse.jdt.core.search.TypeNameRequestor;
+import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
import org.eclipse.jdt.internal.corext.util.CollectionsUtil;
import org.eclipse.jdt.internal.corext.util.Messages;
import org.eclipse.jdt.internal.corext.util.OpenTypeHistory;
@@ -117,7 +118,6 @@ import org.eclipse.jdt.internal.ui.preferences.TypeFilterPreferencePage;
import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
import org.eclipse.jdt.internal.ui.util.TypeNameMatchLabelProvider;
-import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
import org.eclipse.jdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
@@ -436,7 +436,7 @@ public class FilteredTypesSelectionDialog extends FilteredItemsSelectionDialog i
String text= ((ITextSelection) selection).getText();
if (text != null) {
text= text.trim();
- if (text.length() > 0 && JavaConventions.validateJavaTypeName(text, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3).isOK()) {
+ if (text.length() > 0 && JavaConventions.validateJavaTypeName(text, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3, null).isOK()) {
setInitialPattern(text, FULL_SELECTION);
}
}
@@ -1148,7 +1148,7 @@ public class FilteredTypesSelectionDialog extends FilteredItemsSelectionDialog i
}
private String getFormattedLabel(String name) {
- return MessageFormat.format(JavaUIMessages.FilteredTypesSelectionDialog_library_name_format, new Object[] { name });
+ return MessageFormat.format(JavaUIMessages.FilteredTypesSelectionDialog_library_name_format, name);
}
@Override
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/GenerateToStringDialog.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/GenerateToStringDialog.java
index d4306a25ce..f67ba5e3ca 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/GenerateToStringDialog.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/GenerateToStringDialog.java
@@ -810,8 +810,9 @@ public class GenerateToStringDialog extends SourceActionDialog {
IType type= findType(builderSettings.className);
if (type == null || !type.exists()) {
- return new StatusInfo(IStatus.ERROR, MessageFormat.format(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_invalidClassError,
- new Object[] { builderSettings.className }));
+ return new StatusInfo(IStatus.ERROR,
+ MessageFormat.format(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_invalidClassError,
+ builderSettings.className));
}
IStatus typeValidation= validateBuilderType(type);
@@ -819,16 +820,19 @@ public class GenerateToStringDialog extends SourceActionDialog {
return typeValidation;
if (!getAppendMethodSuggestions(type).contains(builderSettings.appendMethod))
- return new StatusInfo(IStatus.ERROR, MessageFormat.format(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_invalidAppendMethodError,
- new Object[] { builderSettings.appendMethod }));
+ return new StatusInfo(IStatus.ERROR,
+ MessageFormat.format(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_invalidAppendMethodError,
+ builderSettings.appendMethod));
if (!getResultMethodSuggestions(type).contains(builderSettings.resultMethod))
- return new StatusInfo(IStatus.ERROR, MessageFormat.format(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_invalidResultMethodError,
- new Object[] { builderSettings.resultMethod }));
+ return new StatusInfo(IStatus.ERROR,
+ MessageFormat.format(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_invalidResultMethodError,
+ builderSettings.resultMethod));
if (!isValidJavaIdentifier(builderSettings.variableName))
- return new StatusInfo(IStatus.ERROR, MessageFormat.format(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_invalidVariableNameError,
- new Object[] { builderSettings.variableName }));
+ return new StatusInfo(IStatus.ERROR,
+ MessageFormat.format(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_invalidVariableNameError,
+ builderSettings.variableName));
} catch (JavaModelException e) {
return new StatusInfo(IStatus.WARNING, JavaUIMessages.GenerateToStringDialog_customBuilderConfig_dataValidationError);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/MultiElementListSelectionDialog.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/MultiElementListSelectionDialog.java
index d360a65bd1..8b578828c9 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/MultiElementListSelectionDialog.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/MultiElementListSelectionDialog.java
@@ -203,18 +203,23 @@ public class MultiElementListSelectionDialog extends AbstractElementListSelectio
*/
@Override
protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.SKIP_ID) {
- boolean isLastPage= fCurrentPage == fNumberOfPages - 1 ? true : false;
- turnPage(true, true);
- if (isLastPage) {
- buttonPressed(IDialogConstants.OK_ID);
- }
- } else if (buttonId == IDialogConstants.BACK_ID) {
- turnPage(false, false);
- } else if (buttonId == IDialogConstants.NEXT_ID) {
- turnPage(true, false);
- } else {
- super.buttonPressed(buttonId);
+ switch (buttonId) {
+ case IDialogConstants.SKIP_ID:
+ boolean isLastPage= fCurrentPage == fNumberOfPages - 1 ? true : false;
+ turnPage(true, true);
+ if (isLastPage) {
+ buttonPressed(IDialogConstants.OK_ID);
+ }
+ break;
+ case IDialogConstants.BACK_ID:
+ turnPage(false, false);
+ break;
+ case IDialogConstants.NEXT_ID:
+ turnPage(true, false);
+ break;
+ default:
+ super.buttonPressed(buttonId);
+ break;
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/SourceActionDialog.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/SourceActionDialog.java
index 3cca93076f..17fd55b2b2 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/SourceActionDialog.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/SourceActionDialog.java
@@ -424,7 +424,7 @@ public class SourceActionDialog extends CheckedTreeSelectionDialog {
return composite;
}
- protected Text createFilterComposite(@SuppressWarnings("unused") Composite inner) {
+ protected Text createFilterComposite(Composite inner) {
return null; // No filter as default
}
@@ -718,7 +718,6 @@ public class SourceActionDialog extends CheckedTreeSelectionDialog {
return JavaPlugin.getDefault().getDialogSettingsSection("DialogBounds_" + getClass().getSimpleName()); //$NON-NLS-1$
}
- @SuppressWarnings("unused")
protected void addMethodSearchFilter(Text filterText, CheckboxTreeViewer treeViewer) {
//Default is do nothing
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/StatusUtil.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/StatusUtil.java
index 4ac21c238d..61063bf114 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/StatusUtil.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/StatusUtil.java
@@ -88,4 +88,7 @@ public class StatusUtil {
break;
}
}
+
+ private StatusUtil() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/TextFieldNavigationHandler.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/TextFieldNavigationHandler.java
index 2fe37c9c68..f728c1f507 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/TextFieldNavigationHandler.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/TextFieldNavigationHandler.java
@@ -540,4 +540,7 @@ public class TextFieldNavigationHandler {
public abstract void execute();
}
+ private TextFieldNavigationHandler() {
+ }
+
} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/filters/FilterDescriptor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/filters/FilterDescriptor.java
index e3ee0c57c7..d9c9c17412 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/filters/FilterDescriptor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/filters/FilterDescriptor.java
@@ -246,7 +246,7 @@ public class FilterDescriptor implements Comparable<FilterDescriptor>, IPluginCo
if (strVal == null)
// backward compatibility
strVal= fElement.getAttribute(SELECTED_ATTRIBUTE);
- return strVal == null || Boolean.valueOf(strVal).booleanValue();
+ return strVal == null || Boolean.parseBoolean(strVal);
}
@Override
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/AutoboxingCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/AutoboxingCleanUp.java
index c75ac701dc..a90d8b0bf8 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/AutoboxingCleanUp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/AutoboxingCleanUp.java
@@ -78,17 +78,15 @@ public class AutoboxingCleanUp extends AbstractMultiFix {
return new String[0];
}
- @SuppressWarnings("nls")
@Override
public String getPreview() {
StringBuilder bld= new StringBuilder();
- bld.append("\n");
if (isEnabled(CleanUpConstants.USE_AUTOBOXING)) {
- bld.append("Integer i = 0;\n");
- bld.append("Character c = '*';\n");
+ bld.append("Integer i = 0;\n"); //$NON-NLS-1$
+ bld.append("Character c = '*';\n"); //$NON-NLS-1$
} else {
- bld.append("Integer i = Integer.valueOf(0);\n");
- bld.append("Character c = Character.valueOf('*');\n");
+ bld.append("Integer i = Integer.valueOf(0);\n"); //$NON-NLS-1$
+ bld.append("Character c = Character.valueOf('*');\n"); //$NON-NLS-1$
}
return bld.toString();
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/ConvertLoopCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/ConvertLoopCleanUp.java
index afe5cf5551..722e2f7454 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/ConvertLoopCleanUp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/ConvertLoopCleanUp.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -50,19 +50,24 @@ public class ConvertLoopCleanUp extends AbstractCleanUp {
return null;
boolean convertForLoops= isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED);
+ boolean checkIfLoopVarUsed= isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_ONLY_IF_LOOP_VAR_USED);
return ConvertLoopFix.createCleanUp(compilationUnit,
convertForLoops, convertForLoops,
- isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL) && isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES));
+ isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL) && isEnabled(CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES),
+ checkIfLoopVarUsed);
}
@Override
public String[] getStepDescriptions() {
List<String> result= new ArrayList<>();
- if (isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED))
+ if (isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED)) {
result.add(MultiFixMessages.Java50CleanUp_ConvertToEnhancedForLoop_description);
-
+ if (isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_ONLY_IF_LOOP_VAR_USED)) {
+ result.add(MultiFixMessages.Java50CleanUp_ConvertLoopOnlyIfLoopVarUsed_description);
+ }
+ }
return result.toArray(new String[result.size()]);
}
@@ -71,14 +76,24 @@ public class ConvertLoopCleanUp extends AbstractCleanUp {
StringBuilder buf= new StringBuilder();
if (isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED)) {
- buf.append("for (int element : ids) {\n"); //$NON-NLS-1$
- buf.append(" double value= element / 2; \n"); //$NON-NLS-1$
+ buf.append("for (int id : ids) {\n"); //$NON-NLS-1$
+ buf.append(" double value= id / 2; \n"); //$NON-NLS-1$
buf.append(" System.out.println(value);\n"); //$NON-NLS-1$
- buf.append("}\n"); //$NON-NLS-1$
+ buf.append("}\n\n"); //$NON-NLS-1$
} else {
buf.append("for (int i = 0; i < ids.length; i++) {\n"); //$NON-NLS-1$
buf.append(" double value= ids[i] / 2; \n"); //$NON-NLS-1$
buf.append(" System.out.println(value);\n"); //$NON-NLS-1$
+ buf.append("}\n\n"); //$NON-NLS-1$
+ }
+ if (isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED) &&
+ !isEnabled(CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_ONLY_IF_LOOP_VAR_USED)) {
+ buf.append("for (int id : ids) {\n"); //$NON-NLS-1$
+ buf.append(" System.out.println(\"here\");\n"); //$NON-NLS-1$
+ buf.append("}\n"); //$NON-NLS-1$
+ } else {
+ buf.append("for (int i = 0; i < ids.length; i++) {\n"); //$NON-NLS-1$
+ buf.append(" System.out.println(\"here\");\n"); //$NON-NLS-1$
buf.append("}\n"); //$NON-NLS-1$
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/LambdaExpressionAndMethodRefCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/LambdaExpressionAndMethodRefCleanUp.java
index d3e1787914..f342d23626 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/LambdaExpressionAndMethodRefCleanUp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/LambdaExpressionAndMethodRefCleanUp.java
@@ -103,7 +103,6 @@ public class LambdaExpressionAndMethodRefCleanUp extends AbstractMultiFix {
@Override
public String getPreview() {
StringBuilder bld= new StringBuilder();
- bld.append("\n"); //$NON-NLS-1$
if (isEnabled(CleanUpConstants.SIMPLIFY_LAMBDA_EXPRESSION_AND_METHOD_REF)) {
bld.append("someString -> someString.trim().toLowerCase();\n"); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/LazyLogicalCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/LazyLogicalCleanUp.java
index 855e2c316e..b45b22b33e 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/LazyLogicalCleanUp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/LazyLogicalCleanUp.java
@@ -73,7 +73,6 @@ public class LazyLogicalCleanUp extends AbstractMultiFix {
@Override
public String getPreview() {
StringBuilder bld= new StringBuilder();
- bld.append("\n"); //$NON-NLS-1$
if (isEnabled(CleanUpConstants.USE_LAZY_LOGICAL_OPERATOR)) {
bld.append("boolean b = isEnabled || isValid;\n"); //$NON-NLS-1$
bld.append("boolean b2 = isEnabled && isValid;\n"); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/MapMethodCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/MapMethodCleanUp.java
index dd70513be2..ac3edcc9d1 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/MapMethodCleanUp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/MapMethodCleanUp.java
@@ -77,7 +77,6 @@ public class MapMethodCleanUp extends AbstractMultiFix {
@Override
public String getPreview() {
StringBuilder bld= new StringBuilder();
- bld.append("\n"); //$NON-NLS-1$
if (isEnabled(CleanUpConstants.USE_DIRECTLY_MAP_METHOD)) {
bld.append("int x = map.size();\n"); //$NON-NLS-1$
bld.append("if (map.containsKey(\"hello\")) {\n"); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/MergeConditionalBlocksCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/MergeConditionalBlocksCleanUp.java
new file mode 100644
index 0000000000..d230ab972a
--- /dev/null
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/MergeConditionalBlocksCleanUp.java
@@ -0,0 +1,237 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Fabrice TIERCELIN and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Fabrice TIERCELIN - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.ui.fix;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTMatcher;
+import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.Expression;
+import org.eclipse.jdt.core.dom.IfStatement;
+import org.eclipse.jdt.core.dom.InfixExpression;
+import org.eclipse.jdt.core.dom.Statement;
+import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
+
+import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory;
+import org.eclipse.jdt.internal.corext.dom.ASTNodes;
+import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
+import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFix;
+import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFix.CompilationUnitRewriteOperation;
+import org.eclipse.jdt.internal.corext.fix.LinkedProposalModel;
+import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
+
+import org.eclipse.jdt.ui.cleanup.CleanUpRequirements;
+import org.eclipse.jdt.ui.cleanup.ICleanUpFix;
+import org.eclipse.jdt.ui.text.java.IProblemLocation;
+
+/**
+ * A fix that merge conditions of if/else if/else that have the same blocks.
+ */
+public class MergeConditionalBlocksCleanUp extends AbstractMultiFix {
+ public MergeConditionalBlocksCleanUp() {
+ this(Collections.emptyMap());
+ }
+
+ public MergeConditionalBlocksCleanUp(Map<String, String> options) {
+ super(options);
+ }
+
+ @Override
+ public CleanUpRequirements getRequirements() {
+ boolean requireAST= isEnabled(CleanUpConstants.MERGE_CONDITIONAL_BLOCKS);
+ return new CleanUpRequirements(requireAST, false, false, null);
+ }
+
+ @Override
+ public String[] getStepDescriptions() {
+ if (isEnabled(CleanUpConstants.MERGE_CONDITIONAL_BLOCKS)) {
+ return new String[] { MultiFixMessages.MergeConditionalBlocksCleanup_description };
+ }
+
+ return new String[0];
+ }
+
+ @Override
+ public String getPreview() {
+ StringBuilder bld= new StringBuilder();
+
+ if (isEnabled(CleanUpConstants.MERGE_CONDITIONAL_BLOCKS)) {
+ bld.append("if ((i == 0) || (i == 1)) {\n"); //$NON-NLS-1$
+ } else {
+ bld.append("if (i == 0) {\n"); //$NON-NLS-1$
+ bld.append(" System.out.println(\"Duplicate\");\n"); //$NON-NLS-1$
+ bld.append("} else if (i == 1) {\n"); //$NON-NLS-1$
+ }
+
+ bld.append(" System.out.println(\"Duplicate\");\n"); //$NON-NLS-1$
+ bld.append("} else {\n"); //$NON-NLS-1$
+ bld.append(" System.out.println(\"Different\");\n"); //$NON-NLS-1$
+ bld.append("}\n"); //$NON-NLS-1$
+
+ return bld.toString();
+ }
+
+ @Override
+ protected ICleanUpFix createFix(CompilationUnit unit) throws CoreException {
+ if (!isEnabled(CleanUpConstants.MERGE_CONDITIONAL_BLOCKS)) {
+ return null;
+ }
+
+ final List<CompilationUnitRewriteOperation> rewriteOperations= new ArrayList<>();
+
+ unit.accept(new ASTVisitor() {
+ @Override
+ public boolean visit(final IfStatement node) {
+ if (node.getElseStatement() != null) {
+ List<IfStatement> duplicateIfBlocks= new ArrayList<>(4);
+ List<Boolean> isThenStatement= new ArrayList<>(4);
+ AtomicInteger operandCount= new AtomicInteger(ASTNodes.getNbOperands(node.getExpression()));
+ duplicateIfBlocks.add(node);
+ isThenStatement.add(Boolean.TRUE);
+
+ while (addOneMoreIf(duplicateIfBlocks, isThenStatement, operandCount)) {
+ // OK continue
+ }
+
+ if (duplicateIfBlocks.size() > 1) {
+ rewriteOperations.add(new MergeConditionalBlocksOperation(duplicateIfBlocks, isThenStatement));
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private boolean addOneMoreIf(final List<IfStatement> duplicateIfBlocks, final List<Boolean> isThenStatement, final AtomicInteger operandCount) {
+ IfStatement lastBlock= getLast(duplicateIfBlocks);
+ Statement previousStatement= getLast(isThenStatement) ? lastBlock.getThenStatement() : lastBlock.getElseStatement();
+ Statement nextStatement= getLast(isThenStatement) ? lastBlock.getElseStatement() : lastBlock.getThenStatement();
+
+ if (nextStatement != null) {
+ IfStatement nextElse= ASTNodes.as(nextStatement, IfStatement.class);
+
+ if (nextElse != null
+ && operandCount.get() + ASTNodes.getNbOperands(nextElse.getExpression()) < ASTNodes.EXCESSIVE_OPERAND_NUMBER) {
+ if (match(previousStatement, nextElse.getThenStatement())) {
+ operandCount.addAndGet(ASTNodes.getNbOperands(nextElse.getExpression()));
+ duplicateIfBlocks.add(nextElse);
+ isThenStatement.add(Boolean.TRUE);
+ return true;
+ }
+
+ if (nextElse.getElseStatement() != null
+ && match(previousStatement, nextElse.getElseStatement())) {
+ operandCount.addAndGet(ASTNodes.getNbOperands(nextElse.getExpression()));
+ duplicateIfBlocks.add(nextElse);
+ isThenStatement.add(Boolean.FALSE);
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private boolean match(final Statement expectedStatement, final Statement actualStatement) {
+ ASTMatcher matcher= new ASTMatcher();
+ List<Statement> expectedStatements= ASTNodes.asList(expectedStatement);
+ List<Statement> actualStatements= ASTNodes.asList(actualStatement);
+
+ if (expectedStatements.size() != actualStatements.size()) {
+ return false;
+ }
+
+ for (int codeLine= 0; codeLine < expectedStatements.size(); codeLine++) {
+ if (!matcher.safeSubtreeMatch(expectedStatements.get(codeLine), actualStatements.get(codeLine))) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ });
+
+ if (rewriteOperations.isEmpty()) {
+ return null;
+ }
+
+ return new CompilationUnitRewriteOperationsFix(MultiFixMessages.MergeConditionalBlocksCleanup_description, unit,
+ rewriteOperations.toArray(new CompilationUnitRewriteOperation[0]));
+ }
+
+ @Override
+ public boolean canFix(final ICompilationUnit compilationUnit, final IProblemLocation problem) {
+ return false;
+ }
+
+ @Override
+ protected ICleanUpFix createFix(final CompilationUnit unit, final IProblemLocation[] problems) throws CoreException {
+ return null;
+ }
+
+ private static class MergeConditionalBlocksOperation extends CompilationUnitRewriteOperation {
+ private final List<IfStatement> duplicateIfBlocks;
+ private final List<Boolean> isThenStatement;
+
+ public MergeConditionalBlocksOperation(final List<IfStatement> duplicateIfBlocks, final List<Boolean> isThenStatement) {
+ this.duplicateIfBlocks= duplicateIfBlocks;
+ this.isThenStatement= isThenStatement;
+ }
+
+ @Override
+ public void rewriteAST(final CompilationUnitRewrite cuRewrite, final LinkedProposalModel linkedModel) throws CoreException {
+ ASTRewrite rewrite= cuRewrite.getASTRewrite();
+ AST ast= cuRewrite.getRoot().getAST();
+
+ List<Expression> newConditions= new ArrayList<>(duplicateIfBlocks.size());
+
+ for (int i= 0; i < duplicateIfBlocks.size(); i++) {
+ if (isThenStatement.get(i)) {
+ newConditions.add(ASTNodeFactory.parenthesizeIfNeeded(ast, ASTNodes.createMoveTarget(rewrite, duplicateIfBlocks.get(i).getExpression())));
+ } else {
+ newConditions.add(ASTNodeFactory.parenthesizeIfNeeded(ast, ASTNodeFactory.negate(ast, rewrite, duplicateIfBlocks.get(i).getExpression(), true)));
+ }
+ }
+
+ IfStatement lastBlock= getLast(duplicateIfBlocks);
+ Statement remainingStatement= getLast(isThenStatement) ? lastBlock.getElseStatement() : lastBlock.getThenStatement();
+ InfixExpression newCondition= ast.newInfixExpression();
+ newCondition.setOperator(InfixExpression.Operator.CONDITIONAL_OR);
+ newCondition.setLeftOperand(newConditions.remove(0));
+ newCondition.setRightOperand(newConditions.remove(0));
+ newCondition.extendedOperands().addAll(newConditions);
+
+ rewrite.replace(duplicateIfBlocks.get(0).getExpression(), newCondition, null);
+
+ if (remainingStatement != null) {
+ rewrite.replace(duplicateIfBlocks.get(0).getElseStatement(), ASTNodes.createMoveTarget(rewrite, remainingStatement), null);
+ } else if (duplicateIfBlocks.get(0).getElseStatement() != null) {
+ rewrite.remove(duplicateIfBlocks.get(0).getElseStatement(), null);
+ }
+ }
+ }
+
+ private static <E> E getLast(final List<E> list) {
+ return list.get(list.size() - 1);
+ }
+}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/NumberSuffixCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/NumberSuffixCleanUp.java
index 9e3e2d6ff0..b832fa9a02 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/NumberSuffixCleanUp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/NumberSuffixCleanUp.java
@@ -71,7 +71,6 @@ public class NumberSuffixCleanUp extends AbstractMultiFix {
@Override
public String getPreview() {
StringBuilder bld= new StringBuilder();
- bld.append("\n"); //$NON-NLS-1$
if (isEnabled(CleanUpConstants.NUMBER_SUFFIX)) {
bld.append("long number1 = 10L;\n"); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/PushDownNegationCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/PushDownNegationCleanUp.java
index 8c3a14030f..45563f9688 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/PushDownNegationCleanUp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/PushDownNegationCleanUp.java
@@ -81,7 +81,6 @@ public class PushDownNegationCleanUp extends AbstractMultiFix {
@Override
public String getPreview() {
StringBuilder bld= new StringBuilder();
- bld.append("\n"); //$NON-NLS-1$
if (isEnabled(CleanUpConstants.PUSH_DOWN_NEGATION)) {
bld.append("boolean b = (myInt <= 0);\n"); //$NON-NLS-1$
bld.append("boolean b2 = (!isEnabled && !isValid);\n"); //$NON-NLS-1$
@@ -117,10 +116,10 @@ public class PushDownNegationCleanUp extends AbstractMultiFix {
return pushDown(node, node.getOperand());
}
- private boolean pushDown(PrefixExpression node, final Expression operand) {
- if (operand instanceof ParenthesizedExpression) {
- return pushDown(node, ((ParenthesizedExpression) operand).getExpression());
- } else if (operand instanceof PrefixExpression) {
+ private boolean pushDown(final PrefixExpression node, Expression operand) {
+ operand= ASTNodes.getUnparenthesedExpression(operand);
+
+ if (operand instanceof PrefixExpression) {
final PrefixExpression pe= (PrefixExpression) operand;
if (ASTNodes.hasOperator(pe, PrefixExpression.Operator.NOT)) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantModifiersCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantModifiersCleanUp.java
index a490148898..debdf0f378 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantModifiersCleanUp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantModifiersCleanUp.java
@@ -83,7 +83,6 @@ public class RedundantModifiersCleanUp extends AbstractMultiFix {
@Override
public String getPreview() {
StringBuilder buf= new StringBuilder();
- buf.append("\n"); //$NON-NLS-1$
if (isEnabled(CleanUpConstants.REMOVE_REDUNDANT_MODIFIERS)) {
buf.append("public interface IFoo {\n"); //$NON-NLS-1$
buf.append(" int MAGIC_NUMBER = 646;\n"); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantSemicolonsCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantSemicolonsCleanUp.java
index 1240bcbd99..fbcf9c5c54 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantSemicolonsCleanUp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/RedundantSemicolonsCleanUp.java
@@ -88,7 +88,6 @@ public class RedundantSemicolonsCleanUp extends AbstractMultiFix implements ICle
@Override
public String getPreview() {
StringBuilder buf= new StringBuilder();
- buf.append("\n"); //$NON-NLS-1$
buf.append("enum color {\n"); //$NON-NLS-1$
buf.append(" red, yellow, green\n"); //$NON-NLS-1$
if (isEnabled(CleanUpConstants.REMOVE_REDUNDANT_SEMICOLONS)) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/SortMembersCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/SortMembersCleanUp.java
index ff4a9c5562..761ebaa2ed 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/SortMembersCleanUp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/SortMembersCleanUp.java
@@ -89,7 +89,7 @@ public class SortMembersCleanUp extends AbstractCleanUp {
if (containsRelevantMarkers(file)) {
String fileLocation= BasicElementLabels.getPathLabel(file.getProjectRelativePath(), false);
String projectName= file.getProject().getName();
- result.addWarning(MessageFormat.format(MultiFixMessages.SortMembersCleanUp_RemoveMarkersWarning0, new Object[] {fileLocation, projectName}));
+ result.addWarning(MessageFormat.format(MultiFixMessages.SortMembersCleanUp_RemoveMarkersWarning0, fileLocation, projectName));
}
monitor.worked(1);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnboxingCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnboxingCleanUp.java
index c8ce91987d..7269a1a066 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnboxingCleanUp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnboxingCleanUp.java
@@ -83,7 +83,6 @@ public class UnboxingCleanUp extends AbstractMultiFix {
@Override
public String getPreview() {
StringBuilder bld= new StringBuilder();
- bld.append("\n"); //$NON-NLS-1$
bld.append("Integer integerObject = Integer.MAX_VALUE;\n"); //$NON-NLS-1$
bld.append("Character cObject = Character.MAX_VALUE;\n"); //$NON-NLS-1$
bld.append("\n"); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnimplementedCodeCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnimplementedCodeCleanUp.java
index 166ed82486..8849959403 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnimplementedCodeCleanUp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnimplementedCodeCleanUp.java
@@ -73,7 +73,7 @@ public class UnimplementedCodeCleanUp extends AbstractMultiFix {
buf.append("public class Face implements IFace {\n"); //$NON-NLS-1$
}
if (isEnabled(CleanUpConstants.ADD_MISSING_METHODES)) {
- boolean createComments= Boolean.valueOf(PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_ADD_COMMENTS, null)).booleanValue();
+ boolean createComments= Boolean.parseBoolean(PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_ADD_COMMENTS, null));
if (createComments)
buf.append(indent(getOverridingMethodComment(), " ")); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnnecessaryArrayCreationCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnnecessaryArrayCreationCleanUp.java
index 903f84d754..073cec9677 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnnecessaryArrayCreationCleanUp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/UnnecessaryArrayCreationCleanUp.java
@@ -63,19 +63,11 @@ public class UnnecessaryArrayCreationCleanUp extends AbstractMultiFix {
@Override
public String getPreview() {
- StringBuilder bld= new StringBuilder();
- bld.append("\n"); //$NON-NLS-1$
- bld.append("public class Foo {\n"); //$NON-NLS-1$
- bld.append(" public static void bar() {\n"); //$NON-NLS-1$
if (isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_ARRAY_CREATION)) {
- bld.append(" List k= ArrayList.asList(\"a\", \"b\", \"c\");\n"); //$NON-NLS-1$
+ return "List k= Arrays.asList(\"a\", \"b\", \"c\");\n"; //$NON-NLS-1$
} else {
- bld.append(" List k= ArrayList.asList(new String[] {\"a\", \"b\", \"c\"});\n"); //$NON-NLS-1$
+ return "List k= Arrays.asList(new String[] {\"a\", \"b\", \"c\"});\n"; //$NON-NLS-1$
}
- bld.append(" }\n"); //$NON-NLS-1$
- bld.append("}\n"); //$NON-NLS-1$
-
- return bld.toString();
}
@Override
@@ -94,7 +86,7 @@ public class UnnecessaryArrayCreationCleanUp extends AbstractMultiFix {
}
return new CompilationUnitRewriteOperationsFix(MultiFixMessages.UnnecessaryArrayCreationCleanup_description, unit,
- rewriteOperations.toArray(new CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation[rewriteOperations.size()]));
+ rewriteOperations.toArray(new CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation[0]));
}
@Override
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/VarCleanUp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/VarCleanUp.java
index 3a83de5ee1..3d1c635141 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/VarCleanUp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/VarCleanUp.java
@@ -14,6 +14,7 @@
package org.eclipse.jdt.internal.ui.fix;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -86,7 +87,6 @@ public class VarCleanUp extends AbstractMultiFix {
@Override
public String getPreview() {
StringBuilder bld= new StringBuilder();
- bld.append("\n"); //$NON-NLS-1$
if (isEnabled(CleanUpConstants.USE_VAR)) {
bld.append("var number = 0;\n"); //$NON-NLS-1$
bld.append("var list = new ArrayList<String>();\n"); //$NON-NLS-1$
@@ -158,17 +158,17 @@ public class VarCleanUp extends AbstractMultiFix {
|| (classInstanceCreation != null
&& classInstanceCreation.getType().isParameterizedType()
&& classInstanceCreation.getType().resolveBinding() != null
- && Objects.equals(variableType.getTypeArguments(), classInstanceCreation.getType().resolveBinding().getTypeArguments())
+ && Arrays.equals(variableType.getTypeArguments(), classInstanceCreation.getType().resolveBinding().getTypeArguments())
&& !((ParameterizedType) classInstanceCreation.getType()).typeArguments().isEmpty())
|| (castExpression != null
&& castExpression.getType().isParameterizedType()
&& castExpression.getType().resolveBinding() != null
&& variableType.getTypeArguments().length == ((ParameterizedType) castExpression.getType()).typeArguments().size()
- && Objects.equals(variableType.getTypeArguments(), castExpression.getType().resolveBinding().getTypeArguments()))
+ && Arrays.equals(variableType.getTypeArguments(), castExpression.getType().resolveBinding().getTypeArguments()))
|| (methodInvocation != null
&& methodInvocation.resolveMethodBinding() != null
&& methodInvocation.resolveMethodBinding().getReturnType().isParameterizedType()
- && Objects.equals(variableType.getTypeArguments(), methodInvocation.resolveMethodBinding().getReturnType().getTypeArguments()))
+ && Arrays.equals(variableType.getTypeArguments(), methodInvocation.resolveMethodBinding().getReturnType().getTypeArguments()))
|| (classInstanceCreation == null
&& castExpression == null
&& methodInvocation == null
@@ -176,7 +176,7 @@ public class VarCleanUp extends AbstractMultiFix {
&& expression != null
&& expression.resolveTypeBinding() != null
&& expression.resolveTypeBinding().isParameterizedType()
- && Objects.equals(variableType.getTypeArguments(), expression.resolveTypeBinding().getTypeArguments()))) {
+ && Arrays.equals(variableType.getTypeArguments(), expression.resolveTypeBinding().getTypeArguments()))) {
rewriteOperations.add(new VarOperation(type));
return false;
} else if (variableType.isParameterizedType()
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarFileExportOperation.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarFileExportOperation.java
index 68b756054d..63a8be3177 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarFileExportOperation.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarFileExportOperation.java
@@ -75,6 +75,7 @@ import org.eclipse.jdt.core.ToolFactory;
import org.eclipse.jdt.core.util.IClassFileReader;
import org.eclipse.jdt.core.util.ISourceAttribute;
+import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.Messages;
import org.eclipse.jdt.internal.corext.util.Resources;
@@ -91,7 +92,6 @@ import org.eclipse.jdt.ui.refactoring.RefactoringSaveHelper;
import org.eclipse.jdt.internal.ui.IJavaStatusConstants;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext;
-import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
/**
* Operation for exporting a resource and its children to a new JAR file.
@@ -934,6 +934,8 @@ public class JarFileExportOperation extends WorkspaceModifyOperation implements
String message= null;
switch (fStatus.getSeverity()) {
case IStatus.OK:
+ default:
+ // defensive code in case new severity is defined
message= ""; //$NON-NLS-1$
break;
case IStatus.INFO:
@@ -948,10 +950,6 @@ public class JarFileExportOperation extends WorkspaceModifyOperation implements
else
message= JarPackagerMessages.JarFileExportOperation_jarCreationFailed;
break;
- default:
- // defensive code in case new severity is defined
- message= ""; //$NON-NLS-1$
- break;
}
fStatus.setMessage(message);
return fStatus;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarManifestWizardPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarManifestWizardPage.java
index 7697e768d0..bc7cb289f6 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarManifestWizardPage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackager/JarManifestWizardPage.java
@@ -496,7 +496,7 @@ class JarManifestWizardPage extends WizardPage implements IJarPackageWizardPage
dialog.setTitle(JarPackagerMessages.JarManifestWizardPage_mainTypeSelectionDialog_title);
dialog.setMessage(JarPackagerMessages.JarManifestWizardPage_mainTypeSelectionDialog_message);
if (fJarPackage.getManifestMainClass() != null)
- dialog.setInitialSelections(new Object[] {fJarPackage.getManifestMainClass()});
+ dialog.setInitialSelections(fJarPackage.getManifestMainClass());
if (dialog.open() == Window.OK) {
fJarPackage.setManifestMainClass((IType)dialog.getResult()[0]);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackagerfat/JIJConstants.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackagerfat/JIJConstants.java
index 9ee54de288..a854ab0041 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackagerfat/JIJConstants.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/jarpackagerfat/JIJConstants.java
@@ -33,4 +33,7 @@ final class JIJConstants {
* but that's not visible for the PDE builder when building the org.eclipse.jdt.ui plug-in.
*/
static final String LOADER_MAIN_CLASS = "org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"; //$NON-NLS-1$
+
+ private JIJConstants() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocTreeWizardPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocTreeWizardPage.java
index 3d1ff375cf..c422d42d4e 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocTreeWizardPage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocTreeWizardPage.java
@@ -624,7 +624,7 @@ public class JavadocTreeWizardPage extends JavadocWizardPage {
if (doclet.length() == 0) {
fDocletStatus.setError(JavadocExportMessages.JavadocTreeWizardPage_nodocletname_error);
- } else if (JavaConventions.validateJavaTypeName(doclet, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3).matches(IStatus.ERROR)) {
+ } else if (JavaConventions.validateJavaTypeName(doclet, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3, null).matches(IStatus.ERROR)) {
fDocletStatus.setError(JavadocExportMessages.JavadocTreeWizardPage_invaliddocletname_error);
} else if ((docletPath.length() == 0) || !validDocletPath(docletPath)) {
fDocletStatus.setError(JavadocExportMessages.JavadocTreeWizardPage_invaliddocletpath_error);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocWizard.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocWizard.java
index eea3650c82..f4dc355676 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocWizard.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocWizard.java
@@ -71,6 +71,7 @@ import org.eclipse.debug.core.ILaunchesListener2;
import org.eclipse.debug.core.Launch;
import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jdt.core.IJavaElement;
@@ -320,6 +321,19 @@ public class JavadocWizard extends Wizard implements IExportWizard {
}
try {
+ // Usually the output from Javadoc command is shown in Console View. The console is automatically created from the
+ // debug framework but only if org.eclipse.debug.ui plug-in is loaded. It is unlikely but possible that this plug-in
+ // is not loaded at this point which does not interfere the command execution but its output will be lost.
+ // Hence the Console View is not part of org.eclipse.debug.ui plug-in but in a separate plug-in it is even possible
+ // that Console View is open but the output of Javadoc command does not appear. For a user it is incomprehensible
+ // why the Javadoc command output does not appear in this uncommon situation.
+ // The easy fix for this is to simply 'touch' a class from org.eclipse.debug.ui plug-in to be sure it is loaded before
+ // starting the Javadoc command. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=239217
+ // Note: you might notice the use of IDebugUIConstants below and feel the urge to remove this workaround because it
+ // seem unnecessary. It is not! IDebugUIConstants.ATTR_PRIVATE is resolved at compile time and will not access the
+ // constants class and will not trigger plug-in activation.
+ DebugUITools.class.getClass();
+
ILaunchManager launchManager= DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType lcType= launchManager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClipboardOperationAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClipboardOperationAction.java
index 234ad4304c..11a3359dc3 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClipboardOperationAction.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClipboardOperationAction.java
@@ -225,20 +225,25 @@ public final class ClipboardOperationAction extends TextEditorAction {
super(bundle, prefix, editor);
fOperationCode= operationCode;
- if (operationCode == ITextOperationTarget.CUT) {
- setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_ACTION);
- setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT);
- updateImages(IWorkbenchCommandConstants.EDIT_CUT);
- } else if (operationCode == ITextOperationTarget.COPY) {
- setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_ACTION);
- setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
- updateImages(IWorkbenchCommandConstants.EDIT_COPY);
- } else if (operationCode == ITextOperationTarget.PASTE) {
- setHelpContextId(IAbstractTextEditorHelpContextIds.PASTE_ACTION);
- setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);
- updateImages(IWorkbenchCommandConstants.EDIT_PASTE);
- } else {
- Assert.isTrue(false, "Invalid operation code"); //$NON-NLS-1$
+ switch (operationCode) {
+ case ITextOperationTarget.CUT:
+ setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_ACTION);
+ setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT);
+ updateImages(IWorkbenchCommandConstants.EDIT_CUT);
+ break;
+ case ITextOperationTarget.COPY:
+ setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_ACTION);
+ setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
+ updateImages(IWorkbenchCommandConstants.EDIT_COPY);
+ break;
+ case ITextOperationTarget.PASTE:
+ setHelpContextId(IAbstractTextEditorHelpContextIds.PASTE_ACTION);
+ setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);
+ updateImages(IWorkbenchCommandConstants.EDIT_PASTE);
+ break;
+ default:
+ Assert.isTrue(false, "Invalid operation code"); //$NON-NLS-1$
+ break;
}
update();
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java
index 32dbce70b3..e3f7f111c6 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java
@@ -1581,8 +1581,6 @@ public class CompilationUnitEditor extends JavaEditor implements IJavaReconcilin
return '[';
case '"':
- return character;
-
case '\'':
return character;
@@ -1604,34 +1602,33 @@ public class CompilationUnitEditor extends JavaEditor implements IJavaReconcilin
String p= event.getProperty();
- if (CLOSE_BRACKETS.equals(p)) {
- fBracketInserter.setCloseBracketsEnabled(getPreferenceStore().getBoolean(p));
- return;
- }
-
- if (CLOSE_STRINGS.equals(p)) {
- fBracketInserter.setCloseStringsEnabled(getPreferenceStore().getBoolean(p));
- return;
- }
-
- if (JavaCore.COMPILER_SOURCE.equals(p)) {
- boolean closeAngularBrackets= JavaCore.compareJavaVersions(JavaCore.VERSION_1_5, getPreferenceStore().getString(p)) <= 0;
- fBracketInserter.setCloseAngularBracketsEnabled(closeAngularBrackets);
- }
-
- if (SPACES_FOR_TABS.equals(p)) {
- if (isTabsToSpacesConversionEnabled())
- installTabsToSpacesConverter();
- else
- uninstallTabsToSpacesConverter();
- return;
- }
-
- if (PreferenceConstants.EDITOR_SMART_TAB.equals(p)) {
- if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) {
- setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
- } else {
- removeActionActivationCode("IndentOnTab"); //$NON-NLS-1$
+ if (p != null) {
+ switch (p) {
+ case CLOSE_BRACKETS:
+ fBracketInserter.setCloseBracketsEnabled(getPreferenceStore().getBoolean(p));
+ return;
+ case CLOSE_STRINGS:
+ fBracketInserter.setCloseStringsEnabled(getPreferenceStore().getBoolean(p));
+ return;
+ case SPACES_FOR_TABS:
+ if (isTabsToSpacesConversionEnabled())
+ installTabsToSpacesConverter();
+ else
+ uninstallTabsToSpacesConverter();
+ return;
+ case JavaCore.COMPILER_SOURCE:
+ boolean closeAngularBrackets= JavaCore.compareJavaVersions(JavaCore.VERSION_1_5, getPreferenceStore().getString(p)) <= 0;
+ fBracketInserter.setCloseAngularBracketsEnabled(closeAngularBrackets);
+ break;
+ case PreferenceConstants.EDITOR_SMART_TAB:
+ if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) {
+ setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
+ } else {
+ removeActionActivationCode("IndentOnTab"); //$NON-NLS-1$
+ }
+ break;
+ default:
+ break;
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/EditorUtility.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/EditorUtility.java
index 5ff6ae1243..d758b7f626 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/EditorUtility.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/EditorUtility.java
@@ -414,7 +414,7 @@ public class EditorUtility {
public static String getEditorID(IEditorInput input) throws PartInitException {
Assert.isNotNull(input);
if (input instanceof IFileEditorInput)
- return IDE.getEditorDescriptor(((IFileEditorInput)input).getFile()).getId();
+ return IDE.getEditorDescriptor(((IFileEditorInput)input).getFile(), true, false).getId();
String name= input.getName();
@@ -435,7 +435,7 @@ public class EditorUtility {
}
}
- return IDE.getEditorDescriptor(name).getId();
+ return IDE.getEditorDescriptor(name, true, false).getId();
}
/**
@@ -885,4 +885,7 @@ public class EditorUtility {
return new NullProgressMonitor();
}
+ private EditorUtility() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java
index ffc5d976bf..4733c29217 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java
@@ -2810,14 +2810,14 @@ public abstract class JavaEditor extends AbstractDecoratedTextEditor implements
protected void setActionsActivated(boolean state) {
Method method= null;
try {
- method= AbstractTextEditor.class.getDeclaredMethod("setActionActivation", new Class[] { boolean.class }); //$NON-NLS-1$
+ method= AbstractTextEditor.class.getDeclaredMethod("setActionActivation", boolean.class); //$NON-NLS-1$
} catch (SecurityException | NoSuchMethodException ex) {
JavaPlugin.log(ex);
}
Assert.isNotNull(method);
method.setAccessible(true);
try {
- method.invoke(this, new Object[] { Boolean.valueOf(state) });
+ method.invoke(this, Boolean.valueOf(state));
} catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException ex) {
JavaPlugin.log(ex);
}
@@ -2870,7 +2870,7 @@ public abstract class JavaEditor extends AbstractDecoratedTextEditor implements
boolean newBooleanValue= false;
Object newValue= event.getNewValue();
if (newValue != null)
- newBooleanValue= Boolean.valueOf(newValue.toString()).booleanValue();
+ newBooleanValue= Boolean.parseBoolean(newValue.toString());
if (PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE.equals(property)) {
if (newBooleanValue)
@@ -2898,45 +2898,39 @@ public abstract class JavaEditor extends AbstractDecoratedTextEditor implements
}
return;
}
- if (PreferenceConstants.EDITOR_MARK_TYPE_OCCURRENCES.equals(property)) {
- fMarkTypeOccurrences= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES.equals(property)) {
- fMarkMethodOccurrences= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES.equals(property)) {
- fMarkConstantOccurrences= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES.equals(property)) {
- fMarkFieldOccurrences= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES.equals(property)) {
- fMarkLocalVariableypeOccurrences= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES.equals(property)) {
- fMarkExceptions= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS.equals(property)) {
- fMarkMethodExitPoints= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_BREAK_CONTINUE_TARGETS.equals(property)) {
- fMarkBreakContinueTargets= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_MARK_IMPLEMENTORS.equals(property)) {
- fMarkImplementors= newBooleanValue;
- return;
- }
- if (PreferenceConstants.EDITOR_STICKY_OCCURRENCES.equals(property)) {
- fStickyOccurrenceAnnotations= newBooleanValue;
- return;
+ switch (property) {
+ case PreferenceConstants.EDITOR_MARK_TYPE_OCCURRENCES:
+ fMarkTypeOccurrences= newBooleanValue;
+ return;
+ case PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES:
+ fMarkMethodOccurrences= newBooleanValue;
+ return;
+ case PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES:
+ fMarkConstantOccurrences= newBooleanValue;
+ return;
+ case PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES:
+ fMarkFieldOccurrences= newBooleanValue;
+ return;
+ case PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES:
+ fMarkLocalVariableypeOccurrences= newBooleanValue;
+ return;
+ case PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES:
+ fMarkExceptions= newBooleanValue;
+ return;
+ case PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS:
+ fMarkMethodExitPoints= newBooleanValue;
+ return;
+ case PreferenceConstants.EDITOR_MARK_BREAK_CONTINUE_TARGETS:
+ fMarkBreakContinueTargets= newBooleanValue;
+ return;
+ case PreferenceConstants.EDITOR_MARK_IMPLEMENTORS:
+ fMarkImplementors= newBooleanValue;
+ return;
+ case PreferenceConstants.EDITOR_STICKY_OCCURRENCES:
+ fStickyOccurrenceAnnotations= newBooleanValue;
+ return;
+ default:
+ break;
}
if (SemanticHighlightings.affectsEnablement(getPreferenceStore(), event)) {
if (isSemanticHighlightingEnabled())
@@ -2976,35 +2970,34 @@ public abstract class JavaEditor extends AbstractDecoratedTextEditor implements
return;
}
- if (PreferenceConstants.EDITOR_FOLDING_PROVIDER.equals(property)) {
- if (sourceViewer instanceof ProjectionViewer) {
- ProjectionViewer projectionViewer= (ProjectionViewer) sourceViewer;
- if (fProjectionModelUpdater != null)
- fProjectionModelUpdater.uninstall();
- // either freshly enabled or provider changed
- fProjectionModelUpdater= JavaPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
- if (fProjectionModelUpdater != null) {
- fProjectionModelUpdater.install(this, projectionViewer);
+ switch (property) {
+ case PreferenceConstants.EDITOR_FOLDING_PROVIDER:
+ if (sourceViewer instanceof ProjectionViewer) {
+ ProjectionViewer projectionViewer= (ProjectionViewer) sourceViewer;
+ if (fProjectionModelUpdater != null)
+ fProjectionModelUpdater.uninstall();
+ // either freshly enabled or provider changed
+ fProjectionModelUpdater= JavaPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
+ if (fProjectionModelUpdater != null) {
+ fProjectionModelUpdater.install(this, projectionViewer);
+ }
}
- }
- return;
- }
-
- if (DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE.equals(property)
- || DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE.equals(property)
- || DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR.equals(property)) {
- StyledText textWidget= sourceViewer.getTextWidget();
- int tabWidth= getSourceViewerConfiguration().getTabWidth(sourceViewer);
- if (textWidget.getTabs() != tabWidth)
- textWidget.setTabs(tabWidth);
- return;
- }
-
- if (PreferenceConstants.EDITOR_FOLDING_ENABLED.equals(property)) {
- if (sourceViewer instanceof ProjectionViewer) {
- new ToggleFoldingRunner().runWhenNextVisible();
- }
- return;
+ return;
+ case DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE:
+ case DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE:
+ case DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR:
+ StyledText textWidget= sourceViewer.getTextWidget();
+ int tabWidth= getSourceViewerConfiguration().getTabWidth(sourceViewer);
+ if (textWidget.getTabs() != tabWidth)
+ textWidget.setTabs(tabWidth);
+ return;
+ case PreferenceConstants.EDITOR_FOLDING_ENABLED:
+ if (sourceViewer instanceof ProjectionViewer) {
+ new ToggleFoldingRunner().runWhenNextVisible();
+ }
+ return;
+ default:
+ break;
}
} finally {
@@ -3016,7 +3009,7 @@ public abstract class JavaEditor extends AbstractDecoratedTextEditor implements
Object newValue= event.getNewValue();
ISourceViewer viewer= getSourceViewer();
if (newValue != null && viewer != null) {
- if (Boolean.valueOf(newValue.toString()).booleanValue()) {
+ if (Boolean.parseBoolean(newValue.toString())) {
// adjust the highlightrange in order to get the magnet right after changing the selection
Point selection= viewer.getSelectedRange();
adjustHighlightRange(selection.x, selection.y);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementDeclaredTypeHyperlink.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementDeclaredTypeHyperlink.java
index f75f4788ae..1d1680e63f 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementDeclaredTypeHyperlink.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementDeclaredTypeHyperlink.java
@@ -128,26 +128,32 @@ public class JavaElementDeclaredTypeHyperlink implements IHyperlink {
}
}
int kind= Signature.getTypeSignatureKind(typeSignature);
- if (kind == Signature.ARRAY_TYPE_SIGNATURE) {
- typeSignature= Signature.getElementType(typeSignature);
- } else if (kind == Signature.CLASS_TYPE_SIGNATURE) {
- typeSignature= Signature.getTypeErasure(typeSignature);
- } else if (kind == Signature.UNION_TYPE_SIGNATURE) {
- ArrayList<IType> types= new ArrayList<>();
- for (String typeBound : Signature.getUnionTypeBounds(typeSignature)) {
- String typeErasure= Signature.getTypeErasure(typeBound);
- IType type= getType(typeErasure);
- if (type != null) {
- types.add(type);
+ switch (kind) {
+ case Signature.ARRAY_TYPE_SIGNATURE:
+ typeSignature= Signature.getElementType(typeSignature);
+ break;
+ case Signature.CLASS_TYPE_SIGNATURE:
+ typeSignature= Signature.getTypeErasure(typeSignature);
+ break;
+ case Signature.UNION_TYPE_SIGNATURE:
+ ArrayList<IType> types= new ArrayList<>();
+ for (String typeBound : Signature.getUnionTypeBounds(typeSignature)) {
+ String typeErasure= Signature.getTypeErasure(typeBound);
+ IType type= getType(typeErasure);
+ if (type != null) {
+ types.add(type);
+ }
}
- }
- if (types.size() > 0) {
- IJavaElement element= SelectionConverter.selectJavaElement(types.toArray(new IType[types.size()]), fOpenAction.getShell(), ActionMessages.OpenAction_error_title, ActionMessages.OpenAction_select_element);
- if (element != null) {
- fOpenAction.run(new StructuredSelection(element));
+ if (types.size() > 0) {
+ IJavaElement element= SelectionConverter.selectJavaElement(types.toArray(new IType[types.size()]), fOpenAction.getShell(), ActionMessages.OpenAction_error_title, ActionMessages.OpenAction_select_element);
+ if (element != null) {
+ fOpenAction.run(new StructuredSelection(element));
+ }
+ return;
}
- return;
- }
+ break;
+ default:
+ break;
}
IType type= getType(typeSignature);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSourceViewer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSourceViewer.java
index b834cb65d4..6711a95652 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSourceViewer.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSourceViewer.java
@@ -204,14 +204,16 @@ public class JavaSourceViewer extends ProjectionViewer implements IPropertyChang
*/
@Override
public boolean canDoOperation(int operation) {
- if (operation == SHOW_OUTLINE)
- return fOutlinePresenter != null;
- if (operation == OPEN_STRUCTURE)
- return fStructurePresenter != null;
- if (operation == SHOW_HIERARCHY)
- return fHierarchyPresenter != null;
-
- return super.canDoOperation(operation);
+ switch (operation) {
+ case SHOW_OUTLINE:
+ return fOutlinePresenter != null;
+ case OPEN_STRUCTURE:
+ return fStructurePresenter != null;
+ case SHOW_HIERARCHY:
+ return fHierarchyPresenter != null;
+ default:
+ return super.canDoOperation(operation);
+ }
}
/*
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDetails.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDetails.java
index 635e993043..3248358f00 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDetails.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDetails.java
@@ -324,12 +324,6 @@ class BreadcrumbItemDetails {
}
break;
case SWT.ARROW_DOWN:
- if (!fSelected) {
- viewer.selectItem(fParent);
- }
- openDropDown();
- e.doit= false;
- break;
case SWT.KEYPAD_ADD:
if (!fSelected) {
viewer.selectItem(fParent);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDropDown.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDropDown.java
index 55218e105a..d5f83fb817 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDropDown.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/breadcrumb/BreadcrumbItemDropDown.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 IBM Corporation and others.
+ * Copyright (c) 2008, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -124,14 +124,24 @@ class BreadcrumbItemDropDown {
image.dispose();
int zoomedArrowSize= ARROW_SIZE * zoom / 100;
for (int y1= 0; y1 < zoomedArrowSize; y1++) {
+ // set opaque pixels for top half of the breadcrumb arrow
for (int x1= 0; x1 <= y1; x1++) {
imageData.setAlpha(fLTR ? x1 : zoomedArrowSize - x1 - 1, y1, 255);
}
+ // set transparent pixels for top half of the breadcrumbe arrow
+ for (int x1= y1+1; x1 < zoomedArrowSize; x1++) {
+ imageData.setAlpha(fLTR ? x1 : zoomedArrowSize - x1 - 1, y1, 0);
+ }
}
for (int y2= 0; y2 < zoomedArrowSize; y2++) {
+ // set opaque pixels for bottom half of the breadcrumb arrow
for (int x2= 0; x2 <= y2; x2++) {
imageData.setAlpha(fLTR ? x2 : zoomedArrowSize - x2 - 1, zoomedArrowSize * 2 - y2 - 1, 255);
}
+ // set transparent pixels for bottom half of the breadcrumbe arrow
+ for (int x2= y2+1; x2 < zoomedArrowSize; x2++) {
+ imageData.setAlpha(fLTR ? x2 : zoomedArrowSize - x2 - 1, zoomedArrowSize * 2 - y2 - 1, 0);
+ }
}
return imageData;
};
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/navigator/PackageExplorerOpenActionProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/navigator/PackageExplorerOpenActionProvider.java
index f5f29b1374..c30452655c 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/navigator/PackageExplorerOpenActionProvider.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/navigator/PackageExplorerOpenActionProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * Copyright (c) 2003, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.jdt.internal.ui.navigator;
-import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.TreeViewer;
@@ -29,59 +28,59 @@ import org.eclipse.jdt.ui.actions.OpenAction;
import org.eclipse.jdt.ui.actions.OpenEditorActionGroup;
public class PackageExplorerOpenActionProvider extends CommonActionProvider {
-
-
- private IAction fOpenAndExpand;
+ private OpenAndExpand fOpenAndExpand;
private OpenEditorActionGroup fOpenGroup;
- private boolean fInViewPart = false;
+ private boolean fInViewPart;
@Override
public void fillActionBars(IActionBars actionBars) {
if (fInViewPart) {
fOpenGroup.fillActionBars(actionBars);
- if (fOpenAndExpand == null && fOpenGroup.getOpenAction().isEnabled()) // TODO: is not updated!
+ if (fOpenAndExpand == null && fOpenGroup.getOpenAction().isEnabled()) {
actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, fOpenGroup.getOpenAction());
- else if (fOpenAndExpand != null && fOpenAndExpand.isEnabled())
- actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, fOpenAndExpand);
+ } else if (fOpenAndExpand != null) {
+ // Enabling will be updated on selection change however the fillActionBars can also be triggered
+ // from selection change listener and might run before action enabling is matching the current selection
+ fOpenAndExpand.update(fOpenAndExpand.getSelection());
+ if (fOpenAndExpand.isEnabled()) {
+ actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, fOpenAndExpand);
+ }
+ }
}
-
}
@Override
public void fillContextMenu(IMenuManager menu) {
-
- if (fInViewPart) {
- if (fOpenGroup.getOpenAction().isEnabled()) {
- fOpenGroup.fillContextMenu(menu);
- }
+ if (fInViewPart && fOpenGroup.getOpenAction().isEnabled()) {
+ fOpenGroup.fillContextMenu(menu);
}
}
@Override
public void init(ICommonActionExtensionSite site) {
-
ICommonViewerWorkbenchSite workbenchSite = null;
- if (site.getViewSite() instanceof ICommonViewerWorkbenchSite)
+ if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) {
workbenchSite = (ICommonViewerWorkbenchSite) site.getViewSite();
+ }
- if (workbenchSite != null) {
- if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
- IViewPart viewPart = (IViewPart) workbenchSite.getPart();
+ if (workbenchSite != null && workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
+ IViewPart viewPart = (IViewPart) workbenchSite.getPart();
- fOpenGroup = new OpenEditorActionGroup(viewPart);
+ fOpenGroup = new OpenEditorActionGroup(viewPart);
- if (site.getStructuredViewer() instanceof TreeViewer)
- fOpenAndExpand = new OpenAndExpand(workbenchSite.getSite(), (OpenAction) fOpenGroup.getOpenAction(), (TreeViewer) site.getStructuredViewer());
- fInViewPart = true;
+ if (site.getStructuredViewer() instanceof TreeViewer) {
+ fOpenAndExpand = new OpenAndExpand(workbenchSite.getSite(), (OpenAction) fOpenGroup.getOpenAction(), (TreeViewer) site.getStructuredViewer());
}
+ fInViewPart = true;
}
}
@Override
public void setContext(ActionContext context) {
super.setContext(context);
+
if (fInViewPart) {
fOpenGroup.setContext(context);
}
@@ -93,9 +92,10 @@ public class PackageExplorerOpenActionProvider extends CommonActionProvider {
*/
@Override
public void dispose() {
- if (fOpenGroup != null)
+ if (fOpenGroup != null) {
fOpenGroup.dispose();
+ }
+
super.dispose();
}
-
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/HierarchicalDecorationContext.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/HierarchicalDecorationContext.java
index 4023d613bd..ccddb339d8 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/HierarchicalDecorationContext.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/HierarchicalDecorationContext.java
@@ -88,4 +88,7 @@ public class HierarchicalDecorationContext {
};
}
}
+
+ private HierarchicalDecorationContext() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/WorkingSetAwareContentProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/WorkingSetAwareContentProvider.java
index aa89eca6a0..99b238e329 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/WorkingSetAwareContentProvider.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/WorkingSetAwareContentProvider.java
@@ -213,12 +213,18 @@ public class WorkingSetAwareContentProvider extends PackageExplorerContentProvid
String property= event.getProperty();
Object newValue= event.getNewValue();
List<Object> toRefresh= new ArrayList<>(1);
- if (WorkingSetModel.CHANGE_WORKING_SET_MODEL_CONTENT.equals(property)) {
- toRefresh.add(fWorkingSetModel);
- } else if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) {
- toRefresh.add(newValue);
- } else if (IWorkingSetManager.CHANGE_WORKING_SET_LABEL_CHANGE.equals(property)) {
- toRefresh.add(newValue);
+ if (property != null) {
+ switch (property) {
+ case WorkingSetModel.CHANGE_WORKING_SET_MODEL_CONTENT:
+ toRefresh.add(fWorkingSetModel);
+ break;
+ case IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE:
+ case IWorkingSetManager.CHANGE_WORKING_SET_LABEL_CHANGE:
+ toRefresh.add(newValue);
+ break;
+ default:
+ break;
+ }
}
ArrayList<Runnable> runnables= new ArrayList<>();
postRefresh(toRefresh, true, runnables);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java
index 2b0b22fe51..eb362cfb4b 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -81,7 +81,6 @@ class CodeAssistConfigurationBlock extends OptionsConfigurationBlock {
private static final Key PREF_CODEASSIST_PREFIX_COMPLETION= getJDTUIKey(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION);
private static final Key PREF_CODEASSIST_DEPRECATION_CHECK= getJDTCoreKey(JavaCore.CODEASSIST_DEPRECATION_CHECK);
private static final Key PREF_CODEASSIST_CAMEL_CASE_MATCH= getJDTCoreKey(JavaCore.CODEASSIST_CAMEL_CASE_MATCH);
- private static final Key PREF_CODEASSIST_SUBSTRING_MATCH= getJDTCoreKey(JavaCore.CODEASSIST_SUBSTRING_MATCH);
private static final Key PREF_CODEASSIST_SUBWORD_MATCH= getJDTCoreKey(JavaCore.CODEASSIST_SUBWORD_MATCH);
private static Key[] getAllKeys() {
@@ -102,7 +101,6 @@ class CodeAssistConfigurationBlock extends OptionsConfigurationBlock {
PREF_CODEASSIST_PREFIX_COMPLETION,
PREF_CODEASSIST_DEPRECATION_CHECK,
PREF_CODEASSIST_CAMEL_CASE_MATCH,
- PREF_CODEASSIST_SUBSTRING_MATCH,
PREF_CODEASSIST_SUBWORD_MATCH,
PREF_CODEASSIST_DISABLE_COMPLETION_PROPOSAL_TRIGGER_CHARS
};
@@ -284,9 +282,6 @@ class CodeAssistConfigurationBlock extends OptionsConfigurationBlock {
label= PreferencesMessages.CodeAssistConfigurationBlock_matchCamelCase_label;
addCheckBox(composite, label, PREF_CODEASSIST_CAMEL_CASE_MATCH, enabledDisabled, 0);
- label= PreferencesMessages.CodeAssistConfigurationBlock_matchSubstring_label;
- addCheckBox(composite, label, PREF_CODEASSIST_SUBSTRING_MATCH, enabledDisabled, 0);
-
label= PreferencesMessages.CodeAssistConfigurationBlock_matchSubword_label;
addCheckBox(composite, label, PREF_CODEASSIST_SUBWORD_MATCH, enabledDisabled, 0);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistFavoritesConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistFavoritesConfigurationBlock.java
index 2a69d8e954..c5a5ef5569 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistFavoritesConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistFavoritesConfigurationBlock.java
@@ -208,7 +208,7 @@ class CodeAssistFavoritesConfigurationBlock extends OptionsConfigurationBlock {
if (newText.length() == 0) {
status.setError(""); //$NON-NLS-1$
} else {
- IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
+ IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3, null);
if (val.matches(IStatus.ERROR)) {
if (fIsEditingMember)
status.setError(PreferencesMessages.FavoriteStaticMemberInputDialog_error_invalidMemberName);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeTemplateBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeTemplateBlock.java
index e3fdd5f40b..a07b7ffa6f 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeTemplateBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeTemplateBlock.java
@@ -159,48 +159,53 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
TemplatePersistenceData data= (TemplatePersistenceData) element;
String id= data.getId();
- if (CodeTemplateContextType.NEWTYPE_ID.equals(id)) {
- return 101;
- } else if (CodeTemplateContextType.CLASSBODY_ID.equals(id)) {
- return 102;
- } else if (CodeTemplateContextType.INTERFACEBODY_ID.equals(id)) {
- return 103;
- } else if (CodeTemplateContextType.ENUMBODY_ID.equals(id)) {
- return 104;
- } else if (CodeTemplateContextType.ANNOTATIONBODY_ID.equals(id)) {
- return 105;
- } else if (CodeTemplateContextType.METHODSTUB_ID.equals(id)) {
- return 106;
- } else if (CodeTemplateContextType.CONSTRUCTORSTUB_ID.equals(id)) {
- return 107;
- } else if (CodeTemplateContextType.GETTERSTUB_ID.equals(id)) {
- return 108;
- } else if (CodeTemplateContextType.SETTERSTUB_ID.equals(id)) {
- return 109;
- } else if (CodeTemplateContextType.CATCHBLOCK_ID.equals(id)) {
- return 110;
- } else if (CodeTemplateContextType.RECORDBODY_ID.equals(id)) {
- return 111;
- } else if (CodeTemplateContextType.FILECOMMENT_ID.equals(id)) {
- return 1;
- } else if (CodeTemplateContextType.TYPECOMMENT_ID.equals(id)) {
- return 2;
- } else if (CodeTemplateContextType.FIELDCOMMENT_ID.equals(id)) {
- return 3;
- } else if (CodeTemplateContextType.CONSTRUCTORCOMMENT_ID.equals(id)) {
- return 4;
- } else if (CodeTemplateContextType.METHODCOMMENT_ID.equals(id)) {
- return 5;
- } else if (CodeTemplateContextType.OVERRIDECOMMENT_ID.equals(id)) {
- return 6;
- } else if (CodeTemplateContextType.DELEGATECOMMENT_ID.equals(id)) {
- return 7;
- } else if (CodeTemplateContextType.GETTERCOMMENT_ID.equals(id)) {
- return 8;
- } else if (CodeTemplateContextType.SETTERCOMMENT_ID.equals(id)) {
- return 9;
- } else if (CodeTemplateContextType.MODULECOMMENT_ID.equals(id)) {
- return 10;
+ if (id != null) {
+ switch (id) {
+ case CodeTemplateContextType.NEWTYPE_ID:
+ return 101;
+ case CodeTemplateContextType.CLASSBODY_ID:
+ return 102;
+ case CodeTemplateContextType.INTERFACEBODY_ID:
+ return 103;
+ case CodeTemplateContextType.ENUMBODY_ID:
+ return 104;
+ case CodeTemplateContextType.ANNOTATIONBODY_ID:
+ return 105;
+ case CodeTemplateContextType.METHODSTUB_ID:
+ return 106;
+ case CodeTemplateContextType.CONSTRUCTORSTUB_ID:
+ return 107;
+ case CodeTemplateContextType.GETTERSTUB_ID:
+ return 108;
+ case CodeTemplateContextType.SETTERSTUB_ID:
+ return 109;
+ case CodeTemplateContextType.CATCHBLOCK_ID:
+ return 110;
+ case CodeTemplateContextType.RECORDBODY_ID:
+ return 111;
+ case CodeTemplateContextType.FILECOMMENT_ID:
+ return 1;
+ case CodeTemplateContextType.TYPECOMMENT_ID:
+ return 2;
+ case CodeTemplateContextType.FIELDCOMMENT_ID:
+ return 3;
+ case CodeTemplateContextType.CONSTRUCTORCOMMENT_ID:
+ return 4;
+ case CodeTemplateContextType.METHODCOMMENT_ID:
+ return 5;
+ case CodeTemplateContextType.OVERRIDECOMMENT_ID:
+ return 6;
+ case CodeTemplateContextType.DELEGATECOMMENT_ID:
+ return 7;
+ case CodeTemplateContextType.GETTERCOMMENT_ID:
+ return 8;
+ case CodeTemplateContextType.SETTERCOMMENT_ID:
+ return 9;
+ case CodeTemplateContextType.MODULECOMMENT_ID:
+ return 10;
+ default:
+ break;
+ }
}
return 1000;
}
@@ -221,48 +226,53 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock {
}
TemplatePersistenceData data= (TemplatePersistenceData) element;
String id=data.getId();
- if (CodeTemplateContextType.CATCHBLOCK_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_catchblock_label;
- } else if (CodeTemplateContextType.METHODSTUB_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_methodstub_label;
- } else if (CodeTemplateContextType.CONSTRUCTORSTUB_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_constructorstub_label;
- } else if (CodeTemplateContextType.GETTERSTUB_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_getterstub_label;
- } else if (CodeTemplateContextType.SETTERSTUB_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_setterstub_label;
- } else if (CodeTemplateContextType.NEWTYPE_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_newtype_label;
- } else if (CodeTemplateContextType.CLASSBODY_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_classbody_label;
- } else if (CodeTemplateContextType.INTERFACEBODY_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_interfacebody_label;
- } else if (CodeTemplateContextType.ENUMBODY_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_enumbody_label;
- } else if (CodeTemplateContextType.RECORDBODY_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_recordbody_label;
- } else if (CodeTemplateContextType.ANNOTATIONBODY_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_annotationbody_label;
- } else if (CodeTemplateContextType.FILECOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_filecomment_label;
- } else if (CodeTemplateContextType.TYPECOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_typecomment_label;
- } else if (CodeTemplateContextType.FIELDCOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_fieldcomment_label;
- } else if (CodeTemplateContextType.METHODCOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_methodcomment_label;
- } else if (CodeTemplateContextType.OVERRIDECOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_overridecomment_label;
- } else if (CodeTemplateContextType.DELEGATECOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_delegatecomment_label;
- } else if (CodeTemplateContextType.CONSTRUCTORCOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_constructorcomment_label;
- } else if (CodeTemplateContextType.GETTERCOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_gettercomment_label;
- } else if (CodeTemplateContextType.SETTERCOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_settercomment_label;
- } else if (CodeTemplateContextType.MODULECOMMENT_ID.equals(id)) {
- return PreferencesMessages.CodeTemplateBlock_modulecomment_label;
+ if (id != null) {
+ switch (id) {
+ case CodeTemplateContextType.CATCHBLOCK_ID:
+ return PreferencesMessages.CodeTemplateBlock_catchblock_label;
+ case CodeTemplateContextType.METHODSTUB_ID:
+ return PreferencesMessages.CodeTemplateBlock_methodstub_label;
+ case CodeTemplateContextType.CONSTRUCTORSTUB_ID:
+ return PreferencesMessages.CodeTemplateBlock_constructorstub_label;
+ case CodeTemplateContextType.GETTERSTUB_ID:
+ return PreferencesMessages.CodeTemplateBlock_getterstub_label;
+ case CodeTemplateContextType.SETTERSTUB_ID:
+ return PreferencesMessages.CodeTemplateBlock_setterstub_label;
+ case CodeTemplateContextType.NEWTYPE_ID:
+ return PreferencesMessages.CodeTemplateBlock_newtype_label;
+ case CodeTemplateContextType.CLASSBODY_ID:
+ return PreferencesMessages.CodeTemplateBlock_classbody_label;
+ case CodeTemplateContextType.INTERFACEBODY_ID:
+ return PreferencesMessages.CodeTemplateBlock_interfacebody_label;
+ case CodeTemplateContextType.ENUMBODY_ID:
+ return PreferencesMessages.CodeTemplateBlock_enumbody_label;
+ case CodeTemplateContextType.RECORDBODY_ID:
+ return PreferencesMessages.CodeTemplateBlock_recordbody_label;
+ case CodeTemplateContextType.ANNOTATIONBODY_ID:
+ return PreferencesMessages.CodeTemplateBlock_annotationbody_label;
+ case CodeTemplateContextType.FILECOMMENT_ID:
+ return PreferencesMessages.CodeTemplateBlock_filecomment_label;
+ case CodeTemplateContextType.TYPECOMMENT_ID:
+ return PreferencesMessages.CodeTemplateBlock_typecomment_label;
+ case CodeTemplateContextType.FIELDCOMMENT_ID:
+ return PreferencesMessages.CodeTemplateBlock_fieldcomment_label;
+ case CodeTemplateContextType.METHODCOMMENT_ID:
+ return PreferencesMessages.CodeTemplateBlock_methodcomment_label;
+ case CodeTemplateContextType.OVERRIDECOMMENT_ID:
+ return PreferencesMessages.CodeTemplateBlock_overridecomment_label;
+ case CodeTemplateContextType.DELEGATECOMMENT_ID:
+ return PreferencesMessages.CodeTemplateBlock_delegatecomment_label;
+ case CodeTemplateContextType.CONSTRUCTORCOMMENT_ID:
+ return PreferencesMessages.CodeTemplateBlock_constructorcomment_label;
+ case CodeTemplateContextType.GETTERCOMMENT_ID:
+ return PreferencesMessages.CodeTemplateBlock_gettercomment_label;
+ case CodeTemplateContextType.SETTERCOMMENT_ID:
+ return PreferencesMessages.CodeTemplateBlock_settercomment_label;
+ case CodeTemplateContextType.MODULECOMMENT_ID:
+ return PreferencesMessages.CodeTemplateBlock_modulecomment_label;
+ default:
+ break;
+ }
}
return data.getTemplate().getDescription();
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilteredPreferenceTree.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilteredPreferenceTree.java
index dfadc2c54b..0d25fe8d39 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilteredPreferenceTree.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/FilteredPreferenceTree.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.ui.preferences;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -523,13 +524,14 @@ public class FilteredPreferenceTree {
fScrolledPageContent.setRedraw(false);
fScrolledPageContent.setReflow(false);
- ArrayList<PreferenceTreeNode<?>> bfsNodes= new ArrayList<>();
+ ArrayDeque<PreferenceTreeNode<?>> bfsNodes= new ArrayDeque<>();
if (start != null) {
bfsNodes.add(start);
} else {
bfsNodes.addAll(fRoot.getChildren());
}
- for (PreferenceTreeNode<?> node : bfsNodes) {
+ while (!bfsNodes.isEmpty()) {
+ PreferenceTreeNode<?> node= bfsNodes.remove();
bfsNodes.addAll(node.getChildren());
if (node.getControl() instanceof ExpandableComposite)
((ExpandableComposite) node.getControl()).setExpanded(expanded);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ImportOrganizeConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ImportOrganizeConfigurationBlock.java
index 3b2f608e7b..011355079e 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ImportOrganizeConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ImportOrganizeConfigurationBlock.java
@@ -428,7 +428,7 @@ public class ImportOrganizeConfigurationBlock extends OptionsConfigurationBlock
ImportOrderEntry[] importOrder= getImportOrderPreference();
int threshold= getImportNumberThreshold(PREF_ONDEMANDTHRESHOLD);
int staticThreshold= getImportNumberThreshold(PREF_STATICONDEMANDTHRESHOLD);
- boolean ignoreLowerCase= Boolean.valueOf(getValue(PREF_IGNORELOWERCASE)).booleanValue();
+ boolean ignoreLowerCase= Boolean.parseBoolean(getValue(PREF_IGNORELOWERCASE));
fOrderListField.removeAllElements();
for (ImportOrderEntry i : importOrder) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ImportOrganizeInputDialog.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ImportOrganizeInputDialog.java
index 2f98afd251..cf94191f33 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ImportOrganizeInputDialog.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ImportOrganizeInputDialog.java
@@ -224,7 +224,7 @@ public class ImportOrganizeInputDialog extends StatusDialog {
status.setError(PreferencesMessages.ImportOrganizeInputDialog_error_entryExists);
}
} else {
- IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
+ IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3, null);
if (val.matches(IStatus.ERROR)) {
status.setError(PreferencesMessages.ImportOrganizeInputDialog_error_invalidName);
} else {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorCodeMiningConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorCodeMiningConfigurationBlock.java
index 45cb853820..7e50b21c62 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorCodeMiningConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorCodeMiningConfigurationBlock.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2018, 2019 Angelo ZERR.
+ * Copyright (c) 2018, 2020 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -130,8 +130,6 @@ public class JavaEditorCodeMiningConfigurationBlock extends OptionsConfiguration
codeMiningEnabledCheckBox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- atLeastOneCheckBox.setEnabled(codeMiningEnabledCheckBox.getSelection());
- fFilteredPrefTree.setEnabled(codeMiningEnabledCheckBox.getSelection());
updateEnableStates();
}
});
@@ -207,6 +205,9 @@ public class JavaEditorCodeMiningConfigurationBlock extends OptionsConfiguration
boolean enabledCodeMining= getCheckBox(PREF_CODEMINING_ENABLED).getSelection();
if (enabledCodeMining) {
// Show references checkboxes
+ atLeastOneCheckBox.setEnabled(true);
+ fFilteredPrefTree.setEnabled(true);
+
boolean showReferences= getCheckBox(PREF_SHOW_REFERENCES).getSelection();
getCheckBox(PREF_SHOW_REFERENCES_ON_TYPES).setEnabled(showReferences);
getCheckBox(PREF_SHOW_REFERENCES_ON_FIELDS).setEnabled(showReferences);
@@ -234,7 +235,7 @@ public class JavaEditorCodeMiningConfigurationBlock extends OptionsConfiguration
return;
}
if (changedKey != null) {
- if (PREF_SHOW_REFERENCES.equals(changedKey) || PREF_SHOW_IMPLEMENTATIONS.equals(changedKey)) {
+ if (PREF_CODEMINING_ENABLED.equals(changedKey) || PREF_SHOW_REFERENCES.equals(changedKey) || PREF_SHOW_IMPLEMENTATIONS.equals(changedKey)) {
updateEnableStates();
}
} else {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferenceCache.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferenceCache.java
index 602a0810f8..deb3841133 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferenceCache.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferenceCache.java
@@ -50,12 +50,20 @@ public class MembersOrderPreferenceCache extends MembersOrderPreferenceCacheComm
public void propertyChange(PropertyChangeEvent event) {
String property= event.getProperty();
- if (PreferenceConstants.APPEARANCE_MEMBER_SORT_ORDER.equals(property)) {
- fCategoryOffsets= null;
- } else if (PreferenceConstants.APPEARANCE_VISIBILITY_SORT_ORDER.equals(property)) {
- fVisibilityOffsets= null;
- } else if (PreferenceConstants.APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER.equals(property)) {
- fSortByVisibility= fPreferenceStore.getBoolean(PreferenceConstants.APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER);
+ if (property != null) {
+ switch (property) {
+ case PreferenceConstants.APPEARANCE_MEMBER_SORT_ORDER:
+ fCategoryOffsets= null;
+ break;
+ case PreferenceConstants.APPEARANCE_VISIBILITY_SORT_ORDER:
+ fVisibilityOffsets= null;
+ break;
+ case PreferenceConstants.APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER:
+ fSortByVisibility= fPreferenceStore.getBoolean(PreferenceConstants.APPEARANCE_ENABLE_VISIBILITY_SORT_ORDER);
+ break;
+ default:
+ break;
+ }
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferencePage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferencePage.java
index 00be417a2a..43ef473138 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferencePage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/MembersOrderPreferencePage.java
@@ -305,6 +305,7 @@ public class MembersOrderPreferencePage extends PreferencePage implements IWorkb
descriptor= new JavaElementImageDescriptor(descriptor, JavaElementImageDescriptor.CONSTRUCTOR, JavaElementImageProvider.SMALL_SIZE);
break;
case METHODS:
+ case INIT:
descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, visibility);
break;
case STATIC_FIELDS:
@@ -312,14 +313,7 @@ public class MembersOrderPreferencePage extends PreferencePage implements IWorkb
//add a static fields adornment to the image descriptor
descriptor= new JavaElementImageDescriptor(descriptor, JavaElementImageDescriptor.STATIC, JavaElementImageProvider.SMALL_SIZE);
break;
- case STATIC_METHODS:
- descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, visibility);
- //add a static methods adornment to the image descriptor
- descriptor= new JavaElementImageDescriptor(descriptor, JavaElementImageDescriptor.STATIC, JavaElementImageProvider.SMALL_SIZE);
- break;
- case INIT:
- descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, visibility);
- break;
+ case STATIC_METHODS://add a static methods adornment to the image descriptor
case STATIC_INIT:
descriptor= JavaElementImageProvider.getMethodImageDescriptor(false, visibility);
descriptor= new JavaElementImageDescriptor(descriptor, JavaElementImageDescriptor.STATIC, JavaElementImageProvider.SMALL_SIZE);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/NameConventionConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/NameConventionConfigurationBlock.java
index 7b2130a279..a92dd5b18d 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/NameConventionConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/NameConventionConfigurationBlock.java
@@ -242,7 +242,6 @@ public class NameConventionConfigurationBlock extends OptionsConfigurationBlock
case STATIC_FINAL:
return registry.get(new JavaElementImageDescriptor(JavaPluginImages.DESC_FIELD_PUBLIC, JavaElementImageDescriptor.STATIC | JavaElementImageDescriptor.FINAL, JavaElementImageProvider.SMALL_SIZE));
case ARGUMENT:
- return registry.get(JavaPluginImages.DESC_OBJS_LOCAL_VARIABLE);
default:
return registry.get(JavaPluginImages.DESC_OBJS_LOCAL_VARIABLE);
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/NewJavaProjectPreferencePage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/NewJavaProjectPreferencePage.java
index 0fc02032b1..94d01c038f 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/NewJavaProjectPreferencePage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/NewJavaProjectPreferencePage.java
@@ -150,7 +150,7 @@ public class NewJavaProjectPreferencePage extends PreferencePage implements IWor
IPath path= decodePath(tok.nextToken());
IPath attachPath= decodePath(tok.nextToken());
IPath attachRoot= decodePath(tok.nextToken());
- boolean isExported= Boolean.valueOf(tok.nextToken()).booleanValue();
+ boolean isExported= Boolean.parseBoolean(tok.nextToken());
switch (kind) {
case IClasspathEntry.CPE_SOURCE:
res.add(JavaCore.newSourceEntry(path));
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/OptionsConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/OptionsConfigurationBlock.java
index 12d90ade1b..9105569159 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/OptionsConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/OptionsConfigurationBlock.java
@@ -910,7 +910,7 @@ public abstract class OptionsConfigurationBlock {
protected boolean getBooleanValue(Key key) {
- return Boolean.valueOf(getValue(key)).booleanValue();
+ return Boolean.parseBoolean(getValue(key));
}
/**
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java
index b8afa2bedf..103839ea6c 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java
@@ -834,7 +834,6 @@ public final class PreferencesMessages extends NLS {
public static String JavaBasePreferencePage_do_not_hide_dialog_title;
public static String JavaBasePreferencePage_do_not_hide_dialog_message;
public static String CodeAssistConfigurationBlock_matchCamelCase_label;
- public static String CodeAssistConfigurationBlock_matchSubstring_label;
public static String CodeAssistConfigurationBlock_matchSubword_label;
public static String ComplianceConfigurationBlock_version16;
public static String ComplianceConfigurationBlock_version17;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties
index b587e837fc..db830262ed 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties
@@ -934,7 +934,6 @@ SmartTypingConfigurationBlock_annotationReporting_link=Also see the <a href="org
CodeAssistConfigurationBlock_insertionSection_title=Insertion
CodeAssistConfigurationBlock_sortingSection_title=Sorting and Filtering
CodeAssistConfigurationBlock_matchCamelCase_label=Show ca&mel case matches
-CodeAssistConfigurationBlock_matchSubstring_label=Show su&bstring matches
CodeAssistConfigurationBlock_matchSubword_label=Show subword mat&ches
CodeAssistConfigurationBlock_autoactivationSection_title=Auto Activation
# do not translate the href argument (org.eclipse.jdt.ui.preferences.ProblemSeveritiesPreferencePage)
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java
index e82c5e7c5f..1b67767a64 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java
@@ -1422,7 +1422,7 @@ public class ProblemSeveritiesConfigurationBlock extends OptionsConfigurationBlo
StatusInfo status= new StatusInfo();
if (value.isEmpty() && !isTypeMandatory)
return status;
- if (JavaConventions.validateJavaTypeName(value, JavaCore.VERSION_1_5, JavaCore.VERSION_1_5).matches(IStatus.ERROR)
+ if (JavaConventions.validateJavaTypeName(value, JavaCore.VERSION_1_5, JavaCore.VERSION_1_5, null).matches(IStatus.ERROR)
|| value.indexOf('.') == -1) {
status.setError(errorMessage);
} else if (fProject != null) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/SmartTypingConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/SmartTypingConfigurationBlock.java
index 92550b9ac2..582ab31df8 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/SmartTypingConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/SmartTypingConfigurationBlock.java
@@ -283,14 +283,18 @@ class SmartTypingConfigurationBlock extends AbstractConfigurationBlock {
private String getIndentMode() {
String indentMode= JavaPlugin.getDefault().getCombinedPreferenceStore().getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
- if (JavaCore.SPACE.equals(indentMode))
- return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_spaces;
-
- if (JavaCore.TAB.equals(indentMode))
- return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tabs;
-
- if (DefaultCodeFormatterConstants.MIXED.equals(indentMode))
- return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tabsAndSpaces;
+ if (indentMode != null) {
+ switch (indentMode) {
+ case JavaCore.SPACE:
+ return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_spaces;
+ case JavaCore.TAB:
+ return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tabs;
+ case DefaultCodeFormatterConstants.MIXED:
+ return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tabsAndSpaces;
+ default:
+ break;
+ }
+ }
Assert.isTrue(false, "Illegal indent mode - must not happen"); //$NON-NLS-1$
return null;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/TodoTaskConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/TodoTaskConfigurationBlock.java
index dff49068cf..2f1714cfbe 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/TodoTaskConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/TodoTaskConfigurationBlock.java
@@ -100,12 +100,17 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
}
return name;
} else {
- if (PRIORITY_HIGH.equals(task.priority)) {
- return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority;
- } else if (PRIORITY_NORMAL.equals(task.priority)) {
- return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority;
- } else if (PRIORITY_LOW.equals(task.priority)) {
- return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority;
+ if (task.priority != null) {
+ switch (task.priority) {
+ case PRIORITY_HIGH:
+ return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority;
+ case PRIORITY_NORMAL:
+ return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority;
+ case PRIORITY_LOW:
+ return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority;
+ default:
+ break;
+ }
}
return ""; //$NON-NLS-1$
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/UserLibraryPreferencePage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/UserLibraryPreferencePage.java
index ff7a499b83..c60036f220 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/UserLibraryPreferencePage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/UserLibraryPreferencePage.java
@@ -673,7 +673,7 @@ public class UserLibraryPreferencePage extends PreferencePage implements IWorkbe
}
Element libElement= (Element) lib;
String name= libElement.getAttribute(TAG_NAME);
- boolean isSystem= Boolean.valueOf(libElement.getAttribute(TAG_SYSTEMLIBRARY)).booleanValue();
+ boolean isSystem= Boolean.parseBoolean(libElement.getAttribute(TAG_SYSTEMLIBRARY));
CPUserLibraryElement newLibrary= new CPUserLibraryElement(name, isSystem, null);
result.add(newLibrary);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/AbstractCleanUpTabPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/AbstractCleanUpTabPage.java
index 1e3f6b1467..ee07c2417e 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/AbstractCleanUpTabPage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/AbstractCleanUpTabPage.java
@@ -60,7 +60,8 @@ public abstract class AbstractCleanUpTabPage extends CleanUpTabPage {
StringBuilder buf= new StringBuilder();
for (AbstractCleanUp fPreviewCleanUp : fPreviewCleanUps) {
buf.append(fPreviewCleanUp.getPreview());
- buf.append("\n"); //$NON-NLS-1$
+ buf.append("\n"); //$NON-NLS-1$ One free line between each code sample,
+ // in most cases the preview variants should always have the same number of lines
}
return buf.toString();
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java
index 73d789a7be..8bcbb0965d 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.java
@@ -51,6 +51,7 @@ public class CleanUpMessages extends NLS {
public static String CodeFormatingTabPage_SortMembersSemanticChange_warning;
public static String CodeStyleTabPage_CheckboxName_ConvertForLoopToEnhanced;
+ public static String CodeStyleTabPage_CheckboxName_ConvertLoopOnlyIfLoopVarUsed;
public static String CodeStyleTabPage_CheckboxName_UseBlocks;
public static String CodeStyleTabPage_CheckboxName_UseFinal;
public static String CodeStyleTabPage_CheckboxName_UseFinalForFields;
@@ -119,6 +120,7 @@ public class CleanUpMessages extends NLS {
public static String UnnecessaryCodeTabPage_CheckboxName_Autoboxing;
public static String UnnecessaryCodeTabPage_CheckboxName_Unboxing;
public static String UnnecessaryCodeTabPage_CheckboxName_PushDownNegation;
+ public static String UnnecessaryCodeTabPage_CheckboxName_MergeConditionalBlocks;
public static String UnnecessaryCodeTabPage_CheckboxName_UseDirectlyMapMethod;
public static String UnnecessaryCodeTabPage_CheckboxName_RedundantModifiers;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties
index 36224fea02..d066227fba 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CleanUpMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2005, 2019 IBM Corporation and others.
+# Copyright (c) 2005, 2020 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
@@ -50,6 +50,7 @@ CodeStyleTabPage_GroupName_VariableDeclarations=Variable declarations
CodeStyleTabPage_CheckboxName_UseFinalForFields=Private &fields
CodeStyleTabPage_CheckboxName_UseFinalForLocals=&Local variables
CodeStyleTabPage_CheckboxName_ConvertForLoopToEnhanced=Conver&t 'for' loops to enhanced
+CodeStyleTabPage_CheckboxName_ConvertLoopOnlyIfLoopVarUsed=Only if loop variable used
CodeStyleTabPage_GroupName_ControlStatments=Control statements
CodeStyleTabPage_RadioName_UseBlocksSpecial=Always &except for single 'return' or 'throw' statements
CodeStyleTabPage_CheckboxName_UseParentheses=Use parent&heses in expressions
@@ -59,6 +60,7 @@ CodeStyleTabPage_CheckboxName_ConvertFunctionalInterfaces=Con&vert functional in
CodeStyleTabPage_RadioName_UseLambdaWherePossible=Use lambda where possible
CodeStyleTabPage_CheckboxName_SimplifyLambdaExpressionAndMethodRefSyntax=Simplify &lambda expression and method reference syntax
CodeStyleTabPage_RadioName_UseAnonymous=Use anonymous class
+
ContributedCleanUpTabPage_ErrorPage_message=An error occurred while creating this page. See the error log for details
MemberAccessesTabPage_GroupName_NonStaticAccesses=Non static accesses
@@ -103,6 +105,7 @@ UnnecessaryCodeTabPage_CheckboxName_RedundantTypeArguments=Remove redundant type
UnnecessaryCodeTabPage_CheckboxName_Autoboxing=Use Autobo&xing (1.5 or higher)
UnnecessaryCodeTabPage_CheckboxName_Unboxing=Use Un&boxing (1.5 or higher)
UnnecessaryCodeTabPage_CheckboxName_PushDownNegation=Push d&own negation
+UnnecessaryCodeTabPage_CheckboxName_MergeConditionalBlocks=Merge &conditions of if/else if/else that have the same blocks
UnnecessaryCodeTabPage_CheckboxName_UseDirectlyMapMethod=Operate on &Maps directly
UnnecessaryCodeTabPage_CheckboxName_RedundantModifiers=R&emove redundant modifiers
UnnecessaryCodeTabPage_CheckboxName_RedundantModifiers_description=Removes unnecessary modifiers on fields and methods
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeStyleTabPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeStyleTabPage.java
index 929b40432d..d2cab49268 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeStyleTabPage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/CodeStyleTabPage.java
@@ -64,6 +64,9 @@ public final class CodeStyleTabPage extends AbstractCleanUpTabPage {
CheckboxPreference convertLoop= createCheckboxPref(controlGroup, numColumns, CleanUpMessages.CodeStyleTabPage_CheckboxName_ConvertForLoopToEnhanced, CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_TO_ENHANCED, CleanUpModifyDialog.FALSE_TRUE);
registerPreference(convertLoop);
+ intent(controlGroup);
+ final CheckboxPreference convertLoopOnlyIfLoopVariableUsed= createCheckboxPref(controlGroup, 1, CleanUpMessages.CodeStyleTabPage_CheckboxName_ConvertLoopOnlyIfLoopVarUsed, CleanUpConstants.CONTROL_STATMENTS_CONVERT_FOR_LOOP_ONLY_IF_LOOP_VAR_USED, CleanUpModifyDialog.FALSE_TRUE);
+ registerSlavePreference(convertLoop, new CheckboxPreference[] {convertLoopOnlyIfLoopVariableUsed});
Group expressionsGroup= createGroup(numColumns, composite, CleanUpMessages.CodeStyleTabPage_GroupName_Expressions);
@@ -72,8 +75,7 @@ public final class CodeStyleTabPage extends AbstractCleanUpTabPage {
final RadioPreference useParenthesesAlwaysPref= createRadioPref(expressionsGroup, 1, CleanUpMessages.CodeStyleTabPage_RadioName_AlwaysUseParantheses, CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_ALWAYS, CleanUpModifyDialog.FALSE_TRUE);
final RadioPreference useParenthesesNeverPref= createRadioPref(expressionsGroup, 1, CleanUpMessages.CodeStyleTabPage_RadioName_NeverUseParantheses, CleanUpConstants.EXPRESSIONS_USE_PARENTHESES_NEVER, CleanUpModifyDialog.FALSE_TRUE);
registerSlavePreference(useParenthesesPref, new RadioPreference[] {useParenthesesAlwaysPref, useParenthesesNeverPref});
- intent(expressionsGroup);
- final CheckboxPreference useLazyLogicalPref= createCheckboxPref(expressionsGroup, 1, CleanUpMessages.CodeStyleTabPage_CheckboxName_UseLazyLogicalOperator,
+ final CheckboxPreference useLazyLogicalPref= createCheckboxPref(expressionsGroup, numColumns, CleanUpMessages.CodeStyleTabPage_CheckboxName_UseLazyLogicalOperator,
CleanUpConstants.USE_LAZY_LOGICAL_OPERATOR, CleanUpModifyDialog.FALSE_TRUE);
registerPreference(useLazyLogicalPref);
@@ -91,7 +93,6 @@ public final class CodeStyleTabPage extends AbstractCleanUpTabPage {
final CheckboxPreference useFinalParametersPref= createCheckboxPref(variableGroup, 1, CleanUpMessages.CodeStyleTabPage_CheckboxName_UseFinalForParameters, CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_PARAMETERS, CleanUpModifyDialog.FALSE_TRUE);
final CheckboxPreference useFinalVariablesPref= createCheckboxPref(variableGroup, 1, CleanUpMessages.CodeStyleTabPage_CheckboxName_UseFinalForLocals, CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL_LOCAL_VARIABLES, CleanUpModifyDialog.FALSE_TRUE);
registerSlavePreference(useFinalPref, new CheckboxPreference[] {useFinalFieldsPref, useFinalParametersPref, useFinalVariablesPref});
- intent(variableGroup);
final CheckboxPreference useVarPref= createCheckboxPref(variableGroup, numColumns, CleanUpMessages.CodeStyleTabPage_CheckboxName_UseVar, CleanUpConstants.USE_VAR,
CleanUpModifyDialog.FALSE_TRUE);
registerPreference(useVarPref);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/UnnecessaryCodeTabPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/UnnecessaryCodeTabPage.java
index 252fdd5437..6a3b77aa16 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/UnnecessaryCodeTabPage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/cleanup/UnnecessaryCodeTabPage.java
@@ -23,10 +23,11 @@ import org.eclipse.jdt.internal.corext.fix.CleanUpConstants;
import org.eclipse.jdt.internal.ui.fix.AbstractCleanUp;
import org.eclipse.jdt.internal.ui.fix.AutoboxingCleanUp;
+import org.eclipse.jdt.internal.ui.fix.MapMethodCleanUp;
+import org.eclipse.jdt.internal.ui.fix.MergeConditionalBlocksCleanUp;
import org.eclipse.jdt.internal.ui.fix.PushDownNegationCleanUp;
import org.eclipse.jdt.internal.ui.fix.RedundantModifiersCleanUp;
import org.eclipse.jdt.internal.ui.fix.RedundantSemicolonsCleanUp;
-import org.eclipse.jdt.internal.ui.fix.MapMethodCleanUp;
import org.eclipse.jdt.internal.ui.fix.StringCleanUp;
import org.eclipse.jdt.internal.ui.fix.TypeParametersCleanUp;
import org.eclipse.jdt.internal.ui.fix.UnboxingCleanUp;
@@ -47,6 +48,7 @@ public final class UnnecessaryCodeTabPage extends AbstractCleanUpTabPage {
new AutoboxingCleanUp(values),
new UnboxingCleanUp(values),
new PushDownNegationCleanUp(values),
+ new MergeConditionalBlocksCleanUp(values),
new MapMethodCleanUp(values),
new RedundantModifiersCleanUp(values),
new RedundantSemicolonsCleanUp(values),
@@ -93,6 +95,9 @@ public final class UnnecessaryCodeTabPage extends AbstractCleanUpTabPage {
CleanUpModifyDialog.FALSE_TRUE);
registerPreference(pushDownNegation);
+ CheckboxPreference mergeConditionalBlocks= createCheckboxPref(unnecessaryGroup, numColumns, CleanUpMessages.UnnecessaryCodeTabPage_CheckboxName_MergeConditionalBlocks, CleanUpConstants.MERGE_CONDITIONAL_BLOCKS, CleanUpModifyDialog.FALSE_TRUE);
+ registerPreference(mergeConditionalBlocks);
+
CheckboxPreference mapMethod= createCheckboxPref(unnecessaryGroup, numColumns, CleanUpMessages.UnnecessaryCodeTabPage_CheckboxName_UseDirectlyMapMethod,
CleanUpConstants.USE_DIRECTLY_MAP_METHOD, CleanUpModifyDialog.FALSE_TRUE);
registerPreference(mapMethod);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileEscapes.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileEscapes.java
index 794cc4f823..9faf5a9c83 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileEscapes.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileEscapes.java
@@ -343,4 +343,7 @@ public class PropertiesFileEscapes {
}
return result;
}
+
+ private PropertiesFileEscapes() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileSourceViewerConfiguration.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileSourceViewerConfiguration.java
index 60553e7c59..3edd45aec3 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileSourceViewerConfiguration.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesFileSourceViewerConfiguration.java
@@ -207,12 +207,18 @@ public class PropertiesFileSourceViewerConfiguration extends TextSourceViewerCon
*/
@Override
public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
- if (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType))
- return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 0, 0, 0);
- if (IPropertiesFilePartitions.COMMENT.equals(contentType))
- return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 0, 0);
- if (IPropertiesFilePartitions.PROPERTY_VALUE.equals(contentType))
- return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 1, -1);
+ if (contentType != null) {
+ switch (contentType) {
+ case IDocument.DEFAULT_CONTENT_TYPE:
+ return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 0, 0, 0);
+ case IPropertiesFilePartitions.COMMENT:
+ return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 0, 0);
+ case IPropertiesFilePartitions.PROPERTY_VALUE:
+ return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 1, -1);
+ default:
+ break;
+ }
+ }
return super.getDoubleClickStrategy(sourceViewer, contentType);
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesQuickAssistProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesQuickAssistProcessor.java
index 2de26691b0..e3acb13d61 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesQuickAssistProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/propertiesfileeditor/PropertiesQuickAssistProcessor.java
@@ -440,4 +440,7 @@ public class PropertiesQuickAssistProcessor {
return IJavaEditorActionDefinitionIds.RENAME_ELEMENT;
}
}
+
+ private PropertiesQuickAssistProcessor() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/MatchLocations.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/MatchLocations.java
index 307ccfdd31..c013d59f51 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/MatchLocations.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/MatchLocations.java
@@ -343,16 +343,18 @@ public class MatchLocations {
}
public static int getTotalNumberOfSettings(int searchFor) {
- if (searchFor == IJavaSearchConstants.TYPE) {
- return 15;
- } else if (searchFor == IJavaSearchConstants.CONSTRUCTOR) {
- return 1;
- } else if (searchFor == IJavaSearchConstants.METHOD) {
- return 5;
- } else if (searchFor == IJavaSearchConstants.FIELD) {
- return 4;
- }
- return 0;
+ switch (searchFor) {
+ case IJavaSearchConstants.TYPE:
+ return 15;
+ case IJavaSearchConstants.CONSTRUCTOR:
+ return 1;
+ case IJavaSearchConstants.METHOD:
+ return 5;
+ case IJavaSearchConstants.FIELD:
+ return 4;
+ default:
+ return 0;
+ }
}
public static int getNumberOfSelectedSettings(int locations, int searchFor) {
@@ -425,4 +427,7 @@ public class MatchLocations {
}
return count;
}
+
+ private MatchLocations() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/PatternStrings.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/PatternStrings.java
index eb48a43220..adb66bf0f1 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/PatternStrings.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/PatternStrings.java
@@ -84,4 +84,7 @@ public class PatternStrings {
public static String getFieldSignature(IField field) {
return JavaElementLabels.getElementLabel(field, JavaElementLabels.F_FULLY_QUALIFIED);
}
+
+ private PatternStrings() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchUtil.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchUtil.java
index b7ee03e8da..42f791ca25 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchUtil.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchUtil.java
@@ -254,4 +254,7 @@ public class SearchUtil {
|| ((first == Signature.C_RESOLVED || first == Signature.C_UNRESOLVED) && fieldType.substring(1, fieldType.length() - 1).equals(String.class.getName())
|| (first == Signature.C_UNRESOLVED && fieldType.substring(1, fieldType.length() - 1).equals("String"))); //$NON-NLS-1$
}
+
+ private SearchUtil() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/ContentAssistPreference.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/ContentAssistPreference.java
index b3beb0aa2f..a6e13cc79a 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/ContentAssistPreference.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/ContentAssistPreference.java
@@ -256,5 +256,8 @@ public class ContentAssistPreference {
public static boolean fillArgumentsOnMethodCompletion(IPreferenceStore store) {
return store.getBoolean(FILL_METHOD_ARGUMENTS);
}
+
+ private ContentAssistPreference() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaHeuristicScanner.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaHeuristicScanner.java
index 0c7e26c8be..c13b508a44 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaHeuristicScanner.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaHeuristicScanner.java
@@ -466,67 +466,52 @@ public final class JavaHeuristicScanner implements Symbols {
private int getToken(String s) {
Assert.isNotNull(s);
- switch (s.length()) {
- case 2:
- if ("if".equals(s)) //$NON-NLS-1$
- return TokenIF;
- if ("do".equals(s)) //$NON-NLS-1$
- return TokenDO;
- break;
- case 3:
- if ("for".equals(s)) //$NON-NLS-1$
- return TokenFOR;
- if ("try".equals(s)) //$NON-NLS-1$
- return TokenTRY;
- if ("new".equals(s)) //$NON-NLS-1$
- return TokenNEW;
- break;
- case 4:
- if ("case".equals(s)) //$NON-NLS-1$
- return TokenCASE;
- if ("else".equals(s)) //$NON-NLS-1$
- return TokenELSE;
- if ("enum".equals(s)) //$NON-NLS-1$
- return TokenENUM;
- if ("goto".equals(s)) //$NON-NLS-1$
- return TokenGOTO;
- break;
- case 5:
- if ("break".equals(s)) //$NON-NLS-1$
- return TokenBREAK;
- if ("catch".equals(s)) //$NON-NLS-1$
- return TokenCATCH;
- if ("class".equals(s)) //$NON-NLS-1$
- return TokenCLASS;
- if ("while".equals(s)) //$NON-NLS-1$
- return TokenWHILE;
- break;
- case 6:
- if ("return".equals(s)) //$NON-NLS-1$
- return TokenRETURN;
- if ("static".equals(s)) //$NON-NLS-1$
- return TokenSTATIC;
- if ("switch".equals(s)) //$NON-NLS-1$
- return TokenSWITCH;
- if ("throws".equals(s)) //$NON-NLS-1$
- return TokenTHROWS;
- break;
- case 7:
- if ("default".equals(s)) //$NON-NLS-1$
- return TokenDEFAULT;
- if ("finally".equals(s)) //$NON-NLS-1$
- return TokenFINALLY;
- break;
- case 9:
- if ("interface".equals(s)) //$NON-NLS-1$
- return TokenINTERFACE;
- break;
- case 12:
- if ("synchronized".equals(s)) //$NON-NLS-1$
- return TokenSYNCHRONIZED;
- break;
+ switch (s) {
+ case "if": //$NON-NLS-1$
+ return TokenIF;
+ case "do": //$NON-NLS-1$
+ return TokenDO;
+ case "for": //$NON-NLS-1$
+ return TokenFOR;
+ case "try": //$NON-NLS-1$
+ return TokenTRY;
+ case "new": //$NON-NLS-1$
+ return TokenNEW;
+ case "case": //$NON-NLS-1$
+ return TokenCASE;
+ case "else": //$NON-NLS-1$
+ return TokenELSE;
+ case "enum": //$NON-NLS-1$
+ return TokenENUM;
+ case "goto": //$NON-NLS-1$
+ return TokenGOTO;
+ case "break": //$NON-NLS-1$
+ return TokenBREAK;
+ case "catch": //$NON-NLS-1$
+ return TokenCATCH;
+ case "class": //$NON-NLS-1$
+ return TokenCLASS;
+ case "while": //$NON-NLS-1$
+ return TokenWHILE;
+ case "return": //$NON-NLS-1$
+ return TokenRETURN;
+ case "static": //$NON-NLS-1$
+ return TokenSTATIC;
+ case "switch": //$NON-NLS-1$
+ return TokenSWITCH;
+ case "throws": //$NON-NLS-1$
+ return TokenTHROWS;
+ case "default": //$NON-NLS-1$
+ return TokenDEFAULT;
+ case "finally": //$NON-NLS-1$
+ return TokenFINALLY;
+ case "interface": //$NON-NLS-1$
+ return TokenINTERFACE;
+ case "synchronized": //$NON-NLS-1$
+ return TokenSYNCHRONIZED;
+ default:
+ return TokenIDENT;
}
- return TokenIDENT;
}
/**
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java
index 95bb534a05..54fc84963b 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java
@@ -1088,6 +1088,7 @@ public final class JavaIndenter {
return skipToStatementStart(danglingElse, false);
case Symbols.TokenRBRACKET:
+ case Symbols.TokenRETURN:
fIndent= fPrefs.prefContinuationIndent;
return fPosition;
@@ -1127,10 +1128,7 @@ public final class JavaIndenter {
fTokenPos = tokenPos;
return skipToPreviousListItemOrListStart();
- case Symbols.TokenRETURN:
- fIndent= fPrefs.prefContinuationIndent;
- return fPosition;
- case Symbols.TokenPLUS:
+ case Symbols.TokenPLUS:
if (isStringContinuation(fPosition)) {
try {
if (isSecondLineOfStringContinuation(offset)) {
@@ -1199,9 +1197,8 @@ public final class JavaIndenter {
fPosition= storedPos;
break;
case Symbols.TokenEOF:
- return false;
- default:
- return false;
+ default:
+ return false;
}
nextToken();
}
@@ -1247,16 +1244,14 @@ public final class JavaIndenter {
case Symbols.TokenFOR:
return true;
case Symbols.TokenLBRACE:
+ case Symbols.TokenCOLON:
+ case Symbols.TokenEOF:
return false;
case Symbols.TokenSEMICOLON:
semiColonCount++;
if (semiColonCount > 2)
return false;
break;
- case Symbols.TokenCOLON:
- return false;
- case Symbols.TokenEOF:
- return false;
}
}
}
@@ -1274,7 +1269,6 @@ public final class JavaIndenter {
case Symbols.TokenTRY:
return true;
case Symbols.TokenLBRACE:
- return false;
case Symbols.TokenEOF:
return false;
}
@@ -1817,7 +1811,6 @@ public final class JavaIndenter {
skipScope();
break;
case Symbols.TokenEOF:
- return false;
default:
return false;
}
@@ -1847,7 +1840,6 @@ public final class JavaIndenter {
skipScope();
break;
case Symbols.TokenEOF:
- return false;
default:
return false;
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaWordFinder.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaWordFinder.java
index 52ba39aa1b..0855acc519 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaWordFinder.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaWordFinder.java
@@ -113,4 +113,7 @@ public class JavaWordFinder {
return null;
}
+
+ private JavaWordFinder() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java
index 72d52cd251..785983aad7 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java
@@ -70,10 +70,6 @@ public class ASTResolving extends org.eclipse.jdt.internal.core.manipulation.dom
while (parent != null) {
switch (parent.getNodeType()) {
case ASTNode.VARIABLE_DECLARATION_FRAGMENT:
- if (((VariableDeclarationFragment) parent).getInitializer() == node) {
- return ASTNodeFactory.newType(ast, (VariableDeclaration) parent);
- }
- return null;
case ASTNode.SINGLE_VARIABLE_DECLARATION:
if (((VariableDeclarationFragment) parent).getInitializer() == node) {
return ASTNodeFactory.newType(ast, (VariableDeclaration) parent);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AdvancedQuickAssistProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AdvancedQuickAssistProcessor.java
index cf7cd2da71..fc07134958 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AdvancedQuickAssistProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AdvancedQuickAssistProcessor.java
@@ -674,10 +674,7 @@ public class AdvancedQuickAssistProcessor implements IQuickAssistProcessor {
}
if (expression instanceof ParenthesizedExpression) {
ParenthesizedExpression parenthesizedExpression= (ParenthesizedExpression) expression;
- Expression innerExpression= parenthesizedExpression.getExpression();
- while (innerExpression instanceof ParenthesizedExpression) {
- innerExpression= ((ParenthesizedExpression) innerExpression).getExpression();
- }
+ Expression innerExpression= ASTNodes.getUnparenthesedExpression(parenthesizedExpression.getExpression());
if (innerExpression instanceof InstanceofExpression) {
return getInversedExpression(rewrite, innerExpression, provider);
}
@@ -1462,9 +1459,7 @@ public class AdvancedQuickAssistProcessor implements IQuickAssistProcessor {
private static Expression combineOperands(ASTRewrite rewrite, Expression existing, Expression originalNode, boolean removeParentheses, Operator operator) {
if (existing == null && removeParentheses) {
- while (originalNode instanceof ParenthesizedExpression) {
- originalNode= ((ParenthesizedExpression)originalNode).getExpression();
- }
+ originalNode= ASTNodes.getUnparenthesedExpression(originalNode);
}
Expression newRight= (Expression)rewrite.createMoveTarget(originalNode);
if (originalNode instanceof InfixExpression) {
@@ -1944,9 +1939,7 @@ public class AdvancedQuickAssistProcessor implements IQuickAssistProcessor {
AST ast= rewrite.getAST();
ReturnStatement thenReturn= ast.newReturnStatement();
Expression cleanExpression= expression;
- while (cleanExpression instanceof ParenthesizedExpression) {
- cleanExpression= ((ParenthesizedExpression) cleanExpression).getExpression();
- }
+ cleanExpression= ASTNodes.getUnparenthesedExpression(cleanExpression);
thenReturn.setExpression((Expression) rewrite.createCopyTarget(cleanExpression));
return thenReturn;
}
@@ -1955,14 +1948,8 @@ public class AdvancedQuickAssistProcessor implements IQuickAssistProcessor {
AST ast= rewrite.getAST();
Assignment elseAssignment= ast.newAssignment();
elseAssignment.setOperator(assignmentOperator);
- Expression left= origAssignee;
- while (left instanceof ParenthesizedExpression) {
- left= ((ParenthesizedExpression) left).getExpression();
- }
- Expression right= origAssigned;
- while (right instanceof ParenthesizedExpression) {
- right= ((ParenthesizedExpression) right).getExpression();
- }
+ Expression left= ASTNodes.getUnparenthesedExpression(origAssignee);
+ Expression right= ASTNodes.getUnparenthesedExpression(origAssigned);
elseAssignment.setLeftHandSide((Expression) rewrite.createCopyTarget(left));
elseAssignment.setRightHandSide((Expression) rewrite.createCopyTarget(right));
ExpressionStatement statement= ast.newExpressionStatement(elseAssignment);
@@ -2026,10 +2013,7 @@ public class AdvancedQuickAssistProcessor implements IQuickAssistProcessor {
AST ast= node.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
// prepare new 'if' statement
- Expression expression= conditional.getExpression();
- while (expression instanceof ParenthesizedExpression) {
- expression= ((ParenthesizedExpression) expression).getExpression();
- }
+ Expression expression= ASTNodes.getUnparenthesedExpression(conditional.getExpression());
IfStatement ifStatement= ast.newIfStatement();
ifStatement.setExpression((Expression) rewrite.createCopyTarget(expression));
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ConfigureProblemSeveritySubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ConfigureProblemSeveritySubProcessor.java
index d509e97859..d930b2c06a 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ConfigureProblemSeveritySubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ConfigureProblemSeveritySubProcessor.java
@@ -87,4 +87,7 @@ public class ConfigureProblemSeveritySubProcessor {
proposals.add(proposal);
}
+
+ private ConfigureProblemSeveritySubProcessor() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/DefaultClasspathFixProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/DefaultClasspathFixProcessor.java
index 316066fa1e..74e05a48ae 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/DefaultClasspathFixProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/DefaultClasspathFixProcessor.java
@@ -169,10 +169,10 @@ public class DefaultClasspathFixProcessor extends ClasspathFixProcessor {
typeNameMatchToModuleName.put(curr, moduleName);
}
} else {
- Object typeNameMatch= classPathEntryToTypeNameMatch.get(entry);
+ TypeNameMatch typeNameMatch= classPathEntryToTypeNameMatch.get(entry);
if (typeNameMatch != null) {
if (moduleName != null) {
- Object modName= typeNameMatchToModuleName.get(typeNameMatch);
+ String modName= typeNameMatchToModuleName.get(typeNameMatch);
if (!moduleName.equals(modName)) {
// remove classpath module if there are multiple type matches
// which belong to the same class path but different modules
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/DefaultModulepathFixProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/DefaultModulepathFixProcessor.java
index e3d7b32586..6bdfc3058d 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/DefaultModulepathFixProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/DefaultModulepathFixProcessor.java
@@ -119,15 +119,6 @@ public class DefaultModulepathFixProcessor extends DefaultClasspathFixProcessor
if (classpaths.add(entry) && moduleName != null) {
classPathEntryToModuleMap.put(entry, curr);
typesWithModule.add(moduleName);
- } else {
- Object typeNameMatch= classPathEntryToModuleMap.get(entry);
- if (typeNameMatch != null) {
- if (moduleName != null) {
- if (typesWithModule.contains(moduleName)) {
- typesWithModule.remove(typeNameMatch);
- }
- }
- }
}
} catch (JavaModelException e) {
// ignore
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/GetterSetterCorrectionSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/GetterSetterCorrectionSubProcessor.java
index aa1ba41dc3..844a062809 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/GetterSetterCorrectionSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/GetterSetterCorrectionSubProcessor.java
@@ -399,4 +399,7 @@ public class GetterSetterCorrectionSubProcessor {
return result;
}
+ private GetterSetterCorrectionSubProcessor() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessor.java
index 6a8ff5851f..eae8c8cdc0 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/JavadocTagsSubProcessor.java
@@ -155,8 +155,7 @@ public class JavadocTagsSubProcessor {
CompilationUnit cu= (CompilationUnit)fDecl.getParent();
Name name= fDecl.getName();
List<Comment> comments= cu.getCommentList();
- for (int i= 0; i < comments.size(); ++i) {
- Comment comment= comments.get(i);
+ for (Comment comment : comments) {
if (comment instanceof Javadoc
&& comment.getStartPosition() + comment.getLength() < name.getStartPosition()) {
javadoc= (Javadoc)comment;
@@ -189,7 +188,7 @@ public class JavadocTagsSubProcessor {
}
}
- public static int findInsertPosition(Javadoc javadoc, @SuppressWarnings("unused") ASTNode node, IDocument document, String lineDelimiter) throws BadLocationException {
+ public static int findInsertPosition(Javadoc javadoc, ASTNode node, IDocument document, String lineDelimiter) throws BadLocationException {
int position= -1;
List<TagElement> tags= javadoc.tags();
TagElement lastTag= null;
@@ -248,8 +247,7 @@ public class JavadocTagsSubProcessor {
CompilationUnit cu= (CompilationUnit)fDecl.getParent();
Name moduleName= fDecl.getName();
List<Comment> comments= cu.getCommentList();
- for (int i= 0; i < comments.size(); ++i) {
- Comment comment= comments.get(i);
+ for (Comment comment : comments) {
if (comment instanceof Javadoc
&& comment.getStartPosition() + comment.getLength() < moduleName.getStartPosition()) {
javadoc= (Javadoc)comment;
@@ -339,17 +337,31 @@ public class JavadocTagsSubProcessor {
newTag.setTagName(TagElement.TAG_PARAM);
newTag.fragments().add(ast.newSimpleName(name));
- MethodDeclaration methodDeclaration= (MethodDeclaration) bodyDecl;
- List<SingleVariableDeclaration> params= methodDeclaration.parameters();
+ if (bodyDecl instanceof MethodDeclaration) {
+ MethodDeclaration methodDeclaration= (MethodDeclaration) bodyDecl;
+ List<SingleVariableDeclaration> params= methodDeclaration.parameters();
- Set<String> sameKindLeadingNames= getPreviousParamNames(params, decl);
+ Set<String> sameKindLeadingNames= getPreviousParamNames(params, decl);
- List<TypeParameter> typeParams= methodDeclaration.typeParameters();
- for (TypeParameter typeParam : typeParams) {
- String curr= '<' + typeParam.getName().getIdentifier() + '>';
- sameKindLeadingNames.add(curr);
+ List<TypeParameter> typeParams= methodDeclaration.typeParameters();
+ for (TypeParameter typeParam : typeParams) {
+ String curr= '<' + typeParam.getName().getIdentifier() + '>';
+ sameKindLeadingNames.add(curr);
+ }
+ insertTag(tagsRewriter, newTag, sameKindLeadingNames);
+ } else if (bodyDecl instanceof RecordDeclaration) {
+ RecordDeclaration recordDeclaration= (RecordDeclaration) bodyDecl;
+ List<SingleVariableDeclaration> params= recordDeclaration.recordComponents();
+
+ Set<String> sameKindLeadingNames= getPreviousParamNames(params, decl);
+
+ List<TypeParameter> typeParams= recordDeclaration.typeParameters();
+ for (TypeParameter typeParam : typeParams) {
+ String curr= '<' + typeParam.getName().getIdentifier() + '>';
+ sameKindLeadingNames.add(curr);
+ }
+ insertTag(tagsRewriter, newTag, sameKindLeadingNames);
}
- insertTag(tagsRewriter, newTag, sameKindLeadingNames);
} else if (location == TypeParameter.NAME_PROPERTY) {
// type parameter
TypeParameter typeParam= (TypeParameter) missingNode.getParent();
@@ -363,6 +375,8 @@ public class JavadocTagsSubProcessor {
List<TypeParameter> params;
if (bodyDecl instanceof TypeDeclaration) {
params= ((TypeDeclaration) bodyDecl).typeParameters();
+ } else if (bodyDecl instanceof RecordDeclaration) {
+ params= ((RecordDeclaration) bodyDecl).typeParameters();
} else {
params= ((MethodDeclaration) bodyDecl).typeParameters();
}
@@ -411,6 +425,8 @@ public class JavadocTagsSubProcessor {
ASTRewrite rewrite= ASTRewrite.create(fDecl.getAST());
if (fDecl instanceof MethodDeclaration) {
insertAllMissingMethodTags(rewrite, (MethodDeclaration) fDecl);
+ } else if (fDecl instanceof RecordDeclaration) {
+ insertAllMissingRecordTypeTags(rewrite, (RecordDeclaration) fDecl);
} else {
insertAllMissingTypeTags(rewrite, (TypeDeclaration) fDecl);
}
@@ -503,6 +519,42 @@ public class JavadocTagsSubProcessor {
}
}
+ private void insertAllMissingRecordTypeTags(ASTRewrite rewriter, RecordDeclaration recDecl) {
+ AST ast= recDecl.getAST();
+ Javadoc javadoc= recDecl.getJavadoc();
+ ListRewrite tagsRewriter= rewriter.getListRewrite(javadoc, Javadoc.TAGS_PROPERTY);
+
+ List<SingleVariableDeclaration> recComps= recDecl.recordComponents();
+ for (int i= recComps.size() - 1; i >= 0; i--) {
+ SingleVariableDeclaration decl= recComps.get(i);
+ String name= decl.getName().getIdentifier();
+ if (findTag(javadoc, TagElement.TAG_PARAM, name) == null) {
+ TagElement newTag= ast.newTagElement();
+ newTag.setTagName(TagElement.TAG_PARAM);
+ TextElement text= ast.newTextElement();
+ text.setText(name);
+ newTag.fragments().add(text);
+ insertTabStop(rewriter, newTag.fragments(), "recComps" + i); //$NON-NLS-1$
+ insertTag(tagsRewriter, newTag, getPreviousParamNames(recComps, decl));
+ }
+ }
+
+ List<TypeParameter> typeParams= recDecl.typeParameters();
+ for (int i= typeParams.size() - 1; i >= 0; i--) {
+ TypeParameter decl= typeParams.get(i);
+ String name= '<' + decl.getName().getIdentifier() + '>';
+ if (findTag(javadoc, TagElement.TAG_PARAM, name) == null) {
+ TagElement newTag= ast.newTagElement();
+ newTag.setTagName(TagElement.TAG_PARAM);
+ TextElement text= ast.newTextElement();
+ text.setText(name);
+ newTag.fragments().add(text);
+ insertTabStop(rewriter, newTag.fragments(), "typeParam" + i); //$NON-NLS-1$
+ insertTag(tagsRewriter, newTag, getPreviousTypeParamNames(typeParams, decl));
+ }
+ }
+ }
+
private void insertTabStop(ASTRewrite rewriter, List<ASTNode> fragments, String linkedName) {
TextElement textElement= rewriter.getAST().newTextElement();
textElement.setText(""); //$NON-NLS-1$
@@ -549,13 +601,17 @@ public class JavadocTagsSubProcessor {
if (location == SingleVariableDeclaration.NAME_PROPERTY) {
label= CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_paramtag_description;
- if (node.getParent().getLocationInParent() != MethodDeclaration.PARAMETERS_PROPERTY) {
+ StructuralPropertyDescriptor propDesc= node.getParent().getLocationInParent();
+ if (propDesc != MethodDeclaration.PARAMETERS_PROPERTY
+ && propDesc != RecordDeclaration.RECORD_COMPONENTS_PROPERTY) {
return; // paranoia checks
}
} else if (location == TypeParameter.NAME_PROPERTY) {
label= CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_paramtag_description;
StructuralPropertyDescriptor parentLocation= node.getParent().getLocationInParent();
- if (parentLocation != MethodDeclaration.TYPE_PARAMETERS_PROPERTY && parentLocation != TypeDeclaration.TYPE_PARAMETERS_PROPERTY) {
+ if (parentLocation != MethodDeclaration.TYPE_PARAMETERS_PROPERTY
+ && parentLocation != TypeDeclaration.TYPE_PARAMETERS_PROPERTY
+ && parentLocation != RecordDeclaration.TYPE_PARAMETERS_PROPERTY) {
return; // paranoia checks
}
} else if (location == MethodDeclaration.RETURN_TYPE2_PROPERTY) {
@@ -959,21 +1015,20 @@ public class JavadocTagsSubProcessor {
}
}
- @SuppressWarnings("rawtypes")
private static ASTNode findModuleJavadocTag(ModuleDeclaration decl, IProblemLocation problem) {
ASTNode result= null;
CompilationUnit cu= (CompilationUnit)decl.getParent();
int problemLocationStart= problem.getOffset();
Name moduleName= decl.getName();
- List comments= cu.getCommentList();
- for (int i= 0; i < comments.size(); ++i) {
- Comment comment= (Comment)comments.get(i);
+ List<Comment> comments= cu.getCommentList();
+
+ for (Comment comment : comments) {
if (comment instanceof Javadoc
&& comment.getStartPosition() + comment.getLength() < moduleName.getStartPosition()) {
Javadoc javadoc= (Javadoc)comment;
- List tags= javadoc.tags();
- for (Object element : tags) {
- TagElement tag= (TagElement)element;
+ List<TagElement> tags= javadoc.tags();
+
+ for (TagElement tag : tags) {
if (problemLocationStart > tag.getStartPosition()
&& problemLocationStart < tag.getStartPosition() + tag.getLength()) {
result= tag;
@@ -1007,4 +1062,7 @@ public class JavadocTagsSubProcessor {
proposals.add(proposal);
}
+
+ private JavadocTagsSubProcessor() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java
index f9ee233c93..704022d78a 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java
@@ -184,7 +184,6 @@ import org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeMethodSignatu
import org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeMethodSignatureProposal.ChangeDescription;
import org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeMethodSignatureProposal.InsertDescription;
import org.eclipse.jdt.internal.ui.text.correction.proposals.ChangeMethodSignatureProposal.RemoveDescription;
-import org.eclipse.jdt.internal.ui.util.ASTHelper;
import org.eclipse.jdt.internal.ui.text.correction.proposals.ConstructorFromSuperclassProposal;
import org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal;
import org.eclipse.jdt.internal.ui.text.correction.proposals.LinkedCorrectionProposal;
@@ -196,6 +195,7 @@ import org.eclipse.jdt.internal.ui.text.correction.proposals.NewProviderMethodDe
import org.eclipse.jdt.internal.ui.text.correction.proposals.NewVariableCorrectionProposal;
import org.eclipse.jdt.internal.ui.text.correction.proposals.RefactoringCorrectionProposal;
import org.eclipse.jdt.internal.ui.text.correction.proposals.ReplaceCorrectionProposal;
+import org.eclipse.jdt.internal.ui.util.ASTHelper;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
/**
@@ -785,10 +785,7 @@ public class LocalCorrectionsSubProcessor {
public static void addUnnecessaryInstanceofProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
- ASTNode curr= selectedNode;
- while (curr instanceof ParenthesizedExpression) {
- curr= ((ParenthesizedExpression) curr).getExpression();
- }
+ ASTNode curr= ASTNodes.getUnparenthesedExpression(selectedNode);
if (curr instanceof InstanceofExpression) {
AST ast= curr.getAST();
@@ -815,10 +812,7 @@ public class LocalCorrectionsSubProcessor {
public static void addIllegalQualifiedEnumConstantLabelProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
ASTNode coveringNode= problem.getCoveringNode(context.getASTRoot());
- ASTNode curr= coveringNode;
- while (curr instanceof ParenthesizedExpression) {
- curr= ((ParenthesizedExpression) curr).getExpression();
- }
+ ASTNode curr= ASTNodes.getUnparenthesedExpression(coveringNode);
if (!(curr instanceof QualifiedName)) {
return;
@@ -925,11 +919,7 @@ public class LocalCorrectionsSubProcessor {
CompilationUnit root= context.getASTRoot();
AST ast= root.getAST();
- ASTNode selectedNode= problem.getCoveringNode(root);
-
- while (selectedNode instanceof ParenthesizedExpression) {
- selectedNode= ((ParenthesizedExpression) selectedNode).getExpression();
- }
+ ASTNode selectedNode= ASTNodes.getUnparenthesedExpression(problem.getCoveringNode(root));
if (selectedNode instanceof PrefixExpression) {
// !x instanceof X -> !(x instanceof X)
@@ -1165,10 +1155,7 @@ public class LocalCorrectionsSubProcessor {
ASTRewrite rewrite= ASTRewrite.create(parent.getAST());
- Expression replacement= leftOperand;
- while (replacement instanceof ParenthesizedExpression) {
- replacement= ((ParenthesizedExpression) replacement).getExpression();
- }
+ Expression replacement= ASTNodes.getUnparenthesedExpression(leftOperand);
Expression toReplace= infixExpression;
while (toReplace.getLocationInParent() == ParenthesizedExpression.EXPRESSION_PROPERTY) {
@@ -2350,4 +2337,7 @@ public class LocalCorrectionsSubProcessor {
}
}
}
+
+ private LocalCorrectionsSubProcessor() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java
index 7dd7cac2f5..e852ff2fdd 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.java
@@ -461,6 +461,7 @@ public class ModifierCorrectionSubProcessor {
excludedModifiers= ~(Modifier.ABSTRACT | Modifier.FINAL | Modifier.STRICTFP);
break;
case IProblem.IllegalModifierForArgument:
+ case IProblem.IllegalModifierForVariable:
excludedModifiers= ~Modifier.FINAL;
break;
case IProblem.IllegalModifierForField:
@@ -472,9 +473,6 @@ public class ModifierCorrectionSubProcessor {
case IProblem.IllegalModifierForConstructor:
excludedModifiers= ~(Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE);
break;
- case IProblem.IllegalModifierForVariable:
- excludedModifiers= ~Modifier.FINAL;
- break;
case IProblem.IllegalModifierForEnum:
excludedModifiers= ~(Modifier.PUBLIC | Modifier.STRICTFP);
break;
@@ -945,4 +943,7 @@ public class ModifierCorrectionSubProcessor {
proposals.add(new ModifierChangeCorrectionProposal(label, cu, binding, selectedNode, modifier, 0, IProposalRelevance.ADD_METHOD_MODIFIER, image));
}
}
+
+ private ModifierCorrectionSubProcessor() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModuleCorrectionsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModuleCorrectionsSubProcessor.java
index b344f74f92..b76836a7f7 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModuleCorrectionsSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModuleCorrectionsSubProcessor.java
@@ -334,6 +334,7 @@ public class ModuleCorrectionsSubProcessor {
String[] args= null;
switch (entry.getEntryKind()) {
case IClasspathEntry.CPE_LIBRARY:
+ case IClasspathEntry.CPE_VARIABLE:
args= new String[] { JavaElementLabels.getElementLabel(root, JavaElementLabels.REFERENCED_ROOT_POST_QUALIFIED) };
break;
case IClasspathEntry.CPE_PROJECT:
@@ -356,9 +357,6 @@ public class ModuleCorrectionsSubProcessor {
args= new String[] { root.getElementName() };
}
break;
- case IClasspathEntry.CPE_VARIABLE:
- args= new String[] { JavaElementLabels.getElementLabel(root, JavaElementLabels.REFERENCED_ROOT_POST_QUALIFIED) };
- break;
default:
break;
}
@@ -396,4 +394,7 @@ public class ModuleCorrectionsSubProcessor {
return projectModule;
}
+ private ModuleCorrectionsSubProcessor() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/NameMatcher.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/NameMatcher.java
index aac30006dc..56d4118d9d 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/NameMatcher.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/NameMatcher.java
@@ -75,4 +75,7 @@ public class NameMatcher {
return Character.toLowerCase(ch1) == Character.toLowerCase(ch2);
}
+ private NameMatcher() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/NullAnnotationsCorrectionProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/NullAnnotationsCorrectionProcessor.java
index a0bb8119f0..765e244883 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/NullAnnotationsCorrectionProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/NullAnnotationsCorrectionProcessor.java
@@ -222,4 +222,7 @@ public class NullAnnotationsCorrectionProcessor {
proposals.add(new MakeLocalVariableNonNullProposal(cu, variableBinding, astRoot, IProposalRelevance.CHANGE_NULLNESS_ANNOTATION, nonNullAnnotationName));
}
}
+
+ private NullAnnotationsCorrectionProcessor() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/PreviewFeaturesSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/PreviewFeaturesSubProcessor.java
index fd1442084d..28f8d26d31 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/PreviewFeaturesSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/PreviewFeaturesSubProcessor.java
@@ -160,14 +160,17 @@ public class PreviewFeaturesSubProcessor {
CONFIGURE_COMPILER_PROBLEM_SEVERITY_DIALOG_ID, shell, JavaHoverMessages.ProblemHover_chooseCompilerSettingsTypeDialog_title, null, message, MessageDialog.QUESTION, buttons,
0, JavaHoverMessages.ProblemHover_chooseSettingsTypeDialog_checkBox_dontShowAgain);
- if (result == OptionalMessageDialog.NOT_SHOWN) {
- usePropertyPage= false;
- } else if (result == 2 || result == SWT.DEFAULT) {
- return;
- } else if (result == 0) {
- usePropertyPage= true;
- } else {
- usePropertyPage= false;
+ switch (result) {
+ case 2:
+ case SWT.DEFAULT:
+ return;
+ case 0:
+ usePropertyPage= true;
+ break;
+ case OptionalMessageDialog.NOT_SHOWN:
+ default:
+ usePropertyPage= false;
+ break;
}
} else {
usePropertyPage= true;
@@ -257,4 +260,7 @@ public class PreviewFeaturesSubProcessor {
}
return isPreviewFeatureEnabled;
}
+
+ private PreviewFeaturesSubProcessor() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
index d5c3250d73..830675d46a 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -25,11 +25,14 @@ package org.eclipse.jdt.internal.ui.text.correction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import org.eclipse.swt.graphics.Image;
@@ -903,34 +906,38 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
}
private static String[] getUniqueParameterNames(MethodReference methodReference, IMethodBinding functionalMethod) throws JavaModelException {
- String[] parameterNames= ((IMethod) functionalMethod.getJavaElement()).getParameterNames();
- List<String> oldNames= new ArrayList<>(Arrays.asList(parameterNames));
- String[] newNames= new String[oldNames.size()];
- List<String> excludedNames= new ArrayList<>(ASTNodes.getVisibleLocalVariablesInScope(methodReference));
-
- for (int i= 0; i < oldNames.size(); i++) {
- String paramName= oldNames.get(i);
- List<String> allNamesToExclude= new ArrayList<>(excludedNames);
- allNamesToExclude.addAll(oldNames.subList(0, i));
- allNamesToExclude.addAll(oldNames.subList(i + 1, oldNames.size()));
- if (allNamesToExclude.contains(paramName)) {
+ String[] originalParameterNames= ((IMethod) functionalMethod.getJavaElement()).getParameterNames();
+ String[] newNames= new String[originalParameterNames.length];
+ Set<String> excludedNames= new HashSet<>(ASTNodes.getVisibleLocalVariablesInScope(methodReference));
+
+ for (int i= 0; i < originalParameterNames.length; i++) {
+ String paramName= originalParameterNames[i];
+
+ if (excludedNames.contains(paramName)) {
+ Set<String> allNamesToExclude= new HashSet<>(excludedNames);
+ Collections.addAll(allNamesToExclude, originalParameterNames);
+
String newParamName= createName(paramName, allNamesToExclude);
+
excludedNames.add(newParamName);
newNames[i]= newParamName;
} else {
newNames[i]= paramName;
}
}
+
return newNames;
}
- private static String createName(String candidate, List<String> excludedNames) {
+ private static String createName(final String nameRoot, final Set<String> excludedNames) {
int i= 1;
- String result= candidate;
- while (excludedNames.contains(result)) {
- result= candidate + i++;
- }
- return result;
+ String candidate;
+
+ do {
+ candidate= nameRoot + i++;
+ } while (excludedNames.remove(candidate));
+
+ return candidate;
}
private static boolean isTypeReferenceToInstanceMethod(MethodReference methodReference) {
@@ -1125,9 +1132,7 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
} else {
exprBody= (Expression) lambdaBody;
}
- while (exprBody instanceof ParenthesizedExpression) {
- exprBody= ((ParenthesizedExpression) exprBody).getExpression();
- }
+ exprBody= ASTNodes.getUnparenthesedExpression(exprBody);
if (exprBody == null || !isValidLambdaReferenceToMethod(exprBody))
return false;
@@ -2014,7 +2019,10 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
return statement;
}
- private static boolean getSplitVariableProposals(IInvocationContext context, ASTNode node, Collection<ICommandAccess> resultingCollections) {
+ private static boolean getSplitVariableProposals(IInvocationContext context, ASTNode node, Collection<ICommandAccess> resultingCollections) throws JavaModelException {
+ if (resultingCollections == null) {
+ return true;
+ }
VariableDeclarationFragment fragment;
if (node instanceof VariableDeclarationFragment) {
fragment= (VariableDeclarationFragment) node;
@@ -2041,7 +2049,6 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
return false;
}
// statement is ForStatement or VariableDeclarationStatement
-
ASTNode statementParent= statement.getParent();
StructuralPropertyDescriptor property= statement.getLocationInParent();
if (!property.isChildListProperty()) {
@@ -2050,10 +2057,6 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
List<? extends ASTNode> list= ASTNodes.getChildListProperty(statementParent, (ChildListPropertyDescriptor) property);
- if (resultingCollections == null) {
- return true;
- }
-
AST ast= statement.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
@@ -2063,7 +2066,7 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
boolean commandConflict= false;
for (ICommandAccess completionProposal : resultingCollections) {
if (completionProposal instanceof ChangeCorrectionProposal) {
- if (SPLIT_JOIN_VARIABLE_DECLARATION_ID.equals(((ChangeCorrectionProposal)completionProposal).getCommandId())) {
+ if (SPLIT_JOIN_VARIABLE_DECLARATION_ID.equals(((ChangeCorrectionProposal) completionProposal).getCommandId())) {
commandConflict= true;
}
}
@@ -2072,47 +2075,91 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
proposal.setCommandId(SPLIT_JOIN_VARIABLE_DECLARATION_ID);
}
- Statement newStatement;
- int insertIndex= list.indexOf(statement);
+ // for multiple declarations; all must be moved outside, leave none behind
+ if (statement instanceof ForStatement) {
+ IBuffer buffer= context.getCompilationUnit().getBuffer();
+ ForStatement forStatement= (ForStatement) statement;
+ VariableDeclarationExpression oldVarDecl= (VariableDeclarationExpression) fragParent;
+ Type type= oldVarDecl.getType();
+ List<VariableDeclarationFragment> oldFragments= oldVarDecl.fragments();
+ CompilationUnit cup= (CompilationUnit) oldVarDecl.getRoot();
+ ListRewrite forListRewrite= rewrite.getListRewrite(forStatement, ForStatement.INITIALIZERS_PROPERTY);
+ // create the new initializers
+ for (VariableDeclarationFragment oldFragment : oldFragments) {
+ int extendedStartPositionFragment= cup.getExtendedStartPosition(oldFragment);
+ int extendedLengthFragment= cup.getExtendedLength(oldFragment);
+ String codeFragment= buffer.getText(extendedStartPositionFragment, extendedLengthFragment);
+ if (oldFragment.getInitializer() == null) {
+ ITypeBinding typeBinding= type.resolveBinding();
+ if ("Z".equals(typeBinding.getBinaryName())) { //$NON-NLS-1$
+ codeFragment+= " = false"; //$NON-NLS-1$
+ } else if (type.isPrimitiveType()) {
+ codeFragment+= " = 0"; //$NON-NLS-1$
+ } else {
+ codeFragment+= " = null"; //$NON-NLS-1$
+ }
+ }
+ Assignment newAssignmentFragment= (Assignment) rewrite.createStringPlaceholder(codeFragment, ASTNode.ASSIGNMENT);
+ forListRewrite.insertLast(newAssignmentFragment, null);
+ }
- Expression placeholder= (Expression) rewrite.createMoveTarget(fragment.getInitializer());
+ // create the new declarations
+ int extendedStartPositionDeclaration= cup.getExtendedStartPosition(oldVarDecl);
+ int firstFragmentStart= ((ASTNode) oldVarDecl.fragments().get(0)).getStartPosition();
+ String codeDeclaration= buffer.getText(extendedStartPositionDeclaration, firstFragmentStart - extendedStartPositionDeclaration);
+ Type nType= (Type) rewrite.createStringPlaceholder(codeDeclaration.trim(), type.getNodeType());
+
+ VariableDeclarationFragment newFrag= ast.newVariableDeclarationFragment();
+ VariableDeclarationStatement newVarDec= ast.newVariableDeclarationStatement(newFrag);
+ newVarDec.setType(nType);
+ newFrag.setName(ast.newSimpleName(oldFragments.get(0).getName().getIdentifier()));
+ newFrag.extraDimensions().addAll(DimensionRewrite.copyDimensions(oldFragments.get(0).extraDimensions(), rewrite));
+
+ for (int i= 1; i < oldFragments.size(); i++) {
+ VariableDeclarationFragment oldFragment= oldFragments.get(i);
+ newFrag= ast.newVariableDeclarationFragment();
+ newFrag.setName(ast.newSimpleName(oldFragment.getName().getIdentifier()));
+ newFrag.extraDimensions().addAll(DimensionRewrite.copyDimensions(oldFragment.extraDimensions(), rewrite));
+ newVarDec.fragments().add(newFrag);
+ }
+ newVarDec.modifiers().addAll(ASTNodeFactory.newModifiers(ast, oldVarDecl.getModifiers()));
+
+ ListRewrite listRewriter= rewrite.getListRewrite(statementParent, (ChildListPropertyDescriptor) property);
+ listRewriter.insertBefore(newVarDec, statement, null);
+
+ rewrite.remove(oldVarDecl, null);
+
+ resultingCollections.add(proposal);
+ return true;
+ }
+
+ Statement newStatement= null;
+ int insertIndex= list.indexOf(statement);
ITypeBinding binding= fragment.getInitializer().resolveTypeBinding();
+ Expression placeholder= (Expression) rewrite.createMoveTarget(fragment.getInitializer());
if (placeholder instanceof ArrayInitializer && binding != null && binding.isArray()) {
ArrayCreation creation= ast.newArrayCreation();
creation.setInitializer((ArrayInitializer) placeholder);
final ITypeBinding componentType= binding.getElementType();
Type type= null;
- if (componentType.isPrimitive())
+ if (componentType.isPrimitive()) {
type= ast.newPrimitiveType(PrimitiveType.toCode(componentType.getName()));
- else
+ } else {
type= ast.newSimpleType(ast.newSimpleName(componentType.getName()));
+ }
creation.setType(ast.newArrayType(type, binding.getDimensions()));
placeholder= creation;
}
- Assignment assignment= ast.newAssignment();
- assignment.setRightHandSide(placeholder);
- assignment.setLeftHandSide(ast.newSimpleName(fragment.getName().getIdentifier()));
-
if (statement instanceof VariableDeclarationStatement) {
+ Assignment assignment= ast.newAssignment();
+ assignment.setRightHandSide(placeholder);
+ assignment.setLeftHandSide(ast.newSimpleName(fragment.getName().getIdentifier()));
+
newStatement= ast.newExpressionStatement(assignment);
insertIndex+= 1; // add after declaration
- } else {
- rewrite.replace(fragment.getParent(), assignment, null);
- VariableDeclarationFragment newFrag= ast.newVariableDeclarationFragment();
- newFrag.setName(ast.newSimpleName(fragment.getName().getIdentifier()));
- newFrag.extraDimensions().addAll(DimensionRewrite.copyDimensions(fragment.extraDimensions(), rewrite));
-
- VariableDeclarationExpression oldVarDecl= (VariableDeclarationExpression) fragParent;
-
- VariableDeclarationStatement newVarDec= ast.newVariableDeclarationStatement(newFrag);
- newVarDec.setType((Type) rewrite.createCopyTarget(oldVarDecl.getType()));
- newVarDec.modifiers().addAll(ASTNodeFactory.newModifiers(ast, oldVarDecl.getModifiers()));
- newStatement= newVarDec;
}
-
ListRewrite listRewriter= rewrite.getListRewrite(statementParent, (ChildListPropertyDescriptor) property);
listRewriter.insertAt(newStatement, insertIndex, null);
-
resultingCollections.add(proposal);
return true;
}
@@ -2424,9 +2471,7 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
arguments.add(formatStringArgument);
if (is50OrHigher) {
- for (Expression expression : formatArguments) {
- arguments.add(expression);
- }
+ arguments.addAll(formatArguments);
} else {
ArrayCreation objectArrayCreation= ast.newArrayCreation();
@@ -2437,9 +2482,7 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
ArrayInitializer arrayInitializer= ast.newArrayInitializer();
List<Expression> initializerExpressions= arrayInitializer.expressions();
- for (Expression expression : formatArguments) {
- initializerExpressions.add(expression);
- }
+ initializerExpressions.addAll(formatArguments);
objectArrayCreation.setInitializer(arrayInitializer);
arguments.add(objectArrayCreation);
@@ -3778,10 +3821,7 @@ public class QuickAssistProcessor implements IQuickAssistProcessor {
replacement.arguments().add(rewrite.createCopyTarget(left));
rewrite.replace(method, replacement, null);
} else {
- ASTNode leftExpression= left;
- while (leftExpression instanceof ParenthesizedExpression) {
- leftExpression= ((ParenthesizedExpression) left).getExpression();
- }
+ ASTNode leftExpression= ASTNodes.getUnparenthesedExpression(left);
rewrite.replace(right, rewrite.createCopyTarget(leftExpression), null);
if (right instanceof CastExpression
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickFixProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickFixProcessor.java
index f478fc892e..2b659009c5 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickFixProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickFixProcessor.java
@@ -315,6 +315,7 @@ public class QuickFixProcessor implements IQuickFixProcessor {
case IProblem.PreviewFeaturesNotAllowed:
case IProblem.UninitializedBlankFinalField:
case IProblem.FeatureNotSupported:
+ case IProblem.SwitchExpressionsReturnWithinSwitchExpression:
return true;
default:
return SuppressWarningsSubProcessor.hasSuppressWarningsProposal(cu.getJavaProject(), problemId)
@@ -877,6 +878,9 @@ public class QuickFixProcessor implements IQuickFixProcessor {
break;
case IProblem.FeatureNotSupported:
ReorgCorrectionsSubProcessor.getNeedHigherComplianceProposals(context, problem, proposals);
+ case IProblem.SwitchExpressionsReturnWithinSwitchExpression:
+ ReturnTypeSubProcessor.replaceReturnWithYieldStatementProposals(context, problem, proposals);
+ break;
default:
}
if (JavaModelUtil.is50OrHigher(context.getCompilationUnit().getJavaProject())) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ReorgCorrectionsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ReorgCorrectionsSubProcessor.java
index 55aec1ed42..6f696655cd 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ReorgCorrectionsSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ReorgCorrectionsSubProcessor.java
@@ -133,6 +133,7 @@ public class ReorgCorrectionsSubProcessor {
IJavaProject javaProject= cu.getJavaProject();
String sourceLevel= javaProject.getOption(JavaCore.COMPILER_SOURCE, true);
String compliance= javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true);
+ String previewEnabled= javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
CompilationUnit root= context.getASTRoot();
@@ -163,7 +164,7 @@ public class ReorgCorrectionsSubProcessor {
found= true;
}
}
- if (!JavaConventions.validateJavaTypeName(newTypeName, sourceLevel, compliance).matches(IStatus.ERROR)) {
+ if (!JavaConventions.validateJavaTypeName(newTypeName, sourceLevel, compliance, previewEnabled).matches(IStatus.ERROR)) {
proposals.add(new CorrectMainTypeNameProposal(cu, context, currTypeName, newTypeName, IProposalRelevance.RENAME_TYPE));
}
@@ -657,5 +658,8 @@ public class ReorgCorrectionsSubProcessor {
return false;
}
+ private ReorgCorrectionsSubProcessor() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ReturnTypeSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ReturnTypeSubProcessor.java
index 6baf7c14c2..7b6cd9934b 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ReturnTypeSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ReturnTypeSubProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,6 +15,7 @@ package org.eclipse.jdt.internal.ui.text.correction;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import org.eclipse.swt.graphics.Image;
@@ -37,15 +38,19 @@ import org.eclipse.jdt.core.dom.LambdaExpression;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.PrimitiveType;
import org.eclipse.jdt.core.dom.ReturnStatement;
+import org.eclipse.jdt.core.dom.Statement;
import org.eclipse.jdt.core.dom.TagElement;
import org.eclipse.jdt.core.dom.TextElement;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeDeclaration;
+import org.eclipse.jdt.core.dom.YieldStatement;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.core.dom.rewrite.ImportRewrite;
import org.eclipse.jdt.core.dom.rewrite.ImportRewrite.ImportRewriteContext;
import org.eclipse.jdt.core.dom.rewrite.ImportRewrite.TypeLocation;
+import org.eclipse.jdt.internal.core.manipulation.dom.ASTResolving;
+import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
import org.eclipse.jdt.internal.corext.codemanipulation.ContextSensitiveImportRewriteContext;
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.dom.Bindings;
@@ -61,9 +66,6 @@ import org.eclipse.jdt.internal.ui.text.correction.proposals.LinkedCorrectionPro
import org.eclipse.jdt.internal.ui.text.correction.proposals.MissingReturnTypeCorrectionProposal;
import org.eclipse.jdt.internal.ui.text.correction.proposals.MissingReturnTypeInLambdaCorrectionProposal;
import org.eclipse.jdt.internal.ui.text.correction.proposals.ReplaceCorrectionProposal;
-
-import org.eclipse.jdt.internal.core.manipulation.dom.ASTResolving;
-import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
import org.eclipse.jdt.internal.ui.viewsupport.BindingLabelProvider;
@@ -331,6 +333,41 @@ public class ReturnTypeSubProcessor {
}
}
+ public static void replaceReturnWithYieldStatementProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
+ ICompilationUnit cu= context.getCompilationUnit();
+ CompilationUnit astRoot= context.getASTRoot();
+ ASTNode selectedNode= problem.getCoveringNode(astRoot);
+ if (!(selectedNode instanceof ReturnStatement)) {
+ return;
+ }
+ ReturnStatement returnStatement= (ReturnStatement) selectedNode;
+ Expression expression= returnStatement.getExpression();
+ if (expression == null) {
+ return;
+ }
+ ASTNode parent= returnStatement.getParent();
+ if (parent instanceof Block) {
+ Block block= (Block) parent;
+ List<Statement> stmts= block.statements();
+ int index= stmts.indexOf(returnStatement);
+ if (index < 0) {
+ return;
+ }
+
+ AST ast= astRoot.getAST();
+ ASTRewrite rewrite= ASTRewrite.create(ast);
+
+ YieldStatement yieldStatement= ast.newYieldStatement();
+ yieldStatement.setExpression((Expression) rewrite.createMoveTarget(expression));
+ rewrite.replace(returnStatement, yieldStatement, null);
+
+ String label= CorrectionMessages.ReturnTypeSubProcessor_changeReturnToYield_description;
+ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
+ ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, IProposalRelevance.REMOVE_ABSTRACT_MODIFIER, image);
+ proposals.add(proposal);
+ }
+ }
+
public static void addMethodRetunsVoidProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) throws JavaModelException {
CompilationUnit astRoot= context.getASTRoot();
ASTNode selectedNode= problem.getCoveringNode(astRoot);
@@ -352,4 +389,7 @@ public class ReturnTypeSubProcessor {
TypeMismatchSubProcessor.addChangeSenderTypeProposals(context, expression, retType.resolveBinding(), false, IProposalRelevance.METHOD_RETURNS_VOID, proposals);
}
}
+
+ private ReturnTypeSubProcessor() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SerialVersionSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SerialVersionSubProcessor.java
index 995359223b..4a1fa20d9d 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SerialVersionSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SerialVersionSubProcessor.java
@@ -97,4 +97,7 @@ public final class SerialVersionSubProcessor {
proposals.add(new SerialVersionProposal(fixes[1], IProposalRelevance.MISSING_SERIAL_VERSION, context, false));
}
}
+
+ private SerialVersionSubProcessor() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java
index b6b4729d9e..e398caa482 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java
@@ -45,6 +45,7 @@ import org.eclipse.jdt.core.dom.ImportDeclaration;
import org.eclipse.jdt.core.dom.MemberValuePair;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.eclipse.jdt.core.dom.RecordDeclaration;
import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.StringLiteral;
@@ -280,6 +281,10 @@ public class SuppressWarningsSubProcessor {
property= TypeDeclaration.MODIFIERS2_PROPERTY;
name= ((TypeDeclaration) node).getName().getIdentifier();
break;
+ case ASTNode.RECORD_DECLARATION:
+ property= RecordDeclaration.MODIFIERS2_PROPERTY;
+ name= ((RecordDeclaration) node).getName().getIdentifier();
+ break;
case ASTNode.ANNOTATION_TYPE_DECLARATION:
property= AnnotationTypeDeclaration.MODIFIERS2_PROPERTY;
name= ((AnnotationTypeDeclaration) node).getName().getIdentifier();
@@ -382,4 +387,7 @@ public class SuppressWarningsSubProcessor {
proposals.add(proposal);
}
+ private SuppressWarningsSubProcessor() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeAnnotationSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeAnnotationSubProcessor.java
index 35550c0f81..47e9e10cfe 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeAnnotationSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeAnnotationSubProcessor.java
@@ -55,4 +55,7 @@ public class TypeAnnotationSubProcessor {
return false;
}
}
+
+ private TypeAnnotationSubProcessor() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeArgumentMismatchSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeArgumentMismatchSubProcessor.java
index 1010e44c9d..f5f115eb82 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeArgumentMismatchSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeArgumentMismatchSubProcessor.java
@@ -80,4 +80,7 @@ public class TypeArgumentMismatchSubProcessor {
QuickAssistProcessor.getInferDiamondArgumentsProposal(context, selectedNode, null, proposals);
}
+ private TypeArgumentMismatchSubProcessor() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java
index f1652f1e02..99861b6735 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java
@@ -110,34 +110,40 @@ public class TypeMismatchSubProcessor {
ITypeBinding castTypeBinding= null;
int parentNodeType= selectedNode.getParent().getNodeType();
- if (parentNodeType == ASTNode.ASSIGNMENT) {
- Assignment assign= (Assignment) selectedNode.getParent();
- Expression leftHandSide= assign.getLeftHandSide();
- if (selectedNode.equals(leftHandSide)) {
- nodeToCast= assign.getRightHandSide();
- }
- castTypeBinding= assign.getLeftHandSide().resolveTypeBinding();
- if (leftHandSide instanceof Name) {
- receiverNode= (Name) leftHandSide;
- } else if (leftHandSide instanceof FieldAccess) {
- receiverNode= ((FieldAccess) leftHandSide).getName();
- }
- } else if (parentNodeType == ASTNode.VARIABLE_DECLARATION_FRAGMENT) {
- VariableDeclarationFragment frag= (VariableDeclarationFragment) selectedNode.getParent();
- if (selectedNode.equals(frag.getName()) || selectedNode.equals(frag.getInitializer())) {
- nodeToCast= frag.getInitializer();
- castTypeBinding= ASTNodes.getType(frag).resolveBinding();
- receiverNode= frag.getName();
- }
- } else if (parentNodeType == ASTNode.MEMBER_VALUE_PAIR) {
- receiverNode= ((MemberValuePair) selectedNode.getParent()).getName();
- castTypeBinding= ASTResolving.guessBindingForReference(nodeToCast);
- } else if (parentNodeType == ASTNode.SINGLE_MEMBER_ANNOTATION) {
- receiverNode= ((SingleMemberAnnotation) selectedNode.getParent()).getTypeName(); // use the type name
- castTypeBinding= ASTResolving.guessBindingForReference(nodeToCast);
- } else {
- // try to find the binding corresponding to 'castTypeName'
- castTypeBinding= ASTResolving.guessBindingForReference(nodeToCast);
+ switch (parentNodeType) {
+ case ASTNode.ASSIGNMENT:
+ Assignment assign= (Assignment) selectedNode.getParent();
+ Expression leftHandSide= assign.getLeftHandSide();
+ if (selectedNode.equals(leftHandSide)) {
+ nodeToCast= assign.getRightHandSide();
+ }
+ castTypeBinding= assign.getLeftHandSide().resolveTypeBinding();
+ if (leftHandSide instanceof Name) {
+ receiverNode= (Name) leftHandSide;
+ } else if (leftHandSide instanceof FieldAccess) {
+ receiverNode= ((FieldAccess) leftHandSide).getName();
+ }
+ break;
+ case ASTNode.VARIABLE_DECLARATION_FRAGMENT:
+ VariableDeclarationFragment frag= (VariableDeclarationFragment) selectedNode.getParent();
+ if (selectedNode.equals(frag.getName()) || selectedNode.equals(frag.getInitializer())) {
+ nodeToCast= frag.getInitializer();
+ castTypeBinding= ASTNodes.getType(frag).resolveBinding();
+ receiverNode= frag.getName();
+ }
+ break;
+ case ASTNode.MEMBER_VALUE_PAIR:
+ receiverNode= ((MemberValuePair) selectedNode.getParent()).getName();
+ castTypeBinding= ASTResolving.guessBindingForReference(nodeToCast);
+ break;
+ case ASTNode.SINGLE_MEMBER_ANNOTATION:
+ receiverNode= ((SingleMemberAnnotation) selectedNode.getParent()).getTypeName(); // use the type name
+ castTypeBinding= ASTResolving.guessBindingForReference(nodeToCast);
+ break;
+ default:
+ // try to find the binding corresponding to 'castTypeName'
+ castTypeBinding= ASTResolving.guessBindingForReference(nodeToCast);
+ break;
}
if (castTypeBinding == null) {
return;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnInitializedFinalFieldSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnInitializedFinalFieldSubProcessor.java
index ba3bd1ab1d..ff989c8625 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnInitializedFinalFieldSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnInitializedFinalFieldSubProcessor.java
@@ -67,7 +67,12 @@ public class UnInitializedFinalFieldSubProcessor {
ITypeBinding targetDecl= targetBinding.getDeclaringClass();
ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, targetDecl);
- proposals.add(new InitializeFinalFieldProposal(problem, targetCU, node, IProposalRelevance.CREATE_CONSTRUCTOR, true));
+ proposals.add(new InitializeFinalFieldProposal(problem, targetCU, node, IProposalRelevance.CREATE_CONSTRUCTOR, InitializeFinalFieldProposal.UPDATE_AT_CONSTRUCTOR));
+
+ InitializeFinalFieldProposal initializeFinalFieldProposal= new InitializeFinalFieldProposal(problem, targetCU, node, IProposalRelevance.CREATE_CONSTRUCTOR, InitializeFinalFieldProposal.UPDATE_CONSTRUCTOR_NEW_PARAMETER);
+ if(initializeFinalFieldProposal.hasProposal()) {
+ proposals.add(initializeFinalFieldProposal);
+ }
} else if (type == ASTNode.SIMPLE_NAME) {
// propose add initialization at declaration
@@ -85,4 +90,7 @@ public class UnInitializedFinalFieldSubProcessor {
proposals.add(new InitializeFinalFieldProposal(problem, targetCU, node, targetBinding, IProposalRelevance.CREATE_CONSTRUCTOR));
}
}
+
+ private UnInitializedFinalFieldSubProcessor() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
index f3c0b5aacd..353cf0d9a7 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -191,9 +191,7 @@ public class UnresolvedElementsSubProcessor {
boolean suggestVariableProposals= true;
int typeKind= 0;
- while (selectedNode instanceof ParenthesizedExpression) {
- selectedNode= ((ParenthesizedExpression) selectedNode).getExpression();
- }
+ selectedNode= ASTNodes.getUnparenthesedExpression(selectedNode);
Name node= null;
@@ -1420,10 +1418,7 @@ public class UnresolvedElementsSubProcessor {
if (!hasCastProposal) {
// x.getName() -> ((TestCase) x).getName
- Expression target= sender;
- while (target instanceof ParenthesizedExpression) {
- target= ((ParenthesizedExpression) target).getExpression();
- }
+ Expression target= ASTNodes.getUnparenthesedExpression(sender);
String label;
if (target.getNodeType() != ASTNode.CAST_EXPRESSION) {
@@ -2003,6 +1998,7 @@ public class UnresolvedElementsSubProcessor {
if (typeBinding != null && !typeBinding.isAnonymous()) {
targetBinding= typeBinding;
arguments= enumNode.arguments();
+ selectedNode= enumNode;
}
}
@@ -2127,5 +2123,8 @@ public class UnresolvedElementsSubProcessor {
}
}
+ private UnresolvedElementsSubProcessor() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/VarargsWarningsSubProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/VarargsWarningsSubProcessor.java
index a6a3f85bab..bd90ec4e6c 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/VarargsWarningsSubProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/VarargsWarningsSubProcessor.java
@@ -170,4 +170,7 @@ public class VarargsWarningsSubProcessor {
proposals.add(proposal);
}
+ private VarargsWarningsSubProcessor() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/InitializeFinalFieldProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/InitializeFinalFieldProposal.java
index f4639e2e75..11cb1ea65f 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/InitializeFinalFieldProposal.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/InitializeFinalFieldProposal.java
@@ -23,6 +23,7 @@ import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.Assignment;
import org.eclipse.jdt.core.dom.Block;
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
@@ -30,22 +31,26 @@ 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.IBinding;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.core.dom.ParameterizedType;
import org.eclipse.jdt.core.dom.PrimitiveType;
import org.eclipse.jdt.core.dom.RecordDeclaration;
+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.Type;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.dom.WildcardType;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.jdt.internal.core.manipulation.StubUtility;
import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory;
+import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.util.Messages;
import org.eclipse.jdt.ui.text.java.IProblemLocation;
@@ -61,8 +66,13 @@ public class InitializeFinalFieldProposal extends LinkedCorrectionProposal {
private final IVariableBinding fVariableBinding;
- private boolean fInConstructor;
+ private int fupdateType;
+ public static final int UPDATE_AT_DECLARATION= 0;
+
+ public static final int UPDATE_AT_CONSTRUCTOR= 1;
+
+ public static final int UPDATE_CONSTRUCTOR_NEW_PARAMETER= 2;
public InitializeFinalFieldProposal(IProblemLocation problem, ICompilationUnit cu, ASTNode astNode, IVariableBinding variableBinding, int relevance) {
super(Messages.format(CorrectionMessages.InitializeFieldAtDeclarationCorrectionProposal_description, problem.getProblemArguments()[0]), cu, null, relevance, null);
@@ -70,31 +80,45 @@ public class InitializeFinalFieldProposal extends LinkedCorrectionProposal {
fProblem= problem;
fAstNode= astNode;
fVariableBinding= variableBinding;
- fInConstructor= false;
+ fupdateType= UPDATE_AT_DECLARATION;
setImage(JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE));
}
- public InitializeFinalFieldProposal(IProblemLocation problem, ICompilationUnit cu, ASTNode astNode, int relevance, boolean inConstructor) {
+ public InitializeFinalFieldProposal(IProblemLocation problem, ICompilationUnit cu, ASTNode astNode, int relevance, int updateType) {
super(Messages.format(CorrectionMessages.InitializeFieldInConstructorCorrectionProposal_description, problem.getProblemArguments()[0]), cu, null, relevance, null);
+ if (updateType == UPDATE_CONSTRUCTOR_NEW_PARAMETER) {
+ setDisplayName(Messages.format(CorrectionMessages.InitializeFieldWithConstructorParameterCorrectionProposal_description, problem.getProblemArguments()[0]));
+ }
fProblem= problem;
fAstNode= astNode;
fVariableBinding= null;
- fInConstructor= inConstructor;
+ fupdateType= updateType;
setImage(JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE));
}
+ public boolean hasProposal() throws CoreException {
+ return getRewrite() != null;
+ }
+
@Override
protected ASTRewrite getRewrite() throws CoreException {
- if (fInConstructor) {
- if (fAstNode != null
- && fAstNode.getParent() instanceof RecordDeclaration
- && ASTHelper.isRecordDeclarationNodeSupportedInAST(fAstNode.getAST())) {
- return doInitRecordComponentsInConstructor();
- }
- return doInitFieldInConstructor();
+ switch (fupdateType) {
+ case UPDATE_AT_CONSTRUCTOR:
+ if (fAstNode != null
+ && fAstNode.getParent() instanceof RecordDeclaration
+ && ASTHelper.isRecordDeclarationNodeSupportedInAST(fAstNode.getAST())) {
+ return doInitRecordComponentsInConstructor();
+ }
+ return doInitFieldInConstructor();
+ case UPDATE_AT_DECLARATION:
+ return doInitField();
+ case UPDATE_CONSTRUCTOR_NEW_PARAMETER:
+ return doUpdateConstructorWithParameter();
+ default:
+ break;
}
- return doInitField();
+ return null;
}
private ASTRewrite doInitField() {
@@ -214,6 +238,87 @@ public class InitializeFinalFieldProposal extends LinkedCorrectionProposal {
return rewrite;
}
+ private ASTRewrite doUpdateConstructorWithParameter() {
+ String variableName= fProblem.getProblemArguments()[0];
+ FieldDeclaration field= getFieldDeclaration(variableName);
+ if (field == null) {
+ return null;
+ }
+ Type fieldType= field.getType();
+ ITypeBinding fieldBinding= fieldType.resolveBinding();
+ if (fieldBinding == null) {
+ return null;
+ }
+ // find all constructors (methods with same name as the type name)
+ ConstructorVisitor cv= new ConstructorVisitor(((AbstractTypeDeclaration) field.getParent()).getName().toString());
+ fAstNode.getRoot().accept(cv);
+ if (cv.getNodes().size() != 1) { // we only handle the simple case of one constructor
+ return null;
+ }
+ MethodDeclaration methodDeclaration= cv.getNodes().get(0); // only one constructor
+ IMethodBinding methodBinding= methodDeclaration.resolveBinding();
+ if (methodBinding == null) {
+ return null;
+ }
+ AST ast= field.getAST();
+ ASTRewrite rewrite= ASTRewrite.create(ast);
+
+ SingleVariableDeclaration newSingleVariableDeclaration= ast.newSingleVariableDeclaration();
+
+ String[] excludedNames= collectParameterNames(methodDeclaration);
+ String newName= StubUtility.suggestArgumentName(getCompilationUnit().getJavaProject(), variableName, excludedNames);
+
+ newSingleVariableDeclaration.setName(ast.newSimpleName(newName));
+ Type copyType= ASTNodes.copySubtree(ast, fieldType);
+ newSingleVariableDeclaration.setType(copyType);
+
+ FieldAccess fieldAccess= ast.newFieldAccess();
+ fieldAccess.setName(ast.newSimpleName(variableName));
+ fieldAccess.setExpression(ast.newThisExpression());
+
+ Assignment assignment= ast.newAssignment();
+ assignment.setLeftHandSide(fieldAccess);
+ assignment.setOperator(Assignment.Operator.ASSIGN);
+ assignment.setRightHandSide(ast.newSimpleName(newName));
+ ExpressionStatement statement= ast.newExpressionStatement(assignment);
+
+ rewrite.getListRewrite(methodDeclaration, MethodDeclaration.PARAMETERS_PROPERTY).insertLast(newSingleVariableDeclaration, null);
+ Block body= methodDeclaration.getBody();
+ // check if we call this(), then we can't add initialization here
+ if (!hasThisCall(body)) {
+ List<ASTNode> decls= ((AbstractTypeDeclaration) methodDeclaration.getParent()).bodyDeclarations();
+ List<String> finalFieldList= getFinalFieldList(decls);
+ int insertIndex= 0;
+ if (finalFieldList.size() > 1) {
+ int findFirstFinalFieldReferenceIndex= findFirstFinalFieldReferenceIndex(body.statements(), variableName);
+ int findFinalFieldInsertIndex= findFinalFieldAssignmentInsertIndex(body.statements(), variableName, finalFieldList);
+ int index= findFirstFinalFieldReferenceIndex == -1 ? findFinalFieldInsertIndex : findFirstFinalFieldReferenceIndex;
+ insertIndex= Math.min(body.statements().size(), Math.min(findFinalFieldInsertIndex, index));
+ }
+ rewrite.getListRewrite(body, Block.STATEMENTS_PROPERTY).insertAt(statement, insertIndex, null);
+ setEndPosition(rewrite.track(assignment)); // set cursor after expression statement
+ }
+ return rewrite;
+ }
+
+ private String[] collectParameterNames(MethodDeclaration methodDeclaration) {
+ final List<String> names= new ArrayList<>();
+
+ for (int i= 0; i < methodDeclaration.parameters().size(); i++) {
+ SingleVariableDeclaration svd= (SingleVariableDeclaration) methodDeclaration.parameters().get(i);
+ names.add(svd.getName().getIdentifier());
+ }
+ ASTVisitor v = new ASTVisitor() {
+ @Override
+ public boolean visit(VariableDeclarationFragment node) {
+ names.add(node.getName().getIdentifier());
+ return super.visit(node);
+ }
+ };
+ methodDeclaration.accept(v);
+ return names.toArray(new String[names.size()]);
+ }
+
private ASTRewrite doInitFieldInConstructor() {
String variableName= fProblem.getProblemArguments()[0];
FieldDeclaration field= getFieldDeclaration(variableName);
@@ -248,20 +353,173 @@ public class InitializeFinalFieldProposal extends LinkedCorrectionProposal {
ASTRewrite rewrite= ASTRewrite.create(ast);
// find all constructors (methods with same name as the type name)
- ConstructorVisitor cv= new ConstructorVisitor(((TypeDeclaration) field.getParent()).getName().toString());
+ ConstructorVisitor cv= new ConstructorVisitor(((AbstractTypeDeclaration) field.getParent()).getName().toString());
fAstNode.getRoot().accept(cv);
for (MethodDeclaration md : cv.getNodes()) {
Block body= md.getBody();
// check if we call this(), then we can't add initialization here
if (!hasThisCall(body)) {
- rewrite.getListRewrite(body, Block.STATEMENTS_PROPERTY).insertAt(statement, 0, null);
+ if (hasFieldInitialization(body, variableName)) {
+ continue;
+ }
+ List<ASTNode> decls= ((AbstractTypeDeclaration) md.getParent()).bodyDeclarations();
+ List<String> finalFieldList= getFinalFieldList(decls);
+ int insertIndex= 0;
+ if (finalFieldList.size() > 1) {
+ int findFirstFinalFieldReferenceIndex= findFirstFinalFieldReferenceIndex(body.statements(), variableName);
+ int findFinalFieldInsertIndex= findFinalFieldAssignmentInsertIndex(body.statements(), variableName, finalFieldList);
+ int index= findFirstFinalFieldReferenceIndex == -1 ? findFinalFieldInsertIndex : findFirstFinalFieldReferenceIndex;
+ insertIndex= Math.min(body.statements().size(), Math.min(findFinalFieldInsertIndex, index));
+ }
+ rewrite.getListRewrite(body, Block.STATEMENTS_PROPERTY).insertAt(statement, insertIndex, null);
setEndPosition(rewrite.track(assignment)); // set cursor after expression statement
}
}
return rewrite;
}
+ private boolean hasFieldInitialization(Block body, final String variableName) {
+ boolean[] hasInit= new boolean[1];
+ ASTVisitor v= new ASTVisitor() {
+ @Override
+ public boolean visit(SimpleName node) {
+ if (!node.getIdentifier().equals(variableName)) {
+ return true;
+ }
+ @SuppressWarnings("unchecked")
+ ASTNode assignNode= ASTNodes.getFirstAncestorOrNull(node, Assignment.class);
+ if (assignNode != null) {
+ Expression lhs= ((Assignment) assignNode).getLeftHandSide();
+ IBinding resolveBinding= node.resolveBinding();
+ if (resolveBinding != null && ((IVariableBinding) resolveBinding).isField()) {
+ int nodeType= lhs.getNodeType();
+ if (nodeType == ASTNode.SIMPLE_NAME) {
+ String name= ((SimpleName) lhs).getIdentifier();
+ if (variableName.equals(name)) {
+ hasInit[0]= true;
+ return false;
+ }
+ } else if (nodeType == ASTNode.FIELD_ACCESS) {
+ String name= ((FieldAccess) lhs).getName().getIdentifier();
+ if (variableName.equals(name)) {
+ hasInit[0]= true;
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+ };
+ body.accept(v);
+ return hasInit[0];
+ }
+
+ private List<String> getFinalFieldList(List<ASTNode> fieldDeclarations) {
+ List<String> list= new ArrayList<>();
+ for (ASTNode astNode : fieldDeclarations) {
+ if (astNode instanceof FieldDeclaration) {
+ int modifiers= ((FieldDeclaration) astNode).getModifiers();
+ if (!Modifier.isFinal(modifiers)) {
+ continue;
+ }
+ for (Object object : ((FieldDeclaration) astNode).fragments()) {
+ list.add(((VariableDeclarationFragment) object).getName().getIdentifier());
+ }
+ }
+ }
+ return list;
+ }
+
+ /*
+ * Find insertion index in statements based on declaration order.
+ */
+ private int findFinalFieldAssignmentInsertIndex(List<ASTNode> astNodes, String variableName, List<String> finalFieldList) {
+ int index= 0;
+ int fieldIndex= 0;
+ int findFinalFieldDeclarationIndex= finalFieldList.indexOf(variableName);
+ String[] fieldAccess= new String[1];
+
+ for (ASTNode astNode : astNodes) {
+ fieldAccess[0]= null;
+
+ ASTVisitor v= new ASTVisitor() {
+ @Override
+ public boolean visit(FieldAccess node) {
+ fieldAccess[0]= node.getName().getIdentifier();
+ return false;
+ }
+
+ @Override
+ public boolean visit(SimpleName node) {
+ @SuppressWarnings("unchecked")
+ ASTNode assignNode= ASTNodes.getFirstAncestorOrNull(node, Assignment.class);
+ if (assignNode != null) {
+ IBinding resolveBinding= node.resolveBinding();
+ if (resolveBinding != null
+ && ((IVariableBinding) resolveBinding).isField()
+ && resolveBinding.getKind() == IBinding.VARIABLE
+ && finalFieldList.contains(node.getIdentifier())) {
+ fieldAccess[0]= node.getIdentifier();
+ return false;
+ }
+ }
+ return true;
+ }
+ };
+ astNode.accept(v);
+ if (fieldAccess[0] == null) {
+ index++;
+ continue;
+ }
+ String fieldId= fieldAccess[0];
+ int indexOfField= finalFieldList.indexOf(fieldId);
+ fieldIndex= index;
+ if (indexOfField > findFinalFieldDeclarationIndex) {
+ return fieldIndex;
+ }
+ fieldIndex++;
+ index++;
+ }
+ return fieldIndex;
+ }
+
+ private int findFirstFinalFieldReferenceIndex(List<ASTNode> astNodes, String variableName) {
+ int index= 0;
+ String[] fieldAccess= new String[1];
+
+ for (ASTNode astNode : astNodes) {
+ fieldAccess[0]= null;
+
+ ASTVisitor v= new ASTVisitor() {
+ @Override
+ public boolean visit(FieldAccess node) {
+ fieldAccess[0]= node.getName().getIdentifier();
+ return false;
+ }
+
+ @Override
+ public boolean visit(SimpleName node) {
+ IBinding resolveBinding= node.resolveBinding();
+ if (resolveBinding != null && resolveBinding.getKind() == IBinding.VARIABLE) {
+ if (((IVariableBinding) resolveBinding).isField()) {
+ fieldAccess[0]= node.getIdentifier();
+ return false;
+ }
+ }
+ return true;
+ }
+ };
+ astNode.accept(v);
+ if (fieldAccess[0] != null && fieldAccess[0].equals(variableName)) {
+ return index;
+ }
+ index++;
+ }
+ return -1;
+ }
+
private boolean hasThisCall(Block body) {
for (Object object : body.statements()) {
if (((ASTNode) object).getNodeType() == ASTNode.CONSTRUCTOR_INVOCATION) {
@@ -273,7 +531,7 @@ public class InitializeFinalFieldProposal extends LinkedCorrectionProposal {
private boolean hasDefaultConstructor(ITypeBinding type) {
for (IMethodBinding mb : type.getDeclaredMethods()) {
- String key = mb.getKey();
+ String key= mb.getKey();
if (key.contains(";.()V")) { //$NON-NLS-1$
return true;
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/NewCUUsingWizardProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/NewCUUsingWizardProposal.java
index 4095fd291c..ffc4b3f423 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/NewCUUsingWizardProposal.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/NewCUUsingWizardProposal.java
@@ -409,9 +409,8 @@ public class NewCUUsingWizardProposal extends ChangeCorrectionProposal {
break;
case ASTNode.VARIABLE_DECLARATION_STATEMENT:
case ASTNode.FIELD_DECLARATION:
+ case ASTNode.PARAMETERIZED_TYPE: // Inheritance doesn't help: A<X> z= new A<String>(); ->
return null; // no guessing for LHS types, cannot be a supertype of a known type
- case ASTNode.PARAMETERIZED_TYPE:
- return null; // Inheritance doesn't help: A<X> z= new A<String>(); ->
case ASTNode.PROVIDES_DIRECTIVE:
if (node.getLocationInParent() == ProvidesDirective.IMPLEMENTATIONS_PROPERTY) {
Name serviceName= ((ProvidesDirective) parent).getName();
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/RemoveDeclarationCorrectionProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/RemoveDeclarationCorrectionProposal.java
index bc202380ce..1a0ec4aca0 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/RemoveDeclarationCorrectionProposal.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/RemoveDeclarationCorrectionProposal.java
@@ -205,34 +205,39 @@ public class RemoveDeclarationCorrectionProposal extends ASTRewriteCorrectionPro
}
int nameParentType= parent.getNodeType();
- if (nameParentType == ASTNode.ASSIGNMENT) {
- Assignment assignment= (Assignment) parent;
- Expression rightHand= assignment.getRightHandSide();
-
- ASTNode assignParent= assignment.getParent();
- if (assignParent.getNodeType() == ASTNode.EXPRESSION_STATEMENT && rightHand.getNodeType() != ASTNode.ASSIGNMENT) {
- removeVariableWithInitializer(rewrite, rightHand, assignParent);
- } else {
- rewrite.replace(assignment, rewrite.createCopyTarget(rightHand), null);
- }
- } else if (nameParentType == ASTNode.SINGLE_VARIABLE_DECLARATION) {
- rewrite.remove(parent, null);
- } else if (nameParentType == ASTNode.VARIABLE_DECLARATION_FRAGMENT) {
- VariableDeclarationFragment frag= (VariableDeclarationFragment) parent;
- ASTNode varDecl= frag.getParent();
- List<VariableDeclarationFragment> fragments;
- if (varDecl instanceof VariableDeclarationExpression) {
- fragments= ((VariableDeclarationExpression) varDecl).fragments();
- } else if (varDecl instanceof FieldDeclaration) {
- fragments= ((FieldDeclaration) varDecl).fragments();
- } else {
- fragments= ((VariableDeclarationStatement) varDecl).fragments();
- }
- if (fragments.size() == 1) {
- rewrite.remove(varDecl, null);
- } else {
- rewrite.remove(frag, null); // don't try to preserve
- }
+ switch (nameParentType) {
+ case ASTNode.ASSIGNMENT:
+ Assignment assignment= (Assignment) parent;
+ Expression rightHand= assignment.getRightHandSide();
+ ASTNode assignParent= assignment.getParent();
+ if (assignParent.getNodeType() == ASTNode.EXPRESSION_STATEMENT && rightHand.getNodeType() != ASTNode.ASSIGNMENT) {
+ removeVariableWithInitializer(rewrite, rightHand, assignParent);
+ } else {
+ rewrite.replace(assignment, rewrite.createCopyTarget(rightHand), null);
+ }
+ break;
+ case ASTNode.SINGLE_VARIABLE_DECLARATION:
+ rewrite.remove(parent, null);
+ break;
+ case ASTNode.VARIABLE_DECLARATION_FRAGMENT:
+ VariableDeclarationFragment frag= (VariableDeclarationFragment) parent;
+ ASTNode varDecl= frag.getParent();
+ List<VariableDeclarationFragment> fragments;
+ if (varDecl instanceof VariableDeclarationExpression) {
+ fragments= ((VariableDeclarationExpression) varDecl).fragments();
+ } else if (varDecl instanceof FieldDeclaration) {
+ fragments= ((FieldDeclaration) varDecl).fragments();
+ } else {
+ fragments= ((VariableDeclarationStatement) varDecl).fragments();
+ }
+ if (fragments.size() == 1) {
+ rewrite.remove(varDecl, null);
+ } else {
+ rewrite.remove(frag, null); // don't try to preserve
+ }
+ break;
+ default:
+ break;
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java
index a7db688ded..047d25ec67 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2019 IBM Corporation and others.
+ * Copyright (c) 2005, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -104,6 +104,7 @@ import org.eclipse.jdt.core.SourceRange;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.SearchPattern;
+import org.eclipse.jdt.internal.core.manipulation.JavaManipulationPlugin;
import org.eclipse.jdt.internal.corext.javadoc.JavaDocLocations;
import org.eclipse.jdt.internal.corext.util.Strings;
@@ -1006,8 +1007,7 @@ public abstract class AbstractJavaCompletionProposal implements IJavaCompletionP
* @since 3.12
*/
protected boolean isSubstringMatching() {
- String value= JavaCore.getOption(JavaCore.CODEASSIST_SUBSTRING_MATCH);
- return JavaCore.ENABLED.equals(value);
+ return JavaManipulationPlugin.CODEASSIST_SUBSTRING_MATCH_ENABLED;
}
private boolean isSubwordMatching() {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ChainCompletionTemplateBuilder.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ChainCompletionTemplateBuilder.java
index d395779f96..5ac94f6871 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ChainCompletionTemplateBuilder.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ChainCompletionTemplateBuilder.java
@@ -25,6 +25,7 @@ import org.eclipse.jface.text.templates.DocumentTemplateContext;
import org.eclipse.jface.text.templates.Template;
import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jdt.core.CompletionContext;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.Signature;
@@ -155,8 +156,9 @@ public final class ChainCompletionTemplateBuilder {
private static JavaContext createJavaContext(final JavaContentAssistInvocationContext contentAssistContext) {
final ContextTypeRegistry templateContextRegistry= JavaPlugin.getDefault().getTemplateContextRegistry();
final TemplateContextType templateContextType= templateContextRegistry.getContextType(JavaContextType.ID_ALL);
+ final CompletionContext ctx= contentAssistContext.getCoreContext();
final JavaContext javaTemplateContext= new JavaContext(templateContextType, contentAssistContext.getDocument(),
- contentAssistContext.getInvocationOffset(), contentAssistContext.getCoreContext().getToken().length,
+ ctx.getTokenStart(), ctx.getToken().length,
contentAssistContext.getCompilationUnit());
javaTemplateContext.setForceEvaluation(true);
return javaTemplateContext;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalComputerDescriptor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalComputerDescriptor.java
index 95e45d7525..20c2b3e208 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalComputerDescriptor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalComputerDescriptor.java
@@ -194,10 +194,10 @@ final class CompletionProposalComputerDescriptor {
}
String activateAttribute= element.getAttribute(ACTIVATE);
- fActivate= Boolean.valueOf(activateAttribute).booleanValue();
+ fActivate= Boolean.parseBoolean(activateAttribute);
String needsSortingAfterFilteringAttribute= element.getAttribute(NEEDS_SORTING_AFTER_FILTERING);
- fNeedsSortingAfterFiltering= Boolean.valueOf(needsSortingAfterFilteringAttribute).booleanValue();
+ fNeedsSortingAfterFiltering= Boolean.parseBoolean(needsSortingAfterFilteringAttribute);
fClass= element.getAttribute(CLASS);
checkNotNull(fClass, CLASS);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaDoubleClickSelector.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaDoubleClickSelector.java
index 2a90bec548..3fbe52d1af 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaDoubleClickSelector.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaDoubleClickSelector.java
@@ -129,8 +129,6 @@ public class JavaDoubleClickSelector extends DefaultTextDoubleClickStrategy impl
private boolean backward(char c, int offset) {
checkDirection(BACKWARD);
switch (fState) {
- case AT:
- return false;
case IDS:
if (isAt(c)) {
fStart= offset;
@@ -182,6 +180,7 @@ public class JavaDoubleClickSelector extends DefaultTextDoubleClickStrategy impl
return true;
}
return false;
+ case AT:
default:
return false;
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/LazyGenericTypeProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/LazyGenericTypeProposal.java
index 41022ef2a6..23d9088944 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/LazyGenericTypeProposal.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/LazyGenericTypeProposal.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -60,14 +60,14 @@ import org.eclipse.jdt.core.dom.ASTRequestor;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jdt.internal.core.manipulation.util.Strings;
import org.eclipse.jdt.internal.corext.dom.Bindings;
+import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
import org.eclipse.jdt.internal.corext.template.java.SignatureUtil;
-import org.eclipse.jdt.internal.core.manipulation.util.Strings;
import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext;
import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jdt.internal.corext.dom.IASTSharedValues;
import org.eclipse.jdt.internal.ui.javaeditor.EditorHighlightingSynchronizer;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
@@ -672,7 +672,10 @@ public class LazyGenericTypeProposal extends LazyJavaTypeCompletionProposal {
if (completion.length == 0)
return false;
- /* No argument list if there already is a generic signature behind the name. */
+ /*
+ * No argument list if there already is a generic signature behind the name or a period to
+ * qualify an inner type.
+ * */
try {
IRegion region= document.getLineInformationOfOffset(offset);
String line= document.get(region.getOffset(), region.getLength());
@@ -685,7 +688,7 @@ public class LazyGenericTypeProposal extends LazyJavaTypeCompletionProposal {
return true;
char ch= line.charAt(index);
- return ch != '<';
+ return ch != '<' && ch != '.';
} catch (BadLocationException e) {
return true;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ParameterGuessingProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ParameterGuessingProposal.java
index 48efc3b837..fa73e064d2 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ParameterGuessingProposal.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ParameterGuessingProposal.java
@@ -157,11 +157,12 @@ public class ParameterGuessingProposal extends JavaMethodCompletionProposal {
ui.setExitPolicy(new ExitPolicy(exitChar, document) {
@Override
public ExitFlags doExit(LinkedModeModel model2, VerifyEvent event, int offset2, int length) {
- if (event.character == ',') {
- for (int i= 0; i < fPositions.length - 1; i++) { // not for the last one
- Position position= fPositions[i];
- if (position.offset <= offset2 && offset2 + length <= position.offset + position.length) {
- try {
+ try {
+ switch (event.character) {
+ case ',':
+ for (int i= 0; i < fPositions.length - 1; i++) { // not for the last one
+ Position position= fPositions[i];
+ if (position.offset <= offset2 && offset2 + length <= position.offset + position.length) {
ITypedRegion partition= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, offset2 + length, false);
if (IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())
|| offset2 + length == partition.getOffset() + partition.getLength()) {
@@ -169,22 +170,35 @@ public class ParameterGuessingProposal extends JavaMethodCompletionProposal {
event.keyCode= SWT.TAB;
return null;
}
- } catch (BadLocationException e) {
- // continue; not serious enough to log
}
}
- }
- } else if (event.character == ')') {
- if (!canExitLinkedMode(ui, document, offset2, length)) {
- return null;
- }
- if (exitChar != ')') {
- // exit from link mode when user is in the last ')' position.
- Position position= fPositions[fPositions.length - 1];
- if (position.offset <= offset2 && offset2 + length <= position.offset + position.length) {
- return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
+ break;
+
+ case ')':
+ if (!canExitLinkedMode(ui, document, offset2, length)) {
+ return null;
+ }
+ if (exitChar != ')') {
+ // exit from link mode when user is in the last ')' position.
+ Position position= fPositions[fPositions.length - 1];
+ if (position.offset <= offset2 && offset2 + length <= position.offset + position.length) {
+ return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
+ }
+ }
+ break;
+
+ case ';':
+ ITypedRegion partition= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, offset2 + length, false);
+ if (!IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())) {
+ return null;
}
+ break;
+
+ default:
+ break;
}
+ } catch (BadLocationException e) {
+ // continue; not serious enough to log
}
return super.doExit(model2, event, offset2, length);
}
@@ -209,42 +223,37 @@ public class ParameterGuessingProposal extends JavaMethodCompletionProposal {
}
}
- private boolean canExitLinkedMode(LinkedModeUI ui, IDocument document, int offset, int length) {
- try {
- int selectionEnd= offset + length;
- ITypedRegion partition= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, selectionEnd, false);
- if (!IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())) {
- return false;
- }
+ private boolean canExitLinkedMode(LinkedModeUI ui, IDocument document, int offset, int length) throws BadLocationException {
+ int selectionEnd= offset + length;
+ ITypedRegion partition= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, selectionEnd, false);
+ if (!IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())) {
+ return false;
+ }
- IRegion argumentRegion= ui.getSelectedRegion();
-
- int openParens= 0;
- int pos= argumentRegion.getOffset();
- while (pos < selectionEnd) {
- ITypedRegion p= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, pos, false);
- int end= p.getOffset() + p.getLength();
- if (IDocument.DEFAULT_CONTENT_TYPE.equals(p.getType())) { // don't count parenthesis in strings, comments, etc.
- String argumentTextFromPartition= document.get(pos, Math.min(selectionEnd, end) - pos);
- for (int i= 0; i < argumentTextFromPartition.length(); i++) {
- char c= argumentTextFromPartition.charAt(i);
- if (c == '(') {
- openParens++;
- } else if (c == ')') {
- openParens--;
- }
+ IRegion argumentRegion= ui.getSelectedRegion();
+
+ int openParens= 0;
+ int pos= argumentRegion.getOffset();
+ while (pos < selectionEnd) {
+ ITypedRegion p= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, pos, false);
+ int end= p.getOffset() + p.getLength();
+ if (IDocument.DEFAULT_CONTENT_TYPE.equals(p.getType())) { // don't count parenthesis in strings, comments, etc.
+ String argumentTextFromPartition= document.get(pos, Math.min(selectionEnd, end) - pos);
+ for (int i= 0; i < argumentTextFromPartition.length(); i++) {
+ char c= argumentTextFromPartition.charAt(i);
+ if (c == '(') {
+ openParens++;
+ } else if (c == ')') {
+ openParens--;
}
}
-
- pos= end;
}
- if (openParens > 0) {
- return false;
- }
+ pos= end;
+ }
- } catch (BadLocationException e) {
- // continue; not serious enough to log
+ if (openParens > 0) {
+ return false;
}
return true;
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/PostfixCompletionProposalComputer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/PostfixCompletionProposalComputer.java
index 82b83d05bd..69106c93da 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/PostfixCompletionProposalComputer.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/PostfixCompletionProposalComputer.java
@@ -226,9 +226,15 @@ public class PostfixCompletionProposalComputer extends AbstractTemplateCompletio
return visit((Expression)node);
}
+ @Override
+ public boolean visit(ClassInstanceCreation node) {
+ return visit((Expression)node);
+ }
+
/**
* Does NOT override {@link ASTVisitor}
- * Handle {@link MethodInvocation} and {@link SuperMethodInvocation}
+ * Handle {@link MethodInvocation}, {@link SuperMethodInvocation}
+ * and {@link ClassInstanceCreation}
*/
public boolean visit(Expression node) {
/*
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/RelevanceComputer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/RelevanceComputer.java
index 9f95153fed..4aa333f719 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/RelevanceComputer.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/RelevanceComputer.java
@@ -41,9 +41,8 @@ public class RelevanceComputer {
case CompletionProposal.METHOD_NAME_REFERENCE:
case CompletionProposal.METHOD_DECLARATION:
case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
- return baseRelevance + 4;
case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
- return baseRelevance + 4 /* + 99 */;
+ return baseRelevance + 4;
case CompletionProposal.FIELD_REF:
return baseRelevance + 5;
case CompletionProposal.LOCAL_VARIABLE_REF:
@@ -53,4 +52,7 @@ public class RelevanceComputer {
return baseRelevance;
}
}
+
+ private RelevanceComputer() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/ConfigureProblemSeverityAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/ConfigureProblemSeverityAction.java
index 5beabd2598..8871155f38 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/ConfigureProblemSeverityAction.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/ConfigureProblemSeverityAction.java
@@ -101,14 +101,17 @@ public class ConfigureProblemSeverityAction extends Action {
CONFIGURE_PROBLEM_SEVERITY_DIALOG_ID, shell, JavaHoverMessages.ProblemHover_chooseSettingsTypeDialog_title, null, message, MessageDialog.QUESTION, buttons, 0,
JavaHoverMessages.ProblemHover_chooseSettingsTypeDialog_checkBox_dontShowAgain);
- if (result == OptionalMessageDialog.NOT_SHOWN) {
- showPropertyPage= false;
- } else if (result == 2 || result == SWT.DEFAULT) {
- return;
- } else if (result == 0) {
- showPropertyPage= true;
- } else {
- showPropertyPage= false;
+ switch (result) {
+ case OptionalMessageDialog.NOT_SHOWN:
+ default:
+ showPropertyPage= false;
+ break;
+ case 0:
+ showPropertyPage= true;
+ break;
+ case 2:
+ case SWT.DEFAULT:
+ return;
}
} else {
showPropertyPage= true;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDoc2HTMLTextReader.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDoc2HTMLTextReader.java
index b7d01eedfd..34fd3dbf19 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDoc2HTMLTextReader.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDoc2HTMLTextReader.java
@@ -231,25 +231,37 @@ public class JavaDoc2HTMLTextReader extends SubstitutionTextReader {
}
private void handleTag(String tag, String tagContent) {
-
tagContent= tagContent.trim();
- if (TagElement.TAG_PARAM.equals(tag))
- fParameters.add(tagContent);
- else if (TagElement.TAG_RETURN.equals(tag))
- fReturn= tagContent;
- else if (TagElement.TAG_EXCEPTION.equals(tag))
- fExceptions.add(tagContent);
- else if (TagElement.TAG_THROWS.equals(tag))
- fExceptions.add(tagContent);
- else if (TagElement.TAG_AUTHOR.equals(tag))
- fAuthors.add(substituteQualification(tagContent));
- else if (TagElement.TAG_SEE.equals(tag))
- fSees.add(substituteQualification(tagContent));
- else if (TagElement.TAG_SINCE.equals(tag))
- fSince.add(substituteQualification(tagContent));
- else if (tagContent != null)
+ if (tag != null) {
+ switch (tag) {
+ case TagElement.TAG_PARAM:
+ fParameters.add(tagContent);
+ return;
+ case TagElement.TAG_RETURN:
+ fReturn= tagContent;
+ return;
+ case TagElement.TAG_EXCEPTION:
+ case TagElement.TAG_THROWS:
+ fExceptions.add(tagContent);
+ return;
+ case TagElement.TAG_AUTHOR:
+ fAuthors.add(substituteQualification(tagContent));
+ return;
+ case TagElement.TAG_SEE:
+ fSees.add(substituteQualification(tagContent));
+ return;
+ case TagElement.TAG_SINCE:
+ fSince.add(substituteQualification(tagContent));
+ return;
+ default:
+ break;
+ }
+ }
+
+ if (tagContent != null) {
fRest.add(new Pair(tag, tagContent));
+ }
}
/*
@@ -286,47 +298,49 @@ public class JavaDoc2HTMLTextReader extends SubstitutionTextReader {
private String printBlockTag(String tag, String tagContent) {
- if (TagElement.TAG_LINK.equals(tag) || TagElement.TAG_LINKPLAIN.equals(tag)) {
-
- char[] contentChars= tagContent.toCharArray();
- boolean inParentheses= false;
- int labelStart= 0;
-
- for (int i= 0; i < contentChars.length; i++) {
- char nextChar= contentChars[i];
-
- // tagContent always has a leading space
- if (i == 0 && Character.isWhitespace(nextChar)) {
- labelStart= 1;
- continue;
- }
-
- if (nextChar == '(') {
- inParentheses= true;
- continue;
- }
-
- if (nextChar == ')') {
- inParentheses= false;
- continue;
- }
-
- // Stop at first whitespace that is not in parentheses
- if (!inParentheses && Character.isWhitespace(nextChar)) {
- labelStart= i+1;
+ if (tag != null) {
+ switch (tag) {
+ case TagElement.TAG_LINK:
+ case TagElement.TAG_LINKPLAIN:
+ char[] contentChars= tagContent.toCharArray();
+ boolean inParentheses= false;
+ int labelStart= 0;
+ for (int i= 0; i < contentChars.length; i++) {
+ char nextChar= contentChars[i];
+
+ // tagContent always has a leading space
+ if (i == 0 && Character.isWhitespace(nextChar)) {
+ labelStart= 1;
+ continue;
+ }
+
+ if (nextChar == '(') {
+ inParentheses= true;
+ continue;
+ }
+
+ if (nextChar == ')') {
+ inParentheses= false;
+ continue;
+ }
+
+ // Stop at first whitespace that is not in parentheses
+ if (!inParentheses && Character.isWhitespace(nextChar)) {
+ labelStart= i+1;
+ break;
+ }
+ }
+ if (TagElement.TAG_LINK.equals(tag))
+ return "<code>" + substituteQualification(tagContent.substring(labelStart)) + "</code>"; //$NON-NLS-1$//$NON-NLS-2$
+ else
+ return substituteQualification(tagContent.substring(labelStart));
+ case TagElement.TAG_LITERAL:
+ return printLiteral(tagContent);
+ case TagElement.TAG_CODE:
+ return "<code>" + printLiteral(tagContent) + "</code>"; //$NON-NLS-1$//$NON-NLS-2$
+ default:
break;
- }
}
- if (TagElement.TAG_LINK.equals(tag))
- return "<code>" + substituteQualification(tagContent.substring(labelStart)) + "</code>"; //$NON-NLS-1$//$NON-NLS-2$
- else
- return substituteQualification(tagContent.substring(labelStart));
-
- } else if (TagElement.TAG_LITERAL.equals(tag)) {
- return printLiteral(tagContent);
-
- } else if (TagElement.TAG_CODE.equals(tag)) {
- return "<code>" + printLiteral(tagContent) + "</code>"; //$NON-NLS-1$//$NON-NLS-2$
}
// If something went wrong at least replace the {} with the content
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java
index 7c9a454bef..6144447131 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavadocContentAccess2.java
@@ -615,7 +615,7 @@ public class JavadocContentAccess2 {
private static String createMethodInTypeLinks(IMethod overridden) {
CharSequence methodLink= createSimpleMemberLink(overridden);
CharSequence typeLink= createSimpleMemberLink(overridden.getDeclaringType());
- String methodInType= MessageFormat.format(JavaDocMessages.JavaDoc2HTMLTextReader_method_in_type, new Object[] { methodLink, typeLink });
+ String methodInType= MessageFormat.format(JavaDocMessages.JavaDoc2HTMLTextReader_method_in_type, methodLink, typeLink);
return methodInType;
}
@@ -948,85 +948,97 @@ public class JavadocContentAccess2 {
if (tagName == null) {
start= tag;
- } else if (TagElement.TAG_PARAM.equals(tagName)) {
- List<? extends ASTNode> fragments= tag.fragments();
- int size= fragments.size();
- if (size > 0) {
- Object first= fragments.get(0);
- if (first instanceof SimpleName) {
- String name= ((SimpleName) first).getIdentifier();
- int paramIndex= parameterNames.indexOf(name);
- if (paramIndex != -1) {
- parameterNames.set(paramIndex, null);
- }
- parameters.add(tag);
- } else if (size > 2 && first instanceof TextElement) {
- String firstText= ((TextElement) first).getText();
- if ("<".equals(firstText)) { //$NON-NLS-1$
- Object second= fragments.get(1);
- Object third= fragments.get(2);
- if (second instanceof SimpleName && third instanceof TextElement) {
- String name= ((SimpleName) second).getIdentifier();
- String thirdText= ((TextElement) third).getText();
- if (">".equals(thirdText)) { //$NON-NLS-1$
- int paramIndex= typeParameterNames.indexOf(name);
- if (paramIndex != -1) {
- typeParameterNames.set(paramIndex, null);
+ } else {
+ switch (tagName) {
+ case TagElement.TAG_PARAM:
+ List<? extends ASTNode> fragments= tag.fragments();
+ int size= fragments.size();
+ if (size > 0) {
+ Object first= fragments.get(0);
+ if (first instanceof SimpleName) {
+ String name= ((SimpleName) first).getIdentifier();
+ int paramIndex= parameterNames.indexOf(name);
+ if (paramIndex != -1) {
+ parameterNames.set(paramIndex, null);
+ }
+ parameters.add(tag);
+ } else if (size > 2 && first instanceof TextElement) {
+ String firstText= ((TextElement) first).getText();
+ if ("<".equals(firstText)) { //$NON-NLS-1$
+ Object second= fragments.get(1);
+ Object third= fragments.get(2);
+ if (second instanceof SimpleName && third instanceof TextElement) {
+ String name= ((SimpleName) second).getIdentifier();
+ String thirdText= ((TextElement) third).getText();
+ if (">".equals(thirdText)) { //$NON-NLS-1$
+ int paramIndex= typeParameterNames.indexOf(name);
+ if (paramIndex != -1) {
+ typeParameterNames.set(paramIndex, null);
+ }
+ typeParameters.add(tag);
+ }
}
- typeParameters.add(tag);
}
}
}
- }
- }
-
- } else if (TagElement.TAG_RETURN.equals(tagName)) {
- if (returnTag == null)
- returnTag= tag; // the Javadoc tool only shows the first return tag
-
- } else if (TagElement.TAG_EXCEPTION.equals(tagName) || TagElement.TAG_THROWS.equals(tagName)) {
- exceptions.add(tag);
- List<? extends ASTNode> fragments= tag.fragments();
- if (fragments.size() > 0) {
- Object first= fragments.get(0);
- if (first instanceof Name) {
- String name= ASTNodes.getSimpleNameIdentifier((Name) first);
- int exceptionIndex= exceptionNames.indexOf(name);
- if (exceptionIndex != -1) {
- exceptionNames.set(exceptionIndex, null);
+ break;
+ case TagElement.TAG_RETURN:
+ if (returnTag == null)
+ returnTag= tag; // the Javadoc tool only shows the first return tag
+ break;
+ case TagElement.TAG_EXCEPTION:
+ case TagElement.TAG_THROWS:
+ exceptions.add(tag);
+ List<? extends ASTNode> fragments2= tag.fragments();
+ if (fragments2.size() > 0) {
+ Object first= fragments2.get(0);
+ if (first instanceof Name) {
+ String name= ASTNodes.getSimpleNameIdentifier((Name) first);
+ int exceptionIndex= exceptionNames.indexOf(name);
+ if (exceptionIndex != -1) {
+ exceptionNames.set(exceptionIndex, null);
+ }
+ }
}
- }
+ break;
+ case TagElement.TAG_PROVIDES:
+ provides.add(tag);
+ break;
+ case TagElement.TAG_USES:
+ uses.add(tag);
+ break;
+ case TagElement.TAG_SINCE:
+ since.add(tag);
+ break;
+ case TagElement.TAG_VERSION:
+ versions.add(tag);
+ break;
+ case TagElement.TAG_AUTHOR:
+ authors.add(tag);
+ break;
+ case TagElement.TAG_SEE:
+ sees.add(tag);
+ break;
+ case TagElement.TAG_DEPRECATED:
+ if (deprecatedTag == null)
+ deprecatedTag= tag; // the Javadoc tool only shows the first deprecated tag
+ break;
+ case TagElement.TAG_API_NOTE:
+ apinote.add(tag);
+ break;
+ case TagElement.TAG_IMPL_SPEC:
+ implspec.add(tag);
+ break;
+ case TagElement.TAG_IMPL_NOTE:
+ implnote.add(tag);
+ break;
+ case TagElement.TAG_HIDDEN:
+ hidden.add(tag);
+ break;
+ default:
+ rest.add(tag);
+ break;
}
-
- } else if (TagElement.TAG_PROVIDES.equals(tagName)) {
- provides.add(tag);
- } else if (TagElement.TAG_USES.equals(tagName)) {
- uses.add(tag);
- } else if (TagElement.TAG_SINCE.equals(tagName)) {
- since.add(tag);
- } else if (TagElement.TAG_VERSION.equals(tagName)) {
- versions.add(tag);
- } else if (TagElement.TAG_AUTHOR.equals(tagName)) {
- authors.add(tag);
- } else if (TagElement.TAG_SEE.equals(tagName)) {
- sees.add(tag);
- } else if (TagElement.TAG_DEPRECATED.equals(tagName)) {
- if (deprecatedTag == null)
- deprecatedTag= tag; // the Javadoc tool only shows the first deprecated tag
- } else if (TagElement.TAG_API_NOTE.equals(tagName)) {
- apinote.add(tag);
- } else if (TagElement.TAG_IMPL_SPEC.equals(tagName)) {
- implspec.add(tag);
- } else if (TagElement.TAG_IMPL_NOTE.equals(tagName)) {
- implnote.add(tag);
- } else if (TagElement.TAG_USES.equals(tagName)) {
- uses.add(tag);
- } else if (TagElement.TAG_PROVIDES.equals(tagName)) {
- provides.add(tag);
- } else if (TagElement.TAG_HIDDEN.equals(tagName)) {
- hidden.add(tag);
- } else {
- rest.add(tag);
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/WordQuickFixProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/WordQuickFixProcessor.java
index 95ff4b1294..3ba12fcfcf 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/WordQuickFixProcessor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/WordQuickFixProcessor.java
@@ -88,8 +88,8 @@ public class WordQuickFixProcessor implements IQuickFixProcessor {
arguments= location.getProblemArguments();
if (arguments != null && arguments.length > 4) {
- sentence= Boolean.valueOf(arguments[3]).booleanValue();
- match= Boolean.valueOf(arguments[4]).booleanValue();
+ sentence= Boolean.parseBoolean(arguments[3]);
+ match= Boolean.parseBoolean(arguments[4]);
fixed= arguments[0].charAt(0) == IHtmlTagConstants.HTML_TAG_PREFIX || arguments[0].charAt(0) == IJavaDocTagConstants.JAVADOC_TAG_PREFIX;
if ((sentence && match) && !fixed)
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/contentassist/PostfixTemplateProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/contentassist/PostfixTemplateProposal.java
index 7b15e91fce..2fd1827daf 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/contentassist/PostfixTemplateProposal.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/contentassist/PostfixTemplateProposal.java
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.template.contentassist;
-import org.eclipse.jdt.internal.ui.text.template.contentassist.TemplateProposal;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentEvent;
@@ -24,8 +24,6 @@ import org.eclipse.jface.text.templates.TemplateContext;
import org.eclipse.jdt.internal.corext.template.java.JavaPostfixContext;
-import org.eclipse.swt.graphics.Image;
-
/**
* This is an extension to the existing {@link TemplateProposal} class. <br/>
* The class overrides the method {@link #validate(IDocument, int, DocumentEvent)} to allow the
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/contentassist/TemplateProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/contentassist/TemplateProposal.java
index ff9b599f9a..cf4d698fe2 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/contentassist/TemplateProposal.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/contentassist/TemplateProposal.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -71,10 +71,10 @@ import org.eclipse.ui.part.IWorkbenchPartOrientation;
import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.SearchPattern;
+import org.eclipse.jdt.internal.core.manipulation.JavaManipulationPlugin;
import org.eclipse.jdt.internal.corext.template.java.JavaContext;
import org.eclipse.jdt.internal.corext.template.java.JavaDocContext;
import org.eclipse.jdt.internal.corext.util.Messages;
@@ -520,7 +520,7 @@ public class TemplateProposal
}
}
int matchRule= SearchPattern.R_PREFIX_MATCH;
- if (JavaCore.ENABLED.equals(JavaCore.getOption(JavaCore.CODEASSIST_SUBSTRING_MATCH)) && CharOperation.substringMatch(pattern, displayString)) {
+ if (JavaManipulationPlugin.CODEASSIST_SUBSTRING_MATCH_ENABLED && CharOperation.substringMatch(pattern, displayString)) {
matchRule= SearchPattern.R_SUBSTRING_MATCH;
}
int[] matchingRegions= SearchPattern.getMatchingRegions(pattern, displayString, matchRule);
@@ -611,7 +611,7 @@ public class TemplateProposal
if (offset >= replaceOffset) {
String content= document.get(replaceOffset, offset - replaceOffset).toLowerCase();
String templateName= fTemplate.getName().toLowerCase();
- boolean isSubstringEnabled= JavaCore.ENABLED.equals(JavaCore.getOption(JavaCore.CODEASSIST_SUBSTRING_MATCH));
+ boolean isSubstringEnabled= JavaManipulationPlugin.CODEASSIST_SUBSTRING_MATCH_ENABLED;
boolean valid= false;
fIsSubstringMatch= false;
if (templateName.startsWith(content)) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/ClasspathVMUtil.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/ClasspathVMUtil.java
index e9bf9e4f89..83b1af5a13 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/ClasspathVMUtil.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/ClasspathVMUtil.java
@@ -141,4 +141,7 @@ public class ClasspathVMUtil {
}
return updated;
}
+
+ private ClasspathVMUtil() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/CoreUtility.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/CoreUtility.java
index f17fb99d9b..b0fac00e5c 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/CoreUtility.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/CoreUtility.java
@@ -208,4 +208,7 @@ public class CoreUtility {
return isAutoBuilding;
}
+ private CoreUtility() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/JavaUIHelp.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/JavaUIHelp.java
index 2ac7fb8cf9..850b65d741 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/JavaUIHelp.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/JavaUIHelp.java
@@ -143,4 +143,7 @@ public class JavaUIHelp {
return null;
}
}
+
+ private JavaUIHelp() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/SWTUtil.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/SWTUtil.java
index 727ac9fe95..c1889f97b6 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/SWTUtil.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/SWTUtil.java
@@ -168,5 +168,8 @@ public class SWTUtil {
textField.setBackground(textField.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
}
+ private SWTUtil() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/SelectionUtil.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/SelectionUtil.java
index 2a872a0b5e..44cb6282b6 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/SelectionUtil.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/SelectionUtil.java
@@ -123,4 +123,7 @@ public class SelectionUtil {
}
}
+ private SelectionUtil() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderWizardPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderWizardPage.java
index 8163d681fb..d47c2344a5 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderWizardPage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewSourceFolderWizardPage.java
@@ -572,7 +572,7 @@ public class NewSourceFolderWizardPage extends NewElementWizardPage {
dialog.setTitle(NewWizardMessages.NewSourceFolderWizardPage_ChooseProjectDialog_title);
dialog.setMessage(NewWizardMessages.NewSourceFolderWizardPage_ChooseProjectDialog_description);
dialog.setElements(projects);
- dialog.setInitialSelections(new Object[] { fCurrJProject });
+ dialog.setInitialSelections(fCurrJProject);
dialog.setHelpAvailable(false);
if (dialog.open() == Window.OK) {
return (IJavaProject) dialog.getFirstResult();
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java
index 9a992097be..2faefdd506 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.java
@@ -195,6 +195,8 @@ public final class NewWizardMessages extends NLS {
public static String NewRecordCreationWizard_title;
public static String NewRecordWizardPage_title;
public static String NewRecordWizardPage_description;
+ public static String NewRecordWizardPage_methods_label;
+ public static String NewRecordWizardPage_methods_inherited;
public static String NewInterfaceCreationWizard_title;
public static String NewInterfaceWizardPage_title;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties
index bf76063183..59f0f1adda 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewWizardMessages.properties
@@ -187,6 +187,8 @@ NewRecordCreationWizard_title=New Java Record
NewRecordWizardPage_title=Java Record
NewRecordWizardPage_description=Create a new Java Record.
+NewRecordWizardPage_methods_label=Which method stubs would you like to create?
+NewRecordWizardPage_methods_inherited=In&herited abstract methods
# ------- NewInterfaceWizardPage -------
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/AccessRulesDialog.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/AccessRulesDialog.java
index a7f0edaf58..109d072adb 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/AccessRulesDialog.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/AccessRulesDialog.java
@@ -47,6 +47,7 @@ import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
import org.eclipse.jdt.internal.corext.util.Messages;
import org.eclipse.jdt.ui.JavaElementLabels;
@@ -54,7 +55,6 @@ import org.eclipse.jdt.ui.JavaElementLabels;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.preferences.ProblemSeveritiesPreferencePage;
-import org.eclipse.jdt.internal.core.manipulation.util.BasicElementLabels;
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
@@ -241,15 +241,20 @@ public class AccessRulesDialog extends StatusDialog {
}
private String getLocalizedString(String severity) {
- if (JavaCore.ERROR.equals(severity)) {
- return NewWizardMessages.AccessRulesDialog_severity_error;
- } else if (JavaCore.WARNING.equals(severity)) {
- return NewWizardMessages.AccessRulesDialog_severity_warning;
- } else if (JavaCore.INFO.equals(severity)) {
- return NewWizardMessages.AccessRulesDialog_severity_info;
- } else {
- return NewWizardMessages.AccessRulesDialog_severity_ignore;
+ if (severity != null) {
+ switch (severity) {
+ case JavaCore.ERROR:
+ return NewWizardMessages.AccessRulesDialog_severity_error;
+ case JavaCore.WARNING:
+ return NewWizardMessages.AccessRulesDialog_severity_warning;
+ case JavaCore.INFO:
+ return NewWizardMessages.AccessRulesDialog_severity_info;
+ default:
+ break;
+ }
}
+
+ return NewWizardMessages.AccessRulesDialog_severity_ignore;
}
private String getDescriptionString() {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildpathProblemMarkerResolutionGenerator.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildpathProblemMarkerResolutionGenerator.java
index 12a6529024..a82422bfe4 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildpathProblemMarkerResolutionGenerator.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildpathProblemMarkerResolutionGenerator.java
@@ -356,7 +356,7 @@ public class BuildpathProblemMarkerResolutionGenerator implements IMarkerResolut
@Override
public String getLabel() {
- String projects = closedProjects.stream().map(p -> p.getName()).collect(Collectors.joining("', '")); //$NON-NLS-1$
+ String projects = closedProjects.stream().map(IProject::getName).collect(Collectors.joining("', '")); //$NON-NLS-1$
if(closedProjects.size() > 1) {
return Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_open_required_projects_description, projects);
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java
index b81877bc9d..5630824beb 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java
@@ -884,32 +884,44 @@ public class CPListElement {
CPListElementAttribute elem= (CPListElementAttribute) curr;
if (elem.isBuiltIn()) {
String key= elem.getKey();
- if (OUTPUT.equals(key) || SOURCEATTACHMENT.equals(key)) {
- appendEncodePath((IPath) elem.getValue(), buf).append(';');
- } else if (EXCLUSION.equals(key) || INCLUSION.equals(key)) {
- appendEncodedFilter((IPath[]) elem.getValue(), buf).append(';');
- } else if (ACCESSRULES.equals(key)) {
- appendEncodedAccessRules((IAccessRule[]) elem.getValue(), buf).append(';');
- } else if (COMBINE_ACCESSRULES.equals(key)) {
- buf.append(((Boolean) elem.getValue()).booleanValue()).append(';');
- } else if (MODULE.equals(key)) {
- Object value= elem.getValue();
- if (value instanceof ModuleEncapsulationDetail[]) {
- buf.append(MODULE+"=true;"); //$NON-NLS-1$
- for (ModuleEncapsulationDetail detail : ((ModuleEncapsulationDetail[]) value)) {
- if (detail instanceof ModulePatch)
- buf.append(IClasspathAttribute.PATCH_MODULE+':'+detail.toString()).append(';');
- if (detail instanceof ModuleAddExport)
- buf.append(IClasspathAttribute.ADD_EXPORTS+':'+detail.toString()).append(';');
- if (detail instanceof ModuleAddOpens)
- buf.append(IClasspathAttribute.ADD_OPENS+':'+detail.toString()).append(';');
- if (detail instanceof ModuleAddReads)
- buf.append(IClasspathAttribute.ADD_READS+':'+detail.toString()).append(';');
- if (detail instanceof LimitModules)
- buf.append(IClasspathAttribute.LIMIT_MODULES+':'+detail.toString()).append(';');
- }
- } else {
- buf.append(MODULE+"=false;"); //$NON-NLS-1$
+ if (key != null) {
+ switch (key) {
+ case OUTPUT:
+ case SOURCEATTACHMENT:
+ appendEncodePath((IPath) elem.getValue(), buf).append(';');
+ break;
+ case EXCLUSION:
+ case INCLUSION:
+ appendEncodedFilter((IPath[]) elem.getValue(), buf).append(';');
+ break;
+ case ACCESSRULES:
+ appendEncodedAccessRules((IAccessRule[]) elem.getValue(), buf).append(';');
+ break;
+ case COMBINE_ACCESSRULES:
+ buf.append(((Boolean) elem.getValue()).booleanValue()).append(';');
+ break;
+ case MODULE:
+ Object value= elem.getValue();
+ if (value instanceof ModuleEncapsulationDetail[]) {
+ buf.append(MODULE+"=true;"); //$NON-NLS-1$
+ for (ModuleEncapsulationDetail detail : ((ModuleEncapsulationDetail[]) value)) {
+ if (detail instanceof ModulePatch)
+ buf.append(IClasspathAttribute.PATCH_MODULE+':'+detail.toString()).append(';');
+ if (detail instanceof ModuleAddExport)
+ buf.append(IClasspathAttribute.ADD_EXPORTS+':'+detail.toString()).append(';');
+ if (detail instanceof ModuleAddOpens)
+ buf.append(IClasspathAttribute.ADD_OPENS+':'+detail.toString()).append(';');
+ if (detail instanceof ModuleAddReads)
+ buf.append(IClasspathAttribute.ADD_READS+':'+detail.toString()).append(';');
+ if (detail instanceof LimitModules)
+ buf.append(IClasspathAttribute.LIMIT_MODULES+':'+detail.toString()).append(';');
+ }
+ } else {
+ buf.append(MODULE+"=false;"); //$NON-NLS-1$
+ }
+ break;
+ default:
+ break;
}
}
} else {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/ClasspathModifierQueries.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/ClasspathModifierQueries.java
index 6f76a05337..a9474818f7 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/ClasspathModifierQueries.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/ClasspathModifierQueries.java
@@ -618,4 +618,7 @@ public class ClasspathModifierQueries {
};
}
+
+ private ClasspathModifierQueries() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/dialogfields/LayoutUtil.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/dialogfields/LayoutUtil.java
index a69a476f1d..efb9fd0826 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/dialogfields/LayoutUtil.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/dialogfields/LayoutUtil.java
@@ -162,4 +162,7 @@ public class LayoutUtil {
return LayoutConstants.getIndent();
}
+ private LayoutUtil() {
+ }
+
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/Mementos.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/Mementos.java
index 728997627f..edcde69843 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/Mementos.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/Mementos.java
@@ -49,4 +49,7 @@ public class Mementos {
if (factory == null) return null;
return factory.createElement(memento);
}
+
+ private Mementos() {
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetModel.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetModel.java
index 1a3ad7aea0..885763f2cd 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetModel.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetModel.java
@@ -548,7 +548,7 @@ public class WorkingSetModel {
if (configured == null)
return false;
- fConfigured= Boolean.valueOf(configured).booleanValue();
+ fConfigured= Boolean.parseBoolean(configured);
fLocalWorkingSetManager.restoreState(memento.getChild(TAG_LOCAL_WORKING_SET_MANAGER));
for (IWorkingSet ws : fLocalWorkingSetManager.getAllWorkingSets()) {
if (IWorkingSetIDs.OTHERS.equals(ws.getId())) {
@@ -564,7 +564,7 @@ public class WorkingSetModel {
if (isSortingEnabled == null) {
fIsSortingEnabled= false;
} else {
- fIsSortingEnabled= Boolean.valueOf(isSortingEnabled).booleanValue();
+ fIsSortingEnabled= Boolean.parseBoolean(isSortingEnabled);
}
for (IMemento active : memento.getChildren(TAG_ACTIVE_WORKING_SET)) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaUI.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaUI.java
index 9e0fd3f0f1..f5b78336cb 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaUI.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaUI.java
@@ -631,14 +631,12 @@ public final class JavaUI {
elementKinds= IJavaSearchConstants.ENUM;
break;
case IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES:
+ case DEPRECATED_CONSIDER_TYPES:
elementKinds= IJavaSearchConstants.CLASS_AND_INTERFACE;
break;
case IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS:
elementKinds= IJavaSearchConstants.CLASS_AND_ENUM;
break;
- case DEPRECATED_CONSIDER_TYPES:
- elementKinds= IJavaSearchConstants.CLASS_AND_INTERFACE;
- break;
case IJavaElementSearchConstants.CONSIDER_INTERFACES_AND_ANNOTATIONS:
elementKinds= IJavaSearchConstants.INTERFACE_AND_ANNOTATION;
break;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/ProblemsLabelDecorator.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/ProblemsLabelDecorator.java
index 0eca50f1e5..ba3c7c124c 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/ProblemsLabelDecorator.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/ProblemsLabelDecorator.java
@@ -310,14 +310,16 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
}
}
}
- if (severity == IMarker.SEVERITY_ERROR) {
+ switch (severity) {
+ case IMarker.SEVERITY_ERROR:
return ERRORTICK_ERROR;
- } else if (severity == IMarker.SEVERITY_WARNING) {
+ case IMarker.SEVERITY_WARNING:
return ERRORTICK_WARNING;
- } else if (severity == IMarker.SEVERITY_INFO) {
+ case IMarker.SEVERITY_INFO:
return ERRORTICK_INFO;
+ default:
+ return 0;
}
- return 0;
}
private int getPackageErrorTicksFromMarkers(IPackageFragment pack) throws CoreException {
@@ -398,12 +400,18 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
IMarker marker= isAnnotationInRange(model, annot, sourceElement);
if (marker != null) {
priority= Math.max(priority, marker.getAttribute(IMarker.SEVERITY, -1));
- if (priority == IMarker.SEVERITY_INFO) {
+ switch (priority) {
+ case IMarker.SEVERITY_INFO:
info= ERRORTICK_INFO;
- } else if (priority == IMarker.SEVERITY_WARNING) {
+ break;
+ case IMarker.SEVERITY_WARNING:
info= ERRORTICK_WARNING;
- } else if (priority == IMarker.SEVERITY_ERROR) {
+ break;
+ case IMarker.SEVERITY_ERROR:
info= ERRORTICK_ERROR;
+ break;
+ default:
+ break;
}
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/AddGetterSetterAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/AddGetterSetterAction.java
index a1d3ddfbea..b2843cf56b 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/AddGetterSetterAction.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/AddGetterSetterAction.java
@@ -1039,8 +1039,7 @@ public class AddGetterSetterAction extends SelectionDispatchAction {
label.setLayoutData(gd);
final Combo combo= new Combo(composite, SWT.READ_ONLY);
- combo.setItems(new String[] { ActionMessages.GetterSetterTreeSelectionDialog_alpha_pair_sort,
- ActionMessages.GetterSetterTreeSelectionDialog_alpha_method_sort});
+ combo.setItems(ActionMessages.GetterSetterTreeSelectionDialog_alpha_pair_sort, ActionMessages.GetterSetterTreeSelectionDialog_alpha_method_sort);
final int methodIndex= 1; // Hard-coded. Change this if the
// list gets more complicated.
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=38400
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/CustomFiltersActionGroup.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/CustomFiltersActionGroup.java
index 30cb4f0276..50d2e0d05b 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/CustomFiltersActionGroup.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/CustomFiltersActionGroup.java
@@ -695,7 +695,7 @@ public class CustomFiltersActionGroup extends ActionGroup {
if (userDefinedPatternsEnabled == null)
return;
- fUserDefinedPatternsEnabled= Boolean.valueOf(userDefinedPatternsEnabled).booleanValue();
+ fUserDefinedPatternsEnabled= Boolean.parseBoolean(userDefinedPatternsEnabled);
restoreUserDefinedPatterns(customFilters);
restoreXmlDefinedFilters(customFilters);
restoreLRUFilters(customFilters);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindAction.java
index 837689c07f..a20b24ca2d 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindAction.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindAction.java
@@ -319,10 +319,8 @@ public abstract class FindAction extends SelectionDispatchAction {
performNewSearch(new JavaSearchQuery(queryList));
} catch (JavaModelException ex) {
ExceptionHandler.handle(ex, getShell(), SearchMessages.Search_Error_search_notsuccessful_title, SearchMessages.Search_Error_search_notsuccessful_message);
- } catch (InterruptedException e) {
- // cancelled
- } catch (IllegalArgumentException e) {
- // no element
+ } catch (InterruptedException | IllegalArgumentException e) {
+ // cancelled or no element
}
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java
index a6154dd513..0f7f2a7f37 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java
@@ -513,16 +513,25 @@ public class JavaSourceViewerConfiguration extends TextSourceViewerConfiguration
@Override
public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
String partitioning= getConfiguredDocumentPartitioning(sourceViewer);
- if (IJavaPartitions.JAVA_DOC.equals(contentType) || IJavaPartitions.JAVA_MULTI_LINE_COMMENT.equals(contentType))
- return new IAutoEditStrategy[] { new JavaDocAutoIndentStrategy(partitioning) };
- else if (IJavaPartitions.JAVA_STRING.equals(contentType))
- return new IAutoEditStrategy[] { new SmartSemicolonAutoEditStrategy(partitioning), new JavaStringAutoIndentStrategy(partitioning, EditorUtility.getJavaProject(fTextEditor)) };
- else if (IJavaPartitions.JAVA_CHARACTER.equals(contentType) || IDocument.DEFAULT_CONTENT_TYPE.equals(contentType))
- return new IAutoEditStrategy[] { new SmartSemicolonAutoEditStrategy(partitioning), new JavaAutoIndentStrategy(partitioning, EditorUtility.getJavaProject(fTextEditor), sourceViewer) };
- else if (IJavaPartitions.JAVA_MULTI_LINE_STRING.equals(contentType))
- return new IAutoEditStrategy[] { new JavaMultiLineStringAutoIndentStrategy(partitioning, EditorUtility.getJavaProject(fTextEditor)) };
- else
- return new IAutoEditStrategy[] { new JavaAutoIndentStrategy(partitioning, EditorUtility.getJavaProject(fTextEditor), sourceViewer) };
+
+ if (contentType != null) {
+ switch (contentType) {
+ case IJavaPartitions.JAVA_DOC:
+ case IJavaPartitions.JAVA_MULTI_LINE_COMMENT:
+ return new IAutoEditStrategy[] { new JavaDocAutoIndentStrategy(partitioning) };
+ case IJavaPartitions.JAVA_STRING:
+ return new IAutoEditStrategy[] { new SmartSemicolonAutoEditStrategy(partitioning), new JavaStringAutoIndentStrategy(partitioning, EditorUtility.getJavaProject(fTextEditor)) };
+ case IJavaPartitions.JAVA_CHARACTER:
+ case IDocument.DEFAULT_CONTENT_TYPE:
+ return new IAutoEditStrategy[] { new SmartSemicolonAutoEditStrategy(partitioning), new JavaAutoIndentStrategy(partitioning, EditorUtility.getJavaProject(fTextEditor), sourceViewer) };
+ case IJavaPartitions.JAVA_MULTI_LINE_STRING:
+ return new IAutoEditStrategy[] { new JavaMultiLineStringAutoIndentStrategy(partitioning, EditorUtility.getJavaProject(fTextEditor)) };
+ default:
+ break;
+ }
+ }
+
+ return new IAutoEditStrategy[] { new JavaAutoIndentStrategy(partitioning, EditorUtility.getJavaProject(fTextEditor), sourceViewer) };
}
/*
@@ -530,16 +539,22 @@ public class JavaSourceViewerConfiguration extends TextSourceViewerConfiguration
*/
@Override
public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
- if (IJavaPartitions.JAVA_DOC.equals(contentType))
- return new JavadocDoubleClickStrategy(getConfiguredDocumentPartitioning(sourceViewer));
- if (IJavaPartitions.JAVA_SINGLE_LINE_COMMENT.equals(contentType))
- return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 0, 0);
- if (IJavaPartitions.JAVA_MULTI_LINE_COMMENT.equals(contentType))
- return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 0, 0);
- else if (IJavaPartitions.JAVA_STRING.equals(contentType) || IJavaPartitions.JAVA_CHARACTER.equals(contentType))
- return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 1, 1);
- else if (IJavaPartitions.JAVA_MULTI_LINE_STRING.equals(contentType))
- return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 3, 3, 3);
+ if (contentType != null) {
+ switch (contentType) {
+ case IJavaPartitions.JAVA_DOC:
+ return new JavadocDoubleClickStrategy(getConfiguredDocumentPartitioning(sourceViewer));
+ case IJavaPartitions.JAVA_SINGLE_LINE_COMMENT:
+ case IJavaPartitions.JAVA_MULTI_LINE_COMMENT:
+ return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 0, 0);
+ case IJavaPartitions.JAVA_STRING:
+ case IJavaPartitions.JAVA_CHARACTER:
+ return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 1, 1);
+ case IJavaPartitions.JAVA_MULTI_LINE_STRING:
+ return new PartitionDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), 3, 3, 3);
+ default:
+ break;
+ }
+ }
if (fJavaDoubleClickSelector == null) {
fJavaDoubleClickSelector= new JavaDoubleClickSelector();
fJavaDoubleClickSelector.setSourceVersion(fPreferenceStore.getString(JavaCore.COMPILER_SOURCE));
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java
index a3ac66ce33..7965870cea 100755
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java
@@ -444,10 +444,9 @@ public class CompletionProposalCollector extends CompletionRequestor {
case CompletionProposal.PACKAGE_REF:
return createPackageProposal(proposal);
case CompletionProposal.MODULE_REF:
- return createModuleProposal(proposal);
- case CompletionProposal.MODULE_DECLARATION:
- return createModuleProposal(proposal);
- case CompletionProposal.TYPE_REF:
+ case CompletionProposal.MODULE_DECLARATION:
+ return createModuleProposal(proposal);
+ case CompletionProposal.TYPE_REF:
return createTypeProposal(proposal);
case CompletionProposal.JAVADOC_TYPE_REF:
return createJavadocLinkTypeProposal(proposal);
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalLabelProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalLabelProvider.java
index 8987276756..eb5d71b643 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalLabelProvider.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalLabelProvider.java
@@ -85,16 +85,14 @@ public class CompletionProposalLabelProvider {
switch (kind) {
case CompletionProposal.METHOD_REF:
case CompletionProposal.CONSTRUCTOR_INVOCATION:
+ case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
+ case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
paramList= appendUnboundedParameterList(new StyledString(), proposal).getString();
return org.eclipse.jdt.internal.core.manipulation.util.Strings.markJavaElementLabelLTR(paramList);
case CompletionProposal.TYPE_REF:
case CompletionProposal.JAVADOC_TYPE_REF:
paramList= appendTypeParameterList(new StyledString(), proposal).getString();
return org.eclipse.jdt.internal.core.manipulation.util.Strings.markJavaElementLabelLTR(paramList);
- case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
- case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
- paramList= appendUnboundedParameterList(new StyledString(), proposal).getString();
- return org.eclipse.jdt.internal.core.manipulation.util.Strings.markJavaElementLabelLTR(paramList);
default:
Assert.isLegal(false);
return null; // dummy
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewRecordWizardPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewRecordWizardPage.java
index 08c187f44a..2041283901 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewRecordWizardPage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewRecordWizardPage.java
@@ -16,18 +16,27 @@ package org.eclipse.jdt.ui.wizards;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.PlatformUI;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogFieldGroup;
/**
* Wizard page to create a new record.
@@ -44,6 +53,9 @@ public class NewRecordWizardPage extends NewTypeWizardPage {
private final static String PAGE_NAME= "NewRecordWizardPage"; //$NON-NLS-1$
private final static int TYPE = NewTypeWizardPage.RECORD_TYPE;
+ private final static String SETTINGS_CREATEUNIMPLEMENTED= "create_unimplemented"; //$NON-NLS-1$
+
+ private SelectionButtonDialogFieldGroup fMethodStubsButtons;
/**
* Creates a new <code>NewRecordWizardPage</code>
@@ -53,6 +65,12 @@ public class NewRecordWizardPage extends NewTypeWizardPage {
setTitle(NewWizardMessages.NewRecordWizardPage_title);
setDescription(NewWizardMessages.NewRecordWizardPage_description);
+
+ String[] buttonNames= new String[] {
+ NewWizardMessages.NewRecordWizardPage_methods_inherited
+ };
+ fMethodStubsButtons= new SelectionButtonDialogFieldGroup(SWT.CHECK, buttonNames, 1);
+ fMethodStubsButtons.setLabelText(NewWizardMessages.NewRecordWizardPage_methods_label);
}
// -------- Initialization ---------
@@ -69,6 +87,17 @@ public class NewRecordWizardPage extends NewTypeWizardPage {
initContainerPage(jelem);
initTypePage(jelem);
doStatusUpdate();
+
+ boolean createUnimplemented= true;
+ IDialogSettings dialogSettings= getDialogSettings();
+ if (dialogSettings != null) {
+ IDialogSettings section= dialogSettings.getSection(PAGE_NAME);
+ if (section != null) {
+ createUnimplemented= section.getBoolean(SETTINGS_CREATEUNIMPLEMENTED);
+ }
+ }
+
+ setMethodStubSelection(createUnimplemented, true);
}
// ------ validation --------
@@ -128,6 +157,8 @@ public class NewRecordWizardPage extends NewTypeWizardPage {
createSuperInterfacesControls(composite, nColumns);
+ createMethodStubSelectionControls(composite, nColumns);
+
createCommentControls(composite, nColumns);
enableCommentControl(true);
@@ -137,6 +168,16 @@ public class NewRecordWizardPage extends NewTypeWizardPage {
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.NEW_RECORD_WIZARD_PAGE);
}
+ private void createMethodStubSelectionControls(Composite composite, int nColumns) {
+ Control labelControl= fMethodStubsButtons.getLabelControl(composite);
+ LayoutUtil.setHorizontalSpan(labelControl, nColumns);
+
+ DialogField.createEmptySpace(composite);
+
+ Control buttonGroup= fMethodStubsButtons.getSelectionButtonsGroup(composite);
+ LayoutUtil.setHorizontalSpan(buttonGroup, nColumns - 1);
+ }
+
/*
* @see WizardPage#becomesVisible
*/
@@ -148,4 +189,50 @@ public class NewRecordWizardPage extends NewTypeWizardPage {
}
}
+ /**
+ * Sets the selection state of the method stub checkboxes.
+ *
+ * @param createInherited initial selection state of the 'Create inherited abstract methods' checkbox.
+ * @param canBeModified if <code>true</code> the method stub checkboxes can be changed by
+ * the user. If <code>false</code> the buttons are "read-only"
+ */
+ public void setMethodStubSelection(boolean createInherited, boolean canBeModified) {
+ fMethodStubsButtons.setSelection(0, createInherited);
+
+ fMethodStubsButtons.setEnabled(canBeModified);
+ }
+
+ /**
+ * Returns the current selection state of the 'Create inherited abstract methods'
+ * checkbox.
+ *
+ * @return the selection state of the 'Create inherited abstract methods' checkbox
+ */
+ public boolean isCreateInherited() {
+ return fMethodStubsButtons.isSelected(0);
+ }
+
+ // ---- creation ----------------
+
+ /*
+ * @see NewTypeWizardPage#createTypeMembers
+ */
+ @Override
+ protected void createTypeMembers(IType type, ImportsManager imports, IProgressMonitor monitor) throws CoreException {
+ boolean doInherited= isCreateInherited();
+ createInheritedMethods(type, false, doInherited, imports, SubMonitor.convert(monitor, 1));
+
+ IDialogSettings dialogSettings= getDialogSettings();
+ if (dialogSettings != null) {
+ IDialogSettings section= dialogSettings.getSection(PAGE_NAME);
+ if (section == null) {
+ section= dialogSettings.addNewSection(PAGE_NAME);
+ }
+ section.put(SETTINGS_CREATEUNIMPLEMENTED, doInherited);
+ }
+
+ if (monitor != null) {
+ monitor.done();
+ }
+ }
}
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewTypeWizardPage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewTypeWizardPage.java
index 19c5507660..27f9262182 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewTypeWizardPage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewTypeWizardPage.java
@@ -746,7 +746,7 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage {
private static IStatus validateJavaTypeName(String text, IJavaProject project) {
if (project == null || !project.exists()) {
- return JavaConventions.validateJavaTypeName(text, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
+ return JavaConventions.validateJavaTypeName(text, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3, null);
}
return JavaConventionsUtil.validateJavaTypeName(text, project);
}
@@ -2081,7 +2081,7 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage {
IPackageFragment pack= getPackageFragment();
if (pack != null) {
- dialog.setInitialSelections(new Object[] { pack });
+ dialog.setInitialSelections(pack);
}
if (dialog.open() == Window.OK) {
diff --git a/org.eclipse.ltk.core.refactoring.tests/META-INF/MANIFEST.MF b/org.eclipse.ltk.core.refactoring.tests/META-INF/MANIFEST.MF
index 1840c33f61..3fa80d1ca8 100644
--- a/org.eclipse.ltk.core.refactoring.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.ltk.core.refactoring.tests/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.ltk.core.refactoring.tests
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ltk.core.refactoring.tests; singleton:=true
-Bundle-Version: 3.8.700.qualifier
+Bundle-Version: 3.8.800.qualifier
Bundle-Activator: org.eclipse.ltk.core.refactoring.tests.RefactoringCoreTestPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
diff --git a/org.eclipse.ltk.core.refactoring.tests/pom.xml b/org.eclipse.ltk.core.refactoring.tests/pom.xml
index 616f80f1c7..20abd7f153 100644
--- a/org.eclipse.ltk.core.refactoring.tests/pom.xml
+++ b/org.eclipse.ltk.core.refactoring.tests/pom.xml
@@ -15,12 +15,12 @@
<parent>
<artifactId>tests-pom</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
<relativePath>../tests-pom/</relativePath>
</parent>
<groupId>org.eclipse.ltk</groupId>
<artifactId>org.eclipse.ltk.core.refactoring.tests</artifactId>
- <version>3.8.700-SNAPSHOT</version>
+ <version>3.8.800-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
diff --git a/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/AllTests.java b/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/AllTests.java
index af1dcf809f..e21d08187d 100644
--- a/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/AllTests.java
+++ b/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,25 +13,23 @@
*******************************************************************************/
package org.eclipse.ltk.core.refactoring.tests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
import org.eclipse.ltk.core.refactoring.tests.history.RefactoringHistoryTests;
import org.eclipse.ltk.core.refactoring.tests.participants.ParticipantTests;
import org.eclipse.ltk.core.refactoring.tests.resource.ResourceRefactoringTests;
+import org.eclipse.ltk.core.refactoring.tests.resource.ResourceRefactoringUndoTests;
import org.eclipse.ltk.core.refactoring.tests.scripting.RefactoringScriptingTests;
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ RefactoringContextTest.class,
+ ParticipantTests.class,
+ RefactoringHistoryTests.class,
+ RefactoringScriptingTests.class,
+ ResourceRefactoringTests.class,
+ ResourceRefactoringUndoTests.class
+})
public class AllTests {
-
- public static Test suite() {
- TestSuite suite= new TestSuite(AllTests.class.getName());
-
- suite.addTestSuite(RefactoringContextTest.class);
-
- suite.addTest(ParticipantTests.suite());
- suite.addTest(RefactoringHistoryTests.suite());
- suite.addTest(RefactoringScriptingTests.suite());
- suite.addTest(ResourceRefactoringTests.suite());
- return suite;
- }
}
diff --git a/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/history/RefactoringHistoryTests.java b/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/history/RefactoringHistoryTests.java
index 02a8669c74..d5d9d5ff6b 100644
--- a/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/history/RefactoringHistoryTests.java
+++ b/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/history/RefactoringHistoryTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2013 IBM Corporation and others.
+ * Copyright (c) 2006, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,15 +13,13 @@
*******************************************************************************/
package org.eclipse.ltk.core.refactoring.tests.history;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ RefactoringHistorySerializationTests.class,
+ RefactoringHistoryServiceTests.class
+})
public class RefactoringHistoryTests {
-
- public static Test suite() {
- TestSuite suite= new TestSuite(RefactoringHistoryTests.class.getName());
- suite.addTestSuite(RefactoringHistorySerializationTests.class);
- suite.addTestSuite(RefactoringHistoryServiceTests.class);
- return suite;
- }
-} \ No newline at end of file
+}
diff --git a/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/participants/ParticipantTests.java b/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/participants/ParticipantTests.java
index 561a5c9d5b..ac4592f0e9 100644
--- a/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/participants/ParticipantTests.java
+++ b/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/participants/ParticipantTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2013 IBM Corporation and others.
+ * Copyright (c) 2006, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,16 +13,14 @@
*******************************************************************************/
package org.eclipse.ltk.core.refactoring.tests.participants;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ FailingParticipantTests.class,
+ SharedTextChangeTests.class,
+ CancelingParticipantTests.class
+})
public class ParticipantTests {
-
- public static Test suite() {
- TestSuite suite= new TestSuite(ParticipantTests.class.getName());
- suite.addTestSuite(FailingParticipantTests.class);
- suite.addTestSuite(SharedTextChangeTests.class);
- suite.addTestSuite(CancelingParticipantTests.class);
- return suite;
- }
-} \ No newline at end of file
+}
diff --git a/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/resource/ResourceRefactoringTests.java b/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/resource/ResourceRefactoringTests.java
index 1146012ee9..85bec64245 100644
--- a/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/resource/ResourceRefactoringTests.java
+++ b/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/resource/ResourceRefactoringTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2019 IBM Corporation and others.
+ * Copyright (c) 2008, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,8 +14,17 @@
*******************************************************************************/
package org.eclipse.ltk.core.refactoring.tests.resource;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.runtime.CoreException;
@@ -46,31 +55,20 @@ import org.eclipse.ltk.core.refactoring.resource.MoveResourceChange;
import org.eclipse.ltk.core.refactoring.resource.MoveResourcesDescriptor;
import org.eclipse.ltk.core.refactoring.tests.util.SimpleTestProject;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class ResourceRefactoringTests extends TestCase {
-
- public static Test suite() {
- TestSuite suite= new TestSuite(ResourceRefactoringTests.class.getName());
- suite.addTestSuite(ResourceRefactoringTests.class);
- suite.addTestSuite(ResourceRefactoringUndoTests.class);
- return suite;
- }
-
+public class ResourceRefactoringTests {
private SimpleTestProject fProject;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
fProject= new SimpleTestProject();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
fProject.delete();
}
+ @Test
public void testMoveChange1() throws Exception {
String content= "hello";
@@ -89,6 +87,7 @@ public class ResourceRefactoringTests extends TestCase {
assertMove(movedResource, file.getParent(), content);
}
+ @Test
public void testMoveChange2() throws Exception {
String content= "hello";
@@ -110,6 +109,7 @@ public class ResourceRefactoringTests extends TestCase {
assertTrue(testFolder.getFile("myFile.txt").exists());
}
+ @Test
public void testMoveChange3() throws Exception {
// move with overwrite
@@ -130,9 +130,10 @@ public class ResourceRefactoringTests extends TestCase {
assertMove(movedResource, file1.getParent(), content1);
- assertTrue(content2.equals(fProject.getContent(file2)));
+ assertEquals(content2, fProject.getContent(file2));
}
+ @Test
public void testMoveRefactoring1() throws Exception {
String content= "hello";
@@ -157,6 +158,7 @@ public class ResourceRefactoringTests extends TestCase {
assertMove(movedResource, file.getParent(), content);
}
+ @Test
public void testMoveRefactoring2() throws Exception {
String content= "hello";
@@ -183,6 +185,7 @@ public class ResourceRefactoringTests extends TestCase {
assertTrue(testFolder.getFile("myFile.txt").exists());
}
+ @Test
public void testMoveRefactoring3() throws Exception {
// move with overwrite
@@ -208,9 +211,10 @@ public class ResourceRefactoringTests extends TestCase {
perform(undoChange);
assertMove(movedResource, file1.getParent(), content1);
- assertTrue(content2.equals(fProject.getContent(file2)));
+ assertEquals(content2, fProject.getContent(file2));
}
+ @Test
public void testMoveRenameRefactoring1() throws Exception {
String content= "hello";
@@ -236,6 +240,7 @@ public class ResourceRefactoringTests extends TestCase {
assertMove(file, file.getParent(), content);
}
+ @Test
public void testMoveRenameRefactoring2() throws Exception {
String content= "hello";
@@ -263,6 +268,7 @@ public class ResourceRefactoringTests extends TestCase {
assertTrue(testFolder.getFile("myFile.txt").exists());
}
+ @Test
public void testMoveRenameRefactoring3() throws Exception {
// move with overwrite
@@ -289,9 +295,10 @@ public class ResourceRefactoringTests extends TestCase {
perform(undoChange);
assertMove(file1, file1.getParent(), content1);
- assertTrue(content2.equals(fProject.getContent(file2)));
+ assertEquals(content2, fProject.getContent(file2));
}
+ @Test
public void testDeleteRefactoring1_bug343584() throws Exception {
IFolder testFolder= fProject.createFolder("test");
fProject.createFile(testFolder, "myFile.txt", "hello");
@@ -316,6 +323,7 @@ public class ResourceRefactoringTests extends TestCase {
}
}
+ @Test
public void testDeleteRefactoring2_bug343584() throws Exception {
IPath location= fProject.getProject().getLocation();
IFolder testFolder= fProject.createFolder("test");
@@ -345,6 +353,7 @@ public class ResourceRefactoringTests extends TestCase {
assertFalse(p2Location.toFile().exists());
}
+ @Test
public void testDeleteRefactoring3_bug343584() throws Exception {
IPath location= fProject.getProject().getLocation();
IFolder testFolder= fProject.createFolder("test");
@@ -399,7 +408,8 @@ public class ResourceRefactoringTests extends TestCase {
PerformRefactoringOperation op= new PerformRefactoringOperation(refactoring, CheckConditionsOperation.ALL_CONDITIONS);
op.run(null);
RefactoringStatus validationStatus= op.getValidationStatus();
- assertTrue(!validationStatus.hasFatalError() && !validationStatus.hasError());
+ assertFalse(validationStatus.hasFatalError());
+ assertFalse(validationStatus.hasError());
return op.getUndoChange();
} finally {
if (context != null)
@@ -410,11 +420,11 @@ public class ResourceRefactoringTests extends TestCase {
private IResource assertMove(IResource source, IContainer destination, String content) throws CoreException, IOException {
IResource res= destination.findMember(source.getName());
- assertTrue(res != null);
- assertTrue(res.getType() == source.getType());
+ assertNotNull(res);
+ assertEquals(res.getType(), source.getType());
if (res instanceof IFile) {
- assertTrue(content.equals(fProject.getContent((IFile) res)));
+ assertEquals(content, fProject.getContent((IFile) res));
}
return res;
}
@@ -422,13 +432,12 @@ public class ResourceRefactoringTests extends TestCase {
private IResource assertMoveRename(IResource source, IContainer destination, String newName, String content) throws CoreException, IOException {
IResource res= destination.findMember(newName);
- assertTrue(res != null);
- assertTrue(res.getType() == source.getType());
+ assertNotNull(res);
+ assertEquals(res.getType(), source.getType());
if (res instanceof IFile) {
- assertTrue(content.equals(fProject.getContent((IFile) res)));
+ assertEquals(content, fProject.getContent((IFile) res));
}
return res;
}
-
}
diff --git a/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/resource/ResourceRefactoringUndoTests.java b/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/resource/ResourceRefactoringUndoTests.java
index 2fe4f15130..4f9ad3d0a1 100644
--- a/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/resource/ResourceRefactoringUndoTests.java
+++ b/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/resource/ResourceRefactoringUndoTests.java
@@ -13,6 +13,11 @@
*******************************************************************************/
package org.eclipse.ltk.core.refactoring.tests.resource;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -26,6 +31,10 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.IOperationHistory;
import org.eclipse.core.commands.operations.IUndoContext;
@@ -63,11 +72,7 @@ import org.eclipse.ltk.core.refactoring.tests.participants.ElementRenameRefactor
import org.eclipse.ltk.core.refactoring.tests.util.SimpleTestProject;
import org.eclipse.ltk.internal.core.refactoring.RefactoringCorePlugin;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class ResourceRefactoringUndoTests extends TestCase {
+public class ResourceRefactoringUndoTests {
private static final String TEST_NEWPROJECT_NAME= "projectTestNew";
private static final String TEST_FOLDER_NAME= "test";
private static final String TEST_NEWFOLDER_NAME= "testNew";
@@ -82,12 +87,6 @@ public class ResourceRefactoringUndoTests extends TestCase {
fileNameExcludes.add(".project");
}
- public static Test suite() {
- TestSuite suite= new TestSuite(ResourceRefactoringUndoTests.class.getName());
- suite.addTestSuite(ResourceRefactoringUndoTests.class);
- return suite;
- }
-
private static final String CONTENT= "hello";
private SimpleTestProject fProject;
private IFolder testFolder;
@@ -99,8 +98,8 @@ public class ResourceRefactoringUndoTests extends TestCase {
private IFile testLinkedFile;
private IFolder testSubFolder;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
fProject= new SimpleTestProject();
testFolder= fProject.createFolder(TEST_FOLDER_NAME);
@@ -127,8 +126,8 @@ public class ResourceRefactoringUndoTests extends TestCase {
context= RefactoringCorePlugin.getUndoContext();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
fProject.delete();
final IFileStore[] toDelete= storesToDelete.toArray(new IFileStore[storesToDelete.size()]);
storesToDelete.clear();
@@ -138,6 +137,7 @@ public class ResourceRefactoringUndoTests extends TestCase {
}
+ @Test
public void testFileRenameUndoRedoLTK() throws ExecutionException, CoreException {
RefactoringContribution renameContribution= RefactoringCore.getRefactoringContribution(RenameResourceDescriptor.ID);
RenameResourceDescriptor desc= (RenameResourceDescriptor) renameContribution.createDescriptor();
@@ -163,6 +163,7 @@ public class ResourceRefactoringUndoTests extends TestCase {
assertTrue("File CONTENT was altered on redo rename", snap.isValid(testFolder));
}
+ @Test
public void testFolderRenameUndoRedoLTK() throws ExecutionException, CoreException {
RefactoringContribution renameContribution= RefactoringCore.getRefactoringContribution(RenameResourceDescriptor.ID);
RenameResourceDescriptor desc= (RenameResourceDescriptor) renameContribution.createDescriptor();
@@ -187,6 +188,7 @@ public class ResourceRefactoringUndoTests extends TestCase {
assertTrue("Folder CONTENT was altered on redo rename", snap.isValid(fProject.getProject()));
}
+ @Test
public void testProjectRenameUndoRedoLTK() throws ExecutionException, CoreException {
IProject renamedProject= null;
try {
@@ -214,6 +216,7 @@ public class ResourceRefactoringUndoTests extends TestCase {
}
}
+ @Test
public void testFileDeleteUndoRedoLTK() throws ExecutionException, CoreException {
RefactoringContribution renameContribution= RefactoringCore.getRefactoringContribution(DeleteResourcesDescriptor.ID);
DeleteResourcesDescriptor desc= (DeleteResourcesDescriptor) renameContribution.createDescriptor();
@@ -233,6 +236,7 @@ public class ResourceRefactoringUndoTests extends TestCase {
assertFalse("Redo delete failed", testFile.exists());
}
+ @Test
public void testFileLinkedDeleteUndoRedoLTK() throws ExecutionException, CoreException {
RefactoringContribution renameContribution= RefactoringCore.getRefactoringContribution(DeleteResourcesDescriptor.ID);
DeleteResourcesDescriptor desc= (DeleteResourcesDescriptor) renameContribution.createDescriptor();
@@ -252,6 +256,7 @@ public class ResourceRefactoringUndoTests extends TestCase {
assertFalse("Redo delete failed", testLinkedFile.exists());
}
+ @Test
public void testFolderDeleteUndoRedoLTK() throws ExecutionException, CoreException {
RefactoringContribution renameContribution= RefactoringCore.getRefactoringContribution(DeleteResourcesDescriptor.ID);
DeleteResourcesDescriptor desc= (DeleteResourcesDescriptor) renameContribution.createDescriptor();
@@ -271,6 +276,7 @@ public class ResourceRefactoringUndoTests extends TestCase {
assertFalse("Redo delete failed", testSubFolder.exists());
}
+ @Test
public void testFolderDeleteLinkedUndoRedoLTK() throws ExecutionException, CoreException {
RefactoringContribution renameContribution= RefactoringCore.getRefactoringContribution(DeleteResourcesDescriptor.ID);
DeleteResourcesDescriptor desc= (DeleteResourcesDescriptor) renameContribution.createDescriptor();
@@ -288,6 +294,7 @@ public class ResourceRefactoringUndoTests extends TestCase {
assertFalse("Redo delete failed", testLinkedFolder.exists());
}
+ @Test
public void testFolderDeleteLinkedDeletedOnFilesystemUndoRedoLTK() throws ExecutionException, CoreException {
RefactoringContribution deleteContribution= RefactoringCore.getRefactoringContribution(DeleteResourcesDescriptor.ID);
DeleteResourcesDescriptor desc= (DeleteResourcesDescriptor) deleteContribution.createDescriptor();
@@ -318,6 +325,7 @@ public class ResourceRefactoringUndoTests extends TestCase {
assertFalse("Redo delete failed", testLinkedFolder.exists());
}
+ @Test
public void testProjectDeleteUndoRedoLTK() throws ExecutionException, CoreException {
RefactoringContribution renameContribution= RefactoringCore.getRefactoringContribution(DeleteResourcesDescriptor.ID);
DeleteResourcesDescriptor desc= (DeleteResourcesDescriptor) renameContribution.createDescriptor();
@@ -344,11 +352,13 @@ public class ResourceRefactoringUndoTests extends TestCase {
undo();
}
+ @Test
public void testProjectClosedDeleteUndoRedoLTK() throws ExecutionException, CoreException {
fProject.getProject().close(getMonitor());
testProjectDeleteUndoRedoLTK();
}
+ @Test
public void testProjectDeleteWithContentUndoRedoLTK() throws ExecutionException, CoreException {
RefactoringContribution renameContribution= RefactoringCore.getRefactoringContribution(DeleteResourcesDescriptor.ID);
DeleteResourcesDescriptor desc= (DeleteResourcesDescriptor) renameContribution.createDescriptor();
@@ -366,11 +376,13 @@ public class ResourceRefactoringUndoTests extends TestCase {
assertFalse("Redo delete failed", fProject.getProject().exists());
}
+ @Test
public void testProjectClosedDeleteWithContentUndoRedoLTK() throws ExecutionException, CoreException {
fProject.getProject().close(getMonitor());
testProjectDeleteWithContentUndoRedoLTK();
}
+ @Test
public void testPreChangeUndoRedoLTK() throws ExecutionException, CoreException {
Refactoring ref= new ElementRenameRefactoring(ElementRenameRefactoring.WORKING | ElementRenameRefactoring.ALWAYS_ENABLED | ElementRenameRefactoring.PRE_CHANGE);
diff --git a/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/scripting/RefactoringScriptingTests.java b/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/scripting/RefactoringScriptingTests.java
index a8cbc31ebc..1c41b7433c 100644
--- a/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/scripting/RefactoringScriptingTests.java
+++ b/org.eclipse.ltk.core.refactoring.tests/src/org/eclipse/ltk/core/refactoring/tests/scripting/RefactoringScriptingTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2013 IBM Corporation and others.
+ * Copyright (c) 2006, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,14 +13,12 @@
*******************************************************************************/
package org.eclipse.ltk.core.refactoring.tests.scripting;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ RefactoringScriptApplicationTests.class
+})
public class RefactoringScriptingTests {
-
- public static Test suite() {
- TestSuite suite= new TestSuite(RefactoringScriptingTests.class.getName());
- suite.addTestSuite(RefactoringScriptApplicationTests.class);
- return suite;
- }
-} \ No newline at end of file
+}
diff --git a/org.eclipse.ltk.core.refactoring/META-INF/MANIFEST.MF b/org.eclipse.ltk.core.refactoring/META-INF/MANIFEST.MF
index d3e4637c14..7a6e6feb18 100644
--- a/org.eclipse.ltk.core.refactoring/META-INF/MANIFEST.MF
+++ b/org.eclipse.ltk.core.refactoring/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.ltk.core.refactoring
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ltk.core.refactoring; singleton:=true
-Bundle-Version: 3.10.500.qualifier
+Bundle-Version: 3.11.0.qualifier
Bundle-Activator: org.eclipse.ltk.internal.core.refactoring.RefactoringCorePlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
@@ -24,5 +24,4 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.commands;bundle-version="[3.5.0,4.0.0)",
org.eclipse.text;bundle-version="[3.5.0,4.0.0)"
-Import-Package: com.ibm.icu.text
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/org.eclipse.ltk.core.refactoring/pom.xml b/org.eclipse.ltk.core.refactoring/pom.xml
index 45c5714c0d..a0939eb0b5 100644
--- a/org.eclipse.ltk.core.refactoring/pom.xml
+++ b/org.eclipse.ltk.core.refactoring/pom.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (c) 2012, 2018 Eclipse Foundation and others.
+ Copyright (c) 2012, 2020 Eclipse Foundation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
@@ -14,10 +14,10 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.ltk</groupId>
<artifactId>org.eclipse.ltk.core.refactoring</artifactId>
- <version>3.10.500-SNAPSHOT</version>
+ <version>3.11.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/participants/IRenameResourceProcessor.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/participants/IRenameResourceProcessor.java
new file mode 100644
index 0000000000..b2e6a8ef3d
--- /dev/null
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/participants/IRenameResourceProcessor.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+* Copyright (c) 2020 IBM Corporation and others.
+*
+* This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License 2.0
+* which accompanies this distribution, and is available at
+* https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+*
+* Contributors:
+* IBM Corporation - initial API and implementation
+*******************************************************************************/
+package org.eclipse.ltk.core.refactoring.participants;
+
+import org.eclipse.core.resources.IResource;
+
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+/**
+ * @since 3.11
+ */
+public interface IRenameResourceProcessor {
+
+ /**
+ * Returns the resource this processor was created on
+ *
+ * @return the resource to rename
+ */
+ public IResource getResource();
+
+ /**
+ * Returns the new resource name
+ *
+ * @return the new resource name
+ */
+ public String getNewResourceName();
+
+ /**
+ * Sets the new resource name
+ *
+ * @param newName the new resource name
+ */
+ public void setNewResourceName(String newName);
+
+ /**
+ * Returns <code>true</code> if the refactoring processor also updates references
+ *
+ * @return <code>true</code> if the refactoring processor also updates references
+ */
+ public boolean isUpdateReferences();
+
+ /**
+ * Specifies if the refactoring processor also updates references.
+ *
+ * @param updateReferences <code>true</code> if the refactoring processor should also updates references
+ */
+ public void setUpdateReferences(boolean updateReferences);
+
+ /**
+ * Validates if the a name is valid.
+ *
+ * @param newName the name to validate
+ * @return returns the resulting status of the validation
+ */
+ public RefactoringStatus validateNewElementName(String newName);
+}
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/Changes.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/Changes.java
index 0ac6837b01..db66b43418 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/Changes.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/Changes.java
@@ -65,4 +65,7 @@ public class Changes {
message= "MalformedTreeException"; //$NON-NLS-1$
return new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.BAD_LOCATION, message, e));
}
+
+ private Changes() {
+ }
}
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/ContentStamps.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/ContentStamps.java
index 99c84577f0..880a85d347 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/ContentStamps.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/ContentStamps.java
@@ -127,4 +127,7 @@ public class ContentStamps {
}
return false;
}
+
+ private ContentStamps() {
+ }
}
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/Messages.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/Messages.java
index 4fdd3106e7..9d55f462b5 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/Messages.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/Messages.java
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.ltk.internal.core.refactoring;
-import com.ibm.icu.text.MessageFormat;
+import java.text.MessageFormat;
/**
* Helper class to format message strings.
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringSessionTransformer.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringSessionTransformer.java
index 8979b99a3e..84c14a23a0 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringSessionTransformer.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/RefactoringSessionTransformer.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.ltk.internal.core.refactoring;
+import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -22,8 +23,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
-import com.ibm.icu.text.Collator;
-
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringHistoryService.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringHistoryService.java
index 1d43641356..ae2680e00a 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringHistoryService.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/history/RefactoringHistoryService.java
@@ -17,6 +17,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
+import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -29,8 +30,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import com.ibm.icu.text.DateFormat;
-
import org.xml.sax.InputSource;
import org.eclipse.core.commands.operations.IOperationHistoryListener;
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/resource/RenameResourceProcessor.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/resource/RenameResourceProcessor.java
index 36b7f97273..3177d5540a 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/resource/RenameResourceProcessor.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/resource/RenameResourceProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2018 IBM Corporation and others.
+ * Copyright (c) 2007, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -30,6 +30,7 @@ import org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.IRenameResourceProcessor;
import org.eclipse.ltk.core.refactoring.participants.ParticipantManager;
import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
@@ -49,7 +50,7 @@ import org.eclipse.ltk.internal.core.refactoring.RefactoringCoreMessages;
*
* @since 3.4
*/
-public class RenameResourceProcessor extends RenameProcessor {
+public class RenameResourceProcessor extends RenameProcessor implements IRenameResourceProcessor{
private IResource fResource;
private String fNewResourceName;
@@ -77,6 +78,7 @@ public class RenameResourceProcessor extends RenameProcessor {
*
* @return the resource to rename
*/
+ @Override
public IResource getResource() {
return fResource;
}
@@ -86,6 +88,7 @@ public class RenameResourceProcessor extends RenameProcessor {
*
* @return the new resource name
*/
+ @Override
public String getNewResourceName() {
return fNewResourceName;
}
@@ -95,6 +98,7 @@ public class RenameResourceProcessor extends RenameProcessor {
*
* @param newName the new resource name
*/
+ @Override
public void setNewResourceName(String newName) {
Assert.isNotNull(newName);
fNewResourceName= newName;
@@ -105,6 +109,7 @@ public class RenameResourceProcessor extends RenameProcessor {
*
* @return <code>true</code> if the refactoring processor also updates references
*/
+ @Override
public boolean isUpdateReferences() {
return fUpdateReferences;
}
@@ -114,6 +119,7 @@ public class RenameResourceProcessor extends RenameProcessor {
*
* @param updateReferences <code>true</code> if the refactoring processor should also updates references
*/
+ @Override
public void setUpdateReferences(boolean updateReferences) {
fUpdateReferences= updateReferences;
}
@@ -155,6 +161,7 @@ public class RenameResourceProcessor extends RenameProcessor {
* @param newName the name to validate
* @return returns the resulting status of the validation
*/
+ @Override
public RefactoringStatus validateNewElementName(String newName) {
Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
IContainer c= fResource.getParent();
diff --git a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/resource/ResourceProcessors.java b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/resource/ResourceProcessors.java
index d8bd1cda4d..dd3ecf6fcb 100644
--- a/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/resource/ResourceProcessors.java
+++ b/org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/internal/core/refactoring/resource/ResourceProcessors.java
@@ -69,4 +69,7 @@ public class ResourceProcessors {
}
return resourcePath.toPortableString();
}
+
+ private ResourceProcessors() {
+ }
}
diff --git a/org.eclipse.ltk.ui.refactoring.tests/META-INF/MANIFEST.MF b/org.eclipse.ltk.ui.refactoring.tests/META-INF/MANIFEST.MF
index da29b1ff4f..338c75845c 100644
--- a/org.eclipse.ltk.ui.refactoring.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.ltk.ui.refactoring.tests/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.ltk.ui.refactoring.tests
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ltk.ui.refactoring.tests;singleton:=true
-Bundle-Version: 3.9.500.qualifier
+Bundle-Version: 3.9.600.qualifier
Bundle-Activator: org.eclipse.ltk.ui.refactoring.tests.RefactoringUITestPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
diff --git a/org.eclipse.ltk.ui.refactoring.tests/pom.xml b/org.eclipse.ltk.ui.refactoring.tests/pom.xml
index ba8041e719..ff7eaebc1a 100644
--- a/org.eclipse.ltk.ui.refactoring.tests/pom.xml
+++ b/org.eclipse.ltk.ui.refactoring.tests/pom.xml
@@ -15,12 +15,12 @@
<parent>
<artifactId>tests-pom</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
<relativePath>../tests-pom/</relativePath>
</parent>
<groupId>org.eclipse.ltk</groupId>
<artifactId>org.eclipse.ltk.ui.refactoring.tests</artifactId>
- <version>3.9.500-SNAPSHOT</version>
+ <version>3.9.600-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
diff --git a/org.eclipse.ltk.ui.refactoring.tests/src/org/eclipse/ltk/ui/refactoring/examples/DeleteResourcesRefactoringAction.java b/org.eclipse.ltk.ui.refactoring.tests/src/org/eclipse/ltk/ui/refactoring/examples/DeleteResourcesRefactoringAction.java
index 922de31cc7..0d67fd121e 100644
--- a/org.eclipse.ltk.ui.refactoring.tests/src/org/eclipse/ltk/ui/refactoring/examples/DeleteResourcesRefactoringAction.java
+++ b/org.eclipse.ltk.ui.refactoring.tests/src/org/eclipse/ltk/ui/refactoring/examples/DeleteResourcesRefactoringAction.java
@@ -136,8 +136,7 @@ public class DeleteResourcesRefactoringAction extends Action implements IActionD
// not in list and no nested or nesting element in list
IPath path= resource.getFullPath();
- for (int i= 0; i < res.size(); i++) {
- IResource curr= res.get(i);
+ for (IResource curr : res) {
IPath currPath= curr.getFullPath();
if (path.isPrefixOf(currPath) || currPath.isPrefixOf(path) || currPath.equals(path)) {
return false;
diff --git a/org.eclipse.ltk.ui.refactoring.tests/src/org/eclipse/ltk/ui/refactoring/tests/AllTests.java b/org.eclipse.ltk.ui.refactoring.tests/src/org/eclipse/ltk/ui/refactoring/tests/AllTests.java
index 95ed2258c4..a7d04b7c38 100644
--- a/org.eclipse.ltk.ui.refactoring.tests/src/org/eclipse/ltk/ui/refactoring/tests/AllTests.java
+++ b/org.eclipse.ltk.ui.refactoring.tests/src/org/eclipse/ltk/ui/refactoring/tests/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,15 +13,12 @@
*******************************************************************************/
package org.eclipse.ltk.ui.refactoring.tests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ EmptySuite.class
+})
public class AllTests {
-
- public static Test suite() {
- TestSuite suite= new TestSuite(AllTests.class.getName());
- suite.addTestSuite(EmptySuite.class);
- return suite;
- }
}
-
diff --git a/org.eclipse.ltk.ui.refactoring/META-INF/MANIFEST.MF b/org.eclipse.ltk.ui.refactoring/META-INF/MANIFEST.MF
index 4214bcd8ca..4631fcec4d 100644
--- a/org.eclipse.ltk.ui.refactoring/META-INF/MANIFEST.MF
+++ b/org.eclipse.ltk.ui.refactoring/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.ltk.ui.refactoring
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ltk.ui.refactoring; singleton:=true
-Bundle-Version: 3.10.300.qualifier
+Bundle-Version: 3.11.0.qualifier
Bundle-Activator: org.eclipse.ltk.internal.ui.refactoring.RefactoringUIPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
@@ -31,5 +31,4 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)",
org.eclipse.compare;bundle-version="[3.5.0,4.0.0)",
org.eclipse.team.core;bundle-version="[3.4.100,4.0.0)",
org.eclipse.team.ui;bundle-version="[3.4.100,4.0.0)"
-Import-Package: com.ibm.icu.text
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/org.eclipse.ltk.ui.refactoring/pom.xml b/org.eclipse.ltk.ui.refactoring/pom.xml
index 3d26f8c497..ffffb6567d 100644
--- a/org.eclipse.ltk.ui.refactoring/pom.xml
+++ b/org.eclipse.ltk.ui.refactoring/pom.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright (c) 2012, 2019 Eclipse Foundation and others.
+ Copyright (c) 2012, 2020 Eclipse Foundation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
@@ -14,10 +14,10 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.ltk</groupId>
<artifactId>org.eclipse.ltk.ui.refactoring</artifactId>
- <version>3.10.300-SNAPSHOT</version>
+ <version>3.11.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/Messages.java b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/Messages.java
index d4af89daec..598bcba6d7 100644
--- a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/Messages.java
+++ b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/Messages.java
@@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.ltk.internal.ui.refactoring;
-import com.ibm.icu.text.MessageFormat;
+import java.text.MessageFormat;
/**
* Helper class to format message strings.
diff --git a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/PreviewWizardPage.java b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/PreviewWizardPage.java
index e6d10d5967..763b6cb0fa 100644
--- a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/PreviewWizardPage.java
+++ b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/PreviewWizardPage.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.ltk.internal.ui.refactoring;
+import java.text.Collator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -21,8 +22,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import com.ibm.icu.text.Collator;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.ACC;
import org.eclipse.swt.accessibility.AccessibleAdapter;
diff --git a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/RefactoringPluginImages.java b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/RefactoringPluginImages.java
index 4af2f43db4..a95efe111b 100644
--- a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/RefactoringPluginImages.java
+++ b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/RefactoringPluginImages.java
@@ -196,4 +196,7 @@ public class RefactoringPluginImages {
}
return null;
}
+
+ private RefactoringPluginImages() {
+ }
}
diff --git a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/actions/RenameResourceHandler.java b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/actions/RenameResourceHandler.java
index 668a7860d2..5e7e1b5b99 100644
--- a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/actions/RenameResourceHandler.java
+++ b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/actions/RenameResourceHandler.java
@@ -24,10 +24,10 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ltk.core.refactoring.Change;
@@ -118,7 +118,7 @@ public class RenameResourceHandler extends AbstractResourcesHandler {
private Change getChange(RenameResourceWizard refactoringWizard) {
refactoringWizard.setChangeCreationCancelable(true);
- refactoringWizard.setInitialComputationContext(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
+ refactoringWizard.setInitialComputationContext((boolean fork, boolean cancelable, IRunnableWithProgress runnable) -> runnable.run(new NullProgressMonitor()));
return refactoringWizard.internalCreateChange(InternalAPI.INSTANCE,
new CreateChangeOperation(new CheckConditionsOperation(refactoringWizard.getRefactoring(), CheckConditionsOperation.FINAL_CONDITIONS), RefactoringStatus.FATAL), true);
}
diff --git a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/RefactoringWizard.java b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/RefactoringWizard.java
index 36ab4d00fc..c8388c6453 100644
--- a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/RefactoringWizard.java
+++ b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/RefactoringWizard.java
@@ -659,8 +659,8 @@ public abstract class RefactoringWizard extends Wizard {
private Change createChange(CreateChangeOperation operation, boolean updateStatus, IRunnableContext context){
InvocationTargetException exception= null;
try {
- context.run((context != PlatformUI.getWorkbench().getActiveWorkbenchWindow()), fIsChangeCreationCancelable, new WorkbenchRunnableAdapter(
- operation, ResourcesPlugin.getWorkspace().getRoot()));
+ context.run(true, fIsChangeCreationCancelable, new WorkbenchRunnableAdapter(
+ operation, ResourcesPlugin.getWorkspace().getRoot()));
} catch (InterruptedException e) {
setConditionCheckingStatus(null);
return null;
diff --git a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/history/RefactoringHistoryLabelProvider.java b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/history/RefactoringHistoryLabelProvider.java
index 758def62e1..e382586a25 100644
--- a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/history/RefactoringHistoryLabelProvider.java
+++ b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/history/RefactoringHistoryLabelProvider.java
@@ -13,12 +13,11 @@
*******************************************************************************/
package org.eclipse.ltk.ui.refactoring.history;
+import java.text.DateFormat;
import java.text.Format;
+import java.text.SimpleDateFormat;
import java.util.Date;
-import com.ibm.icu.text.DateFormat;
-import com.ibm.icu.text.SimpleDateFormat;
-
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
diff --git a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/history/RefactoringHistoryWizard.java b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/history/RefactoringHistoryWizard.java
index ddad257316..ca26db7ce4 100644
--- a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/history/RefactoringHistoryWizard.java
+++ b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/history/RefactoringHistoryWizard.java
@@ -16,11 +16,10 @@ package org.eclipse.ltk.ui.refactoring.history;
import java.lang.reflect.InvocationTargetException;
import java.text.ChoiceFormat;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
-import com.ibm.icu.text.MessageFormat;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
diff --git a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/resource/RenameResourceWizard.java b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/resource/RenameResourceWizard.java
index adc46ace05..4823f9aa78 100644
--- a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/resource/RenameResourceWizard.java
+++ b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/ui/refactoring/resource/RenameResourceWizard.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2019 IBM Corporation and others.
+ * Copyright (c) 2007, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -26,6 +26,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.IRenameResourceProcessor;
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
import org.eclipse.ltk.internal.core.refactoring.resource.RenameResourceProcessor;
import org.eclipse.ltk.internal.ui.refactoring.RefactoringUIMessages;
@@ -65,20 +66,46 @@ public class RenameResourceWizard extends RefactoringWizard {
@Override
protected void addUserInputPages() {
- RenameResourceProcessor processor= getRefactoring().getAdapter(RenameResourceProcessor.class);
- addPage(new RenameResourceRefactoringConfigurationPage(processor));
+ addPage(new RenameResourceRefactoringConfigurationPage(getProcessor()));
}
- private static class RenameResourceRefactoringConfigurationPage extends UserInputWizardPage {
+ /**
+ * @return the IRenameResourceProcessor used by this wizard
+ * @since 3.11
+ */
+ protected IRenameResourceProcessor getProcessor() {
+ return getRefactoring().getAdapter(RenameResourceProcessor.class);
+ }
+
+ /**
+ * @since 3.11
+ */
+ public static class RenameResourceRefactoringConfigurationPage extends UserInputWizardPage {
- private final RenameResourceProcessor fRefactoringProcessor;
+ private final IRenameResourceProcessor fRefactoringProcessor;
private Text fNameField;
- public RenameResourceRefactoringConfigurationPage(RenameResourceProcessor processor) {
+ public RenameResourceRefactoringConfigurationPage(IRenameResourceProcessor processor) {
super("RenameResourceRefactoringInputPage"); //$NON-NLS-1$
fRefactoringProcessor= processor;
}
+ public RenameResourceRefactoringConfigurationPage(String name, IRenameResourceProcessor processor) {
+ super(name);
+ fRefactoringProcessor= processor;
+ }
+
+ /**
+ * Creates the top level Composite for this dialog page
+ * under the given parent composite.
+ * <p>
+ * The created top level Composite will be set as the top level control
+ * for this dialog page and can be accessed using <code>getControl</code>
+ * </p>
+ * <p>
+ * The top level Composite will have a GridLayout of 2 columns of unequal width
+ * </p>
+ */
@Override
public void createControl(Composite parent) {
Composite composite= new Composite(parent, SWT.NONE);
@@ -135,11 +162,16 @@ public class RenameResourceWizard extends RefactoringWizard {
return super.getNextPage();
}
- private void storeSettings() {
+ protected void storeSettings() {
+ //do nothing
}
- private void initializeRefactoring() {
+ protected void initializeRefactoring() {
fRefactoringProcessor.setNewResourceName(fNameField.getText());
}
+
+ protected IRenameResourceProcessor getProcessor() {
+ return fRefactoringProcessor;
+ }
}
} \ No newline at end of file
diff --git a/pom.xml b/pom.xml
index ecedaf2d3d..ac8089a2c0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,13 +15,13 @@
<parent>
<groupId>org.eclipse</groupId>
<artifactId>eclipse-platform-parent</artifactId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
<relativePath>../eclipse-platform-parent</relativePath>
</parent>
<groupId>eclipse.jdt.ui</groupId>
<artifactId>eclipse.jdt.ui</artifactId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
diff --git a/tests-pom/pom.xml b/tests-pom/pom.xml
index a4e38dd9b7..11f1519338 100644
--- a/tests-pom/pom.xml
+++ b/tests-pom/pom.xml
@@ -14,10 +14,10 @@
<parent>
<artifactId>eclipse.jdt.ui</artifactId>
<groupId>eclipse.jdt.ui</groupId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
</parent>
<artifactId>tests-pom</artifactId>
- <version>4.16.0-SNAPSHOT</version>
+ <version>4.17.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<code.ignoredWarnings>${tests.ignoredWarnings}</code.ignoredWarnings>

Back to the top