當前位置: 首頁>>代碼示例>>Java>>正文


Java ForeignLeafPsiElement類代碼示例

本文整理匯總了Java中com.intellij.psi.impl.source.tree.ForeignLeafPsiElement的典型用法代碼示例。如果您正苦於以下問題:Java ForeignLeafPsiElement類的具體用法?Java ForeignLeafPsiElement怎麽用?Java ForeignLeafPsiElement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ForeignLeafPsiElement類屬於com.intellij.psi.impl.source.tree包,在下文中一共展示了ForeignLeafPsiElement類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMatchingLength

import com.intellij.psi.impl.source.tree.ForeignLeafPsiElement; //導入依賴的package包/類
private static int getMatchingLength(@NotNull FileElement treeElement, @NotNull CharSequence text, boolean fromStart) {
  int patternIndex = fromStart ? 0 : text.length() - 1;
  int finalPatternIndex = fromStart ? text.length() - 1 : 0;
  int direction = fromStart ? 1 : -1;
  ASTNode leaf = fromStart ? TreeUtil.findFirstLeaf(treeElement, false) : TreeUtil.findLastLeaf(treeElement, false);
  int result = 0;
  while (leaf != null && (fromStart ? patternIndex <= finalPatternIndex : patternIndex >= finalPatternIndex)) {
    if (!(leaf instanceof ForeignLeafPsiElement)) {
      CharSequence chars = leaf.getChars();
      if (chars.length() > 0) {
        int matchingLength = getLeafMatchingLength(chars, text, patternIndex, finalPatternIndex, direction);
        result += matchingLength;
        if (matchingLength != chars.length()) {
          break;
        }
        patternIndex += (fromStart ? matchingLength : -matchingLength);
      }
    }
    leaf = fromStart ? TreeUtil.nextLeaf(leaf, false) : TreeUtil.prevLeaf(leaf, false);
  }
  return result;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:DocumentCommitProcessor.java

示例2: visitLeaf

import com.intellij.psi.impl.source.tree.ForeignLeafPsiElement; //導入依賴的package包/類
@Override
public void visitLeaf(LeafElement leaf) {
  String leafText = leaf instanceof ForeignLeafPsiElement ? "" : leaf.getText();
  catLeafs.append(leafText);
  final TextRange leafRange = leaf.getTextRange();

  StringBuilder leafEncodedText = constructTextFromHostPSI(leafRange.getStartOffset(), leafRange.getEndOffset());

  if (leaf.getElementType() == TokenType.WHITE_SPACE && prevElementTail != null) {
    // optimization: put all garbage into whitespace
    leafEncodedText.insert(0, prevElementTail);
    newTexts.remove(prevElement);
    storeUnescapedTextFor(prevElement, null);
  }
  if (!Comparing.equal(leafText, leafEncodedText)) {
    newTexts.put(leaf, leafEncodedText.toString());
    storeUnescapedTextFor(leaf, leafText);
  }
  prevElementTail = StringUtil.startsWith(leafEncodedText, leafText) && leafEncodedText.length() != leafText.length() ?
                    leafEncodedText.substring(leafText.length()) : null;
  prevElement = leaf;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:LeafPatcher.java

示例3: getMatchingLength

import com.intellij.psi.impl.source.tree.ForeignLeafPsiElement; //導入依賴的package包/類
private static int getMatchingLength(@Nonnull FileElement treeElement, @Nonnull CharSequence text, boolean fromStart) {
  int patternIndex = fromStart ? 0 : text.length() - 1;
  int finalPatternIndex = fromStart ? text.length() - 1 : 0;
  int direction = fromStart ? 1 : -1;
  ASTNode leaf = fromStart ? TreeUtil.findFirstLeaf(treeElement, false) : TreeUtil.findLastLeaf(treeElement, false);
  int result = 0;
  while (leaf != null && (fromStart ? patternIndex <= finalPatternIndex : patternIndex >= finalPatternIndex)) {
    if (!(leaf instanceof ForeignLeafPsiElement)) {
      CharSequence chars = leaf.getChars();
      if (chars.length() > 0) {
        int matchingLength = getLeafMatchingLength(chars, text, patternIndex, finalPatternIndex, direction);
        result += matchingLength;
        if (matchingLength != chars.length()) {
          break;
        }
        patternIndex += fromStart ? matchingLength : -matchingLength;
      }
    }
    leaf = fromStart ? TreeUtil.nextLeaf(leaf, false) : TreeUtil.prevLeaf(leaf, false);
  }
  return result;
}
 
開發者ID:consulo,項目名稱:consulo,代碼行數:23,代碼來源:ChangedPsiRangeUtil.java

示例4: visitElement

import com.intellij.psi.impl.source.tree.ForeignLeafPsiElement; //導入依賴的package包/類
@Override
public void visitElement(PsiElement element) {
  if (!(element instanceof ForeignLeafPsiElement) && element.isPhysical()) {
    super.visitElement(element);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:7,代碼來源:PsiVisitors.java

示例5: createLeafNode

import com.intellij.psi.impl.source.tree.ForeignLeafPsiElement; //導入依賴的package包/類
@Override
@NotNull
public ASTNode createLeafNode(CharSequence leafText) {
  return new ForeignLeafPsiElement(this, getValue());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:6,代碼來源:ForeignLeafType.java

示例6: createLeafNode

import com.intellij.psi.impl.source.tree.ForeignLeafPsiElement; //導入依賴的package包/類
@Override
@Nonnull
public ASTNode createLeafNode(CharSequence leafText) {
  return new ForeignLeafPsiElement(this, getValue());
}
 
開發者ID:consulo,項目名稱:consulo,代碼行數:6,代碼來源:ForeignLeafType.java


注:本文中的com.intellij.psi.impl.source.tree.ForeignLeafPsiElement類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。