本文整理匯總了Java中com.intellij.psi.TokenType.WHITE_SPACE屬性的典型用法代碼示例。如果您正苦於以下問題:Java TokenType.WHITE_SPACE屬性的具體用法?Java TokenType.WHITE_SPACE怎麽用?Java TokenType.WHITE_SPACE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.intellij.psi.TokenType
的用法示例。
在下文中一共展示了TokenType.WHITE_SPACE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getIdentifiers
@Override
public List<PsiElement> getIdentifiers() {
final List<PsiElement> result = new ArrayList<>();
PsiElement psiChild = getFirstChild();
if (psiChild == null) {
result.add(this);
return result;
}
while (psiChild != null) {
if (psiChild.getNode().getElementType() != TokenType.WHITE_SPACE) {
result.add(psiChild);
}
psiChild = psiChild.getNextSibling();
}
return result;
}
示例2: buildChildren
@Override
protected List<Block> buildChildren() {
List<Block> blocks = new ArrayList<Block>();
Alignment innerBodyAlignment = Alignment.createAlignment();
ASTNode child = getNode().getFirstChildNode();
while (child != null) {
if (child.getElementType() != TokenType.WHITE_SPACE) {
if (child.getElementType() == GCMTypes.PROP) {
blocks.add(new GCMBlock(child, innerBodyAlignment, getWrap()));
} else {
blocks.add(new GCMBlock(child, getAlignment(), getWrap()));
}
}
child = child.getTreeNext();
}
return blocks;
}
示例3: getMergeFunction
@Override
public MergeFunction getMergeFunction() {
return ((final IElementType type, final Lexer originalLexer) -> {
if (type == SoyTypes.OTHER || type == TokenType.WHITE_SPACE) {
IElementType returnType = type;
while (originalLexer.getTokenType() == SoyTypes.OTHER
|| originalLexer.getTokenType() == TokenType.WHITE_SPACE) {
if (originalLexer.getTokenType() == SoyTypes.OTHER) {
returnType = SoyTypes.OTHER;
}
originalLexer.advance();
}
return returnType;
}
return type;
});
}
示例4: buildChildren
@Override
protected List<Block> buildChildren() {
List<Block> blocks = new ArrayList<>();
ASTNode child = myNode.getFirstChildNode();
while (child != null) {
if (child.getElementType() != TokenType.WHITE_SPACE) {
Block block = new FlexibleSearchBlock(
child,
Wrap.createWrap(WrapType.NONE, false),
null,
spacingBuilder
);
blocks.add(block);
}
child = child.getTreeNext();
}
return blocks;
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:20,代碼來源:FlexibleSearchBlock.java
示例5: getParentFieldElement
public static PsiElement getParentFieldElement(PsiElement element) {
if (getElementType(element) == TokenType.WHITE_SPACE) {
if (getElementType(element.getParent()) == CsvTypes.FIELD) {
element = element.getParent();
} else if (getElementType(element.getPrevSibling()) == CsvTypes.FIELD) {
element = element.getPrevSibling();
} else {
element = null;
}
} else {
while (element != null && CsvIntentionHelper.getElementType(element) != CsvTypes.FIELD) {
element = element.getParent();
}
}
return element;
}
示例6: findFurthestSiblingOfSameType
private static PsiElement findFurthestSiblingOfSameType(@NotNull PsiElement anchor, boolean after) {
ASTNode node = anchor.getNode();
final IElementType expectedType = node.getElementType();
ASTNode lastSeen = node;
while (node != null) {
final IElementType elementType = node.getElementType();
if (elementType == expectedType) {
lastSeen = node;
} else if (elementType == TokenType.WHITE_SPACE) {
if (expectedType == token(LINE_COMMENT)
&& node.getText().indexOf('\n', 1) != -1) {
break;
}
} else if (!COMMENT_TOKEN_SET.contains(elementType) || COMMENT_TOKEN_SET.contains(expectedType)) {
break;
}
node = after ? node.getTreeNext() : node.getTreePrev();
}
return lastSeen.getPsi();
}
示例7: buildChildren
@Override
protected List<Block> buildChildren() {
List<Block> blocks = new ArrayList<>();
ASTNode child = myNode.getFirstChildNode();
while (child != null) {
if (child.getElementType() != TokenType.WHITE_SPACE) {
Block block = new DotBlock(child, Wrap.createWrap(WrapType.NONE, false), null,
spacingBuilder);
if (block.getTextRange().getLength() > 0) {
blocks.add(block);
}
}
child = child.getTreeNext();
}
return blocks;
}
示例8: visitLeaf
@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;
}
示例9: findFurthestSiblingOfSameType
/**
* Find the furthest sibling element with the same type as given anchor.
* <p/>
* Ignore white spaces for any type of element except {@link com.intellij.json.JsonElementTypes#LINE_COMMENT}
* where non indentation white space (that has new line in the middle) will stop the search.
*
* @param anchor element to start from
* @param after whether to scan through sibling elements forward or backward
* @return described element or anchor if search stops immediately
*/
@NotNull
public static PsiElement findFurthestSiblingOfSameType(@NotNull PsiElement anchor, boolean after) {
ASTNode node = anchor.getNode();
// Compare by node type to distinguish between different types of comments
final IElementType expectedType = node.getElementType();
ASTNode lastSeen = node;
while (node != null) {
final IElementType elementType = node.getElementType();
if (elementType == expectedType) {
lastSeen = node;
}
else if (elementType == TokenType.WHITE_SPACE) {
if (expectedType == JsonElementTypes.LINE_COMMENT && node.getText().indexOf('\n', 1) != -1) {
break;
}
}
else if (!JSON_COMMENTARIES.contains(elementType) || JSON_COMMENTARIES.contains(expectedType)) {
break;
}
node = after ? node.getTreeNext() : node.getTreePrev();
}
return lastSeen.getPsi();
}
示例10: invoke
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
if (element.getNode().getElementType() == TokenType.WHITE_SPACE) element = PsiTreeUtil.prevVisibleLeaf(element);
SchemaValueTypeRef valueTypeRef = PsiTreeUtil.getParentOfType(element, SchemaValueTypeRef.class);
if (valueTypeRef != null) {
int endOffset = valueTypeRef.getNode().getTextRange().getEndOffset();
editor.getCaretModel().moveToOffset(endOffset);
EditorModificationUtil.insertStringAtCaret(editor, " default ");
ApplicationManager.getApplication().invokeLater(() -> {
AnActionEvent event = AnActionEvent.createFromDataContext("AddDefaultAction",
new Presentation(), ((EditorEx) editor).getDataContext());
new CodeCompletionAction().actionPerformed(event);
});
}
}
示例11: getWsCandidate
@Nullable
private static ASTNode getWsCandidate(@Nullable ASTNode node) {
if (node == null) return null;
ASTNode treePrev = node.getTreePrev();
if (treePrev != null) {
if (treePrev.getElementType() == TokenType.WHITE_SPACE) {
return treePrev;
}
else if (treePrev.getTextLength() == 0) {
return getWsCandidate(treePrev);
}
else {
return node;
}
}
final ASTNode treeParent = node.getTreeParent();
if (treeParent == null || treeParent.getTreeParent() == null) {
return node;
}
else {
return getWsCandidate(treeParent);
}
}
示例12: replaceWithPsiInLeaf
@Override
protected String replaceWithPsiInLeaf(TextRange textRange, String whiteSpace, ASTNode leafElement) {
if (!myCanModifyAllWhiteSpaces) {
if (AppleScriptPsiImplUtil.isWhiteSpaceOrNls(leafElement)) return null;
}
IElementType elementTypeToUse = TokenType.WHITE_SPACE;
ASTNode prevNode = TreeUtil.prevLeaf(leafElement);
if (prevNode != null && AppleScriptPsiImplUtil.isWhiteSpaceOrNls(prevNode)) {
elementTypeToUse = prevNode.getElementType();
}
FormatterUtil.replaceWhiteSpace(whiteSpace, leafElement, elementTypeToUse, textRange);
return whiteSpace;
}
示例13: buildChildren
@Override
protected List<Block> buildChildren() {
List<Block> blocks = new ArrayList<>();
ASTNode child = myNode.getFirstChildNode();
while (child != null) {
final IElementType elementType = child.getElementType();
final Indent indent = elementType == CptTypes.MAPPINGS
? Indent.getNormalIndent()
: Indent.getNoneIndent();
final Indent childIndent = _Set(CptTypes.TEMPLATE,CptTypes.MAPPINGS, CptTypes.MAPPING, CptTypes.REPLACEMENT,
CptTypes.TEMPLATE_ESCAPE, CptTypes.TEMPLATE_CODE, CptTypes.TEMPLATE_VARIABLE).contains(elementType)
? Indent.getNormalIndent()
: Indent.getNoneIndent();
if (elementType != TokenType.WHITE_SPACE) {
Alignment alignment = null; //Alignment.createAlignment();
/*
if (elementType == CptTypes.MAP) {
alignment = mapAlignment;
}
*/
Block block = new CptBlock(child, Wrap.createWrap(WrapType.NONE, false), indent, childIndent, alignment, spacingBuilder);
blocks.add(block);
}
child = child.getTreeNext();
}
return blocks;
}
示例14: buildChildren
@Override
protected List<Block> buildChildren() {
List<ASTNode> todoNodes = new ArrayList<>();
List<Block> blocks = new ArrayList<>();
todoNodes.add(getNode().getFirstChildNode());
CsvBlockField currentField = null;
while (todoNodes.size() > 0) {
ASTNode node = todoNodes.remove(todoNodes.size() - 1);
if (node == null) {
continue;
}
IElementType elementType = node.getElementType();
todoNodes.add(node.getTreeNext());
if (elementType == CsvTypes.RECORD) {
todoNodes.add(node.getFirstChildNode());
} else if (elementType == CsvTypes.FIELD) {
currentField = new CsvBlockField(node, formattingInfo);
if (currentField.getTextLength() > 0) {
blocks.add(currentField);
}
} else if (elementType == CsvTypes.COMMA || elementType == CsvTypes.CRLF) {
blocks.add(new CsvBlockElement(node, formattingInfo, currentField));
} else if (elementType != TokenType.WHITE_SPACE && node.getTextLength() > 0) {
blocks.add(new CsvDummyBlock(node, formattingInfo));
}
}
return blocks;
}
示例15: buildChildren
@Override
protected List<Block> buildChildren() {
ASTNode node = this.getNode().getFirstChildNode();
List<Block> blocks = new ArrayList<>();
while (node != null) {
if (node.getElementType() != TokenType.WHITE_SPACE) {
CsvBlockElement block = new CsvBlockElement(node, formattingInfo, this);
blocks.add(block);
}
node = node.getTreeNext();
}
return blocks;
}