本文整理汇总了Java中com.jetbrains.php.lang.psi.elements.FunctionReference类的典型用法代码示例。如果您正苦于以下问题:Java FunctionReference类的具体用法?Java FunctionReference怎么用?Java FunctionReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FunctionReference类属于com.jetbrains.php.lang.psi.elements包,在下文中一共展示了FunctionReference类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildVisitor
import com.jetbrains.php.lang.psi.elements.FunctionReference; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
return new PhpElementVisitor() {
@Override
public void visitPhpElement(PhpPsiElement element) {
if (!PlatformPatterns.psiElement(PhpElementTypes.FUNCTION_CALL).accepts(element)) {
return;
}
Set<String> constants = getRemovedGlobalFuntions(element);
FunctionReference constantReference = (FunctionReference) element;
if (constants.contains(constantReference.getFQN())) {
problemsHolder.registerProblem(element, "Global function removed with TYPO3 9, consider using an alternative");
}
}
};
}
示例2: isFunctionParameter
import com.jetbrains.php.lang.psi.elements.FunctionReference; //导入依赖的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);
}
}
}
示例3: isFunctionReference
import com.jetbrains.php.lang.psi.elements.FunctionReference; //导入依赖的package包/类
public static boolean isFunctionReference(@NotNull PsiElement psiElement, @NotNull String functionName, int parameterIndex) {
PsiElement parameterList = psiElement.getParent();
if(!(parameterList instanceof ParameterList)) {
return false;
}
ParameterBag index = PhpElementsUtil.getCurrentParameterIndex(psiElement);
if(index == null || index.getIndex() != parameterIndex) {
return false;
}
PsiElement functionCall = parameterList.getParent();
if(!(functionCall instanceof FunctionReference)) {
return false;
}
return functionName.equals(((FunctionReference) functionCall).getName());
}
示例4: visitFunctionReference
import com.jetbrains.php.lang.psi.elements.FunctionReference; //导入依赖的package包/类
private void visitFunctionReference(FunctionReference functionReference) {
if(!"view".equals(functionReference.getName())) {
return;
}
PsiElement[] parameters = functionReference.getParameters();
if(parameters.length < 1 || !(parameters[0] instanceof StringLiteralExpression)) {
return;
}
String contents = ((StringLiteralExpression) parameters[0]).getContents();
if(StringUtils.isBlank(contents)) {
return;
}
views.add(Pair.create(contents, parameters[0]));
}
示例5: applyFix
import com.jetbrains.php.lang.psi.elements.FunctionReference; //导入依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
PsiElement item = descriptor.getPsiElement();
PsiElement context = item.getContext();
if (context instanceof ArrayCreationExpression) {
ArrayCreationExpression params = (ArrayCreationExpression) item.getParent();
PsiUtil.deleteArrayElement(item);
if (!params.getHashElements().iterator().hasNext()) {
if (params.getPrevSibling() instanceof PsiWhiteSpace) {
params.getPrevSibling().delete();
}
params.getPrevSibling().delete();
params.delete();
}
}
if (context instanceof ParameterList && context.getParent() instanceof FunctionReference) {
FunctionReference functionReference = (FunctionReference) context.getParent();
if (functionReference.getName() != null && functionReference.getName().equals("compact")) {
PsiUtil.deleteFunctionParam(item);
if (functionReference.getParameters().length == 0) {
PsiUtil.deleteFunctionParam(functionReference);
}
}
}
}
示例6: visitElement
import com.jetbrains.php.lang.psi.elements.FunctionReference; //导入依赖的package包/类
@Override
public void visitElement(PsiElement element) {
if(element instanceof FunctionReference) {
this.visitFunction((FunctionReference) element);
}
super.visitElement(element);
}
示例7: visitElement
import com.jetbrains.php.lang.psi.elements.FunctionReference; //导入依赖的package包/类
@Override
public void visitElement(PsiElement element) {
if(element instanceof MethodReference) {
visitMethodReference((MethodReference) element);
}
if(element instanceof FunctionReference) {
visitFunctionReference((FunctionReference) element);
}
super.visitElement(element);
}
示例8: extractKey
import com.jetbrains.php.lang.psi.elements.FunctionReference; //导入依赖的package包/类
public static PsiElement extractKey(FunctionReference translationCall) {
PsiElement parameter = translationCall.getParameters()[0];
if (PlatformPatterns.psiElement(PhpElementTypes.CONCATENATION_EXPRESSION).accepts(parameter)) {
BinaryExpression binaryExpression = (BinaryExpression) parameter;
parameter = binaryExpression.getLeftOperand();
}
return parameter;
}
示例9: parse
import com.jetbrains.php.lang.psi.elements.FunctionReference; //导入依赖的package包/类
public void parse(PsiFile psiFile, TranslationCallHandler handler) {
Collection<FunctionReference> calls = PsiTreeUtil.collectElementsOfType(psiFile, FunctionReference.class);
for (FunctionReference call : calls) {
if (TranslationUtils.isTranslationCall(call)) {
PsiElement psiElement = TranslationUtils.extractKey(call);
String key = PsiUtils.getContent(psiElement);
key = StringUtils.strip(key, ".");
if (key != null) {
handler.handleKey(key, psiElement);
}
}
}
}
示例10: isTranslationCall
import com.jetbrains.php.lang.psi.elements.FunctionReference; //导入依赖的package包/类
public static boolean isTranslationCall(FunctionReference call) {
return call.getParameters().length > 0 && (call.getName().equals("t") || call.getText().startsWith("I18n::labels"));
}
示例11: isEnvFunction
import com.jetbrains.php.lang.psi.elements.FunctionReference; //导入依赖的package包/类
/**
* Checks whether this function reference is reference for env functions, like env or getenv
* @param functionReference Checking reference
* @return true if condition filled
*/
public static boolean isEnvFunction(FunctionReference functionReference) {
String name = functionReference.getName();
return (name != null && Arrays.asList("getenv", "env").contains(name));
}
示例12: visitFunction
import com.jetbrains.php.lang.psi.elements.FunctionReference; //导入依赖的package包/类
private void visitFunction(FunctionReference expression) {
if(!PsiUtil.isEnvFunction(expression)) return;
PsiElement[] parameters = expression.getParameters();
if(parameters.length == 0) return;
if(!(parameters[0] instanceof StringLiteralExpression)) return;
String key = ((StringLiteralExpression)parameters[0]).getContents();
collectedItems.add(new KeyUsagePsiElement(key, parameters[0]));
}