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


Java PhpTokenTypes.chLDOUBLE_QUOTE方法代码示例

本文整理汇总了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;
}
 
开发者ID:axelcostaspena,项目名称:php-1up,代码行数:16,代码来源:PhpStringUtil.java

示例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;
}
 
开发者ID:axelcostaspena,项目名称:php-1up,代码行数:43,代码来源:PhpStringUtil.java


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