• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BidirectionalMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.util.containers.BidirectionalMap的典型用法代码示例。如果您正苦于以下问题:Java BidirectionalMap类的具体用法?Java BidirectionalMap怎么用?Java BidirectionalMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BidirectionalMap类属于com.intellij.util.containers包,在下文中一共展示了BidirectionalMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: collectQualifiers

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
private static BidirectionalMap<String, VirtualFile> collectQualifiers(VirtualFile resDirectory, VirtualFile file) {
  BidirectionalMap<String, VirtualFile> result = new BidirectionalMap<String, VirtualFile>();
  ResourceFolderType type = ResourceHelper.getFolderType(file);
  for (VirtualFile dir : resDirectory.getChildren()) {
    ResourceFolderType otherType = ResourceFolderType.getFolderType(dir.getName());
    if (otherType == type) {
      VirtualFile fileWithQualifier = dir.findChild(file.getName());
      if (fileWithQualifier != null) {
        String childName = dir.getName();
        int dashPos = childName.indexOf('-');
        String qualifier = dashPos > 0 ? childName.substring(dashPos+1) : "<default>";
        result.put(qualifier, fileWithQualifier);
      }
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ResourceQualifierSwitcher.java


示例2: SkeletonBuilder

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
public SkeletonBuilder(WireEventsListener treeNavigation) {
  mySkeleton = treeNavigation;

  myAwaitingParents = new MultiMap<AbstractHash, WaitingItem>();
  myBackIndex = new MultiMap<Integer, WaitingItem>();
  myRing = new Ring.IntegerRing();
  // wire number -> last commit on that wire
  mySeizedWires = new BidirectionalMap<Integer, Integer>();
  myFutureSeizedWires = new BidirectionalMap<Integer, AbstractHash>();
  myFutureConvertor = new Convertor<Integer, List<Integer>>() {
    @Override
    public List<Integer> convert(Integer o) {
      return getFutureWireStarts(o);
    }
  };
  myMaxWireNum = 0;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:SkeletonBuilder.java


示例3: getPrefixByNamespace

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
@Override
public String getPrefixByNamespace(String namespace)
{
	BidirectionalMap<String, String> map = getNamespaceMap();
	if(map != null)
	{
		List<String> keysByValue = map.getKeysByValue(namespace);
		final String ns = keysByValue == null || keysByValue.isEmpty() ? null : keysByValue.get(0);
		if(ns != null)
		{
			return ns;
		}
	}
	XmlTag parentTag = getParentTag();
	if(parentTag != null)
	{
		return parentTag.getPrefixByNamespace(namespace);
	}
	//The prefix 'xml' is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. It MAY, but need not, be declared
	if(XmlUtil.XML_NAMESPACE_URI.equals(namespace))
	{
		return XML_NS_PREFIX;
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:26,代码来源:XmlTagImpl.java


示例4: getAttributeValue

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
@Override
public String getAttributeValue(String _name, String namespace) {
  if (namespace == null) {
    return getAttributeValue(_name);
  }

  XmlTagImpl current = this;
  PsiElement parent = getParent();

  while (current != null) {
    BidirectionalMap<String, String> map = current.initNamespaceMaps(parent);
    if (map != null) {
      List<String> keysByValue = map.getKeysByValue(namespace);
      if (keysByValue != null && !keysByValue.isEmpty()) {

        for (String prefix : keysByValue) {
          if (prefix != null && !prefix.isEmpty()) {
            final String value = getAttributeValue(prefix + ":" + _name);
            if (value != null) return value;
          }
        }
      }
    }

    current = parent instanceof XmlTag ? (XmlTagImpl)parent : null;
    parent = parent.getParent();
  }

  if (namespace.isEmpty() || getNamespace().equals(namespace)) {
    return getAttributeValue(_name);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:XmlTagImpl.java


示例5: getPrefixByNamespace

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
@Override
public String getPrefixByNamespace(String namespace) {
  final PsiElement parent = getParent();
  BidirectionalMap<String, String> map = initNamespaceMaps(parent);
  if (map != null) {
    List<String> keysByValue = map.getKeysByValue(namespace);
    final String ns = keysByValue == null || keysByValue.isEmpty() ? null : keysByValue.get(0);
    if (ns != null) return ns;
  }
  if (parent instanceof XmlTag) return ((XmlTag)parent).getPrefixByNamespace(namespace);
  //The prefix 'xml' is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. It MAY, but need not, be declared
  if (XmlUtil.XML_NAMESPACE_URI.equals(namespace)) return XML_NS_PREFIX;
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:XmlTagImpl.java


示例6: knownNamespaces

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
@Override
public String[] knownNamespaces() {
  final PsiElement parentElement = getParent();
  BidirectionalMap<String, String> map = initNamespaceMaps(parentElement);
  Set<String> known = Collections.emptySet();
  if (map != null) {
    known = new HashSet<String>(map.values());
  }
  if (parentElement instanceof XmlTag) {
    if (known.isEmpty()) return ((XmlTag)parentElement).knownNamespaces();
    ContainerUtil.addAll(known, ((XmlTag)parentElement).knownNamespaces());
  }
  else {
    XmlExtension xmlExtension = XmlExtension.getExtensionByElement(this);
    if (xmlExtension != null) {
      final XmlFile xmlFile = xmlExtension.getContainingFile(this);
      if (xmlFile != null) {
        final XmlTag rootTag = xmlFile.getRootTag();
        if (rootTag != null && rootTag != this) {
          if (known.isEmpty()) return rootTag.knownNamespaces();
          ContainerUtil.addAll(known, rootTag.knownNamespaces());
        }
      }
    }
  }
  return ArrayUtil.toStringArray(known);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:XmlTagImpl.java


示例7: initNamespaceMaps

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
@Nullable
private BidirectionalMap<String, String> initNamespaceMaps(PsiElement parent) {
  BidirectionalMap<String, String> map = myNamespaceMap;

  if (map == null) {
    RecursionGuard.StackStamp stamp = ourGuard.markStack();
    map = computeNamespaceMap(parent);
    if (stamp.mayCacheNow()) {
      myNamespaceMap = map;
    }
  }

  return map;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:XmlTagImpl.java


示例8: createNotificationPanel

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
@Nullable
@Override
public ResourceQualifierSwitcherPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
  if (!ApplicationManager.getApplication().isInternal()) {
    return null;
  }
  if (file.getFileType() != XmlFileType.INSTANCE) {
    return null;
  }
  VirtualFile parent = file.getParent();
  if (parent == null) {
    return null;
  }
  parent = parent.getParent();
  if (parent == null || !parent.getName().equals("res")) {
    return null;
  }
  Module module = ModuleUtilCore.findModuleForFile(file, myProject);
  AndroidFacet facet = module == null ? null : AndroidFacet.getInstance(module);
  if (facet == null) {
    return null;
  }
  BidirectionalMap<String, VirtualFile> qualifiers = collectQualifiers(parent, file);
  if (qualifiers.size() <= 1) {
    return null;
  }
  return new ResourceQualifierSwitcherPanel(myProject, file, qualifiers);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:ResourceQualifierSwitcher.java


示例9: ResourceQualifierSwitcherPanel

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
public ResourceQualifierSwitcherPanel(final Project project, @NotNull final VirtualFile file, BidirectionalMap<String, VirtualFile> qualifiers) {
  super(new BorderLayout());
  myProject = project;
  myFile = file;
  myQualifiers = qualifiers;

  final String currentFileQualifier = qualifiers.getKeysByValue(file).get(0);
  final JLabel label = new JLabel(currentFileQualifier);
  label.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent event) {
      if (event.getButton() != MouseEvent.BUTTON1 || event.getClickCount() != 1) {
        return;
      }
      BidirectionalMap<String, VirtualFile> map = collectQualifiers(file.getParent().getParent(), file);
      ListPopupStep popupStep = new BaseListPopupStep<String>("Choose Qualifier", new ArrayList<String>(map.keySet())) {
        @Override
        public PopupStep onChosen(String selectedValue, boolean finalChoice) {
          switchToFile(selectedValue);
          return FINAL_CHOICE;
        }
      };
      ListPopup popup = JBPopupFactory.getInstance().createListPopup(popupStep);
      popup.showUnderneathOf(label);
    }
  });
  add(label, BorderLayout.WEST);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:ResourceQualifierSwitcher.java


示例10: getPrefixForURI

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
@Nullable
public String getPrefixForURI(String uri, XmlElement context) {
  final BidirectionalMap<String, String> bidiMap = new BidirectionalMap<String, String>();
  bidiMap.putAll(Namespace.makeMap(myNamespaceTableModel.getNamespaces()));
  final List<String> list = bidiMap.getKeysByValue(uri);
  return list != null && list.size() > 0 ? list.get(0) : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:EditContextDialog.java


示例11: check

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
void check(BidirectionalMap<PropertiesFile, PropertiesFile> parents,
List<PropertiesFile> files,
Map<PropertiesFile, Set<String>> keysUpToParent,
Map<PropertiesFile, Map<String, String>> propertiesFilesNamesMaps,
InspectionManager manager,
RefManager refManager,
ProblemDescriptionsProcessor processor);
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:InconsistentResourceBundleInspectionProvider.java


示例12: check

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
@Override
public void check(BidirectionalMap<PropertiesFile, PropertiesFile> parents,
                  List<PropertiesFile> files,
                  Map<PropertiesFile, Set<String>> keysUpToParent,
                  Map<PropertiesFile, Map<String, String>> propertiesFilesNamesMaps,
                  InspectionManager manager,
                  RefManager refManager,
                  ProblemDescriptionsProcessor processor) {
  for (PropertiesFile file : files) {
    PropertiesFile parent = parents.get(file);
    Set<String> parentKeys = keysUpToParent.get(parent);
    if (parent == null) {
      parentKeys = new THashSet<String>();
      for (PropertiesFile otherTopLevelFile : files) {
        if (otherTopLevelFile != file && parents.get(otherTopLevelFile) == null) {
          parent = otherTopLevelFile;
          parentKeys.addAll(propertiesFilesNamesMaps.get(otherTopLevelFile).keySet());
        }
      }
      if (parent == null) continue;
    }
    Set<String> keys = new THashSet<String>(propertiesFilesNamesMaps.get(file).keySet());
    keys.removeAll(parentKeys);
    for (String inconsistentKey : keys) {
      IProperty property = file.findPropertyByKey(inconsistentKey);
      assert property != null;
      String message = InspectionsBundle.message("inconsistent.bundle.property.error", inconsistentKey, parent.getName());
      ProblemDescriptor descriptor = manager.createProblemDescriptor(property.getPsiElement(), message, false, LocalQuickFix.EMPTY_ARRAY,
                                                                     ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
      processor.addProblemElement(refManager.getReference(file.getContainingFile()), descriptor);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:PropertiesKeysConsistencyInspectionProvider.java


示例13: check

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
@Override
public void check(BidirectionalMap<PropertiesFile, PropertiesFile> parents,
                  List<PropertiesFile> files,
                  Map<PropertiesFile, Set<String>> keysUpToParent,
                  Map<PropertiesFile, Map<String, String>> propertiesFilesNamesMaps,
                  InspectionManager manager,
                  RefManager refManager,
                  ProblemDescriptionsProcessor processor) {
  for (PropertiesFile file : files) {
    PropertiesFile parent = parents.get(file);
    if (parent == null) continue;
    Set<String> parentKeys = keysUpToParent.get(parent);
    Set<String> overriddenKeys = new THashSet<String>(propertiesFilesNamesMaps.get(file).keySet());
    overriddenKeys.retainAll(parentKeys);
    for (String overriddenKey : overriddenKeys) {
      IProperty property = file.findPropertyByKey(overriddenKey);
      assert property != null;
      while (parent != null) {
        IProperty parentProperty = parent.findPropertyByKey(overriddenKey);
        if (parentProperty != null && Comparing.strEqual(property.getValue(), parentProperty.getValue())) {
          String message = InspectionsBundle.message("inconsistent.bundle.property.inherited.with.the.same.value", parent.getName());
          ProblemDescriptor descriptor = manager.createProblemDescriptor(property.getPsiElement(), message,
                                                                         RemovePropertyLocalFix.INSTANCE,
                                                                         ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
          processor.addProblemElement(refManager.getReference(file.getContainingFile()), descriptor);
        }
        parent = parents.get(parent);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:DuplicatedPropertiesInspectionProvider.java


示例14: getAttributeValue

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
@Override
public String getAttributeValue(String _name, String namespace) {
  if (namespace == null) {
    return getAttributeValue(_name);
  }

  XmlTagImpl current = this;
  PsiElement parent = getParent();

  while (current != null) {
    BidirectionalMap<String, String> map = current.initNamespaceMaps(parent);
    if (map != null) {
      List<String> keysByValue = map.getKeysByValue(namespace);
      if (keysByValue != null && !keysByValue.isEmpty()) {

        for (String prefix : keysByValue) {
          if (prefix != null && prefix.length() > 0) {
            final String value = getAttributeValue(prefix + ":" + _name);
            if (value != null) return value;
          }
        }
      }
    }

    current = parent instanceof XmlTag ? (XmlTagImpl)parent : null;
    parent = parent.getParent();
  }

  if (namespace.length() == 0 || getNamespace().equals(namespace)) {
    return getAttributeValue(_name);
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:34,代码来源:XmlTagImpl.java


示例15: checkDuplicatedProperties

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
private static void checkDuplicatedProperties(final BidirectionalMap<PropertiesFile, PropertiesFile> parents,
                                              final List<PropertiesFile> files,
                                              final Map<PropertiesFile, Set<String>> keysUpToParent,
                                              final InspectionManager manager,
                                              RefManager refManager,
                                              ProblemDescriptionsProcessor processor) {
  for (PropertiesFile file : files) {
    PropertiesFile parent = parents.get(file);
    if (parent == null) continue;
    Set<String> parentKeys = keysUpToParent.get(parent);
    Set<String> overriddenKeys = new THashSet<String>(file.getNamesMap().keySet());
    overriddenKeys.retainAll(parentKeys);
    for (String overriddenKey : overriddenKeys) {
      IProperty property = file.findPropertyByKey(overriddenKey);
      assert property != null;
      while (parent != null) {
        IProperty parentProperty = parent.findPropertyByKey(overriddenKey);
        if (parentProperty != null && Comparing.strEqual(property.getValue(), parentProperty.getValue())) {
          String message = InspectionsBundle.message("inconsistent.bundle.property.inherited.with.the.same.value", parent.getName());
          ProblemDescriptor descriptor = manager.createProblemDescriptor(property.getPsiElement(), message,
                                                                         RemovePropertyLocalFix.INSTANCE,
                                                                         ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
          processor.addProblemElement(refManager.getReference(file.getContainingFile()), descriptor);
        }
        parent = parents.get(parent);
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:InconsistentResourceBundleInspection.java


示例16: checkConsistency

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
private static void checkConsistency(final BidirectionalMap<PropertiesFile, PropertiesFile> parents, final List<PropertiesFile> files,
                                     final Map<PropertiesFile, Set<String>> keysUpToParent,
                                     final InspectionManager manager,
                                     RefManager refManager, ProblemDescriptionsProcessor processor) {
  for (PropertiesFile file : files) {
    PropertiesFile parent = parents.get(file);
    Set<String> parentKeys = keysUpToParent.get(parent);
    if (parent == null) {
      parentKeys = new THashSet<String>();
      for (PropertiesFile otherTopLevelFile : files) {
        if (otherTopLevelFile != file && parents.get(otherTopLevelFile) == null) {
          parent = otherTopLevelFile;
          parentKeys.addAll(otherTopLevelFile.getNamesMap().keySet());
        }
      }
      if (parent == null) continue;
    }
    Set<String> keys = new THashSet<String>(file.getNamesMap().keySet());
    keys.removeAll(parentKeys);
    for (String inconsistentKey : keys) {
      IProperty property = file.findPropertyByKey(inconsistentKey);
      assert property != null;
      String message = InspectionsBundle.message("inconsistent.bundle.property.error", inconsistentKey, parent.getName());
      ProblemDescriptor descriptor = manager.createProblemDescriptor(property.getPsiElement(), message, false, LocalQuickFix.EMPTY_ARRAY,
                                                                     ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
      processor.addProblemElement(refManager.getReference(file.getContainingFile()), descriptor);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:InconsistentResourceBundleInspection.java


示例17: checkMissingTranslations

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
private static void checkMissingTranslations(final BidirectionalMap<PropertiesFile, PropertiesFile> parents,
                                             final List<PropertiesFile> files,
                                             final Map<PropertiesFile, Set<String>> keysUpToParent,
                                             final InspectionManager manager,
                                             RefManager refManager,
                                             ProblemDescriptionsProcessor processor) {
  for (PropertiesFile file : files) {
    PropertiesFile parent = parents.get(file);
    if (parent == null) continue;
    List<PropertiesFile> children = parents.getKeysByValue(file);
    boolean isLeaf = children == null || children.isEmpty();
    if (!isLeaf) continue;
    Set<String> keys = file.getNamesMap().keySet();
    Set<String> parentKeys = new THashSet<String>(keysUpToParent.get(parent));
    if (parent.getLocale().getLanguage().equals(file.getLocale().getLanguage())) {
      // properties can be left untranslated in the dialect files
      keys = new THashSet<String>(keys);
      keys.addAll(parent.getNamesMap().keySet());
      parent = parents.get(parent);
      if (parent == null) continue;
      parentKeys = new THashSet<String>(keysUpToParent.get(parent));
    }
    parentKeys.removeAll(keys);
    for (String untranslatedKey : parentKeys) {
      IProperty untranslatedProperty = null;
      PropertiesFile untranslatedFile = parent;
      while (untranslatedFile != null) {
        untranslatedProperty = untranslatedFile.findPropertyByKey(untranslatedKey);
        if (untranslatedProperty != null) break;
        untranslatedFile = parents.get(untranslatedFile);
      }
      assert untranslatedProperty != null;
      String message = InspectionsBundle.message("inconsistent.bundle.untranslated.property.error", untranslatedKey, file.getName());
      ProblemDescriptor descriptor = manager.createProblemDescriptor(untranslatedProperty.getPsiElement(), message, false, LocalQuickFix.EMPTY_ARRAY,
                                                                     ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
      processor.addProblemElement(refManager.getReference(untranslatedFile.getContainingFile()), descriptor);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:40,代码来源:InconsistentResourceBundleInspection.java


示例18: knownNamespaces

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
@Override
public String[] knownNamespaces()
{
	final PsiElement parentElement = getParent();
	BidirectionalMap<String, String> map = getNamespaceMap();
	Set<String> known = Collections.emptySet();
	if(map != null)
	{
		known = new HashSet<>(map.values());
	}
	if(parentElement instanceof XmlTag)
	{
		if(known.isEmpty())
		{
			return ((XmlTag) parentElement).knownNamespaces();
		}
		ContainerUtil.addAll(known, ((XmlTag) parentElement).knownNamespaces());
	}
	else
	{
		XmlExtension xmlExtension = XmlExtension.getExtensionByElement(this);
		if(xmlExtension != null)
		{
			final XmlFile xmlFile = xmlExtension.getContainingFile(this);
			if(xmlFile != null)
			{
				final XmlTag rootTag = xmlFile.getRootTag();
				if(rootTag != null && rootTag != this)
				{
					if(known.isEmpty())
					{
						return rootTag.knownNamespaces();
					}
					ContainerUtil.addAll(known, rootTag.knownNamespaces());
				}
			}
		}
	}
	return ArrayUtil.toStringArray(known);
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:41,代码来源:XmlTagImpl.java


示例19: getNamespaceByPrefix

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
@Override
@NotNull
public String getNamespaceByPrefix(String prefix) {
  final PsiElement parent = getParent();
  if (!parent.isValid()) {
    LOG.error(this.isValid());
  }
  BidirectionalMap<String, String> map = initNamespaceMaps(parent);
  if (map != null) {
    final String ns = map.get(prefix);
    if (ns != null) return ns;
  }
  if (parent instanceof XmlTag) return ((XmlTag)parent).getNamespaceByPrefix(prefix);
  //The prefix 'xml' is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. It MAY, but need not, be declared
  if (XML_NS_PREFIX.equals(prefix)) return XmlUtil.XML_NAMESPACE_URI;

  if (!prefix.isEmpty() &&
      !hasNamespaceDeclarations() &&
      getNamespacePrefix().equals(prefix)) {
    // When there is no namespace declarations then qualified names should be just used in dtds
    // this implies that we may have "" namespace prefix ! (see last paragraph in Namespaces in Xml, Section 5)

    String result = ourGuard.doPreventingRecursion("getNsByPrefix", true, new Computable<String>() {
      @Override
      public String compute() {
        final String nsFromEmptyPrefix = getNamespaceByPrefix("");
        final XmlNSDescriptor nsDescriptor = getNSDescriptor(nsFromEmptyPrefix, false);
        final XmlElementDescriptor descriptor = nsDescriptor != null ? nsDescriptor.getElementDescriptor(XmlTagImpl.this) : null;
        final String nameFromRealDescriptor =
          descriptor != null && descriptor.getDeclaration() != null && descriptor.getDeclaration().isPhysical()
          ? descriptor.getName()
          : "";
        if (nameFromRealDescriptor.equals(getName())) return nsFromEmptyPrefix;
        return XmlUtil.EMPTY_URI;
      }
    });
    if (result != null) {
      return result;
    }
  }
  return XmlUtil.EMPTY_URI;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:XmlTagImpl.java


示例20: computeNamespaceMap

import com.intellij.util.containers.BidirectionalMap; //导入依赖的package包/类
@Nullable
private BidirectionalMap<String, String> computeNamespaceMap(PsiElement parent) {
  BidirectionalMap<String, String> map = null;
  boolean hasNamespaceDeclarations = hasNamespaceDeclarations();
  if (hasNamespaceDeclarations) {
    map = new BidirectionalMap<String, String>();
    final XmlAttribute[] attributes = getAttributes();

    for (final XmlAttribute attribute : attributes) {
      if (attribute.isNamespaceDeclaration()) {
        final String name = attribute.getName();
        int splitIndex = name.indexOf(':');
        final String value = getRealNs(attribute.getValue());

        if (value != null) {
          if (splitIndex < 0) {
            map.put("", value);
          }
          else {
            map.put(XmlUtil.findLocalNameByQualifiedName(name), value);
          }
        }
      }
    }
  }

  if (parent instanceof XmlDocument) {
    final XmlExtension extension = XmlExtension.getExtensionByElement(parent);
    if (extension != null) {
      final String[][] namespacesFromDocument = extension.getNamespacesFromDocument((XmlDocument)parent, hasNamespaceDeclarations);
      if (namespacesFromDocument != null) {
        if (map == null) {
          map = new BidirectionalMap<String, String>();
        }
        for (final String[] prefix2ns : namespacesFromDocument) {
          map.put(prefix2ns[0], getRealNs(prefix2ns[1]));
        }
      }
    }
  }
  return map;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:XmlTagImpl.java



注:本文中的com.intellij.util.containers.BidirectionalMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Renderer类代码示例发布时间:2022-05-23
下一篇:
Java JMVCommandEvent类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap