mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
Drop PsiElementArrayConstructor in a favor of ArrayFactory
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.util.ArrayFactory;
|
||||
|
||||
/**
|
||||
* Represents a PSI element which can be used as the value of an annotation
|
||||
* element.
|
||||
* Represents a PSI element which can be used as the value of an annotation element.
|
||||
*
|
||||
* @author ven
|
||||
*/
|
||||
@@ -26,4 +27,11 @@ 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];
|
||||
|
||||
ArrayFactory<PsiAnnotationMemberValue> ARRAY_FACTORY = new ArrayFactory<PsiAnnotationMemberValue>() {
|
||||
@Override
|
||||
public PsiAnnotationMemberValue[] create(final int count) {
|
||||
return count == 0 ? PsiAnnotationMemberValue.EMPTY_ARRAY : new PsiAnnotationMemberValue[count];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -31,6 +32,13 @@ public interface PsiCatchSection extends PsiElement {
|
||||
*/
|
||||
PsiCatchSection[] EMPTY_ARRAY = new PsiCatchSection[0];
|
||||
|
||||
ArrayFactory<PsiCatchSection> ARRAY_FACTORY = new ArrayFactory<PsiCatchSection>() {
|
||||
@Override
|
||||
public PsiCatchSection[] create(final int count) {
|
||||
return count == 0 ? PsiCatchSection.EMPTY_ARRAY : new PsiCatchSection[count];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the variable in which the caught exception is captured.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -28,6 +29,13 @@ public interface PsiExpression extends PsiAnnotationMemberValue {
|
||||
*/
|
||||
PsiExpression[] EMPTY_ARRAY = new PsiExpression[0];
|
||||
|
||||
ArrayFactory<PsiExpression> ARRAY_FACTORY = new ArrayFactory<PsiExpression>() {
|
||||
@Override
|
||||
public PsiExpression[] create(final int count) {
|
||||
return count == 0 ? PsiExpression.EMPTY_ARRAY : new PsiExpression[count];
|
||||
}
|
||||
};
|
||||
|
||||
Function<PsiExpression, PsiType> EXPRESSION_TO_TYPE = new NullableFunction<PsiExpression, PsiType>() {
|
||||
@Override
|
||||
public PsiType fun(final PsiExpression expression) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -32,6 +33,13 @@ public interface PsiNameValuePair extends PsiElement {
|
||||
*/
|
||||
PsiNameValuePair[] EMPTY_ARRAY = new PsiNameValuePair[0];
|
||||
|
||||
ArrayFactory<PsiNameValuePair> ARRAY_FACTORY = new ArrayFactory<PsiNameValuePair>() {
|
||||
@Override
|
||||
public PsiNameValuePair[] create(final int count) {
|
||||
return count == 0 ? PsiNameValuePair.EMPTY_ARRAY : new PsiNameValuePair[count];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the identifier specifying the name of the element.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.util.ArrayFactory;
|
||||
|
||||
/**
|
||||
* Represents a Java statement.
|
||||
*/
|
||||
@@ -23,4 +25,11 @@ public interface PsiStatement extends PsiElement {
|
||||
* The empty array of PSI statements which can be reused to avoid unnecessary allocations.
|
||||
*/
|
||||
PsiStatement[] EMPTY_ARRAY = new PsiStatement[0];
|
||||
|
||||
ArrayFactory<PsiStatement> ARRAY_FACTORY = new ArrayFactory<PsiStatement>() {
|
||||
@Override
|
||||
public PsiStatement[] create(final int count) {
|
||||
return count == 0 ? PsiStatement.EMPTY_ARRAY : new PsiStatement[count];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -28,6 +29,13 @@ public interface PsiTypeElement extends PsiElement,PsiAnnotationOwner {
|
||||
*/
|
||||
PsiTypeElement[] EMPTY_ARRAY = new PsiTypeElement[0];
|
||||
|
||||
ArrayFactory<PsiTypeElement> ARRAY_FACTORY = new ArrayFactory<PsiTypeElement>() {
|
||||
@Override
|
||||
public PsiTypeElement[] create(final int count) {
|
||||
return count == 0 ? EMPTY_ARRAY : new PsiTypeElement[count];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the type referenced by the type element.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -24,7 +24,6 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.filters.ElementFilter;
|
||||
import com.intellij.psi.impl.light.LightClassReference;
|
||||
import com.intellij.psi.impl.source.Constants;
|
||||
import com.intellij.psi.impl.source.PsiClassReferenceType;
|
||||
import com.intellij.psi.impl.source.PsiImmediateClassType;
|
||||
import com.intellij.psi.impl.source.tree.CompositeElement;
|
||||
@@ -493,10 +492,10 @@ public class PsiImplUtil {
|
||||
|
||||
@Nullable
|
||||
public static ASTNode findStatementChild(CompositePsiElement statement) {
|
||||
if (DebugUtil.CHECK_INSIDE_ATOMIC_ACTION_ENABLED){
|
||||
if (DebugUtil.CHECK_INSIDE_ATOMIC_ACTION_ENABLED) {
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
}
|
||||
for(ASTNode element = statement.getFirstChildNode(); element != null; element = element.getTreeNext()){
|
||||
for (ASTNode element = statement.getFirstChildNode(); element != null; element = element.getTreeNext()) {
|
||||
if (element.getPsi() instanceof PsiStatement) return element;
|
||||
}
|
||||
return null;
|
||||
@@ -512,10 +511,8 @@ public class PsiImplUtil {
|
||||
}
|
||||
}
|
||||
|
||||
PsiStatement[] result = Constants.PSI_STATEMENT_ARRAY_CONSTRUCTOR.newPsiElementArray(count);
|
||||
if (count == 0) {
|
||||
return result;
|
||||
}
|
||||
PsiStatement[] result = PsiStatement.ARRAY_FACTORY.create(count);
|
||||
if (count == 0) return result;
|
||||
int idx = 0;
|
||||
for (ASTNode child = psiCodeBlock.getFirstChildNode(); child != null && idx < count; child = child.getTreeNext()) {
|
||||
if (child.getPsi() instanceof PsiStatement) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -15,119 +15,11 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
|
||||
public interface Constants extends ElementType {
|
||||
|
||||
PsiElementArrayConstructor<PsiClass> PSI_CLASS_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiClass>() {
|
||||
@Override
|
||||
public PsiClass[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiClass.EMPTY_ARRAY : new PsiClass[length];
|
||||
}
|
||||
};
|
||||
|
||||
PsiElementArrayConstructor<PsiField> PSI_FIELD_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiField>() {
|
||||
@Override
|
||||
public PsiField[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiField.EMPTY_ARRAY : new PsiField[length];
|
||||
}
|
||||
};
|
||||
|
||||
PsiElementArrayConstructor<PsiMethod> PSI_METHOD_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiMethod>() {
|
||||
@Override
|
||||
public PsiMethod[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiMethod.EMPTY_ARRAY : new PsiMethod[length];
|
||||
}
|
||||
};
|
||||
|
||||
PsiElementArrayConstructor<PsiClassInitializer> PSI_CLASS_INITIALIZER_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiClassInitializer>() {
|
||||
@Override
|
||||
public PsiClassInitializer[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiClassInitializer.EMPTY_ARRAY : new PsiClassInitializer[length];
|
||||
}
|
||||
};
|
||||
|
||||
PsiElementArrayConstructor<PsiParameter> PSI_PARAMETER_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiParameter>() {
|
||||
@Override
|
||||
public PsiParameter[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiParameter.EMPTY_ARRAY : new PsiParameter[length];
|
||||
}
|
||||
};
|
||||
|
||||
PsiElementArrayConstructor<PsiCatchSection> PSI_CATCH_SECTION_ARRAYS_CONSTRUCTOR = new PsiElementArrayConstructor<PsiCatchSection>() {
|
||||
@Override
|
||||
public PsiCatchSection[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiCatchSection.EMPTY_ARRAY : new PsiCatchSection[length];
|
||||
}
|
||||
};
|
||||
|
||||
PsiElementArrayConstructor<PsiJavaCodeReferenceElement> PSI_REFERENCE_ELEMENT_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiJavaCodeReferenceElement>() {
|
||||
@Override
|
||||
public PsiJavaCodeReferenceElement[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiJavaCodeReferenceElement.EMPTY_ARRAY : new PsiJavaCodeReferenceElement[length];
|
||||
}
|
||||
};
|
||||
|
||||
PsiElementArrayConstructor<PsiStatement> PSI_STATEMENT_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiStatement>() {
|
||||
@Override
|
||||
public PsiStatement[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiStatement.EMPTY_ARRAY : new PsiStatement[length];
|
||||
}
|
||||
};
|
||||
|
||||
PsiElementArrayConstructor<PsiExpression> PSI_EXPRESSION_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiExpression>() {
|
||||
@Override
|
||||
public PsiExpression[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiExpression.EMPTY_ARRAY : new PsiExpression[length];
|
||||
}
|
||||
};
|
||||
|
||||
PsiElementArrayConstructor<PsiImportStatement> PSI_IMPORT_STATEMENT_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiImportStatement>() {
|
||||
@Override
|
||||
public PsiImportStatement[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiImportStatement.EMPTY_ARRAY : new PsiImportStatement[length];
|
||||
}
|
||||
};
|
||||
|
||||
PsiElementArrayConstructor<PsiImportStaticStatement> PSI_IMPORT_STATIC_STATEMENT_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiImportStaticStatement>() {
|
||||
@Override
|
||||
public PsiImportStaticStatement[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiImportStaticStatement.EMPTY_ARRAY : new PsiImportStaticStatement[length];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
PsiElementArrayConstructor<PsiImportStatementBase> PSI_IMPORT_STATEMENT_BASE_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiImportStatementBase>() {
|
||||
@Override
|
||||
public PsiImportStatementBase[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiImportStatementBase.EMPTY_ARRAY : new PsiImportStatementBase[length];
|
||||
}
|
||||
};
|
||||
|
||||
PsiElementArrayConstructor<PsiAnnotationMemberValue> PSI_ANNOTATION_MEMBER_VALUE_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiAnnotationMemberValue>() {
|
||||
@Override
|
||||
public PsiAnnotationMemberValue[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiAnnotationMemberValue.EMPTY_ARRAY : new PsiAnnotationMemberValue[length];
|
||||
}
|
||||
};
|
||||
|
||||
PsiElementArrayConstructor<PsiNameValuePair> PSI_NAME_VALUE_PAIR_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiNameValuePair>() {
|
||||
@Override
|
||||
public PsiNameValuePair[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiNameValuePair.EMPTY_ARRAY : new PsiNameValuePair[length];
|
||||
}
|
||||
};
|
||||
|
||||
PsiElementArrayConstructor<PsiAnnotation> PSI_ANNOTATION_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiAnnotation>() {
|
||||
@Override
|
||||
public PsiAnnotation[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiAnnotation.EMPTY_ARRAY : new PsiAnnotation[length];
|
||||
}
|
||||
};
|
||||
|
||||
TokenSet CLASS_BIT_SET = TokenSet.create(JavaElementType.CLASS, JavaElementType.ANONYMOUS_CLASS, JavaElementType.ENUM_CONSTANT_INITIALIZER);
|
||||
TokenSet FIELD_BIT_SET = TokenSet.create(JavaElementType.FIELD, JavaElementType.ENUM_CONSTANT);
|
||||
TokenSet METHOD_BIT_SET = TokenSet.create(JavaElementType.METHOD, JavaElementType.ANNOTATION_METHOD);
|
||||
|
||||
@@ -89,7 +89,7 @@ public abstract class PsiJavaFileBaseImpl extends PsiFileImpl implements PsiJava
|
||||
return stub.getChildrenByType(JavaStubElementTypes.CLASS, PsiClass.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
return calcTreeElement().getChildrenAsPsiElements(Constants.CLASS_BIT_SET, Constants.PSI_CLASS_ARRAY_CONSTRUCTOR);
|
||||
return calcTreeElement().getChildrenAsPsiElements(Constants.CLASS_BIT_SET, PsiClass.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -46,7 +46,7 @@ public class PsiMethodReceiverImpl extends CompositePsiElement implements PsiMet
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiAnnotation[] getAnnotations() {
|
||||
return getChildrenAsPsiElements(ElementType.ANNOTATIONS, Constants.PSI_ANNOTATION_ARRAY_CONSTRUCTOR);
|
||||
return getChildrenAsPsiElements(ElementType.ANNOTATIONS, PsiAnnotation.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -40,7 +40,7 @@ public final class PsiReferenceListImpl extends JavaStubPsiElement<PsiClassRefer
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiJavaCodeReferenceElement[] getReferenceElements() {
|
||||
return calcTreeElement().getChildrenAsPsiElements(REFERENCE_BIT_SET, Constants.PSI_REFERENCE_ELEMENT_ARRAY_CONSTRUCTOR);
|
||||
return calcTreeElement().getChildrenAsPsiElements(REFERENCE_BIT_SET, PsiJavaCodeReferenceElement.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -21,7 +21,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleSettingsFacade;
|
||||
import com.intellij.psi.impl.source.Constants;
|
||||
import com.intellij.psi.impl.source.PsiElementArrayConstructor;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
@@ -30,6 +29,7 @@ import com.intellij.psi.tree.ChildRoleBase;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import com.intellij.util.CharTable;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -41,10 +41,10 @@ public class PsiDocCommentImpl extends LazyParseablePsiElement implements PsiDoc
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.javadoc.PsiDocCommentImpl");
|
||||
|
||||
private static final TokenSet TAG_BIT_SET = TokenSet.create(DOC_TAG);
|
||||
private static final PsiElementArrayConstructor<PsiDocTag> PSI_TAG_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiDocTag>() {
|
||||
private static final ArrayFactory<PsiDocTag> ARRAY_FACTORY = new ArrayFactory<PsiDocTag>() {
|
||||
@Override
|
||||
public PsiDocTag[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiDocTag.EMPTY_ARRAY : new PsiDocTag[length];
|
||||
public PsiDocTag[] create(final int count) {
|
||||
return count == 0 ? PsiDocTag.EMPTY_ARRAY : new PsiDocTag[count];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -86,7 +86,7 @@ public class PsiDocCommentImpl extends LazyParseablePsiElement implements PsiDoc
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiDocTag[] getTags() {
|
||||
return getChildrenAsPsiElements(TAG_BIT_SET, PSI_TAG_ARRAY_CONSTRUCTOR);
|
||||
return getChildrenAsPsiElements(TAG_BIT_SET, ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -21,9 +21,8 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.Constants;
|
||||
import com.intellij.psi.impl.source.PsiElementArrayConstructor;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.psi.impl.source.tree.CompositePsiElement;
|
||||
@@ -31,23 +30,16 @@ import com.intellij.psi.impl.source.tree.JavaDocElementType;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.psi.javadoc.PsiDocTagValue;
|
||||
import com.intellij.psi.tree.ChildRoleBase;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.tree.ChildRoleBase;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PsiDocTagImpl extends CompositePsiElement implements PsiDocTag, Constants {
|
||||
|
||||
private static final TokenSet VALUE_BIT_SET = TokenSet.create(new IElementType[]{
|
||||
JAVA_CODE_REFERENCE,
|
||||
DOC_TAG_VALUE_TOKEN,
|
||||
DOC_METHOD_OR_FIELD_REF,
|
||||
DOC_PARAMETER_REF,
|
||||
DOC_COMMENT_DATA,
|
||||
DOC_INLINE_TAG,
|
||||
DOC_REFERENCE_HOLDER
|
||||
});
|
||||
private static final TokenSet VALUE_BIT_SET = TokenSet.create(
|
||||
JAVA_CODE_REFERENCE, DOC_TAG_VALUE_TOKEN, DOC_METHOD_OR_FIELD_REF, DOC_PARAMETER_REF,
|
||||
DOC_COMMENT_DATA, DOC_INLINE_TAG, DOC_REFERENCE_HOLDER);
|
||||
|
||||
public PsiDocTagImpl() {
|
||||
super(DOC_TAG);
|
||||
@@ -70,7 +62,7 @@ public class PsiDocTagImpl extends CompositePsiElement implements PsiDocTag, Con
|
||||
|
||||
@Override
|
||||
public PsiElement[] getDataElements() {
|
||||
return getChildrenAsPsiElements(VALUE_BIT_SET, PsiElementArrayConstructor.PSI_ELEMENT_ARRAY_CONSTRUCTOR);
|
||||
return getChildrenAsPsiElements(VALUE_BIT_SET, PsiElement.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,8 +17,6 @@ package com.intellij.psi.impl.source.tree;
|
||||
|
||||
import com.intellij.psi.JavaDocTokenType;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.PsiTypeElement;
|
||||
import com.intellij.psi.impl.source.PsiElementArrayConstructor;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
|
||||
public interface ElementType extends JavaTokenType, JavaDocTokenType, JavaElementType, JavaDocElementType {
|
||||
@@ -76,12 +74,6 @@ public interface ElementType extends JavaTokenType, JavaDocTokenType, JavaElemen
|
||||
);
|
||||
|
||||
TokenSet TYPES_BIT_SET = TokenSet.create(TYPE);
|
||||
PsiElementArrayConstructor<PsiTypeElement> PSI_TYPE_ELEMENT_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiTypeElement>() {
|
||||
@Override
|
||||
public PsiTypeElement[] newPsiElementArray(int length) {
|
||||
return length > 0 ? new PsiTypeElement[length] : PsiTypeElement.EMPTY_ARRAY;
|
||||
}
|
||||
};
|
||||
TokenSet IMPORT_STATEMENT_BIT_SET = TokenSet.create(IMPORT_STATEMENT);
|
||||
TokenSet IMPORT_STATIC_STATEMENT_BIT_SET = TokenSet.create(IMPORT_STATIC_STATEMENT);
|
||||
TokenSet IMPORT_STATEMENT_BASE_BIT_SET = TokenSet.create(IMPORT_STATEMENT, IMPORT_STATIC_STATEMENT);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -47,7 +47,7 @@ public class PsiAnnotationParameterListImpl extends PsiCommaSeparatedListImpl im
|
||||
public PsiNameValuePair[] getAttributes() {
|
||||
PsiNameValuePair[] cachedMembers = myCachedMembers;
|
||||
if (cachedMembers == null) {
|
||||
myCachedMembers = cachedMembers = getChildrenAsPsiElements(NAME_VALUE_PAIR_BIT_SET, PSI_NAME_VALUE_PAIR_ARRAY_CONSTRUCTOR);
|
||||
myCachedMembers = cachedMembers = getChildrenAsPsiElements(NAME_VALUE_PAIR_BIT_SET, PsiNameValuePair.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
return cachedMembers;
|
||||
|
||||
+5
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -35,7 +35,7 @@ public class PsiArrayInitializerExpressionImpl extends ExpressionPsiElement impl
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiExpression[] getInitializers(){
|
||||
return getChildrenAsPsiElements(EXPRESSION_BIT_SET, PSI_EXPRESSION_ARRAY_CONSTRUCTOR);
|
||||
return getChildrenAsPsiElements(EXPRESSION_BIT_SET, PsiExpression.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,16 +128,15 @@ public class PsiArrayInitializerExpressionImpl extends ExpressionPsiElement impl
|
||||
|
||||
if (ElementType.EXPRESSION_BIT_SET.contains(first.getElementType())) {
|
||||
final CharTable charTab = SharedImplUtil.findCharTableByTree(this);
|
||||
ASTNode element = first;
|
||||
for (ASTNode child = element.getTreeNext(); child != null; child = child.getTreeNext()) {
|
||||
for (ASTNode child = first.getTreeNext(); child != null; child = child.getTreeNext()) {
|
||||
if (child.getElementType() == COMMA) break;
|
||||
if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) {
|
||||
TreeElement comma = Factory.createSingleLeafElement(COMMA, ",", 0, 1, charTab, getManager());
|
||||
super.addInternal(comma, comma, element, Boolean.FALSE);
|
||||
super.addInternal(comma, comma, first, Boolean.FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (ASTNode child = element.getTreePrev(); child != null; child = child.getTreePrev()) {
|
||||
for (ASTNode child = first.getTreePrev(); child != null; child = child.getTreePrev()) {
|
||||
if (child.getElementType() == COMMA) break;
|
||||
if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) {
|
||||
TreeElement comma = Factory.createSingleLeafElement(COMMA, ",", 0, 1, charTab, getManager());
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -38,7 +38,7 @@ public class PsiArrayInitializerMemberValueImpl extends PsiCommaSeparatedListImp
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiAnnotationMemberValue[] getInitializers() {
|
||||
return getChildrenAsPsiElements(ANNOTATION_MEMBER_VALUE_BIT_SET, PSI_ANNOTATION_MEMBER_VALUE_ARRAY_CONSTRUCTOR);
|
||||
return getChildrenAsPsiElements(ANNOTATION_MEMBER_VALUE_BIT_SET, PsiAnnotationMemberValue.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -17,7 +17,6 @@ package com.intellij.psi.impl.source.tree.java;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.PsiElementArrayConstructor;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.scope.ElementClassHint;
|
||||
@@ -33,7 +32,7 @@ public class PsiDeclarationStatementImpl extends CompositePsiElement implements
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiElement[] getDeclaredElements() {
|
||||
return getChildrenAsPsiElements(DECLARED_ELEMENT_BIT_SET, PsiElementArrayConstructor.PSI_ELEMENT_ARRAY_CONSTRUCTOR);
|
||||
return getChildrenAsPsiElements(DECLARED_ELEMENT_BIT_SET, PsiElement.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
private static final TokenSet DECLARED_ELEMENT_BIT_SET = TokenSet.create(JavaElementType.LOCAL_VARIABLE, JavaElementType.CLASS);
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -19,7 +19,6 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.psi.impl.source.Constants;
|
||||
import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.tree.ChildRoleBase;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
@@ -36,7 +35,7 @@ public class PsiExpressionListImpl extends CompositePsiElement implements PsiExp
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiExpression[] getExpressions() {
|
||||
return getChildrenAsPsiElements(ElementType.EXPRESSION_BIT_SET, Constants.PSI_EXPRESSION_ARRAY_CONSTRUCTOR);
|
||||
return getChildrenAsPsiElements(ElementType.EXPRESSION_BIT_SET, PsiExpression.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+7
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -21,26 +21,26 @@ import com.intellij.psi.JavaElementVisitor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.Constants;
|
||||
import com.intellij.psi.impl.source.PsiElementArrayConstructor;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.psi.impl.source.tree.CompositePsiElement;
|
||||
import com.intellij.psi.impl.source.tree.JavaDocElementType;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.javadoc.PsiDocTagValue;
|
||||
import com.intellij.psi.javadoc.PsiInlineDocTag;
|
||||
import com.intellij.psi.tree.ChildRoleBase;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.tree.ChildRoleBase;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PsiInlineDocTagImpl extends CompositePsiElement implements PsiInlineDocTag, Constants {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.java.PsiInlineDocTagImpl");
|
||||
|
||||
private static final TokenSet VALUE_BIT_SET = TokenSet.create(JAVA_CODE_REFERENCE, DOC_TAG_VALUE_TOKEN, DOC_METHOD_OR_FIELD_REF,
|
||||
DOC_COMMENT_DATA, DOC_INLINE_TAG, DOC_REFERENCE_HOLDER, WHITE_SPACE, DOC_COMMENT_BAD_CHARACTER);
|
||||
private static final TokenSet VALUE_BIT_SET = TokenSet.create(
|
||||
JAVA_CODE_REFERENCE, DOC_TAG_VALUE_TOKEN, DOC_METHOD_OR_FIELD_REF, DOC_COMMENT_DATA, DOC_INLINE_TAG,
|
||||
DOC_REFERENCE_HOLDER, WHITE_SPACE, DOC_COMMENT_BAD_CHARACTER);
|
||||
|
||||
public PsiInlineDocTagImpl() {
|
||||
super(DOC_INLINE_TAG);
|
||||
@@ -62,7 +62,7 @@ public class PsiInlineDocTagImpl extends CompositePsiElement implements PsiInlin
|
||||
|
||||
@Override
|
||||
public PsiElement[] getDataElements() {
|
||||
return getChildrenAsPsiElements(VALUE_BIT_SET, PsiElementArrayConstructor.PSI_ELEMENT_ARRAY_CONSTRUCTOR);
|
||||
return getChildrenAsPsiElements(VALUE_BIT_SET, PsiElement.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -20,7 +20,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.psi.impl.source.Constants;
|
||||
import com.intellij.psi.impl.source.PsiClassReferenceType;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.resolve.reference.impl.PsiPolyVariantCachingReference;
|
||||
@@ -93,12 +92,12 @@ public class PsiNewExpressionImpl extends ExpressionPsiElement implements PsiNew
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiExpression[] getArrayDimensions() {
|
||||
PsiExpression[] expressions = getChildrenAsPsiElements(ElementType.ARRAY_DIMENSION_BIT_SET, Constants.PSI_EXPRESSION_ARRAY_CONSTRUCTOR);
|
||||
PsiExpression[] expressions = getChildrenAsPsiElements(ElementType.ARRAY_DIMENSION_BIT_SET, PsiExpression.ARRAY_FACTORY);
|
||||
PsiExpression qualifier = getQualifier();
|
||||
if (qualifier == null){
|
||||
if (qualifier == null) {
|
||||
return expressions;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
LOG.assertTrue(expressions[0] == qualifier);
|
||||
PsiExpression[] expressions1 = new PsiExpression[expressions.length - 1];
|
||||
System.arraycopy(expressions, 1, expressions1, 0, expressions1.length);
|
||||
|
||||
+7
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -18,7 +18,6 @@ package com.intellij.psi.impl.source.tree.java;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.Constants;
|
||||
import com.intellij.psi.impl.source.resolve.JavaResolveCache;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
@@ -28,7 +27,9 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PsiPolyadicExpressionImpl extends ExpressionPsiElement implements PsiPolyadicExpression {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.java.PsiPolyadicExpressionImpl");
|
||||
@@ -57,13 +58,15 @@ public class PsiPolyadicExpressionImpl extends ExpressionPsiElement implements P
|
||||
public PsiType getType() {
|
||||
return JavaResolveCache.getInstance(getProject()).getType(this, MY_TYPE_EVALUATOR);
|
||||
}
|
||||
private static final Function<PsiPolyadicExpressionImpl,PsiType> MY_TYPE_EVALUATOR = new Function<PsiPolyadicExpressionImpl, PsiType>() {
|
||||
|
||||
private static final Function<PsiPolyadicExpressionImpl,PsiType> MY_TYPE_EVALUATOR = new NullableFunction<PsiPolyadicExpressionImpl, PsiType>() {
|
||||
@Override
|
||||
public PsiType fun(PsiPolyadicExpressionImpl expression) {
|
||||
return doGetType(expression);
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
private static PsiType doGetType(PsiPolyadicExpressionImpl param) {
|
||||
PsiExpression[] operands = param.getOperands();
|
||||
PsiType lType = null;
|
||||
@@ -80,7 +83,6 @@ public class PsiPolyadicExpressionImpl extends ExpressionPsiElement implements P
|
||||
return lType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ASTNode findChildByRole(int role) {
|
||||
LOG.assertTrue(ChildRole.isUnique(role));
|
||||
@@ -124,7 +126,7 @@ public class PsiPolyadicExpressionImpl extends ExpressionPsiElement implements P
|
||||
public PsiExpression[] getOperands() {
|
||||
PsiExpression[] operands = cachedOperands;
|
||||
if (operands == null) {
|
||||
cachedOperands = operands = getChildrenAsPsiElements(ElementType.EXPRESSION_BIT_SET, Constants.PSI_EXPRESSION_ARRAY_CONSTRUCTOR);
|
||||
cachedOperands = operands = getChildrenAsPsiElements(ElementType.EXPRESSION_BIT_SET, PsiExpression.ARRAY_FACTORY);
|
||||
}
|
||||
return operands;
|
||||
}
|
||||
@@ -140,4 +142,3 @@ public class PsiPolyadicExpressionImpl extends ExpressionPsiElement implements P
|
||||
return "PsiPolyadicExpression: " + getText();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -38,7 +38,7 @@ public class PsiReferenceParameterListImpl extends CompositePsiElement implement
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiTypeElement[] getTypeParameterElements() {
|
||||
return getChildrenAsPsiElements(ElementType.TYPES_BIT_SET, ElementType.PSI_TYPE_ELEMENT_ARRAY_CONSTRUCTOR);
|
||||
return getChildrenAsPsiElements(ElementType.TYPES_BIT_SET, PsiTypeElement.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -125,16 +125,15 @@ public class PsiReferenceParameterListImpl extends CompositePsiElement implement
|
||||
final TreeElement firstAdded = super.addInternal(first, last, anchor, before);
|
||||
|
||||
if (first == last && first.getElementType() == JavaElementType.TYPE){
|
||||
ASTNode element = first;
|
||||
for(ASTNode child = element.getTreeNext(); child != null; child = child.getTreeNext()){
|
||||
for(ASTNode child = first.getTreeNext(); child != null; child = child.getTreeNext()){
|
||||
if (child.getElementType() == JavaTokenType.COMMA) break;
|
||||
if (child.getElementType() == JavaElementType.TYPE){
|
||||
TreeElement comma = Factory.createSingleLeafElement(JavaTokenType.COMMA, ",", 0, 1, treeCharTab, getManager());
|
||||
super.addInternal(comma, comma, element, Boolean.FALSE);
|
||||
super.addInternal(comma, comma, first, Boolean.FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(ASTNode child = element.getTreePrev(); child != null; child = child.getTreePrev()){
|
||||
for(ASTNode child = first.getTreePrev(); child != null; child = child.getTreePrev()){
|
||||
if (child.getElementType() == JavaTokenType.COMMA) break;
|
||||
if (child.getElementType() == JavaElementType.TYPE){
|
||||
TreeElement comma = Factory.createSingleLeafElement(JavaTokenType.COMMA, ",", 0, 1, treeCharTab, getManager());
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -90,7 +90,7 @@ public class PsiTryStatementImpl extends CompositePsiElement implements PsiTrySt
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiCatchSection[] getCatchSections() {
|
||||
return getChildrenAsPsiElements(CATCH_SECTION_BIT_SET, PSI_CATCH_SECTION_ARRAYS_CONSTRUCTOR);
|
||||
return getChildrenAsPsiElements(CATCH_SECTION_BIT_SET, PsiCatchSection.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -38,8 +38,7 @@ public class PsiTypeParameterExtendsBoundsListImpl extends JavaStubPsiElement<Ps
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiJavaCodeReferenceElement[] getReferenceElements() {
|
||||
return calcTreeElement().getChildrenAsPsiElements(Constants.JAVA_CODE_REFERENCE_BIT_SET,
|
||||
Constants.PSI_REFERENCE_ELEMENT_ARRAY_CONSTRUCTOR);
|
||||
return calcTreeElement().getChildrenAsPsiElements(Constants.JAVA_CODE_REFERENCE_BIT_SET, PsiJavaCodeReferenceElement.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.util.ArrayFactory;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -42,6 +43,13 @@ public interface PsiElement extends UserDataHolder, Iconable {
|
||||
*/
|
||||
PsiElement[] EMPTY_ARRAY = new PsiElement[0];
|
||||
|
||||
ArrayFactory<PsiElement> ARRAY_FACTORY = new ArrayFactory<PsiElement>() {
|
||||
@Override
|
||||
public PsiElement[] create(final int count) {
|
||||
return count == 0 ? EMPTY_ARRAY : new PsiElement[count];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the project to which the PSI element belongs.
|
||||
*
|
||||
|
||||
@@ -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.impl.source;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
|
||||
public interface PsiElementArrayConstructor<T extends PsiElement> {
|
||||
PsiElementArrayConstructor<PsiElement> PSI_ELEMENT_ARRAY_CONSTRUCTOR = new PsiElementArrayConstructor<PsiElement>() {
|
||||
@Override
|
||||
public PsiElement[] newPsiElementArray(int length) {
|
||||
return length == 0 ? PsiElement.EMPTY_ARRAY : new PsiElement[length];
|
||||
}
|
||||
};
|
||||
|
||||
T[] newPsiElementArray(int length);
|
||||
}
|
||||
@@ -52,6 +52,7 @@ import com.intellij.psi.stubs.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.ILazyParseableElementType;
|
||||
import com.intellij.psi.tree.IStubFileElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -755,7 +756,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiElement[] getChildren() {
|
||||
return calcTreeElement().getChildrenAsPsiElements(null, PsiElementArrayConstructor.PSI_ELEMENT_ARRAY_CONSTRUCTOR);
|
||||
return calcTreeElement().getChildrenAsPsiElements((TokenSet)null, PsiElement.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -420,7 +420,7 @@ public class CompositeElement extends TreeElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode[] getChildren(TokenSet filter) {
|
||||
public ASTNode[] getChildren(@Nullable TokenSet filter) {
|
||||
int count = countChildren(filter);
|
||||
if (count == 0) {
|
||||
return EMPTY_ARRAY;
|
||||
@@ -435,28 +435,8 @@ public class CompositeElement extends TreeElement {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public <T extends PsiElement> T[] getChildrenAsPsiElements(TokenSet filter, PsiElementArrayConstructor<T> constructor) {
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
int count = countChildren(filter);
|
||||
T[] result = constructor.newPsiElementArray(count);
|
||||
if (count == 0) {
|
||||
return result;
|
||||
}
|
||||
int idx = 0;
|
||||
for (ASTNode child = getFirstChildNode(); child != null && idx < count; child = child.getTreeNext()) {
|
||||
if (filter == null || filter.contains(child.getElementType())) {
|
||||
T element = (T)child.getPsi();
|
||||
LOG.assertTrue(element != null, child);
|
||||
result[idx++] = element;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <T extends PsiElement> T[] getChildrenAsPsiElements(TokenSet filter, ArrayFactory<T> constructor) {
|
||||
public <T extends PsiElement> T[] getChildrenAsPsiElements(@Nullable TokenSet filter, ArrayFactory<T> constructor) {
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
int count = countChildren(filter);
|
||||
T[] result = constructor.create(count);
|
||||
@@ -466,13 +446,14 @@ public class CompositeElement extends TreeElement {
|
||||
int idx = 0;
|
||||
for (ASTNode child = getFirstChildNode(); child != null && idx < count; child = child.getTreeNext()) {
|
||||
if (filter == null || filter.contains(child.getElementType())) {
|
||||
T element = (T)child.getPsi();
|
||||
@SuppressWarnings("unchecked") T element = (T)child.getPsi();
|
||||
LOG.assertTrue(element != null, child);
|
||||
result[idx++] = element;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <T extends PsiElement> T[] getChildrenAsPsiElements(@NotNull IElementType type, ArrayFactory<T> constructor) {
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
@@ -484,7 +465,7 @@ public class CompositeElement extends TreeElement {
|
||||
int idx = 0;
|
||||
for (ASTNode child = getFirstChildNode(); child != null && idx < count; child = child.getTreeNext()) {
|
||||
if (type == child.getElementType()) {
|
||||
T element = (T)child.getPsi();
|
||||
@SuppressWarnings("unchecked") T element = (T)child.getPsi();
|
||||
LOG.assertTrue(element != null, child);
|
||||
result[idx++] = element;
|
||||
}
|
||||
@@ -492,7 +473,7 @@ public class CompositeElement extends TreeElement {
|
||||
return result;
|
||||
}
|
||||
|
||||
public int countChildren(TokenSet filter) {
|
||||
public int countChildren(@Nullable TokenSet filter) {
|
||||
// no lock is needed because all chameleons are expanded already
|
||||
int count = 0;
|
||||
for (ASTNode child = getFirstChildNode(); child != null; child = child.getTreeNext()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -25,15 +25,15 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.CheckUtil;
|
||||
import com.intellij.psi.impl.SharedPsiElementImplUtil;
|
||||
import com.intellij.psi.impl.ResolveScopeManager;
|
||||
import com.intellij.psi.impl.source.PsiElementArrayConstructor;
|
||||
import com.intellij.psi.impl.SharedPsiElementImplUtil;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -56,7 +56,7 @@ public abstract class CompositePsiElement extends CompositeElement implements Ps
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiElement[] getChildren() {
|
||||
return getChildrenAsPsiElements(null, PsiElementArrayConstructor.PSI_ELEMENT_ARRAY_CONSTRUCTOR);
|
||||
return getChildrenAsPsiElements((TokenSet)null, PsiElement.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -30,13 +30,13 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.CheckUtil;
|
||||
import com.intellij.psi.impl.ResolveScopeManager;
|
||||
import com.intellij.psi.impl.SharedPsiElementImplUtil;
|
||||
import com.intellij.psi.impl.source.PsiElementArrayConstructor;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.ReflectionCache;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -64,7 +64,7 @@ public class LazyParseablePsiElement extends LazyParseableElement implements Psi
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiElement[] getChildren() {
|
||||
return getChildrenAsPsiElements(null, PsiElementArrayConstructor.PSI_ELEMENT_ARRAY_CONSTRUCTOR);
|
||||
return getChildrenAsPsiElements((TokenSet)null, PsiElement.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -20,11 +20,9 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.XmlElementVisitor;
|
||||
import com.intellij.psi.impl.source.PsiElementArrayConstructor;
|
||||
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.ChildRoleBase;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.xml.XmlChildRole;
|
||||
import com.intellij.psi.xml.XmlElementContentGroup;
|
||||
import com.intellij.psi.xml.XmlElementContentSpec;
|
||||
@@ -35,17 +33,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author Mike
|
||||
*/
|
||||
public class XmlElementContentSpecImpl extends XmlElementImpl implements XmlElementContentSpec, XmlElementType {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.xml.XmlElementContentSpecImpl");
|
||||
|
||||
private static final TokenSet GROUPS_FILTER = TokenSet.create(XML_ELEMENT_CONTENT_GROUP);
|
||||
private static final PsiElementArrayConstructor<XmlElementContentGroup> GROUPS_CONSTRUCTOR = new PsiElementArrayConstructor<XmlElementContentGroup>() {
|
||||
@Override
|
||||
public XmlElementContentGroup[] newPsiElementArray(int length) {
|
||||
return new XmlElementContentGroup[length];
|
||||
}
|
||||
};
|
||||
|
||||
public XmlElementContentSpecImpl() {
|
||||
super(XML_ELEMENT_CONTENT_SPEC);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user