当前位置: 首页>>代码示例>>Java>>正文


Java NamespaceContext类代码示例

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


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

示例1: checkPrefixReferences

import org.intellij.lang.xpath.context.NamespaceContext; //导入依赖的package包/类
private static void checkPrefixReferences(AnnotationHolder holder, QNameElement element, ContextProvider myProvider) {
  final PsiReference[] references = element.getReferences();
  for (PsiReference reference : references) {
    if (reference instanceof PrefixReference) {
      final PrefixReference pr = ((PrefixReference)reference);
      if (!pr.isSoft() && pr.isUnresolved()) {
        final TextRange range = pr.getRangeInElement().shiftRight(pr.getElement().getTextRange().getStartOffset());
        final Annotation a = holder.createErrorAnnotation(range, "Unresolved namespace prefix '" + pr.getCanonicalText() + "'");
        a.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);

        final NamespaceContext namespaceContext = myProvider.getNamespaceContext();
        final PrefixedName qName = element.getQName();
        if (namespaceContext != null && qName != null) {
          final IntentionAction[] fixes = namespaceContext.getUnresolvedNamespaceFixes(reference, qName.getLocalName());
          for (IntentionAction fix : fixes) {
            a.registerFix(fix);
          }
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:XPathAnnotator.java

示例2: namespaceMatches

import org.intellij.lang.xpath.context.NamespaceContext; //导入依赖的package包/类
private static boolean namespaceMatches(PrefixedName prefixedName,
                                        String uri,
                                        NamespaceContext namespaceContext,
                                        XmlElement context,
                                        boolean allowDefault) {
  if (namespaceContext == null) return true;

  final String namespaceURI;
  if (prefixedName.getPrefix() != null) {
    if (uri == null || uri.length() == 0) return false;

    namespaceURI = namespaceContext.getNamespaceURI(prefixedName.getPrefix(), context);
  } else {
    if (!allowDefault) return (uri == null || uri.length() == 0);

    if ((namespaceURI = namespaceContext.getDefaultNamespace(context)) == null) {
      return (uri == null || uri.length() == 0);
    }
  }
  return uri.equals(namespaceURI);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CompletionLists.java

示例3: getSettings

import org.intellij.lang.xpath.context.NamespaceContext; //导入依赖的package包/类
protected RefactoringOptions getSettings(XPathExpression expression, Set<XPathExpression> matchingExpressions) {
  final String name = Messages.showInputDialog(expression.getProject(), "Function Name: ", getRefactoringName(), Messages.getQuestionIcon());
  final boolean[] b = new boolean[]{false};
  if (name != null) {
    final String[] parts = name.split(":", 2);
    if (parts.length < 2) {
      Messages.showMessageDialog(expression.getProject(), "Custom functions require a prefixed name", "Error", Messages.getErrorIcon());
      b[0] = true;
    }
    final XmlElement context = PsiTreeUtil.getContextOfType(expression, XmlElement.class);
    final NamespaceContext namespaceContext = expression.getXPathContext().getNamespaceContext();
    if (namespaceContext != null && context != null && namespaceContext.resolve(parts[0], context) == null) {
      Messages.showMessageDialog(expression.getProject(), "Prefix '" + parts[0] + "' is not defined", "Error", Messages.getErrorIcon());
      b[0] = true;
    }
  }
  return new RefactoringOptions() {
    @Override
    public boolean isCanceled() {
      return b[0];
    }

    @Override
    public String getName() {
      return name;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:XsltExtractFunctionAction.java

示例4: addNamespaceCompletions

import org.intellij.lang.xpath.context.NamespaceContext; //导入依赖的package包/类
private static void addNamespaceCompletions(NamespaceContext namespaceContext, Set<Lookup> list, XmlElement context) {
  if (namespaceContext != null) {
    final Collection<String> knownPrefixes = namespaceContext.getKnownPrefixes(context);
    for (String prefix : knownPrefixes) {
      if (prefix != null && prefix.length() > 0) {
        list.add(new NamespaceLookup(prefix));
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:CompletionLists.java

示例5: resolve

import org.intellij.lang.xpath.context.NamespaceContext; //导入依赖的package包/类
@Nullable
public PsiElement resolve() {
  final ContextProvider provider = getElement().getXPathContext();
  final NamespaceContext namespaceContext = provider.getNamespaceContext();
  if (namespaceContext != null) {
    return namespaceContext.resolve(getCanonicalText(), provider.getContextElement());
  } else {
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PrefixReferenceImpl.java

示例6: install

import org.intellij.lang.xpath.context.NamespaceContext; //导入依赖的package包/类
@TestOnly
public static void install(Disposable parent) {
  final NamespaceContext old = ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT;
  ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = TestNamespaceContext.INSTANCE;
  Disposer.register(parent, new Disposable() {
    @Override
    public void dispose() {
      ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = old;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:TestNamespaceContext.java

示例7: getNamespaceContext

import org.intellij.lang.xpath.context.NamespaceContext; //导入依赖的package包/类
@Override
public NamespaceContext getNamespaceContext() {
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:XPathSupportProxyImpl.java

示例8: getNamespaceContext

import org.intellij.lang.xpath.context.NamespaceContext; //导入依赖的package包/类
@NotNull
public NamespaceContext getNamespaceContext() {
  return XsltNamespaceContext.NAMESPACE_CONTEXT;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:XsltContextProviderBase.java

示例9: getFunctionCompletions

import org.intellij.lang.xpath.context.NamespaceContext; //导入依赖的package包/类
public static Collection<Lookup> getFunctionCompletions(XPathElement element) {
  final XPathFile xpathFile = (XPathFile)element.getContainingFile();

  final ContextProvider contextProvider = ContextProvider.getContextProvider(xpathFile);
  final NamespaceContext nsContext = contextProvider.getNamespaceContext();

  String uri;
  PrefixedName qn = null;
  if (element instanceof QNameElement) {
    qn = ((QNameElement)element).getQName();
    if (qn != null) {
      QName qName = contextProvider.getQName(qn, element);
      if (qn.getPrefix() != null) {
        if (qName != null) {
          uri = qName.getNamespaceURI();
        } else {
          return Collections.emptySet();
        }
      } else {
        uri = null;
      }
    } else {
      uri = null;
    }
  } else {
    uri = null;
  }

  final Map<Pair<QName, Integer>, ? extends Function> functions = contextProvider.getFunctionContext().getFunctions();
  final List<Lookup> lookups = new ArrayList<Lookup>(functions.size());
  for (Map.Entry<Pair<QName, Integer>, ? extends Function> entry : functions.entrySet()) {
    final Function functionDecl = entry.getValue();
    final QName f = entry.getKey().first;
    final String p;
    if (nsContext != null) {
      String namespaceURI = f.getNamespaceURI();
      if (uri != null && !namespaceURI.equals(uri)) {
        continue;
      }
      final String prefixForURI = nsContext.getPrefixForURI(namespaceURI, PsiTreeUtil.getContextOfType(element, XmlElement.class, true));
      if (prefixForURI == null && namespaceURI.length() > 0) {
        continue;
      }
      p = qn == null || qn.getPrefix() == null ? makePrefix(prefixForURI) : "";
    } else {
      p = "";
    }
    lookups.add(FunctionLookup.newFunctionLookup(p + f.getLocalPart(), functionDecl));
  }
  return lookups;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:52,代码来源:CompletionLists.java

示例10: canResolve

import org.intellij.lang.xpath.context.NamespaceContext; //导入依赖的package包/类
private boolean canResolve() {
  final NamespaceContext namespaceContext = getElement().getXPathContext().getNamespaceContext();
  return namespaceContext != null && !"xml".equals(getCanonicalText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:PrefixReferenceImpl.java

示例11: getNamespaceContext

import org.intellij.lang.xpath.context.NamespaceContext; //导入依赖的package包/类
public NamespaceContext getNamespaceContext() {
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:4,代码来源:XPathSupportProxyImpl.java

示例12: getNamespaceContext

import org.intellij.lang.xpath.context.NamespaceContext; //导入依赖的package包/类
@Nullable
@Override
public NamespaceContext getNamespaceContext(@NotNull XmlElement xmlElement)
{
	return XsltNamespaceContext.NAMESPACE_CONTEXT;
}
 
开发者ID:consulo,项目名称:consulo-xslt,代码行数:7,代码来源:XsltNamespaceContextProvider.java


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