();
+ final LibraryKind kind = ((LibraryEx)library).getKind();
+ if (kind != null) {
+ result.add(kind);
+ }
+ final VirtualFile[] files = getLibraryFiles(library, context);
+ LibraryDetectionManager.getInstance().processProperties(Arrays.asList(files), new LibraryDetectionManager.LibraryPropertiesProcessor() {
+ @Override
+ public boolean processProperties(@NotNull LibraryKind kind, @NotNull P properties) {
+ result.add(kind);
+ return true;
+ }
+ });
+ return result;
+ }
+
+ @NotNull
+ private static VirtualFile[] getLibraryFiles(@NotNull Library library, @Nullable StructureConfigurableContext context) {
+ if (((LibraryEx)library).isDisposed()) {
+ return VirtualFile.EMPTY_ARRAY;
+ }
+ return context != null ? context.getLibraryFiles(library, OrderRootType.CLASSES) : library.getFiles(OrderRootType.CLASSES);
+ }
+
private
LibraryPresentationProvider
getPresentationProvider(LibraryKind kind) {
if (myPresentationProviders == null) {
final Map> providers = new HashMap>();
@@ -62,9 +87,10 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager {
@Override
public Icon getCustomIcon(@NotNull Library library, StructureConfigurableContext context) {
- final LibraryKind kind = ((LibraryEx)library).getKind();
+ LibraryEx libraryEx = (LibraryEx)library;
+ final LibraryKind kind = libraryEx.getKind();
if (kind != null) {
- return LibraryType.findByKind(kind).getIcon();
+ return LibraryType.findByKind(kind).getIcon(libraryEx.getProperties());
}
final List icons = getCustomIcons(library, context);
if (icons.size() == 1) {
@@ -83,7 +109,7 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager {
public boolean processProperties(@NotNull LibraryKind kind, @NotNull P properties) {
final LibraryPresentationProvider
provider = getPresentationProvider(kind);
if (provider != null) {
- ContainerUtil.addIfNotNull(icons, provider.getIcon());
+ ContainerUtil.addIfNotNull(icons, provider.getIcon(properties));
}
return true;
}
@@ -117,23 +143,6 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager {
});
}
- public static List getLibraryKinds(@NotNull Library library, @Nullable StructureConfigurableContext context) {
- final List result = new SmartList();
- final LibraryKind kind = ((LibraryEx)library).getKind();
- if (kind != null) {
- result.add(kind);
- }
- final VirtualFile[] files = getLibraryFiles(library, context);
- LibraryDetectionManager.getInstance().processProperties(Arrays.asList(files), new LibraryDetectionManager.LibraryPropertiesProcessor() {
- @Override
- public boolean processProperties(@NotNull LibraryKind kind, @NotNull P properties) {
- result.add(kind);
- return true;
- }
- });
- return result;
- }
-
@NotNull
@Override
public List getDescriptions(@NotNull Library library, StructureConfigurableContext context) {
@@ -141,14 +150,6 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager {
return getDescriptions(files, Collections.emptySet());
}
- @NotNull
- private static VirtualFile[] getLibraryFiles(@NotNull Library library, @Nullable StructureConfigurableContext context) {
- if (((LibraryEx)library).isDisposed()) {
- return VirtualFile.EMPTY_ARRAY;
- }
- return context != null ? context.getLibraryFiles(library, OrderRootType.CLASSES) : library.getFiles(OrderRootType.CLASSES);
- }
-
@NotNull
@Override
public List getDescriptions(@NotNull VirtualFile[] classRoots, final Set excludedKinds) {
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java
index 42861a4e84e4..6da7c1c6a004 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/CreateNewLibraryAction.java
@@ -61,20 +61,6 @@ public class CreateNewLibraryAction extends DumbAwareAction {
myProject = project;
}
- @Override
- public void actionPerformed(AnActionEvent e) {
- Library library =
- createLibrary(myType, myLibrariesConfigurable.getTree(), myProject, myLibrariesConfigurable.getModelProvider().getModifiableModel());
- if (library == null) return;
-
- final BaseLibrariesConfigurable rootConfigurable = ProjectStructureConfigurable.getInstance(myProject).getConfigurableFor(library);
- final DefaultMutableTreeNode
- libraryNode = MasterDetailsComponent.findNodeByObject((TreeNode)rootConfigurable.getTree().getModel().getRoot(), library);
- rootConfigurable.selectNodeInTree(libraryNode);
- LibraryEditingUtil.showDialogAndAddLibraryToDependencies(library, myProject, true);
- }
-
-
@Nullable
public static Library createLibrary(@Nullable final LibraryType type, @NotNull final JComponent parentComponent,
@NotNull final Project project, @NotNull final LibrariesModifiableModel modifiableModel) {
@@ -82,7 +68,8 @@ public class CreateNewLibraryAction extends DumbAwareAction {
if (configuration == null) return null;
final LibraryType> libraryType = configuration.getLibraryType();
final Library library = modifiableModel.createLibrary(
- LibraryEditingUtil.suggestNewLibraryName(modifiableModel, configuration.getDefaultLibraryName()), libraryType != null ? libraryType.getKind() : null);
+ LibraryEditingUtil.suggestNewLibraryName(modifiableModel, configuration.getDefaultLibraryName()),
+ libraryType != null ? libraryType.getKind() : null);
final NewLibraryEditor editor = new NewLibraryEditor(libraryType, configuration.getProperties());
configuration.addRoots(editor);
@@ -136,9 +123,22 @@ public class CreateNewLibraryAction extends DumbAwareAction {
for (LibraryType> type : suitableTypes) {
final String actionName = type.getCreateActionName();
if (actionName != null) {
- actions.add(new CreateNewLibraryAction(actionName, type.getIcon(), type, librariesConfigurable, project));
+ actions.add(new CreateNewLibraryAction(actionName, type.getIcon(null), type, librariesConfigurable, project));
}
}
return actions.toArray(new AnAction[actions.size()]);
}
+
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ Library library =
+ createLibrary(myType, myLibrariesConfigurable.getTree(), myProject, myLibrariesConfigurable.getModelProvider().getModifiableModel());
+ if (library == null) return;
+
+ final BaseLibrariesConfigurable rootConfigurable = ProjectStructureConfigurable.getInstance(myProject).getConfigurableFor(library);
+ final DefaultMutableTreeNode
+ libraryNode = MasterDetailsComponent.findNodeByObject((TreeNode)rootConfigurable.getTree().getModel().getRoot(), library);
+ rootConfigurable.selectNodeInTree(libraryNode);
+ LibraryEditingUtil.showDialogAndAddLibraryToDependencies(library, myProject, true);
+ }
}
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/LambdaCanBeMethodReferenceInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/LambdaCanBeMethodReferenceInspection.java
index 6b0b3b12928c..ff96f4025ca5 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/LambdaCanBeMethodReferenceInspection.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/LambdaCanBeMethodReferenceInspection.java
@@ -19,6 +19,8 @@ import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.daemon.GroupNames;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Conditions;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
@@ -217,7 +219,26 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp
}
private static boolean checkQualifier(PsiElement qualifier) {
- return !(qualifier instanceof PsiCallExpression);
+ if (qualifier == null) {
+ return true;
+ }
+ final Condition callExpressionCondition = Conditions.instanceOf(PsiCallExpression.class);
+ final Condition nonFinalFieldRefCondition = new Condition() {
+ @Override
+ public boolean value(PsiElement expression) {
+ if (expression instanceof PsiReferenceExpression) {
+ PsiElement element = ((PsiReferenceExpression)expression).resolve();
+ if (element instanceof PsiField && !((PsiField)element).hasModifierProperty(PsiModifier.FINAL)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ };
+ return SyntaxTraverser
+ .psiTraverser()
+ .withRoot(qualifier)
+ .filter(Conditions.or(callExpressionCondition, nonFinalFieldRefCondition)).toList().isEmpty();
}
@Nullable
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/DefaultInsertHandler.java b/java/java-impl/src/com/intellij/codeInsight/completion/DefaultInsertHandler.java
index c3472a58937f..39a74f7a5e29 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/DefaultInsertHandler.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/DefaultInsertHandler.java
@@ -26,11 +26,9 @@ import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
-import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
-import org.jetbrains.annotations.NotNull;
-public class DefaultInsertHandler extends TemplateInsertHandler implements Cloneable {
+public class DefaultInsertHandler implements InsertHandler {
public static final DefaultInsertHandler NO_TAIL_HANDLER = new DefaultInsertHandler(){
@Override
@@ -40,13 +38,9 @@ public class DefaultInsertHandler extends TemplateInsertHandler implements Clone
};
@Override
- public void handleInsert(final InsertionContext context, LookupElement item) {
- super.handleInsert(context, item);
-
- handleInsertInner(context, (LookupItem)item, context.getCompletionChar());
- }
-
- private void handleInsertInner(InsertionContext context, LookupItem item, final char completionChar) {
+ public void handleInsert(final InsertionContext context, LookupElement lookupElement) {
+ LookupItem item = (LookupItem)lookupElement;
+ char completionChar = context.getCompletionChar();
final Project project = context.getProject();
final Editor editor = context.getEditor();
final Document document = editor.getDocument();
@@ -170,11 +164,6 @@ public class DefaultInsertHandler extends TemplateInsertHandler implements Clone
return editor.getCaretModel().getOffset();
}
- @Override
- protected void populateInsertMap(@NotNull final PsiFile file, @NotNull final OffsetMap offsetMap) {
- JavaCompletionUtil.initOffsets(file, offsetMap);
- }
-
public static class InsertHandlerState{
int tailOffset;
int caretOffset;
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodCallElement.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodCallElement.java
index c0f82668f74a..785486644cfb 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodCallElement.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaMethodCallElement.java
@@ -250,7 +250,6 @@ public class JavaMethodCallElement extends LookupItem implements Type
presentation.setIcon(DefaultLookupItemRenderer.getRawIcon(this, presentation.isReal()));
presentation.setStrikeout(JavaElementLookupRenderer.isToStrikeout(this));
- presentation.setItemTextBold(getAttribute(HIGHLIGHTED_ATTR) != null);
MemberLookupHelper helper = myHelper != null ? myHelper : new MemberLookupHelper(myMethod, myContainingClass, false, false);
final Boolean qualify = getAttribute(FORCE_QUALIFY) != null ? Boolean.TRUE : myHelper == null ? Boolean.FALSE : null;
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaPsiClassReferenceElement.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaPsiClassReferenceElement.java
index a5fcdadeaf06..789117879bd2 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaPsiClassReferenceElement.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaPsiClassReferenceElement.java
@@ -147,11 +147,9 @@ public class JavaPsiClassReferenceElement extends LookupItem