diff --git a/colorSchemes/src/colorSchemes/Darcula.xml b/colorSchemes/src/colorSchemes/Darcula.xml
index 6025ff6f84b8..d960bd12830b 100644
--- a/colorSchemes/src/colorSchemes/Darcula.xml
+++ b/colorSchemes/src/colorSchemes/Darcula.xml
@@ -557,7 +557,7 @@
-
+
@@ -710,7 +710,7 @@
-
+
@@ -731,7 +731,7 @@
-
+
@@ -1367,7 +1367,6 @@
-
@@ -1486,16 +1485,16 @@
-
-
-
+
+
+
-
+
-
+
@@ -1511,10 +1510,20 @@
-
+
+
+
+
+
+
+
+
+
+
+
@@ -1580,14 +1589,13 @@
-
+
-
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompilerEncodingServiceImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompilerEncodingServiceImpl.java
index 34a49096f894..462a73375d3d 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/CompilerEncodingServiceImpl.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompilerEncodingServiceImpl.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.
@@ -60,6 +60,7 @@ public class CompilerEncodingServiceImpl extends CompilerEncodingService {
}, false);
}
+ @NotNull
private Map> computeModuleCharsetMap() {
final Map> map = new THashMap>();
final Map mappings = EncodingProjectManager.getInstance(myProject).getAllMappings();
diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/run/BuildArtifactsBeforeRunTaskProvider.java b/java/compiler/impl/src/com/intellij/packaging/impl/run/BuildArtifactsBeforeRunTaskProvider.java
index a111eaacbca3..0998927415be 100644
--- a/java/compiler/impl/src/com/intellij/packaging/impl/run/BuildArtifactsBeforeRunTaskProvider.java
+++ b/java/compiler/impl/src/com/intellij/packaging/impl/run/BuildArtifactsBeforeRunTaskProvider.java
@@ -15,7 +15,6 @@
*/
package com.intellij.packaging.impl.run;
-import com.intellij.compiler.impl.CompileScopeUtil;
import com.intellij.execution.BeforeRunTask;
import com.intellij.execution.BeforeRunTaskProvider;
import com.intellij.execution.RunManagerEx;
@@ -43,12 +42,10 @@ import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jps.api.CmdlineRemoteProto;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -191,7 +188,6 @@ public class BuildArtifactsBeforeRunTaskProvider extends BeforeRunTaskProvideremptyList());
ExecutionManagerImpl.EXECUTION_SESSION_ID_KEY.set(scope, ExecutionManagerImpl.EXECUTION_SESSION_ID_KEY.get(env));
manager.make(scope, CompilerFilter.ALL, callback);
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java
index bc093f7c233d..4c4375b53b87 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.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.
@@ -35,7 +35,6 @@ import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ExecutionEnvironmentBuilder;
import com.intellij.execution.runners.ProgramRunner;
-import com.intellij.execution.ui.ExecutionConsole;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.RunContentManager;
import com.intellij.execution.ui.RunContentWithExecutorListener;
@@ -158,7 +157,7 @@ public class DebuggerPanelsManager implements ProjectComponent {
@Override
public void contentSelected(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
if (executor == DefaultDebugExecutor.getDebugExecutorInstance()) {
- DebuggerSession session = descriptor == null ? null : getSession(myProject, descriptor.getExecutionConsole());
+ DebuggerSession session = descriptor == null ? null : getSession(myProject, descriptor);
if (session != null) {
getContextManager().setState(session.getContextManager().getContext(), session.getState(), DebuggerSession.EVENT_CONTEXT, null);
}
@@ -222,12 +221,13 @@ public class DebuggerPanelsManager implements ProjectComponent {
}
}
- private static DebuggerSession getSession(Project project, ExecutionConsole console) {
- XDebugSession session = XDebuggerManager.getInstance(project).getDebugSession(console);
- if (session != null) {
- XDebugProcess process = session.getDebugProcess();
- if (process instanceof JavaDebugProcess) {
- return ((JavaDebugProcess)process).getDebuggerSession();
+ private static DebuggerSession getSession(Project project, RunContentDescriptor descriptor) {
+ for (XDebugSession session : XDebuggerManager.getInstance(project).getDebugSessions()) {
+ if (session.getRunContentDescriptor().equals(descriptor)) {
+ XDebugProcess process = session.getDebugProcess();
+ if (process instanceof JavaDebugProcess) {
+ return ((JavaDebugProcess)process).getDebuggerSession();
+ }
}
}
return null;
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/RedundantLambdaCodeBlockInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/RedundantLambdaCodeBlockInspection.java
index 1b4fd9812238..6b45deb9654e 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/RedundantLambdaCodeBlockInspection.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/RedundantLambdaCodeBlockInspection.java
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.infos.CandidateInfo;
+import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.scope.conflictResolvers.JavaMethodsConflictResolver;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
@@ -87,8 +88,7 @@ public class RedundantLambdaCodeBlockInspection extends BaseJavaBatchLocalInspec
final List info = new ArrayList(Arrays.asList(candidates));
final LanguageLevel level = PsiUtil.getLanguageLevel(parent);
final JavaMethodsConflictResolver conflictResolver = new JavaMethodsConflictResolver((PsiExpressionList)parent, level);
- final int applicability = conflictResolver.checkApplicability(info);
- conflictResolver.checkSpecifics(info, applicability, level);
+ conflictResolver.checkSpecifics(info, MethodCandidateInfo.ApplicabilityLevel.FIXED_ARITY, level);
if (info.size() > 1) {
return;
}
diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java
index c092223ea47a..313718928ef4 100644
--- a/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java
+++ b/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java
@@ -50,31 +50,24 @@ import static com.intellij.psi.formatter.java.JavaFormatterUtil.getWrapType;
public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlock, ReservedWrapsProvider {
- /**
- * Holds types of the elements for which 'align in column' rule may be preserved.
- *
- * @see CodeStyleSettings#ALIGN_GROUP_FIELD_DECLARATIONS
- */
- protected static final Set ALIGN_IN_COLUMNS_ELEMENT_TYPES = Collections.unmodifiableSet(new HashSet(
- Arrays.asList(JavaElementType.FIELD)));
-
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.formatter.java.AbstractJavaBlock");
- /**
- * Shared thread-safe config object to use during 'align in column' processing.
- *
- * @see CodeStyleSettings#ALIGN_GROUP_FIELD_DECLARATIONS
- */
- private static final AlignmentInColumnsConfig ALIGNMENT_IN_COLUMNS_CONFIG = new AlignmentInColumnsConfig(
- TokenSet.create(JavaTokenType.IDENTIFIER), JavaJspElementType.WHITE_SPACE_BIT_SET, ElementType.JAVA_COMMENT_BIT_SET,
- TokenSet.create(JavaTokenType.EQ), TokenSet.create(JavaElementType.FIELD));
+ protected static final Set ALIGN_IN_COLUMNS_ELEMENT_TYPES = ContainerUtil.newHashSet(JavaElementType.FIELD);
- /**
- * Enumerates types of variable declaration sub-elements that should be aligned in columns.
- */
- private static final Set VAR_DECLARATION_ELEMENT_TYPES_TO_ALIGN = new HashSet(Arrays.asList(
- JavaElementType.MODIFIER_LIST, JavaElementType.TYPE, JavaTokenType.IDENTIFIER, JavaTokenType.EQ
- ));
+ private static final AlignmentInColumnsConfig ALIGNMENT_IN_COLUMNS_CONFIG = new AlignmentInColumnsConfig(
+ TokenSet.create(JavaTokenType.IDENTIFIER),
+ JavaJspElementType.WHITE_SPACE_BIT_SET,
+ ElementType.JAVA_COMMENT_BIT_SET,
+ TokenSet.create(JavaTokenType.EQ),
+ TokenSet.create(JavaElementType.FIELD)
+ );
+
+ private static final Set VAR_DECLARATION_ELEMENT_TYPES_TO_ALIGN = ContainerUtil.newHashSet(
+ JavaElementType.MODIFIER_LIST,
+ JavaElementType.TYPE,
+ JavaTokenType.IDENTIFIER,
+ JavaTokenType.EQ
+ );
@NotNull protected final CommonCodeStyleSettings mySettings;
@NotNull protected final JavaCodeStyleSettings myJavaSettings;
diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/SimpleJavaBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/SimpleJavaBlock.java
index 478f8ba8d065..06a2e136d659 100644
--- a/java/java-impl/src/com/intellij/psi/formatter/java/SimpleJavaBlock.java
+++ b/java/java-impl/src/com/intellij/psi/formatter/java/SimpleJavaBlock.java
@@ -50,7 +50,11 @@ public class SimpleJavaBlock extends AbstractJavaBlock {
@Override
protected List buildChildren() {
ASTNode child = myNode.getFirstChildNode();
- int offset = myStartOffset != -1 ? myStartOffset : child != null ? child.getTextRange().getStartOffset():0;
+ int offset = myStartOffset;
+ if (offset == -1) {
+ offset = child != null ? child.getTextRange().getStartOffset() : 0;
+ }
+
final ArrayList result = new ArrayList();
Indent indent = null;
@@ -71,11 +75,9 @@ public class SimpleJavaBlock extends AbstractJavaBlock {
myReservedAlignment2 = createChildAlignment2(myReservedAlignment);
Wrap childWrap = createChildWrap();
while (child != null) {
- if (!FormatterUtil.containsWhiteSpacesOnly(child) && child.getTextLength() > 0){
+ if (isNotEmptyNode(child)) {
final ASTNode astNode = child;
- AlignmentStrategy alignmentStrategyToUse = ALIGN_IN_COLUMNS_ELEMENT_TYPES.contains(myNode.getElementType())
- ? myAlignmentStrategy
- : AlignmentStrategy.wrap(chooseAlignment(myReservedAlignment, myReservedAlignment2, child));
+ AlignmentStrategy alignmentStrategyToUse = getAlignmentStrategy(child);
child = processChild(result, astNode, alignmentStrategyToUse, childWrap, indent, offset);
if (astNode != child && child != null) {
offset = child.getTextRange().getStartOffset();
@@ -86,6 +88,7 @@ public class SimpleJavaBlock extends AbstractJavaBlock {
indent = Indent.getContinuationIndent(myIndentSettings.USE_RELATIVE_INDENTS);
}
}
+
if (child != null) {
offset += child.getTextLength();
child = child.getTreeNext();
@@ -95,6 +98,16 @@ public class SimpleJavaBlock extends AbstractJavaBlock {
return result;
}
+ private AlignmentStrategy getAlignmentStrategy(ASTNode child) {
+ return ALIGN_IN_COLUMNS_ELEMENT_TYPES.contains(myNode.getElementType())
+ ? myAlignmentStrategy
+ : AlignmentStrategy.wrap(chooseAlignment(myReservedAlignment, myReservedAlignment2, child));
+ }
+
+ private boolean isNotEmptyNode(@NotNull ASTNode child) {
+ return !FormatterUtil.containsWhiteSpacesOnly(child) && child.getTextLength() > 0;
+ }
+
@Override
@NotNull
public TextRange getTextRange() {
diff --git a/java/java-psi-api/src/com/intellij/codeInsight/AnnotationUtil.java b/java/java-psi-api/src/com/intellij/codeInsight/AnnotationUtil.java
index 32553945cfc0..8987ed47d249 100644
--- a/java/java-psi-api/src/com/intellij/codeInsight/AnnotationUtil.java
+++ b/java/java-psi-api/src/com/intellij/codeInsight/AnnotationUtil.java
@@ -19,7 +19,9 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.*;
import com.intellij.util.ArrayUtil;
+import com.intellij.util.CommonProcessors;
import com.intellij.util.containers.ConcurrentFactoryMap;
+import com.intellij.util.containers.ContainerUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NonNls;
@@ -191,6 +193,30 @@ public class AnnotationUtil {
return result == null ? PsiAnnotation.EMPTY_ARRAY : result.toArray(new PsiAnnotation[result.size()]);
}
+ public static List getSuperAnnotationOwners(final T element) {
+ return CachedValuesManager.getCachedValue(element, new CachedValueProvider>() {
+ @Nullable
+ @Override
+ public Result> compute() {
+ LinkedHashSet result = ContainerUtil.newLinkedHashSet();
+ if (element instanceof PsiMethod) {
+ collectSuperMethods(result, ((PsiMethod)element).getHierarchicalMethodSignature(), element,
+ JavaPsiFacade.getInstance(element.getProject()).getResolveHelper());
+ } else if (element instanceof PsiClass) {
+ //noinspection unchecked
+ InheritanceUtil.processSupers((PsiClass)element, false, new CommonProcessors.CollectProcessor((Set)result));
+ } else if (element instanceof PsiParameter) {
+ collectSuperParameters(result, (PsiParameter)element);
+ }
+
+ List list = new ArrayList();
+ //noinspection unchecked
+ list.addAll((Collection extends T>)result);
+ return Result.create(list, PsiModificationTracker.MODIFICATION_COUNT);
+ }
+ });
+ }
+
@Nullable
public static PsiAnnotation findAnnotationInHierarchy(@NotNull final PsiModifierListOwner listOwner, @NotNull Set annotationNames) {
PsiAnnotation directAnnotation = findAnnotation(listOwner, annotationNames);
@@ -206,20 +232,11 @@ public class AnnotationUtil {
@Nullable
@Override
protected PsiAnnotation create(Set annotationNames) {
- if (listOwner instanceof PsiMethod) {
- PsiMethod method = (PsiMethod)listOwner;
- PsiClass aClass = method.getContainingClass();
- if (aClass == null) return null;
- HierarchicalMethodSignature methodSignature = method.getHierarchicalMethodSignature();
- return findAnnotationInHierarchy(methodSignature, annotationNames, method, null,
- JavaPsiFacade.getInstance(method.getProject()).getResolveHelper());
- }
- if (listOwner instanceof PsiClass) {
- return findAnnotationInHierarchy((PsiClass)listOwner, annotationNames, null);
- }
- if (listOwner instanceof PsiParameter) {
- PsiParameter parameter = (PsiParameter)listOwner;
- return doFindAnnotationInHierarchy(parameter, annotationNames, null);
+ for (PsiModifierListOwner superOwner : getSuperAnnotationOwners(listOwner)) {
+ PsiAnnotation annotation = findAnnotation(superOwner, annotationNames);
+ if (annotation != null) {
+ return annotation;
+ }
}
return null;
}
@@ -230,74 +247,36 @@ public class AnnotationUtil {
return map.get(annotationNames);
}
- @Nullable
- private static PsiAnnotation doFindAnnotationInHierarchy(@NotNull PsiParameter parameter,
- @NotNull Set annotationNames,
- @Nullable Set visited) {
- PsiAnnotation annotation = findAnnotation(parameter, annotationNames);
- if (annotation != null) return annotation;
+ private static void collectSuperParameters(LinkedHashSet result, @NotNull PsiParameter parameter) {
PsiElement scope = parameter.getDeclarationScope();
if (!(scope instanceof PsiMethod)) {
- return null;
+ return;
}
PsiMethod method = (PsiMethod)scope;
- PsiClass aClass = method.getContainingClass();
+
PsiElement parent = parameter.getParent();
- if (aClass == null || !(parent instanceof PsiParameterList)) {
- return null;
+ if (!(parent instanceof PsiParameterList)) {
+ return;
}
int index = ((PsiParameterList)parent).getParameterIndex(parameter);
- HierarchicalMethodSignature methodSignature = method.getHierarchicalMethodSignature();
-
- final List superSignatures = methodSignature.getSuperSignatures();
- PsiResolveHelper resolveHelper = PsiResolveHelper.SERVICE.getInstance(aClass.getProject());
- for (final HierarchicalMethodSignature superSignature : superSignatures) {
- final PsiMethod superMethod = superSignature.getMethod();
- if (visited == null) visited = new THashSet();
- if (!visited.add(superMethod)) continue;
- if (!resolveHelper.isAccessible(superMethod, parameter, null)) continue;
+ for (PsiMethod superMethod : getSuperAnnotationOwners(method)) {
PsiParameter[] superParameters = superMethod.getParameterList().getParameters();
if (index < superParameters.length) {
- PsiAnnotation insuper = doFindAnnotationInHierarchy(superParameters[index], annotationNames, visited);
- if (insuper != null) return insuper;
+ result.add(superParameters[index]);
}
}
- return null;
}
- @Nullable
- private static PsiAnnotation findAnnotationInHierarchy(@NotNull final PsiClass psiClass, @NotNull Set annotationNames, @Nullable Set processed) {
- final PsiClass[] superClasses = psiClass.getSupers();
- for (final PsiClass superClass : superClasses) {
- if (processed == null) processed = new THashSet();
- if (!processed.add(superClass)) return null;
- final PsiAnnotation annotation = findAnnotation(superClass, annotationNames);
- if (annotation != null) return annotation;
- final PsiAnnotation annotationInHierarchy = findAnnotationInHierarchy(superClass, annotationNames, processed);
- if (annotationInHierarchy != null) return annotationInHierarchy;
- }
- return null;
- }
-
- @Nullable
- private static PsiAnnotation findAnnotationInHierarchy(@NotNull HierarchicalMethodSignature signature,
- @NotNull Set annotationNames,
- @NotNull PsiElement place,
- @Nullable Set processed,
- @NotNull PsiResolveHelper resolveHelper) {
- final List superSignatures = signature.getSuperSignatures();
- for (final HierarchicalMethodSignature superSignature : superSignatures) {
+ private static void collectSuperMethods(LinkedHashSet result,
+ @NotNull HierarchicalMethodSignature signature,
+ @NotNull PsiElement place,
+ @NotNull PsiResolveHelper resolveHelper) {
+ for (final HierarchicalMethodSignature superSignature : signature.getSuperSignatures()) {
final PsiMethod superMethod = superSignature.getMethod();
- if (processed == null) processed = new THashSet();
- if (!processed.add(superMethod)) continue;
if (!resolveHelper.isAccessible(superMethod, place, null)) continue;
- PsiAnnotation direct = findAnnotation(superMethod, annotationNames);
- if (direct != null) return direct;
- PsiAnnotation superResult = findAnnotationInHierarchy(superSignature, annotationNames, place, processed, resolveHelper);
- if (superResult != null) return superResult;
+ if (!result.add(superMethod)) continue;
+ collectSuperMethods(result, superSignature, place, resolveHelper);
}
-
- return null;
}
public static boolean isAnnotated(@NotNull PsiModifierListOwner listOwner, @NotNull Collection annotations) {
diff --git a/java/java-psi-api/src/com/intellij/codeInsight/InferredAnnotationsManager.java b/java/java-psi-api/src/com/intellij/codeInsight/InferredAnnotationsManager.java
index 9ff366aaa7ce..6c2db7a9b952 100644
--- a/java/java-psi-api/src/com/intellij/codeInsight/InferredAnnotationsManager.java
+++ b/java/java-psi-api/src/com/intellij/codeInsight/InferredAnnotationsManager.java
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
- * Returns annotations inferred by bytecode our source code, for example contracts and nullity.
+ * Returns annotations inferred by bytecode or source code, for example contracts and nullity.
*
* @see com.intellij.codeInsight.NullableNotNullManager
* @see org.jetbrains.annotations.Contract
diff --git a/java/java-psi-api/src/com/intellij/codeInsight/NullableNotNullManager.java b/java/java-psi-api/src/com/intellij/codeInsight/NullableNotNullManager.java
index 403043d38952..59f0a010d4d8 100644
--- a/java/java-psi-api/src/com/intellij/codeInsight/NullableNotNullManager.java
+++ b/java/java-psi-api/src/com/intellij/codeInsight/NullableNotNullManager.java
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizableStringList;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.*;
+import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jdom.Element;
@@ -167,16 +168,30 @@ public class NullableNotNullManager implements PersistentStateComponent
myDefaultNotNull = defaultNotNull;
}
+ private static boolean skipAnnotation(@NotNull PsiAnnotation annotation, @NotNull PsiModifierListOwner owner) {
+ return owner instanceof PsiMethod &&
+ PsiUtil.canBeOverriden((PsiMethod)owner) &&
+ AnnotationUtil.isInferredAnnotation(annotation) &&
+ AnnotationUtil.NOT_NULL.equals(annotation.getQualifiedName());
+ }
+
@Nullable
private PsiAnnotation findNullabilityAnnotation(@NotNull PsiModifierListOwner owner, boolean checkBases, boolean nullable) {
Set qNames = ContainerUtil.newHashSet(nullable ? getNullables() : getNotNulls());
- PsiAnnotation annotation = checkBases && (owner instanceof PsiClass || owner instanceof PsiMethod)
- ? AnnotationUtil.findAnnotationInHierarchy(owner, qNames)
- : AnnotationUtil.findAnnotation(owner, qNames);
- if (annotation != null) {
+ PsiAnnotation annotation = AnnotationUtil.findAnnotation(owner, qNames);
+ if (annotation != null && !skipAnnotation(annotation, owner)) {
return annotation;
}
+ if (checkBases && owner instanceof PsiMethod) {
+ for (PsiModifierListOwner superOwner : AnnotationUtil.getSuperAnnotationOwners(owner)) {
+ annotation = AnnotationUtil.findAnnotation(superOwner, qNames);
+ if (annotation != null && !skipAnnotation(annotation, superOwner)) {
+ return annotation;
+ }
+ }
+ }
+
PsiType type = getOwnerType(owner);
if (type == null || TypeConversionUtil.isPrimitiveAndNotNull(type)) return null;
@@ -302,6 +317,7 @@ public class NullableNotNullManager implements PersistentStateComponent
}
try {
+ //noinspection deprecation
DefaultJDOMExternalizer.writeExternal(this, component);
}
catch (WriteExternalException e) {
@@ -313,6 +329,7 @@ public class NullableNotNullManager implements PersistentStateComponent
@Override
public void loadState(Element state) {
try {
+ //noinspection deprecation
DefaultJDOMExternalizer.readExternal(this, state);
if (myNullables.isEmpty()) {
Collections.addAll(myNullables, DEFAULT_NULLABLES);
diff --git a/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java b/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java
index 820d9bccd36e..7f707200d6c6 100644
--- a/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/LambdaUtil.java
@@ -18,6 +18,7 @@ package com.intellij.psi;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.infos.MethodCandidateInfo;
import com.intellij.psi.util.*;
@@ -493,6 +494,31 @@ public class LambdaUtil {
return expression;
}
+ // http://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.12.2.1
+ // A lambda expression or a method reference expression is potentially compatible with a type variable
+ // if the type variable is a type parameter of the candidate method.
+ public static boolean isPotentiallyCompatibleWithTypeParameter(PsiFunctionalExpression expression,
+ PsiExpressionList argsList,
+ PsiMethod method) {
+ if (!Registry.is("JDK8042508.bug.fixed", false)) {
+ final PsiCallExpression callExpression = PsiTreeUtil.getParentOfType(argsList, PsiCallExpression.class);
+ if (callExpression == null || callExpression.getTypeArguments().length > 0) {
+ return false;
+ }
+ }
+
+ final int lambdaIdx = getLambdaIdx(argsList, expression);
+ if (lambdaIdx >= 0) {
+ final PsiParameter[] parameters = method.getParameterList().getParameters();
+ final PsiParameter lambdaParameter = parameters[Math.min(lambdaIdx, parameters.length - 1)];
+ final PsiClass paramClass = PsiUtil.resolveClassInType(lambdaParameter.getType());
+ if (paramClass instanceof PsiTypeParameter && ((PsiTypeParameter)paramClass).getOwner() == method) {
+ return true;
+ }
+ }
+ return false;
+ }
+
public static class TypeParamsChecker extends PsiTypeVisitor {
private PsiMethod myMethod;
private final PsiClass myClass;
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpression.java b/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpression.java
index a59d1e50f35e..459b9d176af9 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpression.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiLambdaExpression.java
@@ -46,6 +46,4 @@ public interface PsiLambdaExpression extends PsiFunctionalExpression {
* @return true when lambda declares parameter types explicitly
*/
boolean hasFormalParameterTypes();
-
- boolean isAcceptable(PsiType leftType, boolean checkReturnType);
}
diff --git a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
index abe12f445a38..3347d8319c53 100644
--- a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java
@@ -178,7 +178,7 @@ public class PsiMethodReferenceUtil {
PsiClassType.ClassResolveResult result = PsiUtil.resolveGenericsClassInType(type);
containingClass = result.getElement();
if (containingClass != null) {
- substitutor = result.getSubstitutor();
+ return new QualifierResolveResult(containingClass, result.getSubstitutor(), true);
}
}
}
diff --git a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java
index 1041b9fa1c71..3213970cc260 100644
--- a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java
@@ -731,7 +731,7 @@ public class TypeConversionUtil {
final PsiType lType = lLambdaExpression.getFunctionalInterfaceType();
return Comparing.equal(rType, lType);
}
- return !(left instanceof PsiArrayType) && rLambdaExpression.isAcceptable(left, false);
+ return !(left instanceof PsiArrayType) && rLambdaExpression.isAcceptable(left);
}
if (left instanceof PsiIntersectionType) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java
index 738b835a527d..364017055c98 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java
@@ -18,7 +18,6 @@ package com.intellij.psi.impl.source.tree.java;
import com.intellij.icons.AllIcons;
import com.intellij.lang.ASTNode;
import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.controlFlow.*;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.impl.source.resolve.graphInference.FunctionalInterfaceParameterizationUtil;
@@ -34,6 +33,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
+import java.util.HashMap;
+import java.util.Map;
public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements PsiLambdaExpression {
@@ -168,35 +169,35 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
}
@Override
- public boolean isAcceptable(PsiType left) {
- return isAcceptable(left, false);
- }
-
- @Override
- public boolean isAcceptable(PsiType leftType, boolean checkReturnType) {
+ public boolean isAcceptable(PsiType leftType) {
if (leftType instanceof PsiIntersectionType) {
for (PsiType conjunctType : ((PsiIntersectionType)leftType).getConjuncts()) {
- if (isAcceptable(conjunctType, checkReturnType)) return true;
+ if (isAcceptable(conjunctType)) return true;
}
return false;
}
- final PsiElement argsList = PsiTreeUtil.getParentOfType(this, PsiExpressionList.class);
- if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList)) {
- if (!hasFormalParameterTypes()) {
- return true;
- }
- final MethodCandidateInfo.CurrentCandidateProperties candidateProperties = MethodCandidateInfo.getCurrentMethod(argsList);
- if (candidateProperties != null && !InferenceSession.isPertinentToApplicability(this, candidateProperties.getMethod())) {
- return true;
- }
- }
+ final PsiExpressionList argsList = PsiTreeUtil.getParentOfType(this, PsiExpressionList.class);
leftType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(leftType, this);
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(leftType);
final PsiClass psiClass = resolveResult.getElement();
if (psiClass instanceof PsiAnonymousClass) {
- return isAcceptable(((PsiAnonymousClass)psiClass).getBaseClassType(), checkReturnType);
+ return isAcceptable(((PsiAnonymousClass)psiClass).getBaseClassType());
+ }
+
+ if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList)) {
+ final MethodCandidateInfo.CurrentCandidateProperties candidateProperties = MethodCandidateInfo.getCurrentMethod(argsList);
+ if (candidateProperties != null) {
+ final PsiMethod method = candidateProperties.getMethod();
+ if (!InferenceSession.isPertinentToApplicability(this, method) && hasFormalParameterTypes()) {
+ return true;
+ }
+
+ if (LambdaUtil.isPotentiallyCompatibleWithTypeParameter(this, argsList, method)) {
+ return true;
+ }
+ }
}
final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
@@ -206,56 +207,77 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, resolveResult);
assert leftType != null;
- final PsiParameter[] lambdaParameters = getParameterList().getParameters();
- final PsiType[] parameterTypes = interfaceMethod.getSignature(substitutor).getParameterTypes();
- if (lambdaParameters.length != parameterTypes.length) return false;
+ if (!isPotentiallyCompatible(leftType)) {
+ return false;
+ }
- for (int lambdaParamIdx = 0, length = lambdaParameters.length; lambdaParamIdx < length; lambdaParamIdx++) {
- PsiParameter parameter = lambdaParameters[lambdaParamIdx];
- final PsiTypeElement typeElement = parameter.getTypeElement();
- if (typeElement != null) {
- final PsiType lambdaFormalType = toArray(typeElement.getType());
- final PsiType methodParameterType = toArray(parameterTypes[lambdaParamIdx]);
- if (!lambdaFormalType.equals(methodParameterType)) {
- return false;
+ if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList) && !hasFormalParameterTypes()) {
+ return true;
+ }
+
+
+
+ if (hasFormalParameterTypes()) {
+ final PsiParameter[] lambdaParameters = getParameterList().getParameters();
+ final PsiType[] parameterTypes = interfaceMethod.getSignature(substitutor).getParameterTypes();
+ for (int lambdaParamIdx = 0, length = lambdaParameters.length; lambdaParamIdx < length; lambdaParamIdx++) {
+ PsiParameter parameter = lambdaParameters[lambdaParamIdx];
+ final PsiTypeElement typeElement = parameter.getTypeElement();
+ if (typeElement != null) {
+ final PsiType lambdaFormalType = toArray(typeElement.getType());
+ final PsiType methodParameterType = toArray(parameterTypes[lambdaParamIdx]);
+ if (!lambdaFormalType.equals(methodParameterType)) {
+ return false;
+ }
}
}
}
-
- //A lambda expression (§15.27) is potentially compatible with a functional interface type (§9.8) if all of the following are true:
- // The arity of the target type's function type is the same as the arity of the lambda expression.
- // If the target type's function type has a void return, then the lambda body is either a statement expression (§14.8) or a void-compatible block (§15.27.2).
- // If the target type's function type has a (non-void) return type, then the lambda body is either an expression or a value-compatible block (§15.27.2).
PsiType methodReturnType = interfaceMethod.getReturnType();
- if (checkReturnType) {
- final String uniqueVarName = JavaCodeStyleManager.getInstance(getProject()).suggestUniqueVariableName("l", this, true);
- final String canonicalText = toArray(leftType).getCanonicalText();
- final PsiStatement assignmentFromText = JavaPsiFacade.getElementFactory(getProject())
- .createStatementFromText(canonicalText + " " + uniqueVarName + " = " + getText(), this);
- final PsiLocalVariable localVariable = (PsiLocalVariable)((PsiDeclarationStatement)assignmentFromText).getDeclaredElements()[0];
- if (methodReturnType != null) {
- return LambdaHighlightingUtil.checkReturnTypeCompatible((PsiLambdaExpression)localVariable.getInitializer(),
- substitutor.substitute(methodReturnType)) == null;
+ if (methodReturnType != null && methodReturnType != PsiType.VOID) {
+ Map map = LambdaUtil.ourFunctionTypes.get();
+ if (map == null) {
+ map = new HashMap();
+ LambdaUtil.ourFunctionTypes.set(map);
}
- } else {
- final PsiElement body = getBody();
- if (methodReturnType == PsiType.VOID) {
- if (body instanceof PsiCodeBlock) {
- return isVoidCompatible();
- } else {
- return LambdaUtil.isExpressionStatementExpression(body);
+ try {
+ if (map.put(this, leftType) != null) {
+ return false;
}
- } else {
- if (body instanceof PsiCodeBlock) {
- return isValueCompatible();
- }
- return body instanceof PsiExpression;
+ return LambdaHighlightingUtil.checkReturnTypeCompatible(this, substitutor.substitute(methodReturnType)) == null;
+ }
+ finally {
+ map.remove(this);
}
}
return true;
}
+ //A lambda expression (§15.27) is potentially compatible with a functional interface type (§9.8) if all of the following are true:
+ // The arity of the target type's function type is the same as the arity of the lambda expression.
+ // If the target type's function type has a void return, then the lambda body is either a statement expression (§14.8) or a void-compatible block (§15.27.2).
+ // If the target type's function type has a (non-void) return type, then the lambda body is either an expression or a value-compatible block (§15.27.2).
+ private boolean isPotentiallyCompatible(PsiType left) {
+ final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(left);
+ if (interfaceMethod == null) return false;
+
+ if (getParameterList().getParametersCount() != interfaceMethod.getParameterList().getParametersCount()) {
+ return false;
+ }
+ final PsiType methodReturnType = interfaceMethod.getReturnType();
+ final PsiElement body = getBody();
+ if (methodReturnType == PsiType.VOID) {
+ if (body instanceof PsiCodeBlock) {
+ return isVoidCompatible();
+ } else {
+ return LambdaUtil.isExpressionStatementExpression(body);
+ }
+ }
+ else {
+ return body instanceof PsiCodeBlock && isValueCompatible() || body instanceof PsiExpression;
+ }
+ }
+
private static PsiType toArray(PsiType paramType) {
if (paramType instanceof PsiEllipsisType) {
return ((PsiEllipsisType)paramType).toArrayType();
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java
index 6484898731f7..32545c51df0d 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.impl.source.resolve.graphInference.FunctionalInterfaceParameterizationUtil;
@@ -97,8 +98,8 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
final PsiElement element = resolveResult.getElement();
if (element instanceof PsiMethod) {
final boolean isStatic = ((PsiMethod)element).hasModifierProperty(PsiModifier.STATIC);
+ final int parametersCount = ((PsiMethod)element).getParameterList().getParametersCount();
if (qualifierResolveResult.isReferenceTypeQualified() && getReferenceNameElement() instanceof PsiIdentifier) {
- final int parametersCount = ((PsiMethod)element).getParameterList().getParametersCount();
if (parametersCount == interfaceArity && isStatic) {
return true;
}
@@ -106,8 +107,11 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
return true;
}
if (((PsiMethod)element).isVarArgs()) return true;
- } else if (!isStatic) {
- return true;
+ }
+ else if (!isStatic) {
+ if (parametersCount == interfaceArity || ((PsiMethod)element).isVarArgs()) {
+ return true;
+ }
}
} else if (element instanceof PsiClass) {
return true;
@@ -370,12 +374,19 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
return false;
}
- final PsiElement argsList = PsiTreeUtil.getParentOfType(this, PsiExpressionList.class);
+ final PsiExpressionList argsList = PsiTreeUtil.getParentOfType(this, PsiExpressionList.class);
final boolean isExact = isExact();
- if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList) && isExact) {
+ if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList)) {
final MethodCandidateInfo.CurrentCandidateProperties candidateProperties = MethodCandidateInfo.getCurrentMethod(argsList);
- if (candidateProperties != null && !InferenceSession.isPertinentToApplicability(this, candidateProperties.getMethod())) {
- return true;
+ if (candidateProperties != null) {
+ final PsiMethod method = candidateProperties.getMethod();
+ if (isExact && !InferenceSession.isPertinentToApplicability(this, method)) {
+ return true;
+ }
+
+ if (LambdaUtil.isPotentiallyCompatibleWithTypeParameter(this, argsList, method)) {
+ return true;
+ }
}
}
diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
index f5b690863957..99e577b8506c 100644
--- a/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
+++ b/java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
@@ -33,6 +33,7 @@ import com.intellij.util.containers.HashSet;
import gnu.trove.THashMap;
import gnu.trove.THashSet;
import gnu.trove.TIntArrayList;
+import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -91,9 +92,6 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
// then noone can be more specific
if (!atLeastOneMatch) return null;
- checkLambdaApplicable(conflicts, myLanguageLevel);
- if (conflicts.size() == 1) return conflicts.get(0);
-
checkSpecifics(conflicts, applicabilityLevel, myLanguageLevel);
if (conflicts.size() == 1) return conflicts.get(0);
@@ -108,63 +106,6 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
return null;
}
- private void checkLambdaApplicable(@NotNull List conflicts, @NotNull LanguageLevel languageLevel) {
- if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) return;
- for (int i = 0; i < getActualParametersLength(); i++) {
-
- PsiExpression expression;
- if (myArgumentsList instanceof PsiExpressionList) {
- expression = ((PsiExpressionList)myArgumentsList).getExpressions()[i];
- }
- else {
- final PsiType argType = getActualParameterTypes()[i];
- expression = argType instanceof PsiLambdaExpressionType ? ((PsiLambdaExpressionType)argType).getExpression() : null;
- }
-
- final PsiLambdaExpression lambdaExpression = findNestedLambdaExpression(expression);
- if (lambdaExpression != null) {
- checkLambdaApplicable(conflicts, i, lambdaExpression);
- }
- }
- }
-
- private static PsiLambdaExpression findNestedLambdaExpression(PsiExpression expression) {
- if (expression instanceof PsiLambdaExpression) {
- return (PsiLambdaExpression)expression;
- }
- else if (expression instanceof PsiParenthesizedExpression) {
- return findNestedLambdaExpression(((PsiParenthesizedExpression)expression).getExpression());
- }
- else if (expression instanceof PsiConditionalExpression) {
- PsiLambdaExpression lambdaExpression = findNestedLambdaExpression(((PsiConditionalExpression)expression).getThenExpression());
- if (lambdaExpression != null) {
- return lambdaExpression;
- }
- return findNestedLambdaExpression(((PsiConditionalExpression)expression).getElseExpression());
- }
- return null;
- }
-
- private static void checkLambdaApplicable(@NotNull List conflicts, int i, @NotNull PsiLambdaExpression lambdaExpression) {
- for (Iterator iterator = conflicts.iterator(); iterator.hasNext(); ) {
- ProgressManager.checkCanceled();
- final CandidateInfo conflict = iterator.next();
- final PsiMethod method = (PsiMethod)conflict.getElement();
- final PsiParameter[] methodParameters = method.getParameterList().getParameters();
- if (methodParameters.length == 0) continue;
- final PsiParameter param = i < methodParameters.length ? methodParameters[i] : methodParameters[methodParameters.length - 1];
- final PsiType paramType = param.getType();
- // http://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.12.2.1
- // A lambda expression or a method reference expression is potentially compatible with a type variable if the type variable is a type parameter of the candidate method.
- final PsiClass paramClass = PsiUtil.resolveClassInType(paramType);
- if (paramClass instanceof PsiTypeParameter && ((PsiTypeParameter)paramClass).getOwner() == method) continue;
- if (!lambdaExpression.isAcceptable(((MethodCandidateInfo)conflict).getSubstitutor(false).substitute(paramType),
- InferenceSession.isPertinentToApplicability(lambdaExpression, method))) {
- iterator.remove();
- }
- }
- }
-
public void checkSpecifics(@NotNull List conflicts,
@MethodCandidateInfo.ApplicabilityLevelConstant int applicabilityLevel,
@NotNull LanguageLevel languageLevel) {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityReturnValueResolution2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityReturnValueResolution2.java
index a178b4d970d8..83db64423f6f 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityReturnValueResolution2.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/AmbiguityReturnValueResolution2.java
@@ -20,7 +20,7 @@ public class Test {
public static void main(String[] args) {
Inner inn = new Inner<>();
inn.m8(p -> 1.0);
- new Test().foo(p -> 1.0);
+ new Test().foo(p -> 1.0);
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ConflictResolution.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ConflictResolution.java
index 0cc3741e0f61..6fbdbd116855 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ConflictResolution.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ConflictResolution.java
@@ -1,7 +1,7 @@
class Demo {
public void f1() {
- f2(2, input -> input);
+ f2(2, input -> input);
}
public void f2() {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility.java
index 10cd3fffeb86..cdddcba60c36 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility.java
@@ -25,7 +25,7 @@ class ReturnTypeIncompatibility {
}
public static void main(String[] args) {
- call(i-> {return i;});
+ call(i-> {return i;});
}
}
@@ -57,7 +57,7 @@ class ReturnTypeCompatibility {
}
public static void main(String[] args) {
- call(i-> {return i;});
+ call(i-> {return i;});
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility1.java
index d62afb3fdfcd..55bf990960ef 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility1.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/ReturnTypeCompatibility1.java
@@ -21,9 +21,9 @@ class Test {
}
void foo(Foo as, final Foo ac) {
- boolean b1 = as.forAll(s -> ac.forAll(c -> false));
- String s1 = as.forAll(s -> ac.forAll(c -> ""));
- boolean b2 = as.forAll(s -> ac.forAll(c -> ""));
+ boolean b1 = as.forAll(s -> ac.forAll(c -> false));
+ String s1 = as.forAll(s -> ac.forAll(c -> ""));
+ boolean b2 = as.forAll(s -> ac.forAll(c -> ""));
String s2 = as.forAll2(s -> ac.forAll2(c -> false));
boolean b3 = as.forAll((I)s -> ac.forAll((I)c -> ""));
String s3 = as.forAll((II)s -> ac.forAll((II)c -> false));
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/PotentialCompatibilityWithInvalidShape.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/PotentialCompatibilityWithInvalidShape.java
new file mode 100644
index 000000000000..3cfa72c6ee2e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/PotentialCompatibilityWithInvalidShape.java
@@ -0,0 +1,40 @@
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.function.Function;
+class Test {
+ private List query(String request) {
+ System.out.println(request);
+ return null;
+ }
+ private List query(String request, Object context) {
+ System.out.println(request + context);
+ return null;
+ }
+
+ private List query1(){ return null;}
+ private List query1(String request) {
+ System.out.println(request);
+ return null;
+ }
+ private List query1(String request, Object context) {
+ System.out.println(request + context);
+ return null;
+ }
+
+ private static Set replyWith(Function> futureFn){
+ System.out.println(futureFn);
+ return null;
+ }
+ private static Set replyWith(Callable> fn) {
+ System.out.println(fn);
+ return null;
+ }
+
+ {
+ Set m = replyWith(this::query);
+ System.out.println(m);
+ Set m1 = replyWith(this::query1);
+ System.out.println(m1);
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/IDEA102800.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/IDEA102800.java
index 7c2cc7bdae5e..299c620daeb2 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/IDEA102800.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/IDEA102800.java
@@ -14,7 +14,7 @@ class Test {
}
void fooBar(IntStream1 instr){
- Supplier> si = () -> instr.map ((i) -> (( i % 2) == 0) ? i : -i).boxed();
+ Supplier> si = () -> instr.map ((i) -> (( i % 2) == 0) ? i : -i).boxed();
System.out.println(si);
Supplier> si1 = () -> instr.map (null).boxed();
System.out.println(si1);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/PertinentToApplicabilityOfExplicitlyTypedLambda.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/PertinentToApplicabilityOfExplicitlyTypedLambda.java
index 348108fc3443..adaea236cd62 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/PertinentToApplicabilityOfExplicitlyTypedLambda.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/PertinentToApplicabilityOfExplicitlyTypedLambda.java
@@ -12,6 +12,6 @@ abstract class PertinentToApplicabilityOfExplicitlyTypedLambdaTest {
abstract void foo(B b);
{
- foo(x -> y -> 42);
+ foo(x -> y -> 42);
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/VoidValueCompatibilityOfImplicitlyTypedLambda.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/VoidValueCompatibilityOfImplicitlyTypedLambda.java
index 1188a9584dca..443f6339121d 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/VoidValueCompatibilityOfImplicitlyTypedLambda.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/VoidValueCompatibilityOfImplicitlyTypedLambda.java
@@ -14,10 +14,10 @@ abstract class Test {
foo(x -> {
return x += 1;
});
- foo(x -> x += 1);
+ foo(x -> x += 1);
foo(x -> 1);
foo(x -> !x);
- foo(x -> ++x);
+ foo(x -> ++x);
foo(x -> o instanceof String ? 1 : 0);
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/MethodApplicability.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/MethodApplicability.java
index 81c52a8cb7e6..aa18671e3f48 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/MethodApplicability.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/params/MethodApplicability.java
@@ -26,9 +26,9 @@ class Foo {
System.out.println(s);
});
- foo((String p, String k) -> {
+ foo((String p, String k) -> {
System.out.println(p);
- });
+ });
}
}
@@ -62,7 +62,7 @@ class WithTypeParams {
System.out.println(p);
});
- foo((int k) -> {System.out.println(k);});
+ foo((int k) -> {System.out.println(k);});
}
}
}
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/OverridingInferredNotNullMethod.java b/java/java-tests/testData/inspection/dataFlow/fixture/OverridingInferredNotNullMethod.java
new file mode 100644
index 000000000000..8e2cb1617908
--- /dev/null
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/OverridingInferredNotNullMethod.java
@@ -0,0 +1,12 @@
+import org.jetbrains.annotations.Nullable;
+
+class City {
+ @Nullable
+ private String name;
+
+ @Override
+ @Nullable
+ public String toString() {
+ return name;
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java
index 41559703426b..fad273396623 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
@@ -100,7 +101,9 @@ public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase {
}
public void testJDK8042508() throws Exception {
- doTest(false);
+ if (Registry.is("JDK8042508.bug.fixed", false)) {
+ doTest(false);
+ }
}
public void testIDEA125855() throws Exception {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
index 46d8e65308a9..d8b949ec87ba 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
@@ -334,6 +334,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest(true);
}
+ public void testPotentialCompatibilityWithInvalidShape() throws Exception {
+ doTest(true);
+ }
+
private void doTest() {
doTest(false);
}
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
index 971004403a20..4276d58e24c7 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
@@ -268,6 +268,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
public void testSameComparisonTwice() { doTest(); }
public void testRootThrowableCause() { doTest(); }
+ public void testOverridingInferredNotNullMethod() { doTest(); }
public void testUseInferredContracts() { doTest(); }
public void testContractWithNoArgs() { doTest(); }
public void testContractInferenceBewareOverriding() { doTest(); }
diff --git a/java/java-tests/testSrc/com/intellij/index/IndexTestGenerator.scala b/java/java-tests/testSrc/com/intellij/index/IndexTestGenerator.scala
index b28b998e65d5..a7327bdfbfe6 100644
--- a/java/java-tests/testSrc/com/intellij/index/IndexTestGenerator.scala
+++ b/java/java-tests/testSrc/com/intellij/index/IndexTestGenerator.scala
@@ -44,11 +44,13 @@ object IndexTestGenerator {
const(InvisiblePsiChange),
const(PostponedFormatting),
const(Reformat),
- const(LoadViewProviderDocument),
+ const(ForceReloadPsi),
+ const(AddEnum),
const(CheckStamps),
for (withImport <- arbitrary[Boolean];
viaDocument <- arbitrary[Boolean])
yield TextChange(viaDocument, withImport),
+ arbitrary[Boolean] map ChangeLanguageLevel,
arbitrary[Boolean] map UpdatePsiClassRef,
arbitrary[Boolean] map UpdatePsiFileRef,
arbitrary[Boolean] map UpdateASTNodeRef,
@@ -97,18 +99,26 @@ case class IndexTestSeq(actions: List[Action]) {
|""".stripMargin)
}
+ def printPostponedFormatting = sb.append(
+ """PostprocessReformattingAspect.getInstance(getProject()).
+ | doPostponedFormatting()
+ |""".stripMargin)
+
+
for (action <- actions) {
sb.append("\n")
action match {
case Gc =>
sb.append("PlatformTestUtil.tryGcSoftlyReachableObjects()\n")
- case LoadViewProviderDocument =>
- sb.append("assert psiManager.findFile(vFile).viewProvider.document\n")
case PostponedFormatting =>
- sb.append(
- """PostprocessReformattingAspect.getInstance(getProject()).
- | doPostponedFormatting()
- |""".stripMargin)
+ printPostponedFormatting
+ case ForceReloadPsi =>
+ printPostponedFormatting
+ sb.append("FileContentUtilCore.reparseFiles(vFile)\n")
+ case ChangeLanguageLevel(highest) =>
+ printPostponedFormatting
+ val level = if (highest) "HIGHEST" else "JDK_1_3"
+ sb.append(s"IdeaTestUtil.setModuleLanguageLevel(myFixture.module, LanguageLevel.$level)\n")
case CheckStamps =>
sb.append(
"""L:{
@@ -147,6 +157,12 @@ case class IndexTestSeq(actions: List[Action]) {
s"""((PsiJavaFile)psiManager.findFile(vFile)).importList.add(
| elementFactory.createImportStatementOnDemand("java.io"))
|""".stripMargin)
+ case AddEnum =>
+ printCommit
+ sb.append(
+ s"""psiManager.findFile(vFile).add(
+ | elementFactory.createEnum("SomeEnum"))
+ |""".stripMargin)
case InvisiblePsiChange =>
printCommit
sb.append(
@@ -167,14 +183,13 @@ case class IndexTestSeq(actions: List[Action]) {
case UpdateDocumentRef(load) =>
sb.append("document = " + (if (load) "FileDocumentManager.instance.getDocument(vFile)" else "null") + "\n")
case TextChange(viaDocument, withImport) =>
+ printPostponedFormatting
changeId += 1
docClassName = "Foo" + changeId
val newText = (if (withImport) "import zoo.Zoo; " else "") + s"class $docClassName {\\n }"
sb.append(
- """PostprocessReformattingAspect.getInstance(getProject()).
- | doPostponedFormatting()
- |counterBefore =
+ """counterBefore =
| psiManager.modificationTracker.javaStructureModificationCount
|""".stripMargin)
@@ -214,13 +229,14 @@ case class IndexTestSeq(actions: List[Action]) {
|import com.intellij.openapi.fileEditor.FileDocumentManager
|import com.intellij.openapi.util.Ref
|import com.intellij.openapi.vfs.VfsUtil
+ |import com.intellij.pom.java.*
|import com.intellij.psi.*
|import com.intellij.psi.codeStyle.*
|import com.intellij.psi.impl.source.*
|import com.intellij.psi.search.GlobalSearchScope
- |import com.intellij.testFramework.PlatformTestUtil
+ |import com.intellij.testFramework.*
|import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
- |import com.intellij.util.ObjectUtils
+ |import com.intellij.util.*
|import com.intellij.openapi.fileEditor.impl.LoadTextUtil
|import org.jetbrains.annotations.NotNull
|class DummyTest extends JavaCodeInsightFixtureTestCase {
@@ -264,5 +280,7 @@ case object PsiChange extends Action
case object InvisiblePsiChange extends Action
case object PostponedFormatting extends Action
case object Reformat extends Action
-case object LoadViewProviderDocument extends Action
case object CheckStamps extends Action
+case object ForceReloadPsi extends Action
+case object AddEnum extends Action
+case class ChangeLanguageLevel(highest: Boolean) extends Action
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameHddTest.groovy b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameHddTest.groovy
index 5b3e868ecda0..5aba6a066f02 100644
--- a/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameHddTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/navigation/ChooseByNameHddTest.groovy
@@ -17,6 +17,7 @@ package com.intellij.navigation
import com.intellij.ide.actions.GotoFileItemProvider
import com.intellij.ide.util.gotoByName.ChooseByNamePopup
import com.intellij.ide.util.gotoByName.GotoFileModel
+import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.util.io.FileUtil
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
import org.jetbrains.annotations.NotNull
@@ -27,12 +28,16 @@ class ChooseByNameHddTest extends JavaCodeInsightFixtureTestCase {
public void "test go to file by full path"() {
def psiFile = myFixture.addFileToProject("foo/index.html", "foo")
- def path = psiFile.virtualFile.path
+ def vFile = psiFile.virtualFile
+ def path = vFile.path
- def popup = ChooseByNamePopup.createPopup(project, new GotoFileModel(project), new GotoFileItemProvider(project, null))
- assert ChooseByNameTest.calcPopupElements(popup, path) == [psiFile]
- assert ChooseByNameTest.calcPopupElements(popup, FileUtil.toSystemDependentName(path)) == [psiFile]
- popup.close(false)
+ ApplicationManager.application.runReadAction {
+ def popup = ChooseByNamePopup.createPopup(project, new GotoFileModel(project), new GotoFileItemProvider(project, null))
+ assert ChooseByNameTest.calcPopupElements(popup, path) == [psiFile]
+ assert ChooseByNameTest.calcPopupElements(popup, FileUtil.toSystemDependentName(path)) == [psiFile]
+ assert ChooseByNameTest.calcPopupElements(popup, vFile.parent.path) == [psiFile.containingDirectory]
+ popup.close(false)
+ }
}
@Override
diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/Mappings.java b/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/Mappings.java
index c17bba46eb92..0de487375e1d 100644
--- a/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/Mappings.java
+++ b/jps/jps-builders/src/org/jetbrains/jps/builders/java/dependencyView/Mappings.java
@@ -101,7 +101,7 @@ public class Mappings {
myLock = base.myLock;
myIsDelta = true;
myChangedClasses = new TIntHashSet(DEFAULT_SET_CAPACITY, DEFAULT_SET_LOAD_FACTOR);
- myChangedFiles = new THashSet(FileUtil.FILE_HASHING_STRATEGY);
+ myChangedFiles = new THashSet(FileUtil.FILE_HASHING_STRATEGY);
myDeletedClasses = new HashSet>(DEFAULT_SET_CAPACITY, DEFAULT_SET_LOAD_FACTOR);
myAddedClasses = new HashSet(DEFAULT_SET_CAPACITY, DEFAULT_SET_LOAD_FACTOR);
myDeltaIsTransient = base.myDeltaIsTransient;
@@ -2003,51 +2003,60 @@ public class Mappings {
debug("Begin of Differentiate:");
debug("Easy mode: ", myEasyMode);
- processDisappearedClasses();
+ try {
+ processDisappearedClasses();
- final List newClasses = new ArrayList();
- myDelta.mySourceFileToClasses.forEachEntry(new TObjectObjectProcedure>() {
- @Override
- public boolean execute(File fileName, Collection classes) {
- newClasses.add(new FileClasses(fileName, classes));
- return true;
- }
- });
+ final List newClasses = new ArrayList();
+ myDelta.mySourceFileToClasses.forEachEntry(new TObjectObjectProcedure>() {
+ @Override
+ public boolean execute(File fileName, Collection classes) {
+ newClasses.add(new FileClasses(fileName, classes));
+ return true;
+ }
+ });
- for (final FileClasses compiledFile : newClasses) {
- final File fileName = compiledFile.myFileName;
- final Set classes = compiledFile.myFileClasses;
- final Set pastClasses = (Set)mySourceFileToClasses.get(fileName);
- final DiffState state = new DiffState(Difference.make(pastClasses, classes));
-
- if (!processChangedClasses(state)) {
+ for (final FileClasses compiledFile : newClasses) {
+ final File fileName = compiledFile.myFileName;
+ final Set classes = compiledFile.myFileClasses;
+ final Set pastClasses = (Set)mySourceFileToClasses.get(fileName);
+ final DiffState state = new DiffState(Difference.make(pastClasses, classes));
+
+ if (!processChangedClasses(state)) {
+ if (!myEasyMode) {
+ // turning non-incremental
+ return false;
+ }
+ }
+
+ processRemovedClases(state, fileName);
+ processAddedClasses(state, fileName);
+
if (!myEasyMode) {
- // turning non-incremental
- return false;
+ calculateAffectedFiles(state);
}
}
- processRemovedClases(state, fileName);
- processAddedClasses(state, fileName);
+ debug("End of Differentiate.");
- if (!myEasyMode) {
- calculateAffectedFiles(state);
+ if (myEasyMode) {
+ return false;
+ }
+
+ final Collection removed = myDelta.myRemovedFiles;
+ if (removed != null) {
+ for (final String r : removed) {
+ myAffectedFiles.remove(new File(r));
+ }
+ }
+ return myDelayedWorks.doWork(myAffectedFiles);
+ }
+ finally {
+ if (myFilesToCompile != null) {
+ // if some class is associated with several sources,
+ // some of them may not have been compiled in this round, so such files should be considered unchanged
+ myDelta.myChangedFiles.retainAll(myFilesToCompile);
}
}
-
- debug("End of Differentiate.");
-
- if (myEasyMode) {
- return false;
- }
-
- final Collection removed = myDelta.myRemovedFiles;
- if (removed != null) {
- for (final String r : removed) {
- myAffectedFiles.remove(new File(r));
- }
- }
- return myDelayedWorks.doWork(myAffectedFiles);
}
}
}
diff --git a/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java b/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java
index fac4691f8c5c..7f6a8484adf4 100644
--- a/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java
+++ b/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightDisplayLevel.java
@@ -18,11 +18,9 @@ package com.intellij.codeHighlighting;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.editor.colors.CodeInsightColors;
import com.intellij.openapi.editor.colors.EditorColorsManager;
-import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.util.Comparing;
-import com.intellij.ui.JBColor;
import com.intellij.util.containers.HashMap;
import com.intellij.util.ui.ColorIcon;
import org.jetbrains.annotations.NotNull;
@@ -39,10 +37,8 @@ public class HighlightDisplayLevel {
createIconByKey(CodeInsightColors.GENERIC_SERVER_ERROR_OR_WARNING));
public static final HighlightDisplayLevel ERROR = new HighlightDisplayLevel(HighlightSeverity.ERROR, createIconByKey(CodeInsightColors.ERRORS_ATTRIBUTES));
public static final HighlightDisplayLevel WARNING = new HighlightDisplayLevel(HighlightSeverity.WARNING, createIconByKey(CodeInsightColors.WARNINGS_ATTRIBUTES));
- // todo: move to color schemas
- public static final Color GREEN = new JBColor(new Color(113, 178, 98), new Color(30, 160, 0));
- public static final Color TYPO = new JBColor(new Color(176, 209, 171), new Color(30, 160, 0));
- public static final HighlightDisplayLevel DO_NOT_SHOW = new HighlightDisplayLevel(HighlightSeverity.INFORMATION, createIconByMask(GREEN));
+ private static final Icon DO_NOT_SHOW_KEY = createIconByKey(TextAttributesKey.createTextAttributesKey("DO_NOT_SHOW"));
+ public static final HighlightDisplayLevel DO_NOT_SHOW = new HighlightDisplayLevel(HighlightSeverity.INFORMATION, DO_NOT_SHOW_KEY);
/**
* use #WEAK_WARNING instead
*/
@@ -100,8 +96,8 @@ public class HighlightDisplayLevel {
return mySeverity;
}
- public static void registerSeverity(@NotNull HighlightSeverity severity, final Color renderColor) {
- Icon severityIcon = createIconByMask(renderColor);
+ public static void registerSeverity(@NotNull HighlightSeverity severity, final TextAttributesKey key) {
+ Icon severityIcon = createIconByKey(key);
final HighlightDisplayLevel level = ourMap.get(severity);
if (level == null) {
new HighlightDisplayLevel(severity, severityIcon);
@@ -147,19 +143,20 @@ public class HighlightDisplayLevel {
public Color getColor() {
final EditorColorsManager manager = EditorColorsManager.getInstance();
if (manager != null) {
- final EditorColorsScheme globalScheme = manager.getGlobalScheme();
- return globalScheme.getAttributes(myKey).getErrorStripeColor();
+ TextAttributes attributes = manager.getGlobalScheme().getAttributes(myKey);
+ Color stripe = attributes.getErrorStripeColor();
+ if (stripe != null) return stripe;
+ return attributes.getEffectColor();
}
TextAttributes defaultAttributes = myKey.getDefaultAttributes();
if (defaultAttributes == null) defaultAttributes = TextAttributes.ERASE_MARKER;
- return defaultAttributes.getErrorStripeColor();
+ return defaultAttributes.getErrorStripeColor();
}
@Override
public void paintIcon(final Component c, final Graphics g, final int x, final int y) {
- final Graphics2D g2 = (Graphics2D)g;
- g2.setColor(getColor());
- g2.fillRect(x, y, EMPTY_ICON_DIM, EMPTY_ICON_DIM);
+ g.setColor(getColor());
+ g.fillRect(x, y, EMPTY_ICON_DIM, EMPTY_ICON_DIM);
}
@Override
@@ -172,4 +169,17 @@ public class HighlightDisplayLevel {
return EMPTY_ICON_DIM;
}
}
+
+ public static class SemiBorderIcon extends SingleColorIcon {
+ public SemiBorderIcon(TextAttributesKey key) {
+ super(key);
+ }
+
+ @Override
+ public void paintIcon(Component component, Graphics g, int x, int y) {
+ g.setColor(getColor());
+ g.fillRect(x, y, 1, getIconHeight());
+ g.fillRect(x, y + getIconHeight() - 1, getIconWidth(), 1);
+ }
+ }
}
diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java
index c55d30cd10b6..f0aca8b5d272 100644
--- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java
+++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java
@@ -93,7 +93,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator doCommit(@NotNull final CommitTask task,
+ public Processor doCommit(@NotNull final CommitTask task,
@NotNull final PsiFile file,
final boolean synchronously) {
Document document = task.document;
diff --git a/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java b/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java
index bdc83f8098cb..4d7b44b8e7f7 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/PsiDocumentManagerBase.java
@@ -282,7 +282,8 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
}
}
- boolean finishCommit(@NotNull final Document document,
+ // public for Upsource
+ public boolean finishCommit(@NotNull final Document document,
@NotNull final List> finishProcessors,
final boolean synchronously,
@NotNull final Object reason) {
@@ -363,7 +364,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
}
}
- private void doCommit(@NotNull final Document document) {
+ protected void doCommit(@NotNull final Document document) {
assert !myIsCommitInProgress : "Do not call commitDocument() from inside PSI change listener";
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java
index f0bfedda5188..5d3f85802559 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java
@@ -29,6 +29,7 @@ import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.ex.EditorMarkupModel;
import com.intellij.openapi.editor.ex.MarkupModelEx;
import com.intellij.openapi.editor.ex.RangeHighlighterEx;
@@ -47,13 +48,10 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiCompiledElement;
import com.intellij.psi.PsiFile;
-import com.intellij.ui.ColorUtil;
-import com.intellij.ui.JBColor;
import com.intellij.ui.LayeredIcon;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.io.storage.HeavyProcessLatch;
-import com.intellij.util.ui.EmptyIcon;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.XmlStringUtil;
import gnu.trove.TIntArrayList;
@@ -67,7 +65,8 @@ import java.util.*;
import java.util.List;
public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable {
- private static final Icon NO_ANALYSIS = new SemiBorderIcon();
+ private static final TextAttributesKey NO_ANALYSIS = TextAttributesKey.createTextAttributesKey("NO_ANALYSIS");
+ private static final Icon NO_ANALYSIS_ICON = new HighlightDisplayLevel.SemiBorderIcon(NO_ANALYSIS);
private final Project myProject;
private final Document myDocument;
private final PsiFile myFile;
@@ -341,7 +340,7 @@ public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable {
statusExtraLine = "(" + status.reasonWhyDisabled + ")";
passStatusesVisible = true;
progressBarsCompleted = Boolean.FALSE;
- icon = NO_ANALYSIS;
+ icon = NO_ANALYSIS_ICON;
return result;
}
if (status.reasonWhySuspended != null) {
@@ -416,17 +415,4 @@ public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable {
passes.put(pass, Pair.create(progressBar, percLabel));
}
}
-
- public static class SemiBorderIcon extends EmptyIcon {
- public SemiBorderIcon() {
- super(HighlightDisplayLevel.EMPTY_ICON_DIM, HighlightDisplayLevel.EMPTY_ICON_DIM);
- }
-
- @Override
- public void paintIcon(Component component, Graphics g, int x, int y) {
- g.setColor(new JBColor(ColorUtil.fromHex("d3d3d3"), ColorUtil.fromHex("4a4a4b")));
- g.fillRect(x, y, 1, getIconHeight());
- g.fillRect(x, y + getIconHeight() - 1, getIconWidth(), 1);
- }
- }
}
diff --git a/platform/lang-impl/src/com/intellij/ide/actions/GotoFileItemProvider.java b/platform/lang-impl/src/com/intellij/ide/actions/GotoFileItemProvider.java
index 3a2559b5888d..347abd938690 100644
--- a/platform/lang-impl/src/com/intellij/ide/actions/GotoFileItemProvider.java
+++ b/platform/lang-impl/src/com/intellij/ide/actions/GotoFileItemProvider.java
@@ -19,17 +19,17 @@ import com.intellij.ide.util.gotoByName.ChooseByNameBase;
import com.intellij.ide.util.gotoByName.DefaultChooseByNameItemProvider;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ProjectFileIndex;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiFileSystemItem;
import com.intellij.psi.PsiManager;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.io.File;
-
/**
* @author peter
*/
@@ -48,11 +48,17 @@ public class GotoFileItemProvider extends DefaultChooseByNameItemProvider {
@NotNull ProgressIndicator indicator,
@NotNull Processor
@@ -608,7 +608,7 @@
-
+
@@ -654,7 +654,7 @@
-
+
@@ -810,7 +810,7 @@
-
+
@@ -880,12 +880,28 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/platform/platform-tests/testSrc/com/intellij/util/io/HttpRequestsTest.java b/platform/platform-tests/testSrc/com/intellij/util/io/HttpRequestsTest.java
index 2a68a2c98e50..682b646a53e8 100644
--- a/platform/platform-tests/testSrc/com/intellij/util/io/HttpRequestsTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/util/io/HttpRequestsTest.java
@@ -15,6 +15,7 @@
*/
package com.intellij.util.io;
+import com.intellij.ide.IdeBundle;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
@@ -41,31 +42,19 @@ public class HttpRequestsTest {
fail();
}
catch (IOException e) {
- assertEquals("Too many redirects", e.getMessage());
+ assertEquals(IdeBundle.message("error.connection.failed.redirects"), e.getMessage());
}
}
- @Test
- public void testConnectTimeout() {
- try {
- HttpRequests.request("http://openjdk.java.net").connectTimeout(1).connect(myProcessor);
- fail();
- }
- catch (SocketTimeoutException ignore) { }
- catch (IOException e) {
- fail(e.getMessage());
- }
+ @Test(timeout = 5000, expected = SocketTimeoutException.class)
+ public void testConnectTimeout() throws IOException {
+ HttpRequests.request("http://openjdk.java.net").connectTimeout(1).connect(myProcessor);
+ fail();
}
- @Test
- public void testReadTimeout() {
- try {
- HttpRequests.request("http://openjdk.java.net").readTimeout(1).connect(myProcessor);
- fail();
- }
- catch (SocketTimeoutException ignore) { }
- catch (IOException e) {
- fail(e.getMessage());
- }
+ @Test(timeout = 5000, expected = SocketTimeoutException.class)
+ public void testReadTimeout() throws IOException {
+ HttpRequests.request("http://openjdk.java.net").readTimeout(1).connect(myProcessor);
+ fail();
}
}
diff --git a/platform/testFramework/src/com/intellij/testFramework/PsiTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/PsiTestUtil.java
index 659b938b8023..d925a53cfa1d 100644
--- a/platform/testFramework/src/com/intellij/testFramework/PsiTestUtil.java
+++ b/platform/testFramework/src/com/intellij/testFramework/PsiTestUtil.java
@@ -262,6 +262,12 @@ public class PsiTestUtil {
Assert.assertEquals(reparsedTree, originalTree);
}
+ public static void addLibrary(final Module module, final String libPath) {
+ File file = new File(libPath);
+ String libName = file.getName();
+ addLibrary(module, libName, file.getParent(), libName);
+ }
+
public static void addLibrary(final Module module, final String libName, final String libPath, final String... jarArr) {
ModuleRootModificationUtil.updateModel(module, new Consumer() {
@Override
diff --git a/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java b/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java
index 71227bd4c64a..c5d758fd0eb7 100644
--- a/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java
+++ b/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java
@@ -242,12 +242,12 @@ public class UsageInfo2UsageAdapter implements UsageInModule,
return canNavigate();
}
- @Nullable
private OpenFileDescriptor getDescriptor() {
VirtualFile file = getFile();
if(file == null) return null;
Segment range = getNavigationRange();
- if (range != null && file instanceof VirtualFileWindow) {
+ if (range != null && file instanceof VirtualFileWindow && range.getStartOffset() >= 0) {
+ // have to use injectedToHost(TextRange) to calculate right offset in case of multiple shreds
range = ((VirtualFileWindow)file).getDocumentWindow().injectedToHost(TextRange.create(range));
file = ((VirtualFileWindow)file).getDelegate();
}
@@ -272,7 +272,7 @@ public class UsageInfo2UsageAdapter implements UsageInModule,
Segment range = getUsageInfo().getNavigationRange();
if (range == null) {
ProperTextRange rangeInElement = getUsageInfo().getRangeInElement();
- range = rangeInElement == null ? TextRange.from(myOffset,1) : rangeInElement.shiftRight(myOffset);
+ range = myOffset < 0 ? new UnfairTextRange(-1,-1) : rangeInElement == null ? TextRange.from(myOffset,1) : rangeInElement.shiftRight(myOffset);
}
if (range.getEndOffset() >= document.getTextLength()) {
int line = Math.max(0, Math.min(myLineNumber, document.getLineCount() - 1));
diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties
index b6b6da2d28e9..bd09bd415c8b 100644
--- a/platform/util/resources/misc/registry.properties
+++ b/platform/util/resources/misc/registry.properties
@@ -450,6 +450,7 @@ console.too.much.text.buffer.ratio.description=Used for disabling of console pro
The ratio is used against the console cycle buffer size (idea.cycle.buffer.size/theRatio=maxTextLength).
ide.settings.appearance.font.family.only=true
+ide.settings.keymap.input.method.enabled=false
ide.settings.old.style=true
ide.new.settings.view=true
ide.new.settings.view.description=New view for the Settings dialog
@@ -494,4 +495,7 @@ editor.xcode.like.scrollbar=false
editor.xcode.like.scrollbar.description=Enables auto-hideable Xcode-like editor stripes
editor.config.stop.at.project.root=true
-editor.config.stop.at.project.root.description=Stops searching for .editorconfig at project root (requires project reopening)
\ No newline at end of file
+editor.config.stop.at.project.root.description=Stops searching for .editorconfig at project root (requires project reopening)
+
+JDK8042508.bug.fixed=false
+JDK8042508.bug.fixed.description=Disable check for type variable until javac bug is fixed
diff --git a/platform/util/src/com/intellij/openapi/util/TextRange.java b/platform/util/src/com/intellij/openapi/util/TextRange.java
index 4c09b969a570..30240b539051 100644
--- a/platform/util/src/com/intellij/openapi/util/TextRange.java
+++ b/platform/util/src/com/intellij/openapi/util/TextRange.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.
@@ -58,12 +58,14 @@ public class TextRange implements Segment, Serializable {
return myEndOffset - myStartOffset;
}
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof TextRange)) return false;
TextRange range = (TextRange)obj;
return myStartOffset == range.myStartOffset && myEndOffset == range.myEndOffset;
}
+ @Override
public int hashCode() {
return myStartOffset + myEndOffset;
}
@@ -80,6 +82,7 @@ public class TextRange implements Segment, Serializable {
return myStartOffset <= offset && offset <= myEndOffset;
}
+ @Override
public String toString() {
return "(" + myStartOffset + "," + myEndOffset + ")";
}
diff --git a/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java b/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java
index 3d31f3b771a4..11212543a1d2 100644
--- a/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java
+++ b/platform/util/src/com/intellij/openapi/util/objectTree/ObjectTree.java
@@ -181,7 +181,8 @@ public final class ObjectTree {
}
@TestOnly
- void assertNoReferenceKeptInTree(@NotNull T disposable) {
+ // public for Upsource
+ public void assertNoReferenceKeptInTree(@NotNull T disposable) {
synchronized (treeLock) {
Collection> nodes = myObject2NodeMap.values();
for (ObjectNode node : nodes) {
diff --git a/platform/util/src/com/intellij/util/containers/ContainerUtil.java b/platform/util/src/com/intellij/util/containers/ContainerUtil.java
index 3cb42e33ec47..8a43e245aa14 100644
--- a/platform/util/src/com/intellij/util/containers/ContainerUtil.java
+++ b/platform/util/src/com/intellij/util/containers/ContainerUtil.java
@@ -1426,8 +1426,8 @@ public class ContainerUtil extends ContainerUtilRt {
}
@Contract(pure=true)
- public static T getFirstItem(@Nullable final Collection items, @Nullable final T def) {
- return items == null || items.isEmpty() ? def : items.iterator().next();
+ public static T getFirstItem(@Nullable final Collection items, @Nullable final T defaultResult) {
+ return items == null || items.isEmpty() ? defaultResult : items.iterator().next();
}
/**
diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java
index 376b0da273c6..ad8d3eeb36c3 100644
--- a/platform/util/src/com/intellij/util/ui/UIUtil.java
+++ b/platform/util/src/com/intellij/util/ui/UIUtil.java
@@ -2890,13 +2890,29 @@ public class UIUtil {
}
}
+ /**
+ * Adds an empty border with the specified insets to the specified component.
+ * If the component already has a border it will be preserved.
+ *
+ * @param component the component to which border added
+ * @param top the inset from the top
+ * @param left the inset from the left
+ * @param bottom the inset from the bottom
+ * @param right the inset from the right
+ */
+ public static void addInsets(@NotNull JComponent component, int top, int left, int bottom, int right) {
+ addBorder(component, BorderFactory.createEmptyBorder(top, left, bottom, right));
+ }
+
+ /**
+ * Adds an empty border with the specified insets to the specified component.
+ * If the component already has a border it will be preserved.
+ *
+ * @param component the component to which border added
+ * @param insets the top, left, bottom, and right insets
+ */
public static void addInsets(@NotNull JComponent component, @NotNull Insets insets) {
- if (component.getBorder() != null) {
- component.setBorder(new CompoundBorder(new EmptyBorder(insets), component.getBorder()));
- }
- else {
- component.setBorder(new EmptyBorder(insets));
- }
+ addInsets(component, insets.top, insets.left, insets.bottom, insets.right);
}
public static Dimension addInsets(@NotNull Dimension dimension, @NotNull Insets insets) {
@@ -2947,13 +2963,20 @@ public class UIUtil {
return null;
}
+ /**
+ * Adds the specified border to the specified component.
+ * If the component already has a border it will be preserved.
+ * If component or border is not specified nothing happens.
+ *
+ * @param component the component to which border added
+ * @param border the border to add to the component
+ */
public static void addBorder(JComponent component, Border border) {
- if (component == null) return;
-
- if (component.getBorder() != null) {
- component.setBorder(new CompoundBorder(border, component.getBorder()));
- }
- else {
+ if (component != null && border != null) {
+ Border old = component.getBorder();
+ if (old != null) {
+ border = BorderFactory.createCompoundBorder(border, old);
+ }
component.setBorder(border);
}
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesFilterDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesFilterDialog.java
index a164ea34228c..716df11437fb 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesFilterDialog.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesFilterDialog.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.
@@ -22,15 +22,16 @@
*/
package com.intellij.openapi.vcs.changes.committed;
+import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
import com.intellij.openapi.vcs.versionBrowser.ChangesBrowserSettingsEditor;
-import com.intellij.openapi.application.ModalityState;
+import com.intellij.ui.JBColor;
import com.intellij.util.Alarm;
-import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
@@ -54,7 +55,7 @@ public class CommittedChangesFilterDialog extends DialogWrapper {
myPanel.setSettings(settings);
setTitle(VcsBundle.message("browse.changes.filter.title"));
init();
- myErrorLabel.setForeground(Color.red);
+ myErrorLabel.setForeground(JBColor.RED);
validateInput();
myValidateAlarm.addRequest(myValidateRunnable, 500, ModalityState.stateForComponent(myPanel.getComponent()));
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java
index a346eef46ea0..3f124d04bc7c 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java
@@ -75,7 +75,7 @@ public class XDebuggerEditorLinePainter extends EditorLinePainter {
}
Set values = map.get(Pair.create(file, lineNumber));
if (values != null && !values.isEmpty()) {
- final int bpLine = getCurrentBreakPointLine(values);
+ final int bpLine = getCurrentBreakPointLineInFile(values, file);
ArrayList result = new ArrayList();
for (XValueNodeImpl value : values) {
SimpleColoredText text = new SimpleColoredText();
@@ -147,13 +147,13 @@ public class XDebuggerEditorLinePainter extends EditorLinePainter {
return null;
}
- private static int getCurrentBreakPointLine(Set values) {
+ private static int getCurrentBreakPointLineInFile(Set values, VirtualFile file) {
try {
final XValueNodeImpl node = values.iterator().next();
final XDebugSession session = XDebugView.getSession(node.getTree());
if (session != null) {
final XSourcePosition position = session.getCurrentPosition();
- if (position != null) {
+ if (position != null && position.getFile().equals(file)) {
return position.getLine();
}
}
diff --git a/plugins/editorconfig/src/icons/EditorconfigIcons.java b/plugins/editorconfig/src/icons/EditorconfigIcons.java
new file mode 100644
index 000000000000..ff1eb313974c
--- /dev/null
+++ b/plugins/editorconfig/src/icons/EditorconfigIcons.java
@@ -0,0 +1,17 @@
+package icons;
+
+import com.intellij.openapi.util.IconLoader;
+
+import javax.swing.*;
+
+/**
+ * NOTE THIS FILE IS AUTO-GENERATED
+ * DO NOT EDIT IT BY HAND, run build/scripts/icons.gant instead
+ */
+public class EditorconfigIcons {
+ private static Icon load(String path) {
+ return IconLoader.getIcon(path, EditorconfigIcons.class);
+ }
+
+ public static final Icon Editorconfig = load("/org/editorconfig/icons/editorconfig.png"); // 16x16
+}
diff --git a/plugins/editorconfig/src/org/editorconfig/Utils.java b/plugins/editorconfig/src/org/editorconfig/Utils.java
index 6781229ce405..1f08a0752f91 100644
--- a/plugins/editorconfig/src/org/editorconfig/Utils.java
+++ b/plugins/editorconfig/src/org/editorconfig/Utils.java
@@ -27,10 +27,6 @@ public class Utils {
EditorConfigNotifier.getInstance().error(project, configValue, "\"" + configValue + "\" is not a valid value" + (!configKey.isEmpty() ? " for " + configKey : "") + " for file " + filePath);
}
- public static void appliedConfigMessage(Project project, String configValue, String configKey, String filePath) {
- EditorConfigNotifier.getInstance().info(project, "Applied .editorconfig settings");
- }
-
public static String getFilePath(Project project, VirtualFile file) {
if (!file.isInLocalFileSystem()) {
return project.getBasePath() + "/" + file.getNameWithoutExtension() + "." + file.getFileType().getDefaultExtension();
diff --git a/plugins/editorconfig/src/org/editorconfig/annotations/EditorConfigAnnotator.java b/plugins/editorconfig/src/org/editorconfig/annotations/EditorConfigAnnotator.java
new file mode 100644
index 000000000000..7df46185c4f2
--- /dev/null
+++ b/plugins/editorconfig/src/org/editorconfig/annotations/EditorConfigAnnotator.java
@@ -0,0 +1,126 @@
+package org.editorconfig.annotations;
+
+import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
+import com.intellij.codeInsight.intention.IntentionAction;
+import com.intellij.ide.util.PropertiesComponent;
+import com.intellij.lang.annotation.Annotation;
+import com.intellij.lang.annotation.AnnotationHolder;
+import com.intellij.lang.annotation.Annotator;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.markup.GutterIconRenderer;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
+import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.ObjectUtils;
+import icons.EditorconfigIcons;
+import org.editorconfig.Utils;
+import org.editorconfig.core.EditorConfig;
+import org.editorconfig.plugincomponents.SettingsProviderComponent;
+import org.editorconfig.settings.EditorConfigSettings;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import java.util.List;
+
+/**
+ * @author Dennis.Ushakov
+ */
+public class EditorConfigAnnotator implements Annotator {
+ private static final String EDITOR_CONFIG_ACCEPTED = "editor.config.accepted";
+
+ @Override
+ public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
+ PsiFile file = ObjectUtils.tryCast(element, PsiFile.class);
+ if (file == null) {
+ return;
+ }
+ final Project project = file.getProject();
+ final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(project).getCurrentSettings();
+ if (!Utils.isEnabled(settings) || PropertiesComponent.getInstance(project).getBoolean(EDITOR_CONFIG_ACCEPTED, false)) return;
+ final List pairs = SettingsProviderComponent.getInstance().getOutPairs(project, Utils.getFilePath(project, file.getVirtualFile()));
+ if (!pairs.isEmpty()) {
+ final Annotation annotation = holder.createInfoAnnotation(file, "EditorConfig is overriding Code Style settings for this file");
+ annotation.setFileLevelAnnotation(true);
+ annotation.setGutterIconRenderer(new MyGutterIconRenderer());
+ annotation.registerFix(new IntentionAction() {
+ @NotNull
+ @Override
+ public String getText() {
+ return "Disable EditorConfig support";
+ }
+
+ @NotNull
+ @Override
+ public String getFamilyName() {
+ return "EditorConfig";
+ }
+
+ @Override
+ public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
+ return true;
+ }
+
+ @Override
+ public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
+ settings.getCustomSettings(EditorConfigSettings.class).ENABLED = false;
+ DaemonCodeAnalyzer.getInstance(project).restart();
+ }
+
+ @Override
+ public boolean startInWriteAction() {
+ return false;
+ }
+ });
+ annotation.registerFix(new IntentionAction() {
+ @NotNull
+ @Override
+ public String getText() {
+ return "Dismiss";
+ }
+
+ @NotNull
+ @Override
+ public String getFamilyName() {
+ return "EditorConfig";
+ }
+
+ @Override
+ public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
+ return true;
+ }
+
+ @Override
+ public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
+ PropertiesComponent.getInstance(project).setValue(EDITOR_CONFIG_ACCEPTED, "true");
+ DaemonCodeAnalyzer.getInstance(project).restart();
+ }
+
+ @Override
+ public boolean startInWriteAction() {
+ return false;
+ }
+ });
+ }
+ }
+
+ private static class MyGutterIconRenderer extends GutterIconRenderer {
+ @NotNull
+ @Override
+ public Icon getIcon() {
+ return EditorconfigIcons.Editorconfig;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof MyGutterIconRenderer;
+ }
+
+ @Override
+ public int hashCode() {
+ return EditorconfigIcons.Editorconfig.hashCode();
+ }
+ }
+}
diff --git a/plugins/editorconfig/src/org/editorconfig/configmanagement/EditorConfigIndentOptionsProvider.java b/plugins/editorconfig/src/org/editorconfig/configmanagement/EditorConfigIndentOptionsProvider.java
index 273b11e223d2..756377d2e4aa 100644
--- a/plugins/editorconfig/src/org/editorconfig/configmanagement/EditorConfigIndentOptionsProvider.java
+++ b/plugins/editorconfig/src/org/editorconfig/configmanagement/EditorConfigIndentOptionsProvider.java
@@ -66,7 +66,6 @@ public class EditorConfigIndentOptionsProvider extends FileIndentOptionsProvider
final String calculatedTabWidth = calculateTabWidth(tabWidth, indentSize);
if (!calculatedIndentSize.isEmpty()) {
if (applyIndentSize(indentOptions, calculatedIndentSize)) {
- Utils.appliedConfigMessage(project, calculatedIndentSize, indentSizeKey, filePath);
changed = true;
} else {
Utils.invalidConfigMessage(project, calculatedIndentSize, indentSizeKey, filePath);
@@ -74,7 +73,6 @@ public class EditorConfigIndentOptionsProvider extends FileIndentOptionsProvider
}
if (!calculatedContinuationSize.isEmpty()) {
if (applyContinuationIndentSize(indentOptions, calculatedContinuationSize)) {
- Utils.appliedConfigMessage(project, calculatedContinuationSize, continuationSizeKey, filePath);
changed = true;
}
else {
@@ -83,7 +81,6 @@ public class EditorConfigIndentOptionsProvider extends FileIndentOptionsProvider
}
if (!calculatedTabWidth.isEmpty()) {
if (applyTabWidth(indentOptions, calculatedTabWidth)) {
- Utils.appliedConfigMessage(project, calculatedTabWidth, tabWidthKey, filePath);
changed = true;
}
else {
@@ -92,7 +89,6 @@ public class EditorConfigIndentOptionsProvider extends FileIndentOptionsProvider
}
if (!indentStyle.isEmpty()) {
if (applyIndentStyle(indentOptions, indentStyle)) {
- Utils.appliedConfigMessage(project, indentStyle, indentStyleKey, filePath);
changed = true;
}
else {
diff --git a/plugins/editorconfig/src/org/editorconfig/configmanagement/EditorSettingsManager.java b/plugins/editorconfig/src/org/editorconfig/configmanagement/EditorSettingsManager.java
index 25cf2d046585..0e4c06929f68 100644
--- a/plugins/editorconfig/src/org/editorconfig/configmanagement/EditorSettingsManager.java
+++ b/plugins/editorconfig/src/org/editorconfig/configmanagement/EditorSettingsManager.java
@@ -84,7 +84,6 @@ public class EditorSettingsManager extends FileDocumentManagerAdapter {
}
else {
file.putUserData(userDataKey, data);
- Utils.appliedConfigMessage(myProject, configValue, editorConfigKey, file.getCanonicalPath());
}
}
}
diff --git a/plugins/editorconfig/src/org/editorconfig/configmanagement/EncodingManager.java b/plugins/editorconfig/src/org/editorconfig/configmanagement/EncodingManager.java
index 8a744f5ff0df..278b684e10d2 100644
--- a/plugins/editorconfig/src/org/editorconfig/configmanagement/EncodingManager.java
+++ b/plugins/editorconfig/src/org/editorconfig/configmanagement/EncodingManager.java
@@ -67,7 +67,6 @@ public class EncodingManager extends FileDocumentManagerAdapter {
if (newCharset != null) {
if (Comparing.equal(newCharset, file.getCharset())) return;
encodingProjectManager.setEncoding(file, newCharset);
- Utils.appliedConfigMessage(myProject, charset, charsetKey, filePath);
} else {
Utils.invalidConfigMessage(myProject, charset, charsetKey, filePath);
}
diff --git a/plugins/editorconfig/src/org/editorconfig/configmanagement/LineEndingsManager.java b/plugins/editorconfig/src/org/editorconfig/configmanagement/LineEndingsManager.java
index 03896aa5aaa4..a65d00796699 100644
--- a/plugins/editorconfig/src/org/editorconfig/configmanagement/LineEndingsManager.java
+++ b/plugins/editorconfig/src/org/editorconfig/configmanagement/LineEndingsManager.java
@@ -84,7 +84,6 @@ public class LineEndingsManager extends FileDocumentManagerAdapter {
statusBarUpdated = true;
updateStatusBar();
}
- Utils.appliedConfigMessage(myProject, lineEndings, lineEndingsKey, filePath);
}
}
catch (IllegalArgumentException e) {
diff --git a/plugins/editorconfig/src/org/editorconfig/icons/editorconfig.png b/plugins/editorconfig/src/org/editorconfig/icons/editorconfig.png
new file mode 100644
index 000000000000..636d757dbc42
Binary files /dev/null and b/plugins/editorconfig/src/org/editorconfig/icons/editorconfig.png differ
diff --git a/plugins/editorconfig/src/org/editorconfig/icons/editorconfig@2x.png b/plugins/editorconfig/src/org/editorconfig/icons/editorconfig@2x.png
new file mode 100644
index 000000000000..d65e6a7fb035
Binary files /dev/null and b/plugins/editorconfig/src/org/editorconfig/icons/editorconfig@2x.png differ
diff --git a/plugins/editorconfig/src/org/editorconfig/plugincomponents/SettingsProviderComponent.java b/plugins/editorconfig/src/org/editorconfig/plugincomponents/SettingsProviderComponent.java
index d35a216d0b9d..feeebb8de1c0 100644
--- a/plugins/editorconfig/src/org/editorconfig/plugincomponents/SettingsProviderComponent.java
+++ b/plugins/editorconfig/src/org/editorconfig/plugincomponents/SettingsProviderComponent.java
@@ -1,7 +1,11 @@
package org.editorconfig.plugincomponents;
+import com.intellij.lang.LanguageAnnotators;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.fileTypes.FileType;
+import com.intellij.openapi.fileTypes.FileTypeManager;
+import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
@@ -13,6 +17,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
import org.editorconfig.Utils;
+import org.editorconfig.annotations.EditorConfigAnnotator;
import org.editorconfig.core.EditorConfig;
import org.editorconfig.core.EditorConfig.OutPair;
import org.editorconfig.core.EditorConfigException;
@@ -24,8 +29,18 @@ import java.util.*;
public class SettingsProviderComponent implements ApplicationComponent {
private EditorConfig editorConfig;
- public SettingsProviderComponent() {
+ public SettingsProviderComponent(FileTypeManager manager) {
editorConfig = new EditorConfig();
+ registerAnnotator(manager);
+ }
+
+ public void registerAnnotator(FileTypeManager manager) {
+ final EditorConfigAnnotator annotator = new EditorConfigAnnotator();
+ for (FileType type : manager.getRegisteredFileTypes()) {
+ if (type instanceof LanguageFileType) {
+ LanguageAnnotators.INSTANCE.addExplicitExtension(((LanguageFileType)type).getLanguage(), annotator);
+ }
+ }
}
public static SettingsProviderComponent getInstance() {
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeInfoRootPanelManual.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeInfoRootPanelManual.java
index d4b48281f7ca..350925847ef2 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeInfoRootPanelManual.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeInfoRootPanelManual.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,15 +20,16 @@ import com.intellij.openapi.ui.FixedSizeButton;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.ui.JBColor;
import com.intellij.util.NullableFunction;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.idea.svn.branchConfig.SvnBranchMapperManager;
import org.jetbrains.idea.svn.SvnBundle;
import org.jetbrains.idea.svn.SvnUtil;
import org.jetbrains.idea.svn.branchConfig.SelectBranchPopup;
import org.jetbrains.idea.svn.branchConfig.SvnBranchConfigurationNew;
+import org.jetbrains.idea.svn.branchConfig.SvnBranchMapperManager;
import org.jetbrains.idea.svn.dialogs.WCInfoWithBranches;
import org.jetbrains.idea.svn.integrate.IntegratedSelectedOptionsDialog;
import org.jetbrains.idea.svn.integrate.WorkingCopyInfo;
@@ -196,7 +197,7 @@ public class SvnMergeInfoRootPanelManual {
gb.gridx = 0;
gb.gridwidth = 2;
myMixedRevisions = new JTextArea("Mixed Revision Working Copy");
- myMixedRevisions.setForeground(Color.red);
+ myMixedRevisions.setForeground(JBColor.RED);
myMixedRevisions.setBackground(myContentPanel.getBackground());
myContentPanel.add(myMixedRevisions, gb);
@@ -231,7 +232,7 @@ public class SvnMergeInfoRootPanelManual {
private void calculateBranchPathByBranch(final String url, final String localPath) {
final String local = url == null ? null : getLocal(url, localPath == null ? myBranchToLocal.get(url) : localPath);
if (local == null) {
- myLocalArea.setForeground(Color.red);
+ myLocalArea.setForeground(JBColor.RED);
myLocalArea.setText(SvnBundle.message("tab.repository.merge.panel.root.panel.select.local"));
} else {
myLocalArea.setForeground(UIUtil.getInactiveTextColor());
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/TreeConflictRefreshablePanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/TreeConflictRefreshablePanel.java
index 9a68d63527ae..e35ff970d033 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/TreeConflictRefreshablePanel.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/TreeConflictRefreshablePanel.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.
@@ -35,6 +35,7 @@ import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangesUtil;
import com.intellij.openapi.vcs.history.*;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
+import com.intellij.ui.JBColor;
import com.intellij.util.BeforeAfter;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.UIUtil;
@@ -230,7 +231,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel {
BeforeAfter ba, boolean directory) {
if (description == null) return;
JLabel descriptionLbl = new JLabel(description.toPresentableString());
- descriptionLbl.setForeground(Color.red);
+ descriptionLbl.setForeground(JBColor.RED);
main.add(descriptionLbl, gb);
++ gb.gridy;
//buttons
diff --git a/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java b/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java
index 9547b4f1040d..a745830bd921 100644
--- a/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java
+++ b/spellchecker/src/com/intellij/spellchecker/SpellCheckerSeveritiesProvider.java
@@ -20,12 +20,10 @@
*/
package com.intellij.spellchecker;
-import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
import com.intellij.codeInsight.daemon.impl.SeveritiesProvider;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.editor.colors.TextAttributesKey;
-import com.intellij.openapi.editor.markup.EffectType;
import com.intellij.openapi.editor.markup.TextAttributes;
import org.jetbrains.annotations.NotNull;
@@ -34,23 +32,19 @@ import java.util.Collections;
import java.util.List;
public class SpellCheckerSeveritiesProvider extends SeveritiesProvider {
+ private static final TextAttributesKey TYPO_KEY = TextAttributesKey.createTextAttributesKey("TYPO");
public static final HighlightSeverity TYPO = new HighlightSeverity("TYPO", HighlightSeverity.INFORMATION.myVal + 5);
@Override
@NotNull
public List getSeveritiesHighlightInfoTypes() {
- final TextAttributes attributes = new TextAttributes();
-
- attributes.setEffectType(EffectType.WAVE_UNDERSCORE);
- attributes.setEffectColor(HighlightDisplayLevel.TYPO);
-
- HighlightInfoType typo = new HighlightInfoType.HighlightInfoTypeImpl(TYPO, TextAttributesKey.createTextAttributesKey("TYPO", attributes));
+ HighlightInfoType typo = new HighlightInfoType.HighlightInfoTypeImpl(TYPO, TYPO_KEY);
return Collections.singletonList(typo);
}
@Override
public Color getTrafficRendererColor(@NotNull TextAttributes textAttributes) {
- return HighlightDisplayLevel.TYPO;
+ return textAttributes.getErrorStripeColor();
}
@Override
diff --git a/spellchecker/src/com/intellij/spellchecker/jetbrains.dic b/spellchecker/src/com/intellij/spellchecker/jetbrains.dic
index c8ac0924ee37..83e23db507a8 100644
--- a/spellchecker/src/com/intellij/spellchecker/jetbrains.dic
+++ b/spellchecker/src/com/intellij/spellchecker/jetbrains.dic
@@ -151,6 +151,7 @@ filesystem
filesystems
finalizer
finalizers
+findbugs
firefox
fixme
foreach
diff --git a/xml/xml-psi-api/src/com/intellij/psi/filters/position/NamespaceFilter.java b/xml/xml-psi-api/src/com/intellij/psi/filters/position/NamespaceFilter.java
index 82bafa6818eb..b4a39cd24b44 100644
--- a/xml/xml-psi-api/src/com/intellij/psi/filters/position/NamespaceFilter.java
+++ b/xml/xml-psi-api/src/com/intellij/psi/filters/position/NamespaceFilter.java
@@ -47,7 +47,9 @@ public class NamespaceFilter implements ElementFilter {
if (psiFile instanceof XmlFile) {
// We use file references for as dtd namespace
// But we should also check PUBLIC ID for namespace
- final XmlProlog prolog = ((XmlFile)psiFile).getDocument().getProlog();
+ XmlDocument document = ((XmlFile)psiFile).getDocument();
+ if (document == null) return false;
+ final XmlProlog prolog = document.getProlog();
if (prolog != null) {
final XmlDoctype doctype = prolog.getDoctype();
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementImpl.java
index ec5f1d903b37..c49459d67b4e 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementImpl.java
@@ -148,11 +148,10 @@ public abstract class XmlElementImpl extends CompositePsiElement implements XmlE
if (super.isEquivalentTo(another)) return true;
PsiElement element1 = this;
- PsiElement element2 = another;
- // TODO: seem to be only necessary for tag dirs equivalens checking.
- if (element1 instanceof XmlTag && element2 instanceof XmlTag) {
- if (!element1.isPhysical() && !element2.isPhysical()) return element1.getText().equals(element2.getText());
+ // TODO: seem to be only necessary for tag dirs equivalents checking.
+ if (element1 instanceof XmlTag && another instanceof XmlTag) {
+ if (!element1.isPhysical() && !another.isPhysical()) return element1.getText().equals(another.getText());
}
return false;