references = query.findAll();
for (PsiReference reference : references) {
modifyCalls(reference, typeText, parameters.length - 1);
@@ -93,59 +93,48 @@ public class VarargParameterInspection extends BaseInspection {
final PsiType arrayType = type.toArrayType();
final PsiManager psiManager = lastParameter.getManager();
final PsiElementFactory factory = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory();
- final PsiTypeElement newTypeElement =
- factory.createTypeElement(arrayType);
- final PsiTypeElement typeElement =
- lastParameter.getTypeElement();
+ final PsiTypeElement newTypeElement = factory.createTypeElement(arrayType);
+ final PsiTypeElement typeElement = lastParameter.getTypeElement();
+ if (typeElement == null) {
+ return;
+ }
+ final PsiAnnotation annotation = AnnotationUtil.findAnnotation(method, "java.lang.SafeVarargs");
+ if (annotation != null) {
+ annotation.delete();
+ }
typeElement.replace(newTypeElement);
}
- public static void modifyCalls(PsiReference reference,
- String arrayTypeText,
- int indexOfFirstVarargArgument)
- throws IncorrectOperationException {
- final PsiReferenceExpression referenceExpression =
- (PsiReferenceExpression)reference.getElement();
- final PsiMethodCallExpression methodCallExpression =
- (PsiMethodCallExpression)referenceExpression.getParent();
- final PsiExpressionList argumentList =
- methodCallExpression.getArgumentList();
+ public static void modifyCalls(PsiReference reference, String arrayTypeText, int indexOfFirstVarargArgument) {
+ final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)reference.getElement();
+ final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)referenceExpression.getParent();
+ final PsiExpressionList argumentList = methodCallExpression.getArgumentList();
final PsiExpression[] arguments = argumentList.getExpressions();
@NonNls final StringBuilder builder = new StringBuilder("new ");
builder.append(arrayTypeText);
builder.append("[]{");
if (arguments.length > indexOfFirstVarargArgument) {
- final PsiExpression firstArgument =
- arguments[indexOfFirstVarargArgument];
+ final PsiExpression firstArgument = arguments[indexOfFirstVarargArgument];
final String firstArgumentText = firstArgument.getText();
builder.append(firstArgumentText);
- for (int i = indexOfFirstVarargArgument + 1;
- i < arguments.length; i++) {
- builder.append(',');
- builder.append(arguments[i].getText());
+ for (int i = indexOfFirstVarargArgument + 1; i < arguments.length; i++) {
+ builder.append(',').append(arguments[i].getText());
}
}
builder.append('}');
final Project project = referenceExpression.getProject();
- final PsiElementFactory factory =
- JavaPsiFacade.getElementFactory(project);
- final PsiExpression arrayExpression =
- factory.createExpressionFromText(builder.toString(),
- referenceExpression);
+ final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
+ final PsiExpression arrayExpression = factory.createExpressionFromText(builder.toString(), referenceExpression);
if (arguments.length > indexOfFirstVarargArgument) {
- final PsiExpression firstArgument =
- arguments[indexOfFirstVarargArgument];
- argumentList.deleteChildRange(firstArgument,
- arguments[arguments.length - 1]);
+ final PsiExpression firstArgument = arguments[indexOfFirstVarargArgument];
+ argumentList.deleteChildRange(firstArgument, arguments[arguments.length - 1]);
argumentList.add(arrayExpression);
}
else {
argumentList.add(arrayExpression);
}
- final CodeStyleManager codeStyleManager =
- CodeStyleManager.getInstance(project);
- final JavaCodeStyleManager javaCodeStyleManager =
- JavaCodeStyleManager.getInstance(project);
+ final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
+ final JavaCodeStyleManager javaCodeStyleManager = JavaCodeStyleManager.getInstance(project);
javaCodeStyleManager.shortenClassReferences(argumentList);
codeStyleManager.reformat(argumentList);
}
@@ -165,8 +154,7 @@ public class VarargParameterInspection extends BaseInspection {
return;
}
final PsiParameter[] parameters = parameterList.getParameters();
- final PsiParameter lastParameter =
- parameters[parameters.length - 1];
+ final PsiParameter lastParameter = parameters[parameters.length - 1];
if (lastParameter.isVarArgs()) {
registerMethodError(method);
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/style/UnnecessaryToStringCallInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/style/UnnecessaryToStringCallInspection.java
new file mode 100644
index 000000000000..d7cad4ef4f13
--- /dev/null
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/style/UnnecessaryToStringCallInspection.java
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2008-2013 Bas Leijdekkers
+ *
+ * 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.style;
+
+import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.*;
+import com.intellij.util.IncorrectOperationException;
+import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.BaseInspection;
+import com.siyeh.ig.BaseInspectionVisitor;
+import com.siyeh.ig.InspectionGadgetsFix;
+import com.siyeh.ig.psiutils.ParenthesesUtils;
+import com.siyeh.ig.psiutils.TypeUtils;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public class UnnecessaryToStringCallInspection extends BaseInspection {
+
+ @Override
+ @Nls
+ @NotNull
+ public String getDisplayName() {
+ return InspectionGadgetsBundle.message("unnecessary.tostring.call.display.name");
+ }
+
+ @Override
+ @NotNull
+ protected String buildErrorString(Object... infos) {
+ final String text = (String)infos[0];
+ return InspectionGadgetsBundle.message("unnecessary.tostring.call.problem.descriptor", text);
+ }
+
+ @Override
+ @Nullable
+ protected InspectionGadgetsFix buildFix(Object... infos) {
+ final String text = (String)infos[0];
+ return new UnnecessaryCallToStringValueOfFix(text);
+ }
+
+ public static String calculateReplacementText(PsiExpression expression) {
+ if (expression == null) {
+ return "this";
+ }
+ return expression.getText();
+ }
+
+ private static class UnnecessaryCallToStringValueOfFix extends InspectionGadgetsFix {
+
+ private final String replacementText;
+
+ UnnecessaryCallToStringValueOfFix(String replacementText) {
+ this.replacementText = replacementText;
+ }
+
+ @NotNull
+ public String getName() {
+ return InspectionGadgetsBundle.message("unnecessary.call.to.string.valueof.quickfix", replacementText);
+ }
+
+ @Override
+ protected void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
+ final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)descriptor.getPsiElement().getParent().getParent();
+ final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
+ final PsiExpression qualifier = methodExpression.getQualifierExpression();
+ if (qualifier == null) {
+ replaceExpression(methodCallExpression, "this");
+ } else {
+ methodCallExpression.replace(qualifier);
+ }
+ }
+ }
+
+ @Override
+ public BaseInspectionVisitor buildVisitor() {
+ return new UnnecessaryCallToStringValueOfVisitor();
+ }
+
+ private static class UnnecessaryCallToStringValueOfVisitor extends BaseInspectionVisitor {
+
+ @Override
+ public void visitMethodCallExpression(PsiMethodCallExpression expression) {
+ super.visitMethodCallExpression(expression);
+ final PsiReferenceExpression methodExpression = expression.getMethodExpression();
+ final String referenceName = methodExpression.getReferenceName();
+ if (!"toString".equals(referenceName)) {
+ return;
+ }
+ if (isToStringCallNecessary(expression)) {
+ return;
+ }
+ final PsiExpressionList argumentList = expression.getArgumentList();
+ final PsiExpression[] arguments = argumentList.getExpressions();
+ if (arguments.length != 0) {
+ return;
+ }
+ final PsiExpression qualifier = methodExpression.getQualifierExpression();
+ if (qualifier != null && qualifier.getType() instanceof PsiArrayType) {
+ // do not warn on nonsensical code
+ return;
+ }
+ registerMethodCallError(expression, calculateReplacementText(qualifier));
+ }
+
+ private boolean isToStringCallNecessary(PsiMethodCallExpression expression) {
+ final PsiElement parent = ParenthesesUtils.getParentSkipParentheses(expression);
+ if (parent instanceof PsiPolyadicExpression) {
+ final PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression)parent;
+ final PsiType type = polyadicExpression.getType();
+ if (!TypeUtils.typeEquals(CommonClassNames.JAVA_LANG_STRING, type)) {
+ return true;
+ }
+ final PsiExpression[] operands = polyadicExpression.getOperands();
+ int index = -1;
+ for (int i = 0, length = operands.length; i < length; i++) {
+ final PsiExpression operand = operands[i];
+ if (expression.equals(operand)) {
+ index = i;
+ }
+ }
+ if (index > 0) {
+ if (!TypeUtils.typeEquals(CommonClassNames.JAVA_LANG_STRING, operands[index - 1].getType())) {
+ return true;
+ }
+ } else if (operands.length > 1) {
+ if (!TypeUtils.typeEquals(CommonClassNames.JAVA_LANG_STRING, operands[index + 1].getType())) {
+ return true;
+ }
+ } else {
+ return true;
+ }
+ } else if (parent instanceof PsiExpressionList) {
+ final PsiExpressionList expressionList = (PsiExpressionList)parent;
+ final PsiElement grandParent = expressionList.getParent();
+ if (!(grandParent instanceof PsiMethodCallExpression)) {
+ return true;
+ }
+ final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)grandParent;
+ final PsiReferenceExpression methodExpression1 = methodCallExpression.getMethodExpression();
+ final String name = methodExpression1.getReferenceName();
+ final PsiExpression[] expressions = expressionList.getExpressions();
+ if ("insert".equals(name)) {
+ if (expressions.length < 2 || !expression.equals(ParenthesesUtils.stripParentheses(expressions[1]))) {
+ return true;
+ }
+ if (!isCallToMethodIn(methodCallExpression, "java.lang.StringBuilder", "java.lang.StringBuffer")) {
+ return true;
+ }
+
+ } else if ("append".equals(name)) {
+ if (expressions.length < 1 || !expression.equals(ParenthesesUtils.stripParentheses(expressions[0]))) {
+ return true;
+ }
+ if (!isCallToMethodIn(methodCallExpression, "java.lang.StringBuilder", "java.lang.StringBuffer")) {
+ return true;
+ }
+ } else if ("print".equals(name) || "println".equals(name)) {
+ if (!isCallToMethodIn(methodCallExpression, "java.io.PrintStream", "java.io.PrintWriter")) {
+ return true;
+ }
+ }
+ } else {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isCallToMethodIn(PsiMethodCallExpression methodCallExpression, String... classNames) {
+ final PsiMethod method = methodCallExpression.resolveMethod();
+ if (method == null) {
+ return false;
+ }
+ final PsiClass containingClass = method.getContainingClass();
+ if (containingClass == null) {
+ return false;
+ }
+ final String qualifiedName = containingClass.getQualifiedName();
+ for (String className : classNames) {
+ if (className.equals(qualifiedName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+}
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryCallToStringValueOf.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryCallToStringValueOf.html
index 3d95b3ac2f14..ecbdf6ff2ff8 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryCallToStringValueOf.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryCallToStringValueOf.html
@@ -1,8 +1,8 @@
-Reports on any calls to String.valueOf()
-used in string concatenations. The conversion to string is handled automatically by the compiler
-without a call to String.valueOf(), making it unnecessary.
+Reports on any calls to String.valueOf() used in string concatenations and as arguments to the
+print and println methods of java.io.PrintWriter and java.io.PrintStream. The conversion
+to string will be handled by the underlying library methods without an explicit call to String.valueOf().
Powered by InspectionGadgets
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryToStringCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryToStringCall.html
new file mode 100644
index 000000000000..69cfb6134430
--- /dev/null
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryToStringCall.html
@@ -0,0 +1,13 @@
+
+
+Reports on any calls to .toString() used in string concatenations and as arguments to the
+print and println methods of java.io.PrintWriter and java.io.PrintStream. The conversion
+to string will be handled by the underlying library methods without an explicit call to .toString().
+
+Note that without the .toString() the expression will have different semantics (the string "null" will be used instead of
+ throwing a NullPointerException).
+
+
+Powered by InspectionGadgets
+
+
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/jdk/vararg_parameter/GenericType.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/jdk/vararg_parameter/GenericType.after.java
new file mode 100644
index 000000000000..7c6d0d34ed4d
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/jdk/vararg_parameter/GenericType.after.java
@@ -0,0 +1,11 @@
+package com.siyeh.igfixes.jdk.vararg_parameter;
+
+@SuppressWarnings("UnusedDeclaration")
+public class GenericType {
+ final void addClasses(Class extends Number>[] classes) {
+ }
+
+ void test() {
+ addClasses(new Class[]{Number.class, Byte.class});
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/jdk/vararg_parameter/GenericType.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/jdk/vararg_parameter/GenericType.java
new file mode 100644
index 000000000000..595bf0032e2b
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/jdk/vararg_parameter/GenericType.java
@@ -0,0 +1,12 @@
+package com.siyeh.igfixes.jdk.vararg_parameter;
+
+@SuppressWarnings("UnusedDeclaration")
+public class GenericType {
+ @java.lang.SafeVarargs
+ final void addClasses(Class extends Number>... classes) {
+ }
+
+ void test() {
+ addClasses(Number.class, Byte.class);
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_tostring/UnnecessaryToString.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_tostring/UnnecessaryToString.java
new file mode 100644
index 000000000000..a77660ab714a
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_tostring/UnnecessaryToString.java
@@ -0,0 +1,30 @@
+package com.siyeh.igtest.style.unnecessary_tostring;
+
+public class UnnecessaryToString {
+
+ String foo(Object o) {
+ return "star" + o.toString();
+ }
+
+ String bar() {
+ char[] cs = {'!'};
+ return "wars" + cs.toString();
+ }
+
+ void fizzz(Object o) {
+ boolean c = true;
+ System.out.println(o.toString() + c);
+ }
+
+ void polyadic(Object s) {
+ s = "abc" + s.toString() + "efg";
+ }
+
+ void printStream(Object o) {
+ System.out.print(o.toString());
+ }
+
+ void builder(StringBuilder builder, Object o) {
+ builder.append(o.toString());
+ }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_tostring/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_tostring/expected.xml
new file mode 100644
index 000000000000..9aea4d234a81
--- /dev/null
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_tostring/expected.xml
@@ -0,0 +1,32 @@
+
+
+
+
+ UnnecessaryToString.java
+ 6
+ Unnecessary call to '.toString()'
+ Unnecessary <code>toString()</code> call #loc
+
+
+
+ UnnecessaryToString.java
+ 20
+ Unnecessary call to '.toString()'
+ Unnecessary <code>toString()</code> call #loc
+
+
+
+ UnnecessaryToString.java
+ 24
+ Unnecessary call to '.toString()'
+ Unnecessary <code>toString()</code> call #loc
+
+
+
+ UnnecessaryToString.java
+ 28
+ Unnecessary call to '.toString()'
+ Unnecessary <code>toString()</code> call #loc
+
+
+
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/jdk/VarargParameterFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/jdk/VarargParameterFixTest.java
new file mode 100644
index 000000000000..f14e395ff243
--- /dev/null
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/jdk/VarargParameterFixTest.java
@@ -0,0 +1,18 @@
+package com.siyeh.ig.fixes.jdk;
+
+import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.IGQuickFixesTestCase;
+import com.siyeh.ig.jdk.VarargParameterInspection;
+
+public class VarargParameterFixTest extends IGQuickFixesTestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ myFixture.enableInspections(new VarargParameterInspection());
+ myRelativePath = "jdk/vararg_parameter";
+ myDefaultHint = InspectionGadgetsBundle.message("variable.argument.method.quickfix");
+ }
+
+ public void testGenericType() { doTest(); }
+}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryToStringCallInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryToStringCallInspectionTest.java
new file mode 100644
index 000000000000..797b4273106d
--- /dev/null
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryToStringCallInspectionTest.java
@@ -0,0 +1,10 @@
+package com.siyeh.ig.style;
+
+import com.siyeh.ig.IGInspectionTestCase;
+
+public class UnnecessaryToStringCallInspectionTest extends IGInspectionTestCase {
+
+ public void test() throws Exception {
+ doTest("com/siyeh/igtest/style/unnecessary_tostring", new UnnecessaryToStringCallInspection());
+ }
+}
\ No newline at end of file
diff --git a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ConnectionOnProcess.java b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ConnectionOnProcess.java
index bcf34e8f48a0..b866d1cd9136 100644
--- a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ConnectionOnProcess.java
+++ b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ConnectionOnProcess.java
@@ -142,7 +142,8 @@ public abstract class ConnectionOnProcess implements IConnection {
protected synchronized void execute(GeneralCommandLine commandLine) throws AuthenticationException {
try {
- commandLine.setEnvironment(EnvironmentUtil.getEnvironmentProperties());
+ commandLine.getEnvironment().clear();
+ commandLine.getEnvironment().putAll(EnvironmentUtil.getEnvironmentProperties());
myProcess = commandLine.createProcess();
myErrThread = new ReadProcessThread(
diff --git a/plugins/git4idea/src/git4idea/commands/GitHandler.java b/plugins/git4idea/src/git4idea/commands/GitHandler.java
index 0669a9ee164e..0816bb93db0e 100644
--- a/plugins/git4idea/src/git4idea/commands/GitHandler.java
+++ b/plugins/git4idea/src/git4idea/commands/GitHandler.java
@@ -451,7 +451,8 @@ public abstract class GitHandler {
LOG.debug(String.format("handler=%s, port=%s", myHandlerNo, port));
addAuthListener(httpAuthenticator);
}
- myCommandLine.setEnvironment(myEnv);
+ myCommandLine.getEnvironment().clear();
+ myCommandLine.getEnvironment().putAll(myEnv);
// start process
myProcess = startProcess();
startHandlingStreams();
diff --git a/plugins/google-app-engine/google-app-engine.iml b/plugins/google-app-engine/google-app-engine.iml
index 452bb1f80aed..52217861ad17 100644
--- a/plugins/google-app-engine/google-app-engine.iml
+++ b/plugins/google-app-engine/google-app-engine.iml
@@ -16,7 +16,6 @@
-
diff --git a/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineSupportProvider.java b/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineSupportProvider.java
index b5b1be386585..255145fd9449 100644
--- a/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineSupportProvider.java
+++ b/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineSupportProvider.java
@@ -39,6 +39,10 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.packaging.artifacts.Artifact;
+import com.intellij.packaging.artifacts.ArtifactManager;
+import com.intellij.packaging.artifacts.ArtifactType;
+import com.intellij.packaging.elements.ArtifactRootElement;
+import com.intellij.packaging.elements.PackagingElementFactory;
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.HyperlinkLabel;
@@ -94,28 +98,29 @@ public class AppEngineSupportProvider extends FacetBasedFrameworkSupportProvider
private void addSupport(final Module module, final ModifiableRootModel rootModel, String sdkPath, @Nullable PersistenceApi persistenceApi) {
super.addSupport(module, rootModel, null, null);
- final VirtualFile descriptorDir = AppEngineWebIntegration.getInstance().suggestParentDirectoryForAppEngineWebXml(module, rootModel);
- if (descriptorDir != null) {
- createFileFromTemplate(AppEngineTemplateGroupDescriptorFactory.APP_ENGINE_WEB_XML_TEMPLATE, descriptorDir,
- AppEngineUtil.APP_ENGINE_WEB_XML_NAME);
- }
-
final AppEngineFacet appEngineFacet = AppEngineFacet.getAppEngineFacetByModule(module);
LOG.assertTrue(appEngineFacet != null);
final AppEngineFacetConfiguration facetConfiguration = appEngineFacet.getConfiguration();
facetConfiguration.setSdkHomePath(sdkPath);
final AppEngineSdk sdk = appEngineFacet.getSdk();
- final Artifact artifact = findContainingArtifact(appEngineFacet);
+ final Artifact artifact = findOrCreateArtifact(appEngineFacet);
+
+ final VirtualFile descriptorDir = AppEngineWebIntegration.getInstance().suggestParentDirectoryForAppEngineWebXml(module, rootModel);
+ if (descriptorDir != null) {
+ VirtualFile descriptor = createFileFromTemplate(AppEngineTemplateGroupDescriptorFactory.APP_ENGINE_WEB_XML_TEMPLATE, descriptorDir,
+ AppEngineUtil.APP_ENGINE_WEB_XML_NAME);
+ if (descriptor != null) {
+ AppEngineWebIntegration.getInstance().addDescriptor(artifact, module.getProject(), descriptor);
+ }
+ }
final Project project = module.getProject();
AppEngineWebIntegration.getInstance().setupRunConfiguration(rootModel, sdk, artifact, project);
final Library apiJar = addProjectLibrary(module, "AppEngine API", sdk.getLibUserDirectoryPath(), VirtualFile.EMPTY_ARRAY);
rootModel.addLibraryEntry(apiJar);
- if (artifact != null) {
- AppEngineWebIntegration.getInstance().addLibraryToArtifact(apiJar, artifact, project);
- }
+ AppEngineWebIntegration.getInstance().addLibraryToArtifact(apiJar, artifact, project);
if (persistenceApi != null) {
facetConfiguration.setRunEnhancerOnMake(true);
@@ -146,21 +151,25 @@ public class AppEngineSupportProvider extends FacetBasedFrameworkSupportProvider
}
final Library library = addProjectLibrary(module, "AppEngine ORM", sdk.getOrmLibDirectoryPath(), sdk.getOrmLibSources());
rootModel.addLibraryEntry(library);
- if (artifact != null) {
- AppEngineWebIntegration.getInstance().addLibraryToArtifact(library, artifact, project);
- }
+ AppEngineWebIntegration.getInstance().addLibraryToArtifact(library, artifact, project);
}
}
- @Nullable
- private static Artifact findContainingArtifact(AppEngineFacet appEngineFacet) {
- final Collection artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(appEngineFacet.getModule());
+ @NotNull
+ private static Artifact findOrCreateArtifact(AppEngineFacet appEngineFacet) {
+ Module module = appEngineFacet.getModule();
+ ArtifactType artifactType = AppEngineWebIntegration.getInstance().getAppEngineTargetArtifactType();
+ final Collection artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
for (Artifact artifact : artifacts) {
- if (AppEngineWebIntegration.getInstance().getAppEngineTargetArtifactType().equals(artifact.getArtifactType())) {
+ if (artifactType.equals(artifact.getArtifactType())) {
return artifact;
}
}
- return null;
+ ArtifactManager artifactManager = ArtifactManager.getInstance(module.getProject());
+ PackagingElementFactory elementFactory = PackagingElementFactory.getInstance();
+ ArtifactRootElement> root = elementFactory.createArtifactRootElement();
+ elementFactory.getOrCreateDirectory(root, "WEB-INF/classes").addOrFindChild(elementFactory.createModuleOutput(module));
+ return artifactManager.addArtifact(module.getName(), artifactType, root);
}
private static Library addProjectLibrary(final Module module, final String name, final String path, final VirtualFile[] sources) {
diff --git a/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineWebIntegration.java b/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineWebIntegration.java
index 82076bf1d301..f1d8a67f6779 100644
--- a/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineWebIntegration.java
+++ b/plugins/google-app-engine/source/com/intellij/appengine/facet/AppEngineWebIntegration.java
@@ -52,4 +52,7 @@ public abstract class AppEngineWebIntegration {
public abstract void addLibraryToArtifact(@NotNull Library library, @NotNull Artifact artifact, @NotNull Project project);
public abstract List extends AppEngineSdk> getSdkForConfiguredDevServers();
+
+ public void addDescriptor(@NotNull Artifact artifact, @NotNull Project project, @NotNull VirtualFile descriptor) {
+ }
}
diff --git a/plugins/google-app-engine/source/com/intellij/appengine/facet/impl/AppEngineCommunityWebIntegration.java b/plugins/google-app-engine/source/com/intellij/appengine/facet/impl/AppEngineCommunityWebIntegration.java
index 060355357829..90ea918678ee 100644
--- a/plugins/google-app-engine/source/com/intellij/appengine/facet/impl/AppEngineCommunityWebIntegration.java
+++ b/plugins/google-app-engine/source/com/intellij/appengine/facet/impl/AppEngineCommunityWebIntegration.java
@@ -94,4 +94,9 @@ public class AppEngineCommunityWebIntegration extends AppEngineWebIntegration {
public List extends AppEngineSdk> getSdkForConfiguredDevServers() {
return Collections.emptyList();
}
+
+ @Override
+ public void addDescriptor(@NotNull Artifact artifact, @NotNull Project project, @NotNull VirtualFile descriptor) {
+ ArtifactManager.getInstance(project).addElementsToDirectory(artifact, "WEB-INF", PackagingElementFactory.getInstance().createFileCopy(descriptor.getPath(), null));
+ }
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyGenerationInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyGenerationInfo.java
index 72b88cdfaa95..90c9b9e00f1f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyGenerationInfo.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyGenerationInfo.java
@@ -20,14 +20,18 @@ import com.intellij.codeInsight.generation.PsiGenerationInfo;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ScrollType;
+import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMember;
+import com.intellij.psi.codeStyle.CodeStyleManager;
+import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.GrReferenceAdjuster;
+import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment;
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
@@ -92,6 +96,19 @@ public class GroovyGenerationInfo extends PsiGenerationInfo
}
GrReferenceAdjuster.shortenReferences(member);
+
+ adjustDocCommentIfExists(member);
+ }
+
+ private static void adjustDocCommentIfExists(PsiMember member) {
+ final PsiElement child = member.getFirstChild();
+ if (child instanceof PsiDocComment) {
+ final Project project = member.getProject();
+ final GrDocComment groovyDoc = GroovyPsiElementFactory.getInstance(project).createDocCommentFromText(child.getText());
+ child.delete();
+ CodeStyleManager.getInstance(project).reformat(member);
+ member.getParent().addBefore(groovyDoc, member);
+ }
}
@Override
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java
index 829c73474fd0..284d32d7686c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java
@@ -73,7 +73,6 @@ import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
import org.jetbrains.plugins.groovy.lang.resolve.ClosureMissingMethodContributor;
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
import org.jetbrains.plugins.groovy.lang.resolve.processors.*;
-import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil;
import org.jetbrains.plugins.groovy.util.ResolveProfiler;
import java.util.*;
@@ -95,7 +94,6 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl 0) return classCandidates;
+
final boolean isLValue = PsiUtil.isLValue(this);
String[] accessorNames = isLValue ? GroovyPropertyUtils.suggestSettersName(name) : GroovyPropertyUtils.suggestGettersName(name);
List accessorResults = new ArrayList();
@@ -258,22 +258,6 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl 0) {
- for (GroovyResolveResult candidate : fieldCandidates) {
- PsiElement element = candidate.getElement();
- LOG.assertTrue(element != null, candidate);
- if (GroovyRefactoringUtil.isLocalVariable(element) && !(element instanceof GrBindingVariable)) {
- preferVar = true;
- break;
- }
- }
- }
- return preferVar;
- }
-
-
public GroovyResolveResult[] getCallVariants(GrExpression upToArgument) {
return resolveMethodOrProperty(true, upToArgument, true);
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java
index 219bf607c1b7..2ce54ad11c7c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java
@@ -72,7 +72,10 @@ public class GrIndexPropertyImpl extends GrExpressionImpl implements GrIndexProp
GrExpression selected = getInvokedExpression();
PsiType thisType = selected.getType();
- if (thisType == null) return null;
+ if (thisType == null) {
+ thisType = TypesUtil.getJavaLangObject(this);
+ }
+
GrArgumentList argList = getArgumentList();
@@ -153,7 +156,9 @@ public class GrIndexPropertyImpl extends GrExpressionImpl implements GrIndexProp
GrExpression invoked = getInvokedExpression();
PsiType thisType = invoked.getType();
- if (thisType == null) return GroovyResolveResult.EMPTY_ARRAY;
+ if (thisType == null) {
+ thisType = TypesUtil.getJavaLangObject(this);
+ }
GrArgumentList argList = getArgumentList();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java
index 6f0428fea243..a910b1d3b9fc 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java
@@ -36,6 +36,8 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyFileType;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
@@ -47,6 +49,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAc
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrReflectedMethod;
+import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager;
import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
@@ -278,10 +281,20 @@ public class GrClassImplUtil {
@NotNull ResolveState state,
@Nullable PsiElement lastParent,
@NotNull PsiElement place) {
+ if (place instanceof GrCodeReferenceElement && lastParent instanceof GrModifierList) {
+ final PsiElement possibleAnnotation = PsiTreeUtil.skipParentsOfType(place, GrCodeReferenceElement.class);
+ if (possibleAnnotation instanceof GrAnnotation && possibleAnnotation.getParent() == lastParent) {
+ return true; //don't process class members while resolving annotation which annotates current class
+ }
+ }
+
for (final PsiTypeParameter typeParameter : grType.getTypeParameters()) {
if (!ResolveUtil.processElement(processor, typeParameter, state)) return false;
}
+
+ boolean processInstanceMethods = shouldProcessInstanceMembers(grType, lastParent);
+
NameHint nameHint = processor.getHint(NameHint.KEY);
//todo [DIANA] look more carefully
String name = nameHint == null ? null : nameHint.getName(state);
@@ -296,7 +309,7 @@ public class GrClassImplUtil {
CandidateInfo fieldInfo = fieldsMap.get(name);
if (fieldInfo != null) {
final PsiField field = (PsiField)fieldInfo.getElement();
- if (!isSameDeclaration(place, field)) { //the same variable declaration
+ if (processInstanceMember(processInstanceMethods, field) && !isSameDeclaration(place, field)) { //the same variable declaration
final PsiSubstitutor finalSubstitutor =
PsiClassImplUtil.obtainFinalSubstitutor(field.getContainingClass(), fieldInfo.getSubstitutor(), grType, substitutor, factory,
level);
@@ -307,7 +320,7 @@ public class GrClassImplUtil {
else {
for (CandidateInfo info : fieldsMap.values()) {
final PsiField field = (PsiField)info.getElement();
- if (!isSameDeclaration(place, field)) { //the same variable declaration
+ if (processInstanceMember(processInstanceMethods, field) && !isSameDeclaration(place, field)) { //the same variable declaration
final PsiSubstitutor finalSubstitutor =
PsiClassImplUtil.obtainFinalSubstitutor(field.getContainingClass(), info.getSubstitutor(), grType, substitutor, factory,
level);
@@ -324,7 +337,7 @@ public class GrClassImplUtil {
for (List list : methodsMap.values()) {
for (CandidateInfo info : list) {
PsiMethod method = (PsiMethod)info.getElement();
- if (!isSameDeclaration(place, method) && isMethodVisible(isPlaceGroovy, method)) {
+ if (processInstanceMember(processInstanceMethods, method) && !isSameDeclaration(place, method) && isMethodVisible(isPlaceGroovy, method)) {
final PsiSubstitutor finalSubstitutor =
PsiClassImplUtil.obtainFinalSubstitutor(method.getContainingClass(), info.getSubstitutor(), grType, substitutor, factory,
level);
@@ -340,7 +353,7 @@ public class GrClassImplUtil {
if (byName != null) {
for (CandidateInfo info : byName) {
PsiMethod method = (PsiMethod)info.getElement();
- if (!isSameDeclaration(place, method) && isMethodVisible(isPlaceGroovy, method)) {
+ if (processInstanceMember(processInstanceMethods, method) && !isSameDeclaration(place, method) && isMethodVisible(isPlaceGroovy, method)) {
final PsiSubstitutor finalSubstitutor =
PsiClassImplUtil.obtainFinalSubstitutor(method.getContainingClass(), info.getSubstitutor(), grType, substitutor, factory,
level);
@@ -373,6 +386,27 @@ public class GrClassImplUtil {
return true;
}
+ private static boolean shouldProcessInstanceMembers(@NotNull GrTypeDefinition grType, @Nullable PsiElement lastParent) {
+ if (lastParent != null) {
+ final GrModifierList modifierList = grType.getModifierList();
+ if (modifierList != null && modifierList.findAnnotation(GroovyCommonClassNames.GROOVY_LANG_CATEGORY) != null) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static boolean processInstanceMember(boolean shouldProcessInstance, @NotNull PsiMember member) {
+ if (shouldProcessInstance) return true;
+
+ if (member instanceof GrReflectedMethod) {
+ return ((GrReflectedMethod)member).getBaseMethod().hasModifierProperty(PsiModifier.STATIC);
+ }
+ else {
+ return member.hasModifierProperty(PsiModifier.STATIC);
+ }
+ }
+
@NotNull
private static List getInnerClassesForResolve(@NotNull final GrTypeDefinition grType,
@Nullable final PsiElement lastParent,
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java
index c9c968814d85..05948bb888ec 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java
@@ -389,7 +389,7 @@ public abstract class MvcFramework {
final VirtualFile griffonHome = getSdkRoot(module);
if (griffonHome != null) {
- commandLine.setEnvironment(getSdkHomePropertyName(), FileUtil.toSystemDependentName(griffonHome.getPath()));
+ commandLine.getEnvironment().put(getSdkHomePropertyName(), FileUtil.toSystemDependentName(griffonHome.getPath()));
}
final VirtualFile root = findAppRoot(module);
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/GrCreateConstructorMatchingSuperTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/GrCreateConstructorMatchingSuperTest.groovy
new file mode 100644
index 000000000000..8e450c215b8d
--- /dev/null
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/GrCreateConstructorMatchingSuperTest.groovy
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2013 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.plugins.groovy.intentions
+
+/**
+ * @author Max Medvedev
+ */
+class GrCreateConstructorMatchingSuperTest extends GrIntentionTestCase {
+ GrCreateConstructorMatchingSuperTest() {
+ super('Create constructor matching super')
+ }
+
+ public void testSuperWithJavaDoc() throws Exception {
+ myFixture.addClass('''\
+public class Base {
+ /**
+ * my doc
+ */
+ public Base(int x) {
+ }
+}
+''')
+
+ doTextTest('''\
+class Inheritor extends Base {
+}
+''', '''\
+class Inheritor extends Base {
+ /**
+ * my doc
+ */
+ Inheritor(int x) {
+ super(x)
+ }
+}
+''')
+
+ }
+}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy
index 992c5bfccc6b..d5dbb5681728 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy
@@ -570,7 +570,7 @@ print i[1]
+print a[1, 2]
''')
}
@@ -632,7 +632,7 @@ i[1] = 2
+a[1, 3] = 2
''')
}
diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/unresolvedArrayAccess.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/unresolvedArrayAccess.java
index bf6515e7cb67..dc65c743da98 100644
--- a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/unresolvedArrayAccess.java
+++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/unresolvedArrayAccess.java
@@ -1,2 +1,2 @@
java.lang.Object foo;
-print(foo.getAt(1));
+print(org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(foo, 1));
diff --git a/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/AbstractJavaFxPackager.java b/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/AbstractJavaFxPackager.java
index 7d5f7c25007b..e4e88132fb8f 100644
--- a/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/AbstractJavaFxPackager.java
+++ b/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/AbstractJavaFxPackager.java
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.util.ArrayUtilRt;
import com.intellij.util.Base64Converter;
import com.intellij.util.PathUtilRt;
import com.intellij.util.io.ZipUtil;
@@ -38,6 +39,7 @@ import java.util.List;
*/
public abstract class AbstractJavaFxPackager {
private static final Logger LOG = Logger.getInstance("#" + AbstractJavaFxPackager.class.getName());
+ private static final String JB_JFX_JKS = "jb-jfx.jks";
//artifact description
protected String getArtifactRootName() {
@@ -84,7 +86,7 @@ public abstract class AbstractJavaFxPackager {
tempUnzippedArtifactOutput = FileUtil.createTempDirectory("artifact", "unzipped");
final File artifactOutputFile = new File(zipPath);
ZipUtil.extract(artifactOutputFile, tempUnzippedArtifactOutput, null);
- copyLibraries(artifactOutputFile.getName(), tempUnzippedArtifactOutput);
+ copyLibraries(FileUtil.getNameWithoutExtension(artifactOutputFile), tempUnzippedArtifactOutput);
}
catch (IOException e) {
registerJavaFxPackagerError(e);
@@ -128,11 +130,15 @@ public abstract class AbstractJavaFxPackager {
private void copyLibraries(String zipPath, File tempUnzippedArtifactOutput) throws IOException {
final File[] outFiles = new File(getArtifactOutputPath()).listFiles();
if (outFiles != null) {
+ final String[] generatedItems = new String[] {JB_JFX_JKS, zipPath + ".jar", zipPath + ".jnlp", zipPath + ".html"};
for (File file : outFiles) {
- if (file.isFile()) {
- final String fileName = file.getName();
- if (fileName.endsWith(".jar") && !zipPath.equals(fileName)) {
- FileUtil.copy(file, new File(tempUnzippedArtifactOutput, fileName));
+ final String fileName = file.getName();
+ if (ArrayUtilRt.find(generatedItems, fileName) < 0) {
+ final File destination = new File(tempUnzippedArtifactOutput, fileName);
+ if (file.isFile()) {
+ FileUtil.copy(file, destination);
+ } else {
+ FileUtil.copyDir(file, destination, true);
}
}
}
@@ -320,7 +326,7 @@ public abstract class AbstractJavaFxPackager {
}
private String getKeystore(boolean selfSigning) {
- return selfSigning ? getArtifactOutputPath() + File.separator + "jb-jfx.jks" : getKeystore();
+ return selfSigning ? getArtifactOutputPath() + File.separator + JB_JFX_JKS : getKeystore();
}
private String getStorepass(boolean selfSigning) {
diff --git a/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/JavaFxAntGenerator.java b/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/JavaFxAntGenerator.java
index 5c4e56572558..01ff08300845 100644
--- a/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/JavaFxAntGenerator.java
+++ b/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/JavaFxAntGenerator.java
@@ -53,13 +53,13 @@ public class JavaFxAntGenerator {
topLevelTagsCollector.add(new SimpleTag("fx:fileset", new Pair("id", allButPreloader),
new Pair("dir", tempDirPath),
new Pair("excludes", preloaderJar),
- new Pair("includes", "*.jar")));
+ new Pair("includes", "**/*.jar")));
}
final String allButSelf = "all_but_" + artifactName;
final SimpleTag allButSelfAndPreloader = new SimpleTag("fx:fileset", new Pair("id", allButSelf),
new Pair("dir", tempDirPath),
- new Pair("includes", "*.jar"));
+ new Pair("includes", "**/*.jar"));
allButSelfAndPreloader.add(new SimpleTag("exclude", new Pair("name", artifactFileName)));
if (preloaderJar != null) {
allButSelfAndPreloader.add(new SimpleTag("exclude", new Pair("name", preloaderJar)));
@@ -69,7 +69,7 @@ public class JavaFxAntGenerator {
final String all = "all_" + artifactName;
final SimpleTag allIncluded = new SimpleTag("fx:fileset", new Pair("id", all),
new Pair("dir", tempDirPath),
- new Pair("includes", "*.jar"));
+ new Pair("includes", "**/*.jar"));
topLevelTagsCollector.add(allIncluded);
//register application
@@ -100,7 +100,7 @@ public class JavaFxAntGenerator {
final List fileset2Jar = new ArrayList();
fileset2Jar.add(new Pair("dir", tempDirPath));
- fileset2Jar.add(new Pair("excludes", "*.jar"));
+ fileset2Jar.add(new Pair("excludes", "**/*.jar"));
createJarTag.add(new SimpleTag("fileset", fileset2Jar.toArray(new Pair[fileset2Jar.size()])));
createJarTag.add(createResourcesTag(preloaderFiles, false, allButPreloader, allButSelf, all));
diff --git a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/packaging/JavaFxAntTaskTest.java b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/packaging/JavaFxAntTaskTest.java
index 191304c602c6..0c58204fbc17 100644
--- a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/packaging/JavaFxAntTaskTest.java
+++ b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/packaging/JavaFxAntTaskTest.java
@@ -35,18 +35,18 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
private static final String SIGNED = "signed";
public void testJarDeployNoInfo() throws Exception {
- doTest("\n" +
+ doTest("\n" +
"\n" +
"\n" +
"\n" +
- "\n" +
+ "\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
- "\n" +
+ "\n" +
"\n" +
"\n" +
"\n" +
@@ -64,18 +64,18 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
}
public void testJarDeployTitle() throws Exception {
- doTest("\n" +
+ doTest("\n" +
"\n" +
"\n" +
"\n" +
- "\n" +
+ "\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
- "\n" +
+ "\n" +
"\n" +
"\n" +
"\n" +
@@ -95,18 +95,18 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
}
public void testJarDeploySigned() throws Exception {
- doTest("\n" +
+ doTest("\n" +
"\n" +
"\n" +
"\n" +
- "\n" +
+ "\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
- "\n" +
+ "\n" +
"\n" +
"\n" +
"\n" +
@@ -131,22 +131,22 @@ public class JavaFxAntTaskTest extends UsefulTestCase{
options.put(PRELOADER_JAR, "preloader.jar");
doTest("\n" +
"\n" +
- "\n" +
+ "\n" +
"\n" +
- "\n" +
+ "\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
- "\n" +
+ "\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
- "\n" +
+ "\n" +
"\n" +
"\n" +
"\n" +
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxControllerFieldSearcher.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxControllerFieldSearcher.java
index 6f09d6fb4932..3e9fc9efa3c6 100644
--- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxControllerFieldSearcher.java
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxControllerFieldSearcher.java
@@ -70,11 +70,11 @@ public class JavaFxControllerFieldSearcher implements QueryExecutor paths) {
if (paths == null) return;
- assertUnorderedElementsAreEqual(lib.getRootUrls(type), ArrayUtil.toStringArray(paths));
+ assertUnorderedPathsAreEqual(Arrays.asList(lib.getRootUrls(type)), paths);
// also check the library because it may contain slight different set of urls (e.g. with duplicates)
- assertUnorderedElementsAreEqual(lib.getLibrary().getUrls(type), ArrayUtil.toStringArray(paths));
+ assertUnorderedPathsAreEqual(Arrays.asList(lib.getLibrary().getUrls(type)), paths);
}
protected void assertModuleLibDepScope(String moduleName, String depName, DependencyScope scope) {
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java
index dcf900e1f087..ef8e43f78829 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java
@@ -35,6 +35,7 @@ import com.intellij.testFramework.UsefulTestCase;
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
import com.intellij.util.ui.UIUtil;
+import gnu.trove.THashSet;
import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.idea.maven.indices.MavenIndicesManager;
@@ -497,6 +498,9 @@ public abstract class MavenTestCase extends UsefulTestCase {
protected static void assertUnorderedElementsAreEqual(Collection actual, Collection expected) {
assertEquals(new HashSet(expected), new HashSet(actual));
}
+ protected static void assertUnorderedPathsAreEqual(Collection actual, Collection expected) {
+ assertEquals(new THashSet(expected, FileUtil.PATH_HASHING_STRATEGY), new THashSet(actual, FileUtil.PATH_HASHING_STRATEGY));
+ }
protected static void assertUnorderedElementsAreEqual(T[] actual, T... expected) {
assertUnorderedElementsAreEqual(Arrays.asList(actual), expected);
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenResolveToWorkspaceTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenResolveToWorkspaceTest.java
index 3cfb1a4ca46d..4cf5b79a615b 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenResolveToWorkspaceTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenResolveToWorkspaceTest.java
@@ -35,9 +35,9 @@ import java.util.Properties;
/**
* @author Sergey Evdokimov
*/
-public class MavenResolveToWorkspaceTest extends MavenImportingTestCase {
+public abstract class MavenResolveToWorkspaceTest extends MavenImportingTestCase {
- public void _testIgnoredProject() throws Exception {
+ public void testIgnoredProject() throws Exception {
createProjectPom("test" +
"project" +
"1" +
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/FacetImporterTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/FacetImporterTestCase.java
index 0c11426e5a1f..31ae08162462 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/FacetImporterTestCase.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/FacetImporterTestCase.java
@@ -3,8 +3,7 @@ package org.jetbrains.idea.maven.importing;
import com.intellij.facet.Facet;
import com.intellij.facet.FacetManager;
import com.intellij.facet.FacetType;
-import com.intellij.openapi.vfs.VfsUtil;
-import com.intellij.util.ArrayUtil;
+import com.intellij.openapi.vfs.VfsUtilCore;
import org.jetbrains.idea.maven.MavenImportingTestCase;
import java.util.ArrayList;
@@ -25,11 +24,11 @@ public abstract class FacetImporterTestCase expectedRootUrls = new ArrayList();
for (String r : roots) {
- String url = VfsUtil.pathToUrl(getProjectPath() + "/" + r);
+ String url = VfsUtilCore.pathToUrl(getProjectPath() + "/" + r);
expectedRootUrls.add(url);
}
- assertUnorderedElementsAreEqual(actualRoots, ArrayUtil.toStringArray(expectedRootUrls));
+ assertUnorderedPathsAreEqual(actualRoots, expectedRootUrls);
}
protected FACET_TYPE getFacet(String module) {
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/FoldersImportingTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/FoldersImportingTest.java
index 248c3cd67b97..fa0857650c3c 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/FoldersImportingTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/FoldersImportingTest.java
@@ -608,6 +608,25 @@ public class FoldersImportingTest extends MavenImportingTestCase {
"target/generated-sources");
}
+ public void testIgnoreGeneratedSources() throws Exception {
+ createStdProjectFolders();
+
+ MavenProjectsManager.getInstance(myProject).getImportingSettings().setGeneratedSourcesFolder(
+ MavenImportingSettings.GeneratedSourcesFolder.IGNORE);
+
+ createProjectSubFile("target/generated-sources/annotations/A.java", "package com; class A {}");
+ createProjectSubFile("target/generated-sources/annotations/com/B.java", "package com; class B {}");
+
+ importProject("test" +
+ "project" +
+ "1");
+
+ assertSources("project",
+ "src/main/java",
+ "src/main/resources");
+ }
+
+
public void testAddingExistingGeneratedSources4() throws Exception {
createStdProjectFolders();
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/GroovyImporterTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/GroovyImporterTest.java
index be05c84b78bc..9cf632dc956d 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/GroovyImporterTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/GroovyImporterTest.java
@@ -8,11 +8,10 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.libraries.Library;
import org.jetbrains.idea.maven.MavenImportingTestCase;
-import org.jetbrains.idea.maven.importing.MavenDefaultModifiableModelsProvider;
-import org.jetbrains.idea.maven.importing.MavenRootModelAdapter;
import org.jetbrains.plugins.groovy.config.GroovyConfigUtils;
import java.io.File;
+import java.util.Arrays;
public class GroovyImporterTest extends MavenImportingTestCase {
@Override
@@ -67,9 +66,9 @@ public class GroovyImporterTest extends MavenImportingTestCase {
Library[] libraries = GroovyConfigUtils.getInstance().getSDKLibrariesByModule(getModule("project"));
assertTrue("unexpected groovy libs configuration: " + libraries.length, libraries.length > 0);
Library library = libraries[0];
- assertUnorderedElementsAreEqual(
- library.getUrls(OrderRootType.CLASSES),
- "jar://" + getRepositoryPath() + "/org/codehaus/groovy/groovy-all-minimal/1.5.6/groovy-all-minimal-1.5.6.jar!/");
+ assertUnorderedPathsAreEqual(
+ Arrays.asList(library.getUrls(OrderRootType.CLASSES)),
+ Arrays.asList("jar://" + getRepositoryPath() + "/org/codehaus/groovy/groovy-all-minimal/1.5.6/groovy-all-minimal-1.5.6.jar!/"));
}
public void testAddingGroovySpecificSources() throws Exception {
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsManagerTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsManagerTest.java
index cee2ec718491..ac9b17abe4c8 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsManagerTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsManagerTest.java
@@ -371,8 +371,8 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase {
MavenProject parentNode = roots.get(0);
MavenProject childNode = myProjectsTree.getModules(roots.get(0)).get(0);
- assertUnorderedElementsAreEqual(parentNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/value1"));
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/value1"));
+ assertUnorderedPathsAreEqual(parentNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/value1")));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value1")));
updateSettingsXml("" +
" " +
@@ -387,14 +387,14 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase {
"");
waitForReadingCompletion();
- assertUnorderedElementsAreEqual(parentNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/value2"));
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/value2"));
+ assertUnorderedPathsAreEqual(parentNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/value2")));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value2")));
deleteSettingsXml();
waitForReadingCompletion();
- assertUnorderedElementsAreEqual(parentNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/${prop}"));
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/${prop}"));
+ assertUnorderedPathsAreEqual(parentNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/${prop}")));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/${prop}")));
updateSettingsXml("" +
" " +
@@ -409,8 +409,8 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase {
"");
waitForReadingCompletion();
- assertUnorderedElementsAreEqual(parentNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/value2"));
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/value2"));
+ assertUnorderedPathsAreEqual(parentNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/value2")));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value2")));
}
public void testUpdatingProjectsWhenSettingsXmlLocationIsChanged() throws Exception {
@@ -461,20 +461,20 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase {
MavenProject parentNode = roots.get(0);
MavenProject childNode = myProjectsTree.getModules(roots.get(0)).get(0);
- assertUnorderedElementsAreEqual(parentNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/value1"));
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/value1"));
+ assertUnorderedPathsAreEqual(parentNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/value1")));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value1")));
getMavenGeneralSettings().setUserSettingsFile("");
waitForReadingCompletion();
- assertUnorderedElementsAreEqual(parentNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/${prop}"));
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/${prop}"));
+ assertUnorderedPathsAreEqual(parentNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/${prop}")));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/${prop}")));
getMavenGeneralSettings().setUserSettingsFile(new File(myDir, "settings.xml").getPath());
waitForReadingCompletion();
- assertUnorderedElementsAreEqual(parentNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/value1"));
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/value1"));
+ assertUnorderedPathsAreEqual(parentNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/value1")));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value1")));
}
public void testUpdatingProjectsOnSettingsXmlCreationAndDeletion() throws Exception {
@@ -586,8 +586,8 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase {
MavenProject parentNode = roots.get(0);
MavenProject childNode = myProjectsTree.getModules(roots.get(0)).get(0);
- assertUnorderedElementsAreEqual(parentNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/value1"));
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/value1"));
+ assertUnorderedPathsAreEqual(parentNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/value1")));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value1")));
createProfilesXmlOldStyle("" +
" one" +
@@ -600,14 +600,14 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase {
"");
waitForReadingCompletion();
- assertUnorderedElementsAreEqual(parentNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/value2"));
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/value2"));
+ assertUnorderedPathsAreEqual(parentNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/value2")));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value2")));
deleteProfilesXml();
waitForReadingCompletion();
- assertUnorderedElementsAreEqual(parentNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/${prop}"));
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/${prop}"));
+ assertUnorderedPathsAreEqual(parentNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/${prop}")));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/${prop}")));
createProfilesXmlOldStyle("" +
" one" +
@@ -620,8 +620,8 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase {
"");
waitForReadingCompletion();
- assertUnorderedElementsAreEqual(parentNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/value2"));
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/value2"));
+ assertUnorderedPathsAreEqual(parentNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/value2")));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value2")));
}
public void testHandlingDirectoryWithPomFileDeletion() throws Exception {
@@ -691,9 +691,9 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase {
myProjectsManager.setIgnoredFilesPatterns(Arrays.asList("*.xxx"));
state = myProjectsManager.getState();
- assertUnorderedElementsAreEqual(state.originalFiles, p1.getPath(), p2.getPath());
+ assertUnorderedPathsAreEqual(state.originalFiles, Arrays.asList(p1.getPath(), p2.getPath()));
assertUnorderedElementsAreEqual(MavenWorkspaceSettingsComponent.getInstance(myProject).getState().enabledProfiles, "one", "two");
- assertUnorderedElementsAreEqual(state.ignoredFiles, p1.getPath());
+ assertUnorderedPathsAreEqual(state.ignoredFiles, Arrays.asList(p1.getPath()));
assertUnorderedElementsAreEqual(state.ignoredPathMasks, "*.xxx");
MavenProjectsManagerState newState = new MavenProjectsManagerState();
@@ -705,10 +705,10 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase {
myProjectsManager.loadState(newState);
- assertUnorderedElementsAreEqual(myProjectsManager.getProjectsTreeForTests().getManagedFilesPaths(),
- p1.getPath(), p3.getPath());
+ assertUnorderedPathsAreEqual(myProjectsManager.getProjectsTreeForTests().getManagedFilesPaths(),
+ Arrays.asList(p1.getPath(), p3.getPath()));
assertUnorderedElementsAreEqual(myProjectsManager.getExplicitProfiles(), "three");
- assertUnorderedElementsAreEqual(myProjectsManager.getIgnoredFilesPaths(), p1.getPath());
+ assertUnorderedPathsAreEqual(myProjectsManager.getIgnoredFilesPaths(), Arrays.asList(p1.getPath()));
assertUnorderedElementsAreEqual(myProjectsManager.getIgnoredFilesPatterns(), "*.zzz");
waitForReadingCompletion();
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsTreeReadingTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsTreeReadingTest.java
index 0f594ce41042..2f118ed2b79f 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsTreeReadingTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectsTreeReadingTest.java
@@ -1594,13 +1594,13 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase {
MavenProject parentNode = roots.get(0);
MavenProject childNode = myTree.getModules(roots.get(0)).get(0);
- assertUnorderedElementsAreEqual(parentNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/value1"));
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/value1"));
+ assertUnorderedPathsAreEqual(parentNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/value1")));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value1")));
updateAll(Arrays.asList("two"), myProjectPom);
- assertUnorderedElementsAreEqual(parentNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/value2"));
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/value2"));
+ assertUnorderedPathsAreEqual(parentNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/value2")));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value2")));
}
public void testUpdatingModelWhenProfilesXmlChange() throws Exception {
@@ -1628,7 +1628,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase {
List roots = myTree.getRootProjects();
MavenProject project = roots.get(0);
- assertUnorderedElementsAreEqual(project.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/value1"));
+ assertUnorderedPathsAreEqual(project.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/value1")));
createProfilesXmlOldStyle("" +
" one" +
@@ -1642,7 +1642,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase {
updateAll(myProjectPom);
- assertUnorderedElementsAreEqual(project.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/value2"));
+ assertUnorderedPathsAreEqual(project.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/value2")));
}
public void testUpdatingModelWhenParentProfilesXmlChange() throws Exception {
@@ -1683,7 +1683,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase {
List roots = myTree.getRootProjects();
MavenProject childProject = roots.get(1);
- assertUnorderedElementsAreEqual(childProject.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/value1"));
+ assertUnorderedPathsAreEqual(childProject.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value1")));
createProfilesXmlOldStyle("parent",
"" +
@@ -1697,7 +1697,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase {
"");
update(parent);
- assertUnorderedElementsAreEqual(childProject.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/value2"));
+ assertUnorderedPathsAreEqual(childProject.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value2")));
}
public void testUpdatingModelWhenParentProfilesXmlChangeAndItIsAModuleAlso() throws Exception {
@@ -1738,7 +1738,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase {
updateAll(myProjectPom);
MavenProject childNode = myTree.getModules(myTree.getRootProjects().get(0)).get(0);
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/value1"));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value1")));
createProfilesXmlOldStyle("" +
" one" +
@@ -1751,7 +1751,7 @@ public class MavenProjectsTreeReadingTest extends MavenProjectsTreeTestCase {
"");
updateAll(myProjectPom);
- assertUnorderedElementsAreEqual(childNode.getSources(), FileUtil.toSystemDependentName(getProjectPath() + "/m/value2"));
+ assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value2")));
}
public void testDoNotUpdateModelWhenAggregatorProfilesXmlChange() throws Exception {
diff --git a/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.java b/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.java
index 7df9cfa8f6d1..b9d63d442292 100644
--- a/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.java
+++ b/spellchecker/src/com/intellij/spellchecker/SpellCheckerManager.java
@@ -80,7 +80,7 @@ public class SpellCheckerManager {
public void updateBundledDictionaries(final List removedDictionaries) {
for (BundledDictionaryProvider provider : Extensions.getExtensions(BundledDictionaryProvider.EP_NAME)) {
for (String dictionary : provider.getBundledDictionaries()) {
- boolean dictionaryShouldBeLoad = this.settings == null || !this.settings.getBundledDisabledDictionariesPaths().contains(dictionary);
+ boolean dictionaryShouldBeLoad = settings == null || !settings.getBundledDisabledDictionariesPaths().contains(dictionary);
boolean dictionaryIsLoad = spellChecker.isDictionaryLoad(dictionary);
if (dictionaryIsLoad && !dictionaryShouldBeLoad) {
spellChecker.removeDictionary(dictionary);
@@ -97,10 +97,11 @@ public class SpellCheckerManager {
}
}
}
- if (this.settings != null && this.settings.getDictionaryFoldersPaths() != null) {
+ if (settings != null && settings.getDictionaryFoldersPaths() != null) {
final Set disabledDictionaries = settings.getDisabledDictionariesPaths();
- for (String folder : this.settings.getDictionaryFoldersPaths()) {
+ for (String folder : settings.getDictionaryFoldersPaths()) {
SPFileUtil.processFilesRecursively(folder, new Consumer() {
+ @Override
public void consume(final String s) {
boolean dictionaryShouldBeLoad =!disabledDictionaries.contains(s);
boolean dictionaryIsLoad = spellChecker.isDictionaryLoad(s);
@@ -116,13 +117,13 @@ public class SpellCheckerManager {
}
}
-
- if (removedDictionaries != null && removedDictionaries.size() > 0) {
+
+ if (removedDictionaries != null && !removedDictionaries.isEmpty()) {
for (final String name : removedDictionaries) {
spellChecker.removeDictionary(name);
}
}
-
+
restartInspections();
}
@@ -138,6 +139,7 @@ public class SpellCheckerManager {
spellChecker.reset();
final StateLoader stateLoader = new StateLoader(project);
stateLoader.load(new Consumer() {
+ @Override
public void consume(String s) {
//do nothing - in this loader we don't worry about word list itself - the whole dictionary will be restored
}
@@ -146,7 +148,7 @@ public class SpellCheckerManager {
// Load bundled dictionaries from corresponding jars
for (BundledDictionaryProvider provider : Extensions.getExtensions(BundledDictionaryProvider.EP_NAME)) {
for (String dictionary : provider.getBundledDictionaries()) {
- if (this.settings == null || !this.settings.getBundledDisabledDictionariesPaths().contains(dictionary)) {
+ if (settings == null || !settings.getBundledDisabledDictionariesPaths().contains(dictionary)) {
final Class extends BundledDictionaryProvider> loaderClass = provider.getClass();
final InputStream stream = loaderClass.getResourceAsStream(dictionary);
if (stream != null) {
@@ -158,10 +160,11 @@ public class SpellCheckerManager {
}
}
}
- if (this.settings != null && this.settings.getDictionaryFoldersPaths() != null) {
+ if (settings != null && settings.getDictionaryFoldersPaths() != null) {
final Set disabledDictionaries = settings.getDisabledDictionariesPaths();
- for (String folder : this.settings.getDictionaryFoldersPaths()) {
+ for (String folder : settings.getDictionaryFoldersPaths()) {
SPFileUtil.processFilesRecursively(folder, new Consumer() {
+ @Override
public void consume(final String s) {
if (!disabledDictionaries.contains(s)) {
loaders.add(new FileLoader(s, s));
@@ -225,7 +228,7 @@ public class SpellCheckerManager {
protected List getRawSuggestions(@NotNull String word) {
if (!spellChecker.isCorrect(word)) {
List suggestions = spellChecker.getSuggestions(word, MAX_SUGGESTIONS_THRESHOLD, MAX_METRICS);
- if (suggestions.size() != 0) {
+ if (!suggestions.isEmpty()) {
boolean capitalized = Strings.isCapitalized(word);
boolean upperCases = Strings.isUpperCase(word);
if (capitalized) {
@@ -249,6 +252,7 @@ public class SpellCheckerManager {
public static void restartInspections() {
ApplicationManager.getApplication().invokeLater(new Runnable() {
+ @Override
public void run() {
Project[] projects = ProjectManager.getInstance().getOpenProjects();
for (Project project : projects) {
diff --git a/spellchecker/src/com/intellij/spellchecker/compress/CompressedDictionary.java b/spellchecker/src/com/intellij/spellchecker/compress/CompressedDictionary.java
index 1f5f4e63647f..2e7587ff2c9f 100644
--- a/spellchecker/src/com/intellij/spellchecker/compress/CompressedDictionary.java
+++ b/spellchecker/src/com/intellij/spellchecker/compress/CompressedDictionary.java
@@ -28,7 +28,6 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
public final class CompressedDictionary implements Dictionary {
-
private final Alphabet alphabet;
private int wordsCount;
private byte[][] words;
@@ -39,6 +38,7 @@ public final class CompressedDictionary implements Dictionary {
private TIntObjectHashMap> rawData = new TIntObjectHashMap>();
private static final Comparator COMPARATOR = new Comparator() {
+ @Override
public int compare(byte[] o1, byte[] o2) {
return compareArrays(o1, o2);
}
@@ -50,7 +50,7 @@ public final class CompressedDictionary implements Dictionary {
this.name = name;
}
- void addToDictionary(byte[] word) {
+ void addToDictionary(@NotNull byte[] word) {
SortedSet set = rawData.get(word.length);
if (set == null) {
set = createSet();
@@ -82,11 +82,12 @@ public final class CompressedDictionary implements Dictionary {
rawData = null;
}
+ @NotNull
private static SortedSet createSet() {
return new TreeSet(COMPARATOR);
-
}
+ @NotNull
public List getWords(char first, int minLength, int maxLength) {
int index = alphabet.getIndex(first, false);
List result = new ArrayList();
@@ -111,19 +112,20 @@ public final class CompressedDictionary implements Dictionary {
return result;
}
+ @NotNull
public List getWords(char first) {
return getWords(first, 0, Integer.MAX_VALUE);
}
+ @NotNull
+ @Override
public String getName() {
return name;
}
+ @Override
@Nullable
- public Boolean contains(String word) {
- if (word == null) {
- return false;
- }
+ public Boolean contains(@NotNull String word) {
UnitBitSet bs = encoder.encode(word, false);
if (bs == Encoder.WORD_OF_ENTIRELY_UNKNOWN_LETTERS)
return null;
@@ -141,18 +143,22 @@ public final class CompressedDictionary implements Dictionary {
}
+ @Override
public boolean isEmpty() {
return wordsCount <= 0;
}
- public void traverse(Consumer action) {
+ @Override
+ public void traverse(@NotNull Consumer action) {
throw new UnsupportedOperationException();
}
+ @Override
public Set getWords() {
throw new UnsupportedOperationException();
}
+ @Override
public int size() {
return wordsCount;
}
@@ -167,11 +173,13 @@ public final class CompressedDictionary implements Dictionary {
return sb.toString();
}
+ @NotNull
public static CompressedDictionary create(@NotNull Loader loader, @NotNull final Transformation transform) {
Alphabet alphabet = new Alphabet();
final Encoder encoder = new Encoder(alphabet);
final CompressedDictionary dictionary = new CompressedDictionary(alphabet, encoder, loader.getName());
loader.load(new Consumer() {
+ @Override
public void consume(String s) {
String transformed = transform.transform(s);
if (transformed != null) {
@@ -186,16 +194,20 @@ public final class CompressedDictionary implements Dictionary {
return dictionary;
}
- public static int compareArrays(byte[] array1, byte[] array2) {
- if (array1.length != array2.length) {
- return array1.length < array2.length ? -1 : 1;
+ public static int compareArrays(@NotNull byte[] array1, @NotNull byte[] array2) {
+ return compareArrays(array1, 0, array1.length, array2);
+ }
+ private static int compareArrays(@NotNull byte[] array1, int start1, int length1, @NotNull byte[] array2) {
+ if (length1 != array2.length) {
+ return length1 < array2.length ? -1 : 1;
}
//compare elements values
- for (int i = 0; i < array1.length; i++) {
- if (array1[i] < array2[i]) {
+ for (int i = 0; i < length1; i++) {
+ int d = array1[i+start1] - array2[i];
+ if (d < 0) {
return -1;
}
- else if (array1[i] > array2[i]) {
+ else if (d > 0) {
return 1;
}
}
@@ -203,19 +215,17 @@ public final class CompressedDictionary implements Dictionary {
}
- public static boolean contains(byte[] goal, byte[] data) {
+ public static boolean contains(@NotNull byte[] goal, @NotNull byte[] data) {
return binarySearchNew(goal, 0, data.length / goal.length, data) >= 0;
}
- public static int binarySearchNew(byte[] goal, int fromIndex, int toIndex, byte[] data) {
+ public static int binarySearchNew(@NotNull byte[] goal, int fromIndex, int toIndex, @NotNull byte[] data) {
int unitLength = goal.length;
int low = fromIndex;
int high = toIndex - 1;
while (low <= high) {
int mid = low + high >>> 1;
- byte[] toTest = new byte[unitLength];
- System.arraycopy(data, mid * unitLength, toTest, 0, unitLength);
- int check = compareArrays(toTest, goal);
+ int check = compareArrays(data, mid * unitLength, unitLength, goal);
if (check == -1) {
low = mid + 1;
}
@@ -228,6 +238,4 @@ public final class CompressedDictionary implements Dictionary {
}
return -(low + 1); // key not found.
}
-
-
}
diff --git a/spellchecker/src/com/intellij/spellchecker/dictionary/AggregatedDictionary.java b/spellchecker/src/com/intellij/spellchecker/dictionary/AggregatedDictionary.java
index 78ab84baa616..94f9d2fcc891 100644
--- a/spellchecker/src/com/intellij/spellchecker/dictionary/AggregatedDictionary.java
+++ b/spellchecker/src/com/intellij/spellchecker/dictionary/AggregatedDictionary.java
@@ -16,6 +16,7 @@
package com.intellij.spellchecker.dictionary;
import com.intellij.util.Consumer;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -23,11 +24,12 @@ import java.util.Collection;
import java.util.Set;
public class AggregatedDictionary implements EditableDictionary {
-
- private static final String DICTIONARY_NAME = "common";
+ @NonNls private static final String DICTIONARY_NAME = "common";
private final EditableDictionary cachedDictionary;
private final ProjectDictionary projectDictionary;
+ @NotNull
+ @Override
public String getName() {
return DICTIONARY_NAME;
}
@@ -38,10 +40,12 @@ public class AggregatedDictionary implements EditableDictionary {
this.cachedDictionary.addToDictionary(projectDictionary.getWords());
}
+ @Override
public boolean isEmpty() {
return false;
}
+ @NonNls
@Override
public String toString() {
return "AggregatedDictionary{" +
@@ -50,25 +54,26 @@ public class AggregatedDictionary implements EditableDictionary {
'}';
}
+ @Override
@Nullable
- public Boolean contains(String word) {
- if (word == null) {
- return false;
- }
+ public Boolean contains(@NotNull String word) {
return cachedDictionary.contains(word);
}
+ @Override
public void addToDictionary(String word) {
getProjectDictionary().addToDictionary(word);
getCachedDictionary().addToDictionary(word);
}
+ @Override
public void removeFromDictionary(String word) {
getProjectDictionary().removeFromDictionary(word);
getCachedDictionary().removeFromDictionary(word);
}
+ @Override
public void replaceAll(@Nullable Collection words) {
Set oldWords = getProjectDictionary().getWords();
getProjectDictionary().replaceAll(words);
@@ -81,29 +86,35 @@ public class AggregatedDictionary implements EditableDictionary {
}
}
+ @Override
public void clear() {
getProjectDictionary().clear();
}
+ @Override
public void traverse(@NotNull final Consumer consumer) {
cachedDictionary.traverse(consumer);
}
+ @Override
public Set getWords() {
return cachedDictionary.getWords();
}
+ @Override
public int size() {
- return (cachedDictionary.size());
+ return cachedDictionary.size();
}
+ @Override
@Nullable
public Set getEditableWords() {
return getProjectDictionary().getEditableWords();
}
+ @Override
public void addToDictionary(@Nullable Collection words) {
getProjectDictionary().addToDictionary(words);
getCachedDictionary().addToDictionary(words);
diff --git a/spellchecker/src/com/intellij/spellchecker/dictionary/Dictionary.java b/spellchecker/src/com/intellij/spellchecker/dictionary/Dictionary.java
index 1057bb6e2d32..b9cc69913edb 100644
--- a/spellchecker/src/com/intellij/spellchecker/dictionary/Dictionary.java
+++ b/spellchecker/src/com/intellij/spellchecker/dictionary/Dictionary.java
@@ -16,20 +16,21 @@
package com.intellij.spellchecker.dictionary;
import com.intellij.util.Consumer;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
public interface Dictionary {
-
+ @NotNull
String getName();
@Nullable
- Boolean contains(String word);
+ Boolean contains(@NotNull String word);
boolean isEmpty();
- void traverse(final Consumer action);
+ void traverse(@NotNull Consumer action);
@Nullable
Set getWords();
diff --git a/spellchecker/src/com/intellij/spellchecker/dictionary/EditableDictionary.java b/spellchecker/src/com/intellij/spellchecker/dictionary/EditableDictionary.java
index d2abc06519bc..fdccba32ce56 100644
--- a/spellchecker/src/com/intellij/spellchecker/dictionary/EditableDictionary.java
+++ b/spellchecker/src/com/intellij/spellchecker/dictionary/EditableDictionary.java
@@ -21,7 +21,6 @@ import java.util.Collection;
import java.util.Set;
public interface EditableDictionary extends Dictionary {
-
void addToDictionary(@Nullable String word);
void removeFromDictionary(@Nullable String word);
@@ -34,6 +33,4 @@ public interface EditableDictionary extends Dictionary {
@Nullable
Set getEditableWords();
-
-
}
diff --git a/spellchecker/src/com/intellij/spellchecker/dictionary/ProjectDictionary.java b/spellchecker/src/com/intellij/spellchecker/dictionary/ProjectDictionary.java
index 1202c9201531..b72c8f45928a 100644
--- a/spellchecker/src/com/intellij/spellchecker/dictionary/ProjectDictionary.java
+++ b/spellchecker/src/com/intellij/spellchecker/dictionary/ProjectDictionary.java
@@ -17,6 +17,7 @@ package com.intellij.spellchecker.dictionary;
import com.intellij.util.Consumer;
import gnu.trove.THashSet;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -25,8 +26,7 @@ import java.util.HashSet;
import java.util.Set;
public class ProjectDictionary implements EditableDictionary {
-
- private static final String DEFAULT_CURRENT_USER_NAME = "default.user";
+ @NonNls private static final String DEFAULT_CURRENT_USER_NAME = "default.user";
private static final String DEFAULT_PROJECT_DICTIONARY_NAME = "project";
private String activeName;
private Set dictionaries;
@@ -35,14 +35,17 @@ public class ProjectDictionary implements EditableDictionary {
public ProjectDictionary() {
}
- public ProjectDictionary(Set dictionaries) {
+ public ProjectDictionary(@NotNull Set dictionaries) {
this.dictionaries = dictionaries;
}
+ @Override
public boolean isEmpty() {
return false;
}
+ @NotNull
+ @Override
public String getName() {
return DEFAULT_PROJECT_DICTIONARY_NAME;
}
@@ -52,12 +55,13 @@ public class ProjectDictionary implements EditableDictionary {
}
public void setActiveName(String name) {
- this.activeName = name;
+ activeName = name;
}
+ @Override
@Nullable
- public Boolean contains(String word) {
- if (word == null || dictionaries == null) {
+ public Boolean contains(@NotNull String word) {
+ if (dictionaries == null) {
return false;
}
int errors = 0;
@@ -66,8 +70,7 @@ public class ProjectDictionary implements EditableDictionary {
if (contains == null) {
errors++;
}
- else
- if (contains) {
+ else if (contains) {
return true;
}
}
@@ -75,10 +78,12 @@ public class ProjectDictionary implements EditableDictionary {
return false;
}
+ @Override
public void addToDictionary(String word) {
getActiveDictionary().addToDictionary(word);
}
+ @Override
public void removeFromDictionary(String word) {
getActiveDictionary().removeFromDictionary(word);
}
@@ -95,7 +100,7 @@ public class ProjectDictionary implements EditableDictionary {
}
EditableDictionary result = getDictionaryByName(activeName);
if (result == null) {
- result = new UserDictionary(this.activeName);
+ result = new UserDictionary(activeName);
if (dictionaries == null) {
dictionaries = new THashSet();
}
@@ -120,15 +125,18 @@ public class ProjectDictionary implements EditableDictionary {
}
+ @Override
public void replaceAll(@Nullable Collection words) {
getActiveDictionary().replaceAll(words);
}
+ @Override
public void clear() {
getActiveDictionary().clear();
}
+ @Override
@Nullable
public Set getWords() {
if (dictionaries == null) {
@@ -141,6 +149,7 @@ public class ProjectDictionary implements EditableDictionary {
return words;
}
+ @Override
public int size(){
int result = 0;
for (Dictionary dictionary : dictionaries) {
@@ -149,7 +158,8 @@ public class ProjectDictionary implements EditableDictionary {
return result;
}
- public void traverse(final Consumer consumer) {
+ @Override
+ public void traverse(@NotNull final Consumer consumer) {
if (dictionaries == null) {
return;
}
@@ -160,12 +170,14 @@ public class ProjectDictionary implements EditableDictionary {
}
+ @Override
@Nullable
public Set getEditableWords() {
return getActiveDictionary().getWords();
}
+ @Override
public void addToDictionary(@Nullable Collection words) {
getActiveDictionary().addToDictionary(words);
}
@@ -195,6 +207,7 @@ public class ProjectDictionary implements EditableDictionary {
return result;
}
+ @NonNls
@Override
public String toString() {
return "ProjectDictionary{" + "activeName='" + activeName + '\'' + ", dictionaries=" + dictionaries + '}';
diff --git a/spellchecker/src/com/intellij/spellchecker/dictionary/UserDictionary.java b/spellchecker/src/com/intellij/spellchecker/dictionary/UserDictionary.java
index f4a1615a114a..7ee25df992cb 100644
--- a/spellchecker/src/com/intellij/spellchecker/dictionary/UserDictionary.java
+++ b/spellchecker/src/com/intellij/spellchecker/dictionary/UserDictionary.java
@@ -17,6 +17,7 @@ package com.intellij.spellchecker.dictionary;
import com.intellij.util.Consumer;
import gnu.trove.THashSet;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -24,46 +25,53 @@ import java.util.Collection;
import java.util.Set;
public class UserDictionary implements EditableDictionary {
-
private final String name;
@NotNull
- private final THashSet words = new THashSet();
+ private final Set words = new THashSet();
- public UserDictionary(String name) {
+ public UserDictionary(@NotNull String name) {
this.name = name;
}
+ @NotNull
+ @Override
public String getName() {
return name;
}
+ @Override
@Nullable
- public Boolean contains(String word) {
+ public Boolean contains(@NotNull String word) {
boolean contains = words.contains(word);
if(contains) return true;
return null;
}
+ @Override
public int size() {
return words.size();
}
+ @Override
@Nullable
public Set getWords() {
return words;
}
+ @Override
@Nullable
public Set getEditableWords() {
return words;
}
+ @Override
public void clear() {
words.clear();
}
+ @Override
public void addToDictionary(String word) {
if (word == null) {
return;
@@ -71,6 +79,7 @@ public class UserDictionary implements EditableDictionary {
words.add(word);
}
+ @Override
public void removeFromDictionary(String word) {
if (word == null) {
return;
@@ -78,11 +87,13 @@ public class UserDictionary implements EditableDictionary {
words.remove(word);
}
+ @Override
public void replaceAll(@Nullable Collection words) {
clear();
addToDictionary(words);
}
+ @Override
public void addToDictionary(@Nullable Collection words) {
if (words == null || words.isEmpty()) {
return;
@@ -92,8 +103,9 @@ public class UserDictionary implements EditableDictionary {
}
}
+ @Override
public boolean isEmpty() {
- return words.size() == 0;
+ return words.isEmpty();
}
@Override
@@ -103,11 +115,12 @@ public class UserDictionary implements EditableDictionary {
UserDictionary that = (UserDictionary)o;
- return !(name != null ? !name.equals(that.name) : that.name != null);
+ return name.equals(that.name);
}
- public void traverse(final Consumer consumer) {
+ @Override
+ public void traverse(@NotNull final Consumer consumer) {
for (String word : words) {
consumer.consume(word);
}
@@ -115,9 +128,10 @@ public class UserDictionary implements EditableDictionary {
@Override
public int hashCode() {
- return name != null ? name.hashCode() : 0;
+ return name.hashCode();
}
+ @NonNls
@Override
public String toString() {
return "UserDictionary{" + "name='" + name + '\'' + ", words.count=" + words.size() + '}';
diff --git a/xml/impl/src/com/intellij/application/options/emmet/CssEditPrefixesListPanel.java b/xml/impl/src/com/intellij/application/options/emmet/CssEditPrefixesListPanel.java
index 5cb55b2f0c43..765c00e4d051 100644
--- a/xml/impl/src/com/intellij/application/options/emmet/CssEditPrefixesListPanel.java
+++ b/xml/impl/src/com/intellij/application/options/emmet/CssEditPrefixesListPanel.java
@@ -28,6 +28,10 @@ import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static com.google.common.collect.Sets.newHashSet;
/**
* User: zolotov
@@ -66,12 +70,12 @@ public class CssEditPrefixesListPanel {
myPrefixesTableView.setEnabled(value);
}
- public void setState(List prefixInfos) {
- myPrefixesModel.setItems(prefixInfos);
+ public void setState(Set prefixInfos) {
+ myPrefixesModel.setItems(newArrayList(prefixInfos));
}
- public List getState() {
- return myPrefixesModel.getItems();
+ public Set getState() {
+ return newHashSet(myPrefixesModel.getItems());
}
public JPanel createMainComponent() {
diff --git a/xml/impl/src/com/intellij/application/options/emmet/EmmetConfigurable.java b/xml/impl/src/com/intellij/application/options/emmet/EmmetConfigurable.java
index a702df6fde61..9dbfc55456fd 100644
--- a/xml/impl/src/com/intellij/application/options/emmet/EmmetConfigurable.java
+++ b/xml/impl/src/com/intellij/application/options/emmet/EmmetConfigurable.java
@@ -137,7 +137,7 @@ public class EmmetConfigurable implements SearchableConfigurable, Disposable, Co
public void apply() throws ConfigurationException {
EmmetOptions emmetOptions = EmmetOptions.getInstance();
emmetOptions.setEmmetEnabled(myEnableEmmetJBCheckBox.isSelected());
- emmetOptions.setEnableBemFilterByDefault(myEnableBEMFilterJBCheckBox.isSelected());
+ emmetOptions.setBemFilterEnabledByDefault(myEnableBEMFilterJBCheckBox.isSelected());
emmetOptions.setEmmetExpandShortcut(getSelectedEmmetExpandShortcut());
emmetOptions.setAutoInsertCssPrefixedEnabled(myAutoInsertCssVendorJBCheckBox.isSelected());
emmetOptions.setFuzzySearchEnabled(myEnabledFuzzySearchJBCheckBox.isSelected());
diff --git a/xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java b/xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java
index dd005841293c..614e17a736a7 100644
--- a/xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java
+++ b/xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java
@@ -15,6 +15,7 @@
*/
package com.intellij.application.options.emmet;
+import com.google.common.collect.Sets;
import com.intellij.application.options.editor.WebEditorOptions;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.*;
@@ -29,10 +30,10 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
-import java.util.List;
+import java.util.Collection;
import java.util.Map;
+import java.util.Set;
-import static com.google.common.collect.Lists.newLinkedList;
import static com.google.common.collect.Maps.newHashMap;
import static com.google.common.io.Resources.getResource;
@@ -48,7 +49,7 @@ import static com.google.common.io.Resources.getResource;
)}
)
public class EmmetOptions implements PersistentStateComponent, ExportableComponent {
- private boolean myEnableBemFilterByDefault = false;
+ private boolean myBemFilterEnabledByDefault = false;
private boolean myEmmetEnabled = WebEditorOptions.getInstance().isZenCodingEnabled();
private int myEmmetExpandShortcut = WebEditorOptions.getInstance().getZenCodingExpandShortcut();
private boolean myFuzzySearchEnabled = true;
@@ -56,7 +57,7 @@ public class EmmetOptions implements PersistentStateComponent, Exp
@Nullable
private Map prefixes = null;
- public void setPrefixInfo(List prefixInfos) {
+ public void setPrefixInfo(Collection prefixInfos) {
prefixes = newHashMap();
for (CssPrefixInfo state : prefixInfos) {
prefixes.put(state.getPropertyName(), state.toIntegerValue());
@@ -67,8 +68,8 @@ public class EmmetOptions implements PersistentStateComponent, Exp
return CssPrefixInfo.fromIntegerValue(propertyName, getPrefixes().get(propertyName));
}
- public List getAllPrefixInfo() {
- List result = newLinkedList();
+ public Set getAllPrefixInfo() {
+ Set result = Sets.newHashSetWithExpectedSize(getPrefixes().size());
for (Map.Entry entry : getPrefixes().entrySet()) {
result.add(CssPrefixInfo.fromIntegerValue(entry.getKey(), entry.getValue()));
}
@@ -76,11 +77,11 @@ public class EmmetOptions implements PersistentStateComponent, Exp
}
public boolean isBemFilterEnabledByDefault() {
- return myEnableBemFilterByDefault;
+ return myBemFilterEnabledByDefault;
}
- public void setEnableBemFilterByDefault(boolean enableBemFilterByDefault) {
- myEnableBemFilterByDefault = enableBemFilterByDefault;
+ public void setBemFilterEnabledByDefault(boolean enableBemFilterByDefault) {
+ myBemFilterEnabledByDefault = enableBemFilterByDefault;
}
public void setEmmetExpandShortcut(int emmetExpandShortcut) {
@@ -141,7 +142,6 @@ public class EmmetOptions implements PersistentStateComponent, Exp
return ServiceManager.getService(EmmetOptions.class);
}
- @SuppressWarnings("UnusedDeclaration")
@NotNull
public Map getPrefixes() {
if (prefixes == null) {
@@ -155,7 +155,7 @@ public class EmmetOptions implements PersistentStateComponent, Exp
this.prefixes = prefixes;
}
- public static Map loadDefaultPrefixes() {
+ public Map loadDefaultPrefixes() {
Map result = newHashMap();
try {
Document document = JDOMUtil.loadDocument(getResource(EmmetOptions.class, "emmet_default_options.xml"));