本文整理汇总了Java中com.jetbrains.php.lang.lexer.PhpTokenTypes.chLDOUBLE_QUOTE方法的典型用法代码示例。如果您正苦于以下问题:Java PhpTokenTypes.chLDOUBLE_QUOTE方法的具体用法?Java PhpTokenTypes.chLDOUBLE_QUOTE怎么用?Java PhpTokenTypes.chLDOUBLE_QUOTE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jetbrains.php.lang.lexer.PhpTokenTypes
的用法示例。
在下文中一共展示了PhpTokenTypes.chLDOUBLE_QUOTE方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPhpDoubleQuotedStringExpression
import com.jetbrains.php.lang.lexer.PhpTokenTypes; //导入方法依赖的package包/类
static PsiElement getPhpDoubleQuotedStringExpression(PsiElement psiElement) {
if (psiElement instanceof PhpFile) return null;
if (psiElement instanceof StringLiteralExpression) {
PsiElement firstChild = psiElement.getFirstChild();
if (firstChild != null) {
ASTNode childAstNode = firstChild.getNode();
IElementType childElementType = childAstNode.getElementType();
if (childElementType == PhpTokenTypes.STRING_LITERAL || childElementType == PhpTokenTypes.chLDOUBLE_QUOTE) {
return psiElement;
}
}
}
PsiElement parentPsi = psiElement.getParent();
return parentPsi != null ? getPhpDoubleQuotedStringExpression(parentPsi) : null;
}
示例2: mapPhpDoubleQuotedComplexStringContent
import com.jetbrains.php.lang.lexer.PhpTokenTypes; //导入方法依赖的package包/类
/**
* Gets the child nodes of a PHP double quoted string psiElement and maps them to a List of String values. Allows to
* specify a callback function for processing string literal fragments, and other for embedded variables and
* expressions. Delimiter double quotes are omitted since their presence is constant.
*
* @param psiElement The PHP double quoted string literal whose nodes are wanted to map
* @param stringFragmentMapper A Function implementation which gets a String from the ASTNode of any string
* literal fragment on the PHP string. Any node which lead to a null return value
* will be omitted from the result.
* @param embeddedExpressionMapper A Function implementation which gets a String from the ASTNode of any variable or
* expression embedded on the PHP string. Any node which lead to a null return value
* will be omitted from the result.
* @return A List of String objects containing the results of sequentially applying the PHP string pieces to the
* provided Function implementations as determined by the node type.
*/
public static List<String> mapPhpDoubleQuotedComplexStringContent(PsiElement psiElement, Function<ASTNode, String> stringFragmentMapper, Function<ASTNode, String> embeddedExpressionMapper) {
ASTNode astNode = psiElement.getNode();
if (astNode == null) return null;
ASTNode[] children = astNode.getChildren(null);
// complex strings always have more than one child node
if (children.length <= 1) return null;
List<String> map = new ArrayList<String>();
for (ASTNode childNode : children) {
IElementType pieceType = childNode.getElementType();
// skip delimiter quotes
if (pieceType == PhpTokenTypes.chLDOUBLE_QUOTE || pieceType == PhpTokenTypes.chRDOUBLE_QUOTE) continue;
if (pieceType == PhpTokenTypes.STRING_LITERAL) {
// the ASTNode is a piece of textual content of the string
String stringFragmentResult = stringFragmentMapper.apply(childNode);
if (stringFragmentResult != null) {
map.add(stringFragmentResult);
}
} else {
// the ASTNode is a variable or expression embedded in the string
String embeddedExpressionResult = embeddedExpressionMapper.apply(childNode);
if (embeddedExpressionResult != null) {
map.add(embeddedExpressionResult);
}
}
}
return map;
}