本文整理汇总了Java中com.jetbrains.php.lang.parser.PhpElementTypes.ARRAY_KEY属性的典型用法代码示例。如果您正苦于以下问题:Java PhpElementTypes.ARRAY_KEY属性的具体用法?Java PhpElementTypes.ARRAY_KEY怎么用?Java PhpElementTypes.ARRAY_KEY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.jetbrains.php.lang.parser.PhpElementTypes
的用法示例。
在下文中一共展示了PhpElementTypes.ARRAY_KEY属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: fillCompletionVariants
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result)
{
PsiElement element = parameters.getPosition().getParent();
ParameterList parameterList = PsiTreeUtil.getParentOfType(element, ParameterList.class);
if (parameterList == null) {
return;
}
if (element.getParent() instanceof PhpPsiElement
&& ((PhpPsiElement) element.getParent()).getPrevPsiSibling() != null
&& ((PhpPsiElement) element.getParent()).getPrevPsiSibling().getNode().getElementType() == PhpElementTypes.ARRAY_KEY) {
return;
}
PsiElement context = parameterList.getContext();
if (!(context instanceof MethodReference)) {
return;
}
MethodReference methodReference = (MethodReference) context;
PsiElement methodEl = methodReference.resolve();
if (methodEl == null || !(methodEl instanceof Method)) {
return;
}
Method method = (Method) methodEl;
if (!(method.getName().equals("findBy") || method.getName().equals("getBy") || method.getName().equals("orderBy"))) {
return;
}
Project project = parameters.getEditor().getProject();
if (project == null) {
return;
}
String fieldExpression = parameters.getOriginalPosition().getText();
String[] path = fieldExpression.split("->", -1);
Collection<PhpClass> queriedEntities = OrmUtils.findQueriedEntities(methodReference, path);
for (PhpClass cls : queriedEntities) {
if (cls.getDocComment() == null) {
continue;
}
for (PhpDocPropertyTag phpDocPropertyTag : cls.getDocComment().getPropertyTags()) {
Stream<String> types = phpDocPropertyTag.getType().getTypesSorted().stream()
.filter(s -> !s.contains("Nextras\\Orm\\Relationships") && !s.equals("?"))
.map(s -> s.startsWith("\\") ? s.substring(1) : s);
String strPath = String.join("->", Arrays.copyOfRange(path, 0, path.length - 1));
if (strPath.length() > 0) {
strPath += "->";
}
String fieldName = phpDocPropertyTag.getProperty().getText().substring(1);
strPath += fieldName;
result.addElement(LookupElementBuilder.create(strPath)
.withPresentableText(fieldName)
.withTypeText(types.collect(Collectors.joining("|"))));
}
if (path.length == 1) {
result.addElement(LookupElementBuilder.create("this").withTypeText(cls.getType().toString()));
result.addElement(LookupElementBuilder.create(cls.getFQN()).withTypeText(cls.getType().toString()));
}
}
}