Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anna Kozlova
2014-05-26 20:06:10 +04:00
20 changed files with 432 additions and 44 deletions
@@ -32,6 +32,7 @@ import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -53,6 +54,8 @@ public class SheetMessage {
private int imageHeight;
private boolean restoreFullscreenButton;
private final WeakReference<Component> beforeShowFocusOwner;
public SheetMessage(final Window owner,
final String title,
final String message,
@@ -62,6 +65,10 @@ public class SheetMessage {
final String defaultButton,
final String focusedButton)
{
beforeShowFocusOwner = new WeakReference<Component>(
KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow().getMostRecentFocusOwner()
);
myWindow = new JDialog(owner, "This should not be shown", Dialog.ModalityType.APPLICATION_MODAL);
myWindow.getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE);
@@ -109,6 +116,7 @@ public class SheetMessage {
LaterInvocator.enterModal(myWindow);
myWindow.setVisible(true);
LaterInvocator.leaveModal(myWindow);
beforeShowFocusOwner.get().requestFocus();
}
private void setWindowOpacity(float opacity) {
@@ -26,20 +26,10 @@ public class DataPack implements VcsLogDataPack {
private boolean myFull;
@NotNull
static DataPack build(@NotNull List<? extends GraphCommit<Integer>> commits,
@NotNull RefsModel refsModel,
@NotNull NotNullFunction<Hash, Integer> indexGetter,
@NotNull NotNullFunction<Integer, Hash> hashGetter,
@NotNull Map<VirtualFile, VcsLogProvider> providers,
boolean full) {
PermanentGraph<Integer> permanentGraph;
if (!commits.isEmpty()) {
permanentGraph = buildPermanentGraph(commits, refsModel, indexGetter, hashGetter, providers);
}
else {
permanentGraph = EmptyPermanentGraph.getInstance();
}
return build(permanentGraph, providers, refsModel, full);
static DataPack build(@NotNull List<? extends GraphCommit<Integer>> commits, @NotNull RefsModel refsModel,
@NotNull NotNullFunction<Hash, Integer> indexGetter, @NotNull NotNullFunction<Integer, Hash> hashGetter,
@NotNull Map<VirtualFile, VcsLogProvider> providers, boolean full) {
return build(buildPermanentGraph(commits, refsModel, indexGetter, hashGetter, providers), providers, refsModel, full);
}
@NotNull
@@ -72,6 +62,9 @@ public class DataPack implements VcsLogDataPack {
@NotNull NotNullFunction<Hash, Integer> indexGetter,
@NotNull NotNullFunction<Integer, Hash> hashGetter,
@NotNull Map<VirtualFile, VcsLogProvider> providers) {
if (commits.isEmpty()) {
return EmptyPermanentGraph.getInstance();
}
GraphColorManagerImpl colorManager = new GraphColorManagerImpl(refsModel, hashGetter, getRefManagerMap(providers));
Set<Integer> branches = getBranchCommitHashIndexes(refsModel.getAllRefs(), indexGetter);
StopWatch sw = StopWatch.start("building graph");
@@ -0,0 +1,26 @@
/*
* 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.
* 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 com.intellij.xdebugger.impl;
import com.intellij.xdebugger.XDebugProcessStarter;
import com.intellij.xdebugger.impl.ui.XDebugSessionData;
/**
* Created by avu on 22/05/14.
*/
public abstract class XDebugProcessConfiguratorStarter extends XDebugProcessStarter {
public abstract void configure(XDebugSessionData data);
}
@@ -201,7 +201,15 @@ public class XDebuggerManagerImpl extends XDebuggerManager
if (oldSessionData == null) {
oldSessionData = new XDebugSessionData();
}
// Perform custom configuration of session data for XDebugProcessConfiguratorStarter classes
if (processStarter instanceof XDebugProcessConfiguratorStarter) {
session.activateSession();
((XDebugProcessConfiguratorStarter)processStarter).configure(oldSessionData);
}
session.init(process, oldSessionData);
mySessions.put(session.getDebugProcess().getProcessHandler(), session);
return session;
@@ -23,6 +23,7 @@ import com.intellij.openapi.editor.FoldRegion;
import com.intellij.openapi.editor.markup.GutterIconRenderer;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.XDebuggerUtil;
@@ -48,7 +49,7 @@ public class XBreakpointUtil {
}
public static <B extends XBreakpoint<?>> String getShortText(B breakpoint) {
return getType(breakpoint).getShortText(breakpoint);
return StringUtil.shortenTextWithEllipsis(StringUtil.notNullize(getType(breakpoint).getShortText(breakpoint)), 70, 5);
}
public static <B extends XBreakpoint<?>> String getDisplayText(@NotNull B breakpoint) {
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -294,34 +294,35 @@ public class UnnecessaryBoxingInspection extends BaseInspection {
return unboxedType != null && unboxedType.isAssignableFrom(rhsType);
}
}
final PsiMethodCallExpression containingMethodCallExpression = getParentMethodCallExpression(expression);
final PsiCallExpression containingMethodCallExpression = getParentMethodCallExpression(expression);
return containingMethodCallExpression == null || isSameMethodCalledWithoutBoxing(containingMethodCallExpression, expression);
}
@Nullable
private PsiMethodCallExpression getParentMethodCallExpression(@NotNull PsiElement expression) {
private PsiCallExpression getParentMethodCallExpression(@NotNull PsiElement expression) {
final PsiElement parent = expression.getParent();
if (parent instanceof PsiParenthesizedExpression || parent instanceof PsiExpressionList) {
return getParentMethodCallExpression(parent);
}
else if (parent instanceof PsiMethodCallExpression) {
return (PsiMethodCallExpression)parent;
else if (parent instanceof PsiCallExpression) {
return (PsiCallExpression)parent;
}
else {
return null;
}
}
private boolean isSameMethodCalledWithoutBoxing(@NotNull PsiMethodCallExpression methodCallExpression,
private boolean isSameMethodCalledWithoutBoxing(@NotNull PsiCallExpression methodCallExpression,
@NotNull PsiExpression boxingExpression) {
final PsiExpressionList argumentList = methodCallExpression.getArgumentList();
if (argumentList == null) {
return false;
}
final PsiExpression[] expressions = argumentList.getExpressions();
final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
final PsiElement element = methodExpression.resolve();
if (!(element instanceof PsiMethod)) {
final PsiMethod originalMethod = methodCallExpression.resolveMethod();
if (originalMethod == null) {
return false;
}
final PsiMethod originalMethod = (PsiMethod)element;
final String name = originalMethod.getName();
final PsiClass containingClass = originalMethod.getContainingClass();
if (containingClass == null) {
@@ -54,4 +54,29 @@ public class UnnecessaryBoxing {
}
return null;
}
}
class IntIntegerTest {
public IntIntegerTest(Integer val) {
System.out.println("behavoiur 1");
}
public IntIntegerTest(int val) {
System.out.println("behavoiur 2");
}
public static void f(Integer val) {
System.out.println("behavoiur 1");
}
public static void f(int val) {
System.out.println("behavoiur 2");
}
public IntIntegerTest() {
}
public void test() {
new IntIntegerTest(new Integer(1)); // <-- incorrectly triggered
f(new Integer(1)); // <-- not triggered
}
}
@@ -166,6 +166,8 @@
<codeInsight.lineMarkerProvider language="JAVA"
implementationClass="org.jetbrains.idea.devkit.navigation.DescriptionTypeRelatedItemLineMarkerProvider"/>
<codeInsight.lineMarkerProvider language="JAVA"
implementationClass="org.jetbrains.idea.devkit.navigation.ExtensionPointDeclarationRelatedItemLineMarkerProvider"/>
</extensions>
<project-components>
@@ -0,0 +1,155 @@
/*
* 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.
* 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.navigation;
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo;
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider;
import com.intellij.codeInsight.navigation.NavigationGutterIconBuilder;
import com.intellij.icons.AllIcons;
import com.intellij.navigation.GotoRelatedItem;
import com.intellij.openapi.editor.markup.GutterIconRenderer;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.util.Condition;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTypesUtil;
import com.intellij.util.NotNullFunction;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.devkit.util.ExtensionPointCandidate;
import org.jetbrains.idea.devkit.util.ExtensionPointLocator;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class ExtensionPointDeclarationRelatedItemLineMarkerProvider extends RelatedItemLineMarkerProvider {
private static final NotNullFunction<ExtensionPointCandidate, Collection<? extends PsiElement>> CONVERTER =
new NotNullFunction<ExtensionPointCandidate, Collection<? extends PsiElement>>() {
@NotNull
@Override
public Collection<? extends PsiElement> fun(ExtensionPointCandidate candidate) {
return Collections.singleton(candidate.pointer.getElement());
}
};
private static final NotNullFunction<ExtensionPointCandidate, Collection<? extends GotoRelatedItem>> RELATED_ITEM_PROVIDER =
new NotNullFunction<ExtensionPointCandidate, Collection<? extends GotoRelatedItem>>() {
@NotNull
@Override
public Collection<? extends GotoRelatedItem> fun(ExtensionPointCandidate candidate) {
return GotoRelatedItem.createItems(Collections.singleton(candidate.pointer.getElement()), "DevKit");
}
};
@Override
protected void collectNavigationMarkers(@NotNull PsiElement element, Collection<? super RelatedItemLineMarkerInfo> result) {
if (element instanceof PsiField) {
process((PsiField)element, result);
}
}
private static void process(PsiField psiField, Collection<? super RelatedItemLineMarkerInfo> result) {
if (!isExtensionPointNameDeclarationField(psiField)) return;
final PsiClass epClass = resolveExtensionPointClass(psiField);
if (epClass == null) return;
final String epName = resolveEpName(psiField);
if (epName == null) return;
ExtensionPointLocator locator = new ExtensionPointLocator(epClass);
List<ExtensionPointCandidate> targets =
ContainerUtil.filter(locator.findDirectCandidates(), new Condition<ExtensionPointCandidate>() {
@Override
public boolean value(ExtensionPointCandidate candidate) {
return epName.equals(candidate.epName);
}
});
final RelatedItemLineMarkerInfo<PsiElement> info = NavigationGutterIconBuilder
.create(AllIcons.Nodes.Plugin, CONVERTER, RELATED_ITEM_PROVIDER)
.setTargets(targets)
.setPopupTitle("Choose Extension Point")
.setTooltipText("Extension Point Declaration")
.setAlignment(GutterIconRenderer.Alignment.RIGHT)
.createLineMarkerInfo(psiField.getNameIdentifier());
result.add(info);
}
@Nullable
private static PsiClass resolveExtensionPointClass(PsiField psiField) {
final PsiClassType type = (PsiClassType)psiField.getType();
final PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics();
final PsiClass psiClass = resolveResult.getElement();
if (psiClass == null) return null;
final PsiTypeParameter[] parameters = psiClass.getTypeParameters();
if (parameters.length != 1) return null;
final PsiTypeParameter parameter = parameters[0];
final PsiSubstitutor substitutor = resolveResult.getSubstitutor();
final PsiType substituteType = substitutor.substitute(parameter);
return PsiTypesUtil.getPsiClass(substituteType);
}
private static String resolveEpName(PsiField psiField) {
final PsiExpression initializer = psiField.getInitializer();
PsiExpressionList expressionList = null;
if (initializer instanceof PsiMethodCallExpression) {
expressionList = ((PsiMethodCallExpression)initializer).getArgumentList();
}
else if (initializer instanceof PsiNewExpression) {
expressionList = ((PsiNewExpression)initializer).getArgumentList();
}
if (expressionList == null) return null;
final PsiExpression[] expressions = expressionList.getExpressions();
if (expressions.length != 1) return null;
final PsiExpression epNameExpression = expressions[0];
final PsiConstantEvaluationHelper helper = JavaPsiFacade.getInstance(psiField.getProject()).getConstantEvaluationHelper();
final Object o = helper.computeConstantExpression(epNameExpression);
return o instanceof String ? (String)o : null;
}
private static boolean isExtensionPointNameDeclarationField(PsiField psiField) {
// *do* allow non-public
if (!psiField.hasModifierProperty(PsiModifier.FINAL) ||
!psiField.hasModifierProperty(PsiModifier.STATIC) ||
psiField.hasModifierProperty(PsiModifier.ABSTRACT)) {
return false;
}
if (!psiField.hasInitializer()) {
return false;
}
final PsiExpression initializer = psiField.getInitializer();
if (!(initializer instanceof PsiMethodCallExpression) &&
!(initializer instanceof PsiNewExpression)) {
return false;
}
final PsiClass fieldClass = PsiTypesUtil.getPsiClass(psiField.getType());
if (fieldClass == null) {
return false;
}
return ExtensionPointName.class.getName().equals(fieldClass.getQualifiedName());
}
}
@@ -0,0 +1,10 @@
import com.intellij.openapi.extensions.ExtensionPointName;
import java.lang.String;
public class MyStringEP {
public static final ExtensionPointName<String> EP_<caret>NAME =
ExtensionPointName.create("com.intellij.myStringEP");
}
@@ -0,0 +1,11 @@
import com.intellij.openapi.extensions.ExtensionPointName;
import java.lang.String;
public class MyStringEPConstructor {
// private is allowed
private static final ExtensionPointName<String> EP_<caret>NAME =
new ExtensionPointName<String>("com.intellij.myStringEP");
}
@@ -0,0 +1,12 @@
import com.intellij.openapi.extensions.ExtensionPointName;
import java.lang.String;
public class MyStringEPViaConstant {
public static final String EP_ID = "com.intellij.myStringEP";
public static final ExtensionPointName<String> EP_<caret>NAME =
ExtensionPointName.create(EP_ID);
}
@@ -0,0 +1,10 @@
<idea-plugin>
<extensionPoints>
<extensionPoint name="myStringEP" interface="java.lang.String"/>
<!-- wrong EP name -->
<extensionPoint name="myStringEP2" interface="java.lang.String"/>
</extensionPoints>
</idea-plugin>
@@ -0,0 +1,61 @@
/*
* 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.
* 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.navigation;
import com.intellij.codeInsight.daemon.GutterMark;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.application.PluginPathManager;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.testFramework.TestDataPath;
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
import com.intellij.util.PathUtil;
@TestDataPath("$CONTENT_ROOT/testData/navigation/extensionPointDeclaration")
public class ExtensionPointDeclarationRelatedItemLineMarkerProviderTest extends JavaCodeInsightFixtureTestCase {
@Override
protected String getBasePath() {
return PluginPathManager.getPluginHomePathRelative("devkit") + "/testData/navigation/extensionPointDeclaration";
}
@Override
protected void tuneFixture(JavaModuleFixtureBuilder moduleBuilder) throws Exception {
String pathForClass = PathUtil.getJarPathForClass(ExtensionPointName.class);
moduleBuilder.addLibrary("extensions", pathForClass);
}
public void testMyStringEP() {
assertSingleEPDeclaration("MyStringEP.java");
}
public void testMyStringEPViaConstant() {
assertSingleEPDeclaration("MyStringEPViaConstant.java");
}
public void testMyStringEPConstructor() {
assertSingleEPDeclaration("MyStringEPConstructor.java");
}
private void assertSingleEPDeclaration(String filePath) {
myFixture.configureByFile("plugin.xml"); // index
final GutterMark gutter = myFixture.findGutter(filePath);
DevKitGutterTargetsChecker.checkGutterTargets(gutter, "Extension Point Declaration",
AllIcons.Nodes.Plugin,
"extensionPoint");
}
}
@@ -144,13 +144,7 @@ public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime {
}
public void downloadExistingApplication() throws ServerRuntimeException {
CloudGitApplication application = findApplication();
if (application == null) {
throw new ServerRuntimeException("Can't find the application: " + getApplicationName());
}
new CloneJobWithRemote().cloneToModule(application.getGitUrl());
new CloneJobWithRemote().cloneToModule(getApplication().getGitUrl());
getRepository().update();
refreshContentRoot();
}
@@ -232,8 +226,13 @@ public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime {
}
protected void pushApplication(@NotNull CloudGitApplication application) throws ServerRuntimeException {
push(application, getRepository(), getRemoteName());
}
protected void push(@NotNull CloudGitApplication application, @NotNull GitRepository repository, @NotNull String remote)
throws ServerRuntimeException {
GitCommandResult gitPushResult
= getGit().push(getRepository(), getRemoteName(), application.getGitUrl(), "master:master", createGitLineHandlerListener());
= getGit().push(repository, remote, application.getGitUrl(), "master:master", createGitLineHandlerListener());
checkGitResult(gitPushResult);
}
@@ -250,6 +249,7 @@ public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime {
final VirtualFile contentRoot = getRepositoryRoot();
GitRepository repository = getRepository();
final GitLineHandler fetchHandler = new GitLineHandler(getProject(), contentRoot, GitCommand.FETCH);
fetchHandler.setUrl(getApplication().getGitUrl());
fetchHandler.setSilent(false);
fetchHandler.addParameters(getRemoteName());
fetchHandler.addLineListener(createGitLineHandlerListener());
@@ -333,6 +333,11 @@ public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime {
});
}
public void fetchAndRefresh() throws ServerRuntimeException {
fetch();
refreshContentRoot();
}
private String getRemoteName() {
if (myRemoteName == null) {
myRemoteName = myDefaultRemoteName;
@@ -354,6 +359,14 @@ public class CloudGitDeploymentRuntime extends CloudDeploymentRuntime {
});
}
protected CloudGitApplication getApplication() throws ServerRuntimeException {
CloudGitApplication application = findApplication();
if (application == null) {
throw new ServerRuntimeException("Can't find the application: " + getApplicationName());
}
return application;
}
protected CloudGitApplication createApplication() throws ServerRuntimeException {
return getAgentTaskExecutor().execute(new Computable<CloudGitApplication>() {
@@ -1437,7 +1437,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase {
ExternalResourceManagerExImpl.registerResourceTemporarily(url, location, getTestRootDisposable());
configureByFiles(null, getVirtualFile(getFullRelativeTestName()), getVirtualFile(BASE_PATH + location));
doDoTest(true,false);
doDoTest(true, false);
}
@@ -1528,7 +1528,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase {
public void testEncoding() throws Exception { doTest(true); }
public void testSchemaImportHighlightingAndResolve() throws Exception {
doTestWithLocations(new String[][] { {"http://www.springframework.org/schema/beans", "ComplexSchemaValidation11.xsd"} },"xsd");
doTestWithLocations(new String[][]{{"http://www.springframework.org/schema/beans", "ComplexSchemaValidation11.xsd"}}, "xsd");
}
public void testDocBookV5() throws Exception {
@@ -1731,7 +1731,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase {
{"http://extended", testName + ".xsd"},
{"http://simple", testName + "_2.xsd"}
};
doTestWithLocations(urls,"xml");
doTestWithLocations(urls, "xml");
}
public void testComplexRedefine6() throws Exception {
@@ -1839,7 +1839,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase {
Collection<HighlightInfo> infos = doDoTest(true, false);
findAndInvokeIntentionAction(infos, "Change Root Tag Name to xxx", myEditor, myFile);
checkResultByFile(BASE_PATH + testName+"_after.xml");
checkResultByFile(BASE_PATH + testName + "_after.xml");
}
public void testUnqualifiedAttributePsi() throws Exception {
@@ -1847,7 +1847,8 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase {
final List<XmlAttribute> attrs = new ArrayList<XmlAttribute>(2);
myFile.acceptChildren(new XmlRecursiveElementVisitor() {
@Override public void visitXmlAttribute(final XmlAttribute attribute) {
@Override
public void visitXmlAttribute(final XmlAttribute attribute) {
if (!attribute.isNamespaceDeclaration()) attrs.add(attribute);
}
});
@@ -1876,7 +1877,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase {
final String testName = getTestName(false);
doTest(
new VirtualFile[] {
new VirtualFile[]{
getVirtualFile(BASE_PATH + testName + ".xml"),
getVirtualFile(BASE_PATH + testName + ".xsd")
},
@@ -1921,7 +1922,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase {
}
public void testProblemWithImportedNsReference() throws Exception {
doTestWithLocations(null,"xsd");
doTestWithLocations(null, "xsd");
}
public void testBadXmlns() throws Exception {
@@ -1930,7 +1931,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase {
}
public void testProblemWithMemberTypes() throws Exception {
doTestWithLocations(null,"xsd");
doTestWithLocations(null, "xsd");
}
public void testDtdHighlighting() throws Exception {
@@ -1948,7 +1949,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase {
final String testName = getTestName(false);
doTest(
new VirtualFile[] {
new VirtualFile[]{
getVirtualFile(BASE_PATH + testName + ".xml"),
getVirtualFile(BASE_PATH + testName + ".xsd")
},
@@ -1978,13 +1979,13 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase {
public void testMappedSchemaLocation() throws Exception {
doTestWithLocations(new String[][]{
{ "schemas/Forms.xsd", "Forms.xsd"}
{"schemas/Forms.xsd", "Forms.xsd"}
}, "xml");
}
public void testMuleConfigValidation() throws Exception {
doSchemaTestWithManyFilesFromSeparateDir(
new String[][] {
new String[][]{
{"http://www.springframework.org/schema/tool", "spring-tool-2.5.xsd"},
{"http://www.springframework.org/schema/beans/spring-beans-2.5.xsd", "spring-beans-2.5.xsd"},
{"http://www.mulesource.org/schema/mule/core/2.2/mule.xsd", "mule.xsd"},
@@ -2034,6 +2035,21 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase {
);
}
public void testAnyAttributeNavigation() throws Exception {
doTest(
new VirtualFile[] {
getVirtualFile(BASE_PATH + "AnyAttributeNavigation/test.xml"),
getVirtualFile(BASE_PATH + "AnyAttributeNavigation/test.xsd"),
getVirtualFile(BASE_PATH + "AnyAttributeNavigation/library.xsd")
},
true,
false
);
PsiReference at = getFile().findReferenceAt(getEditor().getCaretModel().getOffset());
PsiElement resolve = at.resolve();
assertTrue(resolve instanceof XmlTag);
}
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://library"
xmlns:library="http://library"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="bar" type='library:barType'/>
<xs:complexType name="barType">
<xs:attribute type='xs:string' name="baz"/>
<xs:anyAttribute namespace="http://untyped http://untyped"/>
</xs:complexType>
</xs:schema>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<test:foo xmlns:test="http://test"
xmlns:library="http://library"
ba<caret>z="baz"/>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://test"
xmlns:local="http://test"
xmlns:library="http://library"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://library"/>
<xs:element name="foo" type='local:fooType'/>
<xs:complexType name="fooType">
<xs:complexContent>
<xs:extension base='library:barType'/>
</xs:complexContent>
</xs:complexType>
</xs:schema>
@@ -377,6 +377,11 @@ public class XmlElementDescriptorImpl extends XsdEnumerationDescriptor<XmlTag>
final ComplexTypeDescriptor.CanContainAttributeType containAttributeType = descriptor.canContainAttribute(namespace, qName);
if (containAttributeType != ComplexTypeDescriptor.CanContainAttributeType.CanNotContain) {
for (XmlAttributeDescriptor attributeDescriptor : descriptors) {
if (attributeDescriptor.getName().equals(attributeName)) {
return attributeDescriptor;
}
}
return new AnyXmlAttributeDescriptor(attributeName, containAttributeType);
}
}