mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
codeInsight-openapi
This commit is contained in:
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
* Copyright 2000-2007 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class AnnotationUtil {
|
||||
/**
|
||||
* The full qualified name of the standard Nullable annotation.
|
||||
*/
|
||||
public static final String NULLABLE = "org.jetbrains.annotations.Nullable";
|
||||
|
||||
/**
|
||||
* The full qualified name of the standard NotNull annotation.
|
||||
*/
|
||||
public static final String NOT_NULL = "org.jetbrains.annotations.NotNull";
|
||||
|
||||
@NonNls public static final String NOT_NULL_SIMPLE_NAME = "NotNull";
|
||||
|
||||
@NonNls public static final String NULLABLE_SIMPLE_NAME = "Nullable";
|
||||
|
||||
/**
|
||||
* The full qualified name of the standard NonNls annotation.
|
||||
*
|
||||
* @since 5.0.1
|
||||
*/
|
||||
public static final String NON_NLS = "org.jetbrains.annotations.NonNls";
|
||||
public static final String NLS = "org.jetbrains.annotations.Nls";
|
||||
public static final String PROPERTY_KEY = "org.jetbrains.annotations.PropertyKey";
|
||||
@NonNls public static final String PROPERTY_KEY_RESOURCE_BUNDLE_PARAMETER = "resourceBundle";
|
||||
|
||||
@NonNls public static final String NON_NLS_SIMPLE_NAME = "NonNls";
|
||||
@NonNls public static final String PROPERTY_KEY_SIMPLE_NAME = "PropertyKey";
|
||||
|
||||
public static final String TEST_ONLY = "org.jetbrains.annotations.TestOnly";
|
||||
@NonNls public static final String TEST_ONLY_SIMPLE_NAME = "TestOnly";
|
||||
|
||||
public static final Set<String> ALL_ANNOTATIONS;
|
||||
|
||||
@NonNls private static final String[] SIMPLE_NAMES =
|
||||
{NOT_NULL_SIMPLE_NAME, NULLABLE_SIMPLE_NAME, NON_NLS_SIMPLE_NAME, PROPERTY_KEY_SIMPLE_NAME, TEST_ONLY_SIMPLE_NAME,
|
||||
"Language", "Identifier", "Pattern", "PrintFormat", "RegExp", "Subst"};
|
||||
public static final String TARGET_ANNOTATION_FQ_NAME = "java.lang.annotation.Target";
|
||||
|
||||
static {
|
||||
ALL_ANNOTATIONS = new HashSet<String>(2);
|
||||
ALL_ANNOTATIONS.add(NULLABLE);
|
||||
ALL_ANNOTATIONS.add(NOT_NULL);
|
||||
}
|
||||
|
||||
public static boolean isNullable(@NotNull PsiModifierListOwner owner) {
|
||||
return !isNotNull(owner) && isAnnotated(owner, NULLABLE, true);
|
||||
}
|
||||
|
||||
public static boolean isNotNull(@NotNull PsiModifierListOwner owner) {
|
||||
return isAnnotated(owner, NOT_NULL, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiAnnotation findAnnotation(PsiModifierListOwner listOwner, @NotNull String... annotationNames) {
|
||||
return findAnnotation(listOwner, false, annotationNames);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiAnnotation findAnnotation(PsiModifierListOwner listOwner, final boolean skipExternal, @NotNull String... annotationNames) {
|
||||
if (annotationNames.length == 0) return null;
|
||||
Set<String> set = annotationNames.length == 1 ? Collections.singleton(annotationNames[0]) : new HashSet<String>(Arrays.asList(annotationNames));
|
||||
return findAnnotation(listOwner, set, skipExternal);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiAnnotation findAnnotation(PsiModifierListOwner listOwner, @NotNull Set<String> annotationNames) {
|
||||
return findAnnotation(listOwner, (Collection<String>)annotationNames);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiAnnotation findAnnotation(@Nullable PsiModifierListOwner listOwner, Collection<String> annotationNames) {
|
||||
return findAnnotation(listOwner, annotationNames, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiAnnotation findAnnotation(@Nullable PsiModifierListOwner listOwner, Collection<String> annotationNames,
|
||||
final boolean skipExternal) {
|
||||
if (listOwner == null) return null;
|
||||
final PsiModifierList list = listOwner.getModifierList();
|
||||
if (list == null) return null;
|
||||
final PsiAnnotation[] allAnnotations = list.getAnnotations();
|
||||
for (PsiAnnotation annotation : allAnnotations) {
|
||||
String qualifiedName = annotation.getQualifiedName();
|
||||
if (annotationNames.contains(qualifiedName)) {
|
||||
return annotation;
|
||||
}
|
||||
}
|
||||
if (!skipExternal) {
|
||||
final ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(listOwner.getProject());
|
||||
for (String annotationName : annotationNames) {
|
||||
final PsiAnnotation annotation = annotationsManager.findExternalAnnotation(listOwner, annotationName);
|
||||
if (annotation != null) {
|
||||
return annotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PsiAnnotation[] findAnnotations(final PsiMember psiMember, @NotNull Collection<String> annotationNames) {
|
||||
if (psiMember == null) return PsiAnnotation.EMPTY_ARRAY;
|
||||
final PsiModifierList modifierList = psiMember.getModifierList();
|
||||
if (modifierList == null) return PsiAnnotation.EMPTY_ARRAY;
|
||||
final PsiAnnotation[] annotations = modifierList.getAnnotations();
|
||||
ArrayList<PsiAnnotation> result = null;
|
||||
for (final PsiAnnotation psiAnnotation : annotations) {
|
||||
if (annotationNames.contains(psiAnnotation.getQualifiedName())) {
|
||||
if (result == null) result = new ArrayList<PsiAnnotation>();
|
||||
result.add(psiAnnotation);
|
||||
}
|
||||
}
|
||||
return result == null ? PsiAnnotation.EMPTY_ARRAY : result.toArray(new PsiAnnotation[result.size()]);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiAnnotation findAnnotationInHierarchy(PsiModifierListOwner listOwner, Set<String> annotationNames) {
|
||||
PsiAnnotation directAnnotation = findAnnotation(listOwner, annotationNames);
|
||||
if (directAnnotation != null) return directAnnotation;
|
||||
|
||||
if (!(listOwner instanceof PsiMethod)) {
|
||||
return null;
|
||||
}
|
||||
PsiMethod method = (PsiMethod)listOwner;
|
||||
PsiClass aClass = method.getContainingClass();
|
||||
if (aClass == null) return null;
|
||||
HierarchicalMethodSignature methodSignature = method.getHierarchicalMethodSignature();
|
||||
return findAnnotationInHierarchy(methodSignature, annotationNames, method);
|
||||
}
|
||||
|
||||
private static PsiAnnotation findAnnotationInHierarchy(HierarchicalMethodSignature signature,
|
||||
Set<String> annotationNames,
|
||||
PsiElement place) {
|
||||
List<HierarchicalMethodSignature> superSignatures = signature.getSuperSignatures();
|
||||
PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(place.getProject()).getResolveHelper();
|
||||
for (HierarchicalMethodSignature superSignature : superSignatures) {
|
||||
PsiMethod superMethod = superSignature.getMethod();
|
||||
if (!resolveHelper.isAccessible(superMethod, place, null)) continue;
|
||||
PsiAnnotation direct = findAnnotation(superMethod, annotationNames);
|
||||
if (direct != null) return direct;
|
||||
PsiAnnotation superResult = findAnnotationInHierarchy(superSignature, annotationNames, place);
|
||||
if (superResult != null) return superResult;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isAnnotated(PsiModifierListOwner listOwner, Collection<String> annotations) {
|
||||
for (String annotation : annotations) {
|
||||
if (isAnnotated(listOwner, annotation, false)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isAnnotated(@NotNull PsiModifierListOwner listOwner, @NonNls String annotationFQN, boolean checkHierarchy) {
|
||||
return isAnnotated(listOwner, annotationFQN, checkHierarchy, false, null);
|
||||
}
|
||||
|
||||
public static boolean isAnnotated(@NotNull PsiModifierListOwner listOwner, @NonNls String annotationFQN, boolean checkHierarchy,
|
||||
boolean skipExternal) {
|
||||
return isAnnotated(listOwner, annotationFQN, checkHierarchy, skipExternal, null);
|
||||
}
|
||||
|
||||
private static boolean isAnnotated(@NotNull PsiModifierListOwner listOwner,
|
||||
@NonNls String annotationFQN,
|
||||
boolean checkHierarchy, final boolean skipExternal, Set<PsiMethod> processed) {
|
||||
if (!listOwner.isValid()) return false;
|
||||
final PsiModifierList modifierList = listOwner.getModifierList();
|
||||
if (modifierList == null) return false;
|
||||
PsiAnnotation annotation = modifierList.findAnnotation(annotationFQN);
|
||||
if (annotation != null) return true;
|
||||
if (!skipExternal && ExternalAnnotationsManager.getInstance(listOwner.getProject()).findExternalAnnotation(listOwner, annotationFQN) != null) {
|
||||
return true;
|
||||
}
|
||||
if (checkHierarchy && listOwner instanceof PsiMethod) {
|
||||
PsiMethod method = (PsiMethod)listOwner;
|
||||
if (processed == null) processed = new THashSet<PsiMethod>();
|
||||
if (!processed.add(method)) return false;
|
||||
final PsiMethod[] superMethods = method.findSuperMethods();
|
||||
for (PsiMethod superMethod : superMethods) {
|
||||
if (isAnnotated(superMethod, annotationFQN, checkHierarchy, skipExternal, processed)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isAnnotatingApplicable(PsiElement elt) {
|
||||
return PsiUtil.isLanguageLevel5OrHigher(elt) &&
|
||||
JavaPsiFacade.getInstance(elt.getProject()).findClass(NULLABLE, elt.getResolveScope()) != null;
|
||||
}
|
||||
|
||||
public static boolean isJetbrainsAnnotation(@NonNls final String simpleName) {
|
||||
return ArrayUtil.find(SIMPLE_NAMES, simpleName) != -1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright 2000-2007 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Alexey
|
||||
*/
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ClassUtil {
|
||||
public static PsiMethod getAnyAbstractMethod(PsiClass aClass, Collection<HierarchicalMethodSignature> allMethodsCollection) {
|
||||
PsiMethod methodToImplement = getAnyMethodToImplement(aClass, allMethodsCollection);
|
||||
if (methodToImplement != null) {
|
||||
return methodToImplement;
|
||||
}
|
||||
PsiMethod[] methods = aClass.getMethods();
|
||||
for (PsiMethod method : methods) {
|
||||
if (method.hasModifierProperty(PsiModifier.ABSTRACT)) return method;
|
||||
}
|
||||
|
||||
return abstractPackageLocalMethod(aClass, allMethodsCollection);
|
||||
/*
|
||||
// the only remaining possiblity for class to have abstract method here is
|
||||
// from package local abstract method defined in inherited class from other package
|
||||
PsiManager manager = aClass.getManager();
|
||||
for (List<MethodSignatureBackedByPsiMethod> sameSignatureMethods : allMethodsCollection.values()) {
|
||||
// look for abstract package locals
|
||||
for (int i = sameSignatureMethods.size() - 1; i >= 0; i--) {
|
||||
MethodSignatureBackedByPsiMethod methodSignature1 = sameSignatureMethods.get(i);
|
||||
PsiMethod method1 = methodSignature1.getMethod();
|
||||
PsiClass class1 = method1.getContainingClass();
|
||||
if (class1 == null) {
|
||||
sameSignatureMethods.remove(i);
|
||||
continue;
|
||||
}
|
||||
if (!method1.hasModifierProperty(PsiModifier.ABSTRACT)
|
||||
|| !method1.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)
|
||||
|| manager.arePackagesTheSame(class1, aClass)) {
|
||||
continue;
|
||||
}
|
||||
// check if abstract package local method gets overriden by not abstract
|
||||
// i.e. there is direct subclass in the same package which overrides this method
|
||||
for (int j = sameSignatureMethods.size() - 1; j >= 0; j--) {
|
||||
MethodSignatureBackedByPsiMethod methodSignature2 = sameSignatureMethods.get(j);
|
||||
PsiMethod method2 = methodSignature2.getMethod();
|
||||
PsiClass class2 = method2.getContainingClass();
|
||||
if (i == j || class2 == null) continue;
|
||||
if (class2.isInheritor(class1, true)
|
||||
// NB! overriding method may be abstract
|
||||
// && !method2.hasModifierProperty(PsiModifier.ABSTRACT)
|
||||
&& manager.arePackagesTheSame(class1, class2)) {
|
||||
sameSignatureMethods.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = sameSignatureMethods.size() - 1; i >= 0; i--) {
|
||||
MethodSignatureBackedByPsiMethod methodSignature = sameSignatureMethods.get(i);
|
||||
PsiMethod method = methodSignature.getMethod();
|
||||
PsiClass class1 = method.getContainingClass();
|
||||
if (class1 == null
|
||||
|| !method.hasModifierProperty(PsiModifier.ABSTRACT)
|
||||
|| !method.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)
|
||||
|| manager.arePackagesTheSame(class1, aClass)) {
|
||||
continue;
|
||||
}
|
||||
return method;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
*/
|
||||
}
|
||||
|
||||
private static PsiMethod abstractPackageLocalMethod(PsiClass aClass, Collection<HierarchicalMethodSignature> allMethodsCollection) {
|
||||
Set<PsiMethod> allMethods = new THashSet<PsiMethod>(Arrays.asList(aClass.getAllMethods()));
|
||||
Set<PsiMethod> suspects = new THashSet<PsiMethod>();
|
||||
// check all methods collection first for sibling overrides
|
||||
for (HierarchicalMethodSignature signature : allMethodsCollection) {
|
||||
removeSupers(signature, allMethods, suspects);
|
||||
PsiMethod method = signature.getMethod();
|
||||
if (method.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
suspects.add(method);
|
||||
}
|
||||
allMethods.remove(method);
|
||||
}
|
||||
while (!allMethods.isEmpty()) {
|
||||
PsiMethod method = allMethods.iterator().next();
|
||||
removeSupers(method.getHierarchicalMethodSignature(), allMethods, suspects);
|
||||
if (method.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
suspects.add(method);
|
||||
}
|
||||
allMethods.remove(method);
|
||||
}
|
||||
return suspects.isEmpty() ? null : suspects.iterator().next();
|
||||
}
|
||||
|
||||
private static void removeSupers(@NotNull HierarchicalMethodSignature hierarchicalMethodSignature, Set<PsiMethod> allMethods, Set<PsiMethod> suspects) {
|
||||
for (HierarchicalMethodSignature superS : hierarchicalMethodSignature.getSuperSignatures()) {
|
||||
PsiMethod superMethod = superS.getMethod();
|
||||
allMethods.remove(superMethod);
|
||||
suspects.remove(superMethod);
|
||||
assert superS != hierarchicalMethodSignature;
|
||||
removeSupers(superS, allMethods, suspects);
|
||||
}
|
||||
}
|
||||
|
||||
public static PsiMethod getAnyMethodToImplement(PsiClass aClass, Collection<HierarchicalMethodSignature> allMethodsCollection) {
|
||||
for (HierarchicalMethodSignature signatureHierarchical : allMethodsCollection) {
|
||||
final PsiMethod method = signatureHierarchical.getMethod();
|
||||
PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass == null) {
|
||||
continue;
|
||||
}
|
||||
if (!aClass.equals(containingClass) &&
|
||||
method.hasModifierProperty(PsiModifier.ABSTRACT)
|
||||
&& !method.hasModifierProperty(PsiModifier.STATIC)
|
||||
&& !method.hasModifierProperty(PsiModifier.PRIVATE)) {
|
||||
return method;
|
||||
}
|
||||
else {
|
||||
final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(aClass.getProject()).getResolveHelper();
|
||||
final List<HierarchicalMethodSignature> superSignatures = signatureHierarchical.getSuperSignatures();
|
||||
for (HierarchicalMethodSignature superSignatureHierarchical : superSignatures) {
|
||||
final PsiMethod superMethod = superSignatureHierarchical.getMethod();
|
||||
if (superMethod.hasModifierProperty(PsiModifier.ABSTRACT) && !resolveHelper.isAccessible(superMethod, method, null)) return superMethod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright 2000-2007 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class CodeInsightServicesUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.CodeInsightServicesUtil");
|
||||
|
||||
private static final IElementType[] ourTokenMap = new IElementType[]{
|
||||
JavaTokenType.EQEQ, JavaTokenType.NE,
|
||||
JavaTokenType.LT, JavaTokenType.GE,
|
||||
JavaTokenType.LE, JavaTokenType.GT,
|
||||
JavaTokenType.OROR, JavaTokenType.ANDAND
|
||||
};
|
||||
|
||||
public static PsiExpression invertCondition(PsiExpression booleanExpression) throws IncorrectOperationException {
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(booleanExpression.getProject()).getElementFactory();
|
||||
|
||||
if (booleanExpression instanceof PsiBinaryExpression) {
|
||||
PsiBinaryExpression expression = (PsiBinaryExpression) booleanExpression;
|
||||
PsiJavaToken operationSign = expression.getOperationSign();
|
||||
for (int i = 0; i < ourTokenMap.length; i++) {
|
||||
IElementType tokenType = ourTokenMap[i];
|
||||
if (operationSign.getTokenType() == tokenType) {
|
||||
expression = (PsiBinaryExpression)expression.copy();
|
||||
expression.getOperationSign().replace(createOperationToken(factory, ourTokenMap[i + (i % 2 == 0 ? 1 : -1)]));
|
||||
if (tokenType == JavaTokenType.OROR || tokenType == JavaTokenType.ANDAND) {
|
||||
expression.getLOperand().replace(invertCondition(expression.getLOperand()));
|
||||
expression.getROperand().replace(invertCondition(expression.getROperand()));
|
||||
}
|
||||
return expression;
|
||||
}
|
||||
}
|
||||
} else if (booleanExpression instanceof PsiPrefixExpression) {
|
||||
PsiPrefixExpression expression = (PsiPrefixExpression) booleanExpression;
|
||||
PsiJavaToken operationSign = expression.getOperationSign();
|
||||
if (operationSign.getTokenType() == JavaTokenType.EXCL) {
|
||||
PsiExpression operand = expression.getOperand();
|
||||
if (operand instanceof PsiParenthesizedExpression) {
|
||||
operand = ((PsiParenthesizedExpression) operand).getExpression();
|
||||
}
|
||||
return operand;
|
||||
}
|
||||
} else if (booleanExpression instanceof PsiLiteralExpression) {
|
||||
return booleanExpression.getText().equals("true") ?
|
||||
factory.createExpressionFromText("false", null) :
|
||||
factory.createExpressionFromText("true", null);
|
||||
}
|
||||
|
||||
if (booleanExpression instanceof PsiParenthesizedExpression) {
|
||||
PsiExpression operand = ((PsiParenthesizedExpression) booleanExpression).getExpression();
|
||||
operand.replace(invertCondition(operand));
|
||||
return booleanExpression;
|
||||
}
|
||||
|
||||
PsiPrefixExpression result = (PsiPrefixExpression)factory.createExpressionFromText("!(a)", null);
|
||||
if (!(booleanExpression instanceof PsiBinaryExpression)) {
|
||||
result.getOperand().replace(booleanExpression);
|
||||
} else {
|
||||
PsiParenthesizedExpression e = (PsiParenthesizedExpression) result.getOperand();
|
||||
e.getExpression().replace(booleanExpression);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static PsiElement createOperationToken(PsiElementFactory factory, IElementType tokenType) throws IncorrectOperationException {
|
||||
final String s;
|
||||
if (tokenType == JavaTokenType.EQEQ) {
|
||||
s = "==";
|
||||
}
|
||||
else if (tokenType == JavaTokenType.NE) {
|
||||
s = "!=";
|
||||
}
|
||||
else if (tokenType == JavaTokenType.LT) {
|
||||
s = "<";
|
||||
}
|
||||
else if (tokenType == JavaTokenType.LE) {
|
||||
s = "<=";
|
||||
}
|
||||
else if (tokenType == JavaTokenType.GT) {
|
||||
s = ">";
|
||||
}
|
||||
else if (tokenType == JavaTokenType.GE) {
|
||||
s = ">=";
|
||||
}
|
||||
else if (tokenType == JavaTokenType.ANDAND) {
|
||||
s = "&&";
|
||||
}
|
||||
else if (tokenType == JavaTokenType.OROR) {
|
||||
s = "||";
|
||||
}
|
||||
else {
|
||||
LOG.error("Unknown token type");
|
||||
s = "==";
|
||||
}
|
||||
|
||||
PsiBinaryExpression expression = (PsiBinaryExpression) factory.createExpressionFromText("a" + s + "b", null);
|
||||
return expression.getOperationSign();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2000-2007 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* The information about a single problem found during pre-checkin code analysis.
|
||||
*
|
||||
* @since 5.1
|
||||
* @see com.intellij.openapi.vcs.CodeSmellDetector#findCodeSmells(java.util.List)
|
||||
* @see com.intellij.openapi.vcs.CodeSmellDetector#showCodeSmellErrors(java.util.List)
|
||||
*/
|
||||
public final class CodeSmellInfo {
|
||||
@NotNull private final Document myDocument;
|
||||
private final String myDescription;
|
||||
private final TextRange myTextRange;
|
||||
private final HighlightSeverity mySeverity;
|
||||
|
||||
public CodeSmellInfo(@NotNull final Document document, final String description, final TextRange textRange, final HighlightSeverity severity) {
|
||||
myDocument = document;
|
||||
myDescription = description;
|
||||
myTextRange = textRange;
|
||||
mySeverity = severity;
|
||||
}
|
||||
|
||||
@NotNull public Document getDocument() {
|
||||
return myDocument;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return myDescription;
|
||||
}
|
||||
|
||||
public TextRange getTextRange(){
|
||||
return myTextRange;
|
||||
}
|
||||
|
||||
public HighlightSeverity getSeverity(){
|
||||
return mySeverity;
|
||||
}
|
||||
|
||||
public int getStartLine() {
|
||||
return getDocument().getLineNumber(getTextRange().getStartOffset());
|
||||
}
|
||||
|
||||
public int getStartColumn() {
|
||||
return getTextRange().getStartOffset() - getDocument().getLineStartOffset(getStartLine());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2000-2007 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 26-Jun-2007
|
||||
*/
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiAnnotation;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiModifierListOwner;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class ExternalAnnotationsManager {
|
||||
@NonNls public static final String ANNOTATIONS_XML = "annotations.xml";
|
||||
|
||||
public enum AnnotationPlace {
|
||||
IN_CODE,
|
||||
EXTERNAL,
|
||||
NOWHERE
|
||||
}
|
||||
|
||||
public static ExternalAnnotationsManager getInstance(Project project) {
|
||||
return ServiceManager.getService(project, ExternalAnnotationsManager.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract PsiAnnotation findExternalAnnotation(final PsiModifierListOwner listOwner, final String annotationFQN);
|
||||
|
||||
@Nullable
|
||||
public abstract PsiAnnotation[] findExternalAnnotations(final PsiModifierListOwner listOwner);
|
||||
|
||||
public abstract void annotateExternally(final PsiModifierListOwner listOwner, final String annotationFQName, final PsiFile fromFile);
|
||||
|
||||
public abstract boolean deannotate(final PsiModifierListOwner listOwner, final String annotationFQN);
|
||||
|
||||
public abstract AnnotationPlace chooseAnnotationsPlace(final PsiElement element);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2007 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public interface MethodImplementor {
|
||||
ExtensionPointName<MethodImplementor> EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.methodImplementor");
|
||||
|
||||
@NotNull
|
||||
PsiMethod[] getMethodsToImplement(PsiClass aClass);
|
||||
|
||||
@NotNull
|
||||
PsiMethod[] createImplementationPrototypes(final PsiClass inClass, PsiMethod method) throws IncorrectOperationException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2000-2007 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 28-May-2007
|
||||
*/
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
public interface TestFramework {
|
||||
boolean isTestKlass(PsiClass psiClass);
|
||||
PsiMethod findSetUpMethod(PsiClass psiClass) throws IncorrectOperationException;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2000-2007 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 28-May-2007
|
||||
*/
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class TestUtil {
|
||||
public static final ExtensionPointName<TestFramework> TEST_FRAMEWORK = ExtensionPointName.create("com.intellij.testFramework");
|
||||
|
||||
private TestUtil() {}
|
||||
|
||||
public static boolean isTestClass(final PsiClass psiClass) {
|
||||
final TestFramework[] testFrameworks = Extensions.getExtensions(TEST_FRAMEWORK);
|
||||
for (TestFramework framework : testFrameworks) {
|
||||
if (framework.isTestKlass(psiClass)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiMethod findSetUpMethod(final PsiClass psiClass) {
|
||||
final TestFramework[] testFrameworks = Extensions.getExtensions(TEST_FRAMEWORK);
|
||||
for (TestFramework framework : testFrameworks) {
|
||||
if (framework.isTestKlass(psiClass)) {
|
||||
try {
|
||||
final PsiMethod setUpMethod = framework.findSetUpMethod(psiClass);
|
||||
if (setUpMethod != null) {
|
||||
return setUpMethod;
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
//skip
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
package com.intellij.codeInsight.completion.util;
|
||||
|
||||
import com.intellij.codeInsight.completion.InsertionContext;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class MethodParenthesesHandler extends ParenthesesInsertHandler<LookupElement> {
|
||||
private final PsiMethod myMethod;
|
||||
private final boolean myOverloadsMatter;
|
||||
|
||||
public MethodParenthesesHandler(final PsiMethod method, boolean overloadsMatter) {
|
||||
myMethod = method;
|
||||
myOverloadsMatter = overloadsMatter;
|
||||
}
|
||||
|
||||
public MethodParenthesesHandler(final PsiMethod method,
|
||||
final boolean overloadsMatter,
|
||||
final boolean spaceBeforeParentheses, final boolean spaceBetweenParentheses,
|
||||
final boolean insertRightParenthesis) {
|
||||
super(spaceBeforeParentheses, spaceBetweenParentheses, insertRightParenthesis);
|
||||
myMethod = method;
|
||||
myOverloadsMatter = overloadsMatter;
|
||||
}
|
||||
|
||||
protected boolean placeCaretInsideParentheses(final InsertionContext context, final LookupElement item) {
|
||||
return hasParams(item, context.getElements(), myOverloadsMatter, myMethod);
|
||||
}
|
||||
|
||||
public static boolean hasParams(LookupElement item, LookupElement[] allItems, final boolean overloadsMatter, final PsiMethod method) {
|
||||
boolean hasParams = method.getParameterList().getParametersCount() > 0;
|
||||
if (overloadsMatter){
|
||||
hasParams |= hasOverloads(item, allItems, method);
|
||||
}
|
||||
return hasParams;
|
||||
}
|
||||
|
||||
private static boolean hasOverloads(LookupElement item, LookupElement[] allItems, final PsiMethod method) {
|
||||
String name = method.getName();
|
||||
for (LookupElement item1 : allItems) {
|
||||
final Object o = item1.getObject();
|
||||
if (item.getObject() != o && o instanceof PsiMethod && ((PsiMethod)o).getName().equals(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiElement findNextToken(final InsertionContext context) {
|
||||
PsiElement element = context.getFile().findElementAt(context.getTailOffset());
|
||||
if (element instanceof PsiWhiteSpace &&
|
||||
element.getText().contains("\n") &&
|
||||
!CodeStyleSettingsManager.getSettings(context.getProject()).METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return super.findNextToken(context);
|
||||
}
|
||||
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
package com.intellij.codeInsight.completion.util;
|
||||
|
||||
import com.intellij.codeInsight.completion.InsertionContext;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementPresentation;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class SimpleMethodCallLookupElement extends LookupElement {
|
||||
private final PsiMethod myMethod;
|
||||
|
||||
public SimpleMethodCallLookupElement(final PsiMethod method) {
|
||||
myMethod = method;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getLookupString() {
|
||||
return myMethod.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInsert(InsertionContext context) {
|
||||
new MethodParenthesesHandler(myMethod, true).handleInsert(context, this);
|
||||
}
|
||||
|
||||
public PsiMethod getMethod() {
|
||||
return myMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderElement(LookupElementPresentation presentation) {
|
||||
presentation.setIcon(myMethod.getIcon(Iconable.ICON_FLAG_VISIBILITY));
|
||||
presentation.setItemText(myMethod.getName());
|
||||
presentation.setTailText(PsiFormatUtil.formatMethod(myMethod,
|
||||
PsiSubstitutor.EMPTY,
|
||||
PsiFormatUtil.SHOW_PARAMETERS,
|
||||
PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE));
|
||||
final PsiType returnType = myMethod.getReturnType();
|
||||
if (returnType != null) {
|
||||
presentation.setTypeText(returnType.getCanonicalText());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright 2000-2007 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon;
|
||||
|
||||
import com.intellij.codeInspection.InspectionsBundle;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: Jun 22, 2005
|
||||
*/
|
||||
public interface GroupNames {
|
||||
String ABSTRACTION_GROUP_NAME = InspectionsBundle.message("group.names.abstraction.issues");
|
||||
String ASSIGNMENT_GROUP_NAME = InspectionsBundle.message("group.names.assignment.issues");
|
||||
String BUGS_GROUP_NAME = InspectionsBundle.message("group.names.probable.bugs");
|
||||
String BITWISE_GROUP_NAME = InspectionsBundle.message("group.names.bitwise.operation.issues");
|
||||
String CLASSLAYOUT_GROUP_NAME = InspectionsBundle.message("group.names.class.structure");
|
||||
String CLASSMETRICS_GROUP_NAME = InspectionsBundle.message("group.names.class.metrics");
|
||||
String CONFUSING_GROUP_NAME = InspectionsBundle.message("group.names.potentially.confusing.code.constructs");
|
||||
String ENCAPSULATION_GROUP_NAME = InspectionsBundle.message("group.names.encapsulation.issues");
|
||||
String ERRORHANDLING_GROUP_NAME = InspectionsBundle.message("group.names.error.handling");
|
||||
String FINALIZATION_GROUP_NAME = InspectionsBundle.message("group.names.finalization.issues");
|
||||
String IMPORTS_GROUP_NAME = InspectionsBundle.message("group.names.imports");
|
||||
String INITIALIZATION_GROUP_NAME = InspectionsBundle.message("group.names.initialization.issues");
|
||||
String INTERNATIONALIZATION_GROUP_NAME = InspectionsBundle.message("group.names.internationalization.issues");
|
||||
String JUNIT_GROUP_NAME = InspectionsBundle.message("group.names.junit.issues");
|
||||
String LOGGING_GROUP_NAME = InspectionsBundle.message("group.names.logging.issues");
|
||||
String MATURITY_GROUP_NAME = InspectionsBundle.message("group.names.code.maturity.issues");
|
||||
String METHODMETRICS_GROUP_NAME = InspectionsBundle.message("group.names.method.metrics");
|
||||
String NAMING_CONVENTIONS_GROUP_NAME = InspectionsBundle.message("group.names.naming.conventions");
|
||||
String PERFORMANCE_GROUP_NAME = InspectionsBundle.message("group.names.performance.issues");
|
||||
String MEMORY_GROUP_NAME = InspectionsBundle.message("group.names.memory.issues");
|
||||
String JDK_GROUP_NAME = InspectionsBundle.message("group.names.java.language.level.issues");
|
||||
String PORTABILITY_GROUP_NAME = InspectionsBundle.message("group.names.portability.issues");
|
||||
String SECURITY_GROUP_NAME = InspectionsBundle.message("group.names.security.issues");
|
||||
String SERIALIZATION_GROUP_NAME = InspectionsBundle.message("group.names.serialization.issues");
|
||||
String STYLE_GROUP_NAME = InspectionsBundle.message("group.names.code.style.issues");
|
||||
String THREADING_GROUP_NAME = InspectionsBundle.message("group.names.threading.issues");
|
||||
String VERBOSE_GROUP_NAME = InspectionsBundle.message("group.names.verbose.or.redundant.code.constructs");
|
||||
String VISIBILITY_GROUP_NAME = InspectionsBundle.message("group.names.visibility.issues");
|
||||
String CLONEABLE_GROUP_NAME = InspectionsBundle.message("group.names.cloning.issues");
|
||||
String RESOURCE_GROUP_NAME = InspectionsBundle.message("group.names.resource.management.issues");
|
||||
String J2ME_GROUP_NAME = InspectionsBundle.message("group.names.j2me.issues");
|
||||
String CONTROL_FLOW_GROUP_NAME = InspectionsBundle.message("group.names.control.flow.issues");
|
||||
String NUMERIC_GROUP_NAME = InspectionsBundle.message("group.names.numeric.issues");
|
||||
String JDK15_SPECIFIC_GROUP_NAME = InspectionsBundle.message("group.names.j2sdk5.0.specific.issues.and.migration.aids");
|
||||
String JAVABEANS_GROUP_NAME = InspectionsBundle.message("group.names.javabeans.issues");
|
||||
String INHERITANCE_GROUP_NAME = InspectionsBundle.message("group.names.inheritance.issues");
|
||||
String DATA_FLOW_ISSUES = InspectionsBundle.message("group.names.data.flow.issues");
|
||||
String DECLARATION_REDUNDANCY = InspectionsBundle.message("group.names.declaration.redundancy");
|
||||
|
||||
String PACKAGING_GROUP_NAME = InspectionsBundle.message("group.names.packaging.issues");
|
||||
String DEPENDENCY_GROUP_NAME = InspectionsBundle.message("group.names.dependency.issues");
|
||||
String MODULARIZATION_GROUP_NAME = InspectionsBundle.message("group.names.modularization.issues");
|
||||
|
||||
String JAVAEE_GROUP_NAME = InspectionsBundle.message("group.names.javaee.issues");
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.codeInsight.folding;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
|
||||
public abstract class JavaCodeFoldingSettings {
|
||||
|
||||
public static JavaCodeFoldingSettings getInstance() {
|
||||
return ServiceManager.getService(JavaCodeFoldingSettings.class);
|
||||
}
|
||||
|
||||
public abstract boolean isCollapseImports();
|
||||
public abstract void setCollapseImports(boolean value);
|
||||
|
||||
public abstract boolean isCollapseLambdas();
|
||||
public abstract void setCollapseLambdas(boolean value);
|
||||
|
||||
public abstract boolean isCollapseMethods();
|
||||
public abstract void setCollapseMethods(boolean value);
|
||||
|
||||
public abstract boolean isCollapseConstructorGenericParameters();
|
||||
public abstract void setCollapseConstructorGenericParameters(boolean value);
|
||||
|
||||
public abstract boolean isCollapseAccessors();
|
||||
public abstract void setCollapseAccessors(boolean value);
|
||||
|
||||
public abstract boolean isCollapseInnerClasses();
|
||||
public abstract void setCollapseInnerClasses(boolean value);
|
||||
|
||||
public abstract boolean isCollapseJavadocs();
|
||||
public abstract void setCollapseJavadocs(boolean value);
|
||||
|
||||
public abstract boolean isCollapseFileHeader();
|
||||
public abstract void setCollapseFileHeader(boolean value);
|
||||
|
||||
public abstract boolean isCollapseAnonymousClasses();
|
||||
public abstract void setCollapseAnonymousClasses(boolean value);
|
||||
|
||||
public abstract boolean isCollapseAnnotations();
|
||||
public abstract void setCollapseAnnotations(boolean value);
|
||||
|
||||
public abstract boolean isCollapseI18nMessages();
|
||||
public abstract void setCollapseI18nMessages(boolean value);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2000-2007 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.codeInsight.generation.actions;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightActionHandler;
|
||||
import com.intellij.codeInsight.actions.CodeInsightAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.jsp.jspJava.JspClass;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BaseGenerateAction extends CodeInsightAction {
|
||||
private final CodeInsightActionHandler myHandler;
|
||||
|
||||
public BaseGenerateAction(CodeInsightActionHandler handler) {
|
||||
myHandler = handler;
|
||||
}
|
||||
|
||||
protected final CodeInsightActionHandler getHandler() {
|
||||
return myHandler;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected PsiClass getTargetClass (Editor editor, PsiFile file) {
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
PsiElement element = file.findElementAt(offset);
|
||||
if (element == null) return null;
|
||||
final PsiClass target = PsiTreeUtil.getParentOfType(element, PsiClass.class);
|
||||
return target instanceof JspClass ? null : target;
|
||||
}
|
||||
|
||||
protected boolean isValidForFile(Project project, Editor editor, PsiFile file) {
|
||||
if (!(file instanceof PsiJavaFile)) return false;
|
||||
if (file instanceof PsiCompiledElement) return false;
|
||||
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
PsiClass targetClass = getTargetClass(editor, file);
|
||||
if (targetClass == null) return false;
|
||||
if (!isValidForClass(targetClass)) return false; //?
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean isValidForClass(final PsiClass targetClass) {
|
||||
return !targetClass.isInterface();
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
|
||||
/*
|
||||
* Copyright 2000-2007 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.codeInsight.generation.surroundWith;
|
||||
|
||||
import com.intellij.lang.surroundWith.Surrounder;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class JavaExpressionSurrounder implements Surrounder {
|
||||
public static ExtensionPointName<JavaExpressionSurrounder> EP_NAME = ExtensionPointName.create("com.intellij.javaExpressionSurrounder");
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.generation.surroundWith.SurroundExpressionHandler");
|
||||
|
||||
public boolean isApplicable(@NotNull PsiElement[] elements) {
|
||||
LOG.assertTrue(elements.length == 1 && elements[0] instanceof PsiExpression);
|
||||
return isApplicable((PsiExpression)elements[0]);
|
||||
}
|
||||
|
||||
public abstract boolean isApplicable(PsiExpression expr);
|
||||
|
||||
public TextRange surroundElements(@NotNull Project project,
|
||||
@NotNull Editor editor,
|
||||
@NotNull PsiElement[] elements) throws IncorrectOperationException {
|
||||
return surroundExpression(project, editor, (PsiExpression)elements[0]);
|
||||
}
|
||||
|
||||
public abstract TextRange surroundExpression(Project project, Editor editor, PsiExpression expr) throws IncorrectOperationException;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<!--
|
||||
~ Copyright 2000-2007 JetBrains s.r.o.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html><body bgcolor="white">
|
||||
Provides interfaces for highlighting regions of text in the IDEA editor.
|
||||
</body></html>
|
||||
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright 2000-2007 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.codeInsight.intention;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.ExternalAnnotationsManager;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.lang.findUsages.FindUsagesProvider;
|
||||
import com.intellij.lang.findUsages.LanguageFindUsages;
|
||||
import com.intellij.openapi.command.undo.UndoUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class AddAnnotationFix extends PsiElementBaseIntentionAction implements LocalQuickFix {
|
||||
private final String myAnnotation;
|
||||
private final PsiModifierListOwner myModifierListOwner;
|
||||
private final String[] myAnnotationsToRemove;
|
||||
private static final Logger LOG = Logger.getInstance("#" + AddAnnotationFix.class.getName());
|
||||
|
||||
public AddAnnotationFix(String fqn, PsiModifierListOwner modifierListOwner, String... annotationsToRemove) {
|
||||
myAnnotation = fqn;
|
||||
myModifierListOwner = modifierListOwner;
|
||||
myAnnotationsToRemove = annotationsToRemove;
|
||||
}
|
||||
|
||||
public AddAnnotationFix(@NonNls final String fqn, @NonNls String... annotationsToRemove) {
|
||||
this(fqn, null,annotationsToRemove);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getText() {
|
||||
final String shortName = myAnnotation.substring(myAnnotation.lastIndexOf('.') + 1);
|
||||
if (myModifierListOwner instanceof PsiNamedElement) {
|
||||
final String name = ((PsiNamedElement)myModifierListOwner).getName();
|
||||
if (name != null) {
|
||||
FindUsagesProvider provider = LanguageFindUsages.INSTANCE.forLanguage(myModifierListOwner.getLanguage());
|
||||
return CodeInsightBundle.message("inspection.i18n.quickfix.annotate.element.as", provider.getType(myModifierListOwner), name, shortName);
|
||||
}
|
||||
}
|
||||
return myModifierListOwner != null ?
|
||||
CodeInsightBundle.message("inspection.i18n.quickfix.annotate.as", shortName) :
|
||||
CodeInsightBundle.message("add.external.annotation.test", shortName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return getText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return CodeInsightBundle.message("intention.add.annotation.family");
|
||||
}
|
||||
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
try {
|
||||
invoke(project, null, descriptor.getPsiElement().getContainingFile());
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static PsiModifierListOwner getContainer(final PsiElement element) {
|
||||
PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(element, PsiParameter.class, false);
|
||||
if (listOwner == null) {
|
||||
final PsiIdentifier psiIdentifier = PsiTreeUtil.getParentOfType(element, PsiIdentifier.class, false);
|
||||
if (psiIdentifier != null && psiIdentifier.getParent() instanceof PsiModifierListOwner) {
|
||||
listOwner = (PsiModifierListOwner)psiIdentifier.getParent();
|
||||
}
|
||||
}
|
||||
return listOwner;
|
||||
}
|
||||
|
||||
public boolean isAvailable(@NotNull final Project project, final Editor editor, @Nullable final PsiElement element) {
|
||||
if (element == null || !element.isValid()) return false;
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(element)) return false;
|
||||
final PsiModifierListOwner owner;
|
||||
if (myModifierListOwner != null) {
|
||||
if (!myModifierListOwner.isValid()) return false;
|
||||
//if (!PsiManager.getInstance(project).isInProject(myModifierListOwner)
|
||||
// || myModifierListOwner.getModifierList() == null) {
|
||||
// if (!myModifierListOwner.isPhysical()) { //we might want to apply fix to just created method
|
||||
// return true;
|
||||
// }
|
||||
//}
|
||||
|
||||
owner = myModifierListOwner;
|
||||
}
|
||||
else if (!element.getManager().isInProject(element) || CodeStyleSettingsManager.getSettings(project).USE_EXTERNAL_ANNOTATIONS) {
|
||||
owner = getContainer(element);
|
||||
}
|
||||
else {
|
||||
owner = null;
|
||||
}
|
||||
return owner != null && !AnnotationUtil.isAnnotated(owner, myAnnotation, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) {
|
||||
final PsiElement element;
|
||||
if (myModifierListOwner != null) {
|
||||
element = myModifierListOwner;
|
||||
}
|
||||
else {
|
||||
final CaretModel caretModel = editor.getCaretModel();
|
||||
final int position = caretModel.getOffset();
|
||||
element = file.findElementAt(position);
|
||||
}
|
||||
return isAvailable(project, editor, element);
|
||||
}
|
||||
|
||||
public void invoke(@NotNull final Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
final ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(project);
|
||||
if (myModifierListOwner != null) {
|
||||
final PsiModifierList modifierList = myModifierListOwner.getModifierList();
|
||||
LOG.assertTrue(modifierList != null);
|
||||
if (modifierList.findAnnotation(myAnnotation) != null) return;
|
||||
final ExternalAnnotationsManager.AnnotationPlace annotationAnnotationPlace = annotationsManager.chooseAnnotationsPlace(myModifierListOwner);
|
||||
if (annotationAnnotationPlace == ExternalAnnotationsManager.AnnotationPlace.NOWHERE) return;
|
||||
if (annotationAnnotationPlace == ExternalAnnotationsManager.AnnotationPlace.EXTERNAL) {
|
||||
for (String fqn : myAnnotationsToRemove) {
|
||||
annotationsManager.deannotate(myModifierListOwner, fqn);
|
||||
}
|
||||
annotationsManager.annotateExternally(myModifierListOwner, myAnnotation, file);
|
||||
}
|
||||
else {
|
||||
final PsiFile containingFile = myModifierListOwner.getContainingFile();
|
||||
if (!containingFile.isWritable()
|
||||
&& ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(containingFile.getVirtualFile()).hasReadonlyFiles()) return;
|
||||
for (String fqn : myAnnotationsToRemove) {
|
||||
PsiAnnotation annotation = AnnotationUtil.findAnnotation(myModifierListOwner, fqn);
|
||||
if (annotation != null) {
|
||||
annotation.delete();
|
||||
}
|
||||
}
|
||||
|
||||
PsiElement inserted = modifierList.addAnnotation(myAnnotation);
|
||||
JavaCodeStyleManager.getInstance(project).shortenClassReferences(inserted);
|
||||
if (containingFile != file) {
|
||||
UndoUtil.markPsiFileForUndo(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
final PsiElement element = file.findElementAt(editor.getCaretModel().getOffset());
|
||||
annotationsManager.annotateExternally(PsiTreeUtil.getParentOfType(element, PsiModifierListOwner.class, false), myAnnotation, file);
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getAnnotationsToRemove() {
|
||||
return myAnnotationsToRemove;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2000-2007 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.intention;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PropertyMemberType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
public abstract class QuickFixFactory {
|
||||
public static QuickFixFactory getInstance() {
|
||||
return ServiceManager.getService(QuickFixFactory.class);
|
||||
}
|
||||
|
||||
public abstract IntentionAction createModifierListFix(@NotNull PsiModifierList modifierList,
|
||||
@Modifier @NotNull String modifier,
|
||||
boolean shouldHave,
|
||||
final boolean showContainingClass);
|
||||
public abstract IntentionAction createModifierListFix(@NotNull PsiModifierListOwner owner,
|
||||
@Modifier @NotNull String modifier,
|
||||
boolean shouldHave,
|
||||
final boolean showContainingClass);
|
||||
public abstract IntentionAction createMethodReturnFix(@NotNull PsiMethod method, @NotNull PsiType toReturn, boolean fixWholeHierarchy);
|
||||
|
||||
public abstract IntentionAction createAddMethodFix(@NotNull PsiMethod method, @NotNull PsiClass toClass);
|
||||
public abstract IntentionAction createAddMethodFix(@NotNull String methodText, @NotNull PsiClass toClass, String... exceptions);
|
||||
|
||||
public abstract IntentionAction createImplementMethodsFix(@NotNull PsiClass aClass);
|
||||
public abstract IntentionAction createMethodThrowsFix(@NotNull PsiMethod method, @NotNull PsiClassType exceptionClass, boolean shouldThrow, boolean showContainingClass);
|
||||
public abstract IntentionAction createAddDefaultConstructorFix(@NotNull PsiClass aClass);
|
||||
public abstract IntentionAction createMethodParameterTypeFix(@NotNull PsiMethod method, int index, @NotNull PsiType newType, boolean fixWholeHierarchy);
|
||||
public abstract IntentionAction createMakeClassInterfaceFix(@NotNull PsiClass aClass);
|
||||
public abstract IntentionAction createMakeClassInterfaceFix(@NotNull PsiClass aClass, final boolean makeInterface);
|
||||
public abstract IntentionAction createExtendsListFix(@NotNull PsiClass aClass, @NotNull PsiClassType typeToExtendFrom, boolean toAdd);
|
||||
public abstract IntentionAction createRemoveUnusedParameterFix(@NotNull PsiParameter parameter);
|
||||
public abstract IntentionAction createRemoveUnusedVariableFix(@NotNull PsiVariable variable);
|
||||
|
||||
@Nullable
|
||||
public abstract IntentionAction createCreateClassOrPackageFix(@NotNull PsiElement context, @NotNull String qualifiedName, final boolean createClass, final String superClass);
|
||||
@Nullable
|
||||
public abstract IntentionAction createCreateClassOrInterfaceFix(@NotNull PsiElement context, @NotNull String qualifiedName, final boolean createClass, final String superClass);
|
||||
public abstract IntentionAction createCreateFieldOrPropertyFix(final PsiClass aClass, final String name, final PsiType type, final PropertyMemberType targetMember, final PsiAnnotation... annotations);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<!--
|
||||
~ Copyright 2000-2007 JetBrains s.r.o.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html><body bgcolor="white">
|
||||
Provides interfaces for working with highlighting in standard IDEA editors, interfaces
|
||||
and classes for defining intention actions and additional functionality related to background
|
||||
code analysis in IDEA.
|
||||
</body></html>
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 27-Aug-2009
|
||||
*/
|
||||
package com.intellij.codeInsight.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.PsiVariable;
|
||||
|
||||
public interface ChangeVariableTypeQuickFixProvider {
|
||||
ExtensionPointName<ChangeVariableTypeQuickFixProvider> EP_NAME = ExtensionPointName.create("com.intellij.codeInsight.changeVariableTypeQuickFixProvider");
|
||||
|
||||
IntentionAction[] getFixes(PsiVariable variable, PsiType toReturn);
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.intellij.codeInsight.quickfix;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.codeInsight.daemon.QuickFixActionRegistrar;
|
||||
|
||||
public interface UnresolvedReferenceQuickFixProvider {
|
||||
ExtensionPointName<UnresolvedReferenceQuickFixProvider> EXTENSION_NAME =
|
||||
ExtensionPointName.create("com.intellij.codeInsight.unresolvedReferenceQuickFixProvider");
|
||||
|
||||
|
||||
void registerFixes(PsiJavaCodeReferenceElement ref, QuickFixActionRegistrar registrar);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.intellij.codeInsight.runner;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
*/
|
||||
public interface JavaMainMethodProvider {
|
||||
|
||||
ExtensionPointName<JavaMainMethodProvider> EP_NAME = ExtensionPointName.create("com.intellij.javaMainMethodProvider");
|
||||
|
||||
boolean isApplicable(final PsiClass clazz);
|
||||
|
||||
boolean hasMainMethod(final PsiClass clazz);
|
||||
|
||||
PsiMethod findMainInClass(final PsiClass clazz);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user