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


Java PhpPatterns类代码示例

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


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

示例1: methodParamsList

import com.jetbrains.php.lang.patterns.PhpPatterns; //导入依赖的package包/类
public static PsiElementPattern.Capture<PsiElement> methodParamsList(String methodName,
                                                                     StringPattern className) {
    return PlatformPatterns.psiElement().withElementType(PhpElementTypes.PARAMETER_LIST)
            .withParent(
                    PlatformPatterns.psiElement()
                            .withElementType(PhpElementTypes.METHOD_REFERENCE)
                            .referencing(
                                    PhpPatterns.psiElement().withElementType(
                                            PhpElementTypes.CLASS_METHOD
                                    ).withName(methodName)
                                            .withParent(
                                                    PhpPatterns.psiElement().withName(
                                                            className
                                                    ))
                            )

            );
}
 
开发者ID:cmazx,项目名称:yiistorm,代码行数:19,代码来源:YiiContibutorHelper.java

示例2: appFieldPattern

import com.jetbrains.php.lang.patterns.PhpPatterns; //导入依赖的package包/类
public static PsiElementPattern.Capture appFieldPattern() {
    return PlatformPatterns.psiElement()
            .withParent(PlatformPatterns.psiElement().withElementType(PhpElementTypes.FIELD_REFERENCE)
                    .withChild(
                            PlatformPatterns.psiElement().withElementType(PhpElementTypes.METHOD_REFERENCE)
                                    .referencing(
                                            PhpPatterns.psiElement().withElementType(PhpElementTypes.CLASS_METHOD)
                                                    .withName("app").withParent(
                                                    PhpPatterns.psiElement()
                                                            .withElementType(PhpElementTypes.CLASS)
                                                            .withName(StandardPatterns.string().oneOf("Yii", "YiiBase"))
                                            )
                                    )
                    )
            ).withLanguage(PhpLanguage.INSTANCE);

}
 
开发者ID:cmazx,项目名称:yiistorm,代码行数:18,代码来源:YiiAppCompletionContributor.java

示例3: isStringArrayValue

