本文整理汇总了Java中com.jetbrains.php.lang.psi.elements.ParameterList.getContext方法的典型用法代码示例。如果您正苦于以下问题:Java ParameterList.getContext方法的具体用法?Java ParameterList.getContext怎么用?Java ParameterList.getContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jetbrains.php.lang.psi.elements.ParameterList
的用法示例。
在下文中一共展示了ParameterList.getContext方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isFunctionParameter
import com.jetbrains.php.lang.psi.elements.ParameterList; //导入方法依赖的package包/类
private static boolean isFunctionParameter(PsiElement psiElement, int parameterIndex, String... funcName) {
PsiElement variableContext = psiElement.getContext();
if(!(variableContext instanceof ParameterList)) {
return false;
} else {
ParameterList parameterList = (ParameterList) variableContext;
PsiElement context = parameterList.getContext();
if(!(context instanceof FunctionReference)) {
return false;
} else {
FunctionReference methodReference = (FunctionReference) context;
String name = methodReference.getName();
return (name != null && Arrays.asList(funcName).contains(name) && getParameterIndex(parameterList, psiElement) == parameterIndex);
}
}
}
示例2: invoke
import com.jetbrains.php.lang.psi.elements.ParameterList; //导入方法依赖的package包/类
private void invoke(@NotNull ProblemsHolder holder, @NotNull PsiElement psiElement) {
if (!(psiElement instanceof StringLiteralExpression) || !(psiElement.getContext() instanceof ParameterList)) {
return;
}
ParameterList parameterList = (ParameterList) psiElement.getContext();
PsiElement methodReference = parameterList.getContext();
if (!(methodReference instanceof MethodReference)) {
return;
}
if (!PhpElementsUtil.isMethodReferenceInstanceOf((MethodReference) methodReference, TranslationUtil.PHP_TRANSLATION_SIGNATURES)) {
return;
}
int domainParameter = 2;
if("transChoice".equals(((MethodReference) methodReference).getName())) {
domainParameter = 3;
}
ParameterBag currentIndex = PsiElementUtils.getCurrentParameterIndex(psiElement);
if(currentIndex != null && currentIndex.getIndex() == domainParameter) {
annotateTranslationDomain((StringLiteralExpression) psiElement, holder);
}
}
示例3: getReferencesByElement
import com.jetbrains.php.lang.psi.elements.ParameterList; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
if (!Symfony2ProjectComponent.isEnabled(psiElement) || !(psiElement.getContext() instanceof ParameterList)) {
return new PsiReference[0];
}
ParameterList parameterList = (ParameterList) psiElement.getContext();
PsiElement methodReference = parameterList.getContext();
if (!(methodReference instanceof MethodReference)) {
return new PsiReference[0];
}
for(Call call: this.oneOfCall) {
if (PhpElementsUtil.isMethodReferenceInstanceOf((MethodReference) methodReference, call.getClassName(), call.getMethodName()) && PsiElementUtils.getParameterIndexValue(psiElement) == call.getIndex()) {
return this.getPsiReferenceBase(psiElement);
}
}
return new PsiReference[0];
}
示例4: getMethodReferenceWithFirstStringParameter
import com.jetbrains.php.lang.psi.elements.ParameterList; //导入方法依赖的package包/类
@Nullable
public static MethodReference getMethodReferenceWithFirstStringParameter(PsiElement psiElement) {
if (!PlatformPatterns.psiElement()
.withParent(StringLiteralExpression.class).inside(ParameterList.class)
.withLanguage(PhpLanguage.INSTANCE).accepts(psiElement)) {
return null;
}
ParameterList parameterList = PsiTreeUtil.getParentOfType(psiElement, ParameterList.class);
if (parameterList == null) {
return null;
}
if (!(parameterList.getContext() instanceof MethodReference)) {
return null;
}
return (MethodReference) parameterList.getContext();
}
示例5: isInContextOfDispatchMethod
import com.jetbrains.php.lang.psi.elements.ParameterList; //导入方法依赖的package包/类
private boolean isInContextOfDispatchMethod(PsiElement psiElement) {
ParameterList parameterList = PsiTreeUtil.getParentOfType(psiElement, ParameterList.class);
if (parameterList == null) {
return false;
}
if (!(parameterList.getContext() instanceof MethodReference)) {
return false;
}
MethodReference methodReference = (MethodReference)parameterList.getContext();
return methodReference.getName() != null && methodReference.getName().equals("dispatch");
}
示例6: getReferencesByElement
import com.jetbrains.php.lang.psi.elements.ParameterList; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
ParameterList parameterList = PsiTreeUtil.getParentOfType(psiElement, ParameterList.class);
if (parameterList == null) {
return new PsiReference[0];
}
if(!(parameterList.getContext() instanceof MethodReference)) {
return new PsiReference[0];
}
MethodReference methodReference = (MethodReference)parameterList.getContext();
if (!DISPATCH_METHOD.equals(methodReference.getName())) {
return new PsiReference[0];
}
PsiElement resolvedElement = methodReference.resolve();
if (resolvedElement != null && resolvedElement instanceof Method) {
PhpClass containingClass = ((Method) resolvedElement).getContainingClass();
if (containingClass != null && MagentoTypes.EVENT_MANAGER_TYPE.equals(containingClass.getPresentableFQN())) {
return new PsiReference[]{new TypeReference(psiElement, this.resultsFillers, true)};
}
}
return new PsiReference[0];
}
示例7: getCurrentParameterIndex
import com.jetbrains.php.lang.psi.elements.ParameterList; //导入方法依赖的package包/类
@Nullable
public static ParameterBag getCurrentParameterIndex(PsiElement psiElement) {
if (!(psiElement.getContext() instanceof ParameterList)) {
return null;
}
ParameterList parameterList = (ParameterList) psiElement.getContext();
if (!(parameterList.getContext() instanceof ParameterListOwner)) {
return null;
}
return getCurrentParameterIndex(parameterList.getParameters(), psiElement);
}
示例8: getReferencesByElement
import com.jetbrains.php.lang.psi.elements.ParameterList; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext processingContext) {
ParameterList parameterList = (ParameterList) psiElement.getContext();
if (parameterList == null || !(parameterList.getContext() instanceof MethodReference)) {
return new PsiReference[0];
}
MethodReference method = (MethodReference) parameterList.getContext();
// System.err.println(referenceClass);
return this.getPsiReferenceBase(psiElement);
// return new PsiReference[0];
}
示例9: invoke
import com.jetbrains.php.lang.psi.elements.ParameterList; //导入方法依赖的package包/类
private void invoke(@NotNull ProblemsHolder holder, @NotNull PsiElement psiElement) {
if (!(psiElement instanceof StringLiteralExpression) || !(psiElement.getContext() instanceof ParameterList)) {
return;
}
ParameterList parameterList = (ParameterList) psiElement.getContext();
PsiElement methodReference = parameterList.getContext();
if (!(methodReference instanceof MethodReference)) {
return;
}
if (!PhpElementsUtil.isMethodReferenceInstanceOf((MethodReference) methodReference, TranslationUtil.PHP_TRANSLATION_SIGNATURES)) {
return;
}
ParameterBag currentIndex = PsiElementUtils.getCurrentParameterIndex(psiElement);
if(currentIndex == null || currentIndex.getIndex() != 0) {
return;
}
int domainParameter = 2;
if("transChoice".equals(((MethodReference) methodReference).getName())) {
domainParameter = 3;
}
PsiElement domainElement = PsiElementUtils.getMethodParameterPsiElementAt(parameterList, domainParameter);
if(domainElement == null) {
// no domain found; fallback to default domain
annotateTranslationKey((StringLiteralExpression) psiElement, "messages", holder);
} else {
// resolve string in parameter
PsiElement[] parameters = parameterList.getParameters();
if(parameters.length >= domainParameter) {
String domain = PhpElementsUtil.getStringValue(parameters[domainParameter]);
if(domain != null) {
annotateTranslationKey((StringLiteralExpression) psiElement, domain, holder);
}
}
}
}