This commit is contained in:
Alexey Kudravtsev
2013-04-26 15:06:14 +04:00
parent 2dd770497c
commit 8c7aa7dde0
40 changed files with 57 additions and 7 deletions
@@ -33,6 +33,7 @@ public interface PsiAnnotation extends PsiAnnotationMemberValue, PsiMetaOwner {
PsiAnnotation[] EMPTY_ARRAY = new PsiAnnotation[0];
ArrayFactory<PsiAnnotation> ARRAY_FACTORY = new ArrayFactory<PsiAnnotation>() {
@NotNull
@Override
public PsiAnnotation[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiAnnotation[count];
@@ -16,6 +16,7 @@
package com.intellij.psi;
import com.intellij.util.ArrayFactory;
import org.jetbrains.annotations.NotNull;
/**
* Represents a PSI element which can be used as the value of an annotation element.
@@ -29,6 +30,7 @@ public interface PsiAnnotationMemberValue extends PsiElement {
PsiAnnotationMemberValue[] EMPTY_ARRAY = new PsiAnnotationMemberValue[0];
ArrayFactory<PsiAnnotationMemberValue> ARRAY_FACTORY = new ArrayFactory<PsiAnnotationMemberValue>() {
@NotNull
@Override
public PsiAnnotationMemberValue[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiAnnotationMemberValue[count];
@@ -33,6 +33,7 @@ public interface PsiCatchSection extends PsiElement {
PsiCatchSection[] EMPTY_ARRAY = new PsiCatchSection[0];
ArrayFactory<PsiCatchSection> ARRAY_FACTORY = new ArrayFactory<PsiCatchSection>() {
@NotNull
@Override
public PsiCatchSection[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiCatchSection[count];
@@ -29,7 +29,7 @@ import java.util.List;
/**
* Represents a Java class or interface.
*
* @see PsiJavaFile#getClasses()
* @see PsiJavaFile#getClasses()
*/
public interface PsiClass
extends PsiNameIdentifierOwner, PsiModifierListOwner, PsiDocCommentOwner, PsiTypeParameterListOwner, PsiTarget, PomRenameableTarget<PsiElement> {
@@ -39,6 +39,7 @@ public interface PsiClass
@NotNull PsiClass[] EMPTY_ARRAY = new PsiClass[0];
ArrayFactory<PsiClass> ARRAY_FACTORY = new ArrayFactory<PsiClass>() {
@NotNull
@Override
public PsiClass[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiClass[count];
@@ -349,7 +350,7 @@ public interface PsiClass
* its superclasses and superinterfaces.
*
* @return the collection of signatures.
* @since 5.1
* @since 5.1
*/
@NotNull
Collection<HierarchicalMethodSignature> getVisibleSignatures();
@@ -28,6 +28,7 @@ public interface PsiClassInitializer extends PsiMember {
PsiClassInitializer[] EMPTY_ARRAY = new PsiClassInitializer[0];
ArrayFactory<PsiClassInitializer> ARRAY_FACTORY = new ArrayFactory<PsiClassInitializer>() {
@NotNull
@Override
public PsiClassInitializer[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiClassInitializer[count];
@@ -34,6 +34,7 @@ public abstract class PsiClassType extends PsiType {
*/
public static final PsiClassType[] EMPTY_ARRAY = new PsiClassType[0];
public static final ArrayFactory<PsiClassType> ARRAY_FACTORY = new ArrayFactory<PsiClassType>() {
@NotNull
@Override
public PsiClassType[] create(int count) {
return new PsiClassType[count];
@@ -18,6 +18,7 @@ package com.intellij.psi;
import com.intellij.util.ArrayFactory;
import com.intellij.util.Function;
import com.intellij.util.NullableFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -30,6 +31,7 @@ public interface PsiExpression extends PsiAnnotationMemberValue {
PsiExpression[] EMPTY_ARRAY = new PsiExpression[0];
ArrayFactory<PsiExpression> ARRAY_FACTORY = new ArrayFactory<PsiExpression>() {
@NotNull
@Override
public PsiExpression[] create(final int count) {
return count == 0 ? PsiExpression.EMPTY_ARRAY : new PsiExpression[count];
@@ -30,6 +30,7 @@ public interface PsiField extends PsiMember, PsiVariable, PsiDocCommentOwner {
PsiField[] EMPTY_ARRAY = new PsiField[0];
ArrayFactory<PsiField> ARRAY_FACTORY = new ArrayFactory<PsiField>() {
@NotNull
@Override
public PsiField[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiField[count];
@@ -23,11 +23,12 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents the list of import statements contained in a Java or JSP file.
*
* @see PsiJavaFile#getImportList()
* @see PsiJavaFile#getImportList()
*/
public interface PsiImportList extends PsiElement {
PsiImportList[] EMPTY_ARRAY = new PsiImportList[0];
ArrayFactory<PsiImportList> ARRAY_FACTORY = new ArrayFactory<PsiImportList>() {
@NotNull
@Override
public PsiImportList[] create(int count) {
return count == 0 ? EMPTY_ARRAY : new PsiImportList[count];
@@ -16,6 +16,7 @@
package com.intellij.psi;
import com.intellij.util.ArrayFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -30,6 +31,7 @@ public interface PsiImportStatementBase extends PsiElement {
PsiImportStatementBase[] EMPTY_ARRAY = new PsiImportStatementBase[0];
ArrayFactory<PsiImportStatementBase> ARRAY_FACTORY = new ArrayFactory<PsiImportStatementBase>() {
@NotNull
@Override
public PsiImportStatementBase[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiImportStatementBase[count];
@@ -30,6 +30,7 @@ public interface PsiJavaCodeReferenceElement extends PsiJavaReference, PsiQualif
PsiJavaCodeReferenceElement[] EMPTY_ARRAY = new PsiJavaCodeReferenceElement[0];
ArrayFactory<PsiJavaCodeReferenceElement> ARRAY_FACTORY = new ArrayFactory<PsiJavaCodeReferenceElement>() {
@NotNull
@Override
public PsiJavaCodeReferenceElement[] create(int count) {
return count == 0 ? EMPTY_ARRAY : new PsiJavaCodeReferenceElement[count];
@@ -39,6 +39,7 @@ public interface PsiMethod extends PsiMember, PsiNameIdentifierOwner, PsiModifie
PsiMethod[] EMPTY_ARRAY = new PsiMethod[0];
ArrayFactory<PsiMethod> ARRAY_FACTORY = new ArrayFactory<PsiMethod>() {
@NotNull
@Override
public PsiMethod[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiMethod[count];
@@ -34,6 +34,7 @@ public interface PsiNameValuePair extends PsiElement {
PsiNameValuePair[] EMPTY_ARRAY = new PsiNameValuePair[0];
ArrayFactory<PsiNameValuePair> ARRAY_FACTORY = new ArrayFactory<PsiNameValuePair>() {
@NotNull
@Override
public PsiNameValuePair[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiNameValuePair[count];
@@ -29,6 +29,7 @@ public interface PsiParameter extends PsiVariable {
PsiParameter[] EMPTY_ARRAY = new PsiParameter[0];
ArrayFactory<PsiParameter> ARRAY_FACTORY = new ArrayFactory<PsiParameter>() {
@NotNull
@Override
public PsiParameter[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiParameter[count];
@@ -16,6 +16,7 @@
package com.intellij.psi;
import com.intellij.util.ArrayFactory;
import org.jetbrains.annotations.NotNull;
/**
* Represents a Java statement.
@@ -27,6 +28,7 @@ public interface PsiStatement extends PsiElement {
PsiStatement[] EMPTY_ARRAY = new PsiStatement[0];
ArrayFactory<PsiStatement> ARRAY_FACTORY = new ArrayFactory<PsiStatement>() {
@NotNull
@Override
public PsiStatement[] create(final int count) {
return count == 0 ? PsiStatement.EMPTY_ARRAY : new PsiStatement[count];
@@ -30,6 +30,7 @@ public interface PsiTypeElement extends PsiElement,PsiAnnotationOwner {
PsiTypeElement[] EMPTY_ARRAY = new PsiTypeElement[0];
ArrayFactory<PsiTypeElement> ARRAY_FACTORY = new ArrayFactory<PsiTypeElement>() {
@NotNull
@Override
public PsiTypeElement[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiTypeElement[count];
@@ -31,6 +31,7 @@ public interface PsiTypeParameter extends PsiClass, PsiAnnotationOwner {
PsiTypeParameter[] EMPTY_ARRAY = new PsiTypeParameter[0];
ArrayFactory<PsiTypeParameter> ARRAY_FACTORY = new ArrayFactory<PsiTypeParameter>() {
@NotNull
@Override
public PsiTypeParameter[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiTypeParameter[count];
@@ -34,6 +34,7 @@ public class PsiImportListImpl extends JavaStubPsiElement<PsiImportListStub> imp
private volatile Map<String,PsiImportStatementBase> myNameToSingleImportMap = null;
private static final PsiImportStatementBase[] EMPTY_ARRAY = new PsiImportStatementBase[0];
private static final ArrayFactory<PsiImportStatementBase> ARRAY_FACTORY = new ArrayFactory<PsiImportStatementBase>() {
@NotNull
@Override
public PsiImportStatementBase[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiImportStatementBase[count];
@@ -25,6 +25,7 @@ import org.jetbrains.annotations.NotNull;
public class PsiImportStatementImpl extends PsiImportStatementBaseImpl implements PsiImportStatement {
public static final PsiImportStatementImpl[] EMPTY_ARRAY = new PsiImportStatementImpl[0];
public static final ArrayFactory<PsiImportStatementImpl> ARRAY_FACTORY = new ArrayFactory<PsiImportStatementImpl>() {
@NotNull
@Override
public PsiImportStatementImpl[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiImportStatementImpl[count];
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable;
public class PsiImportStaticStatementImpl extends PsiImportStatementBaseImpl implements PsiImportStaticStatement {
public static final PsiImportStaticStatementImpl[] EMPTY_ARRAY = new PsiImportStaticStatementImpl[0];
public static final ArrayFactory<PsiImportStaticStatementImpl> ARRAY_FACTORY = new ArrayFactory<PsiImportStaticStatementImpl>() {
@NotNull
@Override
public PsiImportStaticStatementImpl[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiImportStaticStatementImpl[count];
@@ -42,6 +42,7 @@ public class PsiDocCommentImpl extends LazyParseablePsiElement implements PsiDoc
private static final TokenSet TAG_BIT_SET = TokenSet.create(DOC_TAG);
private static final ArrayFactory<PsiDocTag> ARRAY_FACTORY = new ArrayFactory<PsiDocTag>() {
@NotNull
@Override
public PsiDocTag[] create(final int count) {
return count == 0 ? PsiDocTag.EMPTY_ARRAY : new PsiDocTag[count];
@@ -44,6 +44,7 @@ public interface PsiElement extends UserDataHolder, Iconable {
PsiElement[] EMPTY_ARRAY = new PsiElement[0];
ArrayFactory<PsiElement> ARRAY_FACTORY = new ArrayFactory<PsiElement>() {
@NotNull
@Override
public PsiElement[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiElement[count];
@@ -29,7 +29,7 @@ import org.jetbrains.annotations.Nullable;
*
* @see PsiPolyVariantReference
* @see PsiElement#getReference()
* @see PsiElement#getReferences()
* @see PsiElement#getReferences()
* @see com.intellij.psi.PsiReferenceService#getReferences(PsiElement, com.intellij.psi.PsiReferenceService.Hints)
* @see com.intellij.psi.PsiReferenceBase
* @see com.intellij.psi.PsiReferenceContributor
@@ -42,6 +42,7 @@ public interface PsiReference {
PsiReference[] EMPTY_ARRAY = new PsiReference[0];
ArrayFactory<PsiReference> ARRAY_FACTORY = new ArrayFactory<PsiReference>() {
@NotNull
@Override
public PsiReference[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new PsiReference[count];
@@ -118,7 +119,7 @@ public interface PsiReference {
*
* @return the array of available identifiers.
*/
@NotNull
@NotNull
Object[] getVariants();
/**
@@ -28,6 +28,7 @@ import org.jetbrains.annotations.NotNull;
public interface CommonProblemDescriptor {
CommonProblemDescriptor[] EMPTY_ARRAY = new CommonProblemDescriptor[0];
ArrayFactory<CommonProblemDescriptor> ARRAY_FACTORY = new ArrayFactory<CommonProblemDescriptor>() {
@NotNull
@Override
public CommonProblemDescriptor[] create(final int count) {
return count == 0 ? EMPTY_ARRAY : new CommonProblemDescriptor[count];
@@ -47,7 +48,7 @@ public interface CommonProblemDescriptor {
/**
* Returns the quickfixes for the problem.
*
* @return the list of quickfixes registered for the problem.
* @return the list of quickfixes registered for the problem.
*/
QuickFix[] getFixes();
}
@@ -651,6 +651,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
private void removeFromArray(int index) {
myChildren = ArrayUtil.remove(myChildren, index, new ArrayFactory<VirtualFileSystemEntry>() {
@NotNull
@Override
public VirtualFileSystemEntry[] create(int count) {
return new VirtualFileSystemEntry[count];
@@ -256,6 +256,7 @@ public final class DirectoryInfo {
}
private static final ArrayFactory<OrderEntry> ORDER_ENTRY_ARRAY_FACTORY = new ArrayFactory<OrderEntry>() {
@NotNull
@Override
public OrderEntry[] create(int count) {
return count == 0 ? OrderEntry.EMPTY_ARRAY : new OrderEntry[count];
@@ -19,6 +19,9 @@
*/
package com.intellij.util;
import org.jetbrains.annotations.NotNull;
public interface ArrayFactory<T> {
@NotNull
T[] create(int count);
}
@@ -47,12 +47,14 @@ public class ArrayUtil extends ArrayUtilRt {
public static final CharSequence EMPTY_CHAR_SEQUENCE = new CharArrayCharSequence(EMPTY_CHAR_ARRAY);
public static final ArrayFactory<String> STRING_ARRAY_FACTORY = new ArrayFactory<String>() {
@NotNull
@Override
public String[] create(int count) {
return newStringArray(count);
}
};
public static final ArrayFactory<Object> OBJECT_ARRAY_FACTORY = new ArrayFactory<Object>() {
@NotNull
@Override
public Object[] create(int count) {
return newObjectArray(count);
@@ -19,6 +19,7 @@ package org.intellij.plugins.intelliLang.inject.config;
import com.intellij.patterns.ElementPattern;
import com.intellij.psi.PsiElement;
import com.intellij.util.ArrayFactory;
import org.jetbrains.annotations.NotNull;
/**
* @author Gregory.Shrago
@@ -29,6 +30,7 @@ public class InjectionPlace {
public static final InjectionPlace[] EMPTY_ARRAY = new InjectionPlace[0];
public static final ArrayFactory<InjectionPlace> ARRAY_FACTORY = new ArrayFactory<InjectionPlace>() {
@NotNull
@Override
public InjectionPlace[] create(int count) {
return count == 0? EMPTY_ARRAY : new InjectionPlace[count];
@@ -34,6 +34,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
public interface GrVariable extends PsiVariable, GrNamedElement {
GrVariable[] EMPTY_ARRAY = new GrVariable[0];
ArrayFactory<GrVariable> ARRAY_FACTORY = new ArrayFactory<GrVariable>() {
@NotNull
@Override
public GrVariable[] create(int count) {
return new GrVariable[count];
@@ -16,6 +16,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
*/
public interface GrVariableDeclaration extends GrStatement, GrMembersDeclaration {
ArrayFactory<GrVariableDeclaration> ARRAY_FACTORY = new ArrayFactory<GrVariableDeclaration>() {
@NotNull
@Override
public GrVariableDeclaration[] create(int count) {
return new GrVariableDeclaration[count];
@@ -34,6 +34,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
public interface GrParameter extends PsiParameter, GrVariable, GrCondition {
GrParameter[] EMPTY_ARRAY = new GrParameter[0];
ArrayFactory<GrParameter> ARRAY_FACTORY = new ArrayFactory<GrParameter>() {
@NotNull
@Override
public GrParameter[] create(int count) {
return new GrParameter[count];
@@ -26,6 +26,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
*/
public interface GrReferenceList extends GroovyPsiElement {
ArrayFactory<GrReferenceList> ARRAY_FACTORY = new ArrayFactory<GrReferenceList>() {
@NotNull
@Override
public GrReferenceList[] create(int count) {
return new GrReferenceList[0];
@@ -43,6 +43,7 @@ public interface GrTypeDefinition
GrTypeDefinition[] EMPTY_ARRAY = new GrTypeDefinition[0];
ArrayFactory<GrTypeDefinition> ARRAY_FACTORY = new ArrayFactory<GrTypeDefinition>() {
@NotNull
@Override
public GrTypeDefinition[] create(int count) {
return new GrTypeDefinition[count];
@@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members;
import com.intellij.psi.PsiEnumConstant;
import com.intellij.util.ArrayFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
@@ -31,6 +32,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumConsta
public interface GrEnumConstant extends GrField, GrConstructorCall, PsiEnumConstant {
GrEnumConstant[] EMPTY_ARRAY = new GrEnumConstant[0];
ArrayFactory<GrEnumConstant> ARRAY_FACTORY = new ArrayFactory<GrEnumConstant>() {
@NotNull
@Override
public GrEnumConstant[] create(int count) {
return new GrEnumConstant[count];
@@ -44,6 +44,7 @@ public interface GrMethod extends GrMembersDeclaration, GrNamedElement, PsiMetho
GrParametersOwner, GrTopLevelDefinition, GrTypeParameterListOwner, GrDocCommentOwner {
GrMethod[] EMPTY_ARRAY = new GrMethod[0];
ArrayFactory<GrMethod> ARRAY_FACTORY = new ArrayFactory<GrMethod>() {
@NotNull
@Override
public GrMethod[] create(int count) {
return new GrMethod[count];
@@ -64,6 +64,7 @@ public class GrModifierListImpl extends GrStubElementBase<GrModifierListStub> im
public static final TObjectIntHashMap<String> NAME_TO_MODIFIER_FLAG_MAP = new TObjectIntHashMap<String>();
public static final Map<String, IElementType> NAME_TO_MODIFIER_ELEMENT_TYPE = ContainerUtil.newHashMap();
private static final ArrayFactory<GrAnnotation> ARRAY_FACTORY = new ArrayFactory<GrAnnotation>() {
@NotNull
@Override
public GrAnnotation[] create(int count) {
return new GrAnnotation[count];
@@ -221,6 +221,7 @@ public class GrIndexPropertyImpl extends GrExpressionImpl implements GrIndexProp
final GroovyResolveResult[] tupleCandidates = ResolveUtil.getMethodCandidates(thisType, name, invoked, tupleType);
if (incompleteCode) {
candidates = ArrayUtil.mergeArrays(candidates, tupleCandidates, new ArrayFactory<GroovyResolveResult>() {
@NotNull
@Override
public GroovyResolveResult[] create(int count) {
return new GroovyResolveResult[count];
@@ -294,7 +295,7 @@ public class GrIndexPropertyImpl extends GrExpressionImpl implements GrIndexProp
@Override
public PsiType getNominalType() {
if (getParent() instanceof GrThrowStatement) return super.getNominalType();
GroovyResolveResult[] candidates = multiResolve(true);
if (candidates.length == 1) {
return extractLastParameterType(candidates[0]);
@@ -35,6 +35,7 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.GrStubElementBase;
*/
public class GrTypeParameterListImpl extends GrStubElementBase<EmptyStub> implements GrTypeParameterList, StubBasedPsiElement<EmptyStub> {
private static final ArrayFactory<GrTypeParameter> ARRAY_FACTORY = new ArrayFactory<GrTypeParameter>() {
@NotNull
@Override
public GrTypeParameter[] create(int count) {
return new GrTypeParameter[count];
@@ -19,6 +19,7 @@ package com.intellij.xml;
import com.intellij.psi.meta.PsiMetaData;
import com.intellij.psi.xml.XmlElement;
import com.intellij.util.ArrayFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -27,6 +28,7 @@ import org.jetbrains.annotations.Nullable;
public interface XmlAttributeDescriptor extends PsiMetaData {
XmlAttributeDescriptor[] EMPTY = new XmlAttributeDescriptor[0];
ArrayFactory<XmlAttributeDescriptor> ARRAY_FACTORY = new ArrayFactory<XmlAttributeDescriptor>() {
@NotNull
@Override
public XmlAttributeDescriptor[] create(int count) {
return new XmlAttributeDescriptor[count];