本文整理汇总了Java中com.intellij.psi.PsiParameter.getTypeElement方法的典型用法代码示例。如果您正苦于以下问题:Java PsiParameter.getTypeElement方法的具体用法?Java PsiParameter.getTypeElement怎么用?Java PsiParameter.getTypeElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiParameter
的用法示例。
在下文中一共展示了PsiParameter.getTypeElement方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitCatchSection
import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
@Override
public void visitCatchSection(PsiCatchSection section) {
super.visitCatchSection(section);
final PsiParameter parameter = section.getParameter();
if (parameter == null) {
return;
}
final PsiTypeElement typeElement = parameter.getTypeElement();
if (typeElement == null) {
return;
}
final PsiTypeElement[] childTypeElements = PsiTreeUtil.getChildrenOfType(typeElement, PsiTypeElement.class);
if (childTypeElements != null) {
for (PsiTypeElement childTypeElement : childTypeElements) {
checkTypeElement(childTypeElement);
}
}
else {
checkTypeElement(typeElement);
}
}
示例2: visitParameter
import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
@Override
public void visitParameter(@NotNull PsiParameter parameter) {
super.visitParameter(parameter);
if (parameter.getDeclarationScope() instanceof PsiCatchSection) {
return;
}
final PsiTypeElement typeElement = parameter.getTypeElement();
if (typeElement == null) {
return;
}
if (!ConcreteClassUtil.typeIsConcreteClass(typeElement,
ignoreAbstractClasses)) {
return;
}
final String variableName = parameter.getName();
registerError(typeElement, variableName);
}
示例3: navigateToConstructorIfProvider
import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
private boolean navigateToConstructorIfProvider(PsiParameter psiParameter) {
PsiTypeElement declaringTypeElement = psiParameter.getTypeElement();
PsiClass classElement = JavaPsiFacade.getInstance(psiParameter.getProject()).findClass(
declaringTypeElement.getType().getCanonicalText(),
declaringTypeElement.getResolveScope());
if (classElement == null) {
return false;
}
for (PsiMethod method : classElement.getConstructors()) {
if (PsiConsultantImpl.hasAnnotation(method, CLASS_INJECT) && navigateToElement(method)) {
return true;
}
}
return false;
}
示例4: generateSetters
import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
@Override
public PsiMethod[] generateSetters(PsiField field) {
final PsiMethod setter = PropertyUtil.generateSetterPrototype(field);
final Project project = field.getProject();
final PsiType wrappedType = JavaFxPsiUtil.getWrappedPropertyType(field, project, JavaFxCommonClassNames.ourWritableMap);
final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
final PsiTypeElement newTypeElement = elementFactory.createTypeElement(wrappedType);
final PsiParameter[] parameters = setter.getParameterList().getParameters();
LOG.assertTrue(parameters.length == 1);
final PsiParameter parameter = parameters[0];
final PsiTypeElement typeElement = parameter.getTypeElement();
LOG.assertTrue(typeElement != null);
typeElement.replace(newTypeElement);
final PsiCodeBlock body = setter.getBody();
LOG.assertTrue(body != null);
body.getStatements()[0].replace(elementFactory.createStatementFromText("this." + field.getName() + ".set(" + parameter.getName() + ");", field));
return new PsiMethod[] {setter};
}
示例5: debugParameters
import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
public static void debugParameters(String tag, PsiElement root, List<PsiParameter> parameters) {
System.out.println(tag + " :root=>>>>\n" + root.getText() + "\n<<<");
for (PsiParameter param : parameters) {
PsiIdentifier id = param.getNameIdentifier();
PsiTypeElement type = param.getTypeElement();
PsiExpression init = param.getInitializer();
System.out.println("parameter -> " + param.getText()
+ ", id=" + (id != null ? id.getText() : "null")
+ ", type=" + (type != null ? type.getText() : "null"));
}
System.out.println();
}
示例6: verifyParameter
import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
public void verifyParameter(@NotNull final PsiParameter psiParameter, @NotNull final ProblemsHolder holder) {
final PsiTypeElement typeElement = psiParameter.getTypeElement();
boolean isVal = null != typeElement && isSameName(typeElement.getText());
boolean isVar = null != typeElement && isVar(typeElement.getText());
if (isVar || isVal) {
PsiElement scope = psiParameter.getDeclarationScope();
boolean isForeachStatement = scope instanceof PsiForeachStatement;
boolean isForStatement = scope instanceof PsiForStatement;
if (isVal && !isForeachStatement) {
holder.registerProblem(psiParameter, "'val' works only on local variables and on foreach loops", ProblemHighlightType.ERROR);
} else if (isVar && !(isForeachStatement || isForStatement)) {
holder.registerProblem(psiParameter, "'var' works only on local variables and on for/foreach loops", ProblemHighlightType.ERROR);
}
}
}
示例7: getMethodParameter
import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
public static @Nullable PsiTypeElement getMethodParameter(PsiMethod subscribeMethod) {
PsiParameterList parameterList = subscribeMethod.getParameterList();
if (parameterList.getParametersCount() != 1) {
return null;
} else {
PsiParameter subscribeMethodParam = parameterList.getParameters()[0];
return subscribeMethodParam.getTypeElement();
}
}
示例8: getContainer
import com.intellij.psi.PsiParameter; //导入方法依赖的package包/类
@Nullable
@Override
public PsiElement getContainer(PsiElement context) {
PsiParameter psiParameter = PsiTreeUtil.getParentOfType(context, PsiParameter.class, false);
return psiParameter != null && psiParameter.getTypeElement() != null && JavaSuppressionUtil.canHave15Suppressions(psiParameter) ? psiParameter : null;
}