本文整理汇总了Java中com.intellij.psi.util.PsiUtil.isLanguageLevel8OrHigher方法的典型用法代码示例。如果您正苦于以下问题:Java PsiUtil.isLanguageLevel8OrHigher方法的具体用法?Java PsiUtil.isLanguageLevel8OrHigher怎么用?Java PsiUtil.isLanguageLevel8OrHigher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.PsiUtil
的用法示例。
在下文中一共展示了PsiUtil.isLanguageLevel8OrHigher方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMethod
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
public void addMethod(@NotNull PsiMethod method, final PsiSubstitutor substitutor, boolean staticProblem) {
final boolean isAccessible = JavaResolveUtil.isAccessible(method, getContainingClass(method), method.getModifierList(),
myPlace, myAccessClass, myCurrentFileContext, myPlaceFile) &&
!isShadowed(method);
if (isAccepted(method) && !(isInterfaceStaticMethodAccessibleThroughInheritance(method) && ImportsUtil.hasStaticImportOn(myPlace, method, true))) {
if (!staticProblem && myAccessClass != null && method.hasModifierProperty(PsiModifier.STATIC)) {
final PsiClass containingClass = method.getContainingClass();
if (containingClass != null &&
containingClass.isInterface() &&
!(myAccessClass instanceof PsiTypeParameter) &&
!containingClass.equals(myAccessClass)) {
staticProblem = true;
}
}
add(createCandidateInfo(method, substitutor, staticProblem, isAccessible, false));
if (acceptVarargs() && method.isVarArgs() && PsiUtil.isLanguageLevel8OrHigher(myPlace)) {
add(createCandidateInfo(method, substitutor, staticProblem, isAccessible, true));
}
myHasAccessibleStaticCorrectCandidate |= isAccessible && !staticProblem;
}
}
示例2: addClassKeywords
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static void addClassKeywords(Consumer<LookupElement> result, PsiElement position, @Nullable PsiElement prevLeaf) {
if (isSuitableForClass(position)) {
for (String s : ModifierChooser.getKeywords(position)) {
result.consume(new OverrideableSpace(createKeyword(position, s), TailType.HUMBLE_SPACE_BEFORE_WORD));
}
if (PsiUtil.isLanguageLevel8OrHigher(position)) {
PsiClass containingClass = PsiTreeUtil.getParentOfType(position, PsiClass.class);
if (containingClass != null && containingClass.isInterface()) {
result.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.DEFAULT), TailType.HUMBLE_SPACE_BEFORE_WORD));
}
}
result.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.CLASS), TailType.HUMBLE_SPACE_BEFORE_WORD));
if (PsiTreeUtil.getParentOfType(position, PsiCodeBlock.class, true, PsiMember.class) == null) {
result.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.INTERFACE), TailType.HUMBLE_SPACE_BEFORE_WORD));
if (PsiUtil.isLanguageLevel5OrHigher(position)) {
result.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.ENUM), TailType.INSERT_SPACE));
}
}
}
if (psiElement().withText("@").andNot(psiElement().inside(PsiParameterList.class)).andNot(psiElement().inside(psiNameValuePair()))
.accepts(prevLeaf)) {
result.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.INTERFACE), TailType.HUMBLE_SPACE_BEFORE_WORD));
}
}
示例3: getTargetClasses
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
@NotNull
protected List<PsiClass> getTargetClasses(PsiElement element) {
List<PsiClass> targets = super.getTargetClasses(element);
ArrayList<PsiClass> result = new ArrayList<PsiClass>();
PsiMethodCallExpression call = getMethodCall();
if (call == null) return Collections.emptyList();
for (PsiClass target : targets) {
if (shouldCreateStaticMember(call.getMethodExpression(), target)){
if (target.isInterface() && !PsiUtil.isLanguageLevel8OrHigher(target)) continue;
if (target.getContainingClass() != null && !target.hasModifierProperty(PsiModifier.STATIC)) continue;
}
if (!isMethodSignatureExists(call, target)) {
result.add(target);
}
}
return result;
}
示例4: isAvailable
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
final PsiParameter parameter = PsiTreeUtil.getParentOfType(element, PsiParameter.class);
if (parameter != null) {
if (!parameter.getLanguage().isKindOf(StdLanguages.JAVA)) return false;
final PsiElement declarationScope = parameter.getDeclarationScope();
if (declarationScope instanceof PsiMethod) {
final PsiMethod method = (PsiMethod)declarationScope;
final PsiClass containingClass = method.getContainingClass();
if (containingClass != null && (!containingClass.isInterface() || PsiUtil.isLanguageLevel8OrHigher(method))) {
if (containingClass.findMethodBySignature(generateMethodPrototype(method, parameter), false) != null) {
return false;
}
setText("Generate overloaded " + (method.isConstructor() ? "constructor" : "method") + " with default parameter value");
return true;
}
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:DelegateWithDefaultParamValueIntentionAction.java
示例5: isAvailable
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
if (!JavaLanguage.INSTANCE.equals(element.getLanguage())) {
return false;
}
final PsiElement parent = PsiTreeUtil.getParentOfType(element, PsiMethod.class, PsiCodeBlock.class);
if (!(parent instanceof PsiMethod)) {
return false;
}
final PsiMethod method = (PsiMethod)parent;
final PsiParameterList parameterList = method.getParameterList();
if (parameterList.getParametersCount() == 0) {
return false;
}
final PsiClass containingClass = method.getContainingClass();
if (containingClass == null || (containingClass.isInterface() && !PsiUtil.isLanguageLevel8OrHigher(method))) {
return false;
}
setText("Generate overloaded " + (method.isConstructor() ? "constructor" : "method") + " with default parameter values");
return true;
}
示例6: invoke
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static void invoke(final PsiMethod method, final Project project, @Nullable final Editor editor) {
PsiMethod newMethod = SuperMethodWarningUtil.checkSuperMethod(method, RefactoringBundle.message("to.refactor"));
if (newMethod == null) return;
if (!newMethod.equals(method)) {
ChangeSignatureUtil.invokeChangeSignatureOn(newMethod, project);
return;
}
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, method)) return;
final PsiClass containingClass = method.getContainingClass();
final PsiReferenceExpression refExpr = editor != null ? JavaTargetElementEvaluator.findReferenceExpression(editor) : null;
final boolean allowDelegation = containingClass != null && (!containingClass.isInterface() || PsiUtil.isLanguageLevel8OrHigher(containingClass));
final DialogWrapper dialog = new JavaChangeSignatureDialog(project, method, allowDelegation, refExpr == null ? method : refExpr);
dialog.show();
}
示例7: isMemberEnabled
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public boolean isMemberEnabled(MemberInfo member) {
final PsiClass currentSuperClass = getSuperClass();
if(currentSuperClass == null) return true;
if (myMemberInfoStorage.getDuplicatedMemberInfos(currentSuperClass).contains(member)) return false;
if (myMemberInfoStorage.getExtending(currentSuperClass).contains(member.getMember())) return false;
final boolean isInterface = currentSuperClass.isInterface();
if (!isInterface) return true;
PsiElement element = member.getMember();
if (element instanceof PsiClass && ((PsiClass) element).isInterface()) return true;
if (element instanceof PsiField) {
return ((PsiModifierListOwner) element).hasModifierProperty(PsiModifier.STATIC);
}
if (element instanceof PsiMethod) {
final PsiSubstitutor superSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(currentSuperClass, myClass, PsiSubstitutor.EMPTY);
final MethodSignature signature = ((PsiMethod) element).getSignature(superSubstitutor);
final PsiMethod superClassMethod = MethodSignatureUtil.findMethodBySignature(currentSuperClass, signature, false);
if (superClassMethod != null && !PsiUtil.isLanguageLevel8OrHigher(currentSuperClass)) return false;
return !((PsiModifierListOwner) element).hasModifierProperty(PsiModifier.STATIC) || PsiUtil.isLanguageLevel8OrHigher(currentSuperClass);
}
return true;
}
示例8: visitTypeElement
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public void visitTypeElement(PsiTypeElement typeElement) {
super.visitTypeElement(typeElement);
final PsiType type = typeElement.getType();
if (!(type instanceof PsiWildcardType)) {
return;
}
final PsiWildcardType wildcardType = (PsiWildcardType)type;
final PsiType extendsBound = wildcardType.getExtendsBound();
if (!(extendsBound instanceof PsiClassType)) {
return;
}
final PsiClassType classType = (PsiClassType)extendsBound;
final PsiClass aClass = classType.resolve();
if (aClass == null || !aClass.hasModifierProperty(PsiModifier.FINAL)) {
return;
}
if (aClass.hasTypeParameters() && !PsiUtil.isLanguageLevel8OrHigher(typeElement)) {
final PsiType[] parameters = classType.getParameters();
if (parameters.length == 0) {
return;
}
for (PsiType parameter : parameters) {
if (parameter instanceof PsiWildcardType) {
return;
}
}
}
if (!shouldReport(typeElement)) {
return;
}
registerError(typeElement.getFirstChild(), aClass, Integer.valueOf(2));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:TypeParameterExtendsFinalClassInspection.java
示例9: allMethodsPublicAbstract
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private boolean allMethodsPublicAbstract(PsiClass aClass) {
final PsiMethod[] methods = aClass.getMethods();
for (final PsiMethod method : methods) {
if (!method.hasModifierProperty(PsiModifier.ABSTRACT) &&
(!reportClassesWithNonAbstractMethods || !PsiUtil.isLanguageLevel8OrHigher(aClass))) {
return false;
}
else if (!method.hasModifierProperty(PsiModifier.PUBLIC) || method.hasModifierProperty(PsiModifier.FINAL)) {
return false;
}
}
return true;
}
示例10: getMemberUseScope
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@NotNull
public static SearchScope getMemberUseScope(@NotNull PsiMember member) {
PsiFile file = member.getContainingFile();
PsiElement topElement = file == null ? member : file;
Project project = topElement.getProject();
final GlobalSearchScope maximalUseScope = ResolveScopeManager.getInstance(project).getUseScope(topElement);
if (isInServerPage(file)) return maximalUseScope;
PsiClass aClass = member.getContainingClass();
if (aClass instanceof PsiAnonymousClass) {
//member from anonymous class can be called from outside the class
PsiElement methodCallExpr = PsiUtil.isLanguageLevel8OrHigher(aClass) ? PsiTreeUtil.getTopmostParentOfType(aClass, PsiStatement.class)
: PsiTreeUtil.getParentOfType(aClass, PsiMethodCallExpression.class);
return new LocalSearchScope(methodCallExpr != null ? methodCallExpr : aClass);
}
PsiModifierList modifierList = member.getModifierList();
int accessLevel = modifierList == null ? PsiUtil.ACCESS_LEVEL_PUBLIC : PsiUtil.getAccessLevel(modifierList);
if (accessLevel == PsiUtil.ACCESS_LEVEL_PUBLIC || accessLevel == PsiUtil.ACCESS_LEVEL_PROTECTED) {
return maximalUseScope; // class use scope doesn't matter, since another very visible class can inherit from aClass
}
if (accessLevel == PsiUtil.ACCESS_LEVEL_PRIVATE) {
PsiClass topClass = PsiUtil.getTopLevelClass(member);
return topClass != null ? new LocalSearchScope(topClass) : file == null ? maximalUseScope : new LocalSearchScope(file);
}
if (file instanceof PsiJavaFile) {
PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(((PsiJavaFile)file).getPackageName());
if (aPackage != null) {
SearchScope scope = PackageScope.packageScope(aPackage, false);
return scope.intersectWith(maximalUseScope);
}
}
return maximalUseScope;
}
示例11: isAvailable
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
final PsiMethod psiMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class, false);
if (psiMethod != null && PsiUtil.isLanguageLevel8OrHigher(psiMethod)) {
if (psiMethod.getBody() == null && !psiMethod.hasModifierProperty(PsiModifier.DEFAULT)) {
final PsiClass containingClass = psiMethod.getContainingClass();
return containingClass != null && containingClass.isInterface();
}
}
return false;
}
示例12: areInferredTypesApplicable
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static boolean areInferredTypesApplicable(@NotNull PsiType[] types, PsiElement position) {
final PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(position, PsiMethodCallExpression.class);
if (methodCallExpression != null) {
if (PsiUtil.isLanguageLevel8OrHigher(methodCallExpression)) {
final PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(position, PsiNewExpression.class, false);
if (newExpression != null) {
PsiElement parent = newExpression;
while (parent.getParent() instanceof PsiParenthesizedExpression) {
parent = parent.getParent();
}
final int idx = ArrayUtil.find(methodCallExpression.getArgumentList().getExpressions(), parent);
if (idx > -1) {
final JavaResolveResult resolveResult = methodCallExpression.resolveMethodGenerics();
final PsiMethod method = (PsiMethod)resolveResult.getElement();
if (method != null) {
final PsiParameter[] parameters = method.getParameterList().getParameters();
if (idx < parameters.length) {
final PsiType expectedType = resolveResult.getSubstitutor().substitute(parameters[idx].getType());
final PsiClass aClass = PsiUtil.resolveClassInType(expectedType);
if (aClass != null) {
final PsiClassType inferredArg = JavaPsiFacade.getElementFactory(method.getProject()).createType(aClass, types);
LOG.assertTrue(expectedType != null);
return TypeConversionUtil.isAssignable(expectedType, inferredArg);
}
}
}
}
}
}
return false;
}
return true;
}
示例13: makeFinalIfNeeded
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
public static void makeFinalIfNeeded(@NotNull InsertionContext context, @NotNull PsiVariable variable) {
PsiElement place = context.getFile().findElementAt(context.getTailOffset() - 1);
if (!Registry.is("java.completion.make.outer.variables.final") ||
place == null || PsiUtil.isLanguageLevel8OrHigher(place) || JspPsiUtil.isInJspFile(place)) {
return;
}
if (HighlightControlFlowUtil.getInnerClassVariableReferencedFrom(variable, place) != null &&
!HighlightControlFlowUtil.isReassigned(variable, new HashMap<PsiElement, Collection<ControlFlowUtil.VariableInfo>>())) {
PsiUtil.setModifierProperty(variable, PsiModifier.FINAL, true);
}
}
示例14: isAvailable
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
final PsiModifierListOwner owner = AddAnnotationPsiFix.getContainer(file, editor.getCaretModel().getOffset());
if (owner == null ||
owner.getManager().isInProject(owner) && !CodeStyleSettingsManager.getSettings(project).USE_EXTERNAL_ANNOTATIONS) {
return false;
}
Pair<String, String[]> annotations = getAnnotations(project);
String toAdd = annotations.first;
String[] toRemove = annotations.second;
if (toRemove.length > 0 && isAnnotatedSkipInferred(owner, toRemove)) {
return false;
}
setText(AddAnnotationPsiFix.calcText(owner, toAdd));
if (isAnnotatedSkipInferred(owner, toAdd)) return false;
if (owner instanceof PsiMethod) {
PsiType returnType = ((PsiMethod)owner).getReturnType();
return returnType != null && !(returnType instanceof PsiPrimitiveType);
}
if (owner instanceof PsiClass) {
return PsiUtil.isLanguageLevel8OrHigher(owner);
}
return true;
}
示例15: isMemberEnabled
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public boolean isMemberEnabled(MemberInfo member) {
if(myTargetClass != null && myTargetClass.isInterface() && !PsiUtil.isLanguageLevel8OrHigher(myTargetClass)) {
return !(member.getMember() instanceof PsiMethod);
}
return super.isMemberEnabled(member);
}