WEB-6803 HTML microdata: properties of item are taken from the wrong scope in case of nested scopes

This commit is contained in:
Fedor Korotkov
2013-02-25 15:07:29 +04:00
parent a9d8a9c7bc
commit 04c24901c2
2 changed files with 24 additions and 2 deletions
@@ -94,9 +94,10 @@ public class MicrodataAttributeDescriptorsProvider implements XmlAttributeDescri
private static class MicrodataPropertyAttributeDescriptor extends AnyXmlAttributeDescriptor {
@NotNull
private final XmlTag myContext;
public MicrodataPropertyAttributeDescriptor(XmlTag context) {
public MicrodataPropertyAttributeDescriptor(@NotNull XmlTag context) {
super(ITEM_PROP);
myContext = context;
}
@@ -114,7 +115,7 @@ public class MicrodataAttributeDescriptorsProvider implements XmlAttributeDescri
@Override
public String[] getEnumeratedValues() {
final XmlTag scopeParent = findScopeTag(myContext);
final XmlTag scopeParent = findScopeTag(myContext.getParentTag());
return scopeParent != null ? findProperties(scopeParent) : super.getEnumeratedValues();
}
@@ -151,4 +151,25 @@ public class MicrodataCompletionTest extends CodeInsightFixtureTestCase {
"name", "nickname", "photo", "title", "role", "url", "affiliation", "friend", "acquaintance", "address"
);
}
public void testPropValueNestedScopes() throws Throwable {
final VirtualFile personFile = myFixture.copyFileToProject("Person.html");
final VirtualFile addressFile = myFixture.copyFileToProject("Address.html");
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
ExternalResourceManager.getInstance().addResource("http://data-vocabulary.org/Person", personFile.getPath());
ExternalResourceManager.getInstance().addResource("http://data-vocabulary.org/Address", addressFile.getPath());
}
});
doTestInHtml("<div itemscope itemtype=\"http://data-vocabulary.org/Person\">\n" +
" My name is <span itemprop=\"name\">Smith</span>\n" +
" <span itemprop=\"<caret>\" itemscope itemtype=\"http://data-vocabulary.org/Address\">\n" +
" <span itemprop=\"locality\">Albuquerque</span>\n" +
" <span itemprop=\"region\">NM</span>\n" +
" </span>\n" +
"</div>",
"name", "nickname", "photo", "title", "role", "url", "affiliation", "friend", "acquaintance", "address"
);
}
}