mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-42074 Code completion for <beans>'s attributes should base on the attribute
This commit is contained in:
@@ -719,5 +719,15 @@ public class XmlCompletionTest extends LightCodeInsightFixtureTestCase {
|
||||
"http://www.w3.org/2001/XMLSchema ", "http://www.w3.org/2001/XMLSchema-instance ");
|
||||
myFixture.testCompletionVariants("SchemaLocation2.xml", "http://www.w3.org/2001/XMLSchema.xsd");
|
||||
}
|
||||
|
||||
public void testNamespaceCompletion() throws Exception {
|
||||
myFixture.configureByText("foo.xml", "<schema xmlns=\"<caret>\"/>");
|
||||
myFixture.completeBasic();
|
||||
assertSameElements(myFixture.getLookupElementStrings(), "http://www.w3.org/2001/XMLSchema");
|
||||
|
||||
myFixture.configureByText("unknown.xml", "<unknown_tag_name xmlns=\"<caret>\"/>");
|
||||
myFixture.completeBasic();
|
||||
assertTrue(myFixture.getLookupElementStrings().size() > 3); // all standard schemas actually
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-1
@@ -33,6 +33,7 @@ import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.xml.XmlNSDescriptor;
|
||||
import com.intellij.xml.XmlNamespaceHelper;
|
||||
import com.intellij.xml.XmlSchemaProvider;
|
||||
import com.intellij.xml.util.XmlUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -206,6 +207,14 @@ public class URLReference implements PsiReference, EmptyResolveMessageProvider {
|
||||
@NotNull
|
||||
public Object[] getVariants() {
|
||||
final XmlFile file = (XmlFile)myElement.getContainingFile();
|
||||
PsiElement parent = myElement.getParent();
|
||||
if (parent instanceof XmlAttribute && "xmlns".equals(((XmlAttribute)parent).getName())) {
|
||||
XmlNamespaceHelper helper = XmlNamespaceHelper.getHelper(file);
|
||||
Set<String> strings = helper.guessUnboundNamespaces(parent.getParent(), file);
|
||||
if (!strings.isEmpty()) {
|
||||
return strings.toArray();
|
||||
}
|
||||
}
|
||||
Set<String> list = new HashSet<String>();
|
||||
for (XmlSchemaProvider provider : Extensions.getExtensions(XmlSchemaProvider.EP_NAME)) {
|
||||
if (provider.isAvailable(file)) {
|
||||
@@ -215,7 +224,7 @@ public class URLReference implements PsiReference, EmptyResolveMessageProvider {
|
||||
if (!list.isEmpty()) {
|
||||
return ArrayUtil.toObjectArray(list);
|
||||
}
|
||||
String[] resourceUrls = ExternalResourceManager.getInstance().getResourceUrls(null, true);
|
||||
Object[] resourceUrls = ExternalResourceManagerEx.getInstanceEx().getUrlsByNamespace(myElement.getProject()).keySet().toArray();
|
||||
final XmlDocument document = file.getDocument();
|
||||
assert document != null;
|
||||
XmlTag rootTag = document.getRootTag();
|
||||
|
||||
-2
@@ -231,6 +231,4 @@ public class DefaultXmlNamespaceHelper extends XmlNamespaceHelper {
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user