import com.jetbrains.php.lang.patterns.PhpPatterns; //导入依赖的package包/类
@NotNull
public static PsiElementPattern.Capture<PsiElement> isStringArrayValue() {

    return PhpPatterns.psiElement()
            .andOr(
                    PhpPatterns.psiElement().withParent(
                        PlatformPatterns.psiElement(StringLiteralExpression.class)
                            .withParent(PlatformPatterns.psiElement(PhpElementTypes.ARRAY_VALUE))
                    ),
                    PlatformPatterns.psiElement(StringLiteralExpression.class)
                                    .withParent(PlatformPatterns.psiElement(PhpElementTypes.ARRAY_VALUE))
            );
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:14,代码来源:PhpElementsUtil.java

示例4: findArrayCreationExpression

import com.jetbrains.php.lang.patterns.PhpPatterns; //导入依赖的package包/类
@Nullable
private ArrayCreationExpression findArrayCreationExpression(@NotNull StringLiteralExpression psiElement, @NotNull String key) {

    // value inside array
    // $menu->addChild(array(
    //   'route' => 'foo',
    // ));
    if(PhpPatterns.psiElement(PhpElementTypes.ARRAY_VALUE).accepts(psiElement.getContext())) {
        PsiElement arrayValue = psiElement.getContext();
        if(arrayValue != null) {
            PsiElement arrayHashElement = arrayValue.getContext();
            if(arrayHashElement instanceof ArrayHashElement) {
                PhpPsiElement arrayKey = ((ArrayHashElement) arrayHashElement).getKey();
                if(arrayKey instanceof StringLiteralExpression && ((StringLiteralExpression) arrayKey).getContents().equals(key)) {
                    PsiElement arrayCreationExpression = arrayHashElement.getContext();
                    if(arrayCreationExpression instanceof ArrayCreationExpression) {
                        if(!(arrayCreationExpression.getParent() instanceof ParameterList)) {
                            return null;
                        }

                        return (ArrayCreationExpression) arrayCreationExpression;
                    }
                }
            }
        }
    }

    return null;
}
 
开发者ID:Haehnchen,项目名称:idea-php-toolbox,代码行数:30,代码来源:ArrayKeyValueSignatureRegistrarMatcher.java

示例5: isContributedElement

import com.jetbrains.php.lang.patterns.PhpPatterns; //导入依赖的package包/类
public boolean isContributedElement(PsiElement psiElement, MethodParameterSetting config) {

            // value inside array
            // $menu->addChild(array(
            //   'route' => 'foo',
            // ));
            if(PhpPatterns.psiElement(PhpElementTypes.ARRAY_VALUE).accepts(psiElement.getContext())) {
                PsiElement arrayValue = psiElement.getContext();
                if(arrayValue != null) {
                    PsiElement arrayHashElement = arrayValue.getContext();
                    if(arrayHashElement instanceof ArrayHashElement) {
                        PhpPsiElement arrayKey = ((ArrayHashElement) arrayHashElement).getKey();
                        if(arrayKey instanceof StringLiteralExpression && ((StringLiteralExpression) arrayKey).getContents().equals(config.getContributorData())) {
                            PsiElement arrayCreationExpression = arrayHashElement.getContext();
                            if(arrayCreationExpression instanceof ArrayCreationExpression) {
                                if(arrayCreationExpression.getParent() instanceof ParameterList) {
                                    return true;
                                }
                            }
                        }

                    }
                }

            }

            return false;
        }
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:29,代码来源:DefaultReferenceContributor.java

示例6: pattern

import com.jetbrains.php.lang.patterns.PhpPatterns; //导入依赖的package包/类
/**
 * $menu->addChild([
 *   'route' => '<caret>',
 * ]);
 */
@NotNull
public static PsiElementPattern.Capture<PsiElement> pattern() {
    return PhpPatterns.psiElement().withParent(
        PlatformPatterns.psiElement(StringLiteralExpression.class).withParent(
            PlatformPatterns.psiElement(PhpElementTypes.ARRAY_VALUE).inside(ParameterList.class)
        )
    );
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:14,代码来源:ArrayValueWithKeyAndNewExpressionMatcher.java

示例7: getArrayKeyValueMap

import com.jetbrains.php.lang.patterns.PhpPatterns; //导入依赖的package包/类
/**
 * array('foo' => 'bar', 'foo1' => 'bar', 1 => 'foo')
 */
@NotNull
static public HashMap<String, String> getArrayKeyValueMap(@NotNull ArrayCreationExpression arrayCreationExpression) {
    HashMap<String, String> keys = new HashMap<>();

    for(ArrayHashElement arrayHashElement: arrayCreationExpression.getHashElements()) {
        PhpPsiElement child = arrayHashElement.getKey();
        if(child != null && ((child instanceof StringLiteralExpression) || PhpPatterns.psiElement(PhpElementTypes.NUMBER).accepts(child))) {

            String key;
            if(child instanceof StringLiteralExpression) {
                key = ((StringLiteralExpression) child).getContents();
            } else {
                key = child.getText();
            }

            if(key == null || StringUtils.isBlank(key)) {
                continue;
            }

            String value = null;

            if(arrayHashElement.getValue() instanceof StringLiteralExpression) {
                value = ((StringLiteralExpression) arrayHashElement.getValue()).getContents();
            }

            if(value == null || StringUtils.isBlank(value)) {
                continue;
            }

            keys.put(key, value);
        }
    }

    return keys;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:39,代码来源:PhpElementsUtil.java

示例8: methodLiteralExpression

import com.jetbrains.php.lang.patterns.PhpPatterns; //导入依赖的package包/类
public static PhpElementPattern.Capture<StringLiteralExpression> methodLiteralExpression(String methodName,
                                                                                         StringPattern className) {
    return PhpPatterns.phpLiteralExpression()
            .withParent(
                    methodParamsList(methodName, className)
            );
}
 
开发者ID:cmazx,项目名称:yiistorm,代码行数:8,代码来源:YiiContibutorHelper.java

示例9: paramListInMethodWithName

import com.jetbrains.php.lang.patterns.PhpPatterns; //导入依赖的package包/类
public static PsiElementPattern.Capture<PsiElement> paramListInMethodWithName(String methodName) {
    return PlatformPatterns.psiElement().withElementType(PhpElementTypes.PARAMETER_LIST)
            .withParent(
                    PlatformPatterns.psiElement().withElementType(PhpElementTypes.METHOD_REFERENCE)
                            .referencing(PhpPatterns.psiElement().withElementType(PhpElementTypes.CLASS_METHOD)
                                    .withName(methodName)
                            )
            );
}
 
开发者ID:cmazx,项目名称:yiistorm,代码行数:10,代码来源:YiiContibutorHelper.java

示例10: arrayInMethodWithName

import com.jetbrains.php.lang.patterns.PhpPatterns; //导入依赖的package包/类
public static PsiElementPattern.Capture<PsiElement> arrayInMethodWithName(String methodName) {
    return PlatformPatterns.psiElement().withElementType(PhpElementTypes.ARRAY_CREATION_EXPRESSION)
            .withParent(
                    PlatformPatterns.psiElement().withElementType(PhpElementTypes.METHOD_REFERENCE)
                            .referencing(PhpPatterns.psiElement().withElementType(PhpElementTypes.CLASS_METHOD)
                                    .withName(methodName)
                            )
            );
}
 
开发者ID:cmazx,项目名称:yiistorm,代码行数:10,代码来源:YiiContibutorHelper.java

示例11: mapOptionsArrayParam

import com.jetbrains.php.lang.patterns.PhpPatterns; //导入依赖的package包/类
private void mapOptionsArrayParam(TYPO3ServiceDefinition serviceDefinition, Iterable<ArrayHashElement> optionsArray) {
    for (ArrayHashElement element : optionsArray) {
        if (null == element.getKey() || !(element.getKey() instanceof StringLiteralExpression)) {
            continue;
        }

        String key = ((StringLiteralExpression) element.getKey()).getContents();
        // Assign string properties of the service definition options
        if (null != element.getValue() && element.getValue() instanceof StringLiteralExpression) {
            String value = ((StringLiteralExpression) element.getValue()).getContents();
            switch (key) {
                case "os":
                    serviceDefinition.setOs(value);
                    break;
                case "title":
                    serviceDefinition.setTitle(value);
                    break;
                case "description":
                    serviceDefinition.setDescription(value);
                    break;
                case "subtype":
                    serviceDefinition.setSubType(value);
                    break;
                case "exec":
                    serviceDefinition.setExec(value);
                    break;
            }
        }

        // Assign numbers
        if (null != element.getValue() && PhpPatterns.psiElement(PhpElementTypes.NUMBER).accepts(element.getValue())) {
            switch (key) {
                case "priority":
                    serviceDefinition.setPriority(new Integer(element.getValue().getText()));
                    break;
                case "quality":
                    serviceDefinition.setQuality(new Integer(element.getValue().getText()));
                    break;
            }
        }
    }
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:43,代码来源:CoreServiceDefinitionParserVisitor.java

示例12: shouldSkipAutopopup

import com.jetbrains.php.lang.patterns.PhpPatterns; //导入依赖的package包/类
@NotNull
@Override
public ThreeState shouldSkipAutopopup(@NotNull PsiElement contextElement, @NotNull PsiFile psiFile, int offset) {

    if(!(psiFile instanceof PhpFile)) {
        return ThreeState.UNSURE;
    }

    PsiElement context = contextElement.getContext();
    if(context instanceof StringLiteralExpression) {

        // foo="<|>"
        if(PhpPatterns.psiElement(PhpDocElementTypes.phpDocString).accepts(context)) {
            return ThreeState.NO;
        }

    } else if(context instanceof PhpDocComment) {

        // * <|>
        if(PhpPatterns.psiElement().afterLeafSkipping(
            PhpPatterns.psiElement(PsiWhiteSpace.class),
            PhpPatterns.psiElement(PhpDocTokenTypes.DOC_LEADING_ASTERISK)
        ).accepts(contextElement)) {
            return ThreeState.NO;
        }

    } else if(context instanceof PhpPsiElementImpl) {

        // @Foo(<|>)
        if(PhpPatterns.psiElement(PhpDocElementTypes.phpDocAttributeList).accepts(context)) {
            return ThreeState.NO;
        }

        // @<|>
        if(PhpPatterns.psiElement(PhpDocElementTypes.phpDocTag).accepts(context)) {
            return ThreeState.NO;
        }

    }

    return ThreeState.UNSURE;
}
 
开发者ID:Haehnchen,项目名称:idea-php-annotation-plugin,代码行数:43,代码来源:PhpAnnotationCompletionConfidence.java

示例13: registerReferenceProviders

import com.jetbrains.php.lang.patterns.PhpPatterns; //导入依赖的package包/类
@Override
public void registerReferenceProviders(PsiReferenceRegistrar psiReferenceRegistrar) {

    psiReferenceRegistrar.registerReferenceProvider(PhpPatterns.psiElement(PhpElementTypes.PARAMETER),
            new PhpStringLiteralExpressionReference(ParameterReference.class)
                    .addCall("Yii", "getParameter")
    );


}
 
开发者ID:cmazx,项目名称:yiistorm,代码行数:11,代码来源:YiiApplicationReferenceContributor.java


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