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


Java XPathTokenTypes.RBRACE属性代码示例

本文整理汇总了Java中org.intellij.lang.xpath.XPathTokenTypes.RBRACE属性的典型用法代码示例。如果您正苦于以下问题:Java XPathTokenTypes.RBRACE属性的具体用法?Java XPathTokenTypes.RBRACE怎么用?Java XPathTokenTypes.RBRACE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.intellij.lang.xpath.XPathTokenTypes的用法示例。


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

示例1: getInjectionRanges

@NotNull
private synchronized TextRange[] getInjectionRanges(final XmlAttribute attribute, XsltChecker.LanguageLevel languageLevel) {
  final TextRange[] cachedFiles = getCachedRanges(attribute);
  if (cachedFiles != null) {
    return cachedFiles;
  }

  final String value = attribute.getDisplayValue();
  if (value == null) return EMPTY_ARRAY;

  final TextRange[] ranges;
  if (XsltSupport.mayBeAVT(attribute)) {
    final List<TextRange> avtRanges = new SmartList<TextRange>();

    int i;
    int j = 0;
    Lexer lexer = null;
    while ((i = XsltSupport.getAVTOffset(value, j)) != -1) {
      if (lexer == null) {
        lexer = LanguageParserDefinitions.INSTANCE.forLanguage(languageLevel.getXPathVersion().getLanguage())
          .createLexer(attribute.getProject());
      }

      // "A right curly brace inside a Literal in an expression is not recognized as terminating the expression."
      lexer.start(value, i, value.length());
      j = -1;
      while (lexer.getTokenType() != null) {
        if (lexer.getTokenType() == XPathTokenTypes.RBRACE) {
          j = lexer.getTokenStart();
          break;
        }
        lexer.advance();
      }

      if (j != -1) {
        avtRanges.add(AVTRange.create(attribute, i, j + 1, j > i + 1));
      } else {
        // missing '}' error will be flagged by xpath parser
        avtRanges.add(AVTRange.create(attribute, i, value.length(), false));
        break;
      }
    }

    if (avtRanges.size() > 0) {
      ranges = avtRanges.toArray(new TextRange[avtRanges.size()]);
    } else {
      ranges = EMPTY_ARRAY;
    }
  } else {
    ranges = new TextRange[]{ attribute.getValueTextRange() };
  }

  attribute.putUserData(CACHED_FILES, Pair.create(attribute.getValue(), ranges));

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

示例2: getInjectionRanges

@NotNull
private synchronized TextRange[] getInjectionRanges(final XmlAttribute attribute, XsltChecker.LanguageLevel languageLevel)
{
	final TextRange[] cachedFiles = getCachedRanges(attribute);
	if(cachedFiles != null)
	{
		return cachedFiles;
	}

	final String value = attribute.getDisplayValue();
	if(value == null)
	{
		return EMPTY_ARRAY;
	}

	final TextRange[] ranges;
	if(XsltSupport.mayBeAVT(attribute))
	{
		final List<TextRange> avtRanges = new SmartList<TextRange>();

		int i;
		int j = 0;
		Lexer lexer = null;
		while((i = XsltSupport.getAVTOffset(value, j)) != -1)
		{
			if(lexer == null)
			{
				Language language = languageLevel.getXPathVersion().getLanguage();
				lexer = LanguageParserDefinitions.INSTANCE.forLanguage(language).createLexer(LanguageVersionUtil.findDefaultVersion(language));
			}

			// "A right curly brace inside a Literal in an expression is not recognized as terminating the expression."
			lexer.start(value, i, value.length());
			j = -1;
			while(lexer.getTokenType() != null)
			{
				if(lexer.getTokenType() == XPathTokenTypes.RBRACE)
				{
					j = lexer.getTokenStart();
					break;
				}
				lexer.advance();
			}

			if(j != -1)
			{
				avtRanges.add(AVTRange.create(attribute, i, j + 1, j > i + 1));
			}
			else
			{
				// missing '}' error will be flagged by xpath parser
				avtRanges.add(AVTRange.create(attribute, i, value.length(), false));
				break;
			}
		}

		if(avtRanges.size() > 0)
		{
			ranges = avtRanges.toArray(new TextRange[avtRanges.size()]);
		}
		else
		{
			ranges = EMPTY_ARRAY;
		}
	}
	else
	{
		ranges = new TextRange[]{attribute.getValueTextRange()};
	}

	attribute.putUserData(CACHED_FILES, Pair.create(attribute.getValue(), ranges));

	return ranges;
}
 
开发者ID:consulo,项目名称:consulo-xslt,代码行数:74,代码来源:XPathLanguageInjector.java


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