Java Code Examples for com.intellij.patterns.PlatformPatterns#psiElement()
The following examples show how to use
com.intellij.patterns.PlatformPatterns#psiElement() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TwigUtil.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@Nullable public static String getTwigMethodString(@Nullable PsiElement transPsiElement) { if (transPsiElement == null) return null; ElementPattern<PsiElement> pattern = PlatformPatterns.psiElement(TwigTokenTypes.RBRACE); String currentText = transPsiElement.getText(); for (PsiElement child = transPsiElement.getNextSibling(); child != null; child = child.getNextSibling()) { currentText = currentText + child.getText(); if (pattern.accepts(child)) { //noinspection unchecked return currentText; } } return null; }
Example 2
Source File: TwigPattern.java From idea-php-symfony2-plugin with MIT License | 5 votes |
/** * Only a parameter is valid "('foobar'," */ @NotNull public static PsiElementPattern getFirstFunctionParameterAsStringPattern() { // string wrapped elements ElementPattern[] elementPatterns = { PlatformPatterns.psiElement(TwigTokenTypes.WHITE_SPACE), PlatformPatterns.psiElement(PsiWhiteSpace.class), PlatformPatterns.psiElement(TwigTokenTypes.SINGLE_QUOTE), PlatformPatterns.psiElement(TwigTokenTypes.DOUBLE_QUOTE) }; return PlatformPatterns.psiElement(TwigTokenTypes.STRING_TEXT) .beforeLeafSkipping(PlatformPatterns.or(elementPatterns), PlatformPatterns.psiElement(TwigTokenTypes.COMMA)) .afterLeafSkipping(PlatformPatterns.or(elementPatterns), PlatformPatterns.psiElement(TwigTokenTypes.LBRACE)); }
Example 3
Source File: TwigPattern.java From idea-php-symfony2-plugin with MIT License | 5 votes |
/** * Only a parameter is valid ", 'foobar' [,)]" */ @NotNull public static PsiElementPattern getParameterAsStringPattern() { // string wrapped elements ElementPattern[] elementPatterns = { PlatformPatterns.psiElement(TwigTokenTypes.WHITE_SPACE), PlatformPatterns.psiElement(PsiWhiteSpace.class), PlatformPatterns.psiElement(TwigTokenTypes.SINGLE_QUOTE), PlatformPatterns.psiElement(TwigTokenTypes.DOUBLE_QUOTE) }; return PlatformPatterns.psiElement(TwigTokenTypes.STRING_TEXT) .beforeLeafSkipping(PlatformPatterns.or(elementPatterns), PlatformPatterns.or(PlatformPatterns.psiElement(TwigTokenTypes.COMMA), PlatformPatterns.psiElement(TwigTokenTypes.RBRACE))) .afterLeafSkipping(PlatformPatterns.or(elementPatterns), PlatformPatterns.psiElement(TwigTokenTypes.COMMA)); }
Example 4
Source File: TargetRenameValidator.java From intellij with Apache License 2.0 | 4 votes |
@Override public ElementPattern<? extends PsiElement> getPattern() { // FuncallExpression is the owner of the target name. return PlatformPatterns.psiElement(FuncallExpression.class); }
Example 5
Source File: TwigPattern.java From idea-php-symfony2-plugin with MIT License | 4 votes |
/** * trans({}, 'bar') * trans(null, 'bar') * transchoice(2, null, 'bar') */ public static ElementPattern<PsiElement> getTransDomainPattern() { //noinspection unchecked ElementPattern[] whitespace = { PlatformPatterns.psiElement(PsiWhiteSpace.class), PlatformPatterns.psiElement(TwigTokenTypes.WHITE_SPACE) }; ElementPattern[] placeholder = { PlatformPatterns.psiElement(PsiWhiteSpace.class), PlatformPatterns.psiElement(TwigTokenTypes.WHITE_SPACE), PlatformPatterns.psiElement(TwigTokenTypes.IDENTIFIER), PlatformPatterns.psiElement(TwigTokenTypes.DOT), PlatformPatterns.psiElement(TwigTokenTypes.LBRACE_SQ), PlatformPatterns.psiElement(TwigTokenTypes.RBRACE_SQ) }; //noinspection unchecked return PlatformPatterns .psiElement(TwigTokenTypes.STRING_TEXT) .afterLeafSkipping( PlatformPatterns.or( PlatformPatterns.psiElement(PsiWhiteSpace.class), PlatformPatterns.psiElement(TwigTokenTypes.WHITE_SPACE), PlatformPatterns.psiElement(TwigTokenTypes.SINGLE_QUOTE), PlatformPatterns.psiElement(TwigTokenTypes.DOUBLE_QUOTE) ), PlatformPatterns.or( // trans({}, 'bar') PlatformPatterns.psiElement(TwigTokenTypes.COMMA).afterLeafSkipping( PlatformPatterns.or(whitespace), PlatformPatterns.psiElement(TwigTokenTypes.RBRACE_CURL).withParent( PlatformPatterns.psiElement(TwigElementTypes.LITERAL).afterLeafSkipping( PlatformPatterns.or(whitespace), PlatformPatterns.psiElement(TwigTokenTypes.LBRACE).afterLeafSkipping( PlatformPatterns.or(whitespace), PlatformPatterns.psiElement(TwigTokenTypes.IDENTIFIER).withText(PlatformPatterns.string().oneOf("trans")) ) ) ) ), // trans(null, 'bar') // trans(, 'bar') PlatformPatterns.psiElement(TwigTokenTypes.COMMA).afterLeafSkipping( PlatformPatterns.or(placeholder), PlatformPatterns.psiElement(TwigTokenTypes.LBRACE).afterLeafSkipping( PlatformPatterns.or(whitespace), PlatformPatterns.psiElement(TwigTokenTypes.IDENTIFIER).withText(PlatformPatterns.string().oneOf("trans")) ) ), // transchoice(2, {}, 'bar') PlatformPatterns.psiElement(TwigTokenTypes.COMMA).afterLeafSkipping( PlatformPatterns.or(whitespace), PlatformPatterns.psiElement(TwigTokenTypes.RBRACE_CURL).withParent( PlatformPatterns.psiElement(TwigElementTypes.LITERAL).afterLeafSkipping( PlatformPatterns.or(whitespace), PlatformPatterns.psiElement(TwigTokenTypes.COMMA).afterLeafSkipping( PlatformPatterns.or(PARAMETER_WHITE_LIST), PlatformPatterns.psiElement(TwigTokenTypes.LBRACE).afterLeafSkipping( PlatformPatterns.or(whitespace), PlatformPatterns.psiElement(TwigTokenTypes.IDENTIFIER).withText(PlatformPatterns.string().oneOf("transchoice")) ) ) ) ) ), // transchoice(2, null, 'bar') PlatformPatterns.psiElement(TwigTokenTypes.COMMA).afterLeafSkipping( PlatformPatterns.or(placeholder), PlatformPatterns.psiElement(TwigTokenTypes.COMMA).afterLeafSkipping( PlatformPatterns.or(PARAMETER_WHITE_LIST), PlatformPatterns.psiElement(TwigTokenTypes.LBRACE).afterLeafSkipping( PlatformPatterns.or(whitespace), PlatformPatterns.psiElement(TwigTokenTypes.IDENTIFIER).withText(PlatformPatterns.string().oneOf("transchoice")) ) ) ) ) ) .withLanguage(TwigLanguage.INSTANCE); }
Example 6
Source File: YamlGoToDeclarationHandlerTest.java From idea-php-symfony2-plugin with MIT License | 4 votes |
@NotNull private PsiElementPattern.Capture<PhpClass> getClassPattern() { return PlatformPatterns.psiElement(PhpClass.class); }
Example 7
Source File: AnnotationPattern.java From idea-php-annotation-plugin with MIT License | 4 votes |
public static ElementPattern<PsiElement> getDocBlockTagAfterBackslash() { return PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_TAG_NAME); }