summaryrefslogtreecommitdiff
path: root/java/java-impl
diff options
context:
space:
mode:
Diffstat (limited to 'java/java-impl')
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java7
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java36
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExceptionToCatchFix.java17
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java16
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/hint/api/impls/AnnotationParameterInfoHandler.java5
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/hint/api/impls/MethodParameterInfoHandler.java5
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/intention/impl/AddAnnotationIntention.java25
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseColorIntentionAction.java39
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/intention/impl/ColorChooserIntentionAction.java4
-rw-r--r--java/java-impl/src/com/intellij/codeInsight/navigation/JavaGotoSuperHandler.java28
-rw-r--r--java/java-impl/src/com/intellij/codeInspection/dataFlow/EditContractIntention.java18
-rw-r--r--java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaReferenceAdjuster.java6
-rw-r--r--java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceSet.java20
-rw-r--r--java/java-impl/src/com/intellij/refactoring/changeClassSignature/ChangeClassSignatureProcessor.java24
-rw-r--r--java/java-impl/src/com/intellij/refactoring/changeSignature/ParameterInfoImpl.java8
-rw-r--r--java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousClassProcessor.java16
-rw-r--r--java/java-impl/src/com/intellij/refactoring/inlineSuperClass/usageInfo/ReplaceWithSubtypeUsageInfo.java19
-rw-r--r--java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesImpl.java4
-rw-r--r--java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationReplacementUtil.java12
-rw-r--r--java/java-impl/src/com/intellij/spi/SPIGotoSuperHandler.java9
-rw-r--r--java/java-impl/src/com/intellij/util/xml/CanonicalPsiTypeConverterImpl.java5
21 files changed, 191 insertions, 132 deletions
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java
index b647e7d1b37f..f8c395ce17fd 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaLineMarkerProvider.java
@@ -81,6 +81,13 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
}
}
+ final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(element);
+ if (interfaceMethod != null) {
+ final Icon icon = AllIcons.Gutter.ImplementingMethod;
+ final MarkerType type = MarkerType.OVERRIDING_METHOD;
+ return new ArrowUpLineMarkerInfo(element, icon, type);
+ }
+
if (myDaemonSettings.SHOW_METHOD_SEPARATORS && element.getFirstChild() == null) {
PsiElement element1 = element;
boolean isMember = false;
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java
index 12b1788dcea7..72e8eca35fa6 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/MarkerType.java
@@ -53,27 +53,27 @@ public class MarkerType {
public static final MarkerType OVERRIDING_METHOD = new MarkerType(new NullableFunction<PsiElement, String>() {
@Override
public String fun(PsiElement element) {
- PsiElement parent = element.getParent();
+ PsiElement parent = getParentMethod(element);
if (!(parent instanceof PsiMethod)) return null;
PsiMethod method = (PsiMethod)parent;
- return calculateOverridingMethodTooltip(method);
+ return calculateOverridingMethodTooltip(method, method != element.getParent());
}
}, new LineMarkerNavigator(){
@Override
public void browse(MouseEvent e, PsiElement element) {
- PsiElement parent = element.getParent();
+ PsiElement parent = getParentMethod(element);
if (!(parent instanceof PsiMethod)) return;
PsiMethod method = (PsiMethod)parent;
- navigateToOverridingMethod(e, method);
+ navigateToOverridingMethod(e, method, method != element.getParent());
}
});
@Nullable
- public static String calculateOverridingMethodTooltip(PsiMethod method) {
- PsiMethod[] superMethods = method.findSuperMethods(false);
- if (superMethods.length == 0) return null;
+ public static String calculateOverridingMethodTooltip(PsiMethod method, boolean acceptSelf) {
+ PsiMethod[] superMethods = composeSuperMethods(method, acceptSelf);
+ if (superMethods == null) return null;
PsiMethod superMethod = superMethods[0];
boolean isAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT);
@@ -90,9 +90,9 @@ public class MarkerType {
return GutterIconTooltipHelper.composeText(superMethods, "", DaemonBundle.message(key));
}
- public static void navigateToOverridingMethod(MouseEvent e, PsiMethod method) {
- PsiMethod[] superMethods = method.findSuperMethods(false);
- if (superMethods.length == 0) return;
+ public static void navigateToOverridingMethod(MouseEvent e, PsiMethod method, boolean acceptSelf) {
+ PsiMethod[] superMethods = composeSuperMethods(method, acceptSelf);
+ if (superMethods == null) return;
boolean showMethodNames = !PsiUtil.allMethodsHaveSameSignature(superMethods);
PsiElementListNavigator.openTargets(e, superMethods,
DaemonBundle.message("navigation.title.super.method", method.getName()),
@@ -100,6 +100,22 @@ public class MarkerType {
new MethodCellRenderer(showMethodNames));
}
+ @Nullable
+ private static PsiMethod[] composeSuperMethods(PsiMethod method, boolean acceptSelf) {
+ PsiMethod[] superMethods = method.findSuperMethods(false);
+ if (acceptSelf) {
+ superMethods = ArrayUtil.prepend(method, superMethods);
+ }
+ if (superMethods.length == 0) return null;
+ return superMethods;
+ }
+
+ private static PsiElement getParentMethod(PsiElement element) {
+ final PsiElement parent = element.getParent();
+ final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(element);
+ return interfaceMethod != null ? interfaceMethod : parent;
+ }
+
public static final String SEARCHING_FOR_OVERRIDING_METHODS = "Searching for overriding methods";
public static final MarkerType OVERRIDEN_METHOD = new MarkerType(new NullableFunction<PsiElement, String>() {
@Override
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExceptionToCatchFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExceptionToCatchFix.java
index ccb1c3c369e4..5d51949c1d6b 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExceptionToCatchFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExceptionToCatchFix.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -52,7 +52,9 @@ public class AddExceptionToCatchFix extends BaseIntentionAction {
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiElement element = findElement(file, offset);
- PsiTryStatement tryStatement = (PsiTryStatement) element.getParent();
+ if (element == null) return;
+
+ PsiTryStatement tryStatement = (PsiTryStatement)element.getParent();
List<PsiClassType> unhandledExceptions = new ArrayList<PsiClassType>(ExceptionUtil.collectUnhandledExceptions(element, null));
ExceptionUtil.sortExceptionsByHierarchy(unhandledExceptions);
@@ -86,7 +88,9 @@ public class AddExceptionToCatchFix extends BaseIntentionAction {
}
}
- private static PsiCodeBlock addCatchStatement(PsiTryStatement tryStatement, PsiClassType exceptionType, PsiFile file) throws IncorrectOperationException {
+ private static PsiCodeBlock addCatchStatement(PsiTryStatement tryStatement,
+ PsiClassType exceptionType,
+ PsiFile file) throws IncorrectOperationException {
PsiElementFactory factory = JavaPsiFacade.getInstance(tryStatement.getProject()).getElementFactory();
if (tryStatement.getTryBlock() == null) {
@@ -108,9 +112,12 @@ public class AddExceptionToCatchFix extends BaseIntentionAction {
}
PsiParameter[] parameters = tryStatement.getCatchBlockParameters();
- parameters[parameters.length - 1].getTypeElement().replace(factory.createTypeElement(exceptionType));
- PsiCodeBlock[] catchBlocks = tryStatement.getCatchBlocks();
+ PsiTypeElement typeElement = parameters[parameters.length - 1].getTypeElement();
+ if (typeElement != null) {
+ JavaCodeStyleManager.getInstance(file.getProject()).shortenClassReferences(typeElement);
+ }
+ PsiCodeBlock[] catchBlocks = tryStatement.getCatchBlocks();
return catchBlocks[catchBlocks.length - 1];
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java
index 19a4639a0689..69800e5616f7 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/StaticImportMethodFix.java
@@ -200,7 +200,7 @@ public class StaticImportMethodFix implements IntentionAction {
//do not show methods from default package
&& !((PsiJavaFile)file).getPackageName().isEmpty()
&& PsiUtil.isAccessible(file.getProject(), method, element, containingClass)) {
- if (method.isDeprecated()) {
+ if (isEffectivelyDeprecated(method)) {
deprecated.put(containingClass, method);
return processCondition();
}
@@ -209,6 +209,20 @@ public class StaticImportMethodFix implements IntentionAction {
return processCondition();
}
+ private boolean isEffectivelyDeprecated(PsiMethod method) {
+ if (method.isDeprecated()) {
+ return true;
+ }
+ PsiClass aClass = method.getContainingClass();
+ while (aClass != null) {
+ if (aClass.isDeprecated()) {
+ return true;
+ }
+ aClass = aClass.getContainingClass();
+ }
+ return false;
+ }
+
private boolean processCondition() {
return (applicableList.isEmpty() ? list : applicableList).size() + deprecated.size() < 50;
}
diff --git a/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/AnnotationParameterInfoHandler.java b/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/AnnotationParameterInfoHandler.java
index e72756865767..0d822feff94c 100644
--- a/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/AnnotationParameterInfoHandler.java
+++ b/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/AnnotationParameterInfoHandler.java
@@ -21,7 +21,6 @@ import com.intellij.openapi.project.DumbAware;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.text.CharArrayUtil;
-import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -119,9 +118,9 @@ public class AnnotationParameterInfoHandler implements ParameterInfoHandler<PsiA
@NonNls StringBuilder buffer = new StringBuilder();
buffer.append(p.getReturnType().getPresentableText());
buffer.append(" ");
- int highlightStartOffset = XmlStringUtil.escapeString(buffer.toString()).length();
+ int highlightStartOffset = buffer.length();
buffer.append(p.getName());
- int highlightEndOffset = XmlStringUtil.escapeString(buffer.toString()).length();
+ int highlightEndOffset = buffer.length();
buffer.append("()");
if (p.getDefaultValue() != null) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/MethodParameterInfoHandler.java b/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/MethodParameterInfoHandler.java
index 5da27d9c18d3..b3918fd0fbe2 100644
--- a/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/MethodParameterInfoHandler.java
+++ b/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/MethodParameterInfoHandler.java
@@ -32,7 +32,6 @@ import com.intellij.psi.util.MethodSignatureUtil;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.HashSet;
-import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -393,7 +392,7 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
for (int j = 0; j < numParams; j++) {
PsiParameter param = parms[j];
- int startOffset = XmlStringUtil.escapeString(buffer.toString()).length();
+ int startOffset = buffer.length();
if (param.isValid()) {
PsiType paramType = param.getType();
@@ -411,7 +410,7 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc
}
}
- int endOffset = XmlStringUtil.escapeString(buffer.toString()).length();
+ int endOffset = buffer.length();
if (j < numParams - 1) {
buffer.append(", ");
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddAnnotationIntention.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddAnnotationIntention.java
index 2b839b5dfcde..daf5aa5eac74 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddAnnotationIntention.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddAnnotationIntention.java
@@ -26,13 +26,11 @@ import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.intention.AddAnnotationFix;
import com.intellij.codeInsight.intention.AddAnnotationPsiFix;
-import com.intellij.openapi.editor.CaretModel;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
-import com.intellij.psi.util.PsiUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
@@ -49,22 +47,11 @@ public abstract class AddAnnotationIntention extends BaseIntentionAction {
// include not in project files
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
- CaretModel caretModel = editor.getCaretModel();
- int position = caretModel.getOffset();
- PsiElement element = file.findElementAt(position);
- return element != null && isAvailable(project, element);
- }
-
- public boolean isAvailable(@NotNull final Project project, @NotNull final PsiElement element) {
- if (!element.isValid()) return false;
- final PsiModifierListOwner owner;
- if (!element.getManager().isInProject(element) || CodeStyleSettingsManager.getSettings(project).USE_EXTERNAL_ANNOTATIONS) {
- owner = AddAnnotationPsiFix.getContainer(element);
- }
- else {
+ final PsiModifierListOwner owner = AddAnnotationPsiFix.getContainer(file, editor.getCaretModel().getOffset());
+ if (owner == null ||
+ owner.getManager().isInProject(owner) && !CodeStyleSettingsManager.getSettings(project).USE_EXTERNAL_ANNOTATIONS) {
return false;
}
- if (owner == null) return false;
Pair<String, String[]> annotations = getAnnotations(project);
String toAdd = annotations.first;
String[] toRemove = annotations.second;
@@ -82,11 +69,7 @@ public abstract class AddAnnotationIntention extends BaseIntentionAction {
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
- CaretModel caretModel = editor.getCaretModel();
- int position = caretModel.getOffset();
- PsiElement element = file.findElementAt(position);
-
- PsiModifierListOwner owner = AddAnnotationPsiFix.getContainer(element);
+ PsiModifierListOwner owner = AddAnnotationPsiFix.getContainer(file, editor.getCaretModel().getOffset());
if (owner == null || !owner.isValid()) return;
Pair<String, String[]> annotations = getAnnotations(project);
String toAdd = annotations.first;
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseColorIntentionAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseColorIntentionAction.java
index adde45b86af6..f3c9df9dfe16 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseColorIntentionAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseColorIntentionAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -28,9 +28,11 @@ import static com.intellij.patterns.PlatformPatterns.psiElement;
/**
* @author Danila Ponomarenko
+ * @author Konstantin Bulenkov
*/
public abstract class BaseColorIntentionAction extends PsiElementBaseIntentionAction implements HighPriorityAction {
protected static final String JAVA_AWT_COLOR = "java.awt.Color";
+ protected static final String COLOR_UI_RESOURCE = "javax.swing.plaf.ColorUIResource";
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
@@ -39,29 +41,28 @@ public abstract class BaseColorIntentionAction extends PsiElementBaseIntentionAc
}
final PsiNewExpression expression = PsiTreeUtil.getParentOfType(element, PsiNewExpression.class, false);
- if (expression == null) {
- return false;
- }
-
- return isJavaAwtColor(expression.getClassOrAnonymousClassReference()) && isValueArguments(expression.getArgumentList());
+ return expression != null
+ && isJavaAwtColor(expression.getClassOrAnonymousClassReference())
+ && isValueArguments(expression.getArgumentList());
}
private static boolean isJavaAwtColor(@Nullable PsiJavaCodeReferenceElement ref) {
- if (ref == null) {
- return false;
- }
-
- final PsiReference reference = ref.getReference();
- if (reference == null) {
- return false;
- }
+ final String fqn = getFqn(ref);
+ return JAVA_AWT_COLOR.equals(fqn) || COLOR_UI_RESOURCE.equals(fqn);
+ }
- final PsiElement psiElement = reference.resolve();
- if (psiElement instanceof PsiClass && JAVA_AWT_COLOR.equals(((PsiClass)psiElement).getQualifiedName())) {
- return true;
+ @Nullable
+ protected static String getFqn(@Nullable PsiJavaCodeReferenceElement ref) {
+ if (ref != null) {
+ final PsiReference reference = ref.getReference();
+ if (reference != null) {
+ final PsiElement psiElement = reference.resolve();
+ if (psiElement instanceof PsiClass) {
+ return ((PsiClass)psiElement).getQualifiedName();
+ }
+ }
}
-
- return false;
+ return null;
}
private static boolean isValueArguments(@Nullable PsiExpressionList arguments) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ColorChooserIntentionAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ColorChooserIntentionAction.java
index db93d4e851f5..f5d1b3a28afe 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/ColorChooserIntentionAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/ColorChooserIntentionAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -191,7 +191,7 @@ public class ColorChooserIntentionAction extends BaseColorIntentionAction {
final PsiManager manager = expression.getManager();
final PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
final PsiExpression newCall = factory.createExpressionFromText(
- "new " + JAVA_AWT_COLOR + "("
+ "new " + getFqn(expression.getClassOrAnonymousClassReference()) + "("
+ color.getRed() + ", "
+ color.getGreen() + ", "
+ color.getBlue()
diff --git a/java/java-impl/src/com/intellij/codeInsight/navigation/JavaGotoSuperHandler.java b/java/java-impl/src/com/intellij/codeInsight/navigation/JavaGotoSuperHandler.java
index 94ddb7ae863e..55d82a987001 100644
--- a/java/java-impl/src/com/intellij/codeInsight/navigation/JavaGotoSuperHandler.java
+++ b/java/java-impl/src/com/intellij/codeInsight/navigation/JavaGotoSuperHandler.java
@@ -30,6 +30,7 @@ import com.intellij.psi.*;
import com.intellij.psi.impl.FindSuperElementsHelper;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
+import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -65,20 +66,27 @@ public class JavaGotoSuperHandler implements CodeInsightActionHandler {
@Nullable
private PsiElement[] findSuperElements(PsiFile file, int offset) {
- PsiNameIdentifierOwner parent = getElement(file, offset);
- if (parent == null) return null;
+ PsiElement element = getElement(file, offset);
+ if (element == null) return null;
+
+ final PsiExpression expression = PsiTreeUtil.getParentOfType(element, PsiLambdaExpression.class, PsiMethodReferenceExpression.class);
+ if (expression != null) {
+ final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(expression);
+ if (interfaceMethod != null) {
+ return ArrayUtil.prepend(interfaceMethod, interfaceMethod.findSuperMethods(false));
+ }
+ }
+
+ final PsiNameIdentifierOwner parent = PsiTreeUtil.getNonStrictParentOfType(element, PsiMethod.class, PsiClass.class);
+ if (parent == null) {
+ return null;
+ }
return FindSuperElementsHelper.findSuperElements(parent);
}
- protected PsiNameIdentifierOwner getElement(PsiFile file, int offset) {
- PsiElement element = file.findElementAt(offset);
- if (element == null) return null;
-
- PsiNameIdentifierOwner parent = PsiTreeUtil.getParentOfType(element, PsiMethod.class, PsiClass.class);
- if (parent == null)
- return null;
- return parent;
+ protected PsiElement getElement(PsiFile file, int offset) {
+ return file.findElementAt(offset);
}
@Override
diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/EditContractIntention.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/EditContractIntention.java
index 7040347c4d0e..767077b3448e 100644
--- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/EditContractIntention.java
+++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/EditContractIntention.java
@@ -28,7 +28,6 @@ import com.intellij.openapi.ui.InputValidatorEx;
import com.intellij.openapi.ui.Messages;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
-import com.intellij.psi.util.PsiUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@@ -48,22 +47,15 @@ public class EditContractIntention extends BaseIntentionAction {
@Nullable
private static PsiMethod getTargetMethod(@NotNull Project project, Editor editor, PsiFile file) {
- PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
- if (element == null) return null;
- if (!element.getManager().isInProject(element) || CodeStyleSettingsManager.getSettings(project).USE_EXTERNAL_ANNOTATIONS) {
- final PsiModifierListOwner owner = AddAnnotationPsiFix.getContainer(element);
- if (owner instanceof PsiMethod) {
- PsiElement original = owner.getOriginalElement();
- if (original instanceof PsiMethod) {
- return (PsiMethod)original;
- }
- return (PsiMethod)owner;
- }
+ final PsiModifierListOwner owner = AddAnnotationPsiFix.getContainer(file, editor.getCaretModel().getOffset());
+ if (owner instanceof PsiMethod &&
+ (!owner.getManager().isInProject(owner) || CodeStyleSettingsManager.getSettings(project).USE_EXTERNAL_ANNOTATIONS)) {
+ PsiElement original = owner.getOriginalElement();
+ return original instanceof PsiMethod ? (PsiMethod)original : (PsiMethod)owner;
}
return null;
}
-
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
final PsiMethod method = getTargetMethod(project, editor, file);
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaReferenceAdjuster.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaReferenceAdjuster.java
index db020ad58b8b..42d3098b7b07 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaReferenceAdjuster.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaReferenceAdjuster.java
@@ -60,6 +60,12 @@ public class JavaReferenceAdjuster implements ReferenceAdjuster {
}
if (rightKind) {
+ // annotations may jump out of reference (see PsiJavaCodeReferenceImpl#setAnnotations()) so they should be processed first
+ List<PsiAnnotation> annotations = PsiTreeUtil.getChildrenOfTypeAsList(ref, PsiAnnotation.class);
+ for (PsiAnnotation annotation : annotations) {
+ process(annotation.getNode(), addImports, incompleteCode, useFqInJavadoc, useFqInCode);
+ }
+
boolean isInsideDocComment = TreeUtil.findParent(element, JavaDocElementType.DOC_COMMENT) != null;
boolean isShort = !ref.isQualified();
if (isInsideDocComment ? !useFqInJavadoc : !useFqInCode) {
diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceSet.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceSet.java
index c184775ad11b..dbcbfdc4e546 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceSet.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceSet.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -22,6 +22,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.ArrayUtil;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@@ -44,27 +45,29 @@ public class JavaClassReferenceSet {
private final int myStartInElement;
private final JavaClassReferenceProvider myProvider;
- public JavaClassReferenceSet(String str, PsiElement element, int startInElement, final boolean isStatic, JavaClassReferenceProvider provider) {
+ public JavaClassReferenceSet(@NotNull String str, @NotNull PsiElement element, int startInElement, final boolean isStatic, @NotNull JavaClassReferenceProvider provider) {
this(str, element, startInElement, isStatic, provider, null);
}
- private JavaClassReferenceSet(String str, PsiElement element, int startInElement, final boolean isStatic, JavaClassReferenceProvider provider,
+ private JavaClassReferenceSet(@NotNull String str, @NotNull PsiElement element, int startInElement, final boolean isStatic, @NotNull JavaClassReferenceProvider provider,
JavaClassReferenceSet context) {
myStartInElement = startInElement;
myProvider = provider;
reparse(str, element, isStatic, context);
}
+ @NotNull
public JavaClassReferenceProvider getProvider() {
return myProvider;
}
+ @NotNull
public TextRange getRangeInElement() {
PsiReference[] references = getReferences();
return new TextRange(references[0].getRangeInElement().getStartOffset(), references[references.length - 1].getRangeInElement().getEndOffset());
}
- private void reparse(String str, PsiElement element, final boolean isStaticImport, JavaClassReferenceSet context) {
+ private void reparse(@NotNull String str, @NotNull PsiElement element, final boolean isStaticImport, JavaClassReferenceSet context) {
myElement = element;
myContext = context;
final List<JavaClassReference> referencesList = new ArrayList<JavaClassReference>();
@@ -186,7 +189,8 @@ public class JavaClassReferenceSet {
myReferences = referencesList.toArray(new JavaClassReference[referencesList.size()]);
}
- protected JavaClassReference createReference(final int referenceIndex, final String subreferenceText, final TextRange textRange,
+ @NotNull
+ protected JavaClassReference createReference(final int referenceIndex, @NotNull String subreferenceText, @NotNull TextRange textRange,
final boolean staticImport) {
return new JavaClassReference(this, textRange, referenceIndex, subreferenceText, staticImport);
}
@@ -200,7 +204,7 @@ public class JavaClassReferenceSet {
return isAllowDollarInNames() ? c == DOLLAR : c == DOT;
}
- public void reparse(PsiElement element, final TextRange range) {
+ public void reparse(@NotNull PsiElement element, @NotNull TextRange range) {
final String text = range.substring(element.getText());
reparse(text, element, false, myContext);
}
@@ -209,6 +213,7 @@ public class JavaClassReferenceSet {
return myReferences[index];
}
+ @NotNull
public JavaClassReference[] getAllReferences() {
JavaClassReference[] result = myReferences;
if (myNestedGenericParameterReferences != null) {
@@ -229,10 +234,12 @@ public class JavaClassReferenceSet {
return myProvider.isSoft();
}
+ @NotNull
public PsiElement getElement() {
return myElement;
}
+ @NotNull
public PsiReference[] getReferences() {
return myReferences;
}
@@ -243,6 +250,7 @@ public class JavaClassReferenceSet {
}
@SuppressWarnings({"UnresolvedPropertyKey"})
+ @NotNull
public String getUnresolvedMessagePattern(int index){
if (canReferencePackage(index)) {
return JavaErrorMessages.message("error.cannot.resolve.class.or.package");
diff --git a/java/java-impl/src/com/intellij/refactoring/changeClassSignature/ChangeClassSignatureProcessor.java b/java/java-impl/src/com/intellij/refactoring/changeClassSignature/ChangeClassSignatureProcessor.java
index ee207fb89fc7..a32dc464f7fa 100644
--- a/java/java-impl/src/com/intellij/refactoring/changeClassSignature/ChangeClassSignatureProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/changeClassSignature/ChangeClassSignatureProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -21,6 +21,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Ref;
import com.intellij.psi.*;
+import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.PsiUtil;
@@ -187,27 +188,28 @@ public class ChangeClassSignatureProcessor extends BaseRefactoringProcessor {
ChangeSignatureUtil.synchronizeList(myClass.getTypeParameterList(), newTypeParameters, TypeParameterList.INSTANCE, toRemoveParms);
}
- private boolean[] detectRemovedParameters(final PsiTypeParameter[] originaltypeParameters) {
- final boolean[] toRemoveParms = new boolean[originaltypeParameters.length];
- Arrays.fill(toRemoveParms, true);
+ private boolean[] detectRemovedParameters(final PsiTypeParameter[] original) {
+ final boolean[] toRemove = new boolean[original.length];
+ Arrays.fill(toRemove, true);
for (final TypeParameterInfo info : myNewSignature) {
int oldParameterIndex = info.getOldParameterIndex();
if (oldParameterIndex >= 0) {
- toRemoveParms[oldParameterIndex] = false;
+ toRemove[oldParameterIndex] = false;
}
}
- return toRemoveParms;
+ return toRemove;
}
- private void processUsage(final UsageInfo usage, final PsiTypeParameter[] originalTypeParameters, final boolean[] toRemoveParms)
- throws IncorrectOperationException {
+ private void processUsage(UsageInfo usage, PsiTypeParameter[] original, boolean[] toRemove) throws IncorrectOperationException {
PsiElementFactory factory = JavaPsiFacade.getInstance(myClass.getProject()).getElementFactory();
PsiJavaCodeReferenceElement referenceElement = (PsiJavaCodeReferenceElement)usage.getElement();
+ assert referenceElement != null : usage;
PsiSubstitutor usageSubstitutor = determineUsageSubstitutor(referenceElement);
PsiReferenceParameterList referenceParameterList = referenceElement.getParameterList();
+ assert referenceParameterList != null : referenceElement;
PsiTypeElement[] oldValues = referenceParameterList.getTypeParameterElements();
- if (oldValues.length != originalTypeParameters.length) return;
+ if (oldValues.length != original.length) return;
List<PsiTypeElement> newValues = new ArrayList<PsiTypeElement>();
for (final TypeParameterInfo info : myNewSignature) {
int oldIndex = info.getOldParameterIndex();
@@ -221,7 +223,9 @@ public class ChangeClassSignatureProcessor extends BaseRefactoringProcessor {
newValues.add(newValue);
}
}
- ChangeSignatureUtil.synchronizeList(referenceParameterList, newValues, ReferenceParameterList.INSTANCE, toRemoveParms);
+
+ ChangeSignatureUtil.synchronizeList(referenceParameterList, newValues, ReferenceParameterList.INSTANCE, toRemove);
+ JavaCodeStyleManager.getInstance(myProject).shortenClassReferences(referenceParameterList);
}
private PsiSubstitutor determineUsageSubstitutor(PsiJavaCodeReferenceElement referenceElement) {
diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/ParameterInfoImpl.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/ParameterInfoImpl.java
index aa27a6e024ca..69fc99031e80 100644
--- a/java/java-impl/src/com/intellij/refactoring/changeSignature/ParameterInfoImpl.java
+++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/ParameterInfoImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -33,11 +33,13 @@ import java.util.ArrayList;
import java.util.List;
public class ParameterInfoImpl implements JavaParameterInfo {
+ public static final ParameterInfoImpl[] EMPTY_ARRAY = {};
+
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.changeSignature.ParameterInfoImpl");
+
public int oldParameterIndex;
- boolean useAnySingleVariable;
+ private boolean useAnySingleVariable;
private String name = "";
- public static final ParameterInfoImpl[] EMPTY_ARRAY = new ParameterInfoImpl[0];
private CanonicalTypes.Type myType;
String defaultValue = "";
diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousClassProcessor.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousClassProcessor.java
index 25a9481259d8..2b483ddb676c 100644
--- a/java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousClassProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineToAnonymousClassProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.psi.*;
+import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.PsiTreeUtil;
@@ -259,9 +260,13 @@ public class InlineToAnonymousClassProcessor extends BaseRefactoringProcessor {
new InlineToAnonymousConstructorProcessor(myClass, psiNewExpression, superType).run();
}
else {
- PsiJavaCodeReferenceElement element =
- JavaPsiFacade.getInstance(myClass.getProject()).getElementFactory().createClassReferenceElement(superType.resolve());
- psiNewExpression.getClassReference().replace(element);
+ PsiClass target = superType.resolve();
+ assert target != null : superType;
+ PsiElementFactory factory = JavaPsiFacade.getInstance(myClass.getProject()).getElementFactory();
+ PsiJavaCodeReferenceElement element = factory.createClassReferenceElement(target);
+ PsiJavaCodeReferenceElement reference = psiNewExpression.getClassReference();
+ assert reference != null : psiNewExpression;
+ reference.replace(element);
}
}
catch (IncorrectOperationException e) {
@@ -276,7 +281,8 @@ public class InlineToAnonymousClassProcessor extends BaseRefactoringProcessor {
PsiType substType = classResolveResult.getSubstitutor().substitute(superType);
assert classResolveResult.getElement() == myClass;
try {
- typeElement.replace(factory.createTypeElement(substType));
+ PsiElement replaced = typeElement.replace(factory.createTypeElement(substType));
+ JavaCodeStyleManager.getInstance(myProject).shortenClassReferences(replaced);
}
catch(IncorrectOperationException e) {
LOG.error(e);
diff --git a/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/usageInfo/ReplaceWithSubtypeUsageInfo.java b/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/usageInfo/ReplaceWithSubtypeUsageInfo.java
index f2a6a2e647a2..ec1e10df935b 100644
--- a/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/usageInfo/ReplaceWithSubtypeUsageInfo.java
+++ b/java/java-impl/src/com/intellij/refactoring/inlineSuperClass/usageInfo/ReplaceWithSubtypeUsageInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -13,21 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/*
- * User: anna
- * Date: 27-Aug-2008
- */
package com.intellij.refactoring.inlineSuperClass.usageInfo;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
+import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.refactoring.util.FixableUsageInfo;
import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
+/**
+ * @author anna
+ * @since 27-Aug-2008
+ */
public class ReplaceWithSubtypeUsageInfo extends FixableUsageInfo {
public static final Logger LOG = Logger.getInstance("#" + ReplaceWithSubtypeUsageInfo.class.getName());
private final PsiTypeElement myTypeElement;
@@ -51,8 +52,10 @@ public class ReplaceWithSubtypeUsageInfo extends FixableUsageInfo {
public void fixUsage() throws IncorrectOperationException {
if (myTypeElement.isValid()) {
- final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(myTypeElement.getProject()).getElementFactory();
- myTypeElement.replace(elementFactory.createTypeElement(myTargetClassType));
+ Project project = myTypeElement.getProject();
+ PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
+ PsiElement replaced = myTypeElement.replace(elementFactory.createTypeElement(myTargetClassType));
+ JavaCodeStyleManager.getInstance(project).shortenClassReferences(replaced);
}
}
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesImpl.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesImpl.java
index 6d333e9cb54b..3e92a19373ab 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesImpl.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesImpl.java
@@ -23,6 +23,7 @@ package com.intellij.refactoring.move.moveClassesOrPackages;
import com.intellij.history.LocalHistory;
import com.intellij.history.LocalHistoryAction;
import com.intellij.ide.util.DirectoryChooser;
+import com.intellij.ide.util.PlatformPackageUtil;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.diagnostic.Logger;
@@ -266,7 +267,8 @@ public class MoveClassesOrPackagesImpl {
return aPackage != null ? getTargetPackageNameForMovedElement(aPackage) : "";
}
else if (psiElement != null) {
- PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(psiElement.getContainingFile().getContainingDirectory());
+ PsiDirectory directory = PlatformPackageUtil.getDirectory(psiElement);
+ PsiPackage aPackage = directory == null ? null : JavaDirectoryService.getInstance().getPackage(directory);
return aPackage != null ? aPackage.getQualifiedName() : "";
}
else {
diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationReplacementUtil.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationReplacementUtil.java
index f6cdabacedad..0004ff456cb6 100644
--- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationReplacementUtil.java
+++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationReplacementUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -18,6 +18,7 @@ package com.intellij.refactoring.typeMigration;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
+import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.impl.PsiDiamondTypeUtil;
import com.intellij.psi.impl.source.tree.ChildRole;
import com.intellij.psi.impl.source.tree.CompositeElement;
@@ -109,18 +110,19 @@ public class TypeMigrationReplacementUtil {
if (!migratedType.isValid()) {
migratedType = JavaPsiFacade.getElementFactory(project).createTypeByFQClassName(migratedType.getCanonicalText());
}
- final PsiTypeElement typeElement =
- JavaPsiFacade.getInstance(project).getElementFactory().createTypeElement(migratedType);
+ final PsiTypeElement typeElement = JavaPsiFacade.getInstance(project).getElementFactory().createTypeElement(migratedType);
if (element instanceof PsiMethod) {
final PsiTypeElement returnTypeElement = ((PsiMethod)element).getReturnTypeElement();
if (returnTypeElement != null) {
- returnTypeElement.replace(typeElement);
+ final PsiElement replaced = returnTypeElement.replace(typeElement);
+ JavaCodeStyleManager.getInstance(project).shortenClassReferences(replaced);
}
}
else if (element instanceof PsiVariable) {
final PsiTypeElement varTypeElement = ((PsiVariable)element).getTypeElement();
if (varTypeElement != null) {
- varTypeElement.replace(typeElement);
+ final PsiElement replaced = varTypeElement.replace(typeElement);
+ JavaCodeStyleManager.getInstance(project).shortenClassReferences(replaced);
}
}
else {
diff --git a/java/java-impl/src/com/intellij/spi/SPIGotoSuperHandler.java b/java/java-impl/src/com/intellij/spi/SPIGotoSuperHandler.java
index 04c48bc71e40..966a7a3422ea 100644
--- a/java/java-impl/src/com/intellij/spi/SPIGotoSuperHandler.java
+++ b/java/java-impl/src/com/intellij/spi/SPIGotoSuperHandler.java
@@ -16,9 +16,8 @@
package com.intellij.spi;
import com.intellij.codeInsight.navigation.JavaGotoSuperHandler;
-import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiNameIdentifierOwner;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.spi.psi.SPIClassProviderReferenceElement;
@@ -27,11 +26,11 @@ import com.intellij.spi.psi.SPIClassProviderReferenceElement;
*/
public class SPIGotoSuperHandler extends JavaGotoSuperHandler {
@Override
- protected PsiNameIdentifierOwner getElement(PsiFile file, int offset) {
+ protected PsiElement getElement(PsiFile file, int offset) {
final SPIClassProviderReferenceElement
- providerElement = PsiTreeUtil.getParentOfType(file.findElementAt(offset), SPIClassProviderReferenceElement.class);
+ providerElement = PsiTreeUtil.getParentOfType(super.getElement(file, offset), SPIClassProviderReferenceElement.class);
if (providerElement != null) {
- return (PsiClass)providerElement.resolve();
+ return providerElement.resolve();
}
return null;
diff --git a/java/java-impl/src/com/intellij/util/xml/CanonicalPsiTypeConverterImpl.java b/java/java-impl/src/com/intellij/util/xml/CanonicalPsiTypeConverterImpl.java
index 877d27453b1b..254dc036547c 100644
--- a/java/java-impl/src/com/intellij/util/xml/CanonicalPsiTypeConverterImpl.java
+++ b/java/java-impl/src/com/intellij/util/xml/CanonicalPsiTypeConverterImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -80,7 +80,8 @@ public class CanonicalPsiTypeConverterImpl extends CanonicalPsiTypeConverter imp
final boolean isPrimitiveType = type instanceof PsiPrimitiveType;
return new JavaClassReferenceSet(trimmed, element, offset, false, CLASS_REFERENCE_PROVIDER) {
- protected JavaClassReference createReference(int refIndex, String subRefText, TextRange textRange, boolean staticImport) {
+ @NotNull
+ protected JavaClassReference createReference(int refIndex, @NotNull String subRefText, @NotNull TextRange textRange, boolean staticImport) {
return new JavaClassReference(this, textRange, refIndex, subRefText, staticImport) {
public boolean isSoft() {
return true;