|
2 | 2 | * Copyright © Magento, Inc. All rights reserved. |
3 | 3 | * See COPYING.txt for license details. |
4 | 4 | */ |
| 5 | + |
5 | 6 | package com.magento.idea.magento2plugin.util.php; |
6 | 7 |
|
7 | 8 | import com.intellij.patterns.ElementPattern; |
8 | 9 | import com.intellij.patterns.PlatformPatterns; |
| 10 | +import com.intellij.patterns.StandardPatterns; |
9 | 11 | import com.intellij.psi.PsiElement; |
10 | 12 | import com.jetbrains.php.lang.PhpLanguage; |
| 13 | +import com.jetbrains.php.lang.lexer.PhpTokenTypes; |
11 | 14 | import com.jetbrains.php.lang.patterns.PhpPatterns; |
| 15 | +import com.jetbrains.php.lang.psi.elements.ArrayHashElement; |
12 | 16 | import com.jetbrains.php.lang.psi.elements.ParameterList; |
| 17 | +import com.jetbrains.php.lang.psi.elements.PhpPsiElement; |
| 18 | +import com.jetbrains.php.lang.psi.elements.StringLiteralExpression; |
13 | 19 |
|
14 | 20 | public class PhpPatternsHelper { |
15 | 21 | public static final ElementPattern<? extends PsiElement> STRING_METHOD_ARGUMENT = |
16 | | - PhpPatterns |
17 | | - .phpLiteralExpression() |
18 | | - .withParent( |
19 | | - PlatformPatterns |
20 | | - .psiElement(ParameterList.class) |
21 | | - .withParent( |
22 | | - PhpPatterns |
23 | | - .phpFunctionReference() |
| 22 | + PhpPatterns |
| 23 | + .phpLiteralExpression() |
| 24 | + .withParent( |
| 25 | + PlatformPatterns |
| 26 | + .psiElement(ParameterList.class) |
| 27 | + .withParent( |
| 28 | + PhpPatterns |
| 29 | + .phpFunctionReference() |
| 30 | + ) |
| 31 | + ).withLanguage(PhpLanguage.INSTANCE); |
| 32 | + |
| 33 | + public static final ElementPattern<? extends PsiElement> CONFIGPHP_MODULENAME = |
| 34 | + PlatformPatterns.psiElement(StringLiteralExpression.class) |
| 35 | + .withSuperParent(5,PlatformPatterns.psiElement(ArrayHashElement.class) |
| 36 | + .withChild(PlatformPatterns.psiElement(PhpPsiElement.class) |
| 37 | + .withChild(PlatformPatterns.psiElement(StringLiteralExpression.class) |
| 38 | + .withText(StandardPatterns.string().contains("modules").withLength(9)) |
| 39 | + ) |
| 40 | + ) |
| 41 | + ); |
| 42 | + |
| 43 | + public static final ElementPattern<? extends PsiElement> CONFIGPHP_COMPLETION = |
| 44 | + PlatformPatterns.psiElement(PhpTokenTypes.STRING_LITERAL_SINGLE_QUOTE) |
| 45 | + .withSuperParent(6, PlatformPatterns.psiElement(ArrayHashElement.class) |
| 46 | + .withChild(PlatformPatterns.psiElement(PhpPsiElement.class) |
| 47 | + .withChild(PlatformPatterns.psiElement(StringLiteralExpression.class) |
| 48 | + .withText(StandardPatterns.string().contains("modules").withLength(9)) |
| 49 | + ) |
24 | 50 | ) |
25 | | - ).withLanguage(PhpLanguage.INSTANCE); |
| 51 | + ); |
26 | 52 | } |
0 commit comments