mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
java-psi-api and java-psi-impl modules extracted
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.components.ServiceManager;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public abstract class TestFrameworks {
|
||||
public static TestFrameworks getInstance() {
|
||||
return ServiceManager.getService(TestFrameworks.class);
|
||||
}
|
||||
|
||||
public abstract boolean isTestClass(PsiClass psiClass);
|
||||
|
||||
@Nullable
|
||||
public abstract PsiMethod findOrCreateSetUpMethod(PsiClass psiClass);
|
||||
|
||||
@Nullable
|
||||
public abstract PsiMethod findSetUpMethod(PsiClass psiClass);
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* 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.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);
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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.lang.java;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class JavaLanguage extends Language {
|
||||
|
||||
public static JavaLanguage INSTANCE = new JavaLanguage();
|
||||
|
||||
public JavaLanguage() {
|
||||
super("JAVA", "text/java", "application/x-java", "text/x-java");
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return "Java";
|
||||
}
|
||||
|
||||
public boolean isCaseSensitive() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* 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.lexer;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class JavaDocLexer extends DocCommentLexer {
|
||||
public JavaDocLexer(final boolean isJdk15Enabled) {
|
||||
super(JavaDocTokenTypes.INSTANCE, isJdk15Enabled);
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* 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.lexer;
|
||||
|
||||
import com.intellij.psi.JavaDocTokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class JavaDocTokenTypes implements DocCommentTokenTypes {
|
||||
public static final DocCommentTokenTypes INSTANCE = new JavaDocTokenTypes();
|
||||
|
||||
private JavaDocTokenTypes() { }
|
||||
|
||||
public IElementType commentStart() {
|
||||
return JavaDocTokenType.DOC_COMMENT_START;
|
||||
}
|
||||
|
||||
public IElementType commentEnd() {
|
||||
return JavaDocTokenType.DOC_COMMENT_END;
|
||||
}
|
||||
|
||||
public IElementType commentData() {
|
||||
return JavaDocTokenType.DOC_COMMENT_DATA;
|
||||
}
|
||||
|
||||
public IElementType space() {
|
||||
return JavaDocTokenType.DOC_SPACE;
|
||||
}
|
||||
|
||||
public IElementType tagValueToken() {
|
||||
return JavaDocTokenType.DOC_TAG_VALUE_TOKEN;
|
||||
}
|
||||
|
||||
public IElementType tagValueLParen() {
|
||||
return JavaDocTokenType.DOC_TAG_VALUE_LPAREN;
|
||||
}
|
||||
|
||||
public IElementType tagValueRParen() {
|
||||
return JavaDocTokenType.DOC_TAG_VALUE_RPAREN;
|
||||
}
|
||||
|
||||
public IElementType tagValueSharp() {
|
||||
return JavaDocTokenType.DOC_TAG_VALUE_SHARP_TOKEN;
|
||||
}
|
||||
|
||||
public IElementType tagValueComma() {
|
||||
return JavaDocTokenType.DOC_TAG_VALUE_COMMA;
|
||||
}
|
||||
|
||||
public IElementType tagName() {
|
||||
return JavaDocTokenType.DOC_TAG_NAME;
|
||||
}
|
||||
|
||||
public IElementType tagValueLT() {
|
||||
return JavaDocTokenType.DOC_TAG_VALUE_LT;
|
||||
}
|
||||
|
||||
public IElementType tagValueGT() {
|
||||
return JavaDocTokenType.DOC_TAG_VALUE_GT;
|
||||
}
|
||||
|
||||
public IElementType inlineTagStart() {
|
||||
return JavaDocTokenType.DOC_INLINE_TAG_START;
|
||||
}
|
||||
|
||||
public IElementType inlineTagEnd() {
|
||||
return JavaDocTokenType.DOC_INLINE_TAG_END;
|
||||
}
|
||||
|
||||
public IElementType badCharacter() {
|
||||
return JavaDocTokenType.DOC_COMMENT_BAD_CHARACTER;
|
||||
}
|
||||
|
||||
public IElementType commentLeadingAsterisks() {
|
||||
return JavaDocTokenType.DOC_COMMENT_LEADING_ASTERISKS;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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.openapi.roots;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public abstract class LanguageLevelProjectExtension {
|
||||
|
||||
public static LanguageLevelProjectExtension getInstance(Project project) {
|
||||
return ServiceManager.getService(project, LanguageLevelProjectExtension.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract LanguageLevel getLanguageLevel();
|
||||
|
||||
public abstract void setLanguageLevel(@NotNull LanguageLevel languageLevel);
|
||||
|
||||
public abstract void reloadProjectOnLanguageLevelChange(@NotNull LanguageLevel languageLevel, boolean forceReload);
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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.openapi.roots;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Query;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class PackageIndex {
|
||||
public static PackageIndex getInstance(Project project) {
|
||||
return ServiceManager.getService(project, PackageIndex.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all directories in content sources and libraries (and optionally library sources)
|
||||
* corresponding to the given package name.
|
||||
*
|
||||
* @param packageName the name of the package for which directories are requested.
|
||||
* @param includeLibrarySources if true, directories under library sources are included in the returned list.
|
||||
* @return the list of directories.
|
||||
*/
|
||||
public abstract VirtualFile[] getDirectoriesByPackageName(@NotNull String packageName, boolean includeLibrarySources);
|
||||
|
||||
public abstract Query<VirtualFile> getDirsByPackageName(@NotNull String packageName, boolean includeLibrarySources);
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* 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.pom.java;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.PsiBundle;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author dsl
|
||||
*/
|
||||
public enum LanguageLevel {
|
||||
JDK_1_3(PsiBundle.message("jdk.1.3.language.level.description")),
|
||||
JDK_1_4(PsiBundle.message("jdk.1.4.language.level.description")),
|
||||
JDK_1_5(PsiBundle.message("jdk.1.5.language.level.description")),
|
||||
JDK_1_6(PsiBundle.message("jdk.1.6.language.level.description")),
|
||||
JDK_1_7(PsiBundle.message("jdk.1.7.language.level.description")),
|
||||
JDK_1_8(PsiBundle.message("jdk.1.8.language.level.description"));
|
||||
|
||||
public static final LanguageLevel HIGHEST = JDK_1_8;
|
||||
public static final Key<LanguageLevel> KEY = Key.create("LANGUAGE_LEVEL");
|
||||
|
||||
private final String myPresentableText;
|
||||
|
||||
private LanguageLevel(final String presentableText) {
|
||||
myPresentableText = presentableText;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return ordinal() + 3; // solely for backward compatibility
|
||||
}
|
||||
|
||||
public boolean hasAssertKeyword() {
|
||||
return isAtLeast(JDK_1_4);
|
||||
}
|
||||
|
||||
public boolean hasEnumKeywordAndAutoboxing() {
|
||||
return isAtLeast(JDK_1_5);
|
||||
}
|
||||
|
||||
public String getPresentableText() {
|
||||
return myPresentableText;
|
||||
}
|
||||
|
||||
public boolean isAtLeast(final LanguageLevel level) {
|
||||
return compareTo(level) >= 0;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static LanguageLevel parse(final String value) {
|
||||
if ("1.3".equals(value)) return JDK_1_3;
|
||||
if ("1.4".equals(value)) return JDK_1_4;
|
||||
if ("1.5".equals(value)) return JDK_1_5;
|
||||
if ("1.6".equals(value)) return JDK_1_6;
|
||||
if ("1.7".equals(value)) return JDK_1_7;
|
||||
if ("1.8".equals(value)) return JDK_1_8;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public interface CommonClassNames {
|
||||
@NonNls String DEFAULT_PACKAGE = "java.lang";
|
||||
|
||||
@NonNls String JAVA_LANG_OBJECT = "java.lang.Object";
|
||||
@NonNls String JAVA_LANG_CLASS = "java.lang.Class";
|
||||
@NonNls String JAVA_LANG_ENUM = "java.lang.Enum";
|
||||
|
||||
@NonNls String JAVA_LANG_THROWABLE = "java.lang.Throwable";
|
||||
@NonNls String JAVA_LANG_EXCEPTION = "java.lang.Exception";
|
||||
@NonNls String JAVA_LANG_ERROR = "java.lang.Error";
|
||||
@NonNls String JAVA_LANG_RUNTIME_EXCEPTION = "java.lang.RuntimeException";
|
||||
@NonNls String JAVA_LANG_AUTO_CLOSEABLE = "java.lang.AutoCloseable";
|
||||
|
||||
@NonNls String JAVA_LANG_ITERABLE = "java.lang.Iterable";
|
||||
@NonNls String JAVA_UTIL_ITERATOR = "java.util.Iterator";
|
||||
|
||||
@NonNls String JAVA_LANG_DEPRECATED = "java.lang.Deprecated";
|
||||
|
||||
@NonNls String JAVA_LANG_ANNOTATION_INHERITED = "java.lang.annotation.Inherited";
|
||||
@NonNls String JAVA_LANG_ANNOTATION_ANNOTATION = "java.lang.annotation.Annotation";
|
||||
|
||||
@NonNls String JAVA_LANG_REFLECT_ARRAY = "java.lang.reflect.Array";
|
||||
|
||||
@NonNls String JAVA_UTIL_ARRAYS = "java.util.Arrays";
|
||||
@NonNls String JAVA_UTIL_COLLECTIONS = "java.util.Collections";
|
||||
@NonNls String JAVA_UTIL_COLLECTION = "java.util.Collection";
|
||||
@NonNls String JAVA_UTIL_MAP = "java.util.Map";
|
||||
@NonNls String JAVA_UTIL_LIST = "java.util.List";
|
||||
@NonNls String JAVA_UTIL_SET = "java.util.Set";
|
||||
@NonNls String JAVA_UTIL_PROPERTIES = "java.util.Properties";
|
||||
@NonNls String JAVA_UTIL_PROPERTY_RESOURCE_BUNDLE = "java.util.PropertyResourceBundle";
|
||||
@NonNls String JAVA_UTIL_DATE = "java.util.Date";
|
||||
@NonNls String JAVA_UTIL_CALENDAR = "java.util.Calendar";
|
||||
@NonNls String JAVA_UTIL_DICTIONARY = "java.util.Dictionary";
|
||||
@NonNls String JAVA_UTIL_COMPARATOR = "java.util.Comparator";
|
||||
|
||||
@NonNls String JAVA_SQL_DATE = "java.sql.Date";
|
||||
|
||||
@NonNls String JAVA_IO_SERIALIZABLE = "java.io.Serializable";
|
||||
@NonNls String JAVA_IO_EXTERNALIZABLE = "java.io.Externalizable";
|
||||
|
||||
@NonNls String JAVA_LANG_STRING = "java.lang.String";
|
||||
@NonNls String JAVA_LANG_STRING_SHORT = "String";
|
||||
@NonNls String JAVA_LANG_NUMBER = "java.lang.Number";
|
||||
@NonNls String JAVA_LANG_BOOLEAN = "java.lang.Boolean";
|
||||
@NonNls String JAVA_LANG_BYTE = "java.lang.Byte";
|
||||
@NonNls String JAVA_LANG_SHORT = "java.lang.Short";
|
||||
@NonNls String JAVA_LANG_INTEGER = "java.lang.Integer";
|
||||
@NonNls String JAVA_LANG_LONG = "java.lang.Long";
|
||||
@NonNls String JAVA_LANG_FLOAT = "java.lang.Float";
|
||||
@NonNls String JAVA_LANG_DOUBLE = "java.lang.Double";
|
||||
@NonNls String JAVA_LANG_CHARACTER = "java.lang.Character";
|
||||
|
||||
@NonNls String JAVA_LANG_STRING_BUFFER = "java.lang.StringBuffer";
|
||||
@NonNls String JAVA_LANG_ABSTRACT_STRING_BUILDER = "java.lang.AbstractStringBuilder";
|
||||
|
||||
@NonNls String JAVA_LANG_CLONEABLE = "java.lang.Cloneable";
|
||||
@NonNls String JAVA_LANG_COMPARABLE = "java.lang.Comparable";
|
||||
@NonNls String CLASS_FILE_EXTENSION = ".class";
|
||||
|
||||
@NonNls String JAVA_UTIL_CONCURRENT_FUTURE = "java.util.concurrent.Future";
|
||||
@NonNls String JAVA_UTIL_ARRAY_LIST = "java.util.ArrayList";
|
||||
|
||||
@NonNls String JAVA_LANG_INVOKE_MH_POLYMORPHIC = "java.lang.invoke.MethodHandle.PolymorphicSignature";
|
||||
String TARGET_ANNOTATION_FQ_NAME = "java.lang.annotation.Target";
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
|
||||
/**
|
||||
* The substitutor which does not provide any mappings for the type parameters.
|
||||
*
|
||||
* @author dsl
|
||||
* @see PsiSubstitutor#EMPTY
|
||||
*/
|
||||
public abstract class EmptySubstitutor implements PsiSubstitutor {
|
||||
public static EmptySubstitutor getInstance() {
|
||||
return ServiceManager.getService(EmptySubstitutor.class);
|
||||
}
|
||||
}
|
||||
@@ -1,332 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class GenericsUtil {
|
||||
|
||||
private GenericsUtil() {}
|
||||
|
||||
public static PsiType getGreatestLowerBound(PsiType type1, PsiType type2) {
|
||||
return PsiIntersectionType.createIntersection(type1, type2);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiType getLeastUpperBound(PsiType type1, PsiType type2, PsiManager manager) {
|
||||
if (TypeConversionUtil.isPrimitiveAndNotNull(type1) || TypeConversionUtil.isPrimitiveAndNotNull(type2)) return null;
|
||||
if (TypeConversionUtil.isNullType(type1)) return type2;
|
||||
if (TypeConversionUtil.isNullType(type2)) return type1;
|
||||
return getLeastUpperBound(type1, type2, new LinkedHashSet<Pair<PsiType, PsiType>>(), manager);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static PsiType getLeastUpperBound(PsiType type1, PsiType type2, Set<Pair<PsiType, PsiType>> compared, PsiManager manager) {
|
||||
if (type1 instanceof PsiCapturedWildcardType) {
|
||||
return getLeastUpperBound(((PsiCapturedWildcardType)type1).getUpperBound(), type2, compared, manager);
|
||||
}
|
||||
if (type2 instanceof PsiCapturedWildcardType) {
|
||||
return getLeastUpperBound(type1, ((PsiCapturedWildcardType)type2).getUpperBound(), compared, manager);
|
||||
}
|
||||
|
||||
if (type1 instanceof PsiWildcardType) {
|
||||
return getLeastUpperBound(((PsiWildcardType)type1).getExtendsBound(), type2, compared, manager);
|
||||
}
|
||||
if (type2 instanceof PsiWildcardType) {
|
||||
return getLeastUpperBound(type1, ((PsiWildcardType)type2).getExtendsBound(), compared, manager);
|
||||
}
|
||||
|
||||
if (type1 instanceof PsiArrayType && type2 instanceof PsiArrayType) {
|
||||
final PsiType componentType = getLeastUpperBound(((PsiArrayType)type1).getComponentType(),
|
||||
((PsiArrayType)type2).getComponentType(), manager);
|
||||
if (componentType != null) {
|
||||
return componentType.createArrayType();
|
||||
}
|
||||
}
|
||||
if (type1 instanceof PsiIntersectionType) {
|
||||
Set<PsiType> newConjuncts = new LinkedHashSet<PsiType>();
|
||||
final PsiType[] conjuncts = ((PsiIntersectionType)type1).getConjuncts();
|
||||
for (PsiType type : conjuncts) {
|
||||
newConjuncts.add(getLeastUpperBound(type, type2, compared, manager));
|
||||
}
|
||||
return PsiIntersectionType.createIntersection(newConjuncts.toArray(new PsiType[newConjuncts.size()]));
|
||||
}
|
||||
if (type2 instanceof PsiIntersectionType) {
|
||||
return getLeastUpperBound(type2, type1, compared, manager);
|
||||
}
|
||||
if (type1 instanceof PsiClassType && type2 instanceof PsiClassType) {
|
||||
PsiClassType.ClassResolveResult classResolveResult1 = ((PsiClassType)type1).resolveGenerics();
|
||||
PsiClassType.ClassResolveResult classResolveResult2 = ((PsiClassType)type2).resolveGenerics();
|
||||
PsiClass aClass = classResolveResult1.getElement();
|
||||
PsiClass bClass = classResolveResult2.getElement();
|
||||
if (aClass == null || bClass == null) {
|
||||
return PsiType.getJavaLangObject(manager, GlobalSearchScope.allScope(manager.getProject()));
|
||||
}
|
||||
|
||||
PsiClass[] supers = getLeastUpperClasses(aClass, bClass);
|
||||
if (supers.length == 0) {
|
||||
return PsiType.getJavaLangObject(manager, aClass.getResolveScope());
|
||||
}
|
||||
|
||||
PsiClassType[] conjuncts = new PsiClassType[supers.length];
|
||||
for (int i = 0; i < supers.length; i++) {
|
||||
PsiClass aSuper = supers[i];
|
||||
PsiSubstitutor subst1 = TypeConversionUtil.getSuperClassSubstitutor(aSuper, aClass, classResolveResult1.getSubstitutor());
|
||||
PsiSubstitutor subst2 = TypeConversionUtil.getSuperClassSubstitutor(aSuper, bClass, classResolveResult2.getSubstitutor());
|
||||
PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
|
||||
for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable(aSuper)) {
|
||||
PsiType mapping1 = subst1.substitute(parameter);
|
||||
PsiType mapping2 = subst2.substitute(parameter);
|
||||
|
||||
if (mapping1 != null && mapping2 != null) {
|
||||
substitutor = substitutor.put(parameter, getLeastContainingTypeArgument(mapping1, mapping2, compared, manager));
|
||||
}
|
||||
else {
|
||||
substitutor = substitutor.put(parameter, null);
|
||||
}
|
||||
}
|
||||
|
||||
conjuncts[i] = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createType(aSuper, substitutor);
|
||||
}
|
||||
|
||||
return PsiIntersectionType.createIntersection(conjuncts);
|
||||
}
|
||||
if (type2 instanceof PsiArrayType && !(type1 instanceof PsiArrayType)) {
|
||||
return getLeastUpperBound(type2, type1, compared, manager);
|
||||
}
|
||||
if (type1 instanceof PsiArrayType) {
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
|
||||
GlobalSearchScope all = GlobalSearchScope.allScope(manager.getProject());
|
||||
PsiClassType serializable = factory.createTypeByFQClassName(CommonClassNames.JAVA_IO_SERIALIZABLE, all);
|
||||
PsiClassType cloneable = factory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_CLONEABLE, all);
|
||||
PsiType arraySupers = PsiIntersectionType.createIntersection(serializable, cloneable);
|
||||
return getLeastUpperBound(arraySupers, type2, compared, manager);
|
||||
}
|
||||
|
||||
return PsiType.getJavaLangObject(manager, GlobalSearchScope.allScope(manager.getProject()));
|
||||
}
|
||||
|
||||
private static PsiType getLeastContainingTypeArgument(PsiType type1,
|
||||
PsiType type2,
|
||||
Set<Pair<PsiType, PsiType>> compared,
|
||||
PsiManager manager) {
|
||||
Pair<PsiType, PsiType> types = new Pair<PsiType, PsiType>(type1, type2);
|
||||
if (compared.contains(types)) return PsiWildcardType.createUnbounded(manager);
|
||||
compared.add(types);
|
||||
|
||||
try {
|
||||
if (type1 instanceof PsiWildcardType) {
|
||||
PsiWildcardType wild1 = (PsiWildcardType)type1;
|
||||
final PsiType bound1 = wild1.getBound();
|
||||
if (bound1 == null) return type1;
|
||||
if (type2 instanceof PsiWildcardType) {
|
||||
PsiWildcardType wild2 = (PsiWildcardType)type2;
|
||||
final PsiType bound2 = wild2.getBound();
|
||||
if (bound2 == null) return wild1;
|
||||
if (wild1.isExtends() == wild2.isExtends()) {
|
||||
return wild1.isExtends() ?
|
||||
PsiWildcardType.createExtends(manager, getLeastUpperBound(bound1, bound2, compared, manager)) :
|
||||
PsiWildcardType.createSuper(manager, getGreatestLowerBound(bound1, bound2));
|
||||
}
|
||||
else {
|
||||
return bound1.equals(bound2) ? bound1 : PsiWildcardType.createUnbounded(manager);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return wild1.isExtends() ? PsiWildcardType.createExtends(manager, getLeastUpperBound(bound1, type2, compared, manager)) :
|
||||
wild1.isSuper() ? PsiWildcardType.createSuper(manager, getGreatestLowerBound(bound1, type2)) :
|
||||
wild1;
|
||||
}
|
||||
}
|
||||
else if (type2 instanceof PsiWildcardType) {
|
||||
return getLeastContainingTypeArgument(type2, type1, compared, manager);
|
||||
}
|
||||
//Done with wildcards
|
||||
|
||||
if (type1.equals(type2)) return type1;
|
||||
return PsiWildcardType.createExtends(manager, getLeastUpperBound(type1, type2, compared, manager));
|
||||
}
|
||||
finally {
|
||||
compared.remove(types);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PsiClass[] getLeastUpperClasses(PsiClass aClass, PsiClass bClass) {
|
||||
if (InheritanceUtil.isInheritorOrSelf(aClass, bClass, true)) return new PsiClass[]{bClass};
|
||||
Set<PsiClass> supers = new LinkedHashSet<PsiClass>();
|
||||
getLeastUpperClassesInner(aClass, bClass, supers);
|
||||
return supers.toArray(new PsiClass[supers.size()]);
|
||||
}
|
||||
|
||||
private static void getLeastUpperClassesInner(PsiClass aClass, PsiClass bClass, Set<PsiClass> supers) {
|
||||
if (bClass.isInheritor(aClass, true)) {
|
||||
addSuper(supers, aClass);
|
||||
}
|
||||
else {
|
||||
final PsiClass[] aSupers = aClass.getSupers();
|
||||
for (PsiClass aSuper : aSupers) {
|
||||
getLeastUpperClassesInner(aSuper, bClass, supers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addSuper(final Set<PsiClass> supers, final PsiClass classToAdd) {
|
||||
for (Iterator<PsiClass> iterator = supers.iterator(); iterator.hasNext();) {
|
||||
PsiClass superClass = iterator.next();
|
||||
if (InheritanceUtil.isInheritorOrSelf(superClass, classToAdd, true)) return;
|
||||
if (classToAdd.isInheritor(superClass, true)) iterator.remove();
|
||||
}
|
||||
|
||||
supers.add(classToAdd);
|
||||
}
|
||||
|
||||
public static boolean isTypeArgumentsApplicable(PsiTypeParameter[] typeParams, PsiSubstitutor substitutor, final PsiElement context) {
|
||||
for (PsiTypeParameter typeParameter : typeParams) {
|
||||
PsiType substituted = substitutor.substitute(typeParameter);
|
||||
if (substituted == null) return true;
|
||||
substituted = PsiUtil.captureToplevelWildcards(substituted, context);
|
||||
|
||||
PsiClassType[] extendsTypes = typeParameter.getExtendsListTypes();
|
||||
for (PsiClassType type : extendsTypes) {
|
||||
PsiType extendsType = substitutor.substitute(type);
|
||||
if (!extendsType.isAssignableFrom(substituted)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isFromExternalTypeLanguage(@NotNull PsiType type) {
|
||||
String internalCanonicalText = type.getInternalCanonicalText();
|
||||
return internalCanonicalText != null && internalCanonicalText.equals(type.getCanonicalText());
|
||||
}
|
||||
|
||||
public static PsiType getVariableTypeByExpressionType(final PsiType type) {
|
||||
PsiType transformed = type.accept(new PsiTypeVisitor<PsiType>() {
|
||||
public PsiType visitArrayType(PsiArrayType arrayType) {
|
||||
PsiType componentType = arrayType.getComponentType();
|
||||
PsiType type = componentType.accept(this);
|
||||
if (type == componentType) return arrayType;
|
||||
return type.createArrayType();
|
||||
}
|
||||
|
||||
public PsiType visitType(PsiType type) {
|
||||
return type;
|
||||
}
|
||||
|
||||
public PsiType visitWildcardType(final PsiWildcardType wildcardType) {
|
||||
final PsiType bound = wildcardType.getBound();
|
||||
PsiManager manager = wildcardType.getManager();
|
||||
if (bound != null) {
|
||||
final PsiType acceptedBound = bound.accept(this);
|
||||
if (acceptedBound instanceof PsiWildcardType) {
|
||||
if (((PsiWildcardType)acceptedBound).isExtends() != wildcardType.isExtends()) return PsiWildcardType.createUnbounded(manager);
|
||||
return acceptedBound;
|
||||
}
|
||||
if (acceptedBound.equals(bound)) return wildcardType;
|
||||
return wildcardType.isExtends()
|
||||
? PsiWildcardType.createExtends(manager, acceptedBound)
|
||||
: PsiWildcardType.createSuper(manager, acceptedBound);
|
||||
}
|
||||
return wildcardType;
|
||||
}
|
||||
|
||||
public PsiType visitCapturedWildcardType(PsiCapturedWildcardType capturedWildcardType) {
|
||||
return capturedWildcardType.getWildcard().accept(this);
|
||||
}
|
||||
|
||||
public PsiType visitClassType(PsiClassType classType) {
|
||||
PsiClassType.ClassResolveResult resolveResult = classType.resolveGenerics();
|
||||
PsiClass aClass = resolveResult.getElement();
|
||||
if (aClass == null) return classType;
|
||||
boolean toExtend = false;
|
||||
PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
|
||||
for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(aClass)) {
|
||||
PsiType typeArgument = resolveResult.getSubstitutor().substitute(typeParameter);
|
||||
if (typeArgument instanceof PsiCapturedWildcardType) toExtend = true;
|
||||
if (typeArgument instanceof PsiWildcardType && ((PsiWildcardType)typeArgument).getBound() instanceof PsiIntersectionType) {
|
||||
toExtend = true;
|
||||
}
|
||||
PsiType toPut;
|
||||
if (typeArgument == null) {
|
||||
toPut = null;
|
||||
}
|
||||
else {
|
||||
final PsiType accepted = typeArgument.accept(this);
|
||||
if (typeArgument instanceof PsiIntersectionType) {
|
||||
toPut = PsiWildcardType.createExtends(typeParameter.getManager(), accepted);
|
||||
}
|
||||
else {
|
||||
toPut = accepted;
|
||||
}
|
||||
}
|
||||
substitutor = substitutor.put(typeParameter, toPut);
|
||||
}
|
||||
final PsiAnnotation[] applicableAnnotations = classType.getApplicableAnnotations();
|
||||
if (substitutor == PsiSubstitutor.EMPTY && !toExtend && applicableAnnotations.length == 0 && !(aClass instanceof PsiTypeParameter)) return classType;
|
||||
PsiManager manager = aClass.getManager();
|
||||
PsiType result = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory()
|
||||
.createType(aClass, substitutor, PsiUtil.getLanguageLevel(aClass), applicableAnnotations);
|
||||
if (toExtend) result = PsiWildcardType.createExtends(manager, result);
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
PsiType componentType = transformed.getDeepComponentType();
|
||||
if (componentType instanceof PsiWildcardType) {
|
||||
componentType = ((PsiWildcardType)componentType).getExtendsBound();
|
||||
int dims = transformed.getArrayDimensions();
|
||||
for (int i = 0; i < dims; i++) componentType = componentType.createArrayType();
|
||||
return componentType;
|
||||
}
|
||||
|
||||
return transformed;
|
||||
}
|
||||
|
||||
public static PsiSubstitutor substituteByParameterName(final PsiClass psiClass, final PsiSubstitutor parentSubstitutor) {
|
||||
|
||||
final Map<PsiTypeParameter, PsiType> substitutionMap = parentSubstitutor.getSubstitutionMap();
|
||||
final List<PsiType> result = new ArrayList<PsiType>(substitutionMap.size());
|
||||
for (PsiTypeParameter typeParameter : psiClass.getTypeParameters()) {
|
||||
final String name = typeParameter.getName();
|
||||
final PsiTypeParameter key = ContainerUtil.find(substitutionMap.keySet(), new Condition<PsiTypeParameter>() {
|
||||
public boolean value(final PsiTypeParameter psiTypeParameter) {
|
||||
return name.equals(psiTypeParameter.getName());
|
||||
}
|
||||
});
|
||||
if (key != null) {
|
||||
result.add(substitutionMap.get(key));
|
||||
}
|
||||
}
|
||||
return PsiSubstitutor.EMPTY.putAll(psiClass, result.toArray(new PsiType[result.size()]));
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.psi.util.MethodSignatureBackedByPsiMethod;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Data structure which allows efficient retrieval of super methods for a Java method.
|
||||
*
|
||||
* @author ven
|
||||
* @since 5.1
|
||||
*/
|
||||
public abstract class HierarchicalMethodSignature extends MethodSignatureBackedByPsiMethod {
|
||||
|
||||
public HierarchicalMethodSignature(final MethodSignatureBackedByPsiMethod signature) {
|
||||
super(signature.getMethod(), signature.getSubstitutor(), signature.isRaw(),
|
||||
signature.getParameterTypes(), signature.getTypeParameters());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of super method signatures for the specified signature.
|
||||
*
|
||||
* @return the super method signature list.
|
||||
* Note that the list may include signatures for which isSubsignature() check returns false, but erasures are equal
|
||||
*/
|
||||
@NotNull public abstract List<HierarchicalMethodSignature> getSuperSignatures();
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
public interface ImplicitVariable extends PsiLocalVariable {
|
||||
// todo: probably move getDeclarationScope to PsiLocalVariable?
|
||||
PsiElement getDeclarationScope();
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.psi;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageExtension;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
/**
|
||||
* @author Medvedev Max
|
||||
*/
|
||||
public class JVMElementFactories extends LanguageExtension<JVMElementFactoryProvider> {
|
||||
private static final JVMElementFactories INSTANCE = new JVMElementFactories();
|
||||
|
||||
private JVMElementFactories() {
|
||||
super("com.intellij.generation.topLevelFactory");
|
||||
}
|
||||
|
||||
public static JVMElementFactory getFactory(Language language, Project project) {
|
||||
final JVMElementFactoryProvider provider = INSTANCE.forLanguage(language);
|
||||
return provider.getFactory(project);
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.psi;
|
||||
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Medvedev Max
|
||||
*/
|
||||
public interface JVMElementFactory {
|
||||
/**
|
||||
* Creates an empty class with the specified name.
|
||||
*
|
||||
* @param name the name of the class to create.
|
||||
* @return the created class instance.
|
||||
* @throws com.intellij.util.IncorrectOperationException
|
||||
* if <code>name</code> is not a valid Java identifier.
|
||||
*/
|
||||
@NotNull
|
||||
PsiClass createClass(@NonNls @NotNull String name) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an empty interface with the specified name.
|
||||
*
|
||||
* @param name the name of the interface to create.
|
||||
* @return the created interface instance.
|
||||
* @throws IncorrectOperationException if <code>name</code> is not a valid Java identifier.
|
||||
*/
|
||||
@NotNull
|
||||
PsiClass createInterface(@NonNls @NotNull String name) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an empty enum with the specified name.
|
||||
*
|
||||
* @param name the name of the enum to create.
|
||||
* @return the created enum instance.
|
||||
* @throws IncorrectOperationException if <code>name</code> is not a valid Java identifier.
|
||||
*/
|
||||
@NotNull
|
||||
PsiClass createEnum(@NotNull @NonNls String name) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a field with the specified name and type.
|
||||
*
|
||||
* @param name the name of the field to create.
|
||||
* @param type the type of the field to create.
|
||||
* @return the created field instance.
|
||||
* @throws IncorrectOperationException <code>name</code> is not a valid Java identifier
|
||||
* or <code>type</code> represents an invalid type.
|
||||
*/
|
||||
@NotNull
|
||||
PsiField createField(@NotNull @NonNls String name, @NotNull PsiType type) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an empty method with the specified name and return type.
|
||||
*
|
||||
* @param name the name of the method to create.
|
||||
* @param returnType the return type of the method to create.
|
||||
* @return the created method instance.
|
||||
* @throws IncorrectOperationException <code>name</code> is not a valid Java identifier
|
||||
* or <code>type</code> represents an invalid type.
|
||||
*/
|
||||
@NotNull
|
||||
PsiMethod createMethod(@NotNull @NonNls String name, PsiType returnType) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an empty constructor.
|
||||
*
|
||||
* @return the created constructor instance.
|
||||
*/
|
||||
@NotNull
|
||||
PsiMethod createConstructor();
|
||||
|
||||
/**
|
||||
* Creates an empty class initializer block.
|
||||
*
|
||||
* @return the created initializer block instance.
|
||||
* @throws IncorrectOperationException in case of an internal error.
|
||||
*/
|
||||
@NotNull
|
||||
PsiClassInitializer createClassInitializer() throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a parameter with the specified name and type.
|
||||
*
|
||||
* @param name the name of the parameter to create.
|
||||
* @param type the type of the parameter to create.
|
||||
* @return the created parameter instance.
|
||||
* @throws IncorrectOperationException <code>name</code> is not a valid Java identifier
|
||||
* or <code>type</code> represents an invalid type.
|
||||
*/
|
||||
@NotNull
|
||||
PsiParameter createParameter(@NotNull @NonNls String name, PsiType type) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a parameter list from the specified parameter names and types.
|
||||
*
|
||||
* @param names the array of names for the parameters to create.
|
||||
* @param types the array of types for the parameters to create.
|
||||
* @return the created parameter list.
|
||||
* @throws IncorrectOperationException if some of the parameter names or types are invalid.
|
||||
*/
|
||||
@NotNull
|
||||
PsiParameterList createParameterList(@NotNull @NonNls String[] names, @NotNull PsiType[] types) throws IncorrectOperationException;
|
||||
|
||||
@NotNull
|
||||
PsiMethod createMethodFromText(String text, @Nullable PsiElement context);
|
||||
|
||||
@NotNull
|
||||
PsiAnnotation createAnnotationFromText(@NotNull @NonNls String annotationText, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.psi;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
/**
|
||||
* @author Medvedev Max
|
||||
*/
|
||||
public interface JVMElementFactoryProvider {
|
||||
JVMElementFactory getFactory(Project project);
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
/**
|
||||
* Represents a fragment of Java code which exists outside of a project structure (for example,
|
||||
* in a foreign language code or in a user interface element other than the main source code editor).
|
||||
*/
|
||||
public interface JavaCodeFragment extends PsiImportHolder, PsiCodeFragment {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the type corresponding to the <code>this</code> keyword in the code fragment.
|
||||
*
|
||||
* @return the type of <code>this</code> in the fragment.
|
||||
*/
|
||||
PsiType getThisType();
|
||||
|
||||
/**
|
||||
* Sets the type corresponding to the <code>this</code> keyword in the code fragment.
|
||||
*
|
||||
* @param psiType the type of <code>this</code> in the fragment.
|
||||
*/
|
||||
void setThisType(PsiType psiType);
|
||||
|
||||
/**
|
||||
* Returns the type corresponding to the <code>super</code> keyword in the code fragment.
|
||||
*
|
||||
* @return the type of <code>super</code> in the fragment.
|
||||
*/
|
||||
PsiType getSuperType();
|
||||
|
||||
/**
|
||||
* Sets the type corresponding to the <code>super</code> keyword in the code fragment.
|
||||
*
|
||||
* @param superType the type of <code>super</code> in the fragment.
|
||||
*/
|
||||
void setSuperType(PsiType superType);
|
||||
|
||||
/**
|
||||
* Returns the list of classes considered to be imported by the code fragment.
|
||||
*
|
||||
* @return the comma-separated list of full-qualified names of classes considered
|
||||
* to be imported.
|
||||
*/
|
||||
String importsToString();
|
||||
|
||||
/**
|
||||
* Adds the specified classes to the list of classes considered to be imported by the
|
||||
* code fragment.
|
||||
*
|
||||
* @param imports the comma-separated list of full-qualified names of classes to import.
|
||||
*/
|
||||
void addImportsFromString(String imports);
|
||||
|
||||
/**
|
||||
* Sets the visibility checker which is used to determine the visibility of declarations
|
||||
* from the code fragment.
|
||||
*
|
||||
* @param checker the checker instance.
|
||||
*/
|
||||
void setVisibilityChecker(VisibilityChecker checker);
|
||||
|
||||
/**
|
||||
* Gets the visibility checker which is used to determine the visibility of declarations
|
||||
* from the code fragment.
|
||||
*
|
||||
* @return the checker instance.
|
||||
*/
|
||||
VisibilityChecker getVisibilityChecker();
|
||||
|
||||
/**
|
||||
* Sets the exception handler which is used to determine which exceptions are considered handled
|
||||
* in the context where the fragment is used.
|
||||
*
|
||||
* @param checker the exception handler instance.
|
||||
*/
|
||||
void setExceptionHandler(ExceptionHandler checker);
|
||||
|
||||
/**
|
||||
* Gets the exception handler which is used to determine which exceptions are considered handled
|
||||
* in the context where the fragment is used.
|
||||
*
|
||||
* @return the exception handler instance.
|
||||
*/
|
||||
ExceptionHandler getExceptionHandler();
|
||||
|
||||
/**
|
||||
* Interface used to determine the visibility of declarations from the code fragment.
|
||||
*/
|
||||
interface VisibilityChecker {
|
||||
/**
|
||||
* Returns the visibility of the specified declaration from the specified location.
|
||||
*
|
||||
* @param declaration the referenced declaration.
|
||||
* @param place the location of the reference to the declaration.
|
||||
* @return the visibility of the declaraion.
|
||||
*/
|
||||
Visibility isDeclarationVisible(PsiElement declaration, PsiElement place);
|
||||
|
||||
enum Visibility {
|
||||
/**
|
||||
* The declaration is visible from the location.
|
||||
*/
|
||||
VISIBLE,
|
||||
|
||||
/**
|
||||
* The declaration is not visible from the location.
|
||||
*/
|
||||
NOT_VISIBLE,
|
||||
|
||||
/**
|
||||
* The visibility of the declaration from the location is defined by Java scoping rules.
|
||||
*/
|
||||
DEFAULT_VISIBILITY
|
||||
}
|
||||
|
||||
/**
|
||||
* The visibility checker which reports all declarations as visible.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
VisibilityChecker EVERYTHING_VISIBLE = new VisibilityChecker() {
|
||||
public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) {
|
||||
return Visibility.VISIBLE;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface used to determine which exceptions are considered handled
|
||||
* in the context where the fragment is used.
|
||||
*/
|
||||
interface ExceptionHandler {
|
||||
/**
|
||||
* Checks if the specified exception is considered handled
|
||||
* in the context where the fragment is used.
|
||||
*
|
||||
* @param exceptionType the type of the exception to check.
|
||||
* @return true if the exception is handled, false otherwise.
|
||||
*/
|
||||
boolean isHandledException(PsiClassType exceptionType);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class JavaDirectoryService {
|
||||
public static JavaDirectoryService getInstance() {
|
||||
return ServiceManager.getService(JavaDirectoryService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the package corresponding to the directory.
|
||||
*
|
||||
* @return the package instance, or null if the directory does not correspond to any package.
|
||||
*/
|
||||
@Nullable
|
||||
public abstract PsiPackage getPackage(@NotNull PsiDirectory dir);
|
||||
|
||||
/**
|
||||
* Returns the list of Java classes contained in the directory.
|
||||
*
|
||||
* @return the array of classes.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiClass[] getClasses(@NotNull PsiDirectory dir);
|
||||
|
||||
/**
|
||||
* Creates a class with the specified name in the directory.
|
||||
*
|
||||
* @param name the name of the class to create (not including the file extension).
|
||||
* @return the created class instance.
|
||||
* @throws IncorrectOperationException if the operation failed for some reason.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiClass createClass(@NotNull PsiDirectory dir, @NotNull String name) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a class with the specified name in the directory.
|
||||
*
|
||||
* @param name the name of the class to create (not including the file extension).
|
||||
* @param templateName custom file template to create class text based on.
|
||||
* @return the created class instance.
|
||||
* @throws IncorrectOperationException if the operation failed for some reason.
|
||||
* @since 5.1
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiClass createClass(@NotNull PsiDirectory dir, @NotNull String name, @NotNull String templateName) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* @param askForUndefinedVariables
|
||||
* true show dialog asking for undefined variables
|
||||
* false leave them blank
|
||||
*/
|
||||
public abstract PsiClass createClass(@NotNull PsiDirectory dir, @NotNull String name, @NotNull String templateName, boolean askForUndefinedVariables) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Checks if it's possible to create a class with the specified name in the directory,
|
||||
* and throws an exception if the creation is not possible. Does not actually modify
|
||||
* anything.
|
||||
*
|
||||
* @param name the name of the class to check creation possibility (not including the file extension).
|
||||
* @throws IncorrectOperationException if the creation is not possible.
|
||||
*/
|
||||
public abstract void checkCreateClass(@NotNull PsiDirectory dir, @NotNull String name) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an interface class with the specified name in the directory.
|
||||
*
|
||||
* @param name the name of the interface to create (not including the file extension).
|
||||
* @return the created interface instance.
|
||||
* @throws IncorrectOperationException if the operation failed for some reason.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiClass createInterface(@NotNull PsiDirectory dir, @NotNull String name) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Checks if it's possible to create an interface with the specified name in the directory,
|
||||
* and throws an exception if the creation is not possible. Does not actually modify
|
||||
* anything.
|
||||
*
|
||||
* @param name the name of the interface to check creation possibility (not including the file extension).
|
||||
* @throws IncorrectOperationException if the creation is not possible.
|
||||
*/
|
||||
public abstract void checkCreateInterface(@NotNull PsiDirectory dir, @NotNull String name) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an enumeration class with the specified name in the directory.
|
||||
*
|
||||
* @param name the name of the enumeration class to create (not including the file extension).
|
||||
* @return the created class instance.
|
||||
* @throws IncorrectOperationException if the operation failed for some reason.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiClass createEnum(@NotNull PsiDirectory dir, @NotNull String name) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an annotation class with the specified name in the directory.
|
||||
*
|
||||
* @param name the name of the annotation class to create (not including the file extension).
|
||||
* @return the created class instance.
|
||||
* @throws IncorrectOperationException if the operation failed for some reason.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiClass createAnnotationType(@NotNull PsiDirectory dir, @NotNull String name) throws IncorrectOperationException;
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the directory is a source root for the project to which it belongs.
|
||||
*
|
||||
* @return true if the directory is a source root, false otherwise
|
||||
*/
|
||||
public abstract boolean isSourceRoot(@NotNull PsiDirectory dir);
|
||||
|
||||
public abstract LanguageLevel getLanguageLevel(@NotNull PsiDirectory dir);
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.tree.java.IJavaDocElementType;
|
||||
|
||||
|
||||
public interface JavaDocTokenType {
|
||||
IElementType DOC_COMMENT_START = new IJavaDocElementType("DOC_COMMENT_START");
|
||||
IElementType DOC_COMMENT_END = new IJavaDocElementType("DOC_COMMENT_END");
|
||||
IElementType DOC_COMMENT_DATA = new IJavaDocElementType("DOC_COMMENT_DATA");
|
||||
IElementType DOC_SPACE = new IJavaDocElementType("DOC_SPACE");
|
||||
IElementType DOC_COMMENT_LEADING_ASTERISKS = new IJavaDocElementType("DOC_COMMENT_LEADING_ASTERISKS");
|
||||
IElementType DOC_TAG_NAME = new IJavaDocElementType("DOC_TAG_NAME");
|
||||
IElementType DOC_INLINE_TAG_START = new IJavaDocElementType("DOC_INLINE_TAG_START");
|
||||
IElementType DOC_INLINE_TAG_END = new IJavaDocElementType("DOC_INLINE_TAG_END");
|
||||
|
||||
IElementType DOC_TAG_VALUE_TOKEN = new IJavaDocElementType("DOC_TAG_VALUE_TOKEN");
|
||||
IElementType DOC_TAG_VALUE_DOT = new IJavaDocElementType("DOC_TAG_VALUE_DOT");
|
||||
IElementType DOC_TAG_VALUE_COMMA = new IJavaDocElementType("DOC_TAG_VALUE_COMMA");
|
||||
IElementType DOC_TAG_VALUE_LPAREN = new IJavaDocElementType("DOC_TAG_VALUE_LPAREN");
|
||||
IElementType DOC_TAG_VALUE_RPAREN = new IJavaDocElementType("DOC_TAG_VALUE_RPAREN");
|
||||
/** @since 5.0.1 */
|
||||
IElementType DOC_TAG_VALUE_LT = new IJavaDocElementType("DOC_TAG_VALUE_LT");
|
||||
/** @since 5.0.1 */
|
||||
IElementType DOC_TAG_VALUE_GT = new IJavaDocElementType("DOC_TAG_VALUE_GT");
|
||||
IElementType DOC_TAG_VALUE_SHARP_TOKEN = new IJavaDocElementType("DOC_TAG_VALUE_SHARP_TOKEN");
|
||||
|
||||
IElementType DOC_COMMENT_BAD_CHARACTER = new IJavaDocElementType("DOC_COMMENT_BAD_CHARACTER");
|
||||
|
||||
TokenSet ALL_JAVADOC_TOKENS = TokenSet.create(
|
||||
DOC_COMMENT_START, DOC_COMMENT_END, DOC_COMMENT_DATA, DOC_SPACE, DOC_COMMENT_LEADING_ASTERISKS, DOC_TAG_NAME,
|
||||
DOC_INLINE_TAG_START, DOC_INLINE_TAG_END, DOC_TAG_VALUE_TOKEN, DOC_TAG_VALUE_DOT, DOC_TAG_VALUE_COMMA,
|
||||
DOC_TAG_VALUE_LPAREN, DOC_TAG_VALUE_RPAREN, DOC_TAG_VALUE_SHARP_TOKEN
|
||||
);
|
||||
}
|
||||
@@ -1,374 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.psi.javadoc.*;
|
||||
|
||||
@SuppressWarnings({"JavaDoc"})
|
||||
public abstract class JavaElementVisitor extends PsiElementVisitor {
|
||||
|
||||
public void visitAnonymousClass(PsiAnonymousClass aClass) {
|
||||
visitClass(aClass);
|
||||
}
|
||||
|
||||
public void visitArrayAccessExpression(PsiArrayAccessExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
public void visitArrayInitializerExpression(PsiArrayInitializerExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
public void visitAssertStatement(PsiAssertStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitAssignmentExpression(PsiAssignmentExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
public void visitBinaryExpression(PsiBinaryExpression expression) {
|
||||
visitPolyadicExpression(expression);
|
||||
}
|
||||
|
||||
public void visitBlockStatement(PsiBlockStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitBreakStatement(PsiBreakStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitClass(PsiClass aClass) {
|
||||
visitElement(aClass);
|
||||
}
|
||||
|
||||
public void visitClassInitializer(PsiClassInitializer initializer) {
|
||||
visitElement(initializer);
|
||||
}
|
||||
|
||||
public void visitClassObjectAccessExpression(PsiClassObjectAccessExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
public void visitCodeBlock(PsiCodeBlock block) {
|
||||
visitElement(block);
|
||||
}
|
||||
|
||||
public void visitConditionalExpression(PsiConditionalExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
public void visitContinueStatement(PsiContinueStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitDeclarationStatement(PsiDeclarationStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitDocComment(PsiDocComment comment) {
|
||||
visitComment(comment);
|
||||
}
|
||||
|
||||
public void visitDocTag(PsiDocTag tag) {
|
||||
visitElement(tag);
|
||||
}
|
||||
|
||||
public void visitDocTagValue(PsiDocTagValue value) {
|
||||
visitElement(value);
|
||||
}
|
||||
|
||||
public void visitDoWhileStatement(PsiDoWhileStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitEmptyStatement(PsiEmptyStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitExpression(PsiExpression expression) {
|
||||
visitElement(expression);
|
||||
}
|
||||
|
||||
public void visitExpressionList(PsiExpressionList list) {
|
||||
visitElement(list);
|
||||
}
|
||||
|
||||
public void visitExpressionListStatement(PsiExpressionListStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitExpressionStatement(PsiExpressionStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitField(PsiField field) {
|
||||
visitVariable(field);
|
||||
}
|
||||
|
||||
public void visitForStatement(PsiForStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitForeachStatement(PsiForeachStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitIdentifier(PsiIdentifier identifier) {
|
||||
visitJavaToken(identifier);
|
||||
}
|
||||
|
||||
public void visitIfStatement(PsiIfStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitImportList(PsiImportList list) {
|
||||
visitElement(list);
|
||||
}
|
||||
|
||||
public void visitImportStatement(PsiImportStatement statement) {
|
||||
visitElement(statement);
|
||||
}
|
||||
|
||||
public void visitImportStaticStatement(PsiImportStaticStatement statement) {
|
||||
visitElement(statement);
|
||||
}
|
||||
|
||||
public void visitInlineDocTag(PsiInlineDocTag tag) {
|
||||
visitDocTag(tag);
|
||||
}
|
||||
|
||||
public void visitInstanceOfExpression(PsiInstanceOfExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
public void visitJavaToken(PsiJavaToken token){
|
||||
visitElement(token);
|
||||
}
|
||||
|
||||
public void visitKeyword(PsiKeyword keyword) {
|
||||
visitJavaToken(keyword);
|
||||
}
|
||||
|
||||
public void visitLabeledStatement(PsiLabeledStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitLiteralExpression(PsiLiteralExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
public void visitLocalVariable(PsiLocalVariable variable) {
|
||||
visitVariable(variable);
|
||||
}
|
||||
|
||||
public void visitMethod(PsiMethod method) {
|
||||
visitElement(method);
|
||||
}
|
||||
|
||||
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
|
||||
visitCallExpression(expression);
|
||||
}
|
||||
|
||||
public void visitCallExpression(PsiCallExpression callExpression) {
|
||||
visitExpression(callExpression);
|
||||
}
|
||||
|
||||
public void visitModifierList(PsiModifierList list) {
|
||||
visitElement(list);
|
||||
}
|
||||
|
||||
public void visitNewExpression(PsiNewExpression expression) {
|
||||
visitCallExpression(expression);
|
||||
}
|
||||
|
||||
public void visitPackage(PsiPackage aPackage) {
|
||||
visitElement(aPackage);
|
||||
}
|
||||
|
||||
public void visitPackageStatement(PsiPackageStatement statement) {
|
||||
visitElement(statement);
|
||||
}
|
||||
|
||||
public void visitParameter(PsiParameter parameter) {
|
||||
visitVariable(parameter);
|
||||
}
|
||||
|
||||
public void visitParameterList(PsiParameterList list) {
|
||||
visitElement(list);
|
||||
}
|
||||
|
||||
public void visitParenthesizedExpression(PsiParenthesizedExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
public void visitPostfixExpression(PsiPostfixExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
public void visitPrefixExpression(PsiPrefixExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
|
||||
visitElement(reference);
|
||||
}
|
||||
|
||||
public void visitImportStaticReferenceElement(PsiImportStaticReferenceElement reference) {
|
||||
visitElement(reference);
|
||||
}
|
||||
|
||||
/**
|
||||
* PsiReferenceExpression is PsiReferenceElement and PsiExpression at the same time.
|
||||
* If we'd call both visitReferenceElement and visitExpression in default implementation
|
||||
* of this method we can easily stuck with exponential algorithm if the derived visitor
|
||||
* extends visitElement() and accepts children there.
|
||||
* PsiRecursiveElement visitor works that around and implements this method accordingly.
|
||||
* All other visitor must decide themselves what implementation (visitReferenceElement() or visitExpression() or none or LOG.error())
|
||||
* is appropriate for them.
|
||||
* @param expression
|
||||
*/
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {}
|
||||
|
||||
public void visitReferenceList(PsiReferenceList list) {
|
||||
visitElement(list);
|
||||
}
|
||||
|
||||
public void visitReferenceParameterList(PsiReferenceParameterList list) {
|
||||
visitElement(list);
|
||||
}
|
||||
|
||||
public void visitTypeParameterList(PsiTypeParameterList list) {
|
||||
visitElement(list);
|
||||
}
|
||||
|
||||
public void visitReturnStatement(PsiReturnStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitStatement(PsiStatement statement) {
|
||||
visitElement(statement);
|
||||
}
|
||||
|
||||
public void visitSuperExpression(PsiSuperExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
public void visitSwitchLabelStatement(PsiSwitchLabelStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitSwitchStatement(PsiSwitchStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitSynchronizedStatement(PsiSynchronizedStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitThisExpression(PsiThisExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
public void visitThrowStatement(PsiThrowStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitTryStatement(PsiTryStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitCatchSection(PsiCatchSection section) {
|
||||
visitElement(section);
|
||||
}
|
||||
|
||||
public void visitResourceList(PsiResourceList resourceList) {
|
||||
visitElement(resourceList);
|
||||
}
|
||||
|
||||
public void visitResourceVariable(PsiResourceVariable resourceVariable) {
|
||||
visitLocalVariable(resourceVariable);
|
||||
}
|
||||
|
||||
public void visitTypeElement(PsiTypeElement type) {
|
||||
visitElement(type);
|
||||
}
|
||||
|
||||
public void visitTypeCastExpression(PsiTypeCastExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
|
||||
public void visitVariable(PsiVariable variable) {
|
||||
visitElement(variable);
|
||||
}
|
||||
|
||||
public void visitWhileStatement(PsiWhileStatement statement) {
|
||||
visitStatement(statement);
|
||||
}
|
||||
|
||||
public void visitJavaFile(PsiJavaFile file){
|
||||
visitFile(file);
|
||||
}
|
||||
|
||||
public void visitImplicitVariable(ImplicitVariable variable) {
|
||||
visitLocalVariable(variable);
|
||||
}
|
||||
|
||||
public void visitDocToken(PsiDocToken token) {
|
||||
visitElement(token);
|
||||
}
|
||||
|
||||
public void visitTypeParameter(PsiTypeParameter classParameter) {
|
||||
visitClass(classParameter);
|
||||
}
|
||||
|
||||
public void visitAnnotation(PsiAnnotation annotation) {
|
||||
visitElement(annotation);
|
||||
}
|
||||
|
||||
public void visitAnnotationParameterList(PsiAnnotationParameterList list) {
|
||||
visitElement(list);
|
||||
}
|
||||
|
||||
public void visitAnnotationArrayInitializer(PsiArrayInitializerMemberValue initializer) {
|
||||
visitElement(initializer);
|
||||
}
|
||||
|
||||
public void visitNameValuePair(PsiNameValuePair pair) {
|
||||
visitElement(pair);
|
||||
}
|
||||
|
||||
public void visitAnnotationMethod(PsiAnnotationMethod method) {
|
||||
visitMethod(method);
|
||||
}
|
||||
|
||||
public void visitEnumConstant(PsiEnumConstant enumConstant) {
|
||||
visitField(enumConstant);
|
||||
}
|
||||
|
||||
public void visitEnumConstantInitializer(PsiEnumConstantInitializer enumConstantInitializer) {
|
||||
visitAnonymousClass(enumConstantInitializer);
|
||||
}
|
||||
|
||||
public void visitCodeFragment(JavaCodeFragment codeFragment) {
|
||||
visitFile(codeFragment);
|
||||
}
|
||||
|
||||
public void visitPolyadicExpression(PsiPolyadicExpression expression) {
|
||||
visitExpression(expression);
|
||||
}
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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 max
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NotNullLazyKey;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class JavaPsiFacade {
|
||||
private static final NotNullLazyKey<JavaPsiFacade, Project> INSTANCE_KEY = ServiceManager.createLazyKey(JavaPsiFacade.class);
|
||||
|
||||
public static JavaPsiFacade getInstance(Project project) {
|
||||
return INSTANCE_KEY.getValue(project);
|
||||
}
|
||||
|
||||
public static PsiElementFactory getElementFactory(@NotNull Project project) {
|
||||
return getInstance(project).getElementFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the project and all its libraries for a class with the specified full-qualified
|
||||
* name and returns one if it is found.
|
||||
*
|
||||
* @param qualifiedName the full-qualified name of the class to find.
|
||||
* @return the PSI class, or null if no class with such name is found.
|
||||
* @deprecated use {@link #findClass(String, com.intellij.psi.search.GlobalSearchScope)}
|
||||
*/
|
||||
@Nullable
|
||||
public abstract PsiClass findClass(@NotNull @NonNls String qualifiedName);
|
||||
|
||||
|
||||
/**
|
||||
* Searches the specified scope within the project for a class with the specified full-qualified
|
||||
* name and returns one if it is found.
|
||||
*
|
||||
* @param qualifiedName the full-qualified name of the class to find.
|
||||
* @param scope the scope to search.
|
||||
* @return the PSI class, or null if no class with such name is found.
|
||||
*/
|
||||
@Nullable
|
||||
public abstract PsiClass findClass(@NonNls @NotNull String qualifiedName, @NotNull GlobalSearchScope scope);
|
||||
|
||||
|
||||
/**
|
||||
* Searches the specified scope within the project for classes with the specified full-qualified
|
||||
* name and returns all found classes.
|
||||
*
|
||||
* @param qualifiedName the full-qualified name of the class to find.
|
||||
* @param scope the scope to search.
|
||||
* @return the array of found classes, or an empty array if no classes are found.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiClass[] findClasses(@NonNls @NotNull String qualifiedName, @NotNull GlobalSearchScope scope);
|
||||
|
||||
/**
|
||||
* Searches the project for the package with the specified full-qualified name and returns one
|
||||
* if it is found.
|
||||
*
|
||||
* @param qualifiedName the full-qualified name of the package to find.
|
||||
* @return the PSI package, or null if no package with such name is found.
|
||||
*/
|
||||
@Nullable
|
||||
public abstract PsiPackage findPackage(@NonNls @NotNull String qualifiedName);
|
||||
|
||||
/**
|
||||
* Returns the element factory for the project, which can be used to
|
||||
* create instances of Java and XML PSI elements.
|
||||
*
|
||||
* @return the element factory instance.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiElementFactory getElementFactory();
|
||||
|
||||
/**
|
||||
* Returns the factory for the project, which can be used to create instances of certain java constructs from their textual
|
||||
* presentation. Elements created shall not be used to later interfer (like insert into) a PSI parsed from the user codebase
|
||||
* since no formatting to the user codestyle will be performed in this case. Please use {@link #getElementFactory()} instead, which
|
||||
* provides exactly same methods but ensures created instances will get properly formatted.
|
||||
* @return the parser facade.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiJavaParserFacade getParserFacade();
|
||||
|
||||
/**
|
||||
* Returns the resolve helper for the project, which can be used to resolve references
|
||||
* and check accessibility of elements.
|
||||
*
|
||||
* @return the resolve helper instance.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiResolveHelper getResolveHelper();
|
||||
|
||||
/**
|
||||
* Initiates a migrate refactoring. The refactoring is finished when
|
||||
* {@link com.intellij.psi.PsiMigration#finish()} is called.
|
||||
*
|
||||
* @return the migrate operation object.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiMigration startMigration();
|
||||
|
||||
/**
|
||||
* Returns the name helper for the project, which can be used to validate
|
||||
* and parse Java identifiers.
|
||||
*
|
||||
* @return the name helper instance.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiNameHelper getNameHelper();
|
||||
|
||||
/**
|
||||
* Returns the constant expression evaluator for the project.
|
||||
*
|
||||
* @return the evaluator instance.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiConstantEvaluationHelper getConstantEvaluationHelper();
|
||||
|
||||
/**
|
||||
* Checks if the specified package name is part of the package prefix for
|
||||
* any of the modules in this project.
|
||||
*
|
||||
* @param packageName the package name to check.
|
||||
* @return true if it is part of the package prefix, false otherwise.
|
||||
*/
|
||||
public abstract boolean isPartOfPackagePrefix(String packageName);
|
||||
|
||||
/**
|
||||
* Checks if the specified PSI element belongs to the specified package.
|
||||
*
|
||||
* @param element the element to check the package for.
|
||||
* @param aPackage the package to check.
|
||||
* @return true if the element belongs to the package, false otherwise.
|
||||
*/
|
||||
public abstract boolean isInPackage(@NotNull PsiElement element, @NotNull PsiPackage aPackage);
|
||||
|
||||
/**
|
||||
* Checks if the specified PSI elements belong to the same package.
|
||||
*
|
||||
* @param element1 the first element to check.
|
||||
* @param element2 the second element to check.
|
||||
* @return true if the elements are in the same package, false otherwise.
|
||||
*/
|
||||
public abstract boolean arePackagesTheSame(@NotNull PsiElement element1, @NotNull PsiElement element2);
|
||||
|
||||
public abstract Project getProject();
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.util.containers.Stack;
|
||||
|
||||
public abstract class JavaRecursiveElementVisitor extends JavaElementVisitor {
|
||||
// This stack thing is intended to prevent exponential child traversing due to visitReferenceExpression calls both visitRefElement
|
||||
// and visitExpression.
|
||||
private final Stack<PsiReferenceExpression> myRefExprsInVisit = new Stack<PsiReferenceExpression>();
|
||||
private final Stack<PsiBinaryExpression> myBinaryExpressions = new Stack<PsiBinaryExpression>();
|
||||
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
if (!myRefExprsInVisit.isEmpty() && myRefExprsInVisit.peek() == element) {
|
||||
myRefExprsInVisit.pop();
|
||||
myRefExprsInVisit.push(null);
|
||||
}
|
||||
else if (element instanceof PsiBinaryExpression) {
|
||||
//implement smart traversing to avoid stack overflow
|
||||
if (!myBinaryExpressions.isEmpty() && myBinaryExpressions.peek() == element) {
|
||||
return;
|
||||
}
|
||||
PsiElement child = element.getFirstChild();
|
||||
while (child != null) {
|
||||
if (child instanceof PsiBinaryExpression) {
|
||||
myBinaryExpressions.push((PsiBinaryExpression)child);
|
||||
}
|
||||
child.accept(this);
|
||||
child = child.getNextSibling();
|
||||
if (child == null) {
|
||||
child = myBinaryExpressions.isEmpty() ? null : myBinaryExpressions.pop();
|
||||
if (child != null) child = child.getFirstChild();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
element.acceptChildren(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
myRefExprsInVisit.push(expression);
|
||||
try {
|
||||
visitExpression(expression);
|
||||
visitReferenceElement(expression);
|
||||
}
|
||||
finally {
|
||||
myRefExprsInVisit.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class JavaRecursiveElementWalkingVisitor extends JavaElementVisitor {
|
||||
private final PsiWalkingState myWalkingState = new PsiWalkingState(this){
|
||||
public void elementFinished(@NotNull PsiElement element) {
|
||||
JavaRecursiveElementWalkingVisitor.this.elementFinished(element);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
myWalkingState.elementStarted(element);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
protected void elementFinished(PsiElement element) {
|
||||
}
|
||||
|
||||
@Override public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
visitExpression(expression);
|
||||
myWalkingState.startedWalking(); // do not traverse from scratch
|
||||
visitReferenceElement(expression);
|
||||
}
|
||||
|
||||
public void stopWalking() {
|
||||
myWalkingState.stopWalking();
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
/**
|
||||
* JavaResolveResult holds additional information that is obtained
|
||||
* when Java references are being resolved
|
||||
*
|
||||
* @author ik, dsl
|
||||
* @see com.intellij.psi.PsiCall#resolveMethodGenerics()
|
||||
*/
|
||||
public interface JavaResolveResult extends ResolveResult {
|
||||
JavaResolveResult[] EMPTY_ARRAY = new JavaResolveResult[0];
|
||||
|
||||
/**
|
||||
* Substitutor providing values of type parameters occuring
|
||||
* in {@link #getElement()}.
|
||||
*/
|
||||
PsiSubstitutor getSubstitutor();
|
||||
|
||||
boolean isPackagePrefixPackageReference();
|
||||
|
||||
/**
|
||||
* @return true if {@link #getElement()} is accessible from reference.
|
||||
*
|
||||
*/
|
||||
boolean isAccessible();
|
||||
|
||||
boolean isStaticsScopeCorrect();
|
||||
|
||||
/**
|
||||
* @return scope in the reference's file where the reference has been resolved
|
||||
* null for qualified and local references
|
||||
*/
|
||||
PsiElement getCurrentFileResolveScope();
|
||||
|
||||
|
||||
JavaResolveResult EMPTY = new JavaResolveResult(){
|
||||
public PsiElement getElement(){return null;}
|
||||
public PsiSubstitutor getSubstitutor(){return PsiSubstitutor.EMPTY;}
|
||||
public boolean isValidResult(){return false;}
|
||||
public boolean isAccessible(){return false;}
|
||||
public boolean isStaticsScopeCorrect(){return false;}
|
||||
public PsiElement getCurrentFileResolveScope() { return null; }
|
||||
|
||||
public boolean isPackagePrefixPackageReference() { return false; }
|
||||
};
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.tree.java.IJavaElementType;
|
||||
import com.intellij.psi.tree.java.IKeywordElementType;
|
||||
|
||||
|
||||
public interface JavaTokenType extends TokenType{
|
||||
IElementType IDENTIFIER = new IJavaElementType("IDENTIFIER");
|
||||
IElementType C_STYLE_COMMENT = new IJavaElementType("C_STYLE_COMMENT");
|
||||
IElementType END_OF_LINE_COMMENT = new IJavaElementType("END_OF_LINE_COMMENT");
|
||||
|
||||
IElementType INTEGER_LITERAL = new IJavaElementType("INTEGER_LITERAL");
|
||||
IElementType LONG_LITERAL = new IJavaElementType("LONG_LITERAL");
|
||||
IElementType FLOAT_LITERAL = new IJavaElementType("FLOAT_LITERAL");
|
||||
IElementType DOUBLE_LITERAL = new IJavaElementType("DOUBLE_LITERAL");
|
||||
IElementType CHARACTER_LITERAL = new IJavaElementType("CHARACTER_LITERAL");
|
||||
IElementType STRING_LITERAL = new IJavaElementType("STRING_LITERAL");
|
||||
|
||||
IElementType TRUE_KEYWORD = new IKeywordElementType("TRUE_KEYWORD");
|
||||
IElementType FALSE_KEYWORD = new IKeywordElementType("FALSE_KEYWORD");
|
||||
IElementType NULL_KEYWORD = new IKeywordElementType("NULL_KEYWORD");
|
||||
|
||||
IElementType ABSTRACT_KEYWORD = new IKeywordElementType("ABSTRACT_KEYWORD");
|
||||
IElementType ASSERT_KEYWORD = new IKeywordElementType("ASSERT_KEYWORD");
|
||||
IElementType BOOLEAN_KEYWORD = new IKeywordElementType("BOOLEAN_KEYWORD");
|
||||
IElementType BREAK_KEYWORD = new IKeywordElementType("BREAK_KEYWORD");
|
||||
IElementType BYTE_KEYWORD = new IKeywordElementType("BYTE_KEYWORD");
|
||||
IElementType CASE_KEYWORD = new IKeywordElementType("CASE_KEYWORD");
|
||||
IElementType CATCH_KEYWORD = new IKeywordElementType("CATCH_KEYWORD");
|
||||
IElementType CHAR_KEYWORD = new IKeywordElementType("CHAR_KEYWORD");
|
||||
IElementType CLASS_KEYWORD = new IKeywordElementType("CLASS_KEYWORD");
|
||||
IElementType CONST_KEYWORD = new IKeywordElementType("CONST_KEYWORD");
|
||||
IElementType CONTINUE_KEYWORD = new IKeywordElementType("CONTINUE_KEYWORD");
|
||||
IElementType DEFAULT_KEYWORD = new IKeywordElementType("DEFAULT_KEYWORD");
|
||||
IElementType DO_KEYWORD = new IKeywordElementType("DO_KEYWORD");
|
||||
IElementType DOUBLE_KEYWORD = new IKeywordElementType("DOUBLE_KEYWORD");
|
||||
IElementType ELSE_KEYWORD = new IKeywordElementType("ELSE_KEYWORD");
|
||||
IElementType ENUM_KEYWORD = new IKeywordElementType("ENUM_KEYWORD");
|
||||
IElementType EXTENDS_KEYWORD = new IKeywordElementType("EXTENDS_KEYWORD");
|
||||
IElementType FINAL_KEYWORD = new IKeywordElementType("FINAL_KEYWORD");
|
||||
IElementType FINALLY_KEYWORD = new IKeywordElementType("FINALLY_KEYWORD");
|
||||
IElementType FLOAT_KEYWORD = new IKeywordElementType("FLOAT_KEYWORD");
|
||||
IElementType FOR_KEYWORD = new IKeywordElementType("FOR_KEYWORD");
|
||||
IElementType GOTO_KEYWORD = new IKeywordElementType("GOTO_KEYWORD");
|
||||
IElementType IF_KEYWORD = new IKeywordElementType("IF_KEYWORD");
|
||||
IElementType IMPLEMENTS_KEYWORD = new IKeywordElementType("IMPLEMENTS_KEYWORD");
|
||||
IElementType IMPORT_KEYWORD = new IKeywordElementType("IMPORT_KEYWORD");
|
||||
IElementType INSTANCEOF_KEYWORD = new IKeywordElementType("INSTANCEOF_KEYWORD");
|
||||
IElementType INT_KEYWORD = new IKeywordElementType("INT_KEYWORD");
|
||||
IElementType INTERFACE_KEYWORD = new IKeywordElementType("INTERFACE_KEYWORD");
|
||||
IElementType LONG_KEYWORD = new IKeywordElementType("LONG_KEYWORD");
|
||||
IElementType NATIVE_KEYWORD = new IKeywordElementType("NATIVE_KEYWORD");
|
||||
IElementType NEW_KEYWORD = new IKeywordElementType("NEW_KEYWORD");
|
||||
IElementType PACKAGE_KEYWORD = new IKeywordElementType("PACKAGE_KEYWORD");
|
||||
IElementType PRIVATE_KEYWORD = new IKeywordElementType("PRIVATE_KEYWORD");
|
||||
IElementType PUBLIC_KEYWORD = new IKeywordElementType("PUBLIC_KEYWORD");
|
||||
IElementType SHORT_KEYWORD = new IKeywordElementType("SHORT_KEYWORD");
|
||||
IElementType SUPER_KEYWORD = new IKeywordElementType("SUPER_KEYWORD");
|
||||
IElementType SWITCH_KEYWORD = new IKeywordElementType("SWITCH_KEYWORD");
|
||||
IElementType SYNCHRONIZED_KEYWORD = new IKeywordElementType("SYNCHRONIZED_KEYWORD");
|
||||
IElementType THIS_KEYWORD = new IKeywordElementType("THIS_KEYWORD");
|
||||
IElementType THROW_KEYWORD = new IKeywordElementType("THROW_KEYWORD");
|
||||
IElementType PROTECTED_KEYWORD = new IKeywordElementType("PROTECTED_KEYWORD");
|
||||
IElementType TRANSIENT_KEYWORD = new IKeywordElementType("TRANSIENT_KEYWORD");
|
||||
IElementType RETURN_KEYWORD = new IKeywordElementType("RETURN_KEYWORD");
|
||||
IElementType VOID_KEYWORD = new IKeywordElementType("VOID_KEYWORD");
|
||||
IElementType STATIC_KEYWORD = new IKeywordElementType("STATIC_KEYWORD");
|
||||
IElementType STRICTFP_KEYWORD = new IKeywordElementType("STRICTFP_KEYWORD");
|
||||
IElementType WHILE_KEYWORD = new IKeywordElementType("WHILE_KEYWORD");
|
||||
IElementType TRY_KEYWORD = new IKeywordElementType("TRY_KEYWORD");
|
||||
IElementType VOLATILE_KEYWORD = new IKeywordElementType("VOLATILE_KEYWORD");
|
||||
IElementType THROWS_KEYWORD = new IKeywordElementType("THROWS_KEYWORD");
|
||||
|
||||
IElementType LPARENTH = new IJavaElementType("LPARENTH");
|
||||
IElementType RPARENTH = new IJavaElementType("RPARENTH");
|
||||
IElementType LBRACE = new IJavaElementType("LBRACE");
|
||||
IElementType RBRACE = new IJavaElementType("RBRACE");
|
||||
IElementType LBRACKET = new IJavaElementType("LBRACKET");
|
||||
IElementType RBRACKET = new IJavaElementType("RBRACKET");
|
||||
IElementType SEMICOLON = new IJavaElementType("SEMICOLON");
|
||||
IElementType COMMA = new IJavaElementType("COMMA");
|
||||
IElementType DOT = new IJavaElementType("DOT");
|
||||
IElementType ELLIPSIS = new IJavaElementType("ELLIPSIS");
|
||||
IElementType AT = new IJavaElementType("AT");
|
||||
|
||||
IElementType EQ = new IJavaElementType("EQ");
|
||||
IElementType GT = new IJavaElementType("GT");
|
||||
IElementType LT = new IJavaElementType("LT");
|
||||
IElementType EXCL = new IJavaElementType("EXCL");
|
||||
IElementType TILDE = new IJavaElementType("TILDE");
|
||||
IElementType QUEST = new IJavaElementType("QUEST");
|
||||
IElementType COLON = new IJavaElementType("COLON");
|
||||
IElementType PLUS = new IJavaElementType("PLUS");
|
||||
IElementType MINUS = new IJavaElementType("MINUS");
|
||||
IElementType ASTERISK = new IJavaElementType("ASTERISK");
|
||||
IElementType DIV = new IJavaElementType("DIV");
|
||||
IElementType AND = new IJavaElementType("AND");
|
||||
IElementType OR = new IJavaElementType("OR");
|
||||
IElementType XOR = new IJavaElementType("XOR");
|
||||
IElementType PERC = new IJavaElementType("PERC");
|
||||
|
||||
IElementType EQEQ = new IJavaElementType("EQEQ");
|
||||
IElementType LE = new IJavaElementType("LE");
|
||||
IElementType GE = new IJavaElementType("GE");
|
||||
IElementType NE = new IJavaElementType("NE");
|
||||
IElementType ANDAND = new IJavaElementType("ANDAND");
|
||||
IElementType OROR = new IJavaElementType("OROR");
|
||||
IElementType PLUSPLUS = new IJavaElementType("PLUSPLUS");
|
||||
IElementType MINUSMINUS = new IJavaElementType("MINUSMINUS");
|
||||
IElementType LTLT = new IJavaElementType("LTLT");
|
||||
IElementType GTGT = new IJavaElementType("GTGT");
|
||||
IElementType GTGTGT = new IJavaElementType("GTGTGT");
|
||||
IElementType PLUSEQ = new IJavaElementType("PLUSEQ");
|
||||
IElementType MINUSEQ = new IJavaElementType("MINUSEQ");
|
||||
IElementType ASTERISKEQ = new IJavaElementType("ASTERISKEQ");
|
||||
IElementType DIVEQ = new IJavaElementType("DIVEQ");
|
||||
IElementType ANDEQ = new IJavaElementType("ANDEQ");
|
||||
IElementType OREQ = new IJavaElementType("OREQ");
|
||||
IElementType XOREQ = new IJavaElementType("XOREQ");
|
||||
IElementType PERCEQ = new IJavaElementType("PERCEQ");
|
||||
IElementType LTLTEQ = new IJavaElementType("LTLTEQ");
|
||||
IElementType GTGTEQ = new IJavaElementType("GTGTEQ");
|
||||
IElementType GTGTGTEQ = new IJavaElementType("GTGTGTEQ");
|
||||
|
||||
TokenSet OPERATION_BIT_SET = TokenSet.create(
|
||||
EQ, GT, LT, EXCL, TILDE, QUEST, COLON, PLUS, MINUS, ASTERISK, DIV, AND, OR, XOR,
|
||||
PERC, EQEQ, LE, GE, NE, ANDAND, OROR, PLUSPLUS, MINUSMINUS, LTLT, GTGT, GTGTGT,
|
||||
PLUSEQ, MINUSEQ, ASTERISKEQ, DIVEQ, ANDEQ, OREQ, XOREQ, PERCEQ, LTLTEQ, GTGTEQ, GTGTGTEQ
|
||||
);
|
||||
|
||||
TokenSet KEYWORD_BIT_SET = TokenSet.create(
|
||||
ABSTRACT_KEYWORD, ASSERT_KEYWORD, BOOLEAN_KEYWORD, BREAK_KEYWORD, BYTE_KEYWORD, CASE_KEYWORD,
|
||||
CATCH_KEYWORD, CHAR_KEYWORD, CLASS_KEYWORD, CONST_KEYWORD, CONTINUE_KEYWORD,
|
||||
DEFAULT_KEYWORD, DO_KEYWORD, DOUBLE_KEYWORD, ELSE_KEYWORD, ENUM_KEYWORD, EXTENDS_KEYWORD,
|
||||
FINAL_KEYWORD, FINALLY_KEYWORD, FLOAT_KEYWORD, FOR_KEYWORD, GOTO_KEYWORD,
|
||||
IF_KEYWORD, IMPLEMENTS_KEYWORD, IMPORT_KEYWORD, INSTANCEOF_KEYWORD, INT_KEYWORD,
|
||||
INTERFACE_KEYWORD, LONG_KEYWORD, NATIVE_KEYWORD, NEW_KEYWORD, PACKAGE_KEYWORD,
|
||||
PRIVATE_KEYWORD, PROTECTED_KEYWORD, PUBLIC_KEYWORD, RETURN_KEYWORD, SHORT_KEYWORD,
|
||||
SUPER_KEYWORD, STATIC_KEYWORD, STRICTFP_KEYWORD, SWITCH_KEYWORD, SYNCHRONIZED_KEYWORD,
|
||||
THIS_KEYWORD, THROW_KEYWORD, THROWS_KEYWORD, TRANSIENT_KEYWORD, TRY_KEYWORD,
|
||||
VOID_KEYWORD, VOLATILE_KEYWORD, WHILE_KEYWORD, TRUE_KEYWORD, FALSE_KEYWORD, NULL_KEYWORD
|
||||
);
|
||||
|
||||
TokenSet MODIFIER_BIT_SET = TokenSet.create(
|
||||
PUBLIC_KEYWORD, PROTECTED_KEYWORD, PRIVATE_KEYWORD, STATIC_KEYWORD,
|
||||
ABSTRACT_KEYWORD, FINAL_KEYWORD, NATIVE_KEYWORD, STRICTFP_KEYWORD,
|
||||
SYNCHRONIZED_KEYWORD, TRANSIENT_KEYWORD, VOLATILE_KEYWORD
|
||||
);
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.intellij.lang.annotations.Pattern;
|
||||
|
||||
@Pattern(PsiModifier.PUBLIC
|
||||
+ "|" + PsiModifier.PROTECTED
|
||||
+ "|" + PsiModifier.PRIVATE
|
||||
+ "|" + PsiModifier.ABSTRACT
|
||||
+ "|" + PsiModifier.FINAL
|
||||
+ "|" + PsiModifier.NATIVE
|
||||
+ "|" + PsiModifier.PACKAGE_LOCAL
|
||||
+ "|" + PsiModifier.STATIC
|
||||
+ "|" + PsiModifier.STRICTFP
|
||||
+ "|" + PsiModifier.SYNCHRONIZED
|
||||
+ "|" + PsiModifier.TRANSIENT
|
||||
+ "|" + PsiModifier.VOLATILE
|
||||
)
|
||||
/**
|
||||
* Represents Java member modifier.
|
||||
* When String method or variable is annotated with this,
|
||||
* the corresponding value must be one of the string constants defined in {@link com.intellij.psi.PsiModifier}
|
||||
*/
|
||||
public @interface Modifier {
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.psi;
|
||||
|
||||
import com.intellij.psi.meta.PsiMetaOwner;
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java annotation.
|
||||
*
|
||||
* @author ven
|
||||
*/
|
||||
public interface PsiAnnotation extends PsiAnnotationMemberValue, PsiMetaOwner {
|
||||
/**
|
||||
* The empty array of PSI annotations which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiAnnotation[] EMPTY_ARRAY = new PsiAnnotation[0];
|
||||
|
||||
ArrayFactory<PsiAnnotation> ARRAY_FACTORY = new ArrayFactory<PsiAnnotation>() {
|
||||
public PsiAnnotation[] create(final int count) {
|
||||
return count == 0 ? EMPTY_ARRAY : new PsiAnnotation[count];
|
||||
}
|
||||
};
|
||||
|
||||
@NonNls String DEFAULT_REFERENCED_METHOD_NAME = "value";
|
||||
|
||||
/**
|
||||
* Returns the list of parameters for the annotation.
|
||||
*
|
||||
* @return the parameter list instance.
|
||||
*/
|
||||
@NotNull
|
||||
PsiAnnotationParameterList getParameterList();
|
||||
|
||||
/**
|
||||
* Returns the fully qualified name of the annotation class.
|
||||
*
|
||||
* @return the class name, or null if the annotation is unresolved.
|
||||
*/
|
||||
@Nullable
|
||||
@NonNls
|
||||
String getQualifiedName();
|
||||
|
||||
/**
|
||||
* Returns the reference element representing the name of the annotation.
|
||||
*
|
||||
* @return the annotation name element.
|
||||
*/
|
||||
@Nullable
|
||||
PsiJavaCodeReferenceElement getNameReferenceElement();
|
||||
|
||||
/**
|
||||
* Returns the value of the annotation element with the specified name.
|
||||
*
|
||||
* @param attributeName name of the annotation element for which the value is requested. If it isn't defined in annotation, tha default
|
||||
* value is returned.
|
||||
* @return the element value, or null if the annotation does not contain a value for
|
||||
* the element and the element has no default value.
|
||||
*/
|
||||
@Nullable
|
||||
PsiAnnotationMemberValue findAttributeValue(@NonNls String attributeName);
|
||||
|
||||
/**
|
||||
* Returns the value of the annotation element with the specified name.
|
||||
*
|
||||
* @param attributeName name of the annotation element for which the value is requested, declared in this annotation.
|
||||
* @return the element value, or null if the annotation does not contain a value for
|
||||
* the element.
|
||||
*/
|
||||
@Nullable
|
||||
PsiAnnotationMemberValue findDeclaredAttributeValue(@NonNls String attributeName);
|
||||
|
||||
/**
|
||||
* Set annotation attribute value. Adds new name-value pair or uses an existing one, expands unnamed 'value' attribute name if needed.
|
||||
*
|
||||
* @param attributeName attribute name
|
||||
* @param value new value template element
|
||||
* @return new declared attribute value
|
||||
*/
|
||||
<T extends PsiAnnotationMemberValue> T setDeclaredAttributeValue(@NonNls String attributeName, @Nullable T value);
|
||||
|
||||
/**
|
||||
* Returns an owner of the annotation - usually a parent, but for type annotations the owner might be a type element.
|
||||
*
|
||||
* @return annotation owner
|
||||
*/
|
||||
PsiAnnotationOwner getOwner();
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
/**
|
||||
* Represents a PSI element which can be used as the value of an annotation
|
||||
* element.
|
||||
*
|
||||
* @author ven
|
||||
*/
|
||||
public interface PsiAnnotationMemberValue extends PsiElement {
|
||||
/**
|
||||
* The empty array of PSI annotation member values which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiAnnotationMemberValue[] EMPTY_ARRAY = new PsiAnnotationMemberValue[0];
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a method which is declared on an annotation interface and
|
||||
* possibly specifies the default value of the annotation element.
|
||||
*
|
||||
* @author ven
|
||||
*/
|
||||
public interface PsiAnnotationMethod extends PsiMethod {
|
||||
/**
|
||||
* The empty array of PSI annotation methods which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiAnnotationMethod[] EMPTY_ARRAY = new PsiAnnotationMethod[0];
|
||||
|
||||
/**
|
||||
* Returns the default value of the annotation element defined by the method.
|
||||
*
|
||||
* @return the default value of the element, or null if no default value is specified.
|
||||
*/
|
||||
@Nullable
|
||||
PsiAnnotationMemberValue getDefaultValue();
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author cdr
|
||||
*/
|
||||
public interface PsiAnnotationOwner {
|
||||
/**
|
||||
* Returns the list of annotations syntactically contained in the element.
|
||||
*
|
||||
* @return the list of annotations.
|
||||
*/
|
||||
@NotNull
|
||||
PsiAnnotation[] getAnnotations();
|
||||
|
||||
|
||||
/**
|
||||
* @return the list of annotations which are applicable to this owner.
|
||||
* E.g. Type annotations on method belong to its type element, not the method.
|
||||
*/
|
||||
@NotNull
|
||||
PsiAnnotation[] getApplicableAnnotations();
|
||||
|
||||
/**
|
||||
* Searches the modifier list for an annotation with the specified fully qualified name
|
||||
* and returns one if it is found.
|
||||
*
|
||||
* @param qualifiedName the fully qualified name of the annotation to find.
|
||||
* @return the annotation instance, or null if no such annotation is found.
|
||||
*/
|
||||
@Nullable
|
||||
PsiAnnotation findAnnotation(@NotNull @NonNls String qualifiedName);
|
||||
|
||||
/**
|
||||
* Add a new annotation to this modifier list. The annotation class name will be shortened. No attributes will be defined.
|
||||
*
|
||||
* @param qualifiedName qualifiedName
|
||||
* @return newly added annotation
|
||||
*/
|
||||
@NotNull
|
||||
PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName);
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents the list of name/value elements for an annotation.
|
||||
*
|
||||
* @author ven
|
||||
* @see PsiAnnotation
|
||||
*/
|
||||
public interface PsiAnnotationParameterList extends PsiElement {
|
||||
/**
|
||||
* Returns the array of name/value elements specified on the annotation.
|
||||
*
|
||||
* @return the array of name/value pairs.
|
||||
*/
|
||||
@NotNull
|
||||
PsiNameValuePair[] getAttributes();
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Serega.Vasiliev
|
||||
*/
|
||||
public interface PsiAnnotationSupport {
|
||||
|
||||
@NotNull
|
||||
PsiLiteral createLiteralValue(@NotNull String value, @NotNull PsiElement context);
|
||||
|
||||
/*@NotNull
|
||||
PsiArrayInitializerMemberValue createArrayMemberValue(@Nullable PsiElement context);
|
||||
|
||||
@NotNull
|
||||
PsiAnnotation createAnnotation(@NotNull String qname, @Nullable PsiElement context);*/
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java anonymous class.
|
||||
*
|
||||
* @see PsiNewExpression#getAnonymousClass()
|
||||
*/
|
||||
public interface PsiAnonymousClass extends PsiClass {
|
||||
/**
|
||||
* Returns the reference element specifying the base class for the anonymous class.
|
||||
*
|
||||
* @return the reference element for the base class.
|
||||
*/
|
||||
@NotNull
|
||||
PsiJavaCodeReferenceElement getBaseClassReference();
|
||||
|
||||
/**
|
||||
* Returns the type for the base class of the anonymous class.
|
||||
*
|
||||
* @return the type for the base class.
|
||||
*/
|
||||
@NotNull
|
||||
PsiClassType getBaseClassType();
|
||||
|
||||
/**
|
||||
* Returns the list of arguments passed to the base class constructor.
|
||||
*
|
||||
* @return the argument list, or null if no argument list was specified.
|
||||
*/
|
||||
@Nullable
|
||||
PsiExpressionList getArgumentList();
|
||||
|
||||
boolean isInQualifiedNew();
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents an array access expession, for example, <code>i [1]</code>.
|
||||
*/
|
||||
public interface PsiArrayAccessExpression extends PsiExpression {
|
||||
/**
|
||||
* Returns the expression specifying the accessed array.
|
||||
*
|
||||
* @return the array expression.
|
||||
*/
|
||||
@NotNull
|
||||
PsiExpression getArrayExpression();
|
||||
|
||||
/**
|
||||
* Returns the index expression (the expression in square brackets).
|
||||
*
|
||||
* @return the index expression, or null if the array access expression is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiExpression getIndexExpression();
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents an array initializer expression.
|
||||
*
|
||||
* @see PsiNewExpression#getArrayInitializer()
|
||||
*/
|
||||
public interface PsiArrayInitializerExpression extends PsiExpression {
|
||||
/**
|
||||
* Returns the list of expressions initializing members of the array.
|
||||
*
|
||||
* @return the array of member initializer expressions.
|
||||
*/
|
||||
@NotNull
|
||||
PsiExpression[] getInitializers();
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents an array used as a value of an annotation element. For example:
|
||||
* <code>@Endorsers({"Children", "Unscrupulous dentists"})</code>
|
||||
*
|
||||
* @author ven
|
||||
*/
|
||||
public interface PsiArrayInitializerMemberValue extends PsiAnnotationMemberValue {
|
||||
/**
|
||||
* Returns the list of elements in the initializer array.
|
||||
*
|
||||
* @return the initializer array elements.
|
||||
*/
|
||||
@NotNull
|
||||
PsiAnnotationMemberValue[] getInitializers();
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents an array type.
|
||||
*
|
||||
* @author max
|
||||
*/
|
||||
public class PsiArrayType extends PsiType {
|
||||
private final PsiType myComponentType;
|
||||
|
||||
/**
|
||||
* Creates an array type with the specified component type.
|
||||
*
|
||||
* @param componentType the type of the array component.
|
||||
*/
|
||||
public PsiArrayType(@NotNull PsiType componentType) {
|
||||
this(componentType, PsiAnnotation.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
public PsiArrayType(@NotNull PsiType componentType, PsiAnnotation[] annotations) {
|
||||
super(annotations);
|
||||
myComponentType = componentType;
|
||||
}
|
||||
|
||||
public String getPresentableText() {
|
||||
return StringUtil.joinOrNull(myComponentType.getPresentableText(), "[]");
|
||||
}
|
||||
|
||||
public String getCanonicalText() {
|
||||
return StringUtil.joinOrNull(myComponentType.getCanonicalText(), "[]");
|
||||
}
|
||||
|
||||
public String getInternalCanonicalText() {
|
||||
return StringUtil.joinOrNull(myComponentType.getInternalCanonicalText(), "[]");
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return myComponentType.isValid();
|
||||
}
|
||||
|
||||
public boolean equalsToText(String text) {
|
||||
return text.endsWith("[]") && myComponentType.equalsToText(text.substring(0, text.length() - 2));
|
||||
}
|
||||
|
||||
public <A> A accept(PsiTypeVisitor<A> visitor) {
|
||||
return visitor.visitArrayType(this);
|
||||
}
|
||||
|
||||
public GlobalSearchScope getResolveScope() {
|
||||
return myComponentType.getResolveScope();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiType[] getSuperTypes() {
|
||||
final PsiType[] superTypes = myComponentType.getSuperTypes();
|
||||
final PsiType[] result = new PsiType[superTypes.length];
|
||||
for (int i = 0; i < superTypes.length; i++) {
|
||||
result[i] = superTypes[i].createArrayType();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the component type of the array.
|
||||
*
|
||||
* @return the component type instance.
|
||||
*/
|
||||
@NotNull
|
||||
public PsiType getComponentType() {
|
||||
return myComponentType;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
return obj != null && getClass().equals(obj.getClass()) && myComponentType.equals(((PsiArrayType)obj).getComponentType());
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return myComponentType.hashCode() * 3;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java <code>assert</code> statement.
|
||||
*/
|
||||
public interface PsiAssertStatement extends PsiStatement{
|
||||
/**
|
||||
* Returns the expression representing the asserted condition.
|
||||
*
|
||||
* @return the asserted conditione expression, or null if the assert statement
|
||||
* is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiExpression getAssertCondition();
|
||||
|
||||
/**
|
||||
* Returns the expression representing the description of the assert.
|
||||
*
|
||||
* @return the assert description expression, or null if none has been specified.
|
||||
*/
|
||||
@Nullable
|
||||
PsiExpression getAssertDescription();
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
|
||||
/**
|
||||
* Represents a simple assignment (<code>a=b</code>) or a compound assignment (<code>a+=1</code>) expression.
|
||||
*/
|
||||
public interface PsiAssignmentExpression extends PsiExpression {
|
||||
/**
|
||||
* Returns the expression on the left side of the assignment.
|
||||
*
|
||||
* @return the left side expression.
|
||||
*/
|
||||
@NotNull
|
||||
PsiExpression getLExpression();
|
||||
|
||||
/**
|
||||
* Returns the expression on the right side of the assignment.
|
||||
*
|
||||
* @return the right side expression, or null if the assignment
|
||||
* expression is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiExpression getRExpression();
|
||||
|
||||
/**
|
||||
* Returns the token representing the assignment operation ({@link JavaTokenType#EQ} for a simple
|
||||
* assignment, {@link JavaTokenType#PLUSEQ} etc. for a compound assignment).
|
||||
*
|
||||
* @return the assignment operation token.
|
||||
*/
|
||||
@NotNull
|
||||
PsiJavaToken getOperationSign();
|
||||
|
||||
/**
|
||||
* Returns the type of the token representing the operation performed.
|
||||
*
|
||||
* @return the token type.
|
||||
*/
|
||||
@NotNull
|
||||
IElementType getOperationTokenType();
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
|
||||
/**
|
||||
* Represents a Java binary expression (addition, multiplication and so on).
|
||||
* N.B Please use {@link PsiPolyadicExpression} instead as a more general form of an infix operator-expression.
|
||||
*/
|
||||
public interface PsiBinaryExpression extends PsiExpression, PsiPolyadicExpression {
|
||||
/**
|
||||
* Returns the left operand of the expression.
|
||||
*
|
||||
* @return the left operand.
|
||||
*/
|
||||
@NotNull
|
||||
PsiExpression getLOperand();
|
||||
|
||||
/**
|
||||
* Returns the right operand of the expression.
|
||||
*
|
||||
* @return the right operand, or null if the expression is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiExpression getROperand();
|
||||
|
||||
/**
|
||||
* Returns the token representing the operation (for example, {@link JavaTokenType#PLUS} for an
|
||||
* addition operation).
|
||||
*
|
||||
* @return the operation token.
|
||||
*/
|
||||
@NotNull
|
||||
PsiJavaToken getOperationSign();
|
||||
|
||||
/**
|
||||
* Returns the type of the token representing the operation performed.
|
||||
*
|
||||
* @return the token type.
|
||||
*/
|
||||
@NotNull
|
||||
IElementType getOperationTokenType();
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a Java block statement (sequence of statements surrounded with curly braces).
|
||||
*/
|
||||
public interface PsiBlockStatement extends PsiStatement {
|
||||
/**
|
||||
* Returns the code block representing the contents of the block statement.
|
||||
*
|
||||
* @return the code block instance.
|
||||
*/
|
||||
@NotNull
|
||||
PsiCodeBlock getCodeBlock();
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java <code>break</code> statement.
|
||||
*/
|
||||
public interface PsiBreakStatement extends PsiStatement {
|
||||
/**
|
||||
* Returns the identifier representing the label specified on the statement.
|
||||
*
|
||||
* @return the identifier for the label, or null if the statement has no label.
|
||||
*/
|
||||
@Nullable
|
||||
PsiIdentifier getLabelIdentifier();
|
||||
|
||||
/**
|
||||
* Returns the statement instance ({@link PsiForStatement}, {@link PsiSwitchStatement} etc.) representing
|
||||
* the statement out of which <code>break</code> transfers control.
|
||||
*
|
||||
* @return the statement instance, or null if the statement is not valid in the context where it is located.
|
||||
*/
|
||||
@Nullable
|
||||
PsiStatement findExitedStatement();
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents the call of a Java method or constructor or a Java enum constant..
|
||||
*
|
||||
* @author ven
|
||||
*/
|
||||
public interface PsiCall extends PsiElement {
|
||||
/**
|
||||
* Returns the list of arguments passed to the called method.
|
||||
*
|
||||
* @return the argument list, or null if the call is incomplete.
|
||||
*/
|
||||
@Nullable PsiExpressionList getArgumentList();
|
||||
|
||||
/**
|
||||
* Resolves the reference to the called method and returns the method.
|
||||
*
|
||||
* @return the called method, or null if the resolve failed.
|
||||
*/
|
||||
@Nullable PsiMethod resolveMethod();
|
||||
|
||||
/**
|
||||
* Resolves the reference to the called method and returns the resolve result
|
||||
* containing the method and the substitutor for generic type parameters.
|
||||
*
|
||||
* @return the resolve result, or {@link JavaResolveResult#EMPTY} if unresolved
|
||||
*/
|
||||
@NotNull
|
||||
JavaResolveResult resolveMethodGenerics();
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents the call of a Java method or constructor.
|
||||
*
|
||||
* @author dsl
|
||||
* @see PsiResolveHelper#getReferencedMethodCandidates(PsiCallExpression, boolean)
|
||||
*/
|
||||
public interface PsiCallExpression extends PsiExpression, PsiCall {
|
||||
/**
|
||||
* Returns the type argument list specified on the called method.
|
||||
*
|
||||
* @return the type argument list, or an empty list if no type arguments are specified.
|
||||
*/
|
||||
@NotNull
|
||||
PsiReferenceParameterList getTypeArgumentList();
|
||||
|
||||
/**
|
||||
* Returns the type arguments specified on the called method as an array.
|
||||
*
|
||||
* @return the array of type arguments, or an empty array if no type arguments are specified.
|
||||
*/
|
||||
@NotNull
|
||||
PsiType[] getTypeArguments();
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class PsiCapturedWildcardType extends PsiType {
|
||||
private final PsiWildcardType myExistential;
|
||||
private final PsiElement myContext;
|
||||
|
||||
public boolean equals(final Object o) {
|
||||
if (!(o instanceof PsiCapturedWildcardType)) return false;
|
||||
final PsiCapturedWildcardType captured = (PsiCapturedWildcardType)o;
|
||||
return myContext.equals(captured.myContext) &&
|
||||
myExistential.equals(captured.myExistential);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return myExistential.hashCode() + 31 * myContext.hashCode();
|
||||
}
|
||||
|
||||
private PsiCapturedWildcardType(PsiWildcardType existential, final PsiElement context) {
|
||||
super(PsiAnnotation.EMPTY_ARRAY);//todo
|
||||
myExistential = existential;
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
public static PsiCapturedWildcardType create(PsiWildcardType existential, final PsiElement context) {
|
||||
return new PsiCapturedWildcardType(existential, context);
|
||||
}
|
||||
|
||||
public String getPresentableText() {
|
||||
return myExistential.getPresentableText();
|
||||
}
|
||||
|
||||
public String getCanonicalText() {
|
||||
return myExistential.getCanonicalText();
|
||||
}
|
||||
|
||||
public String getInternalCanonicalText() {
|
||||
//noinspection HardCodedStringLiteral
|
||||
return "capture<" + myExistential.getInternalCanonicalText() + '>';
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return myExistential.isValid();
|
||||
}
|
||||
|
||||
public boolean equalsToText(String text) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public <A> A accept(PsiTypeVisitor<A> visitor) {
|
||||
return visitor.visitCapturedWildcardType(this);
|
||||
}
|
||||
|
||||
public GlobalSearchScope getResolveScope() {
|
||||
return myExistential.getResolveScope();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiType[] getSuperTypes() {
|
||||
return myExistential.getSuperTypes();
|
||||
}
|
||||
|
||||
public PsiType getLowerBound () {
|
||||
return myExistential.isSuper() ? myExistential.getBound() : NULL;
|
||||
}
|
||||
|
||||
public PsiType getUpperBound () {
|
||||
return myExistential.isExtends() ? myExistential.getBound() : PsiType.getJavaLangObject(myContext.getManager(), getResolveScope());
|
||||
}
|
||||
|
||||
public PsiWildcardType getWildcard() {
|
||||
return myExistential;
|
||||
}
|
||||
|
||||
public PsiElement getContext() {
|
||||
return myContext;
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a single <code>catch</code> section of a Java <code>try ... catch</code> statement.
|
||||
*
|
||||
* @author ven
|
||||
*/
|
||||
public interface PsiCatchSection extends PsiElement {
|
||||
/**
|
||||
* The empty array of PSI catch sections which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiCatchSection[] EMPTY_ARRAY = new PsiCatchSection[0];
|
||||
|
||||
/**
|
||||
* Returns the variable in which the caught exception is captured.
|
||||
*
|
||||
* @return the parameter for the called variable, or null if none is specified.
|
||||
*/
|
||||
@Nullable
|
||||
PsiParameter getParameter();
|
||||
|
||||
/**
|
||||
* Returns the code block contained in the catch section.
|
||||
*
|
||||
* @return the code block, or null if the section is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiCodeBlock getCatchBlock();
|
||||
|
||||
/**
|
||||
* Returns the type of the caught exception.
|
||||
*
|
||||
* @return the type, or null if the section is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiType getCatchType();
|
||||
|
||||
/**
|
||||
* For language level 7 or higher returns the list of possible types for its parameter re-throw
|
||||
* (as defined in Project Coin/JSR 334 section "Multi-catch and more precise rethrow").
|
||||
* Otherwise, returns parameter's declared type.
|
||||
*
|
||||
* @return the types, or empty list if the section is incomplete.
|
||||
*/
|
||||
@NotNull
|
||||
List<PsiType> getPreciseCatchTypes();
|
||||
|
||||
/**
|
||||
* Returns the <code>try</code> statement to which the catch section is attached.
|
||||
*
|
||||
* @return the statement instance.
|
||||
*/
|
||||
@NotNull
|
||||
PsiTryStatement getTryStatement();
|
||||
|
||||
@Nullable
|
||||
PsiJavaToken getRParenth();
|
||||
|
||||
@Nullable
|
||||
PsiJavaToken getLParenth();
|
||||
}
|
||||
@@ -1,355 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.pom.PomRenameableTarget;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a Java class or interface.
|
||||
*
|
||||
* @see PsiJavaFile#getClasses()
|
||||
*/
|
||||
public interface PsiClass
|
||||
extends PsiNameIdentifierOwner, PsiModifierListOwner, PsiDocCommentOwner, PsiTypeParameterListOwner, PsiTarget, PomRenameableTarget<PsiElement> {
|
||||
/**
|
||||
* The empty array of PSI classes which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
@NotNull PsiClass[] EMPTY_ARRAY = new PsiClass[0];
|
||||
|
||||
ArrayFactory<PsiClass> ARRAY_FACTORY = new ArrayFactory<PsiClass>() {
|
||||
public PsiClass[] create(final int count) {
|
||||
return count == 0 ? EMPTY_ARRAY : new PsiClass[count];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the fully qualified name of the class.
|
||||
*
|
||||
* @return the qualified name of the class, or null for anonymous and local classes, and for type parameters
|
||||
*/
|
||||
@Nullable @NonNls
|
||||
String getQualifiedName();
|
||||
|
||||
/**
|
||||
* Checks if the class is an interface.
|
||||
*
|
||||
* @return true if the class is an interface, false otherwise.
|
||||
*/
|
||||
boolean isInterface();
|
||||
|
||||
/**
|
||||
* Checks if the class is an annotation type.
|
||||
*
|
||||
* @return true if the class is an annotation type, false otherwise
|
||||
*/
|
||||
boolean isAnnotationType();
|
||||
|
||||
/**
|
||||
* Checks if the class is an enumeration.
|
||||
*
|
||||
* @return true if the class is an enumeration, false otherwise.
|
||||
*/
|
||||
boolean isEnum();
|
||||
|
||||
/**
|
||||
* Returns the list of classes that this class or interface extends.
|
||||
*
|
||||
* @return the extends list, or null for anonymous classes, enums and annotation types
|
||||
*/
|
||||
@Nullable
|
||||
PsiReferenceList getExtendsList();
|
||||
|
||||
/**
|
||||
* Returns the list of interfaces that this class implements.
|
||||
*
|
||||
* @return the implements list, or null for anonymous classes
|
||||
*/
|
||||
@Nullable
|
||||
PsiReferenceList getImplementsList();
|
||||
|
||||
/**
|
||||
* Returns the list of class types for the classes that this class or interface extends.
|
||||
*
|
||||
* @return the list of extended class types, or an empty list for anonymous classes,
|
||||
* enums and annotation types
|
||||
*/
|
||||
@NotNull
|
||||
PsiClassType[] getExtendsListTypes();
|
||||
|
||||
/**
|
||||
* Returns the list of class types for the interfaces that this class implements.
|
||||
*
|
||||
* @return the list of extended class types, or an empty list for anonymous classes,
|
||||
* enums and annotation types
|
||||
*/
|
||||
@NotNull
|
||||
PsiClassType[] getImplementsListTypes();
|
||||
|
||||
/**
|
||||
* Returns the base class of this class.
|
||||
*
|
||||
* @return the base class. May return null when jdk is not configured, so no java.lang.Object is found,
|
||||
* or for java.lang.Object itself
|
||||
*/
|
||||
@Nullable
|
||||
PsiClass getSuperClass();
|
||||
|
||||
/**
|
||||
* Returns the list of interfaces implemented by the class, or extended by the interface.
|
||||
*
|
||||
* @return the list of interfaces.
|
||||
*/
|
||||
PsiClass[] getInterfaces();
|
||||
|
||||
/**
|
||||
* Returns the list of classes and interfaces extended or implemented by the class.
|
||||
*
|
||||
* @return the list of classes or interfaces. May return zero elements when jdk is
|
||||
* not configured, so no java.lang.Object is found
|
||||
*/
|
||||
@NotNull PsiClass[] getSupers();
|
||||
|
||||
/**
|
||||
* Returns the list of class types for the classes and interfaces extended or
|
||||
* implemented by the class.
|
||||
*
|
||||
* @return the list of class types for the classes or interfaces.
|
||||
* For the class with no explicit extends list, the returned list always contains at least one element for the java.lang.Object type.
|
||||
* If psiClass is java.lang.Object, returned list is empty.
|
||||
*/
|
||||
@NotNull PsiClassType[] getSuperTypes();
|
||||
|
||||
/**
|
||||
* Returns the list of fields in the class.
|
||||
*
|
||||
* @return the list of fields.
|
||||
*/
|
||||
@NotNull
|
||||
PsiField[] getFields();
|
||||
|
||||
/**
|
||||
* Returns the list of methods in the class.
|
||||
*
|
||||
* @return the list of methods.
|
||||
*/
|
||||
@NotNull
|
||||
PsiMethod[] getMethods();
|
||||
|
||||
/**
|
||||
* Returns the list of constructors for the class.
|
||||
*
|
||||
* @return the list of constructors,
|
||||
*/
|
||||
@NotNull
|
||||
PsiMethod[] getConstructors();
|
||||
|
||||
/**
|
||||
* Returns the list of inner classes for the class.
|
||||
*
|
||||
* @return the list of inner classes.
|
||||
*/
|
||||
@NotNull PsiClass[] getInnerClasses();
|
||||
|
||||
/**
|
||||
* Returns the list of class initializers for the class.
|
||||
*
|
||||
* @return the list of class initializers.
|
||||
*/
|
||||
@NotNull PsiClassInitializer[] getInitializers();
|
||||
|
||||
/**
|
||||
* Returns the list of fields in the class and all its superclasses.
|
||||
*
|
||||
* @return the list of fields.
|
||||
*/
|
||||
@NotNull PsiField[] getAllFields();
|
||||
|
||||
/**
|
||||
* Returns the list of methods in the class and all its superclasses.
|
||||
*
|
||||
* @return the list of methods.
|
||||
*/
|
||||
@NotNull PsiMethod[] getAllMethods();
|
||||
|
||||
/**
|
||||
* Returns the list of inner classes for the class and all its superclasses..
|
||||
*
|
||||
* @return the list of inner classes.
|
||||
*/
|
||||
@NotNull PsiClass[] getAllInnerClasses();
|
||||
|
||||
/**
|
||||
* Searches the class (and optionally its superclasses) for the field with the specified name.
|
||||
*
|
||||
* @param name the name of the field to find.
|
||||
* @param checkBases if true, the field is also searched in the base classes of the class.
|
||||
* @return the field instance, or null if the field cannot be found.
|
||||
*/
|
||||
@Nullable
|
||||
PsiField findFieldByName(@NonNls String name, boolean checkBases);
|
||||
|
||||
/**
|
||||
* Searches the class (and optionally its superclasses) for the method with
|
||||
* the signature matching the signature of the specified method.
|
||||
*
|
||||
* @param patternMethod the method used as a pattern for the search.
|
||||
* @param checkBases if true, the method is also searched in the base classes of the class.
|
||||
* @return the method instance, or null if the method cannot be found.
|
||||
*/
|
||||
@Nullable
|
||||
PsiMethod findMethodBySignature(PsiMethod patternMethod, boolean checkBases);
|
||||
|
||||
/**
|
||||
* Searches the class (and optionally its superclasses) for the methods with the signature
|
||||
* matching the signature of the specified method. If the superclasses are not searched,
|
||||
* the method returns multiple results only in case of a syntax error (duplicate method).
|
||||
*
|
||||
* @param patternMethod the method used as a pattern for the search.
|
||||
* @param checkBases if true, the method is also searched in the base classes of the class.
|
||||
* @return the found methods, or an empty array if no methods are found.
|
||||
*/
|
||||
@NotNull
|
||||
PsiMethod[] findMethodsBySignature(PsiMethod patternMethod, boolean checkBases);
|
||||
|
||||
/**
|
||||
* Searches the class (and optionally its superclasses) for the methods with the specified name.
|
||||
*
|
||||
* @param name the name of the methods to find.
|
||||
* @param checkBases if true, the methods are also searched in the base classes of the class.
|
||||
* @return the found methods, or an empty array if no methods are found.
|
||||
*/
|
||||
@NotNull
|
||||
PsiMethod[] findMethodsByName(@NonNls String name, boolean checkBases);
|
||||
|
||||
/**
|
||||
* Searches the class (and optionally its superclasses) for the methods with the specified name
|
||||
* and returns the methods along with their substitutors.
|
||||
*
|
||||
* @param name the name of the methods to find.
|
||||
* @param checkBases if true, the methods are also searched in the base classes of the class.
|
||||
* @return the found methods and their substitutors, or an empty list if no methods are found.
|
||||
*/
|
||||
@NotNull
|
||||
List<Pair<PsiMethod, PsiSubstitutor>> findMethodsAndTheirSubstitutorsByName(@NonNls String name, boolean checkBases);
|
||||
|
||||
/**
|
||||
* Returns the list of methods in the class and all its superclasses, along with their
|
||||
* substitutors.
|
||||
*
|
||||
* @return the list of methods and their substitutors
|
||||
*/
|
||||
@NotNull
|
||||
List<Pair<PsiMethod, PsiSubstitutor>> getAllMethodsAndTheirSubstitutors();
|
||||
|
||||
/**
|
||||
* Searches the class (and optionally its superclasses) for the inner class with the specified name.
|
||||
*
|
||||
* @param name the name of the inner class to find.
|
||||
* @param checkBases if true, the inner class is also searched in the base classes of the class.
|
||||
* @return the inner class instance, or null if the inner class cannot be found.
|
||||
*/
|
||||
@Nullable
|
||||
PsiClass findInnerClassByName(@NonNls String name, boolean checkBases);
|
||||
|
||||
/**
|
||||
* Returns the token representing the opening curly brace of the class.
|
||||
*
|
||||
* @return the token instance, or null if the token is missing in the source code file.
|
||||
*/
|
||||
@Nullable
|
||||
PsiElement getLBrace();
|
||||
|
||||
/**
|
||||
* Returns the token representing the closing curly brace of the class.
|
||||
*
|
||||
* @return the token instance, or null if the token is missing in the source code file.
|
||||
*/
|
||||
@Nullable
|
||||
PsiElement getRBrace();
|
||||
|
||||
/**
|
||||
* Returns the name identifier of the class.
|
||||
*
|
||||
* @return the name identifier, or null if the class is anonymous or synthetic jsp class
|
||||
*/
|
||||
@Nullable
|
||||
PsiIdentifier getNameIdentifier();
|
||||
|
||||
/**
|
||||
* Returns the PSI member in which the class has been declared (for example,
|
||||
* the method containing the anonymous inner class, or the file containing a regular
|
||||
* class, or the class owning a type parameter).
|
||||
*
|
||||
* @return the member in which the class has been declared.
|
||||
*/
|
||||
PsiElement getScope();
|
||||
|
||||
/**
|
||||
* Checks if this class is an inheritor of the specified base class.
|
||||
* Only java inheritance rules are considered.
|
||||
* Note that {@link com.intellij.psi.search.searches.ClassInheritorsSearch}
|
||||
* may return classes that are inheritors in broader, e.g. in ejb sense, but not in java sense.
|
||||
*
|
||||
* @param baseClass the base class to check the inheritance.
|
||||
* @param checkDeep if false, only direct inheritance is checked; if true, the base class is
|
||||
* searched in the entire inheritance chain
|
||||
* @return true if the class is an inheritor, false otherwise
|
||||
*/
|
||||
boolean isInheritor(@NotNull PsiClass baseClass, boolean checkDeep);
|
||||
|
||||
/**
|
||||
* Checks if this class is a deep inheritor of the specified base class possibly bypassing a class
|
||||
* when checking inheritance chain.
|
||||
* Only java inheritance rules are considered.
|
||||
* Note that {@link com.intellij.psi.search.searches.ClassInheritorsSearch}
|
||||
* may return classes that are inheritors in broader, e.g. in ejb sense, but not in java sense.
|
||||
*
|
||||
* @param baseClass the base class to check the inheritance.
|
||||
* searched in the entire inheritance chain
|
||||
* @param classToByPass class to bypass the inheratance check for
|
||||
* @return true if the class is an inheritor, false otherwise
|
||||
*/
|
||||
boolean isInheritorDeep(PsiClass baseClass, @Nullable PsiClass classToByPass);
|
||||
|
||||
/**
|
||||
* For an inner class, returns its containing class.
|
||||
*
|
||||
* @return the containing class, or null if the class is not an inner class.
|
||||
*/
|
||||
@Nullable
|
||||
PsiClass getContainingClass();
|
||||
|
||||
/**
|
||||
* Returns the hierarchical signatures for all methods in the specified class and
|
||||
* its superclasses and superinterfaces.
|
||||
*
|
||||
* @return the collection of signatures.
|
||||
* @since 5.1
|
||||
*/
|
||||
@NotNull
|
||||
Collection<HierarchicalMethodSignature> getVisibleSignatures();
|
||||
|
||||
PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a Java class initializer block.
|
||||
*/
|
||||
public interface PsiClassInitializer extends PsiMember {
|
||||
/**
|
||||
* The empty array of PSI class initializers which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiClassInitializer[] EMPTY_ARRAY = new PsiClassInitializer[0];
|
||||
|
||||
ArrayFactory<PsiClassInitializer> ARRAY_FACTORY = new ArrayFactory<PsiClassInitializer>() {
|
||||
public PsiClassInitializer[] create(final int count) {
|
||||
return count == 0 ? EMPTY_ARRAY : new PsiClassInitializer[count];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the contents of the class initializer block.
|
||||
*
|
||||
* @return the code block representing the contents of the class initializer block.
|
||||
*/
|
||||
@NotNull
|
||||
PsiCodeBlock getBody();
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public interface PsiClassLevelDeclarationStatement extends PsiStatement {
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a class literal expression (for example, <code>String.class</code>).
|
||||
*/
|
||||
public interface PsiClassObjectAccessExpression extends PsiExpression {
|
||||
/**
|
||||
* Returns the type element for the class referenced by the expression.
|
||||
*
|
||||
* @return the type element instance.
|
||||
*/
|
||||
@NotNull
|
||||
PsiTypeElement getOperand();
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public interface PsiClassOwner extends PsiFile {
|
||||
/**
|
||||
* @return classes owned by this element.
|
||||
*/
|
||||
@NotNull
|
||||
PsiClass[] getClasses();
|
||||
|
||||
/**
|
||||
* Returns the name of the package to which the file belongs.
|
||||
*
|
||||
* @return the name specified in the package statement, or an empty string for a JSP page or
|
||||
* file which has no package statement.
|
||||
*/
|
||||
String getPackageName();
|
||||
|
||||
void setPackageName(String packageName) throws IncorrectOperationException;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.intellij.psi;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public interface PsiClassOwnerEx extends PsiClassOwner {
|
||||
|
||||
/**
|
||||
* @return a set of the short names of the top-level classes defined in this file, as this may be faster than getName() for each of getClasses()
|
||||
*/
|
||||
Set<String> getClassNames();
|
||||
|
||||
}
|
||||
@@ -1,264 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a class type.
|
||||
*
|
||||
* @author max
|
||||
*/
|
||||
public abstract class PsiClassType extends PsiType {
|
||||
/**
|
||||
* The empty array of PSI class types which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
public static final PsiClassType[] EMPTY_ARRAY = new PsiClassType[0];
|
||||
public static final ArrayFactory<PsiClassType> ARRAY_FACTORY = new ArrayFactory<PsiClassType>() {
|
||||
@Override
|
||||
public PsiClassType[] create(int count) {
|
||||
return new PsiClassType[count];
|
||||
}
|
||||
};
|
||||
protected final LanguageLevel myLanguageLevel;
|
||||
|
||||
protected PsiClassType(LanguageLevel languageLevel) {
|
||||
this(languageLevel, PsiAnnotation.EMPTY_ARRAY);
|
||||
}
|
||||
protected PsiClassType(LanguageLevel languageLevel, PsiAnnotation[] annotations) {
|
||||
super(annotations);
|
||||
myLanguageLevel = languageLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the class reference and returns the resulting class.
|
||||
*
|
||||
* @return the class instance, or null if the reference resolve failed.
|
||||
*/
|
||||
@Nullable
|
||||
public abstract PsiClass resolve();
|
||||
|
||||
/**
|
||||
* Returns the non-qualified name of the class referenced by the type.
|
||||
*
|
||||
* @return the name of the class.
|
||||
*/
|
||||
public abstract String getClassName();
|
||||
|
||||
/**
|
||||
* Returns the list of type arguments for the type.
|
||||
*
|
||||
* @return the array of type arguments, or an empty array if the type does not point to a generic class or interface.
|
||||
*/
|
||||
@NotNull public abstract PsiType[] getParameters();
|
||||
|
||||
public int getParameterCount() {
|
||||
return getParameters().length;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof PsiClassType)) return false;
|
||||
PsiClassType otherClassType = (PsiClassType) obj;
|
||||
//if (!isValid() || !otherClassType.isValid()) return false;
|
||||
|
||||
String className = getClassName();
|
||||
String otherClassName = otherClassType.getClassName();
|
||||
if (!Comparing.equal(className, otherClassName)) return false;
|
||||
|
||||
if (getParameterCount() != otherClassType.getParameterCount()) return false;
|
||||
|
||||
final ClassResolveResult result = resolveGenerics();
|
||||
final ClassResolveResult otherResult = otherClassType.resolveGenerics();
|
||||
if (result == otherResult) return true;
|
||||
|
||||
final PsiClass aClass = result.getElement();
|
||||
final PsiClass otherClass = otherResult.getElement();
|
||||
if (aClass == null || otherClass == null) {
|
||||
return aClass == otherClass;
|
||||
}
|
||||
return aClass.getManager().areElementsEquivalent(aClass, otherClass) &&
|
||||
(PsiUtil.isRawSubstitutor(aClass, result.getSubstitutor()) ||
|
||||
PsiUtil.equalOnEquivalentClasses(result.getSubstitutor(), aClass, otherResult.getSubstitutor(), otherClass));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the class type has any parameters with no substituted arguments.
|
||||
*
|
||||
* @return true if the class type has non-substituted parameters, false otherwise
|
||||
*/
|
||||
public boolean hasParameters() {
|
||||
final ClassResolveResult resolveResult = resolveGenerics();
|
||||
PsiClass aClass = resolveResult.getElement();
|
||||
if (aClass == null) return false;
|
||||
boolean hasParams = false;
|
||||
for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable(aClass)) {
|
||||
if (resolveResult.getSubstitutor().substitute(parameter) == null) return false;
|
||||
hasParams = true;
|
||||
}
|
||||
return hasParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the class type has any parameters which are not unbounded wildcards (and not extends-wildcard with the same bound as corresponding type parameter bound)
|
||||
* and do not have substituted arguments.
|
||||
*
|
||||
* @return true if the class type has nontrivial non-substituted parameters, false otherwise
|
||||
*/
|
||||
public boolean hasNonTrivialParameters() {
|
||||
final ClassResolveResult resolveResult = resolveGenerics();
|
||||
PsiClass aClass = resolveResult.getElement();
|
||||
if (aClass == null) return false;
|
||||
for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable(aClass)) {
|
||||
PsiType type = resolveResult.getSubstitutor().substitute(parameter);
|
||||
if (type != null) {
|
||||
if (!(type instanceof PsiWildcardType)) {
|
||||
return true;
|
||||
}
|
||||
final PsiType bound = ((PsiWildcardType)type).getBound();
|
||||
if (bound != null) {
|
||||
if (((PsiWildcardType)type).isExtends()) {
|
||||
final PsiClass superClass = parameter.getSuperClass();
|
||||
if (superClass != null && PsiUtil.resolveClassInType(bound) == superClass) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
final String className = getClassName();
|
||||
if (className == null) return 0;
|
||||
return className.hashCode();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiType[] getSuperTypes() {
|
||||
final ClassResolveResult resolveResult = resolveGenerics();
|
||||
final PsiClass aClass = resolveResult.getElement();
|
||||
if (aClass == null) return EMPTY_ARRAY;
|
||||
final PsiClassType[] superTypes = aClass.getSuperTypes();
|
||||
|
||||
final PsiType[] subtitutionResults = new PsiType[superTypes.length];
|
||||
for (int i = 0; i < superTypes.length; i++) {
|
||||
subtitutionResults[i] = resolveResult.getSubstitutor().substitute(superTypes[i]);
|
||||
}
|
||||
return subtitutionResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the specified resolve result representss a raw type. <br>
|
||||
* Raw type is a class type for a class <i>with type parameters</i> which does not assign
|
||||
* any value to them. If a class does not have any type parameters, it cannot generate any raw type.
|
||||
*/
|
||||
public static boolean isRaw(ClassResolveResult resolveResult) {
|
||||
PsiClass psiClass = resolveResult.getElement();
|
||||
return psiClass != null && PsiUtil.isRawSubstitutor(psiClass, resolveResult.getSubstitutor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this type is a raw type. <br>
|
||||
* Raw type is a class type for a class <i>with type parameters</i> which does not assign
|
||||
* any value to them. If a class does not have any type parameters, it cannot generate any raw type.
|
||||
*/
|
||||
public boolean isRaw() {
|
||||
return isRaw(resolveGenerics());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resolve result containing the class referenced by the class type and the
|
||||
* substitutor which can substitute the values of type arguments used in the class type
|
||||
* declaration.
|
||||
*
|
||||
* @return the resolve result instance.
|
||||
*/
|
||||
@NotNull public abstract ClassResolveResult resolveGenerics();
|
||||
|
||||
/**
|
||||
* Returns the raw type (with no values assigned to type parameters) corresponding to this type.
|
||||
*
|
||||
* @return the raw type instance.
|
||||
*/
|
||||
@NotNull public abstract PsiClassType rawType();
|
||||
|
||||
/**
|
||||
* Overrides {@link com.intellij.psi.PsiType#getResolveScope()} to narrow specify @NotNull.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract GlobalSearchScope getResolveScope();
|
||||
|
||||
|
||||
public <A> A accept(PsiTypeVisitor<A> visitor) {
|
||||
return visitor.visitClassType(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract LanguageLevel getLanguageLevel();
|
||||
|
||||
/**
|
||||
* Functional style setter preserving original type's language level
|
||||
* @param languageLevel level to obtain class type with
|
||||
* @return type with requested language level
|
||||
*/
|
||||
public abstract PsiClassType setLanguageLevel(final LanguageLevel languageLevel);
|
||||
|
||||
/**
|
||||
* Represents the result of resolving a reference to a Java class.
|
||||
*/
|
||||
public interface ClassResolveResult extends JavaResolveResult {
|
||||
PsiClass getElement();
|
||||
|
||||
ClassResolveResult EMPTY = new ClassResolveResult() {
|
||||
public PsiClass getElement() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public PsiSubstitutor getSubstitutor() {
|
||||
return PsiSubstitutor.EMPTY;
|
||||
}
|
||||
|
||||
public boolean isValidResult(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isAccessible(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isStaticsScopeCorrect(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public PsiElement getCurrentFileResolveScope() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isPackagePrefixPackageReference() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java code block, usually surrounded by curly braces.
|
||||
*/
|
||||
public interface PsiCodeBlock extends PsiElement, PsiModifiableCodeBlock {
|
||||
/**
|
||||
* The empty array of PSI code blocks which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiCodeBlock[] EMPTY_ARRAY = new PsiCodeBlock[0];
|
||||
|
||||
/**
|
||||
* Returns the array of statements contained in the block.<br/>
|
||||
* Please note that this method doesn't return comments which are not part of statements.
|
||||
*
|
||||
* @return the array of statements.
|
||||
*/
|
||||
@NotNull
|
||||
PsiStatement[] getStatements();
|
||||
|
||||
/**
|
||||
* Returns the first PSI element contained in the block.
|
||||
*
|
||||
* @return the first PSI element, or null if the block is empty.
|
||||
*/
|
||||
@Nullable
|
||||
PsiElement getFirstBodyElement();
|
||||
|
||||
/**
|
||||
* Returns the last PSI element contained in the block.
|
||||
*
|
||||
* @return the last PSI element, or null if the block is empty.
|
||||
*/
|
||||
@Nullable
|
||||
PsiElement getLastBodyElement();
|
||||
|
||||
/**
|
||||
* Returns the opening curly brace of the block.
|
||||
*
|
||||
* @return the opening curly brace, or null if the block does not have one.
|
||||
*/
|
||||
@Nullable
|
||||
PsiJavaToken getLBrace();
|
||||
|
||||
/**
|
||||
* Returns the closing curly brace of the block.
|
||||
*
|
||||
* @return the closing curly brace, or null if the block does not have one.
|
||||
*/
|
||||
@Nullable
|
||||
PsiJavaToken getRBrace();
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java conditional expression (for example, <code>a ? 1 : 2</code>.
|
||||
*/
|
||||
public interface PsiConditionalExpression extends PsiExpression {
|
||||
/**
|
||||
* Returns the expression representing the condition part of the expression.
|
||||
*
|
||||
* @return the condition expression.
|
||||
*/
|
||||
@NotNull
|
||||
PsiExpression getCondition();
|
||||
|
||||
/**
|
||||
* Returns the expression which is the result used when the condition is true.
|
||||
*
|
||||
* @return the true result expression, or null if the conditional expression is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiExpression getThenExpression();
|
||||
|
||||
/**
|
||||
* Returns the expression which is the result used when the condition is false.
|
||||
*
|
||||
* @return the false result expression, or null if the conditional expression is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiExpression getElseExpression();
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* Service for evaluating values of constant expressions.
|
||||
*
|
||||
* @author ven
|
||||
* @see com.intellij.psi.JavaPsiFacade#getConstantEvaluationHelper()
|
||||
*/
|
||||
public abstract class PsiConstantEvaluationHelper {
|
||||
/**
|
||||
* Evaluates the value of the specified expression.
|
||||
*
|
||||
* @param expression the expression to evaluate.
|
||||
* @return the result of the evaluation, or null if the expression is not a constant expression.
|
||||
*/
|
||||
@Nullable
|
||||
public Object computeConstantExpression(PsiElement expression) {
|
||||
return computeConstantExpression(expression, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the value of the specified expression and optionally throws
|
||||
* {@link com.intellij.psi.util.ConstantEvaluationOverflowException} if an overflow is detected
|
||||
* during the evaluation.
|
||||
*
|
||||
* @param expression the expression to evaluate.
|
||||
* @param throwExceptionOnOverflow if true, an exception is thrown if an overflow is detected during the evaluation.
|
||||
* @return the result of the evaluation, or null if the expression is not a constant expression.
|
||||
*/
|
||||
public abstract Object computeConstantExpression(PsiElement expression, boolean throwExceptionOnOverflow);
|
||||
|
||||
public abstract Object computeExpression(PsiExpression expression, boolean throwExceptionOnOverflow,
|
||||
@Nullable final AuxEvaluator auxEvaluator);
|
||||
|
||||
public interface AuxEvaluator {
|
||||
Object computeExpression(final PsiExpression expression, final AuxEvaluator auxEvaluator);
|
||||
|
||||
ConcurrentMap<PsiElement, Object> getCacheMap(final boolean overflow);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java constructor call or enum constant.
|
||||
*
|
||||
* @author ven
|
||||
*/
|
||||
public interface PsiConstructorCall extends PsiCall {
|
||||
/**
|
||||
* Resolves the reference to the called constructor and returns the constructor.
|
||||
* Equivalent to {@link com.intellij.psi.PsiCall#resolveMethod()}.
|
||||
*
|
||||
* @return the called constructor, or null if the resolve failed.
|
||||
*/
|
||||
@Nullable
|
||||
PsiMethod resolveConstructor();
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java <code>continue</code> statement.
|
||||
*/
|
||||
public interface PsiContinueStatement extends PsiStatement {
|
||||
/**
|
||||
* Returns the identifier representing the label specified on the statement.
|
||||
*
|
||||
* @return the identifier for the label, or null if the statement has no label.
|
||||
*/
|
||||
@Nullable
|
||||
PsiIdentifier getLabelIdentifier();
|
||||
|
||||
/**
|
||||
* Returns the statement instance ({@link PsiForStatement}, {@link PsiWhileStatement} etc.) representing
|
||||
* the statement to the next iteration of which <code>continue</code> transfers control.
|
||||
*
|
||||
* @return the statement instance, or null if the statement is not valid in the context where it is located.
|
||||
*/
|
||||
@Nullable
|
||||
PsiStatement findContinuedStatement();
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a Java local variable or class declaration statement.
|
||||
*/
|
||||
public interface PsiDeclarationStatement extends PsiStatement{
|
||||
/**
|
||||
* Returns the elements declared by the statement.
|
||||
*
|
||||
* @return the array of elements, which can contain elements of types {@link PsiLocalVariable} or
|
||||
* {@link PsiClass} (and possibly other types).
|
||||
*/
|
||||
@NotNull
|
||||
PsiElement[] getDeclaredElements();
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.psi;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class PsiDiamondType extends PsiType {
|
||||
public PsiDiamondType(PsiAnnotation[] annotations) {
|
||||
super(annotations);
|
||||
}
|
||||
|
||||
public abstract DiamondInferenceResult resolveInferredTypes();
|
||||
|
||||
public static class DiamondInferenceResult {
|
||||
public static final DiamondInferenceResult EXPLICIT_CONSTRUCTOR_TYPE_ARGS = new DiamondInferenceResult() {
|
||||
@Override
|
||||
public PsiType[] getTypes() {
|
||||
return PsiType.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorMessage() {
|
||||
return "Cannot use diamonds with explicit type parameters for constructor";
|
||||
}
|
||||
};
|
||||
|
||||
public static final DiamondInferenceResult NULL_RESULT = new DiamondInferenceResult() {
|
||||
@Override
|
||||
public PsiType[] getTypes() {
|
||||
return PsiType.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorMessage() {
|
||||
return "Cannot infer arguments";
|
||||
}
|
||||
};
|
||||
|
||||
public static final DiamondInferenceResult ANONYMOUS_INNER_RESULT = new DiamondInferenceResult() {
|
||||
@Override
|
||||
public PsiType[] getTypes() {
|
||||
return PsiType.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorMessage() {
|
||||
return "Cannot use ''<>'' with anonymous inner classes";
|
||||
}
|
||||
};
|
||||
|
||||
private final List<PsiType> myInferredTypes = new ArrayList<PsiType>();
|
||||
private String myErrorMessage;
|
||||
|
||||
private String myNewExpressionPresentableText;
|
||||
private Project myProject;
|
||||
|
||||
public DiamondInferenceResult() {
|
||||
}
|
||||
|
||||
public DiamondInferenceResult(String expressionPresentableText, Project project) {
|
||||
myNewExpressionPresentableText = expressionPresentableText;
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public PsiType[] getTypes() {
|
||||
if (myErrorMessage != null) {
|
||||
return PsiType.EMPTY_ARRAY;
|
||||
}
|
||||
return myInferredTypes.toArray(new PsiType[myInferredTypes.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return all inferred types even if inference failed
|
||||
*/
|
||||
public List<PsiType> getInferredTypes() {
|
||||
return myInferredTypes;
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
return myErrorMessage;
|
||||
}
|
||||
|
||||
public boolean failedToInfer() {
|
||||
return myErrorMessage != null;
|
||||
}
|
||||
|
||||
public void addInferredType(PsiType psiType) {
|
||||
if (myErrorMessage != null) return;
|
||||
if (psiType == null) {
|
||||
myErrorMessage = "Cannot infer type arguments for " + myNewExpressionPresentableText;
|
||||
} /*else if (!isValid(psiType)) {
|
||||
myErrorMessage = "Cannot infer type arguments for " +
|
||||
myNewExpressionPresentableText + " because type " + psiType.getPresentableText() + " inferred is not allowed in current context";
|
||||
}*/ else {
|
||||
myInferredTypes.add(psiType);
|
||||
}
|
||||
}
|
||||
|
||||
private static Boolean isValid(PsiType type) {
|
||||
return type.accept(new PsiTypeVisitor<Boolean>() {
|
||||
@Override
|
||||
public Boolean visitType(PsiType type) {
|
||||
return !(type instanceof PsiIntersectionType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visitCapturedWildcardType(PsiCapturedWildcardType capturedWildcardType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visitWildcardType(PsiWildcardType wildcardType) {
|
||||
final PsiType bound = wildcardType.getBound();
|
||||
if (bound != null) {
|
||||
if (bound instanceof PsiIntersectionType) return false;
|
||||
return bound.accept(this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visitClassType(PsiClassType classType) {
|
||||
for (PsiType psiType : classType.getParameters()) {
|
||||
if (!psiType.accept(this)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
DiamondInferenceResult that = (DiamondInferenceResult)o;
|
||||
|
||||
if (myErrorMessage != null ? !myErrorMessage.equals(that.myErrorMessage) : that.myErrorMessage != null) return false;
|
||||
if (!myInferredTypes.equals(that.myInferredTypes)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = myInferredTypes.hashCode();
|
||||
result = 31 * result + (myErrorMessage != null ? myErrorMessage.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.psi;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.CachedValue;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.psi.util.PsiModificationTracker;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Composite type resulting from Project Coin's multi-catch statements, i.e. <code>FileNotFoundException | EOFException</code>.
|
||||
* In most cases should be threatened via its least upper bound (<code>IOException</code> in the example above).
|
||||
*/
|
||||
public class PsiDisjunctionType extends PsiType {
|
||||
private final PsiManager myManager;
|
||||
private final List<PsiType> myTypes;
|
||||
private final CachedValue<PsiType> myLubCache;
|
||||
|
||||
public PsiDisjunctionType(final List<PsiType> types, final PsiManager psiManager) {
|
||||
super(PsiAnnotation.EMPTY_ARRAY);
|
||||
|
||||
myManager = psiManager;
|
||||
myTypes = Collections.unmodifiableList(types);
|
||||
|
||||
final CachedValuesManager cacheManager = CachedValuesManager.getManager(psiManager.getProject());
|
||||
myLubCache = cacheManager.createCachedValue(new CachedValueProvider<PsiType>() {
|
||||
public Result<PsiType> compute() {
|
||||
PsiType lub = myTypes.get(0);
|
||||
for (int i = 1; i < myTypes.size(); i++) {
|
||||
lub = GenericsUtil.getLeastUpperBound(lub, myTypes.get(i), psiManager);
|
||||
}
|
||||
return Result.create(lub, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
public PsiType getLeastUpperBound() {
|
||||
return myLubCache.getValue();
|
||||
}
|
||||
|
||||
public List<PsiType> getDisjunctions() {
|
||||
return myTypes;
|
||||
}
|
||||
|
||||
public PsiDisjunctionType newDisjunctionType(final List<PsiType> types) {
|
||||
return new PsiDisjunctionType(types, myManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return StringUtil.join(myTypes, new Function<PsiType, String>() {
|
||||
@Override public String fun(PsiType psiType) { return psiType.getPresentableText(); }
|
||||
}, " | ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCanonicalText() {
|
||||
return StringUtil.join(myTypes, new Function<PsiType, String>() {
|
||||
@Override public String fun(PsiType psiType) { return psiType.getCanonicalText(); }
|
||||
}, " | ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return StringUtil.join(myTypes, new Function<PsiType, String>() {
|
||||
@Override public String fun(PsiType psiType) { return psiType.getInternalCanonicalText(); }
|
||||
}, " | ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
for (PsiType type : myTypes) {
|
||||
if (!type.isValid()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsToText(@NonNls final String text) {
|
||||
return Comparing.equal(text, getCanonicalText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <A> A accept(final PsiTypeVisitor<A> visitor) {
|
||||
return visitor.visitDisjunctionType(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GlobalSearchScope getResolveScope() {
|
||||
return getLeastUpperBound().getResolveScope();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiType[] getSuperTypes() {
|
||||
final PsiType lub = getLeastUpperBound();
|
||||
if (lub instanceof PsiIntersectionType) {
|
||||
return ((PsiIntersectionType)lub).getConjuncts();
|
||||
}
|
||||
else {
|
||||
return new PsiType[]{lub};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java <code>do ... while</code> statement.
|
||||
*/
|
||||
public interface PsiDoWhileStatement extends PsiLoopStatement {
|
||||
/**
|
||||
* Returns the expression representing the exit condition of the loop.
|
||||
*
|
||||
* @return the expression, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiExpression getCondition();
|
||||
|
||||
/**
|
||||
* Returns the <code>while</code> keyword of the statement.
|
||||
*
|
||||
* @return the keyword, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiKeyword getWhileKeyword();
|
||||
|
||||
/**
|
||||
* Returns the opening parenthesis enclosing the statement condition.
|
||||
*
|
||||
* @return the opening parenthesis, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiJavaToken getLParenth();
|
||||
|
||||
/**
|
||||
* Returns the closing parenthesis enclosing the statement condition.
|
||||
*
|
||||
* @return the closing parenthesis, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiJavaToken getRParenth();
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a PSI element which can have an attached JavaDoc comment.
|
||||
*/
|
||||
public interface PsiDocCommentOwner extends PsiMember {
|
||||
/**
|
||||
* Returns the JavaDoc comment for the element.
|
||||
*
|
||||
* @return the JavaDoc comment instance, or null if the element has no JavaDoc comment.
|
||||
*/
|
||||
@Nullable
|
||||
PsiDocComment getDocComment();
|
||||
|
||||
/**
|
||||
* Checks if the element is marked as deprecated via an annotation or JavaDoc tag.
|
||||
*
|
||||
* @return true is the element is marked as deprecated, false otherwise.
|
||||
*/
|
||||
boolean isDeprecated();
|
||||
}
|
||||
@@ -1,528 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.psi;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Service for creating instances of Java, JavaDoc, JSP and XML PSI elements which don't have
|
||||
* an underlying source code file.
|
||||
*
|
||||
* @see com.intellij.psi.JavaPsiFacade#getElementFactory()
|
||||
*/
|
||||
public interface PsiElementFactory extends PsiJavaParserFacade, JVMElementFactory {
|
||||
class SERVICE {
|
||||
private SERVICE() {
|
||||
}
|
||||
|
||||
public static PsiElementFactory getInstance(Project project) {
|
||||
return ServiceManager.getService(project, PsiElementFactory.class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty class with the specified name.
|
||||
*
|
||||
* @param name the name of the class to create.
|
||||
* @return the created class instance.
|
||||
* @throws IncorrectOperationException if <code>name</code> is not a valid Java identifier.
|
||||
*/
|
||||
@NotNull PsiClass createClass(@NonNls @NotNull String name) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an empty interface with the specified name.
|
||||
*
|
||||
* @param name the name of the interface to create.
|
||||
* @return the created interface instance.
|
||||
* @throws IncorrectOperationException if <code>name</code> is not a valid Java identifier.
|
||||
*/
|
||||
@NotNull PsiClass createInterface(@NonNls @NotNull String name) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an empty enum with the specified name.
|
||||
*
|
||||
* @param name the name of the enum to create.
|
||||
* @return the created enum instance.
|
||||
* @throws IncorrectOperationException if <code>name</code> is not a valid Java identifier.
|
||||
*/
|
||||
@NotNull PsiClass createEnum(@NotNull @NonNls String name) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an empty annotation type with the specified name.
|
||||
*
|
||||
* @param name the name of the annotation type to create.
|
||||
* @return the created annotation type instance.
|
||||
* @throws IncorrectOperationException if <code>name</code> is not a valid Java identifier.
|
||||
*/
|
||||
@NotNull
|
||||
PsiClass createAnnotationType(@NotNull @NonNls String name) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a field with the specified name and type.
|
||||
*
|
||||
* @param name the name of the field to create.
|
||||
* @param type the type of the field to create.
|
||||
* @return the created field instance.
|
||||
* @throws IncorrectOperationException <code>name</code> is not a valid Java identifier
|
||||
* or <code>type</code> represents an invalid type.
|
||||
*/
|
||||
@NotNull PsiField createField(@NotNull @NonNls String name, @NotNull PsiType type) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an empty method with the specified name and return type.
|
||||
*
|
||||
* @param name the name of the method to create.
|
||||
* @param returnType the return type of the method to create.
|
||||
* @return the created method instance.
|
||||
* @throws IncorrectOperationException <code>name</code> is not a valid Java identifier
|
||||
* or <code>type</code> represents an invalid type.
|
||||
*/
|
||||
@NotNull PsiMethod createMethod(@NotNull @NonNls String name, PsiType returnType) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an empty constructor.
|
||||
*
|
||||
* @return the created constructor instance.
|
||||
*/
|
||||
@NotNull PsiMethod createConstructor();
|
||||
|
||||
/**
|
||||
* Creates an empty class initializer block.
|
||||
*
|
||||
* @return the created initializer block instance.
|
||||
* @throws IncorrectOperationException in case of an internal error.
|
||||
*/
|
||||
@NotNull PsiClassInitializer createClassInitializer() throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a parameter with the specified name and type.
|
||||
*
|
||||
* @param name the name of the parameter to create.
|
||||
* @param type the type of the parameter to create.
|
||||
* @return the created parameter instance.
|
||||
* @throws IncorrectOperationException <code>name</code> is not a valid Java identifier
|
||||
* or <code>type</code> represents an invalid type.
|
||||
*/
|
||||
@NotNull PsiParameter createParameter(@NotNull @NonNls String name, @NotNull PsiType type) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an empty Java code block.
|
||||
*
|
||||
* @return the created code block instance.
|
||||
*/
|
||||
@NotNull PsiCodeBlock createCodeBlock();
|
||||
|
||||
/**
|
||||
* Creates a class type for the specified class.
|
||||
*
|
||||
* @param aClass the class for which the class type is created.
|
||||
* @return the class type instance.
|
||||
*/
|
||||
@NotNull PsiClassType createType(@NotNull PsiClass aClass);
|
||||
|
||||
/**
|
||||
* Creates a class type for the specified class, using the specified substitutor
|
||||
* to replace generic type parameters on the class.
|
||||
*
|
||||
* @param resolve the class for which the class type is created.
|
||||
* @param substitutor the substitutor to use.
|
||||
* @return the class type instance.
|
||||
*/
|
||||
@NotNull PsiClassType createType(@NotNull PsiClass resolve, @NotNull PsiSubstitutor substitutor);
|
||||
|
||||
/*
|
||||
additional languageLevel parameter to memorize language level for allowing/prohibiting boxing/unboxing
|
||||
*/
|
||||
@NotNull PsiClassType createType(@NotNull PsiClass resolve, @NotNull PsiSubstitutor substitutor, @NotNull LanguageLevel languageLevel);
|
||||
|
||||
@NotNull PsiClassType createType(@NotNull PsiClass resolve, @NotNull PsiSubstitutor substitutor, @NotNull LanguageLevel languageLevel, @NotNull PsiAnnotation[] annotations);
|
||||
|
||||
/**
|
||||
* Creates a class type for the specified reference pointing to a class.
|
||||
*
|
||||
* @param classReference the class reference for which the class type is created.
|
||||
* @return the class type instance.
|
||||
*/
|
||||
@NotNull PsiClassType createType(@NotNull PsiJavaCodeReferenceElement classReference);
|
||||
|
||||
@NotNull PsiClassType createType(@NotNull PsiClass aClass, PsiType parameters);
|
||||
|
||||
@NotNull PsiClassType createType(@NotNull PsiClass aClass, PsiType... parameters);
|
||||
|
||||
/**
|
||||
* Creates a substitutor for the specified class which replaces all type parameters
|
||||
* with their corresponding raw types.
|
||||
*
|
||||
* @param owner the class or method for which the substitutor is created.
|
||||
* @return the substitutor instance.
|
||||
*/
|
||||
@NotNull PsiSubstitutor createRawSubstitutor(@NotNull PsiTypeParameterListOwner owner);
|
||||
|
||||
/**
|
||||
* Creates a substitutor which uses the specified mapping between type parameters and types.
|
||||
*
|
||||
* @param map the type parameter to type map used by the substitutor.
|
||||
* @return the substitutor instance.
|
||||
*/
|
||||
@NotNull PsiSubstitutor createSubstitutor(@NotNull Map<PsiTypeParameter, PsiType> map);
|
||||
|
||||
/**
|
||||
* Returns the primitive type instance for the specified type name.
|
||||
*
|
||||
* @param text the name of a Java primitive type (for example, <code>int</code>)
|
||||
* @return the primitive type instance, or null if <code>name</code> is not a valid
|
||||
* primitive type name.
|
||||
*/
|
||||
@Nullable PsiPrimitiveType createPrimitiveType(@NotNull String text);
|
||||
|
||||
/**
|
||||
* The same as {@link #createTypeByFQClassName(String, GlobalSearchScope)}
|
||||
* with {@link GlobalSearchScope#allScope(com.intellij.openapi.project.Project)}.
|
||||
*
|
||||
* @param qName the full-qualified name of the class to create the reference to.
|
||||
* @return the class type instance.
|
||||
*/
|
||||
@NotNull PsiClassType createTypeByFQClassName(@NotNull @NonNls String qName);
|
||||
|
||||
/**
|
||||
* Creates a class type referencing a class with the specified class name in the specified
|
||||
* search scope.
|
||||
*
|
||||
* @param qName the full-qualified name of the class to create the reference to.
|
||||
* @param resolveScope the scope in which the class is searched.
|
||||
* @return the class type instance.
|
||||
*/
|
||||
@NotNull PsiClassType createTypeByFQClassName(@NotNull @NonNls String qName, @NotNull GlobalSearchScope resolveScope);
|
||||
|
||||
/**
|
||||
* Creates a type element referencing the specified type.
|
||||
*
|
||||
* @param psiType the type to reference.
|
||||
* @return the type element instance.
|
||||
*/
|
||||
@NotNull PsiTypeElement createTypeElement(@NotNull PsiType psiType);
|
||||
|
||||
/**
|
||||
* Creates a reference element resolving to the specified class type.
|
||||
*
|
||||
* @param type the class type to create the reference to.
|
||||
* @return the reference element instance.
|
||||
*/
|
||||
@NotNull PsiJavaCodeReferenceElement createReferenceElementByType(@NotNull PsiClassType type);
|
||||
|
||||
/**
|
||||
* Creates a reference element resolving to the specified class.
|
||||
*
|
||||
* @param aClass the class to create the reference to.
|
||||
* @return the reference element instance.
|
||||
*/
|
||||
@NotNull PsiJavaCodeReferenceElement createClassReferenceElement(@NotNull PsiClass aClass);
|
||||
|
||||
/**
|
||||
* Creates a reference element resolving to the class with the specified name
|
||||
* in the specified search scope. The text of the created reference is the short name of the class.
|
||||
*
|
||||
* @param qName the full-qualified name of the class to create the reference to.
|
||||
* @param resolveScope the scope in which the class is searched.
|
||||
* @return the reference element instance.
|
||||
*/
|
||||
@NotNull PsiJavaCodeReferenceElement createReferenceElementByFQClassName(@NotNull String qName, @NotNull GlobalSearchScope resolveScope);
|
||||
|
||||
/**
|
||||
* Creates a reference element resolving to the class with the specified name
|
||||
* in the specified search scope. The text of the created reference is the fully qualified name of the class.
|
||||
*
|
||||
* @param qName the full-qualified name of the class to create the reference to.
|
||||
* @param resolveScope the scope in which the class is searched.
|
||||
* @return the reference element instance.
|
||||
*/
|
||||
@NotNull PsiJavaCodeReferenceElement createFQClassNameReferenceElement(@NotNull String qName, @NotNull GlobalSearchScope resolveScope);
|
||||
|
||||
/**
|
||||
* Creates a reference element resolving to the specified package.
|
||||
*
|
||||
* @param aPackage the package to create the reference to.
|
||||
* @return the reference element instance.
|
||||
* @throws IncorrectOperationException if <code>aPackage</code> is the default (root) package.
|
||||
*/
|
||||
@NotNull PsiJavaCodeReferenceElement createPackageReferenceElement(@NotNull PsiPackage aPackage) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a reference element resolving to the package with the specified name.
|
||||
*
|
||||
* @param packageName the name of the package to create the reference to.
|
||||
* @return the reference element instance.
|
||||
* @throws IncorrectOperationException if <code>packageName</code> is an empty string.
|
||||
*/
|
||||
@NotNull PsiJavaCodeReferenceElement createPackageReferenceElement(@NotNull String packageName) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a reference expression resolving to the specified class.
|
||||
*
|
||||
* @param aClass the class to create the reference to.
|
||||
* @return the reference expression instance.
|
||||
* @throws IncorrectOperationException never (the exception is kept for compatibility purposes).
|
||||
*/
|
||||
@NotNull PsiReferenceExpression createReferenceExpression(@NotNull PsiClass aClass) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a reference expression resolving to the specified package.
|
||||
*
|
||||
* @param aPackage the package to create the reference to.
|
||||
* @return the reference expression instance.
|
||||
* @throws IncorrectOperationException if <code>aPackage</code> is the default (root) package.
|
||||
*/
|
||||
@NotNull PsiReferenceExpression createReferenceExpression(@NotNull PsiPackage aPackage) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java identifier with the specified text.
|
||||
*
|
||||
* @param text the text of the identifier to create.
|
||||
* @return the identifier instance.
|
||||
* @throws IncorrectOperationException if <code>text</code> is not a valid Java identifier.
|
||||
*/
|
||||
@NotNull PsiIdentifier createIdentifier(@NotNull @NonNls String text) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java keyword with the specified text.
|
||||
*
|
||||
* @param keyword the text of the keyword to create.
|
||||
* @return the keyword instance.
|
||||
* @throws IncorrectOperationException if <code>text</code> is not a valid Java keyword.
|
||||
*/
|
||||
@NotNull PsiKeyword createKeyword(@NotNull @NonNls String keyword) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an import statement for importing the specified class.
|
||||
*
|
||||
* @param aClass the class to create the import statement for.
|
||||
* @return the import statement instance.
|
||||
* @throws IncorrectOperationException if <code>aClass</code> is an anonymous or local class.
|
||||
*/
|
||||
@NotNull PsiImportStatement createImportStatement(@NotNull PsiClass aClass) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an on-demand import statement for importing classes from the package with the specified name.
|
||||
*
|
||||
* @param packageName the name of package to create the import statement for.
|
||||
* @return the import statement instance.
|
||||
* @throws IncorrectOperationException if <code>packageName</code> is not a valid qualified package name.
|
||||
*/
|
||||
@NotNull PsiImportStatement createImportStatementOnDemand(@NotNull @NonNls String packageName) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a local variable declaration statement with the specified name, type and initializer,
|
||||
* optionally without reformatting the declaration.
|
||||
*
|
||||
* @param name the name of the variable to create.
|
||||
* @param type the type of the variable to create.
|
||||
* @param initializer the initializer for the variable.
|
||||
* @return the variable instance.
|
||||
* @throws IncorrectOperationException if <code>name</code> is not a valid identifier or
|
||||
* <code>type</code> is not a valid type.
|
||||
*/
|
||||
@NotNull PsiDeclarationStatement createVariableDeclarationStatement(@NonNls @NotNull String name, @NotNull PsiType type, PsiExpression initializer)
|
||||
throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a PSI element for the "@param" JavaDoc tag.
|
||||
*
|
||||
* @param parameterName the name of the parameter for which the tag is created.
|
||||
* @param description the description of the parameter for which the tag is created.
|
||||
* @return the created tag.
|
||||
* @throws IncorrectOperationException if the name or description are invalid.
|
||||
*/
|
||||
@NotNull PsiDocTag createParamTag(@NotNull String parameterName, String description) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java expression code fragment from the text of the expression.
|
||||
*
|
||||
* @param text the text of the expression to create.
|
||||
* @param context the context for resolving references from the code fragment.
|
||||
* @param expectedType expected type of the expression (does not have any effect on creation
|
||||
* but can be accessed as {@link PsiExpressionCodeFragment#getExpectedType()}).
|
||||
* @param isPhysical whether the code fragment is created as a physical element
|
||||
* (see {@link PsiElement#isPhysical()}).
|
||||
* @return the created code fragment.
|
||||
*/
|
||||
@NotNull PsiExpressionCodeFragment createExpressionCodeFragment(@NotNull String text, PsiElement context, final PsiType expectedType, boolean isPhysical);
|
||||
|
||||
/**
|
||||
* Creates a Java code fragment from the text of a Java code block.
|
||||
*
|
||||
* @param text the text of the code block to create.
|
||||
* @param context the context for resolving references from the code fragment.
|
||||
* @param isPhysical whether the code fragment is created as a physical element
|
||||
* (see {@link PsiElement#isPhysical()}).
|
||||
* @return the created code fragment.
|
||||
*/
|
||||
@NotNull
|
||||
JavaCodeFragment createCodeBlockCodeFragment(@NotNull String text, PsiElement context, boolean isPhysical);
|
||||
|
||||
/**
|
||||
* Flag for {@linkplain #createTypeCodeFragment(String, PsiElement, boolean, int)} - allows void type.
|
||||
*/
|
||||
int ALLOW_VOID = 0x01;
|
||||
/**
|
||||
* Flag for {@linkplain #createTypeCodeFragment(String, PsiElement, boolean, int)} - allows type with ellipsis.
|
||||
*/
|
||||
int ALLOW_ELLIPSIS = 0x02;
|
||||
/**
|
||||
* Flag for {@linkplain #createTypeCodeFragment(String, PsiElement, boolean, int)} - allows disjunctive type.
|
||||
*/
|
||||
int ALLOW_DISJUNCTION = 0x02;
|
||||
|
||||
/**
|
||||
* Creates a Java type code fragment from the text of the name of a Java type (the name
|
||||
* of a primitive type, array type or class), with <code>void</code> and ellipsis
|
||||
* not treated as a valid type.
|
||||
*
|
||||
* @param text the text of the Java type to create.
|
||||
* @param context the context for resolving references from the code fragment.
|
||||
* @param isPhysical whether the code fragment is created as a physical element
|
||||
* (see {@link PsiElement#isPhysical()}).
|
||||
* @return the created code fragment.
|
||||
*/
|
||||
@NotNull PsiTypeCodeFragment createTypeCodeFragment(@NotNull String text, PsiElement context, boolean isPhysical);
|
||||
|
||||
/**
|
||||
* Creates a Java type code fragment from the text of the name of a Java type (the name
|
||||
* of a primitive type, array type or class).<br>
|
||||
* {@code void}, ellipsis and disjunctive types are optionally treated as valid ones.
|
||||
*
|
||||
* @param text the text of the Java type to create.
|
||||
* @param context the context for resolving references from the code fragment.
|
||||
* @param isPhysical whether the code fragment is created as a physical element
|
||||
* (see {@link PsiElement#isPhysical()}).
|
||||
* @param flags types allowed to present in text.
|
||||
* @return the created code fragment.
|
||||
*/
|
||||
@NotNull PsiTypeCodeFragment createTypeCodeFragment(@NotNull String text, PsiElement context, boolean isPhysical, int flags);
|
||||
|
||||
/**
|
||||
* Returns a synthetic Java class containing methods which are defined on Java arrays.
|
||||
*
|
||||
* @param languageLevel language level used to construct array class.
|
||||
* @return the array synthetic class.
|
||||
*/
|
||||
@NotNull PsiClass getArrayClass(@NotNull LanguageLevel languageLevel);
|
||||
|
||||
/**
|
||||
* Returns the class type for a synthetic Java class containing methods which
|
||||
* are defined on Java arrays with the specified element type.
|
||||
*
|
||||
* @param componentType the component type of the array for which the class type is returned.
|
||||
* @param languageLevel language level used to construct array class.
|
||||
* @return the class type the array synthetic class.
|
||||
*/
|
||||
@NotNull PsiClassType getArrayClassType(@NotNull PsiType componentType, @NotNull final LanguageLevel languageLevel);
|
||||
|
||||
/**
|
||||
* Creates a package statement for the specified package name.
|
||||
*
|
||||
* @param name the name of the package to use in the package statement.
|
||||
* @return the created package statement instance.
|
||||
* @throws IncorrectOperationException if <code>name</code> is not a valid package name.
|
||||
*/
|
||||
@NotNull PsiPackageStatement createPackageStatement(@NotNull String name) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java reference code fragment from the text of a Java reference to a
|
||||
* package or class.
|
||||
*
|
||||
* @param text the text of the reference to create.
|
||||
* @param context the context for resolving the reference.
|
||||
* @param isPhysical whether the code fragment is created as a physical element
|
||||
* (see {@link PsiElement#isPhysical()}).
|
||||
* @param isClassesAccepted if true then classes as well as packages are accepted as
|
||||
* reference target, otherwise only packages are
|
||||
* @return the created reference fragment.
|
||||
*/
|
||||
@NotNull PsiJavaCodeReferenceCodeFragment createReferenceCodeFragment(@NotNull String text,
|
||||
PsiElement context,
|
||||
boolean isPhysical,
|
||||
boolean isClassesAccepted);
|
||||
|
||||
/**
|
||||
* Creates an <code>import static</code> statement for importing the specified member
|
||||
* from the specified class.
|
||||
*
|
||||
* @param aClass the class from which the member is imported.
|
||||
* @param memberName the name of the member to import.
|
||||
* @return the created statement.
|
||||
* @throws IncorrectOperationException if the class is inner or local, or
|
||||
* <code>memberName</code> is not a valid identifier.
|
||||
*/
|
||||
@NotNull PsiImportStaticStatement createImportStaticStatement(@NotNull PsiClass aClass, @NotNull String memberName) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a parameter list from the specified parameter names and types.
|
||||
*
|
||||
* @param names the array of names for the parameters to create.
|
||||
* @param types the array of types for the parameters to create.
|
||||
* @return the created parameter list.
|
||||
* @throws IncorrectOperationException if some of the parameter names or types are invalid.
|
||||
*/
|
||||
@NotNull PsiParameterList createParameterList(@NotNull @NonNls String[] names, @NotNull PsiType[] types) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a reference list element from the specified array of references.
|
||||
*
|
||||
* @param references the array of references to include in the list.
|
||||
* @return the created reference list.
|
||||
* @throws IncorrectOperationException if some of the references are invalid.
|
||||
*/
|
||||
@NotNull PsiReferenceList createReferenceList(@NotNull PsiJavaCodeReferenceElement[] references) throws IncorrectOperationException;
|
||||
|
||||
@NotNull
|
||||
PsiSubstitutor createRawSubstitutor(@NotNull PsiSubstitutor baseSubstitutor, @NotNull PsiTypeParameter[] typeParameters);
|
||||
|
||||
/**
|
||||
* Create a lightweight PsiElement of given element type in a lightweight non-physical PsiFile (aka DummyHolder) in a given context.
|
||||
* Element type's language should have a parser definition which supports parsing for this element type (first
|
||||
* parameter in {@link com.intellij.lang.PsiParser#parse(com.intellij.psi.tree.IElementType, com.intellij.lang.PsiBuilder)}.
|
||||
* @param text text to parse
|
||||
* @param type node type
|
||||
* @param context context
|
||||
* @return PsiElement of the desired element type
|
||||
*/
|
||||
@NotNull
|
||||
PsiElement createDummyHolder(@NotNull String text, @NotNull IElementType type, @Nullable PsiElement context);
|
||||
|
||||
/**
|
||||
* Creates a <code>catch</code> section for catching an exception of the specified
|
||||
* type and name.
|
||||
*
|
||||
* @param exceptionType the type of the exception to catch (either {@linkplain PsiClassType} or {@linkplain PsiDisjunctionType}).
|
||||
* @param exceptionName the name of the variable in which the caught exception is stored (may be an empty string).
|
||||
* @param context the context for resolving references.
|
||||
* @return the created catch section instance.
|
||||
* @throws IncorrectOperationException if some of the parameters are not valid.
|
||||
*/
|
||||
@NotNull
|
||||
PsiCatchSection createCatchSection(@NotNull PsiType exceptionType, @NotNull String exceptionName, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Allows to extend the mechanism of locating classes and packages by full-qualified name.
|
||||
* Implementations of this interface need to be registered as extensions in order
|
||||
* to be picked up by {@link JavaPsiFacade}.
|
||||
*/
|
||||
public abstract class PsiElementFinder {
|
||||
public static final ExtensionPointName<PsiElementFinder> EP_NAME = ExtensionPointName.create("com.intellij.java.elementFinder");
|
||||
|
||||
/**
|
||||
* Searches the specified scope within the project for a class with the specified full-qualified
|
||||
* name and returns one if it is found.
|
||||
*
|
||||
* @param qualifiedName the full-qualified name of the class to find.
|
||||
* @param scope the scope to search.
|
||||
* @return the PSI class, or null if no class with such name is found.
|
||||
* @see JavaPsiFacade#findClass(String, GlobalSearchScope)
|
||||
*/
|
||||
@Nullable
|
||||
public abstract PsiClass findClass(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope);
|
||||
|
||||
/**
|
||||
* Searches the specified scope within the project for classes with the specified full-qualified
|
||||
* name and returns all found classes.
|
||||
*
|
||||
* @param qualifiedName the full-qualified name of the class to find.
|
||||
* @param scope the scope to search.
|
||||
* @return the array of found classes, or an empty array if no classes are found.
|
||||
* @see JavaPsiFacade#findClasses(String, GlobalSearchScope)
|
||||
*/
|
||||
@NotNull
|
||||
public abstract PsiClass[] findClasses(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope);
|
||||
|
||||
/**
|
||||
* Searches the project for the package with the specified full-qualified name and returns one
|
||||
* if it is found.
|
||||
*
|
||||
* @param qualifiedName the full-qualified name of the package to find.
|
||||
* @return the PSI package, or null if no package with such name is found.
|
||||
* @see JavaPsiFacade#findPackage(String)
|
||||
*/
|
||||
@Nullable
|
||||
public PsiPackage findPackage(@NotNull String qualifiedName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of subpackages of the specified package in the specified search scope.
|
||||
*
|
||||
* @param psiPackage the package to return the list of subpackages for.
|
||||
* @param scope the scope in which subpackages are searched.
|
||||
* @return the list of subpackages.
|
||||
* @see PsiPackage#getSubPackages(GlobalSearchScope)
|
||||
*/
|
||||
@NotNull
|
||||
public PsiPackage[] getSubPackages(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
|
||||
return new PsiPackage[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of classes in the specified package and in the specified search scope.
|
||||
*
|
||||
* @param psiPackage the package to return the list of classes in.
|
||||
* @param scope the scope in which classes are searched.
|
||||
* @return the list of classes.
|
||||
* @see PsiPackage#getClasses(GlobalSearchScope)
|
||||
*/
|
||||
@NotNull
|
||||
public PsiClass[] getClasses(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
|
||||
return PsiClass.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public Set<String> getClassNames(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
|
||||
return getClassNames(getClasses(psiPackage, scope));
|
||||
}
|
||||
|
||||
protected static Set<String> getClassNames(PsiClass[] classes) {
|
||||
if (classes.length == 0) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
final HashSet<String> names = new HashSet<String>();
|
||||
for (PsiClass aClass : classes) {
|
||||
ContainerUtil.addIfNotNull(aClass.getName(), names);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public boolean processPackageDirectories(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope, Processor<PsiDirectory> consumer) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the type of a variable arguments array passed as a method parameter.
|
||||
*
|
||||
* @author ven
|
||||
*/
|
||||
public class PsiEllipsisType extends PsiArrayType {
|
||||
/**
|
||||
* Creates an ellipsis type instance with the specified component type.
|
||||
*
|
||||
* @param componentType the type of the varargs array component.
|
||||
*/
|
||||
public PsiEllipsisType(PsiType componentType) {
|
||||
super(componentType);
|
||||
}
|
||||
|
||||
public String getPresentableText() {
|
||||
return StringUtil.joinOrNull(getComponentType().getPresentableText(), "...");
|
||||
}
|
||||
|
||||
public String getCanonicalText() {
|
||||
return StringUtil.joinOrNull(getComponentType().getCanonicalText(), "...");
|
||||
}
|
||||
|
||||
public String getInternalCanonicalText() {
|
||||
return StringUtil.joinOrNull(getComponentType().getInternalCanonicalText(), "...");
|
||||
}
|
||||
|
||||
public boolean equalsToText(String text) {
|
||||
return text.endsWith("...") && getComponentType().equalsToText(text.substring(0, text.length() - 3))
|
||||
|| super.equalsToText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the ellipsis type to an array type with the same component type.
|
||||
*
|
||||
* @return the array type instance.
|
||||
*/
|
||||
public PsiType toArrayType() {
|
||||
return getComponentType().createArrayType();
|
||||
}
|
||||
|
||||
public <A> A accept(PsiTypeVisitor<A> visitor) {
|
||||
return visitor.visitEllipsisType(this);
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof PsiEllipsisType && super.equals(obj);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return super.hashCode() * 5;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
/**
|
||||
* Represents an empty statement in Java.
|
||||
*/
|
||||
public interface PsiEmptyStatement extends PsiStatement {
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a constant in a Java enum type.
|
||||
*
|
||||
* @author dsl
|
||||
*/
|
||||
public interface PsiEnumConstant extends PsiField, PsiConstructorCall {
|
||||
/**
|
||||
* Returns the list of arguments passed to the constructor of the enum type to create the
|
||||
* instance of the constant.
|
||||
*
|
||||
* @return the list of arguments, or null
|
||||
*/
|
||||
@Nullable
|
||||
PsiExpressionList getArgumentList();
|
||||
|
||||
/**
|
||||
* Returns the class body attached to the enum constant declaration.
|
||||
*
|
||||
* @return the enum constant class body, or null if
|
||||
* the enum constant does not have one.
|
||||
*/
|
||||
@Nullable
|
||||
PsiEnumConstantInitializer getInitializingClass();
|
||||
|
||||
@NotNull
|
||||
PsiEnumConstantInitializer getOrCreateInitializingClass();
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents the class body attached to a constant in a Java enum type.
|
||||
*
|
||||
* @author dsl
|
||||
* @see com.intellij.psi.PsiEnumConstant#getInitializingClass()
|
||||
*/
|
||||
public interface PsiEnumConstantInitializer extends PsiAnonymousClass {
|
||||
/**
|
||||
* Returns the enum constant to which the class body is attached.
|
||||
*
|
||||
* @return the enum constant instance.
|
||||
*/
|
||||
@NotNull
|
||||
PsiEnumConstant getEnumConstant();
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java expression.
|
||||
*/
|
||||
public interface PsiExpression extends PsiAnnotationMemberValue {
|
||||
/**
|
||||
* The empty array of PSI expressions which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiExpression[] EMPTY_ARRAY = new PsiExpression[0];
|
||||
|
||||
Function<PsiExpression, PsiType> EXPRESSION_TO_TYPE = new NullableFunction<PsiExpression, PsiType>() {
|
||||
public PsiType fun(final PsiExpression expression) {
|
||||
return expression.getType();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the type of the expression.
|
||||
*
|
||||
* @return the expression type, or null if the type is not known.
|
||||
*/
|
||||
@Nullable
|
||||
PsiType getType();
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
/**
|
||||
* Represents a fragment of Java code the contents of which is an expression.
|
||||
*
|
||||
* @see PsiElementFactory#createExpressionCodeFragment(String, PsiElement, PsiType, boolean)
|
||||
*/
|
||||
public interface PsiExpressionCodeFragment extends JavaCodeFragment {
|
||||
/**
|
||||
* Returns the expression contained in the fragment.
|
||||
*
|
||||
* @return the expression contained in the fragment.
|
||||
*/
|
||||
PsiExpression getExpression();
|
||||
|
||||
/**
|
||||
* Returns the expected type of the expression (not used by the expression itself,
|
||||
* but can be used by its clients).
|
||||
*
|
||||
* @return the expected type of the expression.
|
||||
*/
|
||||
PsiType getExpectedType();
|
||||
|
||||
/**
|
||||
* Sets the expected type of the expression (not used by the expression itself,
|
||||
* but can be used by its clients).
|
||||
*
|
||||
* @param type the expected type of the expression.
|
||||
*/
|
||||
void setExpectedType(PsiType type);
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a list of expressions separated by commas.
|
||||
*
|
||||
* @see PsiCall#getArgumentList()
|
||||
* @see PsiExpressionListStatement#getExpressionList()
|
||||
*/
|
||||
public interface PsiExpressionList extends PsiElement {
|
||||
/**
|
||||
* Returns the expressions contained in the list.
|
||||
*
|
||||
* @return the array of expressions contained in the list.
|
||||
*/
|
||||
@NotNull PsiExpression[] getExpressions();
|
||||
|
||||
@NotNull PsiType[] getExpressionTypes();
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
/**
|
||||
* Represents the list of expressions separated by commas, used as the initialize
|
||||
* or update part of a <code>for</code> loop.
|
||||
*/
|
||||
public interface PsiExpressionListStatement extends PsiStatement {
|
||||
/**
|
||||
* Returns the expression list contained in the statement.
|
||||
*
|
||||
* @return the expression list instance.
|
||||
*/
|
||||
PsiExpressionList getExpressionList();
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a Java expression statement.
|
||||
*/
|
||||
public interface PsiExpressionStatement extends PsiStatement {
|
||||
/**
|
||||
* Returns the expression contained in the statement.
|
||||
*
|
||||
* @return the expression instance.
|
||||
*/
|
||||
@NotNull
|
||||
PsiExpression getExpression();
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java field or enum constant.
|
||||
*/
|
||||
public interface PsiField extends PsiMember, PsiVariable, PsiDocCommentOwner {
|
||||
/**
|
||||
* The empty array of PSI fields which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiField[] EMPTY_ARRAY = new PsiField[0];
|
||||
|
||||
ArrayFactory<PsiField> ARRAY_FACTORY = new ArrayFactory<PsiField>() {
|
||||
public PsiField[] create(final int count) {
|
||||
return count == 0 ? EMPTY_ARRAY : new PsiField[count];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds initializer to the field declaration or, if <code>initializer</code> parameter is null,
|
||||
* removes the initializer from the field declaration.
|
||||
*
|
||||
* @param initializer the initializer to add.
|
||||
* @throws IncorrectOperationException if the modifications fails for some reason.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
void setInitializer(@Nullable PsiExpression initializer) throws IncorrectOperationException;
|
||||
|
||||
@NotNull PsiIdentifier getNameIdentifier();
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java basic <code>for</code> statement.
|
||||
*/
|
||||
public interface PsiForStatement extends PsiLoopStatement{
|
||||
/**
|
||||
* Returns the initialization part of the statement.
|
||||
*
|
||||
* @return the initialization part, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiStatement getInitialization();
|
||||
|
||||
/**
|
||||
* Returns the condition part of the statement.
|
||||
*
|
||||
* @return the condition part, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiExpression getCondition();
|
||||
|
||||
/**
|
||||
* Returns the update part of the statement.
|
||||
*
|
||||
* @return the update part, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiStatement getUpdate();
|
||||
|
||||
/**
|
||||
* Returns the opening parenthesis enclosing the statement header.
|
||||
*
|
||||
* @return the opening parenthesis, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiJavaToken getLParenth();
|
||||
|
||||
/**
|
||||
* Returns the closing parenthesis enclosing the statement header.
|
||||
*
|
||||
* @return the closing parenthesis, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiJavaToken getRParenth();
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java enhanced <code>for</code> statement.
|
||||
*
|
||||
* @author dsl
|
||||
*/
|
||||
public interface PsiForeachStatement extends PsiLoopStatement {
|
||||
/**
|
||||
* Returns the variable containing the iteration parameter of the statement.
|
||||
*
|
||||
* @return the iteration parameter instance.
|
||||
*/
|
||||
@NotNull
|
||||
PsiParameter getIterationParameter();
|
||||
|
||||
/**
|
||||
* Returns the expression representing the sequence over which the iteration is performed.
|
||||
*
|
||||
* @return the iterated value expression instance, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiExpression getIteratedValue();
|
||||
|
||||
/**
|
||||
* Returns the opening parenthesis enclosing the statement header.
|
||||
*
|
||||
* @return the opening parenthesis.
|
||||
*/
|
||||
@NotNull
|
||||
PsiJavaToken getLParenth();
|
||||
|
||||
/**
|
||||
* Returns the closing parenthesis enclosing the statement header.
|
||||
*
|
||||
* @return the closing parenthesis, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiJavaToken getRParenth();
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
/**
|
||||
* Represents a Java identifier.
|
||||
*/
|
||||
public interface PsiIdentifier extends PsiJavaToken {
|
||||
/**
|
||||
* The empty array of PSI identifiers which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiIdentifier[] EMPTY_ARRAY = new PsiIdentifier[0];
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a Java <code>if</code> or <code>if ... else</code> statement.
|
||||
*/
|
||||
public interface PsiIfStatement extends PsiStatement {
|
||||
/**
|
||||
* Returns the expression representing the condition of the statement.
|
||||
*
|
||||
* @return the expression instance, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiExpression getCondition();
|
||||
|
||||
/**
|
||||
* Returns the statement which is executed when the condition is true.
|
||||
*
|
||||
* @return the statement instance, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiStatement getThenBranch();
|
||||
|
||||
/**
|
||||
* Returns the statement which is executed when the condition is true.
|
||||
*
|
||||
* @return the statement instance, or null if the statement has no <code>else</code>
|
||||
* part or is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiStatement getElseBranch();
|
||||
|
||||
/**
|
||||
* Returns the <code>else</code> keyword of the statement.
|
||||
*
|
||||
* @return the keyword instance, or null if the statement has no <code>else</code>
|
||||
* part.
|
||||
*/
|
||||
@Nullable
|
||||
PsiKeyword getElseElement();
|
||||
|
||||
/**
|
||||
* Sets the statement which is executed when the condition is false to the specified value.
|
||||
* Adds the <code>else</code> keyword if required.
|
||||
*
|
||||
* @param statement the statement to use as the else branch.
|
||||
* @throws IncorrectOperationException if the modification fails for some reason (for example,
|
||||
* the containing file is read-only).
|
||||
*/
|
||||
void setElseBranch(@NotNull PsiStatement statement) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Sets the statement which is executed when the condition is true to the specified value.
|
||||
* Adds the parentheses if required.
|
||||
*
|
||||
* @param statement the statement to use as the then branch.
|
||||
* @throws IncorrectOperationException if the modification fails for some reason (for example,
|
||||
* the containing file is read-only).
|
||||
*/
|
||||
void setThenBranch(@NotNull PsiStatement statement) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Returns the opening parenthesis enclosing the statement condition.
|
||||
*
|
||||
* @return the opening parenthesis, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiJavaToken getLParenth();
|
||||
|
||||
/**
|
||||
* Returns the closing parenthesis enclosing the statement condition.
|
||||
*
|
||||
* @return the closing parenthesis, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiJavaToken getRParenth();
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a file or code fragment to which import statements can be added.
|
||||
*/
|
||||
public interface PsiImportHolder extends PsiFile {
|
||||
/**
|
||||
* Adds an import statement for importing the specified class.
|
||||
*
|
||||
* @param aClass the class to import.
|
||||
* @return true if the import statement was added successfully, false otherwise.
|
||||
*/
|
||||
boolean importClass(PsiClass aClass);
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents the list of import statements contained in a Java or JSP file.
|
||||
*
|
||||
* @see PsiJavaFile#getImportList()
|
||||
*/
|
||||
public interface PsiImportList extends PsiElement {
|
||||
PsiImportList[] EMPTY_ARRAY = new PsiImportList[0];
|
||||
ArrayFactory<PsiImportList> ARRAY_FACTORY = new ArrayFactory<PsiImportList>() {
|
||||
public PsiImportList[] create(int count) {
|
||||
return count == 0 ? EMPTY_ARRAY : new PsiImportList[count];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the non-static import statements contained in the list.
|
||||
*
|
||||
* @return the array of non-static import statements.
|
||||
*/
|
||||
@NotNull PsiImportStatement[] getImportStatements();
|
||||
|
||||
/**
|
||||
* Returns the static import statements contained in the list.
|
||||
*
|
||||
* @return the array of static import statements.
|
||||
*/
|
||||
@NotNull PsiImportStaticStatement[] getImportStaticStatements();
|
||||
|
||||
/**
|
||||
* Returns all import statements contained in the list.
|
||||
*
|
||||
* @return the array of import statements.
|
||||
*/
|
||||
@NotNull PsiImportStatementBase[] getAllImportStatements();
|
||||
|
||||
/**
|
||||
* Searches the list for a single-class import statement importing the specified class.
|
||||
*
|
||||
* @param qName the full-qualified name of the imported class.
|
||||
* @return the import statement, or null if one was not found.
|
||||
*/
|
||||
@Nullable
|
||||
PsiImportStatement findSingleClassImportStatement(String qName);
|
||||
|
||||
/**
|
||||
* Searches the list for an on-demand import statement importing the specified class.
|
||||
*
|
||||
* @param packageName the name of the imported package.
|
||||
* @return the import statement, or null if one was not found.
|
||||
*/
|
||||
@Nullable
|
||||
PsiImportStatement findOnDemandImportStatement(@NonNls String packageName);
|
||||
|
||||
/**
|
||||
* Searches the list for a single import or import static statement importing the specified
|
||||
* identifier.
|
||||
*
|
||||
* @param name the name of the imported class or method.
|
||||
* @return the import statement, or null if one was not found.
|
||||
*/
|
||||
@Nullable
|
||||
PsiImportStatementBase findSingleImportStatement(String name);
|
||||
|
||||
/**
|
||||
* Checks if replacing this import list with the specified import list will cause no
|
||||
* modifications to the file.
|
||||
*
|
||||
* @param otherList the list to check possibility to replace with.
|
||||
* @return true if replacing will not cause modifications; false otherwise.
|
||||
*/
|
||||
boolean isReplaceEquivalent(PsiImportList otherList);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java <code>import</code> statement.
|
||||
*/
|
||||
public interface PsiImportStatement extends PsiImportStatementBase {
|
||||
/**
|
||||
* The empty array of PSI import statements which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiImportStatement[] EMPTY_ARRAY = new PsiImportStatement[0];
|
||||
|
||||
/**
|
||||
* Returns the full-qualified name of the imported class or package.
|
||||
*
|
||||
* @return the full-qualified name, or null if the statement is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
String getQualifiedName();
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.psi;
|
||||
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java <code>import</code> or <code>import static</code> statement.
|
||||
*
|
||||
* @author dsl
|
||||
*/
|
||||
public interface PsiImportStatementBase extends PsiElement {
|
||||
/**
|
||||
* The empty array of PSI base import statements which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiImportStatementBase[] EMPTY_ARRAY = new PsiImportStatementBase[0];
|
||||
|
||||
ArrayFactory<PsiImportStatementBase> ARRAY_FACTORY = new ArrayFactory<PsiImportStatementBase>() {
|
||||
@Override
|
||||
public PsiImportStatementBase[] create(final int count) {
|
||||
return count == 0 ? EMPTY_ARRAY : new PsiImportStatementBase[count];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if the statement represents a single element or on-demand import.
|
||||
*
|
||||
* @return true if the import statement is on-demand, false otherwise.
|
||||
*/
|
||||
boolean isOnDemand();
|
||||
|
||||
/**
|
||||
* Returns the reference element which specifies the imported class, package or member.
|
||||
*
|
||||
* @return the import reference element.
|
||||
* @see PsiImportStaticReferenceElement
|
||||
*/
|
||||
@Nullable
|
||||
PsiJavaCodeReferenceElement getImportReference();
|
||||
|
||||
/**
|
||||
* Resolves the reference to the imported class, package or member.
|
||||
*
|
||||
* @return the target element, or null if it was not possible to resolve the reference to a valid target.
|
||||
*/
|
||||
@Nullable
|
||||
PsiElement resolve();
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Represents a reference to the member imported by a Java <code>import static</code>
|
||||
* statement.
|
||||
*
|
||||
* @author dsl
|
||||
*/
|
||||
public interface PsiImportStaticReferenceElement extends PsiJavaCodeReferenceElement {
|
||||
/**
|
||||
* Returns the reference element specifying the class from which the member is imported.
|
||||
*
|
||||
* @return the reference element specifying the class.
|
||||
*/
|
||||
PsiJavaCodeReferenceElement getClassReference();
|
||||
|
||||
/**
|
||||
* Binds the reference element to the specified class.
|
||||
*
|
||||
* @param aClass the class to bind the reference element to.
|
||||
* @return the element corresponding to this element in the PSI tree after the rebind.
|
||||
* @throws IncorrectOperationException if the modification fails for some reason (for example,
|
||||
* the containing file is read-only).
|
||||
* @see PsiReference#bindToElement(PsiElement)
|
||||
*/
|
||||
PsiImportStaticStatement bindToTargetClass(PsiClass aClass) throws IncorrectOperationException;
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java <code>import static</code> statement.
|
||||
*
|
||||
* @author dsl
|
||||
*/
|
||||
public interface PsiImportStaticStatement extends PsiImportStatementBase {
|
||||
/**
|
||||
* The empty array of PSI static import statements which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiImportStaticStatement[] EMPTY_ARRAY = new PsiImportStaticStatement[0];
|
||||
|
||||
/**
|
||||
* Resolves the reference to the class from which members are imported.
|
||||
*
|
||||
* @return the class from which members are imported, or null if the reference resolve failed
|
||||
* or the resolve target is not a class.
|
||||
*/
|
||||
@Nullable
|
||||
PsiClass resolveTargetClass();
|
||||
|
||||
/**
|
||||
* Returns the name of the member imported from the statement.
|
||||
*
|
||||
* @return the name of the member, or null for an on-demand import.
|
||||
*/
|
||||
@Nullable
|
||||
String getReferenceName();
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a Java <code>instanceof</code> expression.
|
||||
*/
|
||||
public interface PsiInstanceOfExpression extends PsiExpression {
|
||||
/**
|
||||
* Returns the expression on the left side of the <code>instanceof</code>.
|
||||
*
|
||||
* @return the checked expression.
|
||||
*/
|
||||
@NotNull
|
||||
PsiExpression getOperand();
|
||||
|
||||
/**
|
||||
* Returns the type element on the right side of the <code>instanceof</code>.
|
||||
*
|
||||
* @return the type element, or null if the expression is incomplete.
|
||||
*/
|
||||
@Nullable
|
||||
PsiTypeElement getCheckType();
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
|
||||
// Intersection types arise in the process of computing lub.
|
||||
public class PsiIntersectionType extends PsiType {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.PsiIntersectionType");
|
||||
private final PsiType[] myConjuncts;
|
||||
|
||||
private PsiIntersectionType(@NotNull PsiType[] conjuncts) {
|
||||
super(PsiAnnotation.EMPTY_ARRAY);//todo
|
||||
LOG.assertTrue(conjuncts.length != 0);
|
||||
LOG.assertTrue(conjuncts.length > 1);
|
||||
myConjuncts = conjuncts;
|
||||
}
|
||||
|
||||
private static PsiType[] flattenAndRemoveDuplicates(PsiType[] conjuncts) {
|
||||
Set<PsiType> flattened = flatten(conjuncts, new THashSet<PsiType>());
|
||||
return flattened.toArray(new PsiType[flattened.size()]);
|
||||
}
|
||||
|
||||
private static Set<PsiType> flatten(PsiType[] conjuncts, Set<PsiType> types) {
|
||||
for (PsiType conjunct : conjuncts) {
|
||||
if (conjunct instanceof PsiIntersectionType) {
|
||||
PsiIntersectionType type = (PsiIntersectionType)conjunct;
|
||||
flatten(type.getConjuncts(), types);
|
||||
}
|
||||
else {
|
||||
types.add(conjunct);
|
||||
}
|
||||
}
|
||||
if (types.size() > 1) {
|
||||
PsiType[] array = types.toArray(new PsiType[types.size()]);
|
||||
for (Iterator<PsiType> iterator = types.iterator(); iterator.hasNext();) {
|
||||
PsiType type = iterator.next();
|
||||
|
||||
for (PsiType existing : array) {
|
||||
if (type != existing && type.isAssignableFrom(existing)) {
|
||||
iterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (types.isEmpty()) {
|
||||
types.add(array[0]);
|
||||
}
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiType[] getConjuncts() {
|
||||
return myConjuncts;
|
||||
}
|
||||
|
||||
public String getPresentableText() {
|
||||
return myConjuncts[0].getPresentableText();
|
||||
}
|
||||
|
||||
public String getCanonicalText() {
|
||||
return myConjuncts[0].getCanonicalText();
|
||||
}
|
||||
|
||||
public String getInternalCanonicalText() {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (int i = 0; i < myConjuncts.length; i++) {
|
||||
buffer.append(myConjuncts[i].getInternalCanonicalText());
|
||||
if (i < myConjuncts.length - 1) buffer.append(" & ");
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
for (PsiType conjunct : myConjuncts) {
|
||||
if (!conjunct.isValid()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean equalsToText(String text) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public <A> A accept(PsiTypeVisitor<A> visitor) {
|
||||
return myConjuncts[0].accept(visitor);
|
||||
}
|
||||
|
||||
public GlobalSearchScope getResolveScope() {
|
||||
return myConjuncts[0].getResolveScope();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiType[] getSuperTypes() {
|
||||
return myConjuncts;
|
||||
}
|
||||
|
||||
public static PsiType createIntersection(PsiType... conjuncts) {
|
||||
LOG.assertTrue(conjuncts.length >= 1);
|
||||
conjuncts = flattenAndRemoveDuplicates(conjuncts);
|
||||
if (conjuncts.length == 1) return conjuncts[0];
|
||||
return new PsiIntersectionType(conjuncts);
|
||||
}
|
||||
|
||||
public PsiType getRepresentative() {
|
||||
return myConjuncts[0];
|
||||
}
|
||||
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof PsiIntersectionType)) return false;
|
||||
final PsiType[] first = getConjuncts();
|
||||
final PsiType[] second = ((PsiIntersectionType)obj).getConjuncts();
|
||||
if (first.length != second.length) return false;
|
||||
//positional equality
|
||||
for (int i = 0; i < first.length; i++) {
|
||||
if (!first[i].equals(second[i])) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return myConjuncts[0].hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = "PsiIntersectionType: ";
|
||||
for (PsiType conjunct : myConjuncts) {
|
||||
s += conjunct.getPresentableText() +", ";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
/**
|
||||
* Represents a fragment of Java code the contents of which is a reference element
|
||||
* referencing a Java class or package.
|
||||
*
|
||||
* @author ven
|
||||
* @see PsiElementFactory#createReferenceCodeFragment(String, PsiElement, boolean, boolean)
|
||||
*/
|
||||
public interface PsiJavaCodeReferenceCodeFragment extends JavaCodeFragment {
|
||||
/**
|
||||
* Returns the reference contained in the fragment.
|
||||
*
|
||||
* @return the reference element instance.
|
||||
*/
|
||||
PsiJavaCodeReferenceElement getReferenceElement();
|
||||
|
||||
/**
|
||||
* Checks if classes are accepted as the target of the reference.
|
||||
*
|
||||
* @return if true then classes as well as packages are accepted as reference target,
|
||||
* otherwise only packages are.
|
||||
*/
|
||||
boolean isClassesAccepted();
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a reference found in Java code (either an identifier or a sequence of identifiers
|
||||
* separated by periods, optionally with generic type arguments).
|
||||
*/
|
||||
public interface PsiJavaCodeReferenceElement extends PsiJavaReference, PsiQualifiedReference {
|
||||
/**
|
||||
* The empty array of PSI Java code references which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiJavaCodeReferenceElement[] EMPTY_ARRAY = new PsiJavaCodeReferenceElement[0];
|
||||
|
||||
ArrayFactory<PsiJavaCodeReferenceElement> ARRAY_FACTORY = new ArrayFactory<PsiJavaCodeReferenceElement>() {
|
||||
public PsiJavaCodeReferenceElement[] create(int count) {
|
||||
return count == 0 ? EMPTY_ARRAY : new PsiJavaCodeReferenceElement[count];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the element representing the name of the referenced element.
|
||||
*
|
||||
* @return the element, or null if the reference element is not physical (for example,
|
||||
* exists in compiled code).
|
||||
*/
|
||||
@Nullable
|
||||
PsiElement getReferenceNameElement();
|
||||
|
||||
/**
|
||||
* Returns the list of type arguments specified on the reference.
|
||||
*
|
||||
* @return the type argument list, or null if the reference does not have any type arguments.
|
||||
*/
|
||||
@Nullable
|
||||
PsiReferenceParameterList getParameterList();
|
||||
|
||||
/**
|
||||
* Returns the array of types for the type arguments specified on the reference.
|
||||
*
|
||||
* @return the array of types, or an empty array if the reference does not have any type arguments.
|
||||
*/
|
||||
@NotNull
|
||||
PsiType[] getTypeParameters();
|
||||
|
||||
/**
|
||||
* Checks if the reference is qualified (consists of elements separated with periods).
|
||||
*
|
||||
* @return true if the reference is qualified, false otherwise.
|
||||
*/
|
||||
boolean isQualified();
|
||||
|
||||
/**
|
||||
* Returns the text of the reference including its qualifier.
|
||||
*
|
||||
* @return the qualified text of the reference.
|
||||
*/
|
||||
String getQualifiedName();
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
/**
|
||||
* Represents a Java or JSP file.
|
||||
*/
|
||||
public interface PsiJavaFile extends PsiImportHolder, PsiClassOwner {
|
||||
|
||||
/**
|
||||
* Returns the package statement contained in the file.
|
||||
*
|
||||
* @return the package statement, or null if one is missing.
|
||||
*/
|
||||
@Nullable PsiPackageStatement getPackageStatement();
|
||||
|
||||
/**
|
||||
* Returns the name of the package to which the file belongs.
|
||||
*
|
||||
* @return the name specified in the package statement, or an empty string for a JSP page or
|
||||
* file which has no package statement.
|
||||
*/
|
||||
@NotNull String getPackageName();
|
||||
|
||||
/**
|
||||
* Returns the import list contained in the file.
|
||||
*
|
||||
* @return the import list, or null if this element represents a compiled class.
|
||||
*/
|
||||
@Nullable PsiImportList getImportList();
|
||||
|
||||
/**
|
||||
* Returns the list of classes or packages which have been
|
||||
* imported on demand (for example, javax.swing.*)
|
||||
*
|
||||
* @param includeImplicit if true, implicitly imported packages (like java.lang) are included.
|
||||
* @param checkIncludes deprecated, no longer used
|
||||
* @return the list of PsiClass or PsiPackage elements for the imports.
|
||||
*/
|
||||
@NotNull PsiElement[] getOnDemandImports(boolean includeImplicit, @Deprecated boolean checkIncludes);
|
||||
|
||||
/**
|
||||
* Returns the list of classes which have been imported as
|
||||
* single-class imports.
|
||||
*
|
||||
* @param checkIncludes deprecated, no longer used.
|
||||
* @return the list of PsiClass elements for the import.
|
||||
*/
|
||||
@NotNull PsiClass[] getSingleClassImports(@Deprecated boolean checkIncludes);
|
||||
|
||||
/**
|
||||
* Returns the list of names of implicitly imported packages
|
||||
* (for example, java.lang).
|
||||
*
|
||||
* @return the list of implicitly imported package names.
|
||||
*/
|
||||
@NotNull String[] getImplicitlyImportedPackages();
|
||||
|
||||
/**
|
||||
* returns the list of reference elements for the
|
||||
* implicitly imported packages (for example, java.lang).
|
||||
*
|
||||
* @return the list of implicitly imported package reference elements.
|
||||
*/
|
||||
@NotNull PsiJavaCodeReferenceElement[] getImplicitlyImportedPackageReferences();
|
||||
|
||||
/**
|
||||
* Returns the single-class import statement which references
|
||||
* the specified class, or null if there is no such statement.
|
||||
*
|
||||
* @param aClass the class to return the import statement for.
|
||||
* @return the Java code reference under the import statement, or null if there is no such statement.
|
||||
*/
|
||||
@Nullable PsiJavaCodeReferenceElement findImportReferenceTo(PsiClass aClass);
|
||||
|
||||
@NotNull LanguageLevel getLanguageLevel();
|
||||
}
|
||||
@@ -1,233 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.psi;
|
||||
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public interface PsiJavaParserFacade {
|
||||
/**
|
||||
* Creates a JavaDoc tag from the specified text.
|
||||
*
|
||||
* @param docTagText the text of the JavaDoc tag.
|
||||
* @return the created tag.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text of the tag is not valid.
|
||||
*/
|
||||
@NotNull
|
||||
PsiDocTag createDocTagFromText(@NotNull String docTagText) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a JavaDoc comment from the specified text.
|
||||
*
|
||||
* @param docCommentText the text of the JavaDoc comment.
|
||||
* @return the created comment.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text of the comment is not valid.
|
||||
*/
|
||||
@NotNull
|
||||
PsiDocComment createDocCommentFromText(@NotNull String docCommentText) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java class from the specified text.
|
||||
*
|
||||
* @param text the text of the class to create.
|
||||
* @param context the PSI element used as context for resolving references which cannot be resolved
|
||||
* within the class.
|
||||
* @return the created class instance.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text is not a valid class body.
|
||||
*/
|
||||
@NotNull
|
||||
PsiClass createClassFromText(@NotNull @NonNls String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java field from the specified text.
|
||||
*
|
||||
* @param text the text of the field to create.
|
||||
* @param context the PSI element used as context for resolving references from the field.
|
||||
* @return the created field instance.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text is not a valid field body.
|
||||
*/
|
||||
@NotNull
|
||||
PsiField createFieldFromText(@NotNull @NonNls String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java method from the specified text with the specified language level.
|
||||
*
|
||||
* @param text the text of the method to create.
|
||||
* @param context the PSI element used as context for resolving references from the method.
|
||||
* @param languageLevel the language level used for creating the method.
|
||||
* @return the created method instance.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text is not a valid method body.
|
||||
*/
|
||||
@NotNull
|
||||
PsiMethod createMethodFromText(@NotNull @NonNls String text, @Nullable PsiElement context, LanguageLevel languageLevel) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java method from the specified text.
|
||||
*
|
||||
* @param text the text of the method to create.
|
||||
* @param context the PSI element used as context for resolving references from the method.
|
||||
* @return the created method instance.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text is not a valid method body.
|
||||
*/
|
||||
@NotNull
|
||||
PsiMethod createMethodFromText(@NotNull @NonNls String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java parameter from the specified text.
|
||||
*
|
||||
* @param text the text of the parameter to create.
|
||||
* @param context the PSI element used as context for resolving references from the parameter.
|
||||
* @return the created parameter instance.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text is not a valid parameter body.
|
||||
*/
|
||||
@NotNull
|
||||
PsiParameter createParameterFromText(@NotNull @NonNls String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java try-resource from the specified text.
|
||||
*
|
||||
* @param text the text of the resource to create.
|
||||
* @param context the PSI element used as context for resolving references from the resource.
|
||||
* @return the created resource instance.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text is not a valid resource definition.
|
||||
*/
|
||||
@NotNull
|
||||
PsiResourceVariable createResourceFromText(@NotNull String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java type from the specified text.
|
||||
*
|
||||
* @param text the text of the type to create (for example, a primitive type keyword, an array
|
||||
* declaration or the name of a class).
|
||||
* @param context the PSI element used as context for resolving the reference.
|
||||
* @return the created type instance.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text does not specify a valid type.
|
||||
*/
|
||||
@NotNull
|
||||
PsiType createTypeFromText(@NotNull @NonNls String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java type element from the specified text.
|
||||
*
|
||||
* @param text the text of the type to create (for example, a primitive type keyword, an array
|
||||
* declaration or the name of a class).
|
||||
* @param context the PSI element used as context for resolving the reference.
|
||||
* @return the created type element.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text does not specify a valid type.
|
||||
*/
|
||||
@NotNull
|
||||
PsiTypeElement createTypeElementFromText(@NotNull @NonNls String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java code reference from the specified text.
|
||||
*
|
||||
* @param text the text of the type to create (for example, a primitive type keyword, an array
|
||||
* declaration or the name of a class).
|
||||
* @param context the PSI element used as context for resolving the reference.
|
||||
* @return the created reference element.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text does not specify a valid type.
|
||||
*/
|
||||
@NotNull
|
||||
PsiJavaCodeReferenceElement createReferenceFromText(@NotNull @NonNls String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java code block from the specified text.
|
||||
*
|
||||
* @param text the text of the code block to create.
|
||||
* @param context the PSI element used as context for resolving references from the block.
|
||||
* @return the created code block instance.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text does not specify a valid code block.
|
||||
*/
|
||||
@NotNull
|
||||
PsiCodeBlock createCodeBlockFromText(@NotNull @NonNls String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java statement from the specified text.
|
||||
*
|
||||
* @param text the text of the statement to create.
|
||||
* @param context the PSI element used as context for resolving references from the statement.
|
||||
* @return the created statement instance.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text does not specify a valid statement.
|
||||
*/
|
||||
@NotNull
|
||||
PsiStatement createStatementFromText(@NotNull @NonNls String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java expression from the specified text.
|
||||
*
|
||||
* @param text the text of the expression to create.
|
||||
* @param context the PSI element used as context for resolving references from the expression.
|
||||
* @return the created expression instance.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text does not specify a valid expression.
|
||||
*/
|
||||
@NotNull
|
||||
PsiExpression createExpressionFromText(@NotNull @NonNls String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java comment from the specified text.
|
||||
*
|
||||
* @param text the text of the comment to create.
|
||||
* @param context the PSI element used as context for resolving references from the comment.
|
||||
* @return the created comment instance.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text does not specify a valid comment.
|
||||
*/
|
||||
@NotNull
|
||||
PsiComment createCommentFromText(@NotNull String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a type parameter from the specified text.
|
||||
*
|
||||
* @param text the text of the type parameter to create.
|
||||
* @param context the context for resolving references.
|
||||
* @return the created type parameter instance.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text does not specify a valid type parameter.
|
||||
*/
|
||||
@NotNull
|
||||
PsiTypeParameter createTypeParameterFromText(@NotNull @NonNls String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates an annotation from the specified text.
|
||||
*
|
||||
* @param annotationText the text of the annotation to create.
|
||||
* @param context the context for resolving references from the annotation.
|
||||
* @return the created annotation instance.
|
||||
* @throws com.intellij.util.IncorrectOperationException if the text does not specify a valid annotation.
|
||||
*/
|
||||
@NotNull
|
||||
PsiAnnotation createAnnotationFromText(@NotNull @NonNls String annotationText, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
@NotNull
|
||||
PsiEnumConstant createEnumConstantFromText(@NotNull String text, @Nullable PsiElement context) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* Creates a Java type from the specified text.
|
||||
*
|
||||
* @param text the text of the type to create (a primitive type keyword).
|
||||
* @param annotations array (possible empty) of annotations to annotate the created type.
|
||||
* @return the created type instance.
|
||||
* @throws IncorrectOperationException if some of the parameters are not valid.
|
||||
*/
|
||||
@NotNull
|
||||
PsiType createPrimitiveType(@NotNull String text, @NotNull PsiAnnotation[] annotations) throws IncorrectOperationException;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a reference found in Java code.
|
||||
*/
|
||||
public interface PsiJavaReference extends PsiPolyVariantReference {
|
||||
/**
|
||||
* Passes all variants to which the reference may resolve to the specified
|
||||
* processor.
|
||||
*
|
||||
* @param processor the processor accepting the variants.s
|
||||
*/
|
||||
void processVariants(PsiScopeProcessor processor);
|
||||
|
||||
/**
|
||||
* Resolves the reference and returns the result as a {@link JavaResolveResult}
|
||||
* instead of a plain {@link PsiElement}.
|
||||
*
|
||||
* @param incompleteCode if true, the code in the context of which the reference is
|
||||
* being resolved is considered incomplete, and the method may return an invalid
|
||||
* result.
|
||||
* @return the result of the resolve.
|
||||
*/
|
||||
@NotNull
|
||||
JavaResolveResult advancedResolve(boolean incompleteCode);
|
||||
|
||||
@NotNull
|
||||
JavaResolveResult[] multiResolve(boolean incompleteCode);
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
|
||||
/**
|
||||
* Represents a single token in a Java file (the lowest-level element in the Java PSI tree).
|
||||
*/
|
||||
public interface PsiJavaToken extends PsiElement {
|
||||
/**
|
||||
* Returns the type of the token.
|
||||
*
|
||||
* @return the token type.
|
||||
*/
|
||||
IElementType getTokenType();
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
/**
|
||||
* Represents a Java keyword. Constants defined in this interface represent all
|
||||
* keywords of the Java language.
|
||||
*/
|
||||
@SuppressWarnings({"HardCodedStringLiteral", "JavaDoc"})
|
||||
public interface PsiKeyword extends PsiJavaToken {
|
||||
String ABSTRACT = "abstract";
|
||||
String ASSERT = "assert";
|
||||
String BOOLEAN = "boolean";
|
||||
String BREAK = "break";
|
||||
String BYTE = "byte";
|
||||
String CASE = "case";
|
||||
String CATCH = "catch";
|
||||
String CHAR = "char";
|
||||
String CLASS = "class";
|
||||
String CONST = "const";
|
||||
String CONTINUE = "continue";
|
||||
String DEFAULT = "default";
|
||||
String DO = "do";
|
||||
String DOUBLE = "double";
|
||||
String ELSE = "else";
|
||||
String ENUM = "enum";
|
||||
String EXTENDS = "extends";
|
||||
String FINAL = "final";
|
||||
String FINALLY = "finally";
|
||||
String FLOAT = "float";
|
||||
String FOR = "for";
|
||||
String GOTO = "goto";
|
||||
String IF = "if";
|
||||
String IMPLEMENTS = "implements";
|
||||
String IMPORT = "import";
|
||||
String INSTANCEOF = "instanceof";
|
||||
String INT = "int";
|
||||
String INTERFACE = "interface";
|
||||
String LONG = "long";
|
||||
String NATIVE = "native";
|
||||
String NEW = "new";
|
||||
String PACKAGE = "package";
|
||||
String PRIVATE = "private";
|
||||
String PROTECTED = "protected";
|
||||
String PUBLIC = "public";
|
||||
String RETURN = "return";
|
||||
String SHORT = "short";
|
||||
String SUPER = "super";
|
||||
String SWITCH = "switch";
|
||||
String SYNCHRONIZED = "synchronized";
|
||||
String THIS = "this";
|
||||
String THROW = "throw";
|
||||
String THROWS = "throws";
|
||||
String TRANSIENT = "transient";
|
||||
String TRY = "try";
|
||||
String VOID = "void";
|
||||
String STATIC = "static";
|
||||
String STRICTFP = "strictfp";
|
||||
String WHILE = "while";
|
||||
String VOLATILE = "volatile";
|
||||
|
||||
String TRUE = "true";
|
||||
String FALSE = "false";
|
||||
String NULL = "null";
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a Java statement with an attached label.
|
||||
*/
|
||||
public interface PsiLabeledStatement extends PsiStatement, PsiNamedElement {
|
||||
/**
|
||||
* Returns the identifier representing the label attached to the statement.
|
||||
*
|
||||
* @return the label identifier.
|
||||
*/
|
||||
@NotNull
|
||||
PsiIdentifier getLabelIdentifier();
|
||||
|
||||
/**
|
||||
* Returns the statement to which the label is attached.
|
||||
*
|
||||
* @return the statement instance, or null if the label is not followed by any statement.
|
||||
*/
|
||||
@Nullable
|
||||
PsiStatement getStatement();
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface PsiLiteral extends PsiAnnotationMemberValue {
|
||||
/**
|
||||
* Returns the value of the literal expression (an Integer for an integer constant, a String
|
||||
* for a string literal, and so on).
|
||||
*
|
||||
* @return the value of the expression, or null if the parsing of the literal failed.
|
||||
*/
|
||||
@Nullable
|
||||
Object getValue();
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a Java literal expression.
|
||||
*/
|
||||
public interface PsiLiteralExpression extends PsiExpression, PsiLiteral {
|
||||
/** @deprecated (to remove in IDEA 12) */
|
||||
@Nullable
|
||||
String getParsingError();
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a Java local variable.
|
||||
*/
|
||||
public interface PsiLocalVariable extends PsiVariable {
|
||||
/**
|
||||
* Adds initializer to the variable declaration statement or, if <code>initializer</code>
|
||||
* parameter is null, removes initializer from variable.
|
||||
*
|
||||
* @param initializer the initializer to add.
|
||||
* @throws IncorrectOperationException if the modifications fails for some reason.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
void setInitializer(@Nullable PsiExpression initializer) throws IncorrectOperationException;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@NotNull
|
||||
PsiTypeElement getTypeElement();
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public interface PsiLoopStatement extends PsiStatement {
|
||||
/**
|
||||
* Returns the body of the statement.
|
||||
*
|
||||
* @return the body of the statement, or null if the body is empty
|
||||
*/
|
||||
@Nullable PsiStatement getBody();
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a member of a Java class (for example, a field or a method).
|
||||
*/
|
||||
public interface PsiMember extends PsiModifierListOwner, NavigatablePsiElement {
|
||||
/**
|
||||
* The empty array of PSI members which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiMember[] EMPTY_ARRAY = new PsiMember[0];
|
||||
|
||||
/**
|
||||
* Returns the class containing the member.
|
||||
*
|
||||
* @return the containing class.
|
||||
*/
|
||||
@Nullable
|
||||
PsiClass getContainingClass();
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user