mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
+14
-7
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.CharTailType;
|
||||
import com.intellij.codeInsight.ExpectedTypeInfo;
|
||||
import com.intellij.codeInsight.ExpectedTypesProvider;
|
||||
import com.intellij.codeInsight.TailType;
|
||||
import com.intellij.codeInsight.completion.util.ParenthesesInsertHandler;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
@@ -60,15 +61,21 @@ class TypeArgumentCompletionProvider extends CompletionProvider<CompletionParame
|
||||
final Pair<PsiClass, Integer> pair = getTypeParameterInfo(context);
|
||||
if (pair == null) return;
|
||||
|
||||
ExpectedTypeInfo[] types = JavaSmartCompletionContributor.getExpectedTypes(parameters, false);
|
||||
if (types.length > 0) {
|
||||
for (ExpectedTypeInfo info : types) {
|
||||
PsiType type = info.getType();
|
||||
if (type instanceof PsiClassType) {
|
||||
fillExpectedTypeArgs(resultSet, context, pair.first, pair.second, ((PsiClassType)type).resolveGenerics(), mySmart ? info.getTailType() : TailType.NONE);
|
||||
PsiExpression expression = PsiTreeUtil.getContextOfType(context, PsiExpression.class, true);
|
||||
if (expression != null) {
|
||||
ExpectedTypeInfo[] types = ExpectedTypesProvider.getExpectedTypes(expression, true, false, false);
|
||||
if (types.length > 0) {
|
||||
for (ExpectedTypeInfo info : types) {
|
||||
PsiType type = info.getType();
|
||||
if (type instanceof PsiClassType && !type.equals(expression.getType())) {
|
||||
fillExpectedTypeArgs(resultSet, context, pair.first, pair.second, ((PsiClassType)type).resolveGenerics(), mySmart ? info.getTailType() : TailType.NONE);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if (mySmart) {
|
||||
}
|
||||
|
||||
if (mySmart) {
|
||||
addInheritors(parameters, resultSet, pair.first, pair.second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.search.DelegatingGlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.PsiSearchHelper;
|
||||
import com.intellij.psi.search.searches.AnnotationTargetsSearch;
|
||||
import com.intellij.psi.search.searches.MethodReferencesSearch;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
@@ -50,7 +51,7 @@ public class UsedIconsListingAction extends AnAction {
|
||||
final Project project = LangDataKeys.PROJECT.getData(e.getDataContext());
|
||||
|
||||
final Set<String> answer = new HashSet<String>();
|
||||
final MultiMap<String, PsiCallExpression> calls = new MultiMap<String, PsiCallExpression>();
|
||||
final MultiMap<String, PsiExpression> calls = new MultiMap<String, PsiExpression>();
|
||||
|
||||
|
||||
Processor<PsiReference> consumer = new Processor<PsiReference>() {
|
||||
@@ -111,11 +112,13 @@ public class UsedIconsListingAction extends AnAction {
|
||||
MethodReferencesSearch.search(findIconMethod, false).forEach(consumer);
|
||||
}
|
||||
|
||||
PsiClass javaeeIcons = JavaPsiFacade.getInstance(project).findClass("com.intellij.javaee.oss.JavaeeIcons", GlobalSearchScope.allScope(project));
|
||||
MethodReferencesSearch.search(javaeeIcons.findMethodsByName("getIcon", false)[0], false).forEach(consumer);
|
||||
|
||||
final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
MethodReferencesSearch.search(findIconMethod, false).forEach(consumer);
|
||||
if (false) {
|
||||
PsiClass javaeeIcons = JavaPsiFacade.getInstance(project).findClass("com.intellij.javaee.oss.JavaeeIcons", GlobalSearchScope.allScope(project));
|
||||
MethodReferencesSearch.search(javaeeIcons.findMethodsByName("getIcon", false)[0], false).forEach(consumer);
|
||||
|
||||
MethodReferencesSearch.search(findIconMethod, false).forEach(consumer);
|
||||
}
|
||||
|
||||
PsiClass allIcons =
|
||||
JavaPsiFacade.getInstance(project).findClass("com.intellij.icons.AllIcons", GlobalSearchScope.allScope(project));
|
||||
@@ -171,6 +174,27 @@ public class UsedIconsListingAction extends AnAction {
|
||||
}
|
||||
}
|
||||
|
||||
PsiClass presentation = JavaPsiFacade.getInstance(project).findClass("com.intellij.ide.presentation.Presentation",
|
||||
GlobalSearchScope.allScope(project));
|
||||
final MultiMap<String, PsiAnnotation> annotations = new MultiMap<String, PsiAnnotation>();
|
||||
AnnotationTargetsSearch.search(presentation).forEach(new Processor<PsiModifierListOwner>() {
|
||||
@Override
|
||||
public boolean process(PsiModifierListOwner owner) {
|
||||
PsiAnnotation annotation = owner.getModifierList().findAnnotation("com.intellij.ide.presentation.Presentation");
|
||||
|
||||
PsiAnnotationMemberValue icon = annotation.findAttributeValue("icon");
|
||||
if (icon instanceof PsiLiteralExpression) {
|
||||
Object value = ((PsiLiteralExpression)icon).getValue();
|
||||
if (value instanceof String) {
|
||||
annotations.putValue((String)value, annotation);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (true /*do replacements*/) {
|
||||
ArrayList<String> sorted = new ArrayList<String>(answer);
|
||||
Collections.sort(sorted);
|
||||
@@ -180,17 +204,42 @@ public class UsedIconsListingAction extends AnAction {
|
||||
}
|
||||
|
||||
final JVMElementFactory factory = JVMElementFactories.getFactory(JavaLanguage.INSTANCE, project);
|
||||
for (Map.Entry<String, Collection<PsiCallExpression>> entry : calls.entrySet()) {
|
||||
for (Map.Entry<String, Collection<PsiExpression>> entry : calls.entrySet()) {
|
||||
String path = entry.getKey();
|
||||
final String replacement = mappings.get(path);
|
||||
if (replacement != null) {
|
||||
for (final PsiCallExpression call : entry.getValue()) {
|
||||
for (final PsiExpression call : entry.getValue()) {
|
||||
new WriteCommandAction(project, call.getContainingFile()) {
|
||||
@Override
|
||||
protected void run(Result result) throws Throwable {
|
||||
JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(project);
|
||||
PsiElement expr = factory.createExpressionFromText("com.intellij.icons." + replacement, call);
|
||||
styleManager.shortenClassReferences(call.replace(expr));
|
||||
if (call instanceof PsiLiteralExpression) {
|
||||
call.replace(factory.createExpressionFromText("\"" + replacement + "\"", call));
|
||||
}
|
||||
else {
|
||||
JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(project);
|
||||
PsiElement expr = factory.createExpressionFromText("com.intellij.icons." + replacement, call);
|
||||
styleManager.shortenClassReferences(call.replace(expr));
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Collection<PsiAnnotation>> entry : annotations.entrySet()) {
|
||||
String path = entry.getKey();
|
||||
final String replacement = mappings.get(path);
|
||||
if (replacement != null) {
|
||||
for (final PsiAnnotation annotation : entry.getValue()) {
|
||||
if (annotation instanceof PsiCompiledElement) continue;
|
||||
new WriteCommandAction(project, annotation.getContainingFile()) {
|
||||
@Override
|
||||
protected void run(Result result) throws Throwable {
|
||||
annotation.getNode();
|
||||
annotation.setDeclaredAttributeValue(
|
||||
"icon",
|
||||
JavaPsiFacade.getInstance(annotation.getProject()).getElementFactory()
|
||||
.createAnnotationFromText("@A(\"" + replacement + "\")", null).findDeclaredAttributeValue(null));
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@Presentation(icon = "/nodes/property.png")
|
||||
@Presentation(icon = "AllIcons.Nodes.Property")
|
||||
public class BeanProperty {
|
||||
|
||||
public static final Icon ICON = AllIcons.Nodes.Property;
|
||||
|
||||
+3
-2
@@ -253,10 +253,11 @@ public class PsiDocMethodOrFieldRef extends CompositePsiElement implements PsiDo
|
||||
@NotNull
|
||||
public PsiElement[] getVariants(){
|
||||
final List<PsiModifierListOwner> vars = new ArrayList<PsiModifierListOwner>();
|
||||
final PsiElement scope = getScope();
|
||||
if (scope != null) {
|
||||
PsiClass scope = getScope();
|
||||
while (scope != null) {
|
||||
ContainerUtil.addAll(vars, getAllMethods(scope, PsiDocMethodOrFieldRef.this));
|
||||
ContainerUtil.addAll(vars, getAllVariables(scope, PsiDocMethodOrFieldRef.this));
|
||||
scope = scope.getContainingClass();
|
||||
}
|
||||
return vars.toArray(new PsiModifierListOwner[vars.size()]);
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public class TestClass {
|
||||
|
||||
public static final int MY_CONSTANT = 0;
|
||||
|
||||
/**
|
||||
* {@link #MY<caret>
|
||||
*/
|
||||
public class Inner {}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public class TestClass {
|
||||
|
||||
public static final int MY_CONSTANT = 0;
|
||||
|
||||
/**
|
||||
* {@link #MY_CONSTANT<caret>
|
||||
*/
|
||||
public class Inner {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
public class Util {
|
||||
|
||||
public static <T,V> List<V> map(@NotNull Function<T, V> mapping) { }
|
||||
|
||||
public Object[] getVariants() {
|
||||
return map(new Function<Object, AIOO<caret>>() { }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
interface Function<Param, Result> {
|
||||
Result fun(Param param);
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
public class Util {
|
||||
|
||||
public static <T,V> List<V> map(@NotNull Function<T, V> mapping) { }
|
||||
|
||||
public Object[] getVariants() {
|
||||
return map(new Function<Object, ArrayIndexOutOfBoundsException<caret>>() { }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
interface Function<Param, Result> {
|
||||
Result fun(Param param);
|
||||
}
|
||||
@@ -176,6 +176,10 @@ public class JavadocCompletionTest extends LightFixtureCompletionTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testFieldReferenceInInnerClassJavadoc() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testShortenClassReference() throws Throwable { doTest(); }
|
||||
public void testQualifiedClassReference() throws Throwable {
|
||||
configureByFile(getTestName(false) + ".java");
|
||||
|
||||
+2
@@ -402,6 +402,8 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAnonymousTypeParameter() throws Throwable { doTest(); }
|
||||
|
||||
public void testClassLiteralInAnnoParam() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
+1
-5
@@ -82,11 +82,7 @@ class ChangeHighlighterHolder {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public RangeHighlighter addRangeHighlighter(int start,
|
||||
int end,
|
||||
int layer,
|
||||
TextDiffType type,
|
||||
HighlighterTargetArea targetArea,
|
||||
public RangeHighlighter addRangeHighlighter(int start, int end, int layer, TextDiffType type, HighlighterTargetArea targetArea,
|
||||
boolean applied) {
|
||||
if (getMarkupModel().getDocument().getTextLength() == 0) return null;
|
||||
TextAttributes attributes = type.getTextAttributes(myEditor);
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ public class ChangeList {
|
||||
public Project getProject() { return myProject; }
|
||||
|
||||
public List<Change> getChanges() {
|
||||
return Collections.unmodifiableList(myChanges);
|
||||
return new ArrayList<Change>(myChanges);
|
||||
}
|
||||
|
||||
public static ChangeList build(Document base, Document version, Project project) throws FilesTooBigForDiffException {
|
||||
|
||||
@@ -127,19 +127,11 @@ public class Assertion extends Assert {
|
||||
}
|
||||
|
||||
public static void compareUnordered(Object[] expected, Collection actual) {
|
||||
assertEquals(expected.length, actual.size());
|
||||
assertEquals(String.format("Collections have different sizes%nExpected: %s%n Actual: %s%n", Arrays.toString(expected), actual),
|
||||
expected.length, actual.size());
|
||||
for (Object exp : expected) {
|
||||
assertTrue(actual.contains(exp));
|
||||
assertTrue(String.format("Expected element %s was not found in the collection %s", exp, actual), actual.contains(exp));
|
||||
}
|
||||
//ArrayList expectedList = new ArrayList(Arrays.asList(new Object[Math.max(actual.size(), expected.length)]));
|
||||
//ArrayList actualList = new ArrayList(actual);
|
||||
//for (int i = 0; i < expected.length; i++) {
|
||||
// Object object = expected[i];
|
||||
// int index = actualList.indexOf(object);
|
||||
// if (index == -1) index = i;
|
||||
// expectedList.set(index, object);
|
||||
//}
|
||||
//compareAll(expectedList, actualList);
|
||||
}
|
||||
|
||||
public static void compareUnordered(Collection expected, Collection actual) {
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ import java.io.OutputStream;
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
@Presentation(icon = "/nodes/testSourceFolder.png")
|
||||
@Presentation(icon = "AllIcons.Nodes.TestSourceFolder")
|
||||
public class TestDataGroupVirtualFile extends VirtualFile {
|
||||
private final VirtualFile myBeforeFile;
|
||||
private final VirtualFile myAfterFile;
|
||||
|
||||
+6
@@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.intentions.control;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.intentions.base.Intention;
|
||||
@@ -118,6 +119,11 @@ public class SimplifyTernaryOperatorIntention extends Intention {
|
||||
}
|
||||
|
||||
GrConditionalExpression condExp = (GrConditionalExpression)element;
|
||||
PsiType condType = condExp.getType();
|
||||
if (condType == null || !PsiType.BOOLEAN.isConvertibleFrom(condType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GrExpression thenBranch = condExp.getThenBranch();
|
||||
GrExpression elseBranch = condExp.getElseBranch();
|
||||
|
||||
|
||||
+5
@@ -32,7 +32,12 @@ class SimplifyTernaryOperatorTest extends GrIntentionTestCase {
|
||||
doAntiTest 'aaa ?<caret> bbb : ccc', intentionName
|
||||
doAntiTest 'aaa ?<caret> false : ccc', intentionName
|
||||
doAntiTest 'aaa ?<caret> bbb : true', intentionName
|
||||
}
|
||||
|
||||
public void "test don't trigger for non-boolean conditions"() throws Exception {
|
||||
doAntiTest 'def a = 0\n' +
|
||||
'def b = 2\n' +
|
||||
'println a <caret>? true : b', intentionName
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ import org.jetbrains.idea.maven.dom.converters.MavenDependencyTypeConverter;
|
||||
* 3.0.0+
|
||||
* </pre>
|
||||
*/
|
||||
@Presentation(typeName = "Dependency", icon = "/nodes/ppLib.png")
|
||||
@Presentation(typeName = "Dependency", icon = "AllIcons.Nodes.PpLib")
|
||||
public interface MavenDomDependency extends MavenDomElement, MavenDomArtifactCoordinates {
|
||||
@Required(value = false, nonEmpty = true)
|
||||
GenericDomValue<String> getVersion();
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
@Presentation(icon = "/nodes/resourceBundleClosed.png")
|
||||
@Presentation(icon = "AllIcons.Nodes.ResourceBundleClosed")
|
||||
public class ResourceBundleAsVirtualFile extends VirtualFile {
|
||||
private final ResourceBundle myResourceBundle;
|
||||
|
||||
@@ -139,4 +139,4 @@ public class ResourceBundleAsVirtualFile extends VirtualFile {
|
||||
public void refresh(boolean asynchronous, boolean recursive, Runnable postRunnable) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user