本文整理汇总了Java中com.jetbrains.php.lang.parser.PhpElementTypes.ARRAY_VALUE属性的典型用法代码示例。如果您正苦于以下问题:Java PhpElementTypes.ARRAY_VALUE属性的具体用法?Java PhpElementTypes.ARRAY_VALUE怎么用?Java PhpElementTypes.ARRAY_VALUE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.jetbrains.php.lang.parser.PhpElementTypes
的用法示例。
在下文中一共展示了PhpElementTypes.ARRAY_VALUE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isModuleKeyInFlatArray
public static boolean isModuleKeyInFlatArray(@NotNull StringLiteralExpression psiElement, @NotNull String key) {
PsiElement arrayKey = psiElement.getParent();
if(arrayKey != null && arrayKey.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PsiElement hashElement = arrayKey.getParent();
if(hashElement instanceof ArrayHashElement) {
PsiElement arrayCreation = hashElement.getParent();
if(arrayCreation instanceof ArrayCreationExpression) {
PsiElement arrayValue = arrayCreation.getParent();
if(arrayValue != null && arrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PsiElement hashArray = arrayValue.getParent();
if(hashArray instanceof ArrayHashElement) {
PhpPsiElement keyString = ((ArrayHashElement) hashArray).getKey();
if(keyString instanceof StringLiteralExpression) {
String contents = ((StringLiteralExpression) keyString).getContents();
if(key.equals(contents)) {
return true;
}
}
}
}
}
}
}
return false;
}
示例2: isExtendKey
public static boolean isExtendKey(@NotNull StringLiteralExpression parent) {
ArrayCreationExpression arrayCreation = PhpElementsUtil.getCompletableArrayCreationElement(parent);
if(arrayCreation == null) {
return false;
}
PsiElement arrayValue = arrayCreation.getParent();
if(arrayValue != null && arrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PsiElement hashArray = arrayValue.getParent();
if(hashArray instanceof ArrayHashElement) {
PhpPsiElement key = ((ArrayHashElement) hashArray).getKey();
if(key instanceof StringLiteralExpression && "extend".equals(((StringLiteralExpression) key).getContents())) {
return true;
}
}
}
return false;
}
示例3: matches
@Override
public boolean matches(@NotNull LanguageMatcherParameter parameter) {
PsiElement parent = parameter.getElement().getParent();
if(!(parent instanceof StringLiteralExpression)) {
return false;
}
PsiElement arrayValue = parent.getParent();
if(arrayValue == null || arrayValue.getNode().getElementType() != PhpElementTypes.ARRAY_VALUE) {
return false;
}
PsiElement arrayCreation = arrayValue.getParent();
if(!(arrayCreation instanceof ArrayCreationExpression)) {
return false;
}
PsiElement phpReturn = arrayCreation.getParent();
if(!(phpReturn instanceof PhpReturn)) {
return false;
}
return PhpMatcherUtil.isMachingReturnArray(parameter.getSignatures(), phpReturn);
}
示例4: getMethodNameForEventValue
/**
* foo => 'goo'
* foo => ['goo', ... ]
*/
@Nullable
public static String getMethodNameForEventValue(@NotNull PhpPsiElement value) {
if(value instanceof StringLiteralExpression) {
return ((StringLiteralExpression) value).getContents();
}
if(value instanceof ArrayCreationExpression) {
PhpPsiElement firstPsiChild = value.getFirstPsiChild();
if(firstPsiChild != null && firstPsiChild.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
StringLiteralExpression stringLiteral = ObjectUtils.tryCast(firstPsiChild.getFirstPsiChild(), StringLiteralExpression.class);
if(stringLiteral != null) {
return stringLiteral.getContents();
}
}
return null;
}
return null;
}
示例5: getHashKey
private static String getHashKey(@NotNull StringLiteralExpression psiElement) {
PsiElement arrayValue = psiElement.getParent();
if(arrayValue != null && arrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PsiElement arrayHash = arrayValue.getParent();
if(arrayHash instanceof ArrayHashElement) {
PhpPsiElement key = ((ArrayHashElement) arrayHash).getKey();
if(key instanceof StringLiteralExpression) {
String contents = ((StringLiteralExpression) key).getContents();
if(StringUtils.isNotBlank(contents)) {
return contents;
}
}
}
}
return null;
}
示例6: isAfterArrayKey
public static boolean isAfterArrayKey(PsiElement psiElement, String arrayKeyName) {
PsiElement literal = psiElement.getContext();
if(!(literal instanceof StringLiteralExpression)) {
return false;
}
PsiElement arrayValue = literal.getParent();
if(arrayValue.getNode().getElementType() != PhpElementTypes.ARRAY_VALUE) {
return false;
}
PsiElement arrayHashElement = arrayValue.getParent();
if(!(arrayHashElement instanceof ArrayHashElement)) {
return false;
}
PsiElement arrayKey = ((ArrayHashElement) arrayHashElement).getKey();
String keyString = PhpElementsUtil.getStringValue(arrayKey);
return arrayKeyName.equals(keyString);
}
示例7: getArrayPathValue
/**
*
* array('key' => '<cursor>')
*
* Helper for to get find value getArrayPath
* @param psiElement array value as leaf
* @param key key name in current content
* @return parent array creation element
*/
@Nullable
private static ArrayCreationExpression getArrayPathValue(PsiElement psiElement, String key) {
PsiElement arrayValue = psiElement.getContext();
if(arrayValue == null) {
return null;
}
if(arrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PsiElement arrayHashElement = arrayValue.getContext();
if(arrayHashElement instanceof ArrayHashElement) {
PhpPsiElement arrayKey = ((ArrayHashElement) arrayHashElement).getKey();
if(arrayKey instanceof StringLiteralExpression && ((StringLiteralExpression) arrayKey).getContents().equals(key)) {
PsiElement innerArrayKey = arrayKey.getParent();
if(innerArrayKey != null && innerArrayKey.getNode().getElementType() == PhpElementTypes.ARRAY_KEY) {
PsiElement innerArrayHashElement = innerArrayKey.getParent();
if(innerArrayHashElement instanceof ArrayHashElement) {
PsiElement arrayCreation = innerArrayHashElement.getParent();
if(arrayCreation instanceof ArrayCreationExpression) {
return (ArrayCreationExpression) arrayCreation;
}
}
}
}
}
}
return null;
}
示例8: findClassCallback
@Nullable
private PhpClass findClassCallback(@NotNull PsiElement position) {
ArrayCreationExpression arrayCreation = PsiTreeUtil.getParentOfType(position, ArrayCreationExpression.class);
if(arrayCreation == null) {
return null;
}
PhpPsiElement arrayValue = arrayCreation.getFirstPsiChild();
if(arrayValue == null || arrayValue.getNode().getElementType() != PhpElementTypes.ARRAY_VALUE) {
return null;
}
PhpPsiElement variable = arrayValue.getFirstPsiChild();
if(!(variable instanceof Variable)) {
return null;
}
PsiElement resolve = ((Variable) variable).resolve();
if(resolve instanceof PhpClass) {
return (PhpClass) resolve;
}
for (String s : ((Variable) variable).getType().filterPrimitives().getTypes()) {
Collection<PhpClass> anyByFQN = PhpIndex.getInstance(position.getProject()).getAnyByFQN(s);
if(anyByFQN.size() > 0) {
return anyByFQN.iterator().next();
}
}
return null;
}
示例9: collectThemeJsFieldReferences
public static void collectThemeJsFieldReferences(@NotNull StringLiteralExpression element, @NotNull ThemeAssetVisitor visitor) {
PsiElement arrayValue = element.getParent();
if(arrayValue.getNode().getElementType() != PhpElementTypes.ARRAY_VALUE) {
return;
}
PsiElement arrayCreation = arrayValue.getParent();
if(!(arrayCreation instanceof ArrayCreationExpression)) {
return;
}
PsiElement classField = arrayCreation.getParent();
if(!(classField instanceof Field)) {
return;
}
if(!"javascript".equals(((Field) classField).getName())) {
return;
}
PhpClass phpClass = PsiTreeUtil.getParentOfType(classField, PhpClass.class);
if(phpClass == null || !PhpElementsUtil.isInstanceOf(phpClass, "\\Shopware\\Components\\Theme")) {
return;
}
visitThemeAssetsFile(phpClass, visitor);
}
示例10: createTranslationGotoCompletionWithLabelSwitch
@Nullable
private GotoCompletionProvider createTranslationGotoCompletionWithLabelSwitch(@NotNull PsiElement origin, @NotNull ArrayCreationExpression choices, Processor<ArrayCreationExpression> processor) {
PsiElement choicesArrayValue = choices.getParent();
if(choicesArrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PsiElement choicesValueHash = choicesArrayValue.getParent();
if(choicesValueHash instanceof ArrayHashElement) {
PhpPsiElement transKey = ((ArrayHashElement) choicesValueHash).getKey();
String stringValue = PhpElementsUtil.getStringValue(transKey);
if("choices".equals(stringValue)) {
PsiElement choicesKey = transKey.getParent();
if(choicesKey.getNode().getElementType() == PhpElementTypes.ARRAY_KEY) {
PsiElement formOptionsHash = choicesKey.getParent();
if(formOptionsHash instanceof ArrayHashElement) {
PsiElement arrayCreation = formOptionsHash.getParent();
if(arrayCreation instanceof ArrayCreationExpression) {
if(processor.process((ArrayCreationExpression) arrayCreation)) {
return createTranslationGotoCompletion(origin, arrayCreation);
}
}
}
}
}
}
}
return null;
}
示例11: visitElement
@Override
public void visitElement(PsiElement element) {
super.visitElement(element);
if(!(element instanceof StringLiteralExpression)) {
return;
}
PsiElement arrayValue = element.getParent();
if(arrayValue != null && arrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PhpReturn phpReturn = PsiTreeUtil.getParentOfType(arrayValue, PhpReturn.class);
if(phpReturn != null) {
Method method = PsiTreeUtil.getParentOfType(arrayValue, Method.class);
if(method != null) {
String name = method.getName();
if("getSubscribedEvents".equals(name)) {
PhpClass containingClass = method.getContainingClass();
if(containingClass != null && PhpElementsUtil.isInstanceOf(containingClass, "\\Symfony\\Component\\EventDispatcher\\EventSubscriberInterface")) {
String contents = ((StringLiteralExpression) element).getContents();
if(StringUtils.isNotBlank(contents) && containingClass.findMethodByName(contents) == null) {
registerMethodProblem(element, holder, containingClass);
}
}
}
}
}
}
}
示例12: isInTemplateWithKey
/**
* Block keys, a really depth tree structure
*/
public static boolean isInTemplateWithKey(@NotNull StringLiteralExpression psiElement, @NotNull String key) {
PsiElement arrayValue = psiElement.getParent();
if(arrayValue != null && arrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PsiElement hashElement = arrayValue.getParent();
if(hashElement instanceof ArrayHashElement) {
PhpPsiElement keyString = ((ArrayHashElement) hashElement).getKey();
if(keyString instanceof StringLiteralExpression) {
String contents = ((StringLiteralExpression) keyString).getContents();
if(key.equals(contents)) {
PsiElement templateArrayValue = hashElement.getParent();
if(templateArrayValue instanceof ArrayCreationExpression) {
PsiElement blockArrayValue = templateArrayValue.getParent();
if(blockArrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PsiElement arrayCrea = blockArrayValue.getParent();
if(arrayCrea instanceof ArrayCreationExpression) {
PsiElement arrayValueBlock = arrayCrea.getParent();
if(arrayValueBlock != null && arrayValueBlock.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PsiElement blockHash = arrayValueBlock.getParent();
if(blockHash instanceof ArrayHashElement) {
PhpPsiElement keyBlock = ((ArrayHashElement) blockHash).getKey();
if(keyBlock instanceof StringLiteralExpression) {
String blockContents = ((StringLiteralExpression) keyBlock).getContents();
if("blocks".equals(blockContents)) {
return true;
}
}
}
}
}
}
}
}
}
}
}
return false;
}
示例13: getRepository
@Nullable
@Override
public String getRepository(@NotNull QueryBuilderRepositoryDetectorParameter parameter) {
MethodReference qbMethodRef = parameter.getMethodReferenceByName("createQueryBuilder");
if(qbMethodRef == null) {
return null;
}
/*
$builder->add('field_1', 'foo', array(
'class' => 'Repository',
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('u')
->orderBy('u.field_1', 'ASC');
},
));
*/
Function parentOfType = PsiTreeUtil.getParentOfType(qbMethodRef, Function.class);
if(parentOfType != null && parentOfType.isClosure()) {
PsiElement closure = parentOfType.getParent();
if(closure.getNode().getElementType() == PhpElementTypes.CLOSURE) {
PsiElement arrayValue = closure.getParent();
if(arrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PsiElement arrayHash = arrayValue.getParent();
if(arrayHash instanceof ArrayHashElement) {
PsiElement arrayCreation = arrayHash.getParent();
if(arrayCreation instanceof ArrayCreationExpression) {
String aClass = PhpElementsUtil.getArrayValueString((ArrayCreationExpression) arrayCreation, "class");
if(aClass != null && StringUtils.isNotBlank(aClass)) {
// finally we found our class key
PhpClass phpClass = EntityHelper.resolveShortcutName(parameter.getProject(), aClass);
if(phpClass != null) {
return phpClass.getPresentableFQN();
}
}
}
}
}
}
}
return null;
}
示例14: value
@Override
public boolean value(PsiElement psiElement) {
return psiElement.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE;
}
示例15: getSubscriberMethods
/**
* Extract method name for subscribe
*
* 'pre.foo1' => 'foo'
* 'pre.foo1' => ['onStoreOrder', 0]
* 'pre.foo2' => [['onStoreOrder', 0]]
*/
@NotNull
private static Collection<PsiElement> getSubscriberMethods(@NotNull ArrayHashElement arrayHashElement) {
// support string, constants and array values
PhpPsiElement value = arrayHashElement.getValue();
if(value == null) {
Collections.emptySet();
}
// 'pre.foo' => [...]
if(!(value instanceof ArrayCreationExpression)) {
return new ArrayList<>(Collections.singletonList(value));
}
Collection<PsiElement> psiElements = new HashSet<>();
// 'pre.foo' => [<caret>]
PsiElement firstChild = value.getFirstPsiChild();
if(firstChild != null && firstChild.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
PhpPsiElement firstPsiChild = ((PhpPsiElement) firstChild).getFirstPsiChild();
if(firstPsiChild instanceof StringLiteralExpression) {
// 'pre.foo' => ['method']
psiElements.add(firstPsiChild);
} else if(firstPsiChild instanceof ArrayCreationExpression) {
// 'pre.foo' => [['method', ...], ['method2', ...]]
for (PsiElement psiElement : PsiElementUtils.getChildrenOfTypeAsList(firstPsiChild, PlatformPatterns.psiElement().withElementType(PhpElementTypes.ARRAY_VALUE))) {
if(!(psiElement instanceof PhpPsiElement)) {
continue;
}
PhpPsiElement prioValue = ((PhpPsiElement) psiElement).getFirstPsiChild();
if(prioValue instanceof StringLiteralExpression) {
psiElements.add(prioValue);
}
}
}
}
return psiElements;
}