mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1822,7 +1822,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.intellij.openapi.wm.impl.ToolWindowsPane#createAddDecoratorCmd
|
||||
* @see ToolWindowsPane#createAddDecoratorCmd
|
||||
*/
|
||||
private void appendAddDecoratorCmd(final InternalDecorator decorator,
|
||||
final WindowInfoImpl info,
|
||||
@@ -1834,7 +1834,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.intellij.openapi.wm.impl.ToolWindowsPane#createRemoveDecoratorCmd
|
||||
* @see ToolWindowsPane#createRemoveDecoratorCmd
|
||||
*/
|
||||
private void appendRemoveDecoratorCmd(final String id, final boolean dirtyMode, final List<FinalizableCommand> commandsList) {
|
||||
final FinalizableCommand command = myToolWindowsPane.createRemoveDecoratorCmd(id, dirtyMode, myWindowManager.getCommandProcessor());
|
||||
@@ -1852,7 +1852,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.intellij.openapi.wm.impl.ToolWindowsPane#createAddButtonCmd
|
||||
* @see ToolWindowsPane#createAddButtonCmd
|
||||
*/
|
||||
private void appendAddButtonCmd(final StripeButton button, final WindowInfoImpl info, final List<FinalizableCommand> commandsList) {
|
||||
final Comparator<StripeButton> comparator = myLayout.comparator(info.getAnchor());
|
||||
@@ -1862,7 +1862,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.intellij.openapi.wm.impl.ToolWindowsPane#createAddButtonCmd
|
||||
* @see ToolWindowsPane#createAddButtonCmd
|
||||
*/
|
||||
private void appendRemoveButtonCmd(final String id, final List<FinalizableCommand> commandsList) {
|
||||
final FinalizableCommand command = myToolWindowsPane.createRemoveButtonCmd(id, myWindowManager.getCommandProcessor());
|
||||
@@ -1886,7 +1886,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.intellij.openapi.wm.impl.ToolWindowsPane#createSetEditorComponentCmd
|
||||
* @see ToolWindowsPane#createSetEditorComponentCmd
|
||||
*/
|
||||
public void appendSetEditorComponentCmd(@Nullable final JComponent component, final List<FinalizableCommand> commandsList) {
|
||||
final CommandProcessor commandProcessor = myWindowManager.getCommandProcessor();
|
||||
|
||||
+2
-2
@@ -1436,11 +1436,11 @@
|
||||
key="junit4.test.method.in.class.extending.junit3.testcase.display.name" groupBundle="messages.InspectionsBundle"
|
||||
groupKey="group.names.junit.issues" enabledByDefault="true" level="WARNING"
|
||||
implementationClass="com.siyeh.ig.junit.JUnit4AnnotatedMethodInJUnit3TestCaseInspection"/>
|
||||
<localInspection shortName="JUnitAbstractTestClassNamingConvention" bundle="com.siyeh.InspectionGadgetsBundle"
|
||||
<localInspection groupPath="Java" shortName="JUnitAbstractTestClassNamingConvention" bundle="com.siyeh.InspectionGadgetsBundle"
|
||||
key="junit.abstract.test.class.naming.convention.display.name" groupBundle="messages.InspectionsBundle"
|
||||
groupKey="group.names.junit.issues" enabledByDefault="false" level="WARNING"
|
||||
implementationClass="com.siyeh.ig.junit.JUnitAbstractTestClassNamingConventionInspection"/>
|
||||
<localInspection shortName="JUnitTestClassNamingConvention" bundle="com.siyeh.InspectionGadgetsBundle"
|
||||
<localInspection groupPath="Java" shortName="JUnitTestClassNamingConvention" bundle="com.siyeh.InspectionGadgetsBundle"
|
||||
key="junit.test.class.naming.convention.display.name" groupBundle="messages.InspectionsBundle"
|
||||
groupKey="group.names.junit.issues" enabledByDefault="false" level="WARNING"
|
||||
implementationClass="com.siyeh.ig.junit.JUnitTestClassNamingConventionInspection"/>
|
||||
|
||||
+13
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.siyeh.ig.psiutils;
|
||||
|
||||
import com.intellij.codeInsight.ExceptionUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
@@ -22,10 +23,12 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ExpectedTypeUtils {
|
||||
@@ -526,9 +529,12 @@ public class ExpectedTypeUtils {
|
||||
if (aClass == null) {
|
||||
return null;
|
||||
}
|
||||
final PsiReferenceList throwsList = method.getThrowsList();
|
||||
final HashSet<PsiClassType> thrownTypes = ContainerUtil.newHashSet(throwsList.getReferencedTypes());
|
||||
final PsiMethod[] superMethods = aClass.findMethodsBySignature(method, true);
|
||||
PsiMethod topSuper = null;
|
||||
PsiClass topSuperContainingClass = null;
|
||||
methodLoop:
|
||||
for (PsiMethod superMethod : superMethods) {
|
||||
final PsiClass superClass = superMethod.getContainingClass();
|
||||
if (superClass == null) {
|
||||
@@ -552,6 +558,13 @@ public class ExpectedTypeUtils {
|
||||
if (topSuper != null && superClass.isInheritor(topSuperContainingClass, true)) {
|
||||
continue;
|
||||
}
|
||||
final PsiReferenceList superThrowsList = superMethod.getThrowsList();
|
||||
final PsiClassType[] superThrownTypes = superThrowsList.getReferencedTypes();
|
||||
for (PsiClassType superThrownType : superThrownTypes) {
|
||||
if (!ExceptionUtil.isUncheckedException(superThrownType) && !thrownTypes.contains(superThrownType)) {
|
||||
continue methodLoop;
|
||||
}
|
||||
}
|
||||
topSuper = superMethod;
|
||||
topSuperContainingClass = superClass;
|
||||
}
|
||||
|
||||
+22
-4
@@ -14,21 +14,21 @@ interface TestInter{}
|
||||
public class OverlyStrongTypeCast
|
||||
{
|
||||
void iterate(Object o) {
|
||||
for (Object object : (ArrayList) o) {}
|
||||
for (String s : (ArrayList<String>) o) {}
|
||||
for (Object object : (<warning descr="Cast to 'ArrayList' can be weakened to 'Iterable'">ArrayList</warning>) o) {}
|
||||
for (String s : (<warning descr="Cast to 'ArrayList<String>' can be weakened to 'Iterable<String>'">ArrayList<String></warning>) o) {}
|
||||
}
|
||||
|
||||
void optional(Object foo) {
|
||||
if (foo instanceof SubClass2) {
|
||||
((SubClass2)foo).doSmth();
|
||||
}
|
||||
((SubClass2)foo).doSmth();
|
||||
((<warning descr="Cast to 'SubClass2' can be weakened to 'SuperClass'">SubClass2</warning>)foo).doSmth();
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
List bar = new ArrayList();
|
||||
AbstractList foo = (ArrayList) bar;
|
||||
AbstractList foo = (<warning descr="Cast to 'ArrayList' can be weakened to 'AbstractList'">ArrayList</warning>) bar;
|
||||
List foo2 = (ArrayList) bar;
|
||||
double x = (double)3.0f;
|
||||
}
|
||||
@@ -70,4 +70,22 @@ class SAM {
|
||||
{
|
||||
Object runnable = (Runnable) () -> {};
|
||||
}
|
||||
}
|
||||
class CloseableWarningTest {
|
||||
private Object x = new Object();
|
||||
|
||||
public void example() {
|
||||
//if (x instanceof SafeCloseable) {
|
||||
((SafeCloseable) x).close();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
interface SafeCloseable extends Closeable {
|
||||
@Override
|
||||
void close();
|
||||
}
|
||||
interface Closeable extends AutoCloseable {
|
||||
|
||||
public void close() throws java.io.IOException;
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>OverlyStrongTypeCast.java</file>
|
||||
<line>17</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Overly strong type cast</problem_class>
|
||||
<description>Cast to <code>ArrayList</code> can be weakened to 'Iterable' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>OverlyStrongTypeCast.java</file>
|
||||
<line>18</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Overly strong type cast</problem_class>
|
||||
<description>Cast to <code>ArrayList<String></code> can be weakened to 'Iterable<String>' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>OverlyStrongTypeCast.java</file>
|
||||
<line>25</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Overly strong type cast</problem_class>
|
||||
<description>Cast to <code>SubClass2</code> can be weakened to 'SuperClass' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>OverlyStrongTypeCast.java</file>
|
||||
<line>31</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Overly strong type cast</problem_class>
|
||||
<description>Cast to <code>ArrayList</code> can be weakened to 'AbstractList' #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+14
-7
@@ -1,13 +1,20 @@
|
||||
package com.siyeh.ig.abstraction;
|
||||
|
||||
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
|
||||
import com.siyeh.ig.IGInspectionTestCase;
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class OverlyStrongTypeCastInspectionTest extends IGInspectionTestCase {
|
||||
public class OverlyStrongTypeCastInspectionTest extends LightInspectionTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
final OverlyStrongTypeCastInspection tool = new OverlyStrongTypeCastInspection();
|
||||
tool.ignoreInMatchingInstanceof = true;
|
||||
doTest("com/siyeh/igtest/abstraction/overly_strong_type_cast", new LocalInspectionToolWrapper(tool), "java 1.8");
|
||||
public void testOverlyStrongTypeCast() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
final OverlyStrongTypeCastInspection inspection = new OverlyStrongTypeCastInspection();
|
||||
inspection.ignoreInMatchingInstanceof = true;
|
||||
return inspection;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ package org.jetbrains.idea.devkit.dom;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.util.xml.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.devkit.dom.impl.ActionOrGroupResolveConverter;
|
||||
import org.jetbrains.idea.devkit.dom.impl.PluginPsiClassConverter;
|
||||
|
||||
import java.util.List;
|
||||
@@ -29,7 +30,7 @@ import java.util.List;
|
||||
/**
|
||||
* plugin.dtd:action interface.
|
||||
*/
|
||||
public interface Action extends DomElement {
|
||||
public interface Action extends ActionOrGroup {
|
||||
|
||||
/**
|
||||
* Returns the value of the popup child.
|
||||
@@ -78,6 +79,7 @@ public interface Action extends DomElement {
|
||||
* @return the value of the text child.
|
||||
*/
|
||||
@NotNull
|
||||
@Stubbed
|
||||
GenericAttributeValue<String> getText();
|
||||
|
||||
/**
|
||||
@@ -87,6 +89,7 @@ public interface Action extends DomElement {
|
||||
*/
|
||||
@NotNull
|
||||
@Required
|
||||
@Stubbed
|
||||
GenericAttributeValue<String> getId();
|
||||
|
||||
///**
|
||||
@@ -161,7 +164,8 @@ public interface Action extends DomElement {
|
||||
AddToGroup addAddToGroup();
|
||||
|
||||
@NotNull
|
||||
GenericAttributeValue<String> getUseShortcutOf();
|
||||
@Convert(ActionOrGroupResolveConverter.OnlyActions.class)
|
||||
GenericAttributeValue<ActionOrGroup> getUseShortcutOf();
|
||||
|
||||
@NotNull
|
||||
GenericAttributeValue<String> getKeymap();
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.devkit.dom;
|
||||
|
||||
import com.intellij.util.xml.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @since 15
|
||||
*/
|
||||
public interface ActionOrGroup extends DomElement {
|
||||
|
||||
@NotNull
|
||||
@NameValue
|
||||
@Stubbed
|
||||
@Required(value = false, nonEmpty = true)
|
||||
GenericAttributeValue<String> getId();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@
|
||||
package org.jetbrains.idea.devkit.dom;
|
||||
|
||||
import com.intellij.util.xml.DomElement;
|
||||
import com.intellij.util.xml.Stubbed;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@@ -27,12 +28,14 @@ import java.util.List;
|
||||
public interface Actions extends DomElement {
|
||||
|
||||
@NotNull
|
||||
@Stubbed
|
||||
List<Action> getActions();
|
||||
|
||||
Action addAction();
|
||||
|
||||
|
||||
@NotNull
|
||||
@Stubbed
|
||||
List<Group> getGroups();
|
||||
|
||||
Group addGroup();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package org.jetbrains.idea.devkit.dom;
|
||||
|
||||
import com.intellij.ide.presentation.Presentation;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.util.xml.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -29,7 +30,8 @@ import java.util.List;
|
||||
/**
|
||||
* plugin.dtd:group interface.
|
||||
*/
|
||||
public interface Group extends Actions {
|
||||
@Presentation(icon = "AllIcons.Actions.GroupByPackage")
|
||||
public interface Group extends Actions, ActionOrGroup {
|
||||
|
||||
/**
|
||||
* Returns the value of the popup child.
|
||||
@@ -87,14 +89,6 @@ public interface Group extends Actions {
|
||||
@NotNull
|
||||
GenericAttributeValue<String> getText();
|
||||
|
||||
/**
|
||||
* Returns the value of the id child.
|
||||
* Attribute id
|
||||
* @return the value of the id child.
|
||||
*/
|
||||
@NotNull
|
||||
GenericAttributeValue<String> getId();
|
||||
|
||||
///**
|
||||
// * Returns the value of the overrides child.
|
||||
// * Attribute overrides
|
||||
|
||||
@@ -134,6 +134,7 @@ public interface IdeaPlugin extends DomElement {
|
||||
|
||||
@NotNull
|
||||
@SubTagList("actions")
|
||||
@Stubbed
|
||||
List<Actions> getActions();
|
||||
Actions addActions();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -19,9 +19,11 @@
|
||||
|
||||
package org.jetbrains.idea.devkit.dom;
|
||||
|
||||
import com.intellij.util.xml.Convert;
|
||||
import com.intellij.util.xml.DomElement;
|
||||
import com.intellij.util.xml.GenericAttributeValue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.devkit.dom.impl.ActionOrGroupResolveConverter;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -30,17 +32,13 @@ import java.util.Collection;
|
||||
*/
|
||||
public interface Reference extends DomElement {
|
||||
|
||||
/**
|
||||
* Returns the value of the id child.
|
||||
* Attribute id
|
||||
*
|
||||
* @return the value of the id child.
|
||||
*/
|
||||
@NotNull
|
||||
GenericAttributeValue<String> getRef();
|
||||
@Convert(ActionOrGroupResolveConverter.class)
|
||||
GenericAttributeValue<ActionOrGroup> getRef();
|
||||
|
||||
@NotNull
|
||||
GenericAttributeValue<String> getId();
|
||||
@Convert(ActionOrGroupResolveConverter.class)
|
||||
GenericAttributeValue<ActionOrGroup> getId();
|
||||
|
||||
@NotNull
|
||||
Collection<AddToGroup> getAddToGroups();
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.devkit.dom.impl;
|
||||
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.PairProcessor;
|
||||
import com.intellij.util.xml.ConvertContext;
|
||||
import com.intellij.util.xml.DomUtil;
|
||||
import com.intellij.util.xml.ElementPresentationManager;
|
||||
import com.intellij.util.xml.ResolvingConverter;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.devkit.dom.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ActionOrGroupResolveConverter extends ResolvingConverter<ActionOrGroup> {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<? extends ActionOrGroup> getVariants(ConvertContext context) {
|
||||
final List<ActionOrGroup> variants = new ArrayList<ActionOrGroup>();
|
||||
PairProcessor<String, ActionOrGroup> collectProcessor = new PairProcessor<String, ActionOrGroup>() {
|
||||
@Override
|
||||
public boolean process(String s, ActionOrGroup actionOrGroup) {
|
||||
if (isRelevant(actionOrGroup)) {
|
||||
variants.add(actionOrGroup);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
processActionOrGroup(context, collectProcessor);
|
||||
return variants;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ActionOrGroup fromString(@Nullable @NonNls final String value, ConvertContext context) {
|
||||
if (StringUtil.isEmptyOrSpaces(value)) return null;
|
||||
|
||||
final ActionOrGroup[] result = {null};
|
||||
PairProcessor<String, ActionOrGroup> findProcessor = new PairProcessor<String, ActionOrGroup>() {
|
||||
@Override
|
||||
public boolean process(String s, ActionOrGroup actionOrGroup) {
|
||||
if (isRelevant(actionOrGroup) &&
|
||||
Comparing.strEqual(value, s)) {
|
||||
result[0] = actionOrGroup;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
processActionOrGroup(context, findProcessor);
|
||||
return result[0];
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String toString(@Nullable ActionOrGroup actionGroup, ConvertContext context) {
|
||||
return actionGroup == null ? null : getName(actionGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorMessage(@Nullable String s, ConvertContext context) {
|
||||
return "Cannot resolve action or group '" + s + "'";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public LookupElement createLookupElement(ActionOrGroup actionOrGroup) {
|
||||
if (actionOrGroup instanceof Action) {
|
||||
Action action = (Action)actionOrGroup;
|
||||
final PsiElement element = getPsiElement(actionOrGroup);
|
||||
if (element == null) {
|
||||
throw new IllegalStateException(action.getId().getStringValue() + " in " + DomUtil.getFile(action) + " " + action.isValid() + " ");
|
||||
}
|
||||
|
||||
LookupElementBuilder builder =
|
||||
LookupElementBuilder.create(ObjectUtils.assertNotNull(element),
|
||||
ObjectUtils.assertNotNull(getName(action)));
|
||||
|
||||
final String text = action.getText().getStringValue();
|
||||
if (StringUtil.isNotEmpty(text)) {
|
||||
String withoutMnemonic = StringUtil.replace(text, "_", "");
|
||||
builder = builder.withTailText(" \"" + withoutMnemonic + "\"", true);
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
return super.createLookupElement(actionOrGroup);
|
||||
}
|
||||
|
||||
protected boolean isRelevant(ActionOrGroup actionOrGroup) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class OnlyActions extends ActionOrGroupResolveConverter {
|
||||
@Override
|
||||
protected boolean isRelevant(ActionOrGroup actionOrGroup) {
|
||||
return actionOrGroup instanceof Action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorMessage(@Nullable String s, ConvertContext context) {
|
||||
return "Cannot resolve action '" + s + "'";
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean processActionOrGroup(ConvertContext context, final PairProcessor<String, ActionOrGroup> processor) {
|
||||
final Project project = context.getProject();
|
||||
|
||||
Module module = context.getModule();
|
||||
if (module == null) {
|
||||
final Collection<IdeaPlugin> plugins = IdeaPluginConverter.getAllPlugins(project);
|
||||
return processPlugins(plugins, processor);
|
||||
}
|
||||
|
||||
return ModuleUtilCore.visitMeAndDependentModules(module, new ModuleUtilCore.ModuleVisitor() {
|
||||
@Override
|
||||
public boolean visit(Module module) {
|
||||
final Collection<IdeaPlugin> dependenciesAndLibs =
|
||||
IdeaPluginConverter.getPlugins(project, module.getModuleRuntimeScope(false));
|
||||
return processPlugins(dependenciesAndLibs, processor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean processPlugins(Collection<IdeaPlugin> plugins, PairProcessor<String, ActionOrGroup> processor) {
|
||||
for (IdeaPlugin plugin : plugins) {
|
||||
final Map<String, ActionOrGroup> forFile = collectForFile(plugin);
|
||||
for (Map.Entry<String, ActionOrGroup> entry : forFile.entrySet()) {
|
||||
if (!processor.process(entry.getKey(), entry.getValue())) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Map<String, ActionOrGroup> collectForFile(final IdeaPlugin plugin) {
|
||||
final XmlFile xmlFile = DomUtil.getFile(plugin);
|
||||
return CachedValuesManager.getCachedValue(xmlFile, new CachedValueProvider<Map<String, ActionOrGroup>>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Result<Map<String, ActionOrGroup>> compute() {
|
||||
Map<String, ActionOrGroup> result = new HashMap<String, ActionOrGroup>();
|
||||
for (Actions actions : plugin.getActions()) {
|
||||
collectRecursive(result, actions);
|
||||
}
|
||||
|
||||
return Result.create(result, xmlFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void collectRecursive(Map<String, ActionOrGroup> result, Actions actions) {
|
||||
for (Action action : actions.getActions()) {
|
||||
final String name = getName(action);
|
||||
if (!StringUtil.isEmptyOrSpaces(name)) {
|
||||
result.put(name, action);
|
||||
}
|
||||
}
|
||||
for (Group group : actions.getGroups()) {
|
||||
final String name = getName(group);
|
||||
if (!StringUtil.isEmptyOrSpaces(name)) {
|
||||
result.put(name, group);
|
||||
}
|
||||
collectRecursive(result, group);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getName(@NotNull ActionOrGroup actionOrGroup) {
|
||||
return ElementPresentationManager.getElementName(actionOrGroup);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -118,13 +118,19 @@ public class IdeaPluginConverter extends ResolvingConverter<IdeaPlugin> {
|
||||
public Result<Collection<IdeaPlugin>> compute() {
|
||||
GlobalSearchScope scope = GlobalSearchScopesCore.projectProductionScope(project).
|
||||
union(ProjectScope.getLibrariesScope(project));
|
||||
List<DomFileElement<IdeaPlugin>> files = DomService.getInstance().getFileElements(IdeaPlugin.class, project, scope);
|
||||
final Collection<IdeaPlugin> pluginList = ContainerUtil.map(files, new Function<DomFileElement<IdeaPlugin>, IdeaPlugin>() {
|
||||
public IdeaPlugin fun(DomFileElement<IdeaPlugin> ideaPluginDomFileElement) {
|
||||
return ideaPluginDomFileElement.getRootElement();
|
||||
}
|
||||
});
|
||||
return Result.create(pluginList, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
|
||||
return Result.create(getPlugins(project, scope), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Collection<IdeaPlugin> getPlugins(Project project, GlobalSearchScope scope) {
|
||||
if (DumbService.isDumb(project)) return Collections.emptyList();
|
||||
|
||||
List<DomFileElement<IdeaPlugin>> files = DomService.getInstance().getFileElements(IdeaPlugin.class, project, scope);
|
||||
return ContainerUtil.map(files, new Function<DomFileElement<IdeaPlugin>, IdeaPlugin>() {
|
||||
public IdeaPlugin fun(DomFileElement<IdeaPlugin> ideaPluginDomFileElement) {
|
||||
return ideaPluginDomFileElement.getRootElement();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -43,6 +43,6 @@ public class PluginXmlDomFileDescription extends DomFileDescription<IdeaPlugin>
|
||||
|
||||
@Override
|
||||
public int getStubVersion() {
|
||||
return 4;
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<idea-plugin>
|
||||
<actions>
|
||||
<group id="myGroup">
|
||||
<group id="myRecursiveGroup"/>
|
||||
<action id="myRecursiveAction" class="foo.bar.BarAction"/>
|
||||
</group>
|
||||
<action id="myAction" class="foo.bar.BarAction"/>
|
||||
|
||||
<group id=<error descr="Value must not be empty">""</error>/>
|
||||
<group id="withClass" class="foo.bar.BarGroup"/>
|
||||
<group id="invalidClass" class="<error descr="'java.lang.String' is not assignable to 'com.intellij.openapi.actionSystem.ActionGroup'">java.lang.String</error>"/>
|
||||
|
||||
<action id=<error descr="Value must not be empty">""</error> class="foo.bar.BarAction"/>
|
||||
<action id="invalidClass" class="<error descr="'java.lang.String' is not assignable to 'com.intellij.openapi.actionSystem.AnAction'">java.lang.String</error>" />
|
||||
|
||||
<action id="withUseShortcutOf" class="foo.bar.BarAction" use-shortcut-of="myAction"/>
|
||||
<action id="withUseShortcutOfGroupInvalid" class="foo.bar.BarAction" use-shortcut-of="<error descr="Cannot resolve action 'myGroup'">myGroup</error>"/>
|
||||
<action id="withUseShortcutOfInvalid" class="foo.bar.BarAction" use-shortcut-of="<error descr="Cannot resolve action 'INVALID_VALUE'">INVALID_VALUE</error>"/>
|
||||
|
||||
<reference id="myGroup"/>
|
||||
<reference id="myAction"/>
|
||||
<reference id="myRecursiveGroup"/>
|
||||
<reference id="myRecursiveAction"/>
|
||||
<reference id="<error descr="Cannot resolve action or group 'INVALID_VALUE'">INVALID_VALUE</error>"/>
|
||||
|
||||
<reference ref="myGroup"/>
|
||||
<reference ref="myAction"/>
|
||||
<reference ref="myRecursiveGroup"/>
|
||||
<reference ref="myRecursiveAction"/>
|
||||
<reference ref="<error descr="Cannot resolve action or group 'INVALID_VALUE'">INVALID_VALUE</error>"/>
|
||||
</actions>
|
||||
</idea-plugin>
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<extensionPoints>
|
||||
<extensionPoint name="myEP" interface="SomeInterface">
|
||||
<with attribute="attributeName" implements="SomeImplements"/>
|
||||
<with attribute="attributeName" implements="SomeImplements"/>
|
||||
</extensionPoint>
|
||||
|
||||
<extensionPoint qualifiedName="qualifiedName" beanClass="BeanClass"/>
|
||||
@@ -15,4 +15,14 @@
|
||||
|
||||
<extensions defaultExtensionNs="defaultExtensionNs" xmlns="extensionXmlNs"/>
|
||||
|
||||
<actions>
|
||||
<action id="actionId" text="actionText" class="actionClass"/>
|
||||
<group id="groupId">
|
||||
<action id="groupAction" text="groupActionText" class="actionClass"/>
|
||||
<group id="nestedGroup">
|
||||
<action id="nestedGroupActionId" text="nestedGroupActionText" class="actionClass"/>
|
||||
</group>
|
||||
</group>
|
||||
</actions>
|
||||
|
||||
</idea-plugin>
|
||||
@@ -43,7 +43,21 @@ public class PluginXmlDomStubsTest extends DomStubTest {
|
||||
" Attribute:beanClass:BeanClass\n" +
|
||||
" Element:extensions\n" +
|
||||
" Attribute:defaultExtensionNs:defaultExtensionNs\n" +
|
||||
" Attribute:xmlns:extensionXmlNs\n");
|
||||
" Attribute:xmlns:extensionXmlNs\n" +
|
||||
" Element:actions\n" +
|
||||
" Element:action\n" +
|
||||
" Attribute:id:actionId\n" +
|
||||
" Attribute:text:actionText\n" +
|
||||
" Element:group\n" +
|
||||
" Attribute:id:groupId\n" +
|
||||
" Element:action\n" +
|
||||
" Attribute:id:groupAction\n" +
|
||||
" Attribute:text:groupActionText\n" +
|
||||
" Element:group\n" +
|
||||
" Attribute:id:nestedGroup\n" +
|
||||
" Element:action\n" +
|
||||
" Attribute:id:nestedGroupActionId\n" +
|
||||
" Attribute:text:nestedGroupActionText\n");
|
||||
}
|
||||
|
||||
public void testXInclude() throws Exception {
|
||||
|
||||
@@ -281,4 +281,14 @@ public class PluginXmlFunctionalTest extends JavaCodeInsightFixtureTestCase {
|
||||
myFixture.launchAction(myFixture.findSingleIntention("Define class attribute"))
|
||||
myFixture.checkResultByFile(getTestName(true) + "_after.xml")
|
||||
}
|
||||
|
||||
public void testActionHighlighting() {
|
||||
configureByFile()
|
||||
myFixture.addClass("package com.intellij.openapi.actionSystem; public class AnAction { }");
|
||||
myFixture.addClass("package foo.bar; public class BarAction extends com.intellij.openapi.actionSystem.AnAction { }");
|
||||
|
||||
myFixture.addClass("package com.intellij.openapi.actionSystem; public class ActionGroup { }")
|
||||
myFixture.addClass("package foo.bar; public class BarGroup extends com.intellij.openapi.actionSystem.ActionGroup { }");
|
||||
myFixture.testHighlighting()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user