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

Java OuterLanguageElement类代码示例

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

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



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

示例1: isAvailable

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
    if (!element.isWritable()) return false;
    boolean isTwigFile = GravFileTemplateUtil.isTwigTemplateFile(element.getContainingFile()) || element.getContainingFile() instanceof HtmlFileImpl;
    boolean isXmlAttribute = false;
    if (!isTwigFile) return false;
    if (element.getParent() instanceof XmlAttributeValueImpl) {
        XmlAttributeValueImpl parent0 = ((XmlAttributeValueImpl) element.getParent());
        boolean hasTwigElement = PsiTreeUtil.findChildOfType(parent0, OuterLanguageElement.class) != null;
        if (!hasTwigElement && parent0.getParent() instanceof XmlAttributeImpl) {
            XmlAttributeImpl parent1 = (XmlAttributeImpl) parent0.getParent();
            if (parent1.getName().equalsIgnoreCase("href") || parent1.getName().equalsIgnoreCase("src"))
                isXmlAttribute = true;
        }
    }
    return isXmlAttribute;
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:18,代码来源:ConvertTwigResource.java


示例2: findElementAt

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
@Override
@Nullable
public PsiElement findElementAt(int offset, @NotNull Class<? extends Language> lang) {
  final PsiFile mainRoot = getPsi(getBaseLanguage());
  PsiElement ret = null;
  for (final Language language : getLanguages()) {
    if (!ReflectionUtil.isAssignable(lang, language.getClass())) continue;
    if (lang.equals(Language.class) && !getLanguages().contains(language)) continue;

    final PsiFile psiRoot = getPsi(language);
    final PsiElement psiElement = findElementAt(psiRoot, offset);
    if (psiElement == null || psiElement instanceof OuterLanguageElement) continue;
    if (ret == null || psiRoot != mainRoot) {
      ret = psiElement;
    }
  }
  return ret;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:MultiplePsiFilesPerDocumentFileViewProvider.java


示例3: findReferenceAt

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
@Nullable
public static PsiReference findReferenceAt(PsiElement thisElement, int offset, @Nullable Language lang) {
  if (thisElement == null) return null;
  PsiElement element = lang != null ? thisElement.getContainingFile().getViewProvider().findElementAt(offset, lang) :
                       thisElement.findElementAt(offset);
  if (element == null || element instanceof OuterLanguageElement) return null;
  offset = thisElement.getTextRange().getStartOffset() + offset - element.getTextRange().getStartOffset();

  List<PsiReference> referencesList = new ArrayList<PsiReference>();
  while (element != null) {
    addReferences(offset, element, referencesList);
    offset = element.getStartOffsetInParent() + offset;
    if (element instanceof PsiFile) break;
    element = element.getParent();
  }

  if (referencesList.isEmpty()) return null;
  if (referencesList.size() == 1) return referencesList.get(0);
  return new PsiMultiReference(referencesList.toArray(new PsiReference[referencesList.size()]),
                               referencesList.get(referencesList.size() - 1).getElement());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SharedPsiElementImplUtil.java


示例4: testSelectionForNonComments

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
private boolean testSelectionForNonComments() {
  if (!myCaret.hasSelection()) {
    return true;
  }
  TextRange range
    = new TextRange(myCaret.getSelectionStart(), myCaret.getSelectionEnd() - 1);
  for (PsiElement element = myFile.findElementAt(range.getStartOffset()); element != null && range.intersects(element.getTextRange());
       element = element.getNextSibling()) {
    if (element instanceof OuterLanguageElement) {
      if (!isInjectedWhiteSpace(range, (OuterLanguageElement)element)) {
        return false;
      }
    }
    else {
      if (!isWhiteSpaceOrComment(element, range)) {
        return false;
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CommentByBlockCommentHandler.java


示例5: findReferenceAt

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
/**
 * Overrides the findReferenceAt() logic in order to provide a resolve context with origin file for returned references.
 * The findReferenceAt() is usually invoked from UI operations, and it helps to be able to do deeper analysis in the
 * current file for such operations.
 *
 * @param offset the offset to find the reference at
 * @return the reference or null.
 */
@Override
public PsiReference findReferenceAt(int offset) {
  // copy/paste from SharedPsiElementImplUtil
  PsiElement element = findElementAt(offset);
  if (element == null || element instanceof OuterLanguageElement) return null;
  offset = getTextRange().getStartOffset() + offset - element.getTextRange().getStartOffset();

  List<PsiReference> referencesList = new ArrayList<PsiReference>();
  final PsiFile file = element.getContainingFile();
  final PyResolveContext resolveContext = file != null ?
                                   PyResolveContext.defaultContext().withTypeEvalContext(TypeEvalContext.codeAnalysis(file.getProject(), file)) :
                                   PyResolveContext.defaultContext();
  while (element != null) {
    addReferences(offset, element, referencesList, resolveContext);
    offset = element.getStartOffsetInParent() + offset;
    if (element instanceof PsiFile) break;
    element = element.getParent();
  }

  if (referencesList.isEmpty()) return null;
  if (referencesList.size() == 1) return referencesList.get(0);
  return new PsiMultiReference(referencesList.toArray(new PsiReference[referencesList.size()]),
                               referencesList.get(referencesList.size() - 1).getElement());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:PyBaseElementImpl.java


示例6: buildVisitor

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
  return new XmlElementVisitor() {
    @Override public void visitXmlToken(final XmlToken token) {
      if (token.getTokenType() == XmlTokenType.XML_NAME) {
        PsiElement element = token.getPrevSibling();
        while(element instanceof PsiWhiteSpace) element = element.getPrevSibling();

        if (element instanceof XmlToken && ((XmlToken)element).getTokenType() == XmlTokenType.XML_START_TAG_START) {
          PsiElement parent = element.getParent();

          if (parent instanceof XmlTag && !(token.getNextSibling() instanceof OuterLanguageElement)) {
            XmlTag tag = (XmlTag)parent;
            checkTag(tag, holder, isOnTheFly);
          }
        }
      }
    }

    @Override public void visitXmlAttribute(final XmlAttribute attribute) {
      checkAttribute(attribute, holder, isOnTheFly);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:HtmlLocalInspectionTool.java


示例7: compute

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
@Override
protected Boolean compute(PsiElement parent, Object p) {
  OuterLanguageElement element = PsiTreeUtil.getChildOfType(parent, OuterLanguageElement.class);

  if (element == null) {
    // JspOuterLanguageElement is located under XmlText
    for (PsiElement child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
      if (child instanceof XmlText) {
        element = PsiTreeUtil.getChildOfType(child, OuterLanguageElement.class);
        if (element != null) {
          break;
        }
      }
    }
  }
  if (element == null) return false;
  PsiFile containingFile = parent.getContainingFile();
  return containingFile.getViewProvider().getBaseLanguage() != containingFile.getLanguage();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:XmlHighlightVisitor.java


示例8: visitXmlProcessingInstruction

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
@Override
public void visitXmlProcessingInstruction(XmlProcessingInstruction processingInstruction) {
  super .visitXmlProcessingInstruction(processingInstruction);
  PsiElement parent = processingInstruction.getParent();

  if (parent instanceof XmlProlog && processingInstruction.getText().startsWith("<?xml")) {
    for(PsiElement e = PsiTreeUtil.prevLeaf(processingInstruction); e != null; e = PsiTreeUtil.prevLeaf(e)) {
      if (e instanceof PsiWhiteSpace && PsiTreeUtil.prevLeaf(e) != null ||
          e instanceof OuterLanguageElement) {
        continue;
      }
      PsiElement eParent = e.getParent();
      if (eParent instanceof PsiComment) e = eParent;
      if (eParent instanceof XmlProcessingInstruction) break;

      String description = XmlErrorMessages.message("xml.declaration.should.precede.all.document.content");
      addToResults(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(e).descriptionAndTooltip(description).create());
    }
  }
  checkReferences(processingInstruction);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:XmlHighlightVisitor.java


示例9: createLeafBlocks

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
private void createLeafBlocks(ASTNode node, List<Block> result) {
  if (node instanceof OuterLanguageElement) {
    processChild(result, node, null, null, null);
    return;
  }

  ASTNode child = node.getFirstChildNode();
  if (child == null && !(node instanceof PsiWhiteSpace) && node.getElementType() != TokenType.ERROR_ELEMENT && node.getTextLength() > 0) {
    result.add(new ReadOnlyBlock(node));
    return;
  }
  while (child != null) {
    createLeafBlocks(child, result);
    child = child.getTreeNext();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:XmlBlock.java


示例10: splitComment

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
protected List<Block> splitComment() {
  if (myNode.getElementType() != XmlElementType.XML_COMMENT) return EMPTY;
  final ArrayList<Block> result = new ArrayList<Block>(3);
  ASTNode child = myNode.getFirstChildNode();
  boolean hasOuterLangElements = false;
  while (child != null) {
    if (child instanceof OuterLanguageElement) {
      hasOuterLangElements = true;
    }
    result.add(new XmlBlock(child, null, null, myXmlFormattingPolicy, getChildIndent(), null, isPreserveSpace()));
    child = child.getTreeNext();
  }
  if (hasOuterLangElements) {
    return result;
  }
  else {
    return EMPTY;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:XmlBlock.java


示例11: suggestImport

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
private static boolean suggestImport(PsiElement context) {
  if (context.getParent() != null &&
      !(context.getParent() instanceof PsiErrorElement) &&
      GroovyCompletionUtil.isNewStatement(context, false) &&
      context.getParent().getParent() instanceof GroovyFile) {
    return true;
  }
  final PsiElement leaf = GroovyCompletionUtil.getLeafByOffset(context.getTextRange().getStartOffset() - 1, context);
  if (leaf != null) {
    PsiElement parent = leaf.getParent();
    if (parent instanceof GroovyFile) {
      return GroovyCompletionUtil.isNewStatement(context, false);
    }
  }
  return context.getTextRange().getStartOffset() == 0 && !(context instanceof OuterLanguageElement);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GroovyCompletionData.java


示例12: checkApplicability

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
@Override
public void checkApplicability(final PsiFile psiFile, final Editor editor) throws IncorrectOperationException {
  final JspFile jspFile = (JspFile)psiFile;

  final TextRange selectedRange = JavaI18nUtil.getSelectedRange(editor, jspFile);
  // must contain no or balanced tags only
  // must not contain scriptlets or custom tags
  PsiFile root = jspFile.getBaseLanguageRoot();
  root.accept(new PsiRecursiveElementVisitor(){
    @Override public void visitElement(PsiElement element) {
      TextRange elementRange = element.getTextRange();
      if (elementRange.intersectsStrict(selectedRange)) {
        // in JSPX base language root is a Jspx file itself
        if (jspFile.getLanguage() != StdLanguages.JSPX && element instanceof OuterLanguageElement ||

            element instanceof XmlTag
            && !selectedRange.contains(elementRange)
            && (!elementRange.contains(selectedRange) || !((XmlTag)element).getValue().getTextRange().contains(selectedRange))) {
          throw new IncorrectOperationException(CodeInsightBundle.message("i18nize.jsp.error"));
        }
      }
      super.visitElement(element);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:I18nizeJspHandlerProvider.java


示例13: findElementAt

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
@Override
@Nullable
public PsiElement findElementAt(int offset, @NotNull Class<? extends Language> lang) {
  final PsiFile mainRoot = getPsi(getBaseLanguage());
  PsiElement ret = null;
  for (final Language language : getLanguages()) {
    if (!ReflectionCache.isAssignable(lang, language.getClass())) continue;
    if (lang.equals(Language.class) && !getLanguages().contains(language)) continue;

    final PsiFile psiRoot = getPsi(language);
    final PsiElement psiElement = findElementAt(psiRoot, offset);
    if (psiElement == null || psiElement instanceof OuterLanguageElement) continue;
    if (ret == null || psiRoot != mainRoot) {
      ret = psiElement;
    }
  }
  return ret;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:MultiplePsiFilesPerDocumentFileViewProvider.java


示例14: testSelectionForNonComments

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
private boolean testSelectionForNonComments() {
  SelectionModel model = myEditor.getSelectionModel();
  if (!model.hasSelection()) {
    return true;
  }
  TextRange range
    = new TextRange(model.getSelectionStart(), model.getSelectionEnd() - 1);
  for (PsiElement element = myFile.findElementAt(range.getStartOffset()); element != null && range.intersects(element.getTextRange());
       element = element.getNextSibling()) {
    if (element instanceof OuterLanguageElement) {
      if (!isInjectedWhiteSpace(range, (OuterLanguageElement)element)) {
        return false;
      }
    }
    else {
      if (!isWhiteSpaceOrComment(element, range)) {
        return false;
      }
    }
  }
  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:CommentByBlockCommentHandler.java


示例15: createLeafBlocks

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
private void createLeafBlocks(ASTNode node, List<Block> result) {
  if (node instanceof OuterLanguageElement) {
    processChild(result, node, null, null, null);
    return;
  }

  ASTNode child = node.getFirstChildNode();
  if (child == null && !(node instanceof PsiWhiteSpace) && node.getElementType() != TokenType.ERROR_ELEMENT) {
    result.add(new ReadOnlyBlock(node));
    return;
  }
  while (child != null) {
    createLeafBlocks(child, result);
    child = child.getTreeNext();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:XmlBlock.java


示例16: splitComment

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
private List<Block> splitComment() {
  if (myNode.getElementType() != XmlElementType.XML_COMMENT) return EMPTY;
  final ArrayList<Block> result = new ArrayList<Block>(3);
  ASTNode child = myNode.getFirstChildNode();
  boolean hasOuterLangElements = false;
  while (child != null) {
    if (child instanceof OuterLanguageElement) {
      hasOuterLangElements = true;
    }
    result.add(new XmlBlock(child, null, null, myXmlFormattingPolicy, getChildIndent(), null, isPreserveSpace()));
    child = child.getTreeNext();
  }
  if (hasOuterLangElements) {
    return result;
  }
  else {
    return EMPTY;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:XmlBlock.java


示例17: suggestImport

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
private static boolean suggestImport(PsiElement context) {
  if (context.getParent() != null &&
      !(context.getParent() instanceof PsiErrorElement) &&
      isNewStatement(context, false) &&
      context.getParent().getParent() instanceof GroovyFile) {
    return true;
  }
  final PsiElement leaf = getLeafByOffset(context.getTextRange().getStartOffset() - 1, context);
  if (leaf != null) {
    PsiElement parent = leaf.getParent();
    if (parent instanceof GroovyFile) {
      return isNewStatement(context, false);
    }
  }
  return context.getTextRange().getStartOffset() == 0 && !(context instanceof OuterLanguageElement);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:GroovyCompletionData.java


示例18: shouldHighlightErrorElement

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
public boolean shouldHighlightErrorElement(@NotNull PsiErrorElement element) {
	PsiFile templateLanguageFile = PsiUtilCore.getTemplateLanguageFile(element.getContainingFile());
	if (templateLanguageFile == null) {
		return true;
	}
	Language language = templateLanguageFile.getLanguage();
	if (language != LatteLanguage.INSTANCE) {
		return true;
	}
	if (element.getParent() instanceof XmlElement || element.getParent() instanceof CssElement) {
		return false;
	}
	if (element.getParent().getLanguage() == LatteLanguage.INSTANCE) {
		return true;
	}
	PsiElement nextSibling;
	for (nextSibling = PsiTreeUtil.nextLeaf(element); nextSibling instanceof PsiWhiteSpace; nextSibling = nextSibling.getNextSibling());

	PsiElement psiElement = nextSibling == null ? null : PsiTreeUtil.findCommonParent(nextSibling, element);
	boolean nextIsOuterLanguageElement = nextSibling instanceof OuterLanguageElement || nextSibling instanceof LatteMacroClassic;
	return !nextIsOuterLanguageElement || psiElement == null || psiElement instanceof PsiFile;
}
 
开发者ID:JanTvrdik,项目名称:intellij-latte,代码行数:23,代码来源:ErrorFilter.java


示例19: findReferenceAt

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
@Nullable
@RequiredReadAction
public static PsiReference findReferenceAt(PsiElement thisElement, int offset, @Nullable Language lang) {
  if (thisElement == null) return null;
  PsiElement element = lang != null ? thisElement.getContainingFile().getViewProvider().findElementAt(offset, lang) :
                       thisElement.findElementAt(offset);
  if (element == null || element instanceof OuterLanguageElement) return null;
  offset = thisElement.getTextRange().getStartOffset() + offset - element.getTextRange().getStartOffset();

  List<PsiReference> referencesList = new ArrayList<PsiReference>();
  while (element != null) {
    addReferences(offset, element, referencesList);
    if (element instanceof PsiFile) break;
    if (element instanceof HintedReferenceHost &&
        !((HintedReferenceHost)element).shouldAskParentForReferences(new PsiReferenceService.Hints(null, offset))) {
      break;
    }
    offset = element.getStartOffsetInParent() + offset;
    element = element.getParent();
  }

  if (referencesList.isEmpty()) return null;
  if (referencesList.size() == 1) return referencesList.get(0);
  return new PsiMultiReference(referencesList.toArray(new PsiReference[referencesList.size()]),
                               referencesList.get(referencesList.size() - 1).getElement());
}
 
开发者ID:consulo,项目名称:consulo,代码行数:27,代码来源:SharedPsiElementImplUtil.java


示例20: testSelectionForNonComments

import com.intellij.psi.templateLanguages.OuterLanguageElement; //导入依赖的package包/类
private boolean testSelectionForNonComments() {
  if (!myCaret.hasSelection()) {
    return true;
  }
  TextRange range = new TextRange(myCaret.getSelectionStart(), myCaret.getSelectionEnd() - 1);
  for (PsiElement element = myFile.findElementAt(range.getStartOffset()); element != null && range.intersects(element.getTextRange()); element = element.getNextSibling()) {
    if (element instanceof OuterLanguageElement) {
      if (!isInjectedWhiteSpace(range, (OuterLanguageElement)element)) {
        return false;
      }
    }
    else {
      if (!isWhiteSpaceOrComment(element, range)) {
        return false;
      }
    }
  }
  return true;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:CommentByBlockCommentHandler.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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