summaryrefslogtreecommitdiff
path: root/java/java-impl/src/com
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2013-06-21 16:58:30 -0700
committerTor Norbye <tnorbye@google.com>2013-06-21 16:58:30 -0700
commitc6218e46d5d2017e987ecdbd99b318a95c42abc0 (patch)
tree85106b3c757a794fb274159cebe07c8d979740a5 /java/java-impl/src/com
parent0e154c74931b6ff5ad6e0ec512b32e30df3cb068 (diff)
downloadidea-c6218e46d5d2017e987ecdbd99b318a95c42abc0.tar.gz
Snapshot d8891a7de15cebb78b6ce5711e50e531b42c0baf from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: Ida9d1b0a2341112b9ebcf67bf560c8f62f0afdc6
Diffstat (limited to 'java/java-impl/src/com')
-rw-r--r--java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.java31
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/daemon/JavaAwareInspectionProfileCoverter.java7
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java21
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFix.java1
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java1
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java2
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightSuppressedWarningsHandler.java14
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/intention/impl/ConcatenationToMessageFormatAction.java46
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/template/macro/MacroUtil.java6
-rw-r--r--java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java51
-rw-r--r--java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java13
-rw-r--r--java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java3
-rw-r--r--java/java-impl/src/com/intellij/codeInspection/ex/GlobalJavaInspectionContextImpl.java25
-rw-r--r--java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java7
-rw-r--r--java/java-impl/src/com/intellij/psi/impl/PackagePrefixElementFinder.java6
-rw-r--r--java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java31
-rw-r--r--java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParamListOwnerComment.java64
-rw-r--r--java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java67
-rw-r--r--java/java-impl/src/com/intellij/refactoring/copy/CopyClassesHandler.java11
-rw-r--r--java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java5
-rw-r--r--java/java-impl/src/com/intellij/refactoring/inline/InlineParameterHandler.java2
-rw-r--r--java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerImpl.java6
-rw-r--r--java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java15
-rw-r--r--java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperHandler.java9
-rw-r--r--java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperOrMembersHandler.java6
-rw-r--r--java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java2
26 files changed, 263 insertions, 189 deletions
diff --git a/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.java b/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.java
index aebfb44da1ca..44ccf4985b95 100644
--- a/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.java
+++ b/java/java-impl/src/com/intellij/application/options/CodeStyleGenerationConfigurable.java
@@ -18,10 +18,8 @@ package com.intellij.application.options;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.options.Configurable;
-import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
-import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ToolbarDecorator;
@@ -232,18 +230,18 @@ public class CodeStyleGenerationConfigurable implements Configurable {
reset(mySettings);
}
- public void apply(CodeStyleSettings settings) throws ConfigurationException {
+ public void apply(CodeStyleSettings settings) {
settings.PREFER_LONGER_NAMES = myCbPreferLongerNames.isSelected();
- settings.FIELD_NAME_PREFIX = setPrefixSuffix(myFieldPrefixField.getText(), true);
- settings.STATIC_FIELD_NAME_PREFIX = setPrefixSuffix(myStaticFieldPrefixField.getText(), true);
- settings.PARAMETER_NAME_PREFIX = setPrefixSuffix(myParameterPrefixField.getText(), true);
- settings.LOCAL_VARIABLE_NAME_PREFIX = setPrefixSuffix(myLocalVariablePrefixField.getText(), true);
+ settings.FIELD_NAME_PREFIX = myFieldPrefixField.getText().trim();
+ settings.STATIC_FIELD_NAME_PREFIX = myStaticFieldPrefixField.getText().trim();
+ settings.PARAMETER_NAME_PREFIX = myParameterPrefixField.getText().trim();
+ settings.LOCAL_VARIABLE_NAME_PREFIX = myLocalVariablePrefixField.getText().trim();
- settings.FIELD_NAME_SUFFIX = setPrefixSuffix(myFieldSuffixField.getText(), false);
- settings.STATIC_FIELD_NAME_SUFFIX = setPrefixSuffix(myStaticFieldSuffixField.getText(), false);
- settings.PARAMETER_NAME_SUFFIX = setPrefixSuffix(myParameterSuffixField.getText(), false);
- settings.LOCAL_VARIABLE_NAME_SUFFIX = setPrefixSuffix(myLocalVariableSuffixField.getText(), false);
+ settings.FIELD_NAME_SUFFIX = myFieldSuffixField.getText().trim();
+ settings.STATIC_FIELD_NAME_SUFFIX = myStaticFieldSuffixField.getText().trim();
+ settings.PARAMETER_NAME_SUFFIX = myParameterSuffixField.getText().trim();
+ settings.LOCAL_VARIABLE_NAME_SUFFIX = myLocalVariableSuffixField.getText().trim();
settings.LINE_COMMENT_AT_FIRST_COLUMN = myCbLineCommentAtFirstColumn.isSelected();
settings.BLOCK_COMMENT_AT_FIRST_COLUMN = myCbBlockCommentAtFirstColumn.isSelected();
@@ -262,16 +260,7 @@ public class CodeStyleGenerationConfigurable implements Configurable {
}
}
- private static String setPrefixSuffix(String text, boolean prefix) throws ConfigurationException {
- text = text.trim();
- if (text.isEmpty()) return text;
- if (!StringUtil.isJavaIdentifier(text)) {
- throw new ConfigurationException("Not a valid java identifier part in " + (prefix ? "prefix" : "suffix") + " \'" + text + "\'");
- }
- return text;
- }
-
- public void apply() throws ConfigurationException {
+ public void apply() {
apply(mySettings);
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/JavaAwareInspectionProfileCoverter.java b/java/java-impl/src/com/intellij/codeInsight/daemon/JavaAwareInspectionProfileCoverter.java
index e411fc11add3..e79fdbe14ed9 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/JavaAwareInspectionProfileCoverter.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/JavaAwareInspectionProfileCoverter.java
@@ -20,8 +20,9 @@
*/
package com.intellij.codeInsight.daemon;
+import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.ModifiableModel;
-import com.intellij.codeInspection.ex.InspectionToolWrapper;
+import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import org.jdom.Element;
@@ -52,8 +53,8 @@ public class JavaAwareInspectionProfileCoverter extends InspectionProfileConvert
super.fillErrorLevels(profile);
//javadoc attributes
- final InspectionToolWrapper toolWrapper = (InspectionToolWrapper)profile.getInspectionTool(JavaDocLocalInspection.SHORT_NAME, null);
- JavaDocLocalInspection inspection = (JavaDocLocalInspection)toolWrapper.getTool();
+ final InspectionProfileEntry inspectionTool = profile.getInspectionTool(JavaDocLocalInspection.SHORT_NAME, null);
+ JavaDocLocalInspection inspection = (JavaDocLocalInspection)((LocalInspectionToolWrapper)inspectionTool).getTool();
inspection.myAdditionalJavadocTags = myAdditionalJavadocTags;
}
} \ No newline at end of file
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
index 5bcc31079aab..4f6f0996ad29 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
@@ -94,32 +94,19 @@ public class HighlightClassUtil {
static HighlightInfo checkClassWithAbstractMethods(PsiClass aClass, PsiElement implementsFixElement, TextRange range) {
PsiMethod abstractMethod = ClassUtil.getAnyAbstractMethod(aClass);
- if (abstractMethod == null) {
+ if (abstractMethod == null || abstractMethod.getContainingClass() == null) {
return null;
}
-
- final PsiClass superClass = abstractMethod.getContainingClass();
- if (superClass == null) {
- return null;
- }
-
String baseClassName = HighlightUtil.formatClass(aClass, false);
String methodName = JavaHighlightUtil.formatMethod(abstractMethod);
String message = JavaErrorMessages.message(aClass instanceof PsiEnumConstantInitializer || implementsFixElement instanceof PsiEnumConstant ? "enum.constant.should.implement.method" : "class.must.be.abstract",
baseClassName,
methodName,
- HighlightUtil.formatClass(superClass, false));
+ HighlightUtil.formatClass(abstractMethod.getContainingClass(), false));
HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(message).create();
- final PsiMethod anyMethodToImplement = ClassUtil.getAnyMethodToImplement(aClass);
- if (anyMethodToImplement != null) {
- if (!anyMethodToImplement.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) ||
- JavaPsiFacade.getInstance(aClass.getProject()).arePackagesTheSame(aClass, superClass)) {
- QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createImplementMethodsFix(implementsFixElement));
- } else {
- QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createModifierListFix(anyMethodToImplement, PsiModifier.PROTECTED, true, true));
- QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createModifierListFix(anyMethodToImplement, PsiModifier.PUBLIC, true, true));
- }
+ if (ClassUtil.getAnyMethodToImplement(aClass) != null) {
+ QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createImplementMethodsFix(implementsFixElement));
}
if (!(aClass instanceof PsiAnonymousClass)
&& HighlightUtil.getIncompatibleModifier(PsiModifier.ABSTRACT, aClass.getModifierList()) == null) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFix.java
index 2e23f7ef65e4..a2bebf63ac18 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFix.java
@@ -107,7 +107,6 @@ public class ImportClassFix extends ImportClassFixBase<PsiJavaCodeReferenceEleme
return super.getRequiredMemberName(reference);
}
- @NotNull
@Override
protected List<PsiClass> filterByContext(@NotNull List<PsiClass> candidates, @NotNull PsiJavaCodeReferenceElement ref) {
PsiElement typeElement = ref.getParent();
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java
index bfb7c45bf3c8..e34ad1820c89 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java
@@ -184,7 +184,6 @@ public abstract class ImportClassFixBase<T extends PsiElement, R extends PsiRefe
return null;
}
- @NotNull
protected List<PsiClass> filterByContext(@NotNull List<PsiClass> candidates, @NotNull T ref) {
return candidates;
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
index 4f45ac344e73..68c3684ff662 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
@@ -612,7 +612,7 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
finally {
PsiFile psiFile = psiClass.getContainingFile();
- Editor editor = fileEditorManager.openTextEditor(new OpenFileDescriptor(psiFile.getProject(), psiFile.getVirtualFile()), true);
+ Editor editor = fileEditorManager.openTextEditor(new OpenFileDescriptor(psiFile.getProject(), psiFile.getVirtualFile()), false);
if (editor != null && !results.isEmpty()) {
results.get(0).positionCaret(editor, true);
editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
diff --git a/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightSuppressedWarningsHandler.java b/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightSuppressedWarningsHandler.java
index 85835a8fcff1..2e92545483f9 100644
--- a/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightSuppressedWarningsHandler.java
+++ b/java/java-impl/src/com/intellij/codeInsight/highlighting/HighlightSuppressedWarningsHandler.java
@@ -25,7 +25,11 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.daemon.impl.LocalInspectionsPass;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.InspectionProfile;
-import com.intellij.codeInspection.ex.*;
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
+import com.intellij.codeInspection.ex.InspectionManagerEx;
+import com.intellij.codeInspection.ex.InspectionProfileImpl;
+import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.reference.RefManagerImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
@@ -118,20 +122,20 @@ public class HighlightSuppressedWarningsHandler extends HighlightUsagesHandlerBa
if (!(value instanceof String)) {
continue;
}
- InspectionToolWrapper toolById = ((InspectionProfileImpl)inspectionProfile).getToolById((String)value, target);
+ final InspectionProfileEntry toolById = ((InspectionProfileImpl)inspectionProfile).getToolById((String)value, target);
if (!(toolById instanceof LocalInspectionToolWrapper)) {
continue;
}
- final LocalInspectionToolWrapper toolWrapper = ((LocalInspectionToolWrapper)toolById).createCopy();
+ final LocalInspectionToolWrapper tool = ((LocalInspectionToolWrapper)toolById).createCopy();
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false);
- toolWrapper.initialize(context);
+ tool.initialize(context);
((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted();
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
Runnable inspect = new Runnable() {
@Override
public void run() {
- pass.doInspectInBatch(managerEx, Collections.<LocalInspectionToolWrapper>singletonList(toolWrapper));
+ pass.doInspectInBatch(managerEx, Collections.<LocalInspectionToolWrapper>singletonList(tool));
}
};
if (indicator == null) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConcatenationToMessageFormatAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConcatenationToMessageFormatAction.java
index 9bc47e30f1fa..544440fa3e21 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConcatenationToMessageFormatAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ConcatenationToMessageFormatAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -25,6 +25,7 @@ import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
+import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiConcatenationUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
@@ -59,7 +60,7 @@ public class ConcatenationToMessageFormatAction implements IntentionAction {
if (concatenation == null) return;
StringBuilder formatString = new StringBuilder();
List<PsiExpression> args = new ArrayList<PsiExpression>();
- PsiConcatenationUtil.buildFormatString(concatenation, formatString, args, false);
+ buildMessageFormatString(concatenation, formatString, args);
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
PsiMethodCallExpression call = (PsiMethodCallExpression)
@@ -86,6 +87,47 @@ public class ConcatenationToMessageFormatAction implements IntentionAction {
concatenation.replace(call);
}
+ public static void buildMessageFormatString(PsiExpression expression,
+ StringBuilder formatString,
+ List<PsiExpression> args)
+ throws IncorrectOperationException {
+ PsiConcatenationUtil.buildFormatString(expression, formatString, args, false);
+
+ }
+
+ private static void appendArgument(List<PsiExpression> args, PsiExpression argument, StringBuilder formatString) throws IncorrectOperationException {
+ formatString.append("{").append(args.size()).append("}");
+ args.add(getBoxedArgument(argument));
+ }
+
+ private static PsiExpression getBoxedArgument(PsiExpression arg) throws IncorrectOperationException {
+ arg = PsiUtil.deparenthesizeExpression(arg);
+ assert arg != null;
+ if (PsiUtil.isLanguageLevel5OrHigher(arg)) {
+ return arg;
+ }
+ final PsiType type = arg.getType();
+ if (!(type instanceof PsiPrimitiveType) || type.equals(PsiType.NULL)) {
+ return arg;
+ }
+ final PsiPrimitiveType primitiveType = (PsiPrimitiveType)type;
+ final String boxedQName = primitiveType.getBoxedTypeName();
+ if (boxedQName == null) {
+ return arg;
+ }
+ final GlobalSearchScope resolveScope = arg.getResolveScope();
+ final PsiElementFactory factory = JavaPsiFacade.getElementFactory(arg.getProject());
+ final PsiJavaCodeReferenceElement ref = factory.createReferenceElementByFQClassName(boxedQName, resolveScope);
+ final PsiNewExpression newExpr = (PsiNewExpression)factory.createExpressionFromText("new A(b)", null);
+ final PsiElement classRef = newExpr.getClassReference();
+ assert classRef != null;
+ classRef.replace(ref);
+ final PsiExpressionList argumentList = newExpr.getArgumentList();
+ assert argumentList != null;
+ argumentList.getExpressions()[0].replace(arg);
+ return newExpr;
+ }
+
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
if (PsiUtil.getLanguageLevel(file).compareTo(LanguageLevel.JDK_1_4) < 0) return false;
diff --git a/java/java-impl/src/com/intellij/codeInsight/template/macro/MacroUtil.java b/java/java-impl/src/com/intellij/codeInsight/template/macro/MacroUtil.java
index 6010a7a4b41f..059c0471eebb 100644
--- a/java/java-impl/src/com/intellij/codeInsight/template/macro/MacroUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/template/macro/MacroUtil.java
@@ -27,13 +27,11 @@ import com.intellij.psi.scope.util.PsiScopesUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
public class MacroUtil {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.template.macro.MacroUtil");
@@ -160,15 +158,11 @@ public class MacroUtil {
return new PsiVariable[0];
}
- final Set<String> usedNames = ContainerUtil.newHashSet();
final List<PsiVariable> list = new ArrayList<PsiVariable>();
VariablesProcessor varproc = new VariablesProcessor(prefix, true, list) {
@Override
public boolean execute(@NotNull PsiElement pe, ResolveState state) {
if (pe instanceof PsiVariable) {
- if (!usedNames.add(((PsiVariable)pe).getName())) {
- return false;
- }
//exclude variables that are initialized in 'place'
final PsiExpression initializer = ((PsiVariable)pe).getInitializer();
if (initializer != null && PsiTreeUtil.isAncestor(initializer, place, false)) return true;
diff --git a/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java b/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java
index b2ce257425f5..f65d58051522 100644
--- a/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/RedundantSuppressInspection.java
@@ -141,7 +141,7 @@ public class RedundantSuppressInspection extends GlobalInspectionTool{
private void checkElement(final PsiElement owner) {
String idsString = SuppressManager.getInstance().getSuppressedInspectionIdsIn(owner);
- if (idsString != null && !idsString.isEmpty()) {
+ if (idsString != null && idsString.length() != 0) {
List<String> ids = StringUtil.split(idsString, ",");
if (IGNORE_ALL && (ids.contains(SuppressionUtil.ALL) || ids.contains(SuppressionUtil.ALL.toLowerCase()))) return;
Collection<String> suppressed = suppressedScopes.get(owner);
@@ -162,29 +162,27 @@ public class RedundantSuppressInspection extends GlobalInspectionTool{
if (suppressedScopes.values().isEmpty()) return null;
// have to visit all file from scratch since inspections can be written in any perversive way including checkFile() overriding
- Collection<InspectionToolWrapper> suppressedTools = new THashSet<InspectionToolWrapper>();
- InspectionToolWrapper[] toolWrappers = getInspectionTools(psiElement, manager);
+ Collection<InspectionTool> suppressedTools = new THashSet<InspectionTool>();
+ InspectionTool[] tools = getInspectionTools(psiElement, manager);
for (Collection<String> ids : suppressedScopes.values()) {
for (Iterator<String> iterator = ids.iterator(); iterator.hasNext(); ) {
final String shortName = iterator.next().trim();
- for (InspectionToolWrapper toolWrapper : toolWrappers) {
- if (toolWrapper instanceof LocalInspectionToolWrapper && ((LocalInspectionToolWrapper)toolWrapper).getTool().getID().equals(shortName)) {
- if (((LocalInspectionToolWrapper)toolWrapper).isUnfair()) {
+ for (InspectionTool tool : tools) {
+ if (tool instanceof LocalInspectionToolWrapper && ((LocalInspectionToolWrapper)tool).getTool().getID().equals(shortName)) {
+ if (!((LocalInspectionToolWrapper)tool).isUnfair()) {
+ suppressedTools.add(tool);
+ } else {
iterator.remove();
break;
}
- else {
- suppressedTools.add(toolWrapper);
- }
}
- else if (toolWrapper.getShortName().equals(shortName)) {
+ else if (tool.getShortName().equals(shortName)) {
//ignore global unused as it won't be checked anyway
- if (toolWrapper instanceof LocalInspectionToolWrapper || toolWrapper instanceof GlobalInspectionToolWrapper) {
- suppressedTools.add(toolWrapper);
- }
- else {
+ if (!(tool instanceof LocalInspectionToolWrapper) && !(tool instanceof GlobalInspectionToolWrapper)) {
iterator.remove();
break;
+ } else {
+ suppressedTools.add(tool);
}
}
}
@@ -192,26 +190,26 @@ public class RedundantSuppressInspection extends GlobalInspectionTool{
}
final AnalysisScope scope = new AnalysisScope(psiElement.getContainingFile());
- final InspectionManagerEx inspectionManagerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
+ final InspectionManagerEx inspectionManagerEx = ((InspectionManagerEx)InspectionManager.getInstance(project));
GlobalInspectionContextImpl globalContext = inspectionManagerEx.createNewGlobalContext(false);
globalContext.setCurrentScope(scope);
- final RefManagerImpl refManager = (RefManagerImpl)globalContext.getRefManager();
+ final RefManagerImpl refManager = ((RefManagerImpl)globalContext.getRefManager());
refManager.inspectionReadActionStarted();
final List<ProblemDescriptor> result;
try {
result = new ArrayList<ProblemDescriptor>();
- for (InspectionToolWrapper toolWrapper : suppressedTools) {
- String toolId = toolWrapper instanceof LocalInspectionToolWrapper ? ((LocalInspectionToolWrapper)toolWrapper).getTool().getID() : toolWrapper.getShortName();
- toolWrapper.initialize(globalContext);
+ for (InspectionTool tool : suppressedTools) {
+ String toolId = tool instanceof LocalInspectionToolWrapper ? ((LocalInspectionToolWrapper)tool).getTool().getID() : tool.getShortName();
+ tool.initialize(globalContext);
Collection<CommonProblemDescriptor> descriptors;
- if (toolWrapper instanceof LocalInspectionToolWrapper) {
- LocalInspectionToolWrapper local = (LocalInspectionToolWrapper)toolWrapper;
+ if (tool instanceof LocalInspectionToolWrapper) {
+ LocalInspectionToolWrapper local = (LocalInspectionToolWrapper)tool;
if (local.isUnfair()) continue; //cant't work with passes other than LocalInspectionPass
local.processFile(psiElement.getContainingFile(), false, manager);
descriptors = local.getProblemDescriptors();
}
- else if (toolWrapper instanceof GlobalInspectionToolWrapper) {
- GlobalInspectionToolWrapper global = (GlobalInspectionToolWrapper)toolWrapper;
+ else if (tool instanceof GlobalInspectionToolWrapper) {
+ GlobalInspectionToolWrapper global = (GlobalInspectionToolWrapper)tool;
if (global.getTool().isGraphNeeded()) {
refManager.findAllDeclarations();
}
@@ -285,12 +283,13 @@ public class RedundantSuppressInspection extends GlobalInspectionTool{
return result.toArray(new ProblemDescriptor[result.size()]);
}
- protected InspectionToolWrapper[] getInspectionTools(PsiElement psiElement, InspectionManager manager) {
- ModifiableModel model = InspectionProjectProfileManager.getInstance(manager.getProject()).getInspectionProfile().getModifiableModel();
+ protected InspectionTool[] getInspectionTools(PsiElement psiElement, InspectionManager manager) {
+ final ModifiableModel
+ model = InspectionProjectProfileManager.getInstance(manager.getProject()).getInspectionProfile().getModifiableModel();
InspectionProfileWrapper profile = new InspectionProfileWrapper((InspectionProfile)model);
profile.init(manager.getProject());
- return (InspectionToolWrapper[])profile.getInspectionTools(psiElement);
+ return profile.getInspectionTools(psiElement);
}
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java
index c22571a65287..348d3dfc5fa5 100644
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspection.java
@@ -46,7 +46,6 @@ public class DataFlowInspection extends DataFlowInspectionBase {
}
private class OptionsPanel extends JPanel {
- private final JCheckBox myIgnoreAssertions;
private final JCheckBox mySuggestNullables;
private final JCheckBox myDontReportTrueAsserts;
@@ -78,15 +77,6 @@ public class DataFlowInspection extends DataFlowInspectionBase {
DONT_REPORT_TRUE_ASSERT_STATEMENTS = myDontReportTrueAsserts.isSelected();
}
});
-
- myIgnoreAssertions = new JCheckBox("Ignore assert statements");
- myIgnoreAssertions.setSelected(IGNORE_ASSERT_STATEMENTS);
- myIgnoreAssertions.getModel().addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- IGNORE_ASSERT_STATEMENTS = myIgnoreAssertions.isSelected();
- }
- });
gc.insets = new Insets(0, 0, 0, 0);
gc.gridy = 0;
@@ -131,9 +121,6 @@ public class DataFlowInspection extends DataFlowInspectionBase {
gc.insets.left = 0;
gc.gridy++;
add(myDontReportTrueAsserts, gc);
-
- gc.gridy++;
- add(myIgnoreAssertions, gc);
}
}
diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java
index 633a6089d6e2..fa341a05bd20 100644
--- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java
@@ -1100,9 +1100,8 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool {
super.updateContent();
}
- @NotNull
@Override
- public InspectionNode createToolNode(@NotNull final InspectionRVContentProvider provider, @NotNull final InspectionTreeNode parentNode, final boolean showStructure) {
+ public InspectionNode createToolNode(@NotNull final InspectionRVContentProvider provider, final InspectionTreeNode parentNode, final boolean showStructure) {
final InspectionNode toolNode = super.createToolNode(provider, parentNode, showStructure);
final EntryPointsNode entryPointsNode = new EntryPointsNode(this);
provider.appendToolNodeContent(entryPointsNode, toolNode, showStructure);
diff --git a/java/java-impl/src/com/intellij/codeInspection/ex/GlobalJavaInspectionContextImpl.java b/java/java-impl/src/com/intellij/codeInspection/ex/GlobalJavaInspectionContextImpl.java
index f3bdaf20aeea..86ff16ca9553 100644
--- a/java/java-impl/src/com/intellij/codeInspection/ex/GlobalJavaInspectionContextImpl.java
+++ b/java/java-impl/src/com/intellij/codeInspection/ex/GlobalJavaInspectionContextImpl.java
@@ -23,6 +23,7 @@ package com.intellij.codeInspection.ex;
import com.intellij.CommonBundle;
import com.intellij.analysis.AnalysisScope;
import com.intellij.codeInspection.*;
+import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
import com.intellij.codeInspection.reference.*;
import com.intellij.lang.StdLanguages;
import com.intellij.openapi.application.ApplicationManager;
@@ -412,26 +413,32 @@ public class GlobalJavaInspectionContextImpl extends GlobalJavaInspectionContext
}
@Override
- public void performPreRunActivities(@NotNull final List<Tools> globalTools,
- @NotNull final List<Tools> localTools,
- @NotNull final GlobalInspectionContext context) {
+ public void performPreRunActivities(final List<Tools> globalTools, final List<Tools> localTools,
+ final GlobalInspectionContext context) {
getEntryPointsManager(context.getRefManager()).resolveEntryPoints(context.getRefManager());
+ for (int i = 0; i < globalTools.size(); i++) {
+ InspectionProfileEntry tool = globalTools.get(i).getTool();
+ if (UnusedDeclarationInspection.SHORT_NAME.equals(tool.getShortName())) {
+ Collections.swap(globalTools, i, 0);
+ break;
+ }
+ }
}
@Override
- public void performPostRunActivities(@NotNull List<InspectionProfileEntry> needRepeatSearchRequest, @NotNull final GlobalInspectionContext context) {
+ public void performPostRunActivities(List<InspectionProfileEntry> needRepeatSearchRequest, final GlobalInspectionContext context) {
JobDescriptor progress = context.getStdJobDescriptors().FIND_EXTERNAL_USAGES;
progress.setTotalAmount(getRequestCount());
do {
processSearchRequests(context);
- InspectionToolWrapper[] requestors = needRepeatSearchRequest.toArray(new InspectionToolWrapper[needRepeatSearchRequest.size()]);
- for (InspectionToolWrapper wrapper : requestors) {
- InspectionProfileEntry requestor = wrapper.getTool();
- if (requestor instanceof InspectionTool && !((InspectionTool)requestor).queryExternalUsagesRequests(InspectionManager.getInstance(context.getProject()))) {
- needRepeatSearchRequest.remove(wrapper);
+ InspectionProfileEntry[] requestors = needRepeatSearchRequest.toArray(new InspectionProfileEntry[needRepeatSearchRequest.size()]);
+ for (InspectionProfileEntry requestor : requestors) {
+ if (requestor instanceof InspectionTool &&
+ !((InspectionTool)requestor).queryExternalUsagesRequests(InspectionManager.getInstance(context.getProject()))) {
+ needRepeatSearchRequest.remove(requestor);
}
}
int oldSearchRequestCount = progress.getTotalAmount();
diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
index 1376f44c07ca..e81e167d3c45 100644
--- a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
+++ b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java
@@ -296,12 +296,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
}
else if (myRole1 == ChildRole.FIELD) {
int lines = Math.max(getLinesAroundField(), getLinesAroundMethod()) + 1;
- // IJ has been keeping initialization block which starts at the same line as a field for a while.
- // However, it's not convenient for a situation when particular code is created via PSI - it's easier to not bothering
- // with whitespace elements when inserting, say, new initialization blocks. That's why we don't enforce new line
- // only during explicit reformatting ('Reformat' action).
- int minLineFeeds = FormatterUtil.isFormatterCalledExplicitly() ? 0 : 1;
- myResult = Spacing.createSpacing(0, mySettings.SPACE_BEFORE_CLASS_LBRACE ? 1 : 0, 1, true, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE,
+ myResult = Spacing.createSpacing(0, mySettings.SPACE_BEFORE_CLASS_LBRACE ? 1 : 0, 0, true, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE,
lines);
}
else if (myRole1 == ChildRole.CLASS) {
diff --git a/java/java-impl/src/com/intellij/psi/impl/PackagePrefixElementFinder.java b/java/java-impl/src/com/intellij/psi/impl/PackagePrefixElementFinder.java
index 0f2df2db49ab..7f58413a051f 100644
--- a/java/java-impl/src/com/intellij/psi/impl/PackagePrefixElementFinder.java
+++ b/java/java-impl/src/com/intellij/psi/impl/PackagePrefixElementFinder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2011 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.
@@ -68,7 +68,7 @@ public class PackagePrefixElementFinder extends PsiElementFinder implements Dumb
final String qualifiedName = psiPackage.getQualifiedName();
for (final String prefix : myPackagePrefixIndex.getAllPackagePrefixes(scope)) {
- if (StringUtil.isEmpty(qualifiedName) || StringUtil.startsWithConcatenation(prefix, qualifiedName, ".")) {
+ if (StringUtil.isEmpty(qualifiedName) || StringUtil.startsWithConcatenationOf(prefix, qualifiedName, ".")) {
final int i = prefix.indexOf('.', qualifiedName.length() + 1);
String childName = i >= 0 ? prefix.substring(0, i) : prefix;
if (!packagesMap.containsKey(childName)) {
@@ -83,7 +83,7 @@ public class PackagePrefixElementFinder extends PsiElementFinder implements Dumb
public boolean packagePrefixExists(String packageQName) {
for (final String prefix : myPackagePrefixIndex.getAllPackagePrefixes(null)) {
- if (StringUtil.startsWithConcatenation(prefix, packageQName, ".") || prefix.equals(packageQName)) {
+ if (StringUtil.startsWithConcatenationOf(prefix, packageQName, ".") || prefix.equals(packageQName)) {
return true;
}
}
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java
index 67661e7c387b..6fd664b1add7 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java
@@ -25,19 +25,19 @@ import java.util.ArrayList;
* @author Dmitry Skavish
*/
public class JDMethodComment extends JDParamListOwnerComment {
-
- private static final @NonNls String THROWS_TAG = "@throws ";
- private static final @NonNls String EXCEPTION_TAG = "@exception ";
+ public JDMethodComment(CommentFormatter formatter) {
+ super(formatter);
+ }
private String returnTag;
private ArrayList<NameDesc> throwsList;
- public JDMethodComment(CommentFormatter formatter) {
- super(formatter);
- }
+ private static final @NonNls String THROWS_TAG = "@throws ";
+ private static final @NonNls String EXCEPTION_TAG = "@exception ";
@Override
protected void generateSpecial(String prefix, @NonNls StringBuffer sb) {
+
super.generateSpecial(prefix, sb);
if (returnTag != null) {
@@ -56,16 +56,27 @@ public class JDMethodComment extends JDParamListOwnerComment {
String tag = myFormatter.getSettings().JD_USE_THROWS_NOT_EXCEPTION ? THROWS_TAG : EXCEPTION_TAG;
generateList(prefix, sb, throwsList, tag,
myFormatter.getSettings().JD_ALIGN_EXCEPTION_COMMENTS,
+ myFormatter.getSettings().JD_MIN_EXCEPTION_NAME_LENGTH,
+ myFormatter.getSettings().JD_MAX_EXCEPTION_NAME_LENGTH,
myFormatter.getSettings().JD_KEEP_EMPTY_EXCEPTION,
myFormatter.getSettings().JD_PARAM_DESCRIPTION_ON_NEW_LINE
);
}
}
+ public String getReturnTag() {
+ return returnTag;
+ }
+
public void setReturnTag(String returnTag) {
this.returnTag = returnTag;
}
+ public void removeThrow(NameDesc nd) {
+ if (throwsList == null) return;
+ throwsList.remove(nd);
+ }
+
public ArrayList<NameDesc> getThrowsList() {
return throwsList;
}
@@ -77,4 +88,12 @@ public class JDMethodComment extends JDParamListOwnerComment {
throwsList.add(new NameDesc(className, description));
}
+ public NameDesc getThrow(String name) {
+ return getNameDesc(name, throwsList);
+ }
+
+ public void setThrowsList(ArrayList<NameDesc> throwsList) {
+ this.throwsList = throwsList;
+ }
+
}
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParamListOwnerComment.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParamListOwnerComment.java
index a063cf2935eb..64af28761b09 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParamListOwnerComment.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParamListOwnerComment.java
@@ -22,7 +22,6 @@ package com.intellij.psi.impl.source.codeStyle.javadoc;
import com.intellij.formatting.IndentInfo;
import com.intellij.ide.highlighter.JavaFileType;
-import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import org.jetbrains.annotations.NonNls;
@@ -43,6 +42,8 @@ public class JDParamListOwnerComment extends JDComment{
int before = sb.length();
generateList(prefix, sb, parmsList, PARAM_TAG,
myFormatter.getSettings().JD_ALIGN_PARAM_COMMENTS,
+ myFormatter.getSettings().JD_MIN_PARM_NAME_LENGTH,
+ myFormatter.getSettings().JD_MAX_PARM_NAME_LENGTH,
myFormatter.getSettings().JD_KEEP_EMPTY_PARAMETER,
myFormatter.getSettings().JD_PARAM_DESCRIPTION_ON_NEW_LINE
);
@@ -59,6 +60,15 @@ public class JDParamListOwnerComment extends JDComment{
return getNameDesc(name, parmsList);
}
+ public void removeParameter(NameDesc nd) {
+ if (parmsList == null) return;
+ parmsList.remove(nd);
+ }
+
+ public ArrayList<NameDesc> getParmsList() {
+ return parmsList;
+ }
+
public void addParameter(String name, String description) {
if (parmsList == null) {
parmsList = new ArrayList<NameDesc>();
@@ -66,6 +76,10 @@ public class JDParamListOwnerComment extends JDComment{
parmsList.add(new NameDesc(name, description));
}
+ public void setParmsList(ArrayList<NameDesc> parmsList) {
+ this.parmsList = parmsList;
+ }
+
static NameDesc getNameDesc(String name, ArrayList<NameDesc> list) {
if (list == null) return null;
for (Object aList : list) {
@@ -79,37 +93,34 @@ public class JDParamListOwnerComment extends JDComment{
* Generates parameters or exceptions
*
*/
- protected void generateList(String prefix,
- StringBuffer sb,
- ArrayList<NameDesc> list,
- String tag,
- boolean align_comments,
- boolean generate_empty_tags,
- boolean wrapDescription)
+ protected void generateList(String prefix, StringBuffer sb, ArrayList<NameDesc> list, String tag, boolean align_comments,
+ int min_name_length, int max_name_length, boolean generate_empty_tags, boolean wrapDescription)
{
CodeStyleSettings settings = myFormatter.getSettings();
CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(JavaFileType.INSTANCE);
String continuationIndent = new IndentInfo(0, indentOptions.CONTINUATION_INDENT_SIZE, 0).generateNewWhiteSpace(indentOptions);
-
int max = 0;
-
- if (align_comments && !wrapDescription) {
- for (NameDesc nd: list) {
- int currentLength = nd.name.length();
+ if (align_comments && ! wrapDescription) {
+ for (Object aList : list) {
+ NameDesc nd = (NameDesc)aList;
+ int l = nd.name.length();
if (isNull(nd.desc) && !generate_empty_tags) continue;
- //finding longest parameter length
- if (currentLength > max) {
- max = currentLength;
- }
+ if (l > max && l <= max_name_length) max = l;
}
}
+ max = Math.max(max, min_name_length);
+
+ // create filler
StringBuffer fill = new StringBuffer(prefix.length() + tag.length() + max + 1);
fill.append(prefix);
- StringUtil.repeatSymbol(fill, ' ', max + 1 + tag.length());
+ int k = max + 1 + tag.length();
+ for (int i = 0; i < k; i++) fill.append(' ');
String wrapParametersPrefix = prefix + continuationIndent;
- for (NameDesc nd : list) {
+
+ for (Object aList1 : list) {
+ NameDesc nd = (NameDesc)aList1;
if (isNull(nd.desc) && !generate_empty_tags) continue;
if (wrapDescription && !isNull(nd.desc)) {
sb.append(prefix).append(tag).append(nd.name).append("\n");
@@ -119,9 +130,18 @@ public class JDParamListOwnerComment extends JDComment{
sb.append(prefix);
sb.append(tag);
sb.append(nd.name);
- int spacesNumber = max + 1 - nd.name.length();
- StringUtil.repeatSymbol(sb, ' ', Math.max(0, spacesNumber));
- sb.append(myFormatter.getParser().splitIntoCLines(nd.desc, fill, false));
+
+ if (nd.name.length() > max_name_length) {
+ sb.append('\n');
+ sb.append(myFormatter.getParser().splitIntoCLines(nd.desc, fill, true));
+ }
+ else {
+ int len = max - nd.name.length() + 1;
+ for (int j = 0; j < len; j++) {
+ sb.append(' ');
+ }
+ sb.append(myFormatter.getParser().splitIntoCLines(nd.desc, fill, false));
+ }
}
else {
sb.append(myFormatter.getParser().splitIntoCLines(tag + nd.name + " " + nd.desc, prefix, true));
diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java
index d46fa203f7e0..647cd09f0806 100644
--- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java
+++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureDialog.java
@@ -30,6 +30,7 @@ import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.ValidationInfo;
+import com.intellij.openapi.ui.VerticalFlowLayout;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
@@ -49,13 +50,13 @@ import com.intellij.refactoring.util.CanonicalTypes;
import com.intellij.refactoring.util.RefactoringMessageUtil;
import com.intellij.refactoring.util.RefactoringUtil;
import com.intellij.ui.*;
+import com.intellij.ui.components.JBLabel;
import com.intellij.ui.table.JBTable;
import com.intellij.ui.table.TableView;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.*;
import com.intellij.util.ui.DialogUtil;
import com.intellij.util.ui.UIUtil;
-import com.intellij.util.ui.table.JBListTable;
import com.intellij.util.ui.table.JBTableRow;
import com.intellij.util.ui.table.JBTableRowEditor;
import org.jetbrains.annotations.NotNull;
@@ -227,6 +228,7 @@ public class JavaChangeSignatureDialog extends ChangeSignatureDialogBase<Paramet
@Override
protected JComponent getRowPresentation(ParameterTableModelItemBase<ParameterInfoImpl> item, boolean selected, final boolean focused) {
+ final JPanel panel = new JPanel(new BorderLayout());
final String typeText = item.typeCodeFragment.getText();
final String separator = StringUtil.repeatSymbol(' ', getTypesMaxLength() - typeText.length() + 1);
String text = typeText + separator + item.parameter.getName();
@@ -244,7 +246,28 @@ public class JavaChangeSignatureDialog extends ChangeSignatureDialogBase<Paramet
if (!StringUtil.isEmpty(tail)) {
text += " //" + tail;
}
- return JBListTable.createEditorTextFieldPresentation(getProject(), getFileType(), " " + text, selected, focused);
+ final EditorTextField field = new EditorTextField(" " + text, getProject(), getFileType()) {
+ @Override
+ protected boolean shouldHaveBorder() {
+ return false;
+ }
+ };
+
+ Font font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN);
+ font = new Font(font.getFontName(), font.getStyle(), 12);
+ field.setFont(font);
+
+ if (selected && focused) {
+ panel.setBackground(UIUtil.getTableSelectionBackground());
+ field.setAsRendererWithSelection(UIUtil.getTableSelectionBackground(), UIUtil.getTableSelectionForeground());
+ } else {
+ panel.setBackground(UIUtil.getTableBackground());
+ if (selected && !focused) {
+ panel.setBorder(new DottedBorder(UIUtil.getTableForeground()));
+ }
+ }
+ panel.add(field, BorderLayout.WEST);
+ return panel;
}
private int getTypesMaxLength() {
@@ -288,20 +311,43 @@ public class JavaChangeSignatureDialog extends ChangeSignatureDialogBase<Paramet
private EditorTextField myDefaultValueEditor;
private JCheckBox myAnyVar;
+ class MyDocumentListener extends DocumentAdapter {
+ private int myColumn;
+
+ private MyDocumentListener(int column) {
+ myColumn = column;
+ }
+
+ @Override
+ public void documentChanged(DocumentEvent e) {
+ fireDocumentChanged(e, myColumn);
+ }
+ }
+
@Override
public void prepareEditor(JTable table, int row) {
setLayout(new BorderLayout());
+ final JPanel typePanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 4, 2, true, false));
final Document document = PsiDocumentManager.getInstance(getProject()).getDocument(item.typeCodeFragment);
myTypeEditor = new EditorTextField(document, getProject(), getFileType());
myTypeEditor.addDocumentListener(mySignatureUpdater);
+ final JBLabel typeLabel = new JBLabel("Type:", UIUtil.ComponentStyle.SMALL);
+ IJSwingUtilities.adjustComponentsOnMac(typeLabel, myTypeEditor);
+ typePanel.add(typeLabel);
+ typePanel.add(myTypeEditor);
myTypeEditor.setPreferredWidth(t.getWidth() / 2);
- myTypeEditor.addDocumentListener(new RowEditorChangeListener(0));
- add(createLabeledPanel("Type:", myTypeEditor), BorderLayout.WEST);
+ myTypeEditor.addDocumentListener(new MyDocumentListener(0));
+ add(typePanel, BorderLayout.WEST);
+ final JPanel namePanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 4, 2, true, false));
myNameEditor = new EditorTextField(item.parameter.getName(), getProject(), getFileType());
myNameEditor.addDocumentListener(mySignatureUpdater);
- myNameEditor.addDocumentListener(new RowEditorChangeListener(1));
- add(createLabeledPanel("Name:", myNameEditor), BorderLayout.CENTER);
+ myNameEditor.addDocumentListener(new MyDocumentListener(1));
+ final JBLabel nameLabel = new JBLabel("Name:", UIUtil.ComponentStyle.SMALL);
+ IJSwingUtilities.adjustComponentsOnMac(nameLabel, myNameEditor);
+ namePanel.add(nameLabel);
+ namePanel.add(myNameEditor);
+ add(namePanel, BorderLayout.CENTER);
new TextFieldCompletionProvider() {
@Override
@@ -331,12 +377,17 @@ public class JavaChangeSignatureDialog extends ChangeSignatureDialogBase<Paramet
if (!item.isEllipsisType() && item.parameter.getOldIndex() == -1) {
final JPanel additionalPanel = new JPanel(new BorderLayout());
+ final JPanel defaultValuePanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 4, 2, true, false));
final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(item.defaultValueCodeFragment);
myDefaultValueEditor = new EditorTextField(doc, getProject(), getFileType());
((PsiExpressionCodeFragment)item.defaultValueCodeFragment).setExpectedType(getRowType(item));
+ final JBLabel defaultValueLabel = new JBLabel("Default value:", UIUtil.ComponentStyle.SMALL);
+ IJSwingUtilities.adjustComponentsOnMac(defaultValueLabel, myDefaultValueEditor);
+ defaultValuePanel.add(defaultValueLabel);
+ defaultValuePanel.add(myDefaultValueEditor);
myDefaultValueEditor.setPreferredWidth(t.getWidth() / 2);
- myDefaultValueEditor.addDocumentListener(new RowEditorChangeListener(2));
- additionalPanel.add(createLabeledPanel("Default value:", myDefaultValueEditor), BorderLayout.WEST);
+ myDefaultValueEditor.addDocumentListener(new MyDocumentListener(2));
+ additionalPanel.add(defaultValuePanel, BorderLayout.WEST);
if (!isGenerateDelegate()) {
myAnyVar = new JCheckBox("&Use Any Var");
diff --git a/java/java-impl/src/com/intellij/refactoring/copy/CopyClassesHandler.java b/java/java-impl/src/com/intellij/refactoring/copy/CopyClassesHandler.java
index b6e3be4b86bd..a081ff233ca6 100644
--- a/java/java-impl/src/com/intellij/refactoring/copy/CopyClassesHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/copy/CopyClassesHandler.java
@@ -37,7 +37,6 @@ import com.intellij.refactoring.MoveDestination;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.move.moveClassesOrPackages.MoveDirectoryWithClassesProcessor;
import com.intellij.util.ArrayUtil;
-import com.intellij.util.ArrayUtilRt;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -184,16 +183,14 @@ public class CopyClassesHandler extends CopyHandlerDelegateBase {
String className = null;
boolean openInEditor = true;
if (copyOneClass(classes)) {
- final String commonPath =
- ArrayUtilRt.find(elements, classes.values().iterator().next()) == -1 ? normalizeRelativeMap(relativePathsMap) : null;
+ final String commonPath = ArrayUtil.find(elements, classes.values().iterator().next()) == -1 ? normalizeRelativeMap(relativePathsMap) : null;
CopyClassDialog dialog = new CopyClassDialog(classes.values().iterator().next()[0], defaultTargetDirectory, project, false){
@Override
protected String getQualifiedName() {
- final String qualifiedName = super.getQualifiedName();
- if (commonPath != null && !commonPath.isEmpty() && !qualifiedName.endsWith(commonPath)) {
- return StringUtil.getQualifiedName(qualifiedName, commonPath.replaceAll("/", "."));
+ if (commonPath != null && !commonPath.isEmpty()) {
+ return StringUtil.getQualifiedName(super.getQualifiedName(), commonPath.replaceAll("/", "."));
}
- return qualifiedName;
+ return super.getQualifiedName();
}
};
dialog.setTitle(RefactoringBundle.message("copy.handler.copy.class"));
diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java
index 3c90eecd11f9..317117537ac7 100644
--- a/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java
@@ -195,7 +195,7 @@ public class InlineLocalHandler extends JavaInlineActionHandler {
}
}
- final PsiElement writeAccess = checkRefsInAugmentedAssignmentOrUnaryModified(refsToInline, defToInline);
+ final PsiElement writeAccess = checkRefsInAugmentedAssignmentOrUnaryModified(refsToInline);
if (writeAccess != null) {
HighlightManager.getInstance(project).addOccurrenceHighlights(editor, new PsiElement[]{writeAccess}, writeAttributes, true, null);
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("variable.is.accessed.for.writing", localName));
@@ -273,13 +273,12 @@ public class InlineLocalHandler extends JavaInlineActionHandler {
}
@Nullable
- public static PsiElement checkRefsInAugmentedAssignmentOrUnaryModified(final PsiElement[] refsToInline, PsiElement defToInline) {
+ public static PsiElement checkRefsInAugmentedAssignmentOrUnaryModified(final PsiElement[] refsToInline) {
for (PsiElement element : refsToInline) {
PsiElement parent = element.getParent();
if (parent instanceof PsiArrayAccessExpression) {
if (((PsiArrayAccessExpression)parent).getIndexExpression() == element) continue;
- if (defToInline instanceof PsiExpression && !(defToInline instanceof PsiNewExpression)) continue;
element = parent;
parent = parent.getParent();
}
diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineParameterHandler.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineParameterHandler.java
index 58d4d1eb282d..e22f0b86e2cd 100644
--- a/java/java-impl/src/com/intellij/refactoring/inline/InlineParameterHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineParameterHandler.java
@@ -125,7 +125,7 @@ public class InlineParameterHandler extends JavaInlineActionHandler {
if (rExpr != null) {
final PsiElement[] refs = DefUseUtil.getRefs(codeBlock, psiParameter, refExpr);
- if (InlineLocalHandler.checkRefsInAugmentedAssignmentOrUnaryModified(refs, def) == null) {
+ if (InlineLocalHandler.checkRefsInAugmentedAssignmentOrUnaryModified(refs) == null) {
new WriteCommandAction(project) {
@Override
protected void run(Result result) throws Throwable {
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerImpl.java b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerImpl.java
index c33cc48b6864..fe37b7d3cf82 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerImpl.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerImpl.java
@@ -34,16 +34,14 @@ public class MoveInnerImpl {
public static final String REFACTORING_NAME = RefactoringBundle.message("move.inner.to.upper.level.title");
- public static void doMove(final Project project, PsiElement[] elements, final MoveCallback moveCallback, @Nullable PsiElement targetContainer) {
+ public static void doMove(final Project project, PsiElement[] elements, final MoveCallback moveCallback) {
if (elements.length != 1) return;
final PsiClass aClass = (PsiClass) elements[0];
boolean condition = aClass.getContainingClass() != null;
LOG.assertTrue(condition);
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, aClass)) return;
- if (targetContainer == null) {
- targetContainer = getTargetContainer(aClass, true);
- }
+ final PsiElement targetContainer = getTargetContainer(aClass, true);
if (targetContainer == null) return;
final MoveInnerDialog dialog = new MoveInnerDialog(
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java
index ddff1f089669..35ca3e256ee2 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java
@@ -164,7 +164,7 @@ public class MoveInnerProcessor extends BaseRefactoringProcessor {
if (myParameterNameOuterClass != null) {
// pass outer as a parameter
field = factory.createField(myFieldNameOuterClass, factory.createType(myOuterClass));
- field = addOuterField(field);
+ field = (PsiField)myInnerClass.add(field);
myInnerClass = field.getContainingClass();
addFieldInitializationToConstructors(myInnerClass, field, myParameterNameOuterClass);
}
@@ -296,19 +296,6 @@ public class MoveInnerProcessor extends BaseRefactoringProcessor {
}
}
- private PsiField addOuterField(PsiField field) {
- final PsiMember[] members = PsiTreeUtil.getChildrenOfType(myInnerClass, PsiMember.class);
- if (members != null) {
- for (PsiMember member : members) {
- if (!member.hasModifierProperty(PsiModifier.STATIC)) {
- return (PsiField)myInnerClass.addBefore(field, member);
- }
- }
- }
-
- return (PsiField)myInnerClass.add(field);
- }
-
protected void performPsiSpoilingRefactoring() {
if (myNonCodeUsages != null) {
RenameUtil.renameNonCodeUsages(myProject, myNonCodeUsages);
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperHandler.java b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperHandler.java
index 706fc7954b27..f807e89d4c64 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperHandler.java
@@ -17,7 +17,6 @@ package com.intellij.refactoring.move.moveInner;
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiClass;
@@ -36,7 +35,9 @@ public class MoveInnerToUpperHandler extends MoveHandlerDelegate {
public boolean canMove(final PsiElement[] elements, @Nullable final PsiElement targetContainer) {
if (elements.length != 1) return false;
PsiElement element = elements [0];
- return isNonStaticInnerClass(element);
+ return isNonStaticInnerClass(element) &&
+ (targetContainer == null || targetContainer.equals(MoveInnerImpl.getTargetContainer((PsiClass)elements[0], false)));
+
}
private static boolean isNonStaticInnerClass(final PsiElement element) {
@@ -45,7 +46,7 @@ public class MoveInnerToUpperHandler extends MoveHandlerDelegate {
}
public void doMove(final Project project, final PsiElement[] elements, final PsiElement targetContainer, final MoveCallback callback) {
- MoveInnerImpl.doMove(project, elements, callback, targetContainer);
+ MoveInnerImpl.doMove(project, elements, callback);
}
public boolean tryToMove(final PsiElement element, final Project project, final DataContext dataContext, final PsiReference reference,
@@ -59,7 +60,7 @@ public class MoveInnerToUpperHandler extends MoveHandlerDelegate {
RefactoringBundle.message("move.title"), null);
return true;
}
- MoveInnerImpl.doMove(project, new PsiElement[]{aClass}, null, LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext));
+ MoveInnerImpl.doMove(project, new PsiElement[]{aClass}, null);
return true;
}
return false;
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperOrMembersHandler.java b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperOrMembersHandler.java
index 1993c3c563f9..823ee22a1687 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperOrMembersHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerToUpperOrMembersHandler.java
@@ -17,7 +17,6 @@ package com.intellij.refactoring.move.moveInner;
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
@@ -40,7 +39,8 @@ public class MoveInnerToUpperOrMembersHandler extends MoveHandlerDelegate {
public boolean canMove(final PsiElement[] elements, @Nullable final PsiElement targetContainer) {
if (elements.length != 1) return false;
PsiElement element = elements [0];
- return isStaticInnerClass(element);
+ return isStaticInnerClass(element) &&
+ (targetContainer == null || targetContainer.equals(MoveInnerImpl.getTargetContainer((PsiClass)elements[0], false)));
}
private static boolean isStaticInnerClass(final PsiElement element) {
@@ -70,7 +70,7 @@ public class MoveInnerToUpperOrMembersHandler extends MoveHandlerDelegate {
if (dialog.isOK()) {
final MoveHandlerDelegate moveHandlerDelegate = dialog.getRefactoringHandler();
if (moveHandlerDelegate != null) {
- moveHandlerDelegate.doMove(project, new PsiElement[] { aClass }, LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext), null);
+ moveHandlerDelegate.doMove(project, new PsiElement[] { aClass }, null, null);
}
}
return true;
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java
index 4dda4d75a304..ea39904f5a1d 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java
@@ -193,7 +193,7 @@ public class MoveJavaMemberHandler implements MoveMemberHandler {
}
}
else { // no qualifier
- if (usage.qualifierClass != null && (!usage.qualifierClass.isEnum() || PsiTreeUtil.getParentOfType(refExpr, PsiSwitchLabelStatement.class) == null)) {
+ if (usage.qualifierClass != null && PsiTreeUtil.getParentOfType(refExpr, PsiSwitchLabelStatement.class) == null) {
changeQualifier(refExpr, usage.qualifierClass, usage.member);
}
}