本文整理汇总了Java中com.intellij.xml.index.XmlNamespaceIndex类的典型用法代码示例。如果您正苦于以下问题:Java XmlNamespaceIndex类的具体用法?Java XmlNamespaceIndex怎么用?Java XmlNamespaceIndex使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XmlNamespaceIndex类属于com.intellij.xml.index包,在下文中一共展示了XmlNamespaceIndex类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compute
import com.intellij.xml.index.XmlNamespaceIndex; //导入依赖的package包/类
@Nullable
@Override
public CachedValueProvider.Result<MultiMap<String, String>> compute() {
MultiMap<String, String> result = new MultiMap<String, String>();
Collection<Map<String, Resource>> values = myStandardResources.getValue().values();
for (Map<String, Resource> map : values) {
for (Map.Entry<String, Resource> entry : map.entrySet()) {
String url = entry.getValue().getResourceUrl();
if (url != null) {
VirtualFile file = VfsUtilCore.findRelativeFile(url, null);
if (file != null) {
String namespace = XmlNamespaceIndex.computeNamespace(file);
if (namespace != null) {
result.putValue(namespace, entry.getKey());
}
}
}
}
}
return CachedValueProvider.Result.create(result, ExternalResourceManagerExImpl.this);
}
示例2: retrieveFile
import com.intellij.xml.index.XmlNamespaceIndex; //导入依赖的package包/类
@Nullable
private XmlFile retrieveFile(final String fileLocation, final String version, String namespace, boolean nsDecl)
{
final String targetNs = XmlUtil.getTargetSchemaNsFromTag(this);
if(fileLocation.equals(targetNs))
{
return null;
}
final XmlFile file = XmlUtil.getContainingFile(this);
final PsiFile psiFile = ExternalResourceManager.getInstance().getResourceLocation(fileLocation, file, version);
if(psiFile instanceof XmlFile)
{
return (XmlFile) psiFile;
}
return XmlNamespaceIndex.guessSchema(namespace, nsDecl ? null : myLocalName, version, fileLocation, file);
}
示例3: ApplicationEnvironment
import com.intellij.xml.index.XmlNamespaceIndex; //导入依赖的package包/类
public ApplicationEnvironment(CoreApplicationEnvironment appEnvironment) {
appEnvironment.registerFileType(HtmlFileType.INSTANCE, "html;htm;sht;shtm;shtml");
appEnvironment.registerFileType(XHtmlFileType.INSTANCE, "xhtml");
appEnvironment.registerFileType(DTDFileType.INSTANCE, "dtd;ent;mod;elt");
appEnvironment.registerFileType(XmlFileType.INSTANCE, "xml;xsd;tld;xsl;jnlp;wsdl;jhm;ant;xul;xslt;rng;fxml");
SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(XMLLanguage.INSTANCE, new XmlSyntaxHighlighterFactory());
SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(DTDLanguage.INSTANCE, new DtdSyntaxHighlighterFactory());
SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(HTMLLanguage.INSTANCE, new HtmlSyntaxHighlighterFactory());
SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(XHTMLLanguage.INSTANCE, new XhtmlSyntaxHighlighterFactory());
appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, XMLLanguage.INSTANCE, new XMLParserDefinition());
appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, DTDLanguage.INSTANCE, new DTDParserDefinition());
appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, HTMLLanguage.INSTANCE, new HTMLParserDefinition());
appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, XHTMLLanguage.INSTANCE, new XHTMLParserDefinition());
appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, XmlFileType.INSTANCE, new XmlIdIndexer());
appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, DTDFileType.INSTANCE, new XmlIdIndexer());
appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, XmlFileType.INSTANCE, new XmlTodoIndexer());
appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, DTDFileType.INSTANCE, new XmlTodoIndexer());
appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, XHtmlFileType.INSTANCE, new XHtmlTodoIndexer());
appEnvironment.addExtension(MetaDataContributor.EP_NAME, new XmlApplicationComponent());
appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlNamespaceIndex());
appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new SchemaTypeInheritanceIndex());
appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlTagNamesIndex());
appEnvironment.addExtension(StandardResourceProvider.EP_NAME, new InternalResourceProvider());
appEnvironment.registerApplicationComponent(PathMacros.class, new PathMacrosImpl());
appEnvironment.registerApplicationService(ExternalResourceManager.class, new ExternalResourceManagerExImpl());
appEnvironment.registerApplicationService(XmlFoldingSettings.class, new XmlFoldingSettings());
Language[] myLanguages = new Language[]{XMLLanguage.INSTANCE, HTMLLanguage.INSTANCE, XHTMLLanguage.INSTANCE, DTDLanguage.INSTANCE};
for (Language myLanguage : myLanguages) {
appEnvironment.addExplicitExtension(LanguageFolding.INSTANCE, myLanguage, new XmlFoldingBuilder());
appEnvironment.addExplicitExtension(LanguageFindUsages.INSTANCE, myLanguage, new XmlFindUsagesProvider());
appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, myLanguage, new XmlASTFactory());
}
}
示例4: guessNamespace
import com.intellij.xml.index.XmlNamespaceIndex; //导入依赖的package包/类
private static Set<String> guessNamespace(final PsiFile file, String tagName) {
final Project project = file.getProject();
final Collection<VirtualFile> files = XmlTagNamesIndex.getFilesByTagName(tagName, project);
final Set<String> possibleUris = new LinkedHashSet<String>(files.size());
for (VirtualFile virtualFile : files) {
final String namespace = XmlNamespaceIndex.getNamespace(virtualFile, project, file);
if (namespace != null) {
possibleUris.add(namespace);
}
}
return possibleUris;
}
示例5: findNSFilesByURI
import com.intellij.xml.index.XmlNamespaceIndex; //导入依赖的package包/类
public static Collection<XmlFile> findNSFilesByURI(String namespace, final Project project, Module module) {
final List<IndexedRelevantResource<String, XsdNamespaceBuilder>>
resources = XmlNamespaceIndex.getResourcesByNamespace(namespace, project, module);
final PsiManager psiManager = PsiManager.getInstance(project);
return ContainerUtil.mapNotNull(resources, new NullableFunction<IndexedRelevantResource<String, XsdNamespaceBuilder>, XmlFile>() {
@Override
public XmlFile fun(IndexedRelevantResource<String, XsdNamespaceBuilder> resource) {
PsiFile file = psiManager.findFile(resource.getFile());
return file instanceof XmlFile ? (XmlFile)file : null;
}
});
}
示例6: retrieveFile
import com.intellij.xml.index.XmlNamespaceIndex; //导入依赖的package包/类
@Nullable
private XmlFile retrieveFile(final String fileLocation, final String version, String namespace, boolean nsDecl) {
final String targetNs = XmlUtil.getTargetSchemaNsFromTag(this);
if (fileLocation.equals(targetNs)) {
return null;
}
final XmlFile file = XmlUtil.getContainingFile(this);
final PsiFile psiFile = ExternalResourceManager.getInstance().getResourceLocation(fileLocation, file, version);
if (psiFile instanceof XmlFile) {
return (XmlFile)psiFile;
}
return XmlNamespaceIndex.guessSchema(namespace, nsDecl ? null : myLocalName, version, fileLocation, file);
}
示例7: ApplicationEnvironment
import com.intellij.xml.index.XmlNamespaceIndex; //导入依赖的package包/类
public ApplicationEnvironment(CoreApplicationEnvironment appEnvironment) {
appEnvironment.registerFileType(HtmlFileType.INSTANCE, "html;htm;sht;shtm;shtml");
appEnvironment.registerFileType(XHtmlFileType.INSTANCE, "xhtml");
appEnvironment.registerFileType(DTDFileType.INSTANCE, "dtd;ent;mod;elt");
appEnvironment.registerFileType(XmlFileType.INSTANCE, "xml;xsd;tld;xsl;jnlp;wsdl;jhm;ant;xul;xslt;rng;fxml");
appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, XMLLanguage.INSTANCE, new XMLParserDefinition());
appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, DTDLanguage.INSTANCE, new DTDParserDefinition());
appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, HTMLLanguage.INSTANCE, new HTMLParserDefinition());
appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, XHTMLLanguage.INSTANCE, new XHTMLParserDefinition());
XmlASTFactory astFactory = new XmlASTFactory();
appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, XMLLanguage.INSTANCE, astFactory);
appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, HTMLLanguage.INSTANCE, astFactory);
appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, XHTMLLanguage.INSTANCE, astFactory);
appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, DTDLanguage.INSTANCE, astFactory);
appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, XmlFileType.INSTANCE, new XmlIdIndexer());
appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, DTDFileType.INSTANCE, new XmlIdIndexer());
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), StartTagEndTokenProvider.EP_NAME, StartTagEndTokenProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlSuppressionProvider.EP_NAME, XmlSuppressionProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlFileNSInfoProvider.EP_NAME, XmlFileNSInfoProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlSchemaProvider.EP_NAME, XmlSchemaProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), ImplicitNamespaceDescriptorProvider.EP_NAME, ImplicitNamespaceDescriptorProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlElementDescriptorProvider.EP_NAME, XmlElementDescriptorProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), Html5SchemaProvider.EP_NAME, Html5SchemaProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlAttributeDescriptorsProvider.EP_NAME, XmlAttributeDescriptorsProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlExtension.EP_NAME, XmlExtension.class);
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), HtmlEmbeddedTokenTypesProvider.EXTENSION_POINT_NAME, HtmlEmbeddedTokenTypesProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), StandardResourceProvider.EP_NAME, StandardResourceProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), StandardResourceEP.EP_NAME, StandardResourceEP.class);
appEnvironment.addExtension(MetaDataContributor.EP_NAME, new XmlApplicationComponent());
appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlNamespaceIndex());
appEnvironment.addExtension(StandardResourceProvider.EP_NAME, new InternalResourceProvider());
appEnvironment.registerApplicationService(ExternalResourceManager.class, createExternalResourceManager());
}
示例8: findNSFilesByURI
import com.intellij.xml.index.XmlNamespaceIndex; //导入依赖的package包/类
public static Collection<XmlFile> findNSFilesByURI(String namespace, final Project project, Module module) {
final List<IndexedRelevantResource<String, XsdNamespaceBuilder>>
resources = XmlNamespaceIndex.getResourcesByNamespace(namespace, project, module);
final PsiManager psiManager = PsiManager.getInstance(project);
return ContainerUtil.mapNotNull(resources, new NullableFunction<IndexedRelevantResource<String, XsdNamespaceBuilder>, XmlFile>() {
public XmlFile fun(IndexedRelevantResource<String, XsdNamespaceBuilder> resource) {
PsiFile file = psiManager.findFile(resource.getFile());
return file instanceof XmlFile ? (XmlFile)file : null;
}
});
}
示例9: retrieveFile
import com.intellij.xml.index.XmlNamespaceIndex; //导入依赖的package包/类
@Nullable
private XmlFile retrieveFile(final String fileLocation, final String version, String namespace) {
final String targetNs = XmlUtil.getTargetSchemaNsFromTag(this);
if (fileLocation.equals(targetNs)) {
return null;
}
final XmlFile file = XmlUtil.getContainingFile(this);
final PsiFile psiFile = ExternalResourceManager.getInstance().getResourceLocation(fileLocation, file, version);
if (psiFile instanceof XmlFile) {
return (XmlFile)psiFile;
}
return XmlNamespaceIndex.guessSchema(namespace, myLocalName, version, file);
}
示例10: findNSFilesByURI
import com.intellij.xml.index.XmlNamespaceIndex; //导入依赖的package包/类
public static Collection<XmlFile> findNSFilesByURI(String namespace, final Project project, Module module)
{
final List<IndexedRelevantResource<String, XsdNamespaceBuilder>> resources = XmlNamespaceIndex.getResourcesByNamespace(namespace, project, module);
final PsiManager psiManager = PsiManager.getInstance(project);
return ContainerUtil.mapNotNull(resources, (NullableFunction<IndexedRelevantResource<String, XsdNamespaceBuilder>, XmlFile>) resource ->
{
PsiFile file = psiManager.findFile(resource.getFile());
return file instanceof XmlFile ? (XmlFile) file : null;
});
}
示例11: execute
import com.intellij.xml.index.XmlNamespaceIndex; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final PsiElement queryParameters, @NotNull final Processor<PsiElement> consumer) {
if (queryParameters instanceof XmlTagImpl) {
final XmlTagImpl xml = (XmlTagImpl) queryParameters;
if (isTypeElement(xml)) {
final Collection<SchemaTypeInfo> infos = ApplicationManager.getApplication().runReadAction(new Computable<Collection<SchemaTypeInfo>>() {
@Override
public Collection<SchemaTypeInfo> compute() {
return gatherInheritors(xml);
}
});
if (infos != null && ! infos.isEmpty()) {
final XmlFile file = XmlUtil.getContainingFile(xml);
final Project project = file.getProject();
final Module module = ModuleUtilCore.findModuleForPsiElement(queryParameters);
//if (module == null) return false;
final VirtualFile vf = file.getVirtualFile();
String thisNs = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return XmlNamespaceIndex.getNamespace(vf, project, file);
}
});
thisNs = thisNs == null ? getDefaultNs(file) : thisNs;
// so thisNs can be null
if (thisNs == null) return false;
final ArrayList<SchemaTypeInfo> infosLst = new ArrayList<SchemaTypeInfo>(infos);
Collections.sort(infosLst);
final Map<String, Set<XmlFile>> nsMap = new HashMap<String, Set<XmlFile>>();
for (final SchemaTypeInfo info : infosLst) {
Set<XmlFile> targetFiles = nsMap.get(info.getNamespaceUri());
if (targetFiles == null) {
targetFiles = new HashSet<XmlFile>();
if (Comparing.equal(info.getNamespaceUri(), thisNs)) {
targetFiles.add(file);
}
final Collection<XmlFile> files = ApplicationManager.getApplication().runReadAction(new Computable<Collection<XmlFile>>() {
@Override
public Collection<XmlFile> compute() {
return XmlUtil.findNSFilesByURI(info.getNamespaceUri(), project, module);
}
});
if (files != null) {
targetFiles.addAll(files);
}
nsMap.put(info.getNamespaceUri(), targetFiles);
}
if (! targetFiles.isEmpty()) {
for (final XmlFile targetFile : targetFiles) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
final String prefixByURI = XmlUtil.findNamespacePrefixByURI(targetFile, info.getNamespaceUri());
if (prefixByURI == null) return;
final PsiElementProcessor processor = new PsiElementProcessor() {
@Override
public boolean execute(@NotNull PsiElement element) {
if (element instanceof XmlTagImpl) {
if (isCertainTypeElement((XmlTagImpl)element, info.getTagName(), prefixByURI) ||
isElementWithEmbeddedType((XmlTagImpl)element, info.getTagName(), prefixByURI)) {
consumer.process(element);
return false;
}
}
return true;
}
};
XmlUtil.processXmlElements(targetFile, processor, true);
}
});
}
}
}
}
}
}
return true;
}
示例12: execute
import com.intellij.xml.index.XmlNamespaceIndex; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final PsiElement queryParameters, @NotNull final Processor<PsiElement> consumer) {
if (queryParameters instanceof XmlTagImpl) {
final XmlTagImpl xml = (XmlTagImpl) queryParameters;
if (isTypeElement(xml)) {
final Collection<SchemaTypeInfo> infos = ApplicationManager.getApplication().runReadAction(new Computable<Collection<SchemaTypeInfo>>() {
@Override
public Collection<SchemaTypeInfo> compute() {
return gatherInheritors(xml);
}
});
if (infos != null && ! infos.isEmpty()) {
final XmlFile file = XmlUtil.getContainingFile(xml);
final Project project = file.getProject();
final Module module = ModuleUtil.findModuleForPsiElement(queryParameters);
//if (module == null) return false;
final VirtualFile vf = file.getVirtualFile();
String thisNs = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return XmlNamespaceIndex.getNamespace(vf, project, file);
}
});
thisNs = thisNs == null ? getDefaultNs(file) : thisNs;
// so thisNs can be null
if (thisNs == null) return false;
final ArrayList<SchemaTypeInfo> infosLst = new ArrayList<SchemaTypeInfo>(infos);
Collections.sort(infosLst);
final Map<String, Set<XmlFile>> nsMap = new HashMap<String, Set<XmlFile>>();
for (final SchemaTypeInfo info : infosLst) {
Set<XmlFile> targetFiles = nsMap.get(info.getNamespaceUri());
if (targetFiles == null) {
targetFiles = new HashSet<XmlFile>();
if (Comparing.equal(info.getNamespaceUri(), thisNs)) {
targetFiles.add(file);
}
final Collection<XmlFile> files = ApplicationManager.getApplication().runReadAction(new Computable<Collection<XmlFile>>() {
@Override
public Collection<XmlFile> compute() {
return XmlUtil.findNSFilesByURI(info.getNamespaceUri(), project, module);
}
});
if (files != null) {
targetFiles.addAll(files);
}
nsMap.put(info.getNamespaceUri(), targetFiles);
}
if (! targetFiles.isEmpty()) {
for (final XmlFile targetFile : targetFiles) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
final String prefixByURI = XmlUtil.findNamespacePrefixByURI(targetFile, info.getNamespaceUri());
if (prefixByURI == null) return;
final PsiElementProcessor processor = new PsiElementProcessor() {
@Override
public boolean execute(@NotNull PsiElement element) {
if (element instanceof XmlTagImpl) {
if (isCertainTypeElement((XmlTagImpl)element, info.getTagName(), prefixByURI) ||
isElementWithEmbeddedType((XmlTagImpl)element, info.getTagName(), prefixByURI)) {
consumer.process(element);
return false;
}
}
return true;
}
};
XmlUtil.processXmlElements(targetFile, processor, true);
}
});
}
}
}
}
}
}
return true;
}