Merge remote-tracking branch 'origin/master'
authorVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Fri, 9 Jan 2015 12:13:10 +0000 (13:13 +0100)
committerVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Fri, 9 Jan 2015 12:13:10 +0000 (13:13 +0100)
123 files changed:
bin/WinLauncher/WinLauncher.exe
bin/WinLauncher/WinLauncher64.exe
build/scripts/tests.gant
java/java-analysis-impl/src/com/intellij/codeInspection/LambdaCanBeMethodReferenceInspection.java
java/java-analysis-impl/src/org/jetbrains/generate/tostring/util/StringUtil.java [deleted file]
java/java-analysis-impl/src/org/jetbrains/java/generate/GenerateToStringActionHandler.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/GenerateToStringActionHandler.java with 96% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/GenerateToStringContext.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/GenerateToStringContext.java with 93% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/GenerateToStringUtils.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/GenerateToStringUtils.java with 92% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/config/CancelPolicy.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/CancelPolicy.java with 96% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/config/Config.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/Config.java with 99% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/config/ConflictResolutionPolicy.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/ConflictResolutionPolicy.java with 97% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/config/DuplicationPolicy.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/DuplicationPolicy.java with 95% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/config/FilterPattern.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/FilterPattern.java with 97% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/config/InsertLastStrategy.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/InsertLastStrategy.java with 95% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/config/InsertNewMethodStrategy.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/InsertNewMethodStrategy.java with 96% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/config/InsertWhere.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/InsertWhere.java with 95% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/config/PolicyOptions.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/PolicyOptions.java with 96% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/exception/GenerateCodeException.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/exception/GenerateCodeException.java with 96% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/exception/PluginException.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/exception/PluginException.java with 96% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/inspection/AbstractToStringInspection.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/inspection/AbstractToStringInspection.java with 84% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/inspection/ClassHasNoToStringMethodInspection.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/inspection/ClassHasNoToStringMethodInspection.java with 98% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/inspection/FieldNotUsedInToStringInspection.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/inspection/FieldNotUsedInToStringInspection.java with 97% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/inspection/GenerateToStringQuickFix.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/inspection/GenerateToStringQuickFix.java with 93% similarity]
java/java-analysis-impl/src/org/jetbrains/java/generate/psi/PsiAdapter.java [moved from java/java-analysis-impl/src/org/jetbrains/generate/tostring/psi/PsiAdapter.java with 98% similarity]
java/java-impl/src/com/intellij/codeInsight/generation/EqualsHashCodeTemplatesManager.java [new file with mode: 0644]
java/java-impl/src/com/intellij/codeInsight/generation/defaultEquals.vm [new file with mode: 0644]
java/java-impl/src/com/intellij/codeInsight/generation/defaultHashCode.vm [new file with mode: 0644]
java/java-impl/src/com/intellij/codeInspection/dataFlow/EditContractIntention.java
java/java-impl/src/com/intellij/ide/actions/CreatePackageInfoAction.java
java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueDialog.java
java/java-impl/src/com/intellij/refactoring/wrapreturnvalue/WrapReturnValueProcessor.java
java/java-psi-api/src/com/intellij/psi/PsiClassObjectAccessExpression.java
java/java-psi-api/src/com/intellij/psi/util/TypesDistinctProver.java
java/java-psi-impl/src/com/intellij/psi/impl/PsiImplUtil.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiClassObjectAccessExpressionImpl.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AssignabilityBetweenWildcardsAndArrays.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/afterLambdaWithFormalParams.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeLambdaWithFormalParams.java [new file with mode: 0644]
java/java-tests/testData/refactoring/wrapReturnValue/inferFieldType/after/Test.java [new file with mode: 0644]
java/java-tests/testData/refactoring/wrapReturnValue/inferFieldType/after/Wrapper.java [new file with mode: 0644]
java/java-tests/testData/refactoring/wrapReturnValue/inferFieldType/before/Test.java [new file with mode: 0644]
java/java-tests/testData/refactoring/wrapReturnValue/inferFieldType/before/Wrapper.java [new file with mode: 0644]
java/java-tests/testData/refactoring/wrapReturnValue/inferFieldTypeArg/after/Test.java [new file with mode: 0644]
java/java-tests/testData/refactoring/wrapReturnValue/inferFieldTypeArg/after/Wrapper.java [new file with mode: 0644]
java/java-tests/testData/refactoring/wrapReturnValue/inferFieldTypeArg/before/Test.java [new file with mode: 0644]
java/java-tests/testData/refactoring/wrapReturnValue/inferFieldTypeArg/before/Wrapper.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInspection/bytecodeAnalysis/BytecodeAnalysisTest.java
java/java-tests/testSrc/com/intellij/refactoring/WrapReturnValueTest.java
java/java-tests/testSrc/com/intellij/run/JavaPathMacroCollectorTest.groovy [new file with mode: 0644]
native/WinLauncher/WinLauncher/WinLauncher.manifest [deleted file]
native/WinLauncher/WinLauncher/WinLauncher.rc
native/WinLauncher/WinLauncher/WinLauncher.vcxproj
platform/analysis-api/src/com/intellij/codeInspection/CleanupLocalInspectionTool.java
platform/analysis-api/src/com/intellij/codeInspection/InspectionEP.java
platform/analysis-impl/src/com/intellij/codeInspection/inspection-black-list.txt
platform/core-api/src/com/intellij/psi/PsiElement.java
platform/core-api/src/com/intellij/psi/PsiReference.java
platform/indexing-api/src/com/intellij/psi/search/searches/ReferencesSearch.java
platform/lang-impl/src/com/intellij/codeInsight/editorActions/CopyHandler.java
platform/lang-impl/src/com/intellij/codeInsight/editorActions/CopyPastePostProcessor.java
platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java
platform/lang-impl/src/com/intellij/execution/configuration/RunConfigurationPathMacroFilter.java
platform/lang-impl/src/com/intellij/execution/filters/FileHyperlinkParsedData.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteDialog.java
platform/lang-impl/src/com/intellij/ui/StringComboboxEditor.java
platform/platform-impl/src/com/intellij/platform/ProjectTemplateEP.java
platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/GlobalMatchingVisitor.java
platform/util/src/com/intellij/openapi/util/text/StringUtil.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/FieldMayBeFinalInspection.java
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/threading/VariableAccessVisitor.java
plugins/InspectionGadgets/test/com/siyeh/igtest/threading/FieldAccessedSynchronizedAndUnsynchronized.java [deleted file]
plugins/InspectionGadgets/test/com/siyeh/igtest/threading/field_accessed_synchronized_and_unsynchronized/FieldAccessedSynchronizedAndUnsynchronized.java [new file with mode: 0644]
plugins/InspectionGadgets/testsrc/com/siyeh/ig/threading/FieldAccessedSynchronizedAndUnsynchronizedInspectionTest.java [new file with mode: 0644]
plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResourceLocator.java [deleted file]
plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringAction.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/GenerateToStringAction.java with 96% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringActionHandlerImpl.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/GenerateToStringActionHandlerImpl.java with 90% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringConfigurable.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/GenerateToStringConfigurable.java with 87% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringWorker.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/GenerateToStringWorker.java with 72% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/GenerationUtil.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/GenerationUtil.java with 51% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/config/DuplicatePolicy.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/DuplicatePolicy.java with 93% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/config/InsertAfterEqualsHashCodeStrategy.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertAfterEqualsHashCodeStrategy.java with 95% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/config/InsertAtCaretStrategy.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertAtCaretStrategy.java with 91% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/config/ReplacePolicy.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/ReplacePolicy.java with 97% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/element/AbstractElement.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/AbstractElement.java with 83% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/element/ClassElement.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/ClassElement.java with 99% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/element/Element.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/Element.java with 95% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/element/ElementComparator.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/ElementComparator.java with 97% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/element/ElementFactory.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/ElementFactory.java with 92% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/element/ElementUtils.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/ElementUtils.java with 95% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/element/FieldElement.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/FieldElement.java with 98% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/element/MethodElement.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/MethodElement.java with 98% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/exception/TemplateResourceException.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/exception/TemplateResourceException.java with 95% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/package.html [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/package.html with 100% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/template/TemplateResource.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResource.java with 75% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/template/TemplatesManager.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplatesManager.java with 63% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/template/TemplatesState.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplatesState.java with 94% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/template/toString/DefaultBuffer.vm [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/DefaultBuffer.vm with 100% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/template/toString/DefaultBuilder.vm [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/DefaultBuilder.vm with 100% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/template/toString/DefaultConcatMember.vm [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/DefaultConcatMember.vm with 100% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/template/toString/DefaultConcatMemberGroovy.vm [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/DefaultConcatMemberGroovy.vm with 100% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/template/toString/DefaultConcatMemberSuper.vm [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/DefaultConcatMemberSuper.vm with 100% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/template/toString/DefaultGuava.vm [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/DefaultGuava.vm with 100% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/template/toString/DefaultToStringBuilder.vm [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/DefaultToStringBuilder.vm with 100% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/template/toString/DefaultToStringBuilder3.vm [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/DefaultToStringBuilder3.vm with 100% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/template/toString/ToStringTemplatesManager.java [new file with mode: 0644]
plugins/generate-tostring/src/org/jetbrains/java/generate/velocity/VelocityFactory.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/velocity/VelocityFactory.java with 97% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/view/ConfigUI.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/view/ConfigUI.java with 98% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/view/GenerateTemplateConfigurable.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/view/ToStringTemplateConfigurable.java with 89% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/view/MethodExistsDialog.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/view/MethodExistsDialog.java with 86% similarity]
plugins/generate-tostring/src/org/jetbrains/java/generate/view/TemplatesPanel.java [moved from plugins/generate-tostring/src/org/jetbrains/generate/tostring/view/TemplatesPanel.java with 85% similarity]
plugins/generate-tostring/testSrc/org/jetbrains/java/generate/inspection/ClassHasNoToStringMethodInspectionTest.java [moved from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/inspection/ClassHasNoToStringMethodInspectionTest.java with 96% similarity]
plugins/generate-tostring/testSrc/org/jetbrains/java/generate/inspection/FieldNotUsedInToStringInspectionTest.java [moved from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/inspection/FieldNotUsedInToStringInspectionTest.java with 98% similarity]
plugins/generate-tostring/testSrc/org/jetbrains/java/generate/inspection/ToStringGeneratingTest.groovy [moved from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/inspection/ToStringGeneratingTest.groovy with 87% similarity]
plugins/generate-tostring/testSrc/org/jetbrains/java/generate/test/DummyCompleteTestBean.java [moved from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/test/DummyCompleteTestBean.java with 99% similarity]
plugins/generate-tostring/testSrc/org/jetbrains/java/generate/test/DummyGetterTestBean.java [moved from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/test/DummyGetterTestBean.java with 96% similarity]
plugins/generate-tostring/testSrc/org/jetbrains/java/generate/test/DummyModelTestBean.java [moved from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/test/DummyModelTestBean.java with 97% similarity]
plugins/generate-tostring/testSrc/org/jetbrains/java/generate/test/DummySortTestBean.java [moved from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/test/DummySortTestBean.java with 96% similarity]
plugins/generate-tostring/testSrc/org/jetbrains/java/generate/test/DummyTestBean.java [moved from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/test/DummyTestBean.java with 95% similarity]
plugins/generate-tostring/testSrc/org/jetbrains/java/generate/test/Owner.java [moved from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/test/Owner.java with 98% similarity]
plugins/generate-tostring/testSrc/org/jetbrains/java/generate/test/Pet.java [moved from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/test/Pet.java with 97% similarity]
resources/src/META-INF/IdeaPlugin.xml
resources/src/idea/JavaActions.xml

index e98b3601acb0a835e7d58df7e4f1cc64b31635d9..749a855aaa0e1b2c82ebdc104f39b94ac2de3216 100644 (file)
Binary files a/bin/WinLauncher/WinLauncher.exe and b/bin/WinLauncher/WinLauncher.exe differ
index e5f616575b9c6df3cfa099c5b9385a63e75bbdac..e0855845243ee57f4689ba12b9c1953b45e12e54 100644 (file)
Binary files a/bin/WinLauncher/WinLauncher64.exe and b/bin/WinLauncher/WinLauncher64.exe differ
index 1c6be2927d7d0f17df237fb3aedefbe73884c831..e4aada4b821a4c11065657bb01765bfe10591a17 100644 (file)
@@ -17,8 +17,6 @@ import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
 
 def home = guessHome(this)
 
-setProperty("testcases", ["com.intellij.AllTests"])
-
 includeTargets << new File("${home}/build/scripts/common_tests.gant")
 
 if ("GIT_TESTS".equalsIgnoreCase(System.getProperty("idea.test.group"))) {
@@ -40,3 +38,5 @@ if (System.getProperty("os.name").toLowerCase().startsWith("mac")) {
 };
 
 setProperty("jvm_args", args)
+
+setProperty("testcases", ["com.intellij.AllTests"])
index 97b1a99bbc9996339b70ded1d3a188e54f854534..33ef7d22442c2ba87022edb4ae7f0ca356fa7844 100644 (file)
@@ -420,21 +420,24 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp
       if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return;
       final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(element, PsiLambdaExpression.class);
       if (lambdaExpression == null) return;
-      final PsiType functionalInterfaceType = lambdaExpression.getFunctionalInterfaceType();
+      PsiType functionalInterfaceType = lambdaExpression.getFunctionalInterfaceType();
       if (functionalInterfaceType == null || !functionalInterfaceType.isValid()) return;
       final String methodRefText = createMethodReferenceText(element, functionalInterfaceType,
                                                              lambdaExpression.getParameterList().getParameters());
 
       if (methodRefText != null) {
         final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
-        final PsiExpression psiExpression =
-          factory.createExpressionFromText(methodRefText, lambdaExpression);
+        final PsiExpression psiExpression = factory.createExpressionFromText(methodRefText, lambdaExpression);
+        final SmartTypePointer typePointer = SmartTypePointerManager.getInstance(project).createSmartTypePointer(functionalInterfaceType);
         PsiElement replace = lambdaExpression.replace(psiExpression);
         if (((PsiMethodReferenceExpression)replace).getFunctionalInterfaceType() == null) { //ambiguity
           final PsiTypeCastExpression cast = (PsiTypeCastExpression)factory.createExpressionFromText("(A)a", replace);
-          cast.getCastType().replace(factory.createTypeElement(functionalInterfaceType));
-          cast.getOperand().replace(replace);
-          replace = replace.replace(cast);
+          functionalInterfaceType = typePointer.getType();
+          if (functionalInterfaceType != null) {
+            cast.getCastType().replace(factory.createTypeElement(functionalInterfaceType));
+            cast.getOperand().replace(replace);
+            replace = replace.replace(cast);
+          }
         }
         JavaCodeStyleManager.getInstance(project).shortenClassReferences(replace);
       }
diff --git a/java/java-analysis-impl/src/org/jetbrains/generate/tostring/util/StringUtil.java b/java/java-analysis-impl/src/org/jetbrains/generate/tostring/util/StringUtil.java
deleted file mode 100644 (file)
index 5171177..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright 2001-2007 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jetbrains.generate.tostring.util;
-
-/**
- * String utility methods.
- */
-public class StringUtil {
-
-    /**
-     * Private constructor, to prevent instances of this class, since it only has static members.
-     */
-    private StringUtil() {
-    }
-
-    /**
-     * Is the string empty (null, or contains just whitespace)
-     *
-     * @param s string to test.
-     * @return true if it's an empty string.
-     */
-    public static boolean isEmpty(String s) {
-        return s == null || s.trim().length() == 0;
-    }
-
-    /**
-     * Does the string contain some chars (whitespace is consideres as empty)
-     *
-     * @param s string to test.
-     * @return true if it's NOT an empty string.
-     */
-    public static boolean isNotEmpty(String s) {
-        return ! isEmpty(s);
-    }
-
-  /**
-     * Does the string have an uppercase character?
-     * @param s  the string to test.
-     * @return   true if the string has an uppercase character, false if not.
-     */
-    public static boolean hasUpperCaseChar(String s) {
-        char[] chars = s.toCharArray();
-        for (char c : chars) {
-            if (Character.isUpperCase(c)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Does the string have a lowercase character?
-     * @param s  the string to test.
-     * @return   true if the string has a lowercase character, false if not.
-     */
-    public static boolean hasLowerCaseChar(String s) {
-        char[] chars = s.toCharArray();
-        for (char c : chars) {
-            if (Character.isLowerCase(c)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Returns the part of s after the token.
-     * <p/>
-     * <br/>Example:   after("helloWorldThisIsMe", "World") will return "ThisIsMe".
-     * <br/>Example:   after("helloWorldThisIsMe", "Dog") will return null.
-     *
-     * @param s   the string to test.
-     * @param token   the token.
-     * @return  the part of s that is after the token.
-     */
-    public static String after(String s, String token) {
-        if (s == null) {
-            return null;
-        }
-
-        int i = s.indexOf(token);
-        if (i == -1) {
-            return s;
-        }
-
-        return s.substring(i + token.length());
-    }
-
-    /**
-     * Returns the part of s before the token.
-     * <p/>
-     * <br/>Example:   before("helloWorldThisIsMe", "World") will return "hello".
-     * <br/>Example:   before("helloWorldThisIsMe", "Dog") will return "helloWorldThisIsMe".
-     * <p/>
-     * If the token is not in the string, the entire string is returned.
-     *
-     * @param s   the string to test.
-     * @param token   the token.
-     * @return  the part of s that is before the token.
-     */
-    public static String before(String s, String token) {
-        if (s == null) {
-            return null;
-        }
-
-        int i = s.indexOf(token);
-        if (i == -1) {
-            return s;
-        }
-
-        return s.substring(0, i);
-    }
-
-    /**
-     * Returns the middle part of s between before and after tokens.
-     * <p/>
-     * <br/>Example:   middle("helloWorldThisIsMe", "World", "Me") will return "ThisIs".
-     * <br/>Example:   middle("helloWorldThisIsMe", "World", Dog") will return "ThisIsMe".
-     *
-     * @param s       the string to test
-     * @param before  the before token
-     * @param after   the after token
-     * @return  the middle part
-     */
-    public static String middle(String s, String before, String after) {
-        String first = after(s, before);
-        return before(first, after);
-    }
-
-    /**
-     * Converts the first letter to lowercase
-     * <p/>
-     * <br/>Example: FirstName => firstName
-     * <br/>Example: name => name
-     * <br/>Example: S => s
-     *
-     * @param s  the string
-     * @return  the string with the first letter in lowercase.
-     */
-    public static String firstLetterToLowerCase(String s) {
-        if (s.length() > 1) {
-            return Character.toLowerCase(s.charAt(0)) + s.substring(1);
-        } else if (s.length() == 1) {
-            return String.valueOf(Character.toLowerCase(s.charAt(0)));
-        } else {
-            return s;
-        }
-    }
-}
similarity index 96%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/GenerateToStringActionHandler.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/GenerateToStringActionHandler.java
index 2e15736ccdeeab6426224cd8f526edd5da199d15..7c8faf2367904461a2c22e6483d4c6d3f0c77bdd 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring;
+package org.jetbrains.java.generate;
 
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiClass;
similarity index 93%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/GenerateToStringContext.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/GenerateToStringContext.java
index 37e19542bc03570fe688f6f9ac384e7dd2be9b33..9a433929e681ef49d54226eaea6e559e6226f6d9 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring;
+package org.jetbrains.java.generate;
 
 import com.intellij.openapi.components.*;
-import org.jetbrains.generate.tostring.config.Config;
+import org.jetbrains.java.generate.config.Config;
 
 /**
  * Application context for this plugin.
similarity index 92%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/GenerateToStringUtils.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/GenerateToStringUtils.java
index 0fdb14de510672e31388a6faeb02848fd218284c..cb0a1083441462865233c6f1ae9d1024fe43e1ac 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring;
+package org.jetbrains.java.generate;
 
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.psi.*;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.generate.tostring.config.FilterPattern;
-import org.jetbrains.generate.tostring.psi.PsiAdapter;
+import org.jetbrains.java.generate.config.FilterPattern;
+import org.jetbrains.java.generate.psi.PsiAdapter;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -29,12 +29,12 @@ import java.util.List;
  */
 public class GenerateToStringUtils {
 
-    private static final Logger log = Logger.getInstance("#org.jetbrains.generate.tostring.GenerateToStringUtils");
+    private static final Logger log = Logger.getInstance("#GenerateToStringUtils");
 
     private GenerateToStringUtils() {}
 
     /**
-     * Filters the list of fields from the class with the given parameters from the {@link org.jetbrains.generate.tostring.config.Config config} settings.
+     * Filters the list of fields from the class with the given parameters from the {@link org.jetbrains.java.generate.config.Config config} settings.
      *
      * @param clazz          the class to filter it's fields
      * @param pattern        the filter pattern to filter out unwanted fields
similarity index 96%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/CancelPolicy.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/config/CancelPolicy.java
index 47f9e9ed871777ebfd9a77ef8f05a8fa39f69c36..da340e131dfc4b16fcf41449a2d7744180a48d34 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.config;
+package org.jetbrains.java.generate.config;
 
 import com.intellij.openapi.editor.Editor;
 import com.intellij.psi.PsiClass;
similarity index 99%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/Config.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/config/Config.java
index facdfa526150a8af13912d554508631eb6123a80..95b93d9f90287117c81bb0ff973950f4f6d1fff5 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.config;
+package org.jetbrains.java.generate.config;
 
 /**
  * The configuration is stored standard xmlb.XmlSerializer that automatically stores the
similarity index 97%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/ConflictResolutionPolicy.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/config/ConflictResolutionPolicy.java
index c726b88e8e2f7cead1c7645b111b63b3cd8c90f0..52d7c6a5fd822df6f5d89887b5a42c2928ae5a65 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.config;
+package org.jetbrains.java.generate.config;
 
 import com.intellij.openapi.editor.Editor;
 import com.intellij.psi.PsiClass;
similarity index 95%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/DuplicationPolicy.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/config/DuplicationPolicy.java
index 27ba0057de5392c4bc6f388770993079f5d1acae..5e8555a09090e973532444c7ece27f61abb49c3b 100644 (file)
@@ -17,7 +17,7 @@
 /*
  * @author max
  */
-package org.jetbrains.generate.tostring.config;
+package org.jetbrains.java.generate.config;
 
 public enum DuplicationPolicy {
     ASK("Ask"),
similarity index 97%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/FilterPattern.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/config/FilterPattern.java
index a1cbe9761861c1a8943d1a180a054ae80296c021..e56ac4f3d0ee22df93e75619ce5a493964e5298d 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.config;
+package org.jetbrains.java.generate.config;
 
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.text.StringUtil;
@@ -23,7 +23,7 @@ import com.intellij.psi.PsiModifier;
 import com.intellij.psi.PsiType;
 import gnu.trove.THashSet;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.generate.tostring.psi.PsiAdapter;
+import org.jetbrains.java.generate.psi.PsiAdapter;
 
 import java.util.Collections;
 import java.util.Set;
@@ -35,7 +35,7 @@ import java.util.regex.PatternSyntaxException;
  */
 public class FilterPattern {
 
-    private static final Logger LOG = Logger.getInstance("#org.jetbrains.generate.tostring.config.FilterPattern");
+    private static final Logger LOG = Logger.getInstance("#FilterPattern");
     private static final Set<String> loggerNames = new THashSet<String>();
     static {
       Collections.addAll(loggerNames,
similarity index 95%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/InsertLastStrategy.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/config/InsertLastStrategy.java
index c3b059107d701f1922182b05fb105fd9a68b910d..71e99a9f45b0c61befeb735a5b5d5f4eda309707 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.config;
+package org.jetbrains.java.generate.config;
 
 import com.intellij.openapi.editor.Editor;
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiMethod;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.generate.tostring.psi.PsiAdapter;
+import org.jetbrains.java.generate.psi.PsiAdapter;
 
 /**
  * Inserts the method last in the javafile.
similarity index 96%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/InsertNewMethodStrategy.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/config/InsertNewMethodStrategy.java
index 42fff861b785be20eb2a02e74c2dab55a3db29d6..be9bc241775bd0fbe118f55c5c9d7623c91e52e8 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.config;
+package org.jetbrains.java.generate.config;
 
 import com.intellij.openapi.editor.Editor;
 import com.intellij.psi.PsiClass;
similarity index 95%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/InsertWhere.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/config/InsertWhere.java
index 05b6d4a01f77d9ecf6254f7e629e71ce6b88ae68..497994911d0effbd285bd6f47ac31a5f6e8abdc9 100644 (file)
@@ -17,7 +17,7 @@
 /*
  * @author max
  */
-package org.jetbrains.generate.tostring.config;
+package org.jetbrains.java.generate.config;
 
 public enum InsertWhere {
     AT_CARET("At caret"),
similarity index 96%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/config/PolicyOptions.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/config/PolicyOptions.java
index 40e830bb9a4c68385201cd19a470b6e44b923973..53381892e3cf42d52df5c6647755b1ac76378bbe 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.config;
+package org.jetbrains.java.generate.config;
 
 /**
  * Options for the various policies.
similarity index 96%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/exception/GenerateCodeException.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/exception/GenerateCodeException.java
index 94e8920cbf11a909d0c329211c686f537ec1d0f7..8081574e9811d14803646588bb72dc43eb3f4591 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.exception;
+package org.jetbrains.java.generate.exception;
 
 /**
  * Error generating the javacode for the <code>toString</code> method.
similarity index 96%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/exception/PluginException.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/exception/PluginException.java
index 891dbe7757f0478c1068400bc2543e1a8a17beee..8cdbfff08ab0067dbc098e33bfbb6247a0e5738e 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.exception;
+package org.jetbrains.java.generate.exception;
 
 /**
  * Base plugin exception.
similarity index 84%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/inspection/AbstractToStringInspection.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/inspection/AbstractToStringInspection.java
index d60baa9c7c52971910475a7edfb7ab563dd3f5a3..f0eac792e4c56020232511cb170327364c5679aa 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.inspection;
+package org.jetbrains.java.generate.inspection;
 
 import com.intellij.codeInspection.LocalInspectionTool;
 import com.intellij.openapi.diagnostic.Logger;
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull;
  * Base class for inspection support.
  */
 public abstract class AbstractToStringInspection extends LocalInspectionTool {
-    protected static final Logger log = Logger.getInstance("#org.jetbrains.generate.tostring.inspection.AbstractToStringInspection");
+    protected static final Logger log = Logger.getInstance("#AbstractToStringInspection");
 
     @Override
     @NotNull
similarity index 98%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/inspection/ClassHasNoToStringMethodInspection.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/inspection/ClassHasNoToStringMethodInspection.java
index cd1a7f7ddba86b3b0a54a0bf83461c3afd85e805..a5359d5a1392c27b327db9fa6e4348ff51be3dad 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.inspection;
+package org.jetbrains.java.generate.inspection;
 
 import com.intellij.codeInsight.TestFrameworks;
 import com.intellij.codeInspection.ProblemHighlightType;
@@ -26,8 +26,8 @@ import com.intellij.ui.DocumentAdapter;
 import com.intellij.util.ui.CheckBox;
 import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.generate.tostring.GenerateToStringContext;
-import org.jetbrains.generate.tostring.GenerateToStringUtils;
+import org.jetbrains.java.generate.GenerateToStringContext;
+import org.jetbrains.java.generate.GenerateToStringUtils;
 
 import javax.swing.*;
 import javax.swing.event.DocumentEvent;
similarity index 97%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/inspection/FieldNotUsedInToStringInspection.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/inspection/FieldNotUsedInToStringInspection.java
index be69a8240cb0de4d723dfb91f252b753946edb90..b794e03047bac4cde7e151bd4619dcaf17798d64 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.inspection;
+package org.jetbrains.java.generate.inspection;
 
 import com.intellij.codeInspection.ProblemHighlightType;
 import com.intellij.codeInspection.ProblemsHolder;
@@ -22,8 +22,8 @@ import com.intellij.psi.util.PropertyUtil;
 import gnu.trove.THashSet;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.generate.tostring.GenerateToStringContext;
-import org.jetbrains.generate.tostring.GenerateToStringUtils;
+import org.jetbrains.java.generate.GenerateToStringContext;
+import org.jetbrains.java.generate.GenerateToStringUtils;
 
 import java.util.Collections;
 
similarity index 93%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/inspection/GenerateToStringQuickFix.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/inspection/GenerateToStringQuickFix.java
index 63afe18ccbb395b871f7f60b12deb5d6631b46a2..440a3b38667c8954bf21aa59a9626eba9a40af25 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.inspection;
+package org.jetbrains.java.generate.inspection;
 
 import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.codeInspection.ProblemDescriptor;
@@ -22,7 +22,7 @@ import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.util.PsiTreeUtil;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.generate.tostring.GenerateToStringActionHandler;
+import org.jetbrains.java.generate.GenerateToStringActionHandler;
 
 /**
  * Quick fix to run Generate toString() to fix any code inspection problems.
similarity index 98%
rename from java/java-analysis-impl/src/org/jetbrains/generate/tostring/psi/PsiAdapter.java
rename to java/java-analysis-impl/src/org/jetbrains/java/generate/psi/PsiAdapter.java
index a886f29c84f1cf4f37bc41682ead274b3be33a4d..4bf4f6c7d96ec4fb38d7aa60d7c649fde74f5ad3 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.psi;
+package org.jetbrains.java.generate.psi;
 
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleManager;
@@ -28,7 +29,6 @@ import com.intellij.psi.util.PsiUtil;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.generate.tostring.util.StringUtil;
 
 import static com.intellij.psi.CommonClassNames.*;
 
@@ -137,7 +137,7 @@ public class PsiAdapter {
      * @return true if it's a Map type.
      */
     public static boolean isMapType(PsiElementFactory factory, PsiType type) {
-        return isTypeOf(factory, type, CommonClassNames.JAVA_UTIL_MAP);
+        return isTypeOf(factory, type, JAVA_UTIL_MAP);
     }
 
     /**
@@ -148,7 +148,7 @@ public class PsiAdapter {
      * @return true if it's a Map type.
      */
     public static boolean isSetType(PsiElementFactory factory, PsiType type) {
-        return isTypeOf(factory, type, CommonClassNames.JAVA_UTIL_SET);
+        return isTypeOf(factory, type, JAVA_UTIL_SET);
     }
 
     /**
@@ -159,7 +159,7 @@ public class PsiAdapter {
      * @return true if it's a Map type.
      */
     public static boolean isListType(PsiElementFactory factory, PsiType type) {
-        return isTypeOf(factory, type, CommonClassNames.JAVA_UTIL_LIST);
+        return isTypeOf(factory, type, JAVA_UTIL_LIST);
     }
 
     /**
@@ -517,7 +517,7 @@ public class PsiAdapter {
      * @return true if class is an exception.
      */
     public static boolean isExceptionClass(PsiClass clazz) {
-      return InheritanceUtil.isInheritor(clazz, CommonClassNames.JAVA_LANG_THROWABLE);
+      return InheritanceUtil.isInheritor(clazz, JAVA_LANG_THROWABLE);
     }
 
     /**
@@ -689,6 +689,9 @@ public class PsiAdapter {
       case JDK_1_8:
         version = 8;
         break;
+      case JDK_1_9:
+        version = 9;
+        break;
     }
     return version;
   }
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/EqualsHashCodeTemplatesManager.java b/java/java-impl/src/com/intellij/codeInsight/generation/EqualsHashCodeTemplatesManager.java
new file mode 100644 (file)
index 0000000..5c4b59d
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.generation;
+
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.components.State;
+import com.intellij.openapi.components.Storage;
+import com.intellij.openapi.components.StoragePathMacros;
+import org.jetbrains.java.generate.exception.TemplateResourceException;
+import org.jetbrains.java.generate.template.TemplateResource;
+import org.jetbrains.java.generate.template.TemplatesManager;
+
+import java.io.IOException;
+
+@State(
+  name = "EqualsHashCodeTemplates",
+  storages = {
+    @Storage(
+      file = StoragePathMacros.APP_CONFIG + "/equalsHashCodeTemplates.xml"
+    )}
+)
+public class EqualsHashCodeTemplatesManager extends TemplatesManager {
+  private static final String DEFAULT_EQUALS = "com/intellij/codeInsight/generation/defaultEquals.vm";
+  private static final String DEFAULT_HASH_CODE = "com/intellij/codeInsight/generation/defaultHashCode.vm";
+
+
+  public static TemplatesManager getInstance() {
+    return ServiceManager.getService(EqualsHashCodeTemplatesManager.class);
+  }
+
+  @Override
+  public TemplateResource[] getDefaultTemplates() {
+    try {
+      return new TemplateResource[] {
+        new TemplateResource("Default equals", readFile(DEFAULT_EQUALS), true),
+        new TemplateResource("Default hashCode", readFile(DEFAULT_HASH_CODE), true),
+      };
+    }
+    catch (IOException e) {
+      throw new TemplateResourceException("Error loading default templates", e);
+    }
+  }
+
+  private static String readFile(String resourceName) throws IOException {
+    return readFile(resourceName, EqualsHashCodeTemplatesManager.class);
+  }
+}
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/defaultEquals.vm b/java/java-impl/src/com/intellij/codeInsight/generation/defaultEquals.vm
new file mode 100644 (file)
index 0000000..f07eab1
--- /dev/null
@@ -0,0 +1,2 @@
+//todo
+//equals template to place here
\ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/defaultHashCode.vm b/java/java-impl/src/com/intellij/codeInsight/generation/defaultHashCode.vm
new file mode 100644 (file)
index 0000000..bbcfca6
--- /dev/null
@@ -0,0 +1,2 @@
+//todo
+//hashCode template to place here
\ No newline at end of file
index 66c438dd337e6facf63a4a14222245e6bb905cf2..72326bd843c0cafcca36a27c37b7719eb7d78727 100644 (file)
@@ -32,7 +32,6 @@ import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.Contract;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.generate.tostring.util.StringUtil;
 
 /**
  * @author peter
@@ -81,7 +80,7 @@ public class EditContractIntention extends BaseIntentionAction {
       @Nullable
       @Override
       public String getErrorText(String inputString) {
-        if (StringUtil.isEmpty(inputString)) return null;
+        if (com.intellij.openapi.util.text.StringUtil.isEmpty(inputString)) return null;
 
         return ContractInspection.checkContract(method, inputString);
       }
@@ -102,7 +101,7 @@ public class EditContractIntention extends BaseIntentionAction {
     try {
       ExternalAnnotationsManager manager = ExternalAnnotationsManager.getInstance(project);
       manager.deannotate(method, ControlFlowAnalyzer.ORG_JETBRAINS_ANNOTATIONS_CONTRACT);
-      if (StringUtil.isNotEmpty(newContract)) {
+      if (!com.intellij.openapi.util.text.StringUtil.isEmpty(newContract)) {
         PsiAnnotation mockAnno = JavaPsiFacade.getElementFactory(project).createAnnotationFromText("@Foo(\"" + newContract + "\")", null);
         manager.annotateExternally(method, ControlFlowAnalyzer.ORG_JETBRAINS_ANNOTATIONS_CONTRACT, file,
                                    mockAnno.getParameterList().getAttributes());
index 12607efd927ec118360dbe7f20b35b56d0bcf911..be70cc8a5d8abd11d4594e2034573b7b34100e34 100644 (file)
@@ -33,7 +33,6 @@ import com.intellij.openapi.ui.Messages;
 import com.intellij.psi.*;
 import com.intellij.psi.util.PsiUtil;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.generate.tostring.util.StringUtil;
 import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
 
 /**
@@ -99,7 +98,7 @@ public class CreatePackageInfoAction extends CreateFromTemplateActionBase implem
         final PsiPackage aPackage = directoryService.getPackage(directory);
         if (aPackage != null) {
           final String qualifiedName = aPackage.getQualifiedName();
-          if (StringUtil.isEmpty(qualifiedName) || nameHelper.isQualifiedName(qualifiedName)) {
+          if (com.intellij.openapi.util.text.StringUtil.isEmpty(qualifiedName) || nameHelper.isQualifiedName(qualifiedName)) {
             return true;
           }
         }
index e7918134afe5fb08c5fc398d6f20a52d4927afbd..6c0eb5c41f5378c1b2b39aac14b88f7dc1f9cfb4 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.refactoring.wrapreturnvalue;
 
+import com.intellij.psi.util.PsiUtil;
 import com.intellij.ui.ListCellRendererWrapper;
 import com.intellij.ide.util.TreeClassChooser;
 import com.intellij.ide.util.TreeClassChooserFactory;
@@ -215,12 +216,18 @@ class WrapReturnValueDialog extends RefactoringDialog {
         final PsiClass currentClass = facade.findClass(existingClassField.getText(), GlobalSearchScope.allScope(myProject));
         if (currentClass != null) {
           model.removeAllElements();
+          final PsiType returnType = sourceMethod.getReturnType();
+          assert returnType != null;
           for (PsiField field : currentClass.getFields()) {
-            final PsiType returnType = sourceMethod.getReturnType();
-            assert returnType != null;
-            if (TypeConversionUtil.isAssignable(field.getType(), returnType)) {
+            final PsiType fieldType = field.getType();
+            if (TypeConversionUtil.isAssignable(fieldType, returnType)) {
               model.addElement(field);
             }
+            else {
+              if (WrapReturnValueProcessor.getInferredType(fieldType, returnType, currentClass, sourceMethod) != null) {
+                model.addElement(field);
+              }
+            }
           }
         }
       }
index d410252f5528d53469741b3b5c21d9fe8e76f7be..6d7ed2ffd93976ed30b16633b20132660fd9cf7a 100644 (file)
@@ -31,6 +31,7 @@ import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.search.searches.OverridingMethodsSearch;
 import com.intellij.psi.search.searches.ReferencesSearch;
 import com.intellij.psi.util.PropertyUtil;
+import com.intellij.psi.util.PsiUtil;
 import com.intellij.psi.util.TypeConversionUtil;
 import com.intellij.refactoring.MoveDestination;
 import com.intellij.refactoring.RefactorJBundle;
@@ -157,9 +158,32 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
       }, ","));
       returnTypeBuffer.append('>');
     }
+    else if (myDelegateField != null) {
+      final PsiType type = myDelegateField.getType();
+      final PsiType returnType = myMethod.getReturnType();
+      final PsiClass containingClass = myDelegateField.getContainingClass();
+      final PsiType inferredType = getInferredType(type, returnType, containingClass, myMethod);
+      if (inferredType != null) {
+        returnTypeBuffer.append("<").append(inferredType.getCanonicalText()).append(">");
+      }
+    }
     return returnTypeBuffer.toString();
   }
 
+  protected static PsiType getInferredType(PsiType type, PsiType returnType, PsiClass containingClass, PsiMethod method) {
+    if (containingClass != null && containingClass.getTypeParameters().length == 1) {
+      final PsiSubstitutor substitutor = PsiResolveHelper.SERVICE.getInstance(method.getProject())
+        .inferTypeArguments(containingClass.getTypeParameters(), new PsiType[]{type}, new PsiType[]{returnType}, PsiUtil.getLanguageLevel(
+          method));
+      final PsiTypeParameter typeParameter = containingClass.getTypeParameters()[0];
+      final PsiType substituted = substitutor.substitute(typeParameter);
+      if (substituted != null && !typeParameter.equals(PsiUtil.resolveClassInClassTypeOnly(substituted))) {
+        return substituted;
+      }
+    }
+    return null;
+  }
+
   @Override
   protected boolean preprocessUsages(final Ref<UsageInfo[]> refUsages) {
     MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
@@ -198,7 +222,7 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
             final PsiParameter parameter = parameters[0];
             final PsiType parameterType = parameter.getType();
             for (PsiType returnType : returnTypes) {
-              if (!TypeConversionUtil.isAssignable(parameterType, returnType)) {
+              if (getInferredType(parameterType, returnType, existingClass, myMethod) == null && !TypeConversionUtil.isAssignable(parameterType, returnType)) {
                 continue constr;
               }
             }
index d1a8cdb7d085f3a62370cafec4e1ea61d927bd86..e97089098f840cd3fb3e6217eaf468d48fa39f51 100644 (file)
@@ -28,4 +28,8 @@ public interface PsiClassObjectAccessExpression extends PsiExpression {
    */
   @NotNull
   PsiTypeElement getOperand();
+
+  @NotNull
+  @Override
+  PsiType getType();
 }
index 5e13c8f780fc52f1044451ac7f7735178555b258..9a3fc135e16fc1d2d0e485ef401b51fcc311a38a 100644 (file)
@@ -260,7 +260,11 @@ public class TypesDistinctProver {
     }
     else if (bound instanceof PsiWildcardType) {
       final PsiType boundBound = ((PsiWildcardType)bound).getBound();
-      return boundBound != null && !boundBound.equals(type);
+      if (boundBound != null && !boundBound.equals(type)) {
+        final PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(boundBound);
+        return psiClass == null || !(((PsiWildcardType)bound).isExtends() && possibleClasses.contains(psiClass));
+      }
+      return false;
     }
     return true;
   }
index 7641f629fa24ff594cb3d3f1d02a0734e8965541..a55d7d53b3d5015a0cef47332054b3e6d38d4c76 100644 (file)
@@ -273,6 +273,7 @@ public class PsiImplUtil {
     return types;
   }
 
+  @NotNull
   public static PsiType getType(@NotNull PsiClassObjectAccessExpression classAccessExpression) {
     GlobalSearchScope resolveScope = classAccessExpression.getResolveScope();
     PsiManager manager = classAccessExpression.getManager();
index b0c633d9c030e85b0625761d30107ad24a5ca331..6e81bfcb114ad5a1efc6b5109c6596001181c15a 100644 (file)
@@ -37,6 +37,7 @@ public class PsiClassObjectAccessExpressionImpl extends ExpressionPsiElement imp
     super(CLASS_OBJECT_ACCESS_EXPRESSION);
   }
 
+  @NotNull
   @Override
   public PsiType getType() {
     return PsiImplUtil.getType(this);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AssignabilityBetweenWildcardsAndArrays.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/AssignabilityBetweenWildcardsAndArrays.java
new file mode 100644 (file)
index 0000000..709249d
--- /dev/null
@@ -0,0 +1,24 @@
+import java.io.Serializable;
+
+class B {}
+abstract class A {
+  abstract Class<?> get();
+  abstract Class<? extends Object> get1();
+  abstract Class<? super Object> get2();
+
+  abstract Class<? extends B> get3();
+  abstract Class<? super B> get4();
+
+  abstract Class<? extends Serializable> get5();
+  abstract Class<? super Serializable> get6();
+
+  {
+    if (get()  == byte[].class);
+    if (get1() == byte[].class);
+    if (<error descr="Operator '==' cannot be applied to 'java.lang.Class<capture<? super java.lang.Object>>', 'java.lang.Class<byte[]>'">get2() == byte[].class</error>);
+    if (<error descr="Operator '==' cannot be applied to 'java.lang.Class<capture<? extends B>>', 'java.lang.Class<byte[]>'">get3() == byte[].class</error>);
+    if (<error descr="Operator '==' cannot be applied to 'java.lang.Class<capture<? super B>>', 'java.lang.Class<byte[]>'">get4() == byte[].class</error>);
+    if (get5() == byte[].class);
+    if (<error descr="Operator '==' cannot be applied to 'java.lang.Class<capture<? super java.io.Serializable>>', 'java.lang.Class<byte[]>'">get6() == byte[].class</error>);
+  } 
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/afterLambdaWithFormalParams.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/afterLambdaWithFormalParams.java
new file mode 100644 (file)
index 0000000..a33ef0f
--- /dev/null
@@ -0,0 +1,16 @@
+// "Replace lambda with method reference" "true"
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+class Test {
+  public Test(String s) {}
+
+  public static void define(Supplier<?> moduleConstructor){}
+  public static void define(Function<?, ?> moduleConstructor){}
+  public static void define(BiFunction<?, ?, ?> moduleConstructor){}
+
+  {
+    define((Function<String, Object>) Test::new);
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeLambdaWithFormalParams.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambda2methodReference/beforeLambdaWithFormalParams.java
new file mode 100644 (file)
index 0000000..d8e1d88
--- /dev/null
@@ -0,0 +1,16 @@
+// "Replace lambda with method reference" "true"
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+class Test {
+  public Test(String s) {}
+
+  public static void define(Supplier<?> moduleConstructor){}
+  public static void define(Function<?, ?> moduleConstructor){}
+  public static void define(BiFunction<?, ?, ?> moduleConstructor){}
+
+  {
+    define((String s) -> new Test<caret>(s));
+  }
+}
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldType/after/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldType/after/Test.java
new file mode 100644 (file)
index 0000000..af4bb01
--- /dev/null
@@ -0,0 +1,10 @@
+class Test {
+    Wrapper<String> foo() {
+    return new Wrapper<String>("");
+  }
+
+  void bar() {
+    String s = foo().getMyField();
+  }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldType/after/Wrapper.java b/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldType/after/Wrapper.java
new file mode 100644 (file)
index 0000000..4562e93
--- /dev/null
@@ -0,0 +1,10 @@
+class Wrapper<T> {
+  T myField;
+  Wrapper(T s) {
+    myField = s;
+  }
+
+  String getMyField() {
+    return myField;
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldType/before/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldType/before/Test.java
new file mode 100644 (file)
index 0000000..df1a8df
--- /dev/null
@@ -0,0 +1,10 @@
+class Test {
+  String foo() {
+    return "";
+  }
+
+  void bar() {
+    String s = foo();
+  }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldType/before/Wrapper.java b/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldType/before/Wrapper.java
new file mode 100644 (file)
index 0000000..4562e93
--- /dev/null
@@ -0,0 +1,10 @@
+class Wrapper<T> {
+  T myField;
+  Wrapper(T s) {
+    myField = s;
+  }
+
+  String getMyField() {
+    return myField;
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldTypeArg/after/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldTypeArg/after/Test.java
new file mode 100644 (file)
index 0000000..249a8bc
--- /dev/null
@@ -0,0 +1,12 @@
+import java.util.List;
+
+class Test {
+    Wrapper<String> foo() {
+    return new Wrapper<String>(null);
+  }
+
+  void bar() {
+    List<String> s = foo().getMyField();
+  }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldTypeArg/after/Wrapper.java b/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldTypeArg/after/Wrapper.java
new file mode 100644 (file)
index 0000000..46a4678
--- /dev/null
@@ -0,0 +1,11 @@
+import java.util.List;
+class Wrapper<T> {
+  List<T> myField;
+  Wrapper(List<T> s) {
+    myField = s;
+  }
+
+  List<T> getMyField() {
+    return myField;
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldTypeArg/before/Test.java b/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldTypeArg/before/Test.java
new file mode 100644 (file)
index 0000000..0ecc382
--- /dev/null
@@ -0,0 +1,12 @@
+import java.util.List;
+
+class Test {
+  List<String> foo() {
+    return null;
+  }
+
+  void bar() {
+    List<String> s = foo();
+  }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldTypeArg/before/Wrapper.java b/java/java-tests/testData/refactoring/wrapReturnValue/inferFieldTypeArg/before/Wrapper.java
new file mode 100644 (file)
index 0000000..46a4678
--- /dev/null
@@ -0,0 +1,11 @@
+import java.util.List;
+class Wrapper<T> {
+  List<T> myField;
+  Wrapper(List<T> s) {
+    myField = s;
+  }
+
+  List<T> getMyField() {
+    return myField;
+  }
+}
\ No newline at end of file
index bb377400bd0678677f4437c3b6453e732a214700..87677f08bf2a58ed91cdc0420d22a9be9e242d38 100644 (file)
@@ -450,6 +450,10 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
     doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
   }
 
+  public void testAssignabilityBetweenWildcardsAndArrays() throws Exception {
+    doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
+  }
+
   public void testJavaUtilCollections_NoVerify() throws Exception {
     PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
     assertNotNull(collectionsClass);
index 2c684b72c4a6a6bc48305c81f86eea328c373d25..d9c7c8707702d11c22eb74d7046205fd6892321f 100644 (file)
@@ -213,8 +213,8 @@ public class BytecodeAnalysisTest extends JavaCodeInsightFixtureTestCase {
     Assert.assertEquals(asmKey, psiKey);
   }
 
-  private void setUpDataClasses() throws IOException {
-    File classesDir = new File(Test01.class.getResource("/" + Test01.class.getPackage().getName().replace('.', '/')).getFile());
+  private void setUpDataClasses() throws Exception {
+    File classesDir = new File(Test01.class.getResource("/" + Test01.class.getPackage().getName().replace('.', '/')).toURI());
     File destDir = new File(myModule.getProject().getBaseDir().getPath() + myClassesProjectRelativePath);
     FileUtil.copyDir(classesDir, destDir);
     VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(destDir);
index b1efc20c45230bc6595eddcef16cc710f1594880..a6e362073bb9be99cbdd4daa3c262e313edf6a64 100644 (file)
@@ -51,6 +51,8 @@ public class WrapReturnValueTest extends MultiFileTestCase {
   public void testHierarchy() { doTest(false, null, true); }
   public void testAnonymous() { doTest(true, null, false); }
   public void testWrongFieldAssignment() { doTest(true, "Existing class does not have appropriate constructor", false); }
+  public void testInferFieldType() { doTest(true, null, false); }
+  public void testInferFieldTypeArg() { doTest(true, null, false); }
   public void testWrongFieldType() { doTest(true, "Existing class does not have appropriate constructor", false); }
   public void testStaticMethodInnerClass() { doTest(false, null, true); }
   public void testRawReturnType() { doTest(true, "Existing class does not have appropriate constructor"); }
diff --git a/java/java-tests/testSrc/com/intellij/run/JavaPathMacroCollectorTest.groovy b/java/java-tests/testSrc/com/intellij/run/JavaPathMacroCollectorTest.groovy
new file mode 100644 (file)
index 0000000..129d9d3
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.run
+
+import com.intellij.application.options.PathMacrosCollector
+import com.intellij.openapi.util.JDOMUtil;
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
+
+public class JavaPathMacroCollectorTest extends LightCodeInsightFixtureTestCase {
+  public void testJunitConfiguration() {
+    String text = '''
+  <component name="RunManager" selected="JUnit.FooWithComments.test$withDollar$2">
+    <configuration default="false" name="FooWithComments.test$withDollar$2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
+      <module name="idea.folding.problem" />
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+      <option name="ALTERNATIVE_JRE_PATH" />
+      <option name="PACKAGE_NAME" value="idea.folding.problem" />
+      <option name="MAIN_CLASS_NAME" value="idea.folding.problem.FooWithComments" />
+      <option name="METHOD_NAME" value="test$withDollar$2" />
+      <option name="TEST_OBJECT" value="method" />
+      <option name="VM_PARAMETERS" />
+      <option name="PARAMETERS" />
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
+      <option name="ENV_VARIABLES" />
+      <option name="PASS_PARENT_ENVS" value="true" />
+      <option name="TEST_SEARCH_SCOPE">
+        <value defaultName="moduleWithDependencies" />
+      </option>
+      <envs />
+      <patterns />
+      <method />
+    </configuration>
+    <list size="4">
+      <item index="0" class="java.lang.String" itemvalue="Application.Foo" />
+      <item index="1" class="java.lang.String" itemvalue="Application.FooWithComments" />
+      <item index="2" class="java.lang.String" itemvalue="Application.A" />
+      <item index="3" class="java.lang.String" itemvalue="JUnit.FooWithComments.test$withDollar$2" />
+    </list>
+    <recent_temporary>
+      <list size="4">
+        <item index="0" class="java.lang.String" itemvalue="JUnit.FooWithComments.test$withDollar$2" />
+      </list>
+    </recent_temporary>
+  </component>
+'''
+    def element = JDOMUtil.loadDocument(text).rootElement
+    assert PathMacrosCollector.getMacroNames(element).empty
+  }
+
+}
diff --git a/native/WinLauncher/WinLauncher/WinLauncher.manifest b/native/WinLauncher/WinLauncher/WinLauncher.manifest
deleted file mode 100644 (file)
index a43d169..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
-          manifestVersion="1.0">
-  <application xmlns="urn:schemas-microsoft-com:asm.v3">
-    <windowsSettings>
-      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
-    </windowsSettings>
-  </application>
-</assembly>
index ceedc4d25153865b1a91c2c9783d6d6be9bab41b..b973671bec0058ad3f98edf644f9aaba2577032c 100644 (file)
Binary files a/native/WinLauncher/WinLauncher/WinLauncher.rc and b/native/WinLauncher/WinLauncher/WinLauncher.rc differ
index f140ec2fe7af8ee6d1ea2e422143a5b47131f7f5..812ad622c9ab89a4db90b130fd3dfbc5074e93ce 100644 (file)
@@ -89,6 +89,9 @@
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
     </Link>
+    <Manifest>
+      <EnableDPIAwareness>true</EnableDPIAwareness>
+    </Manifest>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <ClCompile>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
     </Link>
+    <Manifest>
+      <EnableDPIAwareness>true</EnableDPIAwareness>
+    </Manifest>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
     </Link>
+    <Manifest>
+      <EnableDPIAwareness>true</EnableDPIAwareness>
+    </Manifest>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <ClCompile>
       <OptimizeReferences>true</OptimizeReferences>
       <OutputFile>$(OutDir)WinLauncher64.exe</OutputFile>
     </Link>
+    <Manifest>
+      <EnableDPIAwareness>true</EnableDPIAwareness>
+    </Manifest>
   </ItemDefinitionGroup>
   <ItemGroup>
     <None Include="ReadMe.txt" />
index 930ae2d76dfb0551aa67d5ed79473ed251aed553..729870ad78d108fb755ad79b612f176a950451d8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 package com.intellij.codeInspection;
 
+/**
+ * Marker interface for inspections which can be executed as part of "Code Cleanup" action.
+ * Such inspections need to provide some quickfixes which can run without user input and
+ * are generally safe to apply.
+ */
 public interface CleanupLocalInspectionTool {
 }
index 66d8b7d41ba3a5b2bc79d274a438246d8bdc64e2..630d53006d87d18cbd7451b24aae0748c9d42899 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -109,6 +109,9 @@ public class InspectionEP extends LanguageExtensionPoint implements InspectionPr
   @Attribute("applyToDialects")
   public boolean applyToDialects = true;
 
+  /**
+   * If true, the inspection can run as part of the code cleanup action.
+   */
   @Attribute("cleanupTool")
   public boolean cleanupTool = false;
 
index 45a62d073e629f54aac44e009cf14a247eb605b2..f5e8d6c01451a5265678c836c66b7d623fdb9e81 100644 (file)
@@ -239,7 +239,7 @@ org.intellij.lang.xpath.validation.inspections.ImplicitTypeConversion
 org.intellij.lang.xpath.validation.inspections.RedundantTypeConversion
 org.intellij.plugins.intelliLang.inject.java.validation.LanguageMismatch
 org.intellij.plugins.intelliLang.pattern.PatternValidator
-org.jetbrains.generate.tostring.inspection.ClassHasNoToStringMethodInspection
+org.jetbrains.java.generate.inspection.ClassHasNoToStringMethodInspection
 org.jetbrains.idea.devkit.inspections.ComponentNotRegisteredInspection
 org.jetbrains.plugins.groovy.codeInspection.assignment.GroovyAssignmentCanBeOperatorAssignmentInspection
 org.jetbrains.plugins.groovy.codeInspection.confusing.GroovyOverlyComplexArithmeticExpressionInspection
index 1be6c2db7ff80cd98a93fa1eaf05aa073e3446f3..ddb590b9c4aab21131097d78d86a10a5a3be4c11 100644 (file)
@@ -432,20 +432,21 @@ public interface PsiElement extends UserDataHolder, Iconable {
   boolean isWritable();
 
   /**
-   * Returns the reference associated with this PSI element. If the element has multiple
-   * associated references (see {@link #getReferences()} for an example), returns the first
-   * associated reference.
+   * Returns the reference from this PSI element to another PSI element (or elements), if one exists.
+   * If the element has multiple associated references (see {@link #getReferences()}
+   * for an example), returns the first associated reference.
    *
    * @return the reference instance, or null if the PSI element does not have any
    *         associated references.
+   * @see com.intellij.psi.search.searches.ReferencesSearch
    */
   @Nullable
   @Contract(pure=true)
   PsiReference getReference();
 
   /**
-   * Returns all references associated with this PSI element. An element can be associated
-   * with multiple references when, for example, the element is a string literal containing
+   * Returns all references from this PSI element to other PSI elements. An element can
+   * have multiple references when, for example, the element is a string literal containing
    * multiple sub-strings which are valid full-qualified class names. If an element
    * contains only one text fragment which acts as a reference but the reference has
    * multiple possible targets, {@link PsiPolyVariantReference} should be used instead
@@ -457,6 +458,7 @@ public interface PsiElement extends UserDataHolder, Iconable {
    * @return the array of references, or an empty array if the element has no associated
    *         references.
    * @see com.intellij.psi.PsiReferenceService#getReferences
+   * @see com.intellij.psi.search.searches.ReferencesSearch
    */
   @NotNull
   @Contract(pure=true)
index c296bf9227ed14632f2ba4911338dd08ea7f8927..f06e30d1c9466191f84bd7e4cc962e9634612a4d 100644 (file)
@@ -33,6 +33,7 @@ import org.jetbrains.annotations.Nullable;
  * @see com.intellij.psi.PsiReferenceService#getReferences(PsiElement, com.intellij.psi.PsiReferenceService.Hints)
  * @see com.intellij.psi.PsiReferenceBase
  * @see com.intellij.psi.PsiReferenceContributor
+ * @see com.intellij.psi.search.searches.ReferencesSearch
  */
 
 public interface PsiReference {
index f6dd16c898ec02b4bad2118a2cf6eff33869eab4..fe9221a4489cafa70e7dd731ac77a1fe4fba8a1a 100644 (file)
@@ -26,6 +26,9 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 /**
+ * Locates all references to a specified PSI element.
+ *
+ * @see com.intellij.psi.PsiReference
  * @author max
  */
 public class ReferencesSearch extends ExtensibleQueryFactory<PsiReference, ReferencesSearch.SearchParameters> {
@@ -96,21 +99,50 @@ public class ReferencesSearch extends ExtensibleQueryFactory<PsiReference, Refer
     }
   }
 
+  /**
+   * Searches for references to the specified element in the scope in which such references are expected to be found, according to
+   * dependencies and access rules.
+   *
+   * @param element the element (declaration) the references to which are requested.
+   * @return the query allowing to enumerate the references.
+   */
   @NotNull
   public static Query<PsiReference> search(@NotNull PsiElement element) {
     return search(element, GlobalSearchScope.allScope(PsiUtilCore.getProjectInReadAction(element)), false);
   }
 
+  /**
+   * Searches for references to the specified element in the specified scope.
+   *
+   * @param element the element (declaration) the references to which are requested.
+   * @param searchScope the scope in which the search is performed.
+   * @return the query allowing to enumerate the references.
+   */
   @NotNull
   public static Query<PsiReference> search(@NotNull PsiElement element, @NotNull SearchScope searchScope) {
     return search(element, searchScope, false);
   }
 
+  /**
+   * Searches for references to the specified element in the specified scope, optionally returning also references which
+   * are invalid because of access rules (e.g. references to a private method from a different class).
+   *
+   * @param element the element (declaration) the references to which are requested.
+   * @param searchScope the scope in which the search is performed.
+   * @param ignoreAccessScope if true, references which are invalid because of access rules are included in the results.
+   * @return the query allowing to enumerate the references.
+   */
   @NotNull
   public static Query<PsiReference> search(@NotNull PsiElement element, @NotNull SearchScope searchScope, boolean ignoreAccessScope) {
     return search(new SearchParameters(element, searchScope, ignoreAccessScope));
   }
 
+  /**
+   * Searches for references to the specified element according to the specified parameters.
+   *
+   * @param parameters the parameters for the search (contain also the element the references to which are requested).
+   * @return the query allowing to enumerate the references.
+   */
   @NotNull
   public static Query<PsiReference> search(@NotNull final SearchParameters parameters) {
     final Query<PsiReference> result = INSTANCE.createQuery(parameters);
index 1b8acbccc56e5ec887a2c6f95f739a8a11b7829c..e780e3922b2946e685c67107cab35bff2ef1c13b 100644 (file)
@@ -90,7 +90,7 @@ public class CopyHandler extends EditorActionHandler {
 
     List<TextBlockTransferableData> transferableDatas = new ArrayList<TextBlockTransferableData>();
     CopyPastePostProcessor<? extends TextBlockTransferableData>[] postProcessors = Extensions.getExtensions(CopyPastePostProcessor.EP_NAME);
-    for (CopyPastePostProcessor<? extends TextBlockTransferableData> processor : DumbService.getInstance(project).filterByDumbAwareness( Arrays.asList(postProcessors))) {
+    for (CopyPastePostProcessor<? extends TextBlockTransferableData> processor : DumbService.getInstance(project).filterByDumbAwareness(Arrays.asList(postProcessors))) {
       transferableDatas.addAll(processor.collectTransferableData(file, editor, startOffsets, endOffsets));
     }
 
index e95410218a1e9a03601901fe52e1e609c9c3bb96..f34488917b27b8f831e9ce17d9d64955510705e2 100644 (file)
@@ -19,6 +19,7 @@ package com.intellij.codeInsight.editorActions;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.RangeMarker;
 import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Ref;
 import com.intellij.psi.PsiFile;
@@ -29,6 +30,10 @@ import java.util.Collections;
 import java.util.List;
 
 /**
+ * An extension to collect and apply additional transferable data when performing copy-paste in editors.<p/>
+ * 
+ * Can be {@link DumbAware}
+ * 
  * @author yole
  */
 public abstract class CopyPastePostProcessor<T extends TextBlockTransferableData> {
index 7a9a54414c528b1a0c54b9b42ecd39235d4770ef..21d9aedbb18bff5c894f91cb941e5e1df6403104 100644 (file)
@@ -380,17 +380,17 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
       final List<LocalInspectionToolWrapper> lTools = getWrappersFromTools(localTools, file);
       pass.doInspectInBatch(this, inspectionManager, lTools);
 
-      JobLauncher.getInstance().invokeConcurrentlyUnderProgress(globalSimpleTools, myProgressIndicator, false, new Processor<Tools>() {
+      final List<GlobalInspectionToolWrapper> tools = getWrappersFromTools(globalSimpleTools, file);
+      JobLauncher.getInstance().invokeConcurrentlyUnderProgress(tools, myProgressIndicator, false, new Processor<GlobalInspectionToolWrapper>() {
         @Override
-        public boolean process(Tools tools) {
-          GlobalInspectionToolWrapper toolWrapper = (GlobalInspectionToolWrapper)tools.getTool();
-          GlobalSimpleInspectionTool tool = (GlobalSimpleInspectionTool)toolWrapper.getTool();
-          ProblemsHolder problemsHolder = new ProblemsHolder(inspectionManager, file, false);
-          ProblemDescriptionsProcessor problemDescriptionProcessor = getProblemDescriptionProcessor(toolWrapper, wrappersMap);
-          tool.checkFile(file, inspectionManager, problemsHolder, GlobalInspectionContextImpl.this, problemDescriptionProcessor);
-          InspectionToolPresentation toolPresentation = getPresentation(toolWrapper);
-          LocalDescriptorsUtil.addProblemDescriptors(problemsHolder.getResults(), false, GlobalInspectionContextImpl.this, null,
-                                                     CONVERT, toolPresentation);
+        public boolean process(GlobalInspectionToolWrapper toolWrapper) {
+            GlobalSimpleInspectionTool tool = (GlobalSimpleInspectionTool)toolWrapper.getTool();
+            ProblemsHolder problemsHolder = new ProblemsHolder(inspectionManager, file, false);
+            ProblemDescriptionsProcessor problemDescriptionProcessor = getProblemDescriptionProcessor(toolWrapper, wrappersMap);
+            tool.checkFile(file, inspectionManager, problemsHolder, GlobalInspectionContextImpl.this, problemDescriptionProcessor);
+            InspectionToolPresentation toolPresentation = getPresentation(toolWrapper);
+            LocalDescriptorsUtil.addProblemDescriptors(problemsHolder.getResults(), false, GlobalInspectionContextImpl.this, null,
+                                                       CONVERT, toolPresentation);
           return true;
         }
       });
@@ -575,10 +575,10 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
     }
   }
 
-  private static List<LocalInspectionToolWrapper> getWrappersFromTools(List<Tools> localTools, PsiFile file) {
-    final List<LocalInspectionToolWrapper> lTools = new ArrayList<LocalInspectionToolWrapper>();
+  private static <T extends InspectionToolWrapper> List<T> getWrappersFromTools(List<Tools> localTools, PsiFile file) {
+    final List<T> lTools = new ArrayList<T>();
     for (Tools tool : localTools) {
-      final LocalInspectionToolWrapper enabledTool = (LocalInspectionToolWrapper)tool.getEnabledTool(file);
+      final T enabledTool = (T)tool.getEnabledTool(file);
       if (enabledTool != null) {
         lTools.add(enabledTool);
       }
index afa589fb7dbba6f867835c522a0ba479449e48f8..84adf3cfb1f0ca8b76aba10219c41f5bc8a6a253 100644 (file)
@@ -28,9 +28,23 @@ public class RunConfigurationPathMacroFilter extends PathMacroFilter {
     final Element parent = attribute.getParent();
     final String attrName = attribute.getName();
     String tagName = parent.getName();
-    return tagName.equals(EnvironmentVariablesComponent.ENV) &&
-              (attrName.equals(EnvironmentVariablesComponent.NAME) || attrName.equals(EnvironmentVariablesComponent.VALUE))
-           || tagName.equals("option") && "MAIN_CLASS_NAME".equals(parent.getAttributeValue("name"));
+    if (tagName.equals(EnvironmentVariablesComponent.ENV) &&
+        (attrName.equals(EnvironmentVariablesComponent.NAME) || attrName.equals(EnvironmentVariablesComponent.VALUE))) {
+      return true;
+    }
+
+    if (tagName.equals("configuration") && attrName.equals("name")) {
+      return true;
+    }
+
+    if (tagName.equals("option")) {
+      String optionName = parent.getAttributeValue("name");
+      if ("MAIN_CLASS_NAME".equals(optionName) || "METHOD_NAME".equals(optionName)) {
+        return true;
+      }
+    }
+    
+    return false;
   }
 
   @Override
diff --git a/platform/lang-impl/src/com/intellij/execution/filters/FileHyperlinkParsedData.java b/platform/lang-impl/src/com/intellij/execution/filters/FileHyperlinkParsedData.java
new file mode 100644 (file)
index 0000000..bab166e
--- /dev/null
@@ -0,0 +1,45 @@
+package com.intellij.execution.filters;
+
+import org.jetbrains.annotations.NotNull;
+
+public class FileHyperlinkParsedData {
+
+  private final String myFilePath;
+  private final int myDocumentLine;
+  private final int myDocumentColumn;
+  private final int myHyperlinkStartOffset;
+  private final int myHyperlinkEndOffset;
+
+  public FileHyperlinkParsedData(@NotNull String filePath,
+                                 int documentLine,
+                                 int documentColumn,
+                                 int hyperlinkStartOffset,
+                                 int hyperlinkEndOffset) {
+    myFilePath = filePath;
+    myDocumentLine = documentLine;
+    myDocumentColumn = documentColumn;
+    myHyperlinkStartOffset = hyperlinkStartOffset;
+    myHyperlinkEndOffset = hyperlinkEndOffset;
+  }
+
+  @NotNull
+  public String getFilePath() {
+    return myFilePath;
+  }
+
+  public int getDocumentLine() {
+    return myDocumentLine;
+  }
+
+  public int getDocumentColumn() {
+    return myDocumentColumn;
+  }
+
+  public int getHyperlinkStartOffset() {
+    return myHyperlinkStartOffset;
+  }
+
+  public int getHyperlinkEndOffset() {
+    return myHyperlinkEndOffset;
+  }
+}
index 9086841fa211135cd45495eca0880f1cbdaf3c16..1d997a30d0afcfc882bf9d5e25be6f9348357d20 100644 (file)
@@ -134,20 +134,13 @@ public class SafeDeleteDialog extends DialogWrapper {
       panel.add(myCbSearchTextOccurrences, gbc);
     }
 
-    if (myDelegate == null) {
-      final RefactoringSettings refactoringSettings = RefactoringSettings.getInstance();
-      myCbSearchInComments.setSelected(refactoringSettings.SAFE_DELETE_SEARCH_IN_COMMENTS);
-      if (myCbSearchTextOccurrences != null) {
-        myCbSearchTextOccurrences.setSelected(refactoringSettings.SAFE_DELETE_SEARCH_IN_NON_JAVA);
-      }
-      if (myCbSafeDelete != null) {
-        myCbSafeDelete.setSelected(refactoringSettings.SAFE_DELETE_WHEN_DELETE);
-      }
-    } else {
-      myCbSearchInComments.setSelected(myDelegate.isToSearchInComments(myElements[0]));
-      if (myCbSearchTextOccurrences != null) {
-        myCbSearchTextOccurrences.setSelected(myDelegate.isToSearchForTextOccurrences(myElements[0]));
-      }
+    final RefactoringSettings refactoringSettings = RefactoringSettings.getInstance();
+    if (myCbSafeDelete != null) {
+      myCbSafeDelete.setSelected(refactoringSettings.SAFE_DELETE_WHEN_DELETE);
+    }
+    myCbSearchInComments.setSelected(myDelegate != null ? myDelegate.isToSearchInComments(myElements[0]) : refactoringSettings.SAFE_DELETE_SEARCH_IN_COMMENTS);
+    if (myCbSearchTextOccurrences != null) {
+      myCbSearchTextOccurrences.setSelected(myDelegate != null ? myDelegate.isToSearchForTextOccurrences(myElements[0]) : refactoringSettings.SAFE_DELETE_SEARCH_IN_NON_JAVA);
     }
     updateControls(myCbSearchTextOccurrences);
     updateControls(myCbSearchInComments);
@@ -203,20 +196,22 @@ public class SafeDeleteDialog extends DialogWrapper {
       super.doOKAction();
     }
 
-    if (myDelegate == null) {
-      final RefactoringSettings refactoringSettings = RefactoringSettings.getInstance();
-      refactoringSettings.SAFE_DELETE_SEARCH_IN_COMMENTS = isSearchInComments();
-      if (myCbSearchTextOccurrences != null) {
-        refactoringSettings.SAFE_DELETE_SEARCH_IN_NON_JAVA = isSearchForTextOccurences();
-      }
-      if (myCbSafeDelete != null) {
-        refactoringSettings.SAFE_DELETE_WHEN_DELETE = myCbSafeDelete.isSelected();
-      }
-    } else {
-      myDelegate.setToSearchInComments(myElements[0], isSearchInComments());
-
-      if (myCbSearchTextOccurrences != null) {
-        myDelegate.setToSearchForTextOccurrences(myElements[0], isSearchForTextOccurences());
+    final RefactoringSettings refactoringSettings = RefactoringSettings.getInstance();
+    if (myCbSafeDelete != null) {
+      refactoringSettings.SAFE_DELETE_WHEN_DELETE = myCbSafeDelete.isSelected();
+    }
+    if (isSafeDelete()) {
+      if (myDelegate == null) {
+        refactoringSettings.SAFE_DELETE_SEARCH_IN_COMMENTS = isSearchInComments();
+        if (myCbSearchTextOccurrences != null) {
+          refactoringSettings.SAFE_DELETE_SEARCH_IN_NON_JAVA = isSearchForTextOccurences();
+        }
+      } else {
+        myDelegate.setToSearchInComments(myElements[0], isSearchInComments());
+  
+        if (myCbSearchTextOccurrences != null) {
+          myDelegate.setToSearchForTextOccurrences(myElements[0], isSearchForTextOccurences());
+        }
       }
     }
   }
index 1d43ebb362a50eef2b28a542be087af009908287..68afc2b26b6b36395ff5284fe18098d67afedd76 100644 (file)
@@ -18,7 +18,6 @@ package com.intellij.ui;
 
 import com.intellij.openapi.application.Result;
 import com.intellij.openapi.command.WriteCommandAction;
-import com.intellij.openapi.command.undo.UndoConstants;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
@@ -58,7 +57,7 @@ public class StringComboboxEditor extends EditorComboBoxEditor {
     if (usePlainMatcher) {
       document.putUserData(USE_PLAIN_PREFIX_MATCHER, true);
     }
-    document.putUserData(UndoConstants.DONT_RECORD_UNDO, true);
+
     super.setItem(document);
   }
 
index 314cd74ce87196faa1fd5da1e7773865fe269ae2..352f11bde2dd3fb53220ec3da40eb27cb59dc8be 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@ import com.intellij.openapi.extensions.ExtensionPointName;
 import com.intellij.util.xmlb.annotations.Attribute;
 
 /**
+ * Allows to define a project template in plugin.xml.
+ *
  * @author Dmitry Avdeev
  *         Date: 07.11.13
  */
@@ -27,12 +29,31 @@ public class ProjectTemplateEP extends AbstractExtensionPointBean {
 
   public static final ExtensionPointName<ProjectTemplateEP> EP_NAME = ExtensionPointName.create("com.intellij.projectTemplate");
 
+  /**
+   * If the category attribute is set to true, specifies the title under which the template appears in the first page
+   * of the new project dialog. If the category attribute is set to false, specifies the module type ID for which
+   * the template is displayed in the "Create project from template" list.
+   */
   @Attribute("projectType")
   public String projectType;
 
+  /**
+   * The path to a .zip file containing the template contents of the project. The top level directory of the archive
+   * is ignored (i.e. the contents of the archive must be a single directory, which is going to be renamed to the
+   * name of the project the user is creating). Under that directory, .idea/description.html specifies the description
+   * of the template and .idea/project-template.xml specifies additional metadata for the template.
+   */
   @Attribute("templatePath")
   public String templatePath;
 
+  /**
+   * If true, this template will be offered on the first page of the new project wizard dialog, and the value
+   * of the projectType attribute will define the top-level category under which the template will appear.
+   *
+   * If false, the template will be offered on the second page of the dialog, under the "[x] Create project from template"
+   * option, and the projectType attribute is the module type ID for which the template will be available
+   * (for example, "JAVA_MODULE" for a regular Java module).
+   */
   @Attribute("category")
   public boolean category;
 }
index f7451649974d83197dc581d36a774f46946d7287..2f53da09cd1295c1640bd895a13f46a915a80458 100644 (file)
@@ -39,9 +39,7 @@ public class GlobalMatchingVisitor extends AbstractMatchingVisitor {
   // context of matching
   private MatchContext matchContext;
 
-  private MatchingHandler myLastHandler;
-
-  private Map<Language, PsiElementVisitor> myLanguage2MatchingVisitor = new HashMap<Language, PsiElementVisitor>(1);
+  private final Map<Language, PsiElementVisitor> myLanguage2MatchingVisitor = new HashMap<Language, PsiElementVisitor>(1);
 
   public PsiElement getElement() {
     return myElement;
@@ -162,8 +160,7 @@ public class GlobalMatchingVisitor extends AbstractMatchingVisitor {
       return nodes.hasNext() == nodes2.hasNext();
     }
 
-    myLastHandler = matchContext.getPattern().getHandler(nodes.current());
-    return myLastHandler.matchSequentially(
+    return matchContext.getPattern().getHandler(nodes.current()).matchSequentially(
       nodes,
       nodes2,
       matchContext
index eb3147012c7651e2bb3414edabab9f8b8d901f23..f95039d7b40aa24fb070c89ab2bb1a6f7b0a594c 100644 (file)
@@ -3063,6 +3063,36 @@ public class StringUtil extends StringUtilRt {
     return builder.toString().replaceAll("\\.{4,}", "...");
   }
 
+  /**
+     * Does the string have an uppercase character?
+     * @param s  the string to test.
+     * @return   true if the string has an uppercase character, false if not.
+     */
+    public static boolean hasUpperCaseChar(String s) {
+        char[] chars = s.toCharArray();
+        for (char c : chars) {
+            if (Character.isUpperCase(c)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+  /**
+     * Does the string have a lowercase character?
+     * @param s  the string to test.
+     * @return   true if the string has a lowercase character, false if not.
+     */
+    public static boolean hasLowerCaseChar(String s) {
+        char[] chars = s.toCharArray();
+        for (char c : chars) {
+            if (Character.isLowerCase(c)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
   /**
    * Expirable CharSequence. Very useful to control external library execution time,
    * i.e. when java.util.regex.Pattern match goes out of control.
index 02554ab35332619c94aea33743ee79c750c957de..3a0c68d2f1fc931e90802b021f152fc57f9f6e01 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.siyeh.ig.style;
 
+import com.intellij.codeInspection.CleanupLocalInspectionTool;
 import com.intellij.codeInspection.canBeFinal.CanBeFinalHandler;
 import com.intellij.psi.PsiField;
 import com.intellij.psi.PsiModifier;
@@ -26,7 +27,7 @@ import com.siyeh.ig.fixes.MakeFieldFinalFix;
 import com.siyeh.ig.psiutils.FinalUtils;
 import org.jetbrains.annotations.NotNull;
 
-public class FieldMayBeFinalInspection extends BaseInspection {
+public class FieldMayBeFinalInspection extends BaseInspection implements CleanupLocalInspectionTool {
 
   @Override
   @NotNull
index e510381682275c923feff1f921549ee79a05da55..ccf65acb98dfd04d55974c7da9857238d30fde4b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,7 +46,6 @@ class VariableAccessVisitor extends JavaRecursiveElementVisitor {
   private final boolean countGettersAndSetters;
 
   VariableAccessVisitor(PsiClass aClass, boolean countGettersAndSetters) {
-    super();
     this.aClass = aClass;
     this.countGettersAndSetters = countGettersAndSetters;
   }
@@ -54,7 +53,12 @@ class VariableAccessVisitor extends JavaRecursiveElementVisitor {
   @Override
   public void visitClass(PsiClass classToVisit) {
     calculatePrivateMethodUsagesIfNecessary();
+    final boolean wasInSync = m_inSynchronizedContext;
+    if (!classToVisit.equals(aClass)) {
+      m_inSynchronizedContext = false;
+    }
     super.visitClass(classToVisit);
+    m_inSynchronizedContext = wasInSync;
   }
 
   @Override
@@ -131,11 +135,11 @@ class VariableAccessVisitor extends JavaRecursiveElementVisitor {
         return;
       }
     }
-    final boolean methodIsSynchonized =
+    final boolean methodIsSynchronized =
       method.hasModifierProperty(PsiModifier.SYNCHRONIZED)
       || methodIsAlwaysUsedSynchronized(method);
     boolean wasInSync = false;
-    if (methodIsSynchonized) {
+    if (methodIsSynchronized) {
       wasInSync = m_inSynchronizedContext;
       m_inSynchronizedContext = true;
     }
@@ -144,7 +148,7 @@ class VariableAccessVisitor extends JavaRecursiveElementVisitor {
       m_inInitializer = true;
     }
     super.visitMethod(method);
-    if (methodIsSynchonized) {
+    if (methodIsSynchronized) {
       m_inSynchronizedContext = wasInSync;
     }
     if (isConstructor) {
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/FieldAccessedSynchronizedAndUnsynchronized.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/FieldAccessedSynchronizedAndUnsynchronized.java
deleted file mode 100644 (file)
index 5f747c9..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.siyeh.igtest.threading;
-
-public class FieldAccessedSynchronizedAndUnsynchronized
-{
-    private final Object m_lock = new Object();          
-    private Object m_contents = new Object();
-
-    public void foo()
-    {
-        synchronized(m_lock)
-        {
-            m_contents = new Object();
-        }
-        getContents();
-    }
-
-    private Object getContents()
-    {
-        getContents2();
-        return m_contents;
-    }
-
-    private void getContents2() {
-        getContents();
-    }
-
-}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/field_accessed_synchronized_and_unsynchronized/FieldAccessedSynchronizedAndUnsynchronized.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/threading/field_accessed_synchronized_and_unsynchronized/FieldAccessedSynchronizedAndUnsynchronized.java
new file mode 100644 (file)
index 0000000..61e2e8a
--- /dev/null
@@ -0,0 +1,42 @@
+package com.siyeh.igtest.threading.field_accessed_synchronized_and_unsynchronized;
+
+public class FieldAccessedSynchronizedAndUnsynchronized
+{
+    private final Object m_lock = new Object();          
+    private Object <warning descr="Field 'm_contents' is accessed in both synchronized and unsynchronized contexts">m_contents</warning> = new Object();
+
+    public void foo()
+    {
+        synchronized(m_lock)
+        {
+            m_contents = new Object();
+        }
+        getContents();
+    }
+
+    private Object getContents()
+    {
+        getContents2();
+        return m_contents;
+    }
+
+    private void getContents2() {
+        getContents();
+    }
+
+}
+class Test {
+  private Object <warning descr="Field 'object' is accessed in both synchronized and unsynchronized contexts">object</warning>;
+
+  synchronized Runnable method() {
+    return new Runnable() {
+      @Override public void run() {
+        System.out.println(object);
+      }
+    };
+  }
+
+  synchronized void setObject(Object object) {
+    this.object = object;
+  }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/threading/FieldAccessedSynchronizedAndUnsynchronizedInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/threading/FieldAccessedSynchronizedAndUnsynchronizedInspectionTest.java
new file mode 100644 (file)
index 0000000..952b136
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.threading;
+
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.siyeh.ig.LightInspectionTestCase;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class FieldAccessedSynchronizedAndUnsynchronizedInspectionTest extends LightInspectionTestCase {
+
+  public void testFieldAccessedSynchronizedAndUnsynchronized() {
+    doTest();
+  }
+
+  @Nullable
+  @Override
+  protected InspectionProfileEntry getInspection() {
+    return new FieldAccessedSynchronizedAndUnsynchronizedInspection();
+  }
+}
diff --git a/plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResourceLocator.java b/plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResourceLocator.java
deleted file mode 100644 (file)
index 82cff7d..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2001-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jetbrains.generate.tostring.template;
-
-import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vfs.CharsetToolkit;
-import org.jetbrains.generate.tostring.exception.TemplateResourceException;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-/**
- * Resource locator for default method body templates.
- */
-public class TemplateResourceLocator {
-
-  private static final String DEFAULT_CONCAT = "/org/jetbrains/generate/tostring/template/DefaultConcatMember.vm";
-  private static final String DEFAULT_CONCAT_GROOVY = "/org/jetbrains/generate/tostring/template/DefaultConcatMemberGroovy.vm";
-  private static final String DEFAULT_CONCAT_SUPER = "/org/jetbrains/generate/tostring/template/DefaultConcatMemberSuper.vm";
-  private static final String DEFAULT_BUFFER = "/org/jetbrains/generate/tostring/template/DefaultBuffer.vm";
-  private static final String DEFAULT_BUILDER = "/org/jetbrains/generate/tostring/template/DefaultBuilder.vm";
-  private static final String DEFAULT_TOSTRINGBUILDER = "/org/jetbrains/generate/tostring/template/DefaultToStringBuilder.vm";
-  private static final String DEFAULT_TOSTRINGBUILDER3 = "/org/jetbrains/generate/tostring/template/DefaultToStringBuilder3.vm";
-  private static final String DEFAULT_GUAVA = "/org/jetbrains/generate/tostring/template/DefaultGuava.vm";
-
-  private TemplateResourceLocator() {}
-
-  /**
-   * Get the default templates.
-   */
-  public static TemplateResource[] getDefaultTemplates() {
-    try {
-      return new TemplateResource[]{
-        new TemplateResource("String concat (+)", readFile(DEFAULT_CONCAT), true),
-        new TemplateResource("String concat (+) and super.toString()", readFile(DEFAULT_CONCAT_SUPER), true),
-        new TemplateResource("StringBuffer", readFile(DEFAULT_BUFFER), true),
-        new TemplateResource("StringBuilder (JDK 1.5)", readFile(DEFAULT_BUILDER), true),
-        new TemplateResource("ToStringBuilder (Apache commons-lang)", readFile(DEFAULT_TOSTRINGBUILDER), true),
-        new TemplateResource("ToStringBuilder (Apache commons-lang 3)", readFile(DEFAULT_TOSTRINGBUILDER3), true),
-        new TemplateResource("Objects.toStringHelper (Guava)", readFile(DEFAULT_GUAVA), true),
-        new TemplateResource("Groovy: String concat (+)", readFile(DEFAULT_CONCAT_GROOVY), true),
-      };
-    }
-    catch (IOException e) {
-      throw new TemplateResourceException("Error loading default templates", e);
-    }
-  }
-
-  /**
-   * Reads the content of the resource and return it as a String.
-   * <p/>Uses the class loader that loaded this class to find the resource in its classpath.
-   *
-   * @param resource the resource name. Will lookup using the classpath.
-   * @return the content if the resource
-   * @throws IOException error reading the file.
-   */
-  private static String readFile(String resource) throws IOException {
-    BufferedInputStream in = new BufferedInputStream(TemplateResourceLocator.class.getResourceAsStream(resource));
-    return StringUtil.convertLineSeparators(FileUtil.loadTextAndClose(new InputStreamReader(in, CharsetToolkit.UTF8_CHARSET)));
-  }
-}
similarity index 96%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/GenerateToStringAction.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringAction.java
index cbfaff7ec686555326b5ab90d0f1718eee1253fe..c46b70b1d4ccf76335a773435c9a6a7b410eb489 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring;
+package org.jetbrains.java.generate;
 
 import com.intellij.openapi.editor.actionSystem.EditorAction;
 
similarity index 90%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/GenerateToStringActionHandlerImpl.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringActionHandlerImpl.java
index 0e7f6a84c086eb78a88b479bd44c7f6fd444b434..38631f596d734c9a39c457d21a0f6a6859f0328f 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring;
+package org.jetbrains.java.generate;
 
 import com.intellij.codeInsight.generation.PsiElementClassMember;
 import com.intellij.codeInsight.hint.HintManager;
 import com.intellij.ide.util.MemberChooser;
-import com.intellij.ide.util.MemberChooserBuilder;
 import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.CommonDataKeys;
 import com.intellij.openapi.actionSystem.DataContext;
@@ -39,10 +38,11 @@ import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.generate.tostring.config.Config;
-import org.jetbrains.generate.tostring.template.TemplateResource;
-import org.jetbrains.generate.tostring.template.TemplatesManager;
-import org.jetbrains.generate.tostring.view.TemplatesPanel;
+import org.jetbrains.generate.tostring.GenerateToStringClassFilter;
+import org.jetbrains.java.generate.config.Config;
+import org.jetbrains.java.generate.template.TemplateResource;
+import org.jetbrains.java.generate.template.toString.ToStringTemplatesManager;
+import org.jetbrains.java.generate.view.TemplatesPanel;
 
 import javax.swing.*;
 import java.awt.*;
@@ -57,7 +57,7 @@ import java.util.List;
  * The action-handler that does the code generation.
  */
 public class GenerateToStringActionHandlerImpl extends EditorWriteActionHandler implements GenerateToStringActionHandler {
-    private static final Logger logger = Logger.getInstance("#org.jetbrains.generate.tostring.GenerateToStringActionHandlerImpl");
+    private static final Logger logger = Logger.getInstance("#GenerateToStringActionHandlerImpl");
 
     public void executeWriteAction(Editor editor, DataContext dataContext) {
         final Project project = CommonDataKeys.PROJECT.getData(dataContext);
@@ -107,7 +107,7 @@ public class GenerateToStringActionHandlerImpl extends EditorWriteActionHandler
                     Collection<PsiMember> selectedMembers = GenerationUtil.convertClassMembersToPsiMembers(chooser.getSelectedElements());
 
                     final TemplateResource template = header.getSelectedTemplate();
-                    TemplatesManager.getInstance().setDefaultTemplate(template);
+                    ToStringTemplatesManager.getInstance().setDefaultTemplate(template);
 
                     if (template.isValidTemplate()) {
                         GenerateToStringWorker.executeGenerateActionLater(clazz, editor, selectedMembers, template,
@@ -183,7 +183,7 @@ public class GenerateToStringActionHandlerImpl extends EditorWriteActionHandler
         public MemberChooserHeaderPanel(final PsiClass clazz) {
             super(new GridBagLayout());
 
-            final Collection<TemplateResource> templates = TemplatesManager.getInstance().getAllTemplates();
+            final Collection<TemplateResource> templates = ToStringTemplatesManager.getInstance().getAllTemplates();
             final TemplateResource[] all = templates.toArray(new TemplateResource[templates.size()]);
 
             final JButton settingsButton = new JButton("Settings");
@@ -216,23 +216,23 @@ public class GenerateToStringActionHandlerImpl extends EditorWriteActionHandler
                             updateDialog(clazz, chooser);
 
                             comboBox.removeAllItems();
-                            for (TemplateResource resource : TemplatesManager.getInstance().getAllTemplates()) {
+                            for (TemplateResource resource : ToStringTemplatesManager.getInstance().getAllTemplates()) {
                               comboBox.addItem(resource);
                             }
-                            comboBox.setSelectedItem(TemplatesManager.getInstance().getDefaultTemplate());
+                            comboBox.setSelectedItem(ToStringTemplatesManager.getInstance().getDefaultTemplate());
                         }
                     };
 
                     ShowSettingsUtil.getInstance().editConfigurable(MemberChooserHeaderPanel.this, composite, new Runnable() {
                         public void run() {
-                            ui.selectItem(TemplatesManager.getInstance().getDefaultTemplate());
+                            ui.selectItem(ToStringTemplatesManager.getInstance().getDefaultTemplate());
                         }
                     });
                   Disposer.dispose(disposable);
                 }
             });
 
-            comboBox.setSelectedItem(TemplatesManager.getInstance().getDefaultTemplate());
+            comboBox.setSelectedItem(ToStringTemplatesManager.getInstance().getDefaultTemplate());
 
             final JLabel templatesLabel = new JLabel("Template: ");
             templatesLabel.setDisplayedMnemonic('T');
similarity index 87%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/GenerateToStringConfigurable.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringConfigurable.java
index 59b9602ba281673f9c6059d919b177cf99e8d25d..3514cee42ad8653ceb7be177f67e959eadf0ae36 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring;
+package org.jetbrains.java.generate;
 
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.options.Configurable;
 import com.intellij.openapi.options.ConfigurationException;
 import com.intellij.openapi.project.Project;
-import org.jetbrains.generate.tostring.config.Config;
-import org.jetbrains.generate.tostring.view.ConfigUI;
+import org.jetbrains.java.generate.config.Config;
+import org.jetbrains.java.generate.view.ConfigUI;
 
 import javax.swing.*;
 
@@ -28,7 +28,7 @@ import javax.swing.*;
  * @author yole
  */
 public class GenerateToStringConfigurable implements Configurable {
-  private static final Logger log = Logger.getInstance("#org.jetbrains.generate.tostring.GenerateToStringConfigurable"); 
+  private static final Logger log = Logger.getInstance("#GenerateToStringConfigurable");
 
   private ConfigUI configUI;
   private final Project myProject;
similarity index 72%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/GenerateToStringWorker.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/GenerateToStringWorker.java
index aff07225bf17ac8e74eb3e1dcbd85a4c2c158830..cde95464b43902fb6000171dc52da643b97572f5 100644 (file)
@@ -17,7 +17,7 @@
 /*
  * @author max
  */
-package org.jetbrains.generate.tostring;
+package org.jetbrains.java.generate;
 
 import com.intellij.codeInsight.hint.HintManager;
 import com.intellij.openapi.application.ApplicationManager;
@@ -32,22 +32,17 @@ import com.intellij.psi.codeStyle.CodeStyleManager;
 import com.intellij.psi.codeStyle.JavaCodeStyleManager;
 import com.intellij.psi.javadoc.PsiDocComment;
 import com.intellij.util.IncorrectOperationException;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.generate.tostring.config.*;
-import org.jetbrains.generate.tostring.element.*;
-import org.jetbrains.generate.tostring.exception.GenerateCodeException;
-import org.jetbrains.generate.tostring.psi.PsiAdapter;
-import org.jetbrains.generate.tostring.template.TemplateResource;
-import org.jetbrains.generate.tostring.velocity.VelocityFactory;
-import org.jetbrains.generate.tostring.view.MethodExistsDialog;
+import org.jetbrains.java.generate.config.*;
+import org.jetbrains.java.generate.exception.GenerateCodeException;
+import org.jetbrains.java.generate.psi.PsiAdapter;
+import org.jetbrains.java.generate.template.TemplateResource;
+import org.jetbrains.java.generate.view.MethodExistsDialog;
 
-import java.io.StringWriter;
 import java.util.*;
 
 public class GenerateToStringWorker {
-  private static final Logger logger = Logger.getInstance("#org.jetbrains.generate.tostring.GenerateToStringWorker");
+  private static final Logger logger = Logger.getInstance("#" + GenerateToStringWorker.class.getName());
 
   private final Editor editor;
   private final PsiClass clazz;
@@ -61,6 +56,70 @@ public class GenerateToStringWorker {
     this.hasOverrideAnnotation = insertAtOverride;
   }
 
+  /**
+   * Creates the <code>toString</code> method.
+   *
+   * @param selectedMembers the selected members as both {@link com.intellij.psi.PsiField} and {@link com.intellij.psi.PsiMethod}.
+   * @param policy          conflict resolution policy
+   * @param params          additional parameters stored with key/value in the map.
+   * @param template        the template to use
+   * @return the created method, null if the method is not created due the user cancels this operation
+   * @throws GenerateCodeException       is thrown when there is an error generating the javacode.
+   * @throws IncorrectOperationException is thrown by IDEA.
+   */
+  @Nullable
+  private PsiMethod createToStringMethod(Collection<PsiMember> selectedMembers,
+                                         ConflictResolutionPolicy policy,
+                                         Map<String, String> params,
+                                         TemplateResource template) throws IncorrectOperationException, GenerateCodeException {
+    // generate code using velocity
+    String body = GenerationUtil.velocityGenerateCode(clazz, selectedMembers, params, template.getMethodBody(), config.getSortElements(), config.isUseFullyQualifiedName());
+    if (logger.isDebugEnabled()) logger.debug("Method body generated from Velocity:\n" + body);
+
+    // fix weird linebreak problem in IDEA #3296 and later
+    body = StringUtil.convertLineSeparators(body);
+
+    // create psi newMethod named toString()
+    final JVMElementFactory topLevelFactory = JVMElementFactories.getFactory(clazz.getLanguage(), clazz.getProject());
+    if (topLevelFactory == null) {
+      return null;
+    }
+    PsiMethod newMethod;
+    try {
+      newMethod = topLevelFactory.createMethodFromText(template.getMethodSignature() + " { " + body + " }", clazz);
+      CodeStyleManager.getInstance(clazz.getProject()).reformat(newMethod);
+    } catch (IncorrectOperationException ignore) {
+      HintManager.getInstance().showErrorHint(editor, "'toString()' method could not be created from template '" +
+                                                      template.getFileName() + '\'');
+      return null;
+    }
+
+    // insertNewMethod conflict resolution policy (add/replace, duplicate, cancel)
+    PsiMethod existingMethod = clazz.findMethodBySignature(newMethod, false);
+    PsiMethod toStringMethod = policy.applyMethod(clazz, existingMethod, newMethod, editor);
+    if (toStringMethod == null) {
+      return null; // user cancelled so return null
+    }
+
+    if (hasOverrideAnnotation) {
+      toStringMethod.getModifierList().addAnnotation("java.lang.Override");
+    }
+
+    // applyJavaDoc conflict resolution policy (add or keep existing)
+    String existingJavaDoc = params.get("existingJavaDoc");
+    String newJavaDoc = template.getJavaDoc();
+    if (existingJavaDoc != null || newJavaDoc != null) {
+      // generate javadoc using velocity
+      newJavaDoc = GenerationUtil.velocityGenerateCode(clazz, selectedMembers, params, newJavaDoc, config.getSortElements(), config.isUseFullyQualifiedName());
+      if (logger.isDebugEnabled()) logger.debug("JavaDoc body generated from Velocity:\n" + newJavaDoc);
+
+      GenerationUtil.applyJavaDoc(toStringMethod, existingJavaDoc, newJavaDoc);
+    }
+
+    // return the created method
+    return toStringMethod;
+  }
+
   public void execute(Collection<PsiMember> members, TemplateResource template) throws IncorrectOperationException, GenerateCodeException {
     // decide what to do if the method already exists
     ConflictResolutionPolicy resolutionPolicy = exitsMethodDialog(template);
@@ -74,7 +133,8 @@ public class GenerateToStringWorker {
     beforeCreateToStringMethod(params, template);
 
     // generate method
-    PsiMethod method = createToStringMethod(members, resolutionPolicy, params, template);
+    PsiMethod method =
+      createToStringMethod(members, resolutionPolicy, params, template);
 
     // after, if method was generated (not cancel policy)
     if (method != null) {
@@ -135,75 +195,6 @@ public class GenerateToStringWorker {
     }
   }
 
-  /**
-   * Creates the <code>toString</code> method.
-   *
-   * @param selectedMembers the selected members as both {@link com.intellij.psi.PsiField} and {@link com.intellij.psi.PsiMethod}.
-   * @param policy          conflict resolution policy
-   * @param params          additional parameters stored with key/value in the map.
-   * @param template        the template to use
-   * @return the created method, null if the method is not created due the user cancels this operation
-   * @throws GenerateCodeException       is thrown when there is an error generating the javacode.
-   * @throws IncorrectOperationException is thrown by IDEA.
-   */
-  @Nullable
-  private PsiMethod createToStringMethod(Collection<PsiMember> selectedMembers,
-                                         ConflictResolutionPolicy policy,
-                                         Map<String, String> params,
-                                         TemplateResource template) throws IncorrectOperationException, GenerateCodeException {
-    // generate code using velocity
-    String body = velocityGenerateCode(selectedMembers, params, template.getMethodBody());
-    if (logger.isDebugEnabled()) logger.debug("Method body generated from Velocity:\n" + body);
-
-    // fix weird linebreak problem in IDEA #3296 and later
-    body = StringUtil.convertLineSeparators(body);
-
-    // create psi newMethod named toString()
-    final JVMElementFactory topLevelFactory = JVMElementFactories.getFactory(clazz.getLanguage(), clazz.getProject());
-    if (topLevelFactory == null) {
-      return null;
-    }
-    PsiMethod newMethod;
-    try {
-      newMethod = topLevelFactory.createMethodFromText(template.getMethodSignature() + " { " + body + " }", clazz);
-      CodeStyleManager.getInstance(clazz.getProject()).reformat(newMethod);
-    } catch (IncorrectOperationException ignore) {
-      HintManager.getInstance().showErrorHint(editor, "'toString()' method could not be created from template '" +
-                                                      template.getFileName() + '\'');
-      return null;
-    }
-
-    // insertNewMethod conflict resolution policy (add/replace, duplicate, cancel)
-    PsiMethod existingMethod = clazz.findMethodBySignature(newMethod, false);
-    PsiMethod toStringMethod = policy.applyMethod(clazz, existingMethod, newMethod, editor);
-    if (toStringMethod == null) {
-      return null; // user cancelled so return null
-    }
-
-    if (hasOverrideAnnotation) {
-      toStringMethod.getModifierList().addAnnotation("java.lang.Override");
-    }
-
-    // applyJavaDoc conflict resolution policy (add or keep existing)
-    String existingJavaDoc = params.get("existingJavaDoc");
-    String newJavaDoc = template.getJavaDoc();
-    if (existingJavaDoc != null || newJavaDoc != null) {
-      // generate javadoc using velocity
-      newJavaDoc = velocityGenerateCode(selectedMembers, params, newJavaDoc);
-      if (logger.isDebugEnabled()) logger.debug("JavaDoc body generated from Velocity:\n" + newJavaDoc);
-
-      applyJavaDoc(toStringMethod, existingJavaDoc, newJavaDoc);
-    }
-
-    // return the created method
-    return toStringMethod;
-  }
-
-  private static void applyJavaDoc(PsiMethod newMethod, String existingJavaDoc, String newJavaDoc) {
-    String text = newJavaDoc != null ? newJavaDoc : existingJavaDoc; // prefer to use new javadoc
-    PsiAdapter.addOrReplaceJavadoc(newMethod, text, true);
-  }
-
 
   /**
    * This method is executed just after the <code>toString</code> method is created or updated.
@@ -253,75 +244,6 @@ public class GenerateToStringWorker {
     }
   }
 
-  /**
-   * Generates the code using Velocity.
-   * <p/>
-   * This is used to create the <code>toString</code> method body and it's javadoc.
-   *
-   * @param selectedMembers the selected members as both {@link com.intellij.psi.PsiField} and {@link com.intellij.psi.PsiMethod}.
-   * @param params          additional parameters stored with key/value in the map.
-   * @param templateMacro   the velocity macro template
-   * @return code (usually javacode). Returns null if templateMacro is null.
-   * @throws GenerateCodeException is thrown when there is an error generating the javacode.
-   */
-  private String velocityGenerateCode(Collection<PsiMember> selectedMembers, Map<String, String> params, String templateMacro)
-    throws GenerateCodeException {
-    if (templateMacro == null) {
-      return null;
-    }
-
-    StringWriter sw = new StringWriter();
-    try {
-      VelocityContext vc = new VelocityContext();
-
-      vc.put("java_version", PsiAdapter.getJavaVersion(clazz));
-
-      // field information
-      logger.debug("Velocity Context - adding fields");
-      vc.put("fields", ElementUtils.getOnlyAsFieldElements(selectedMembers));
-
-      // method information
-      logger.debug("Velocity Context - adding methods");
-      vc.put("methods", ElementUtils.getOnlyAsMethodElements(selectedMembers));
-
-      // element information (both fields and methods)
-      logger.debug("Velocity Context - adding members (fields and methods)");
-      List<Element> elements = ElementUtils.getOnlyAsFieldAndMethodElements(selectedMembers);
-      // sort elements if enabled and not using chooser dialog
-      if (config.getSortElements() != 0) {
-        Collections.sort(elements, new ElementComparator(config.getSortElements()));
-      }
-      vc.put("members", elements);
-
-      // class information
-      ClassElement ce = ElementFactory.newClassElement(clazz);
-      vc.put("class", ce);
-      if (logger.isDebugEnabled()) logger.debug("Velocity Context - adding class: " + ce);
-
-      // information to keep as it is to avoid breaking compatibility with prior releases
-      vc.put("classname", config.isUseFullyQualifiedName() ? ce.getQualifiedName() : ce.getName());
-      vc.put("FQClassname", ce.getQualifiedName());
-
-      if (logger.isDebugEnabled()) logger.debug("Velocity Macro:\n" + templateMacro);
-
-      // velocity
-      VelocityEngine velocity = VelocityFactory.getVelocityEngine();
-      logger.debug("Executing velocity +++ START +++");
-      velocity.evaluate(vc, sw, this.getClass().getName(), templateMacro);
-      logger.debug("Executing velocity +++ END +++");
-
-      // any additional packages to import returned from velocity?
-      if (vc.get("autoImportPackages") != null) {
-        params.put("autoImportPackages", (String)vc.get("autoImportPackages"));
-      }
-    }
-    catch (Exception e) {
-      throw new GenerateCodeException("Error in Velocity code generator", e);
-    }
-
-    return sw.getBuffer().toString();
-  }
-
   /**
    * Generates the toString() code for the specified class and selected
    * fields, doing the work through a WriteAction ran by a CommandProcessor.
similarity index 51%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/GenerationUtil.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/GenerationUtil.java
index 1c5b2fed439dc9a26e8791a4721463962a104948..362709a503c0dd763c2713bae9e1bb617e3abcda 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring;
+package org.jetbrains.java.generate;
 
 import com.intellij.codeInsight.generation.PsiElementClassMember;
 import com.intellij.codeInsight.generation.PsiFieldMember;
@@ -21,19 +21,25 @@ import com.intellij.codeInsight.generation.PsiMethodMember;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.Messages;
+import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiField;
 import com.intellij.psi.PsiMember;
 import com.intellij.psi.PsiMethod;
+import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.generate.tostring.exception.GenerateCodeException;
-import org.jetbrains.generate.tostring.exception.PluginException;
+import org.jetbrains.java.generate.element.*;
+import org.jetbrains.java.generate.exception.GenerateCodeException;
+import org.jetbrains.java.generate.exception.PluginException;
+import org.jetbrains.java.generate.psi.PsiAdapter;
+import org.jetbrains.java.generate.velocity.VelocityFactory;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import java.io.StringWriter;
+import java.util.*;
 
 public class GenerationUtil {
-  private static final Logger log = Logger.getInstance("#org.jetbrains.generate.tostring.GenerationUtil");
+  private static final Logger logger = Logger.getInstance("#" + GenerationUtil.class.getName());
 
   /**
      * Handles any exception during the executing on this plugin.
@@ -43,7 +49,7 @@ public class GenerationUtil {
      * @throws RuntimeException is thrown for severe exceptions
      */
     public static void handleException(Project project, Exception e) throws RuntimeException {
-        log.info(e);
+        logger.info(e);
 
         if (e instanceof GenerateCodeException) {
             // code generation error - display velocity error in error dialog so user can identify problem quicker
@@ -105,4 +111,84 @@ public class GenerationUtil {
 
       return psiMemberList;
   }
+
+  public static void applyJavaDoc(PsiMethod newMethod, String existingJavaDoc, String newJavaDoc) {
+    String text = newJavaDoc != null ? newJavaDoc : existingJavaDoc; // prefer to use new javadoc
+    PsiAdapter.addOrReplaceJavadoc(newMethod, text, true);
+  }
+
+  /**
+   * Generates the code using Velocity.
+   * <p/>
+   * This is used to create the <code>toString</code> method body and it's javadoc.
+   *
+   * @param selectedMembers the selected members as both {@link com.intellij.psi.PsiField} and {@link com.intellij.psi.PsiMethod}.
+   * @param params          additional parameters stored with key/value in the map.
+   * @param templateMacro   the velocity macro template
+   * @return code (usually javacode). Returns null if templateMacro is null.
+   * @throws org.jetbrains.java.generate.exception.GenerateCodeException is thrown when there is an error generating the javacode.
+   */
+  public static String velocityGenerateCode(PsiClass clazz,
+                                            Collection<? extends PsiMember> selectedMembers,
+                                            Map<String, String> params,
+                                            String templateMacro,
+                                            int sortElements,
+                                            boolean useFullyQualifiedName)
+    throws GenerateCodeException {
+    if (templateMacro == null) {
+      return null;
+    }
+
+    StringWriter sw = new StringWriter();
+    try {
+      VelocityContext vc = new VelocityContext();
+
+      vc.put("java_version", PsiAdapter.getJavaVersion(clazz));
+
+      // field information
+      logger.debug("Velocity Context - adding fields");
+      vc.put("fields", ElementUtils.getOnlyAsFieldElements(selectedMembers));
+
+      // method information
+      logger.debug("Velocity Context - adding methods");
+      vc.put("methods", ElementUtils.getOnlyAsMethodElements(selectedMembers));
+
+      // element information (both fields and methods)
+      logger.debug("Velocity Context - adding members (fields and methods)");
+      List<Element> elements = ElementUtils.getOnlyAsFieldAndMethodElements(selectedMembers);
+      // sort elements if enabled and not using chooser dialog
+      if (sortElements != 0) {
+        Collections.sort(elements, new ElementComparator(sortElements));
+      }
+      vc.put("members", elements);
+
+      // class information
+      ClassElement ce = ElementFactory.newClassElement(clazz);
+      vc.put("class", ce);
+      if (logger.isDebugEnabled()) logger.debug("Velocity Context - adding class: " + ce);
+
+      // information to keep as it is to avoid breaking compatibility with prior releases
+      vc.put("classname", useFullyQualifiedName ? ce.getQualifiedName() : ce.getName());
+      vc.put("FQClassname", ce.getQualifiedName());
+      vc.put("settings", CodeStyleSettingsManager.getSettings(clazz.getProject()));
+
+      if (logger.isDebugEnabled()) logger.debug("Velocity Macro:\n" + templateMacro);
+
+      // velocity
+      VelocityEngine velocity = VelocityFactory.getVelocityEngine();
+      logger.debug("Executing velocity +++ START +++");
+      velocity.evaluate(vc, sw, GenerateToStringWorker.class.getName(), templateMacro);
+      logger.debug("Executing velocity +++ END +++");
+
+      // any additional packages to import returned from velocity?
+      if (vc.get("autoImportPackages") != null) {
+        params.put("autoImportPackages", (String)vc.get("autoImportPackages"));
+      }
+    }
+    catch (Exception e) {
+      throw new GenerateCodeException("Error in Velocity code generator", e);
+    }
+
+    return sw.getBuffer().toString();
+  }
 }
\ No newline at end of file
similarity index 93%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/DuplicatePolicy.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/config/DuplicatePolicy.java
index 5de932ede68914344fe82386e9a51a38b3095c1d..da8f9e4018bfe901bbe07ab6ecdc4017b6b5e420 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.config;
+package org.jetbrains.java.generate.config;
 
 import com.intellij.openapi.editor.Editor;
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiMethod;
-import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 
 /**
similarity index 95%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertAfterEqualsHashCodeStrategy.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/config/InsertAfterEqualsHashCodeStrategy.java
index d9757947531ac846564ca87c500e782b9adeca32..d5e2f5b3fbef8242777863c8b1a082426f043276 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.config;
+package org.jetbrains.java.generate.config;
 
 import com.intellij.openapi.editor.Editor;
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiMethod;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.generate.tostring.psi.PsiAdapter;
+import org.jetbrains.java.generate.psi.PsiAdapter;
 
 /**
  * Inserts the method after the hashCode/equals methods in the javafile.
similarity index 91%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/InsertAtCaretStrategy.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/config/InsertAtCaretStrategy.java
index f41c60196921fe0bcd9bace615891296460b7524..fadc7f9c7fa64b29f31c395475fa9f94adb0dd2b 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.config;
+package org.jetbrains.java.generate.config;
 
 import com.intellij.codeInsight.generation.GenerateMembersUtil;
-import com.intellij.codeInsight.generation.OverrideImplementUtil;
 import com.intellij.codeInsight.generation.PsiGenerationInfo;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiMethod;
-import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Arrays;
similarity index 97%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/config/ReplacePolicy.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/config/ReplacePolicy.java
index e070573d1dadac7055de186b61baad8c1e6ceb6f..ab6a2a2e0ca6658a4d30a362b89d5c46707cddb4 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.config;
+package org.jetbrains.java.generate.config;
 
 import com.intellij.openapi.editor.Editor;
 import com.intellij.psi.PsiClass;
similarity index 83%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/AbstractElement.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/element/AbstractElement.java
index a1ff5a87ef29998651c0339972adea455f9d2b58..ec931a1e404e7baa81f28222825b8dc9fddac7a8 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.element;
+package org.jetbrains.java.generate.element;
 
 /**
  * Base class to extends for Elements.
@@ -38,6 +38,13 @@ public abstract class AbstractElement implements Element {
     protected boolean isDate;
     protected boolean isCalendar;
     protected boolean isBoolean;
+    protected boolean isLong;
+    protected boolean isFloat;
+    protected boolean isDouble;
+    protected boolean isVoid;
+    protected boolean isChar;
+    protected boolean isByte;
+    protected boolean isShort;
     protected String typeName;
     protected String typeQualifiedName;
     protected boolean isModifierStatic;
@@ -119,6 +126,69 @@ public abstract class AbstractElement implements Element {
         return isBoolean;
     }
 
+    @Override
+    public boolean isLong() {
+        return isLong;
+    }
+
+    public void setLong(boolean isLong) {
+        this.isLong = isLong;
+    }
+
+    @Override
+    public boolean isFloat() {
+        return isFloat;
+    }
+
+    public void setFloat(boolean isFloat) {
+        this.isFloat = isFloat;
+    }
+
+    @Override
+    public boolean isDouble() {
+        return isDouble;
+    }
+
+    public void setDouble(boolean isDouble) {
+        this.isDouble = isDouble;
+    }
+
+    @Override
+    public boolean isVoid() {
+        return isVoid;
+    }
+
+    public void setVoid(boolean isVoid) {
+        this.isVoid = isVoid;
+    }
+
+    @Override
+    public boolean isChar() {
+        return isChar;
+    }
+
+    public void setChar(boolean isChar) {
+        this.isChar = isChar;
+    }
+
+    @Override
+    public boolean isByte() {
+        return isByte;
+    }
+
+    public void setByte(boolean isByte) {
+        this.isByte = isByte;
+    }
+
+    @Override
+    public boolean isShort() {
+        return isShort;
+    }
+
+    public void setShort(boolean isShort) {
+        this.isShort = isShort;
+    }
+
     public void setBoolean(boolean aBoolean) {
         isBoolean = aBoolean;
     }
similarity index 99%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/ClassElement.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/element/ClassElement.java
index 6b9d8057419d530642a6b292ad563b21f8884120..17eb57d9eb6b6df12533d6bb36e2bea597bf3528 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.element;
+package org.jetbrains.java.generate.element;
 
 import com.intellij.openapi.util.text.StringUtil;
 
similarity index 95%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/Element.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/element/Element.java
index 04f6ec6a5808d705e9f40872de27659e2ccc0ee0..bf23afa33e7d90f43eef52e9f502ad1e1e13816a 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.element;
+package org.jetbrains.java.generate.element;
 
 /**
  * This is an Element.
@@ -146,6 +146,14 @@ public interface Element {
      */
     boolean isBoolean();
 
+    boolean isLong();
+    boolean isShort();
+    boolean isChar();
+    boolean isFloat();
+    boolean isDouble();
+    boolean isByte();
+    boolean isVoid();
+
     /**
      * Get's the elements type classname (etc. Object, String, List)
      *
similarity index 97%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/ElementComparator.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/element/ElementComparator.java
index 3b36260c3f10a655d07828e459ac5e22e6e12ae9..4e6c82778722e9a1b2184409669a689748ffe83c 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.element;
+package org.jetbrains.java.generate.element;
 
 import java.util.Comparator;
 
similarity index 92%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/ElementFactory.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/element/ElementFactory.java
index be60bffa6c09aebdad64a96206ff4ab86277f607..2c219f1900facaa627e3797352fc87bb067f069f 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.element;
+package org.jetbrains.java.generate.element;
 
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.psi.*;
-import org.jetbrains.generate.tostring.psi.PsiAdapter;
+import org.jetbrains.java.generate.psi.PsiAdapter;
 
 /**
  * Factory for creating {@link FieldElement} or {@link ClassElement} objects.
  */
 public class ElementFactory {
 
-  private static final Logger log = Logger.getInstance("#org.jetbrains.generate.tostring.element.ElementFactory");
+  private static final Logger log = Logger.getInstance("#ElementFactory");
 
   private ElementFactory() {
   }
@@ -170,6 +170,13 @@ public class ElementFactory {
     if (PsiAdapter.isDateType(factory, type)) element.setDate(true);
     if (PsiAdapter.isCalendarType(factory, type)) element.setCalendar(true);
     if (PsiAdapter.isBooleanType(factory, type)) element.setBoolean(true);
+    if (PsiType.VOID.equals(type)) element.setVoid(true);
+    if (PsiType.LONG.equals(type)) element.setLong(true);
+    if (PsiType.FLOAT.equals(type)) element.setFloat(true);
+    if (PsiType.DOUBLE.equals(type)) element.setDouble(true);
+    if (PsiType.BYTE.equals(type)) element.setByte(true);
+    if (PsiType.CHAR.equals(type)) element.setChar(true);
+    if (PsiType.SHORT.equals(type)) element.setShort(true);
 
     // modifiers
     if (modifiers != null) {
similarity index 95%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/ElementUtils.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/element/ElementUtils.java
index 3c2ddae6e73c12d9affba8907f61c06de88a2eac..e0caa4ceee2b723a8442d6a96ab8b16b07c31a91 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.element;
+package org.jetbrains.java.generate.element;
 
 import com.intellij.psi.PsiField;
 import com.intellij.psi.PsiMember;
@@ -36,7 +36,7 @@ public class ElementUtils {
      * @param members a list of {@link com.intellij.psi.PsiMember} objects.
      * @return a filtered list of only the fields as {@link FieldElement} objects.
      */
-    public static List<FieldElement> getOnlyAsFieldElements(Collection<PsiMember> members) {
+    public static List<FieldElement> getOnlyAsFieldElements(Collection<? extends PsiMember> members) {
         List<FieldElement> fieldElementList = new ArrayList<FieldElement>();
 
         for (PsiMember member : members) {
@@ -56,7 +56,7 @@ public class ElementUtils {
      * @param members a list of {@link com.intellij.psi.PsiMember} objects.
      * @return a filtered list of only the methods as a {@link MethodElement} objects.
      */
-    public static List<MethodElement> getOnlyAsMethodElements(Collection<PsiMember> members) {
+    public static List<MethodElement> getOnlyAsMethodElements(Collection<? extends PsiMember> members) {
         List<MethodElement> methodElementList = new ArrayList<MethodElement>();
 
         for (PsiMember member : members) {
@@ -76,7 +76,7 @@ public class ElementUtils {
      * @param members a list of {@link com.intellij.psi.PsiMember} objects.
      * @return a filtered list of only the methods as a {@link FieldElement} or {@link MethodElement} objects.
      */
-    public static List<Element> getOnlyAsFieldAndMethodElements(Collection<PsiMember> members) {
+    public static List<Element> getOnlyAsFieldAndMethodElements(Collection<? extends PsiMember> members) {
         List<Element> elementList = new ArrayList<Element>();
 
         for (PsiMember member : members) {
similarity index 98%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/FieldElement.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/element/FieldElement.java
index 8be76e1edbd4fde7cec83522a120c198e409093e..1075bf4dc8821ab000cc4464bf1662deee50b08c 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.element;
+package org.jetbrains.java.generate.element;
 
 import com.intellij.openapi.util.text.StringUtil;
 
similarity index 98%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/element/MethodElement.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/element/MethodElement.java
index 4005a8bb3f9dbc5cadab43628b7c503affdb7e0b..28df950de60ff27db5a8851a7fe6953db8df957f 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.element;
+package org.jetbrains.java.generate.element;
 
 import com.intellij.openapi.util.text.StringUtil;
 
similarity index 95%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/exception/TemplateResourceException.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/exception/TemplateResourceException.java
index 3bf694a9de287b7038a25abe90a43958009db0fc..50a247b446381133436e9160b0c67db88d798fd5 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.exception;
+package org.jetbrains.java.generate.exception;
 
 /**
  * Template resource related exceptions.
similarity index 75%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplateResource.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/template/TemplateResource.java
index e2a8470493810c2ee8578d7457309ab05ef784a7..db56f816bd576e507852879554c7a91597bbab64 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.template;
+package org.jetbrains.java.generate.template;
 
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.generate.tostring.util.StringUtil;
 
 import java.io.Serializable;
 
@@ -42,6 +41,54 @@ public class TemplateResource implements Serializable {
     isDefault = false;
   }
 
+  /**
+     * Returns the part of s after the token.
+     * <p/>
+     * <br/>Example:   after("helloWorldThisIsMe", "World") will return "ThisIsMe".
+     * <br/>Example:   after("helloWorldThisIsMe", "Dog") will return null.
+     *
+     * @param s   the string to test.
+     * @param token   the token.
+     * @return  the part of s that is after the token.
+     */
+    public static String after(String s, String token) {
+        if (s == null) {
+            return null;
+        }
+
+        int i = s.indexOf(token);
+        if (i == -1) {
+            return s;
+        }
+
+        return s.substring(i + token.length());
+    }
+
+  /**
+     * Returns the part of s before the token.
+     * <p/>
+     * <br/>Example:   before("helloWorldThisIsMe", "World") will return "hello".
+     * <br/>Example:   before("helloWorldThisIsMe", "Dog") will return "helloWorldThisIsMe".
+     * <p/>
+     * If the token is not in the string, the entire string is returned.
+     *
+     * @param s   the string to test.
+     * @param token   the token.
+     * @return  the part of s that is before the token.
+     */
+    public static String before(String s, String token) {
+        if (s == null) {
+            return null;
+        }
+
+        int i = s.indexOf(token);
+        if (i == -1) {
+            return s;
+        }
+
+        return s.substring(0, i);
+    }
+
   public String getTemplate() {
     return template;
   }
@@ -89,7 +136,7 @@ public class TemplateResource implements Serializable {
   @Nullable
   private static String getMethodBody(String template) {
     String signature = getMethodSignature(template);
-    String s = StringUtil.after(template, signature);
+    String s = after(template, signature);
 
     if (s == null) {
       return null;
@@ -110,7 +157,7 @@ public class TemplateResource implements Serializable {
   }
 
   private static String getMethodSignature(String template) {
-    String s = StringUtil.after(template, "*/").trim();
+    String s = after(template, "*/").trim();
 
     StringBuffer signature = new StringBuffer();
 
@@ -136,7 +183,7 @@ public class TemplateResource implements Serializable {
    */
   public String getTargetMethodName() {
     String s = getMethodSignature();
-    s = StringUtil.before(s, "(");
+    s = before(s, "(");
     int i = s.lastIndexOf(" ");
     return s.substring(i).trim();
   }
similarity index 63%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplatesManager.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/template/TemplatesManager.java
index f1c462c8164a5becd6937673ab89b2e76efce04c..d69e87d11f69d48df701b1d58a561d497bc1a5dc 100644 (file)
 /*
  * @author max
  */
-package org.jetbrains.generate.tostring.template;
+package org.jetbrains.java.generate.template;
 
 import com.intellij.openapi.components.*;
 import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.CharsetToolkit;
 
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.util.*;
 
-@State(
-  name = "ToStringTemplates",
-  storages = {
-    @Storage(
-      file = StoragePathMacros.APP_CONFIG + "/toStringTemplates.xml"
-    )}
-)
-public class TemplatesManager implements PersistentStateComponent<TemplatesState> {
-    public static TemplatesManager getInstance() {
-        return ServiceManager.getService(TemplatesManager.class);
-    }
-
-    private TemplatesState myState = new TemplatesState();
-
-    public TemplatesManager() {
-        for (TemplateResource o : TemplateResourceLocator.getDefaultTemplates()) {
-            addTemplate(o);
-        }
-    }
+public abstract class TemplatesManager implements PersistentStateComponent<TemplatesState> {
+
+  private TemplatesState myState = new TemplatesState();
+
+  public abstract TemplateResource[] getDefaultTemplates();
+  /**
+   * Reads the content of the resource and return it as a String.
+   * <p/>Uses the class loader that loaded this class to find the resource in its classpath.
+   *
+   * @param resource the resource name. Will lookup using the classpath.
+   * @return the content if the resource
+   * @throws java.io.IOException error reading the file.
+   */
+  protected static String readFile(String resource, Class<? extends TemplatesManager> templatesManagerClass) throws IOException {
+    BufferedInputStream in = new BufferedInputStream(templatesManagerClass.getResourceAsStream(resource));
+    return StringUtil.convertLineSeparators(FileUtil.loadTextAndClose(new InputStreamReader(in, CharsetToolkit.UTF8_CHARSET)));
+  }
 
-    public TemplatesState getState() {
+  public TemplatesState getState() {
         return myState;
     }
 
@@ -67,14 +71,10 @@ public class TemplatesManager implements PersistentStateComponent<TemplatesState
     }
 
   public Collection<TemplateResource> getAllTemplates() {
-    TemplateResource[] defaultTemplates = TemplateResourceLocator.getDefaultTemplates();
     HashSet<String> names = new HashSet<String>();
-    for (TemplateResource defaultTemplate : defaultTemplates) {
-      names.add(defaultTemplate.getFileName());
-    }
-    Collection<TemplateResource> templates = new LinkedHashSet<TemplateResource>(Arrays.asList(defaultTemplates));
+    Collection<TemplateResource> templates = new LinkedHashSet<TemplateResource>(Arrays.asList(getDefaultTemplates()));
     for (TemplateResource template : myState.templates) {
-      if (!names.contains(template.getFileName())) {
+      if (names.add(template.getFileName())) {
         templates.add(template);
       }
     }
similarity index 94%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/template/TemplatesState.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/template/TemplatesState.java
index 735d6fa34fbbc7e73010950f68a8cc80eefefa1f..c0c8e213b048ff103dce6899cb951b9365f8e164 100644 (file)
@@ -17,7 +17,7 @@
 /*
  * @author max
  */
-package org.jetbrains.generate.tostring.template;
+package org.jetbrains.java.generate.template;
 
 import java.util.ArrayList;
 import java.util.List;
diff --git a/plugins/generate-tostring/src/org/jetbrains/java/generate/template/toString/ToStringTemplatesManager.java b/plugins/generate-tostring/src/org/jetbrains/java/generate/template/toString/ToStringTemplatesManager.java
new file mode 100644 (file)
index 0000000..af2c7e9
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.java.generate.template.toString;
+
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.components.State;
+import com.intellij.openapi.components.Storage;
+import com.intellij.openapi.components.StoragePathMacros;
+import org.jetbrains.java.generate.exception.TemplateResourceException;
+import org.jetbrains.java.generate.template.TemplateResource;
+import org.jetbrains.java.generate.template.TemplatesManager;
+
+import java.io.IOException;
+
+@State(
+  name = "ToStringTemplates",
+  storages = {
+    @Storage(
+      file = StoragePathMacros.APP_CONFIG + "/toStringTemplates.xml"
+    )}
+)
+public class ToStringTemplatesManager extends TemplatesManager {
+  private static final String DEFAULT_CONCAT = "DefaultConcatMember.vm";
+  private static final String DEFAULT_CONCAT_GROOVY = "/org/jetbrains/java/generate/template/toString/DefaultConcatMemberGroovy.vm";
+  private static final String DEFAULT_CONCAT_SUPER = "/org/jetbrains/java/generate/template/toString/DefaultConcatMemberSuper.vm";
+  private static final String DEFAULT_BUFFER = "/org/jetbrains/java/generate/template/toString/DefaultBuffer.vm";
+  private static final String DEFAULT_BUILDER = "/org/jetbrains/java/generate/template/toString/DefaultBuilder.vm";
+  private static final String DEFAULT_TOSTRINGBUILDER = "/org/jetbrains/java/generate/template/toString/DefaultToStringBuilder.vm";
+  private static final String DEFAULT_TOSTRINGBUILDER3 = "/org/jetbrains/java/generate/template/toString/DefaultToStringBuilder3.vm";
+  private static final String DEFAULT_GUAVA = "/org/jetbrains/java/generate/template/toString/DefaultGuava.vm";
+
+  public static TemplatesManager getInstance() {
+    return ServiceManager.getService(ToStringTemplatesManager.class);
+  }
+
+  @Override
+  public TemplateResource[] getDefaultTemplates() {
+    try {
+      return new TemplateResource[]{
+        new TemplateResource("String concat (+)", readFile(DEFAULT_CONCAT), true),
+        new TemplateResource("String concat (+) and super.toString()", readFile(DEFAULT_CONCAT_SUPER), true),
+        new TemplateResource("StringBuffer", readFile(DEFAULT_BUFFER), true),
+        new TemplateResource("StringBuilder (JDK 1.5)", readFile(DEFAULT_BUILDER), true),
+        new TemplateResource("ToStringBuilder (Apache commons-lang)", readFile(DEFAULT_TOSTRINGBUILDER), true),
+        new TemplateResource("ToStringBuilder (Apache commons-lang 3)", readFile(DEFAULT_TOSTRINGBUILDER3), true),
+        new TemplateResource("Objects.toStringHelper (Guava)", readFile(DEFAULT_GUAVA), true),
+        new TemplateResource("Groovy: String concat (+)", readFile(DEFAULT_CONCAT_GROOVY), true),
+      };
+    }
+    catch (IOException e) {
+      throw new TemplateResourceException("Error loading default templates", e);
+    }
+  }
+
+  protected static String readFile(String resource) throws IOException {
+    return readFile(resource, ToStringTemplatesManager.class);
+  }
+}
similarity index 97%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/velocity/VelocityFactory.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/velocity/VelocityFactory.java
index ff4a5b63c83c270a76f381bdd6a3fc13ce37f14d..542e181142ede43d4ad7fd00624f1b6c3c204e3e 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.velocity;
+package org.jetbrains.java.generate.velocity;
 
 import org.apache.commons.collections.ExtendedProperties;
 import org.apache.velocity.app.VelocityEngine;
similarity index 98%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/view/ConfigUI.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/view/ConfigUI.java
index fc5979d34a467f042ba1d0cad458cff96084ea59..89ed39f77be75d0a6b2fa43a65fd5a140b28f01a 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.view;
+package org.jetbrains.java.generate.view;
 
 import com.intellij.openapi.project.Project;
 import com.intellij.ui.IdeBorderFactory;
 import com.intellij.ui.LanguageTextField;
 import org.intellij.lang.regexp.RegExpLanguage;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.generate.tostring.config.Config;
-import org.jetbrains.generate.tostring.config.DuplicationPolicy;
-import org.jetbrains.generate.tostring.config.InsertWhere;
-import org.jetbrains.generate.tostring.config.PolicyOptions;
+import org.jetbrains.java.generate.config.Config;
+import org.jetbrains.java.generate.config.DuplicationPolicy;
+import org.jetbrains.java.generate.config.InsertWhere;
+import org.jetbrains.java.generate.config.PolicyOptions;
 
 import javax.swing.*;
 import java.awt.*;
similarity index 89%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/view/ToStringTemplateConfigurable.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/view/GenerateTemplateConfigurable.java
index 0de3284ba560ee9e248ddd70803f57aa82a22673..e618402cdc2f8bfef1ad4dad14d624dcc9143f3c 100644 (file)
@@ -17,7 +17,7 @@
 /*
  * @author max
  */
-package org.jetbrains.generate.tostring.view;
+package org.jetbrains.java.generate.view;
 
 import com.intellij.openapi.application.Result;
 import com.intellij.openapi.command.WriteCommandAction;
@@ -27,20 +27,19 @@ import com.intellij.openapi.editor.EditorFactory;
 import com.intellij.openapi.fileTypes.FileType;
 import com.intellij.openapi.fileTypes.FileTypeManager;
 import com.intellij.openapi.fileTypes.FileTypes;
-import com.intellij.openapi.fileTypes.StdFileTypes;
 import com.intellij.openapi.options.ConfigurationException;
 import com.intellij.openapi.options.UnnamedConfigurable;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Comparing;
-import org.jetbrains.generate.tostring.template.TemplateResource;
+import org.jetbrains.java.generate.template.TemplateResource;
 
 import javax.swing.*;
 
-public class ToStringTemplateConfigurable implements UnnamedConfigurable{
+public class GenerateTemplateConfigurable implements UnnamedConfigurable{
     private final TemplateResource template;
     private final Editor myEditor;
 
-    public ToStringTemplateConfigurable(TemplateResource template, Project project) {
+    public GenerateTemplateConfigurable(TemplateResource template, Project project) {
         this.template = template;
         final EditorFactory factory = EditorFactory.getInstance();
         final Document doc = factory.createDocument(template.getTemplate());
similarity index 86%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/view/MethodExistsDialog.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/view/MethodExistsDialog.java
index 8547ac5eae8153bff3c1cdff6b17c2114f5d45e6..59a3a0adb4a322dbe00addb3b41fc774f0c304c1 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.view;
+package org.jetbrains.java.generate.view;
 
 import com.intellij.openapi.ui.Messages;
-import org.jetbrains.generate.tostring.config.CancelPolicy;
-import org.jetbrains.generate.tostring.config.ConflictResolutionPolicy;
-import org.jetbrains.generate.tostring.config.DuplicatePolicy;
-import org.jetbrains.generate.tostring.config.ReplacePolicy;
+import org.jetbrains.java.generate.config.CancelPolicy;
+import org.jetbrains.java.generate.config.ConflictResolutionPolicy;
+import org.jetbrains.java.generate.config.DuplicatePolicy;
+import org.jetbrains.java.generate.config.ReplacePolicy;
 
 /**
  * This is a dialog when the <code>toString()</code> method already exists.
similarity index 85%
rename from plugins/generate-tostring/src/org/jetbrains/generate/tostring/view/TemplatesPanel.java
rename to plugins/generate-tostring/src/org/jetbrains/java/generate/view/TemplatesPanel.java
index 2327611b540db38c858071ac3120f4d9528c251f..ed70605e5b243308d5ad4763c4c91c11eff2810e 100644 (file)
@@ -17,7 +17,7 @@
 /*
  * @author max
  */
-package org.jetbrains.generate.tostring.view;
+package org.jetbrains.java.generate.view;
 
 import com.intellij.openapi.options.ConfigurationException;
 import com.intellij.openapi.options.UnnamedConfigurable;
@@ -31,8 +31,8 @@ import gnu.trove.Equality;
 import org.jetbrains.annotations.Nls;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.generate.tostring.template.TemplateResource;
-import org.jetbrains.generate.tostring.template.TemplatesManager;
+import org.jetbrains.java.generate.template.TemplateResource;
+import org.jetbrains.java.generate.template.toString.ToStringTemplatesManager;
 
 import java.util.ArrayList;
 
@@ -80,7 +80,7 @@ public class TemplatesPanel extends NamedItemsListEditor<TemplateResource> {
 
   public TemplatesPanel(Project project) {
         super(NAMER, FACTORY, CLONER, COMPARER,
-                new ArrayList<TemplateResource>(TemplatesManager.getInstance().getAllTemplates()));
+                new ArrayList<TemplateResource>(ToStringTemplatesManager.getInstance().getAllTemplates()));
 
         //ServiceManager.getService(project, MasterDetailsStateService.class).register("ToStringTemplates.UI", this);
     myProject = project;
@@ -104,7 +104,7 @@ public class TemplatesPanel extends NamedItemsListEditor<TemplateResource> {
 
     @Override
     public boolean isModified() {
-        return super.isModified() || !Comparing.equal(TemplatesManager.getInstance().getDefaultTemplate(), getSelectedItem());
+        return super.isModified() || !Comparing.equal(ToStringTemplatesManager.getInstance().getDefaultTemplate(), getSelectedItem());
     }
 
     @Override
@@ -113,16 +113,16 @@ public class TemplatesPanel extends NamedItemsListEditor<TemplateResource> {
     }
 
     protected UnnamedConfigurable createConfigurable(TemplateResource item) {
-        return new ToStringTemplateConfigurable(item, myProject);
+        return new GenerateTemplateConfigurable(item, myProject);
     }
 
     @Override
     public void apply() throws ConfigurationException {
         super.apply();
-        TemplatesManager.getInstance().setTemplates(getItems());
+        ToStringTemplatesManager.getInstance().setTemplates(getItems());
         final TemplateResource selection = getSelectedItem();
         if (selection != null) {
-            TemplatesManager.getInstance().setDefaultTemplate(selection);
+            ToStringTemplatesManager.getInstance().setDefaultTemplate(selection);
         }
     }
 }
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.inspection;
+package org.jetbrains.java.generate.inspection;
 
 import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
 import org.jetbrains.annotations.NonNls;
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.inspection;
+package org.jetbrains.java.generate.inspection;
 
 import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
 import org.jetbrains.annotations.NonNls;
similarity index 87%
rename from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/inspection/ToStringGeneratingTest.groovy
rename to plugins/generate-tostring/testSrc/org/jetbrains/java/generate/inspection/ToStringGeneratingTest.groovy
index b4685b9403e670dfae1747136d54b372486e41ec..df8a5aed1e93fb948cac1fadee662559d648d34b 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.inspection
+package org.jetbrains.java.generate.inspection
 
 import com.intellij.openapi.application.Result
 import com.intellij.openapi.command.WriteCommandAction
@@ -23,11 +23,11 @@ import com.intellij.psi.PsiJavaFile
 import com.intellij.psi.PsiMember
 import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
 import org.jetbrains.annotations.NotNull
-import org.jetbrains.generate.tostring.GenerateToStringWorker
-import org.jetbrains.generate.tostring.config.ConflictResolutionPolicy
-import org.jetbrains.generate.tostring.config.ReplacePolicy
-import org.jetbrains.generate.tostring.template.TemplateResource
-import org.jetbrains.generate.tostring.template.TemplatesManager
+import org.jetbrains.java.generate.config.ConflictResolutionPolicy
+import org.jetbrains.java.generate.config.ReplacePolicy
+import org.jetbrains.java.generate.template.TemplateResource
+import org.jetbrains.java.generate.GenerateToStringWorker
+import org.jetbrains.java.generate.template.toString.ToStringTemplatesManager
 
 /**
  * Created by Max Medvedev on 07/03/14
@@ -101,7 +101,7 @@ public class Foobar  {
 
   @NotNull
   private static TemplateResource findDefaultTemplate() {
-    Collection<TemplateResource> templates = TemplatesManager.getInstance().getAllTemplates();
+    Collection<TemplateResource> templates = ToStringTemplatesManager.getInstance().getAllTemplates();
     def template = templates.find { it.fileName == "String concat (+)" }
     assert template != null
     template
similarity index 99%
rename from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/test/DummyCompleteTestBean.java
rename to plugins/generate-tostring/testSrc/org/jetbrains/java/generate/test/DummyCompleteTestBean.java
index b88b15146d75c2a4181c91ec2edca5dedd60cb6c..8dca2556fa06d2b56437e8c8059e04f90ebb7f78 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.test;
+package org.jetbrains.java.generate.test;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
similarity index 96%
rename from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/test/DummyGetterTestBean.java
rename to plugins/generate-tostring/testSrc/org/jetbrains/java/generate/test/DummyGetterTestBean.java
index 04a173304047ec8a5739ebab91ec23ae8cfeb6a5..5c07aa5b68c74a22d7aa8c3dfa04fb4f53e79183 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.test;
+package org.jetbrains.java.generate.test;
 
 /**
  * This is a dummy test bean for testing the toString() plugin.
similarity index 97%
rename from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/test/DummyModelTestBean.java
rename to plugins/generate-tostring/testSrc/org/jetbrains/java/generate/test/DummyModelTestBean.java
index e1987dcb08adbb13c41ba06ddc93703b2a0ca065..89833fe34ceba346cd1f60bae93c7b6b0e5c2e62 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.test;
+package org.jetbrains.java.generate.test;
 
 import java.util.ArrayList;
 import java.util.Collections;
similarity index 96%
rename from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/test/DummySortTestBean.java
rename to plugins/generate-tostring/testSrc/org/jetbrains/java/generate/test/DummySortTestBean.java
index 7c8a06c6538a794a3a1568bef1b29a93a555cc9c..a35d0732c3cc738b192fda3bea3f899e72075de7 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.test;
+package org.jetbrains.java.generate.test;
 
 import java.util.logging.Logger;
 
similarity index 95%
rename from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/test/DummyTestBean.java
rename to plugins/generate-tostring/testSrc/org/jetbrains/java/generate/test/DummyTestBean.java
index 904421a169f6808b7ada8adf847260bb732efa1d..9277963c06b473fffe5fd0cc1edb583113da84ea 100644 (file)
@@ -13,9 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.test;
+package org.jetbrains.java.generate.test;
 
-import org.jetbrains.generate.tostring.config.Config;
+import org.jetbrains.java.generate.config.Config;
 
 import java.io.Serializable;
 import java.util.Date;
similarity index 98%
rename from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/test/Owner.java
rename to plugins/generate-tostring/testSrc/org/jetbrains/java/generate/test/Owner.java
index d09b8508818a66566f726afe38514859f93796a7..7a8fb2e8eb84af2a3bf948850d070b0bcfb6ba41 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.test;
+package org.jetbrains.java.generate.test;
 
 /**
  * To be used for testing.
similarity index 97%
rename from plugins/generate-tostring/testSrc/org/jetbrains/generate/tostring/test/Pet.java
rename to plugins/generate-tostring/testSrc/org/jetbrains/java/generate/test/Pet.java
index 122831cb83f75418c47e371f030f53f77b351b00..89f1d9aa413e8773fdf97d320c08205bc3c6b81c 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.generate.tostring.test;
+package org.jetbrains.java.generate.test;
 
 import java.util.Date;
 
index a3516e47faa231b2c04fb2ff34a53b86de4e59c9..c69af6def2c5d4e59b05dd7677b23e2df92abdda 100644 (file)
     <weigher order="first" key="completion" id="methodsChains"
              implementationClass="com.intellij.compiler.classFilesIndex.chainsSearch.completion.MethodsChainsWeigher"/>
 
-    <applicationService serviceInterface="org.jetbrains.generate.tostring.template.TemplatesManager"
-                        serviceImplementation="org.jetbrains.generate.tostring.template.TemplatesManager"/>
-    <applicationService serviceInterface="org.jetbrains.generate.tostring.GenerateToStringActionHandler"
-                        serviceImplementation="org.jetbrains.generate.tostring.GenerateToStringActionHandlerImpl"/>
-    <applicationService serviceInterface="org.jetbrains.generate.tostring.GenerateToStringContext"
-                        serviceImplementation="org.jetbrains.generate.tostring.GenerateToStringContext"/>
+    <applicationService serviceInterface="org.jetbrains.java.generate.template.toString.ToStringTemplatesManager"
+                        serviceImplementation="org.jetbrains.java.generate.template.toString.ToStringTemplatesManager"/>
+    <applicationService serviceInterface="com.intellij.codeInsight.generation.EqualsHashCodeTemplatesManager"
+                        serviceImplementation="com.intellij.codeInsight.generation.EqualsHashCodeTemplatesManager"/>
+    <applicationService serviceInterface="org.jetbrains.java.generate.GenerateToStringActionHandler"
+                        serviceImplementation="org.jetbrains.java.generate.GenerateToStringActionHandlerImpl"/>
+    <applicationService serviceInterface="org.jetbrains.java.generate.GenerateToStringContext"
+                        serviceImplementation="org.jetbrains.java.generate.GenerateToStringContext"/>
 
     <localInspection language="JAVA" shortName="ClassHasNoToStringMethod" displayName="Class does not override 'toString()' method"
                      groupName="toString() issues" enabledByDefault="false" level="WARNING"
-                     implementationClass="org.jetbrains.generate.tostring.inspection.ClassHasNoToStringMethodInspection"/>
+                     implementationClass="org.jetbrains.java.generate.inspection.ClassHasNoToStringMethodInspection"/>
     <localInspection language="JAVA" shortName="FieldNotUsedInToString" displayName="Field not used in 'toString()' method" groupName="toString() issues"
                      enabledByDefault="false" level="WARNING" runForWholeFile="true"
-                     implementationClass="org.jetbrains.generate.tostring.inspection.FieldNotUsedInToStringInspection"/>
+                     implementationClass="org.jetbrains.java.generate.inspection.FieldNotUsedInToStringInspection"/>
     <generation.toStringClassFilter implementation="org.jetbrains.generate.tostring.GenerateToStringInterfaceFilter" order="last"/>
 
     <codeInsight.unresolvedReferenceQuickFixProvider implementation="com.intellij.jarFinder.FindJarQuickFixProvider"/>
index c7cc6e9756a774bf6d7f865f6f33ac3f2d73edfd..6cc9ba83758fbc06bf4908a39cd189c42cfbf7b6 100644 (file)
@@ -11,7 +11,7 @@
       <action id="GenerateSetter" class="com.intellij.codeInsight.generation.actions.GenerateSetterAction"/>
       <action id="GenerateGetterAndSetter" class="com.intellij.codeInsight.generation.actions.GenerateGetterAndSetterAction"/>
       <action id="GenerateEquals" class="com.intellij.codeInsight.generation.actions.GenerateEqualsAction"/>
-      <action id="Actions.ActionsPlugin.GenerateToString" class="org.jetbrains.generate.tostring.GenerateToStringAction" text="to_String()" description="Generate toString() method"/>
+      <action id="Actions.ActionsPlugin.GenerateToString" class="org.jetbrains.java.generate.GenerateToStringAction" text="to_String()" description="Generate toString() method"/>
       <action id="GenerateCreateUI" class="com.intellij.codeInsight.generation.actions.GenerateCreateUIAction"/>
       <add-to-group group-id="GenerateGroup" anchor="first"/>
     </group>