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


Java InjectedLanguageUtil.hasInjections方法代码示例

本文整理汇总了Java中com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil.hasInjections方法的典型用法代码示例。如果您正苦于以下问题:Java InjectedLanguageUtil.hasInjections方法的具体用法?Java InjectedLanguageUtil.hasInjections怎么用?Java InjectedLanguageUtil.hasInjections使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil的用法示例。


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

示例1: tokenize

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Override
public void tokenize(@NotNull PsiLiteralExpression element, TokenConsumer consumer) {
  PsiLiteralExpressionImpl literalExpression = (PsiLiteralExpressionImpl)element;
  if (literalExpression.getLiteralElementType() != JavaTokenType.STRING_LITERAL) return;  // not a string literal

  String text = literalExpression.getInnerText();
  if (StringUtil.isEmpty(text) || text.length() <= 2) { // optimisation to avoid expensive injection check
    return;
  }
  if (InjectedLanguageUtil.hasInjections(literalExpression)) return;

  final PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(element, PsiModifierListOwner.class);
  if (listOwner != null && AnnotationUtil.isAnnotated(listOwner, Collections.singleton(AnnotationUtil.NON_NLS), false, false)) {
    return;
  }

  if (!text.contains("\\")) {
    consumer.consumeToken(element, PlainTextSplitter.getInstance());
  }
  else {
    processTextWithEscapeSequences(element, text, consumer);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:LiteralExpressionTokenizer.java

示例2: tokenize

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
public void tokenize(@NotNull final XmlAttributeValue element, final TokenConsumer consumer)
{
	if(element instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost) element))
	{
		return;
	}

	final String valueTextTrimmed = element.getValue().trim();
	// do not inspect colors like #00aaFF
	if(valueTextTrimmed.startsWith("#") && valueTextTrimmed.length() <= 7 && isHexString(valueTextTrimmed.substring(1)))
	{
		return;
	}

	consumer.consumeToken(element, TextSplitter.getInstance());
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:17,代码来源:XmlBaseSpellcheckingStrategy.java

示例3: getTokenizer

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@NotNull
public Tokenizer getTokenizer(PsiElement element) {
  if (element instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)element)) {
    return EMPTY_TOKENIZER;
  }
  if (element instanceof PsiNameIdentifierOwner) return new PsiIdentifierOwnerTokenizer();
  if (element instanceof PsiComment) {
    if (SuppressionUtil.isSuppressionComment(element)) {
      return EMPTY_TOKENIZER;
    }
    return myCommentTokenizer;
  }
  if (element instanceof XmlAttributeValue) return myXmlAttributeTokenizer;
  if (element instanceof XmlText) return myXmlTextTokenizer;
  if (element instanceof PsiPlainText) {
    PsiFile file = element.getContainingFile();
    FileType fileType = file == null ? null : file.getFileType();
    if (fileType instanceof CustomSyntaxTableFileType) {
      return new CustomFileTypeTokenizer(((CustomSyntaxTableFileType)fileType).getSyntaxTable());
    }
    return TEXT_TOKENIZER;
  }
  if (element instanceof XmlToken) {
    if (((XmlToken)element).getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) {
      PsiElement injection = InjectedLanguageManager.getInstance(element.getProject()).findInjectedElementAt(element.getContainingFile(), element.getTextOffset());
      if (injection == null) {
        return TEXT_TOKENIZER;
      }
    }

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

示例4: tokenize

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
public void tokenize(@NotNull final XmlAttributeValue element, final TokenConsumer consumer) {
  if (element instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)element)) return;

  final String valueTextTrimmed = element.getValue().trim();
  // do not inspect colors like #00aaFF
  if (valueTextTrimmed.startsWith("#") && valueTextTrimmed.length() <= 7 && isHexString(valueTextTrimmed.substring(1))) {
    return;
  }

  consumer.consumeToken(element, TextSplitter.getInstance());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:SpellcheckingStrategy.java

示例5: tokenize

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Override
public void tokenize(@NotNull T element, TokenConsumer consumer) {
  if (element instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)element)) {
    return;
  }
  consumer.consumeToken(element, mySplitter);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:TokenizerBase.java

示例6: isInsidePlainComment

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static boolean isInsidePlainComment(int offset, @Nullable PsiElement element) {
  if (!(element instanceof PsiComment) || element instanceof PsiDocCommentBase || !element.getTextRange().contains(offset - 1)) {
    return false;
  }

  if (element instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)element)) {
    return false;
  }

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

示例7: getReferencesByElement

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {

  if (XmlSchemaTagsProcessor.PROCESSING_FLAG.get() != null || context.get(SUPPRESS) != null) {
    return PsiReference.EMPTY_ARRAY;
  }
  @SuppressWarnings("unchecked") PsiElement host = getHost((T)element);
  if (host instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)host)) {
    return PsiReference.EMPTY_ARRAY;
  }
  String unquotedValue = ElementManipulators.getValueText(element);
  if (XmlHighlightVisitor.skipValidation(element) || !XmlUtil.isSimpleValue(unquotedValue, element)) {
    return PsiReference.EMPTY_ARRAY;
  }
  @SuppressWarnings("unchecked") final Object descriptor = getDescriptor((T)element);
  if (descriptor instanceof XmlEnumerationDescriptor) {
    XmlEnumerationDescriptor enumerationDescriptor = (XmlEnumerationDescriptor)descriptor;

    if (enumerationDescriptor.isFixed() || enumerationDescriptor.isEnumerated((XmlElement)element)) {
      //noinspection unchecked
      return enumerationDescriptor.getValueReferences((XmlElement)element, unquotedValue);
    }
    else if (unquotedValue.equals(enumerationDescriptor.getDefaultValue())) {  // todo case insensitive
      return ContainerUtil.map2Array(enumerationDescriptor.getValueReferences((XmlElement)element, unquotedValue), PsiReference.class,
                                     new Function<PsiReference, PsiReference>() {
                                       @Override
                                       public PsiReference fun(PsiReference reference) {
                                         return PsiDelegateReference.createSoft(reference, true);
                                       }
                                     });
    }
  }
  return PsiReference.EMPTY_ARRAY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:XmlEnumeratedValueReferenceProvider.java

示例8: satisfiedBy

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
public boolean satisfiedBy(PsiElement element) {
  //final PsiFile file = element.getContainingFile();
  //if (file instanceof JspFile){
  //    return false;
  //}
  if (!(element instanceof PsiComment)) {
    return false;
  }
  if (element instanceof PsiDocComment) {
    return false;
  }

  final PsiComment comment = (PsiComment)element;
  if (comment instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)comment)) {
    return false;
  }
  final IElementType type = comment.getTokenType();
  if (!JavaTokenType.C_STYLE_COMMENT.equals(type) &&
      !JavaTokenType.END_OF_LINE_COMMENT.equals(type)) {
    return false; // can't move JSP comments
  }
  final PsiElement prevSibling = PsiTreeUtil.prevLeaf(element);
  if (!(prevSibling instanceof PsiWhiteSpace)) {
    return true;
  }
  final String prevSiblingText = prevSibling.getText();
  if (prevSiblingText.indexOf((int)'\n') < 0 &&
      prevSiblingText.indexOf((int)'\r') < 0) {
    return true;
  }
  final PsiElement nextSibling = PsiTreeUtil.nextLeaf(element);
  if (!(nextSibling instanceof PsiWhiteSpace)) {
    return true;
  }
  final String nextSiblingText = nextSibling.getText();
  return nextSiblingText.indexOf((int)'\n') < 0 &&
         nextSiblingText.indexOf((int)'\r') < 0;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:CommentOnLineWithSourcePredicate.java

示例9: isInsidePlainComment

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static boolean isInsidePlainComment(int offset, @Nullable PsiElement element) {
  if (!(element instanceof PsiComment) || !element.getTextRange().contains(offset)) {
    return false;
  }

  if (element instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)element)) {
    return false;
  }

  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:CodeStyleManagerRunnable.java

示例10: findDeclarationsAt

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
public void findDeclarationsAt(@NotNull PsiElement psiElement, int offsetInElement, Consumer<PomTarget> consumer) {
  if (!(psiElement instanceof XmlToken)) return;

  final IElementType tokenType = ((XmlToken)psiElement).getTokenType();

  final DomManager domManager = DomManager.getDomManager(psiElement.getProject());
  final DomElement nameElement;
  if (tokenType == XmlTokenType.XML_DATA_CHARACTERS && psiElement.getParent() instanceof XmlText && psiElement.getParent().getParent() instanceof XmlTag) {
    final XmlTag tag = (XmlTag)psiElement.getParent().getParent();
    for (XmlText text : tag.getValue().getTextElements()) {
      if (InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)text)) {
        return;
      }
    }

    nameElement = domManager.getDomElement(tag);
  } else if (tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN && psiElement.getParent() instanceof XmlAttributeValue && psiElement.getParent().getParent() instanceof XmlAttribute) {
    final PsiElement attributeValue = psiElement.getParent();
    if (InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)attributeValue)) {
      return;
    }
    nameElement = domManager.getDomElement((XmlAttribute)attributeValue.getParent());
  } else {
    return;
  }

  if (!(nameElement instanceof GenericDomValue)) {
    return;
  }

  DomElement parent = nameElement.getParent();
  if (parent == null) {
    return;
  }

  final DomTarget target = createDomTarget(parent, nameElement);
  if (target != null) {
    consumer.consume(target);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:41,代码来源:AbstractDomDeclarationSearcher.java

示例11: getReferencesByElement

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context)
{

	if(XmlSchemaTagsProcessor.PROCESSING_FLAG.get() != null || context.get(SUPPRESS) != null)
	{
		return PsiReference.EMPTY_ARRAY;
	}
	@SuppressWarnings("unchecked") PsiElement host = getHost((T) element);
	if(host instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost) host))
	{
		return PsiReference.EMPTY_ARRAY;
	}
	String unquotedValue = ElementManipulators.getValueText(element);
	if(XmlHighlightVisitor.skipValidation(element) || !XmlUtil.isSimpleValue(unquotedValue, element))
	{
		return PsiReference.EMPTY_ARRAY;
	}
	@SuppressWarnings("unchecked") final Object descriptor = getDescriptor((T) element);
	if(descriptor instanceof XmlEnumerationDescriptor)
	{
		XmlEnumerationDescriptor enumerationDescriptor = (XmlEnumerationDescriptor) descriptor;

		if(enumerationDescriptor.isFixed() || enumerationDescriptor.isEnumerated((XmlElement) element))
		{
			//noinspection unchecked
			return enumerationDescriptor.getValueReferences((XmlElement) element, unquotedValue);
		}
		else if(unquotedValue.equals(enumerationDescriptor.getDefaultValue()))
		{  // todo case insensitive
			return ContainerUtil.map2Array(enumerationDescriptor.getValueReferences((XmlElement) element, unquotedValue), PsiReference.class, reference -> PsiDelegateReference.createSoft
					(reference, true));
		}
	}
	return PsiReference.EMPTY_ARRAY;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:38,代码来源:XmlEnumeratedValueReferenceProvider.java

示例12: createJavaBlock

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@NotNull
private Block createJavaBlock(@NotNull ASTNode child,
                              @NotNull CommonCodeStyleSettings settings,
                              @NotNull JavaCodeStyleSettings javaSettings,
                              @Nullable Indent indent,
                              Wrap wrap,
                              @NotNull AlignmentStrategy alignmentStrategy,
                              int startOffset) {
  Indent actualIndent = indent == null ? getDefaultSubtreeIndent(child, getJavaIndentOptions(settings)) : indent;
  final IElementType elementType = child.getElementType();
  Alignment alignment = alignmentStrategy.getAlignment(elementType);

  if (child.getPsi() instanceof PsiWhiteSpace) {
    String text = child.getText();
    int start = CharArrayUtil.shiftForward(text, 0, " \t\n");
    int end = CharArrayUtil.shiftBackward(text, text.length() - 1, " \t\n") + 1;
    LOG.assertTrue(start < end);
    return new PartialWhitespaceBlock(child, new TextRange(start + child.getStartOffset(), end + child.getStartOffset()),
                                      wrap, alignment, actualIndent, settings, javaSettings);
  }
  if (child.getPsi() instanceof PsiClass) {
    return new CodeBlockBlock(child, wrap, alignment, actualIndent, settings, javaSettings);
  }
  if (isBlockType(elementType)) {
    return new BlockContainingJavaBlock(child, wrap, alignment, actualIndent, settings, javaSettings);
  }
  if (isStatement(child, child.getTreeParent())) {
    return new CodeBlockBlock(child, wrap, alignment, actualIndent, settings, javaSettings);
  }
  if (!isBuildIndentsOnly() &&
      child instanceof PsiComment &&
      child instanceof PsiLanguageInjectionHost &&
      InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)child)) {
    return new CommentWithInjectionBlock(child, wrap, alignment, indent, settings, javaSettings);
  }
  if (child instanceof LeafElement) {
    final LeafBlock block = new LeafBlock(child, wrap, alignment, actualIndent);
    block.setStartOffset(startOffset);
    return block;
  }
  else if (isLikeExtendsList(elementType)) {
    return new ExtendsListBlock(child, wrap, alignmentStrategy, settings, javaSettings);
  }
  else if (elementType == JavaElementType.CODE_BLOCK) {
    return new CodeBlockBlock(child, wrap, alignment, actualIndent, settings, javaSettings);
  }
  else if (elementType == JavaElementType.LABELED_STATEMENT) {
    return new LabeledJavaBlock(child, wrap, alignment, actualIndent, settings, javaSettings);
  }
  else if (elementType == JavaDocElementType.DOC_COMMENT) {
    return new DocCommentBlock(child, wrap, alignment, actualIndent, settings, javaSettings);
  }
  else {
    final SimpleJavaBlock simpleJavaBlock = new SimpleJavaBlock(child, wrap, alignmentStrategy, actualIndent, settings, javaSettings);
    simpleJavaBlock.setStartOffset(startOffset);
    return simpleJavaBlock;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:59,代码来源:AbstractJavaBlock.java

示例13: tokenize

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Override
public void tokenize(@NotNull XmlText element, TokenConsumer consumer) {
  if (element instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)element)) return;
  processChildren(element, consumer);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:XmlTextTokenizer.java

示例14: getReferencesByElement

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Override
@NotNull
public final PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull final ProcessingContext context) {
  final DomManagerImpl domManager = DomManagerImpl.getDomManager(psiElement.getProject());

  final DomInvocationHandler<?, ?> handler;
  if (psiElement instanceof XmlTag) {
    handler = domManager.getDomHandler((XmlTag)psiElement);
  } else if (psiElement instanceof XmlAttributeValue && psiElement.getParent() instanceof XmlAttribute) {
    handler = domManager.getDomHandler((XmlAttribute)psiElement.getParent());
  } else {
    return PsiReference.EMPTY_ARRAY;
  }

  if (handler == null || !GenericDomValue.class.isAssignableFrom(handler.getRawType())) {
    return PsiReference.EMPTY_ARRAY;
  }

  if (psiElement instanceof XmlTag) {
    for (XmlText text : ((XmlTag)psiElement).getValue().getTextElements()) {
      if (InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)text)) return PsiReference.EMPTY_ARRAY;
    }
  } else {
    if (InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)psiElement)) return PsiReference.EMPTY_ARRAY;
  }

  final GenericDomValue domValue = (GenericDomValue)handler.getProxy();

  final Referencing referencing = handler.getAnnotation(Referencing.class);
  final Object converter;
  if (referencing == null) {
    converter = WrappingConverter.getDeepestConverter(domValue.getConverter(), domValue);
  }
  else {
    Class<? extends CustomReferenceConverter> clazz = referencing.value();
    converter = ((ConverterManagerImpl)domManager.getConverterManager()).getInstance(clazz);
  }
  PsiReference[] references = createReferences(domValue, (XmlElement)psiElement, converter, handler, domManager);
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    for (PsiReference reference : references) {
      if (!reference.isSoft()) {
        LOG.error("dom reference should be soft: " + reference + " (created by " + converter + ")");
      }
    }
  }
  if (references.length > 0) {
    if (converter instanceof EnumConverter && !((EnumConverter)converter).isExhaustive()) {
      // will be handled by core XML
      return PsiReference.EMPTY_ARRAY;
    }
    context.put(XmlEnumeratedValueReferenceProvider.SUPPRESS, Boolean.TRUE);
  }
  return references;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:55,代码来源:GenericValueReferenceProvider.java

示例15: findDeclarationsAt

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Override
public void findDeclarationsAt(@NotNull PsiElement psiElement, int offsetInElement, Consumer<PomTarget> consumer) {
  if (!(psiElement instanceof XmlToken)) return;

  final IElementType tokenType = ((XmlToken)psiElement).getTokenType();

  final DomManager domManager = DomManager.getDomManager(psiElement.getProject());
  final DomElement nameElement;
  if (tokenType == XmlTokenType.XML_DATA_CHARACTERS && psiElement.getParent() instanceof XmlText && psiElement.getParent().getParent() instanceof XmlTag) {
    final XmlTag tag = (XmlTag)psiElement.getParent().getParent();
    for (XmlText text : tag.getValue().getTextElements()) {
      if (InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)text)) {
        return;
      }
    }

    nameElement = domManager.getDomElement(tag);
  } else if (tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN && psiElement.getParent() instanceof XmlAttributeValue && psiElement.getParent().getParent() instanceof XmlAttribute) {
    final PsiElement attributeValue = psiElement.getParent();
    if (InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)attributeValue)) {
      return;
    }
    nameElement = domManager.getDomElement((XmlAttribute)attributeValue.getParent());
  } else {
    return;
  }

  if (!(nameElement instanceof GenericDomValue)) {
    return;
  }

  DomElement parent = nameElement.getParent();
  if (parent == null) {
    return;
  }

  final DomTarget target = createDomTarget(parent, nameElement);
  if (target != null) {
    consumer.consume(target);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:AbstractDomDeclarationSearcher.java


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