Java 类com.intellij.util.ArrayFactory 实例源码

项目:intellij-ce-playground    文件:StubBasedPsiElementBase.java   
/**
 * @return children of specified type, taken from stubs (if this element is currently stub-based) or AST (otherwise).
 */
public <S extends StubElement, Psi extends PsiElement> Psi[] getStubOrPsiChildren(final IStubElementType<S, Psi> elementType, ArrayFactory<Psi> f) {
  T stub = myStub;
  if (stub != null) {
    //noinspection unchecked
    return (Psi[])stub.getChildrenByType(elementType, f);
  }
  else {
    final ASTNode[] nodes = SharedImplUtil.getChildrenOfType(getNode(), elementType);
    Psi[] psiElements = f.create(nodes.length);
    for (int i = 0; i < nodes.length; i++) {
      //noinspection unchecked
      psiElements[i] = (Psi)nodes[i].getPsi();
    }
    return psiElements;
  }
}
项目:intellij-ce-playground    文件:StubBasedPsiElementBase.java   
/**
 * @return children of specified type, taken from stubs (if this element is currently stub-based) or AST (otherwise).
 */
public <Psi extends PsiElement> Psi[] getStubOrPsiChildren(TokenSet filter, ArrayFactory<Psi> f) {
  T stub = myStub;
  if (stub != null) {
    //noinspection unchecked
    return (Psi[])stub.getChildrenByType(filter, f);
  }
  else {
    final ASTNode[] nodes = getNode().getChildren(filter);
    Psi[] psiElements = f.create(nodes.length);
    for (int i = 0; i < nodes.length; i++) {
      //noinspection unchecked
      psiElements[i] = (Psi)nodes[i].getPsi();
    }
    return psiElements;
  }
}
项目:intellij-ce-playground    文件:CompositeElement.java   
@NotNull
public <T extends PsiElement> T[] getChildrenAsPsiElements(@Nullable TokenSet filter, ArrayFactory<T> constructor) {
  ApplicationManager.getApplication().assertReadAccessAllowed();
  int count = countChildren(filter);
  T[] result = constructor.create(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())) {
      @SuppressWarnings("unchecked") T element = (T)child.getPsi();
      LOG.assertTrue(element != null, child);
      result[idx++] = element;
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:CompositeElement.java   
@NotNull
public <T extends PsiElement> T[] getChildrenAsPsiElements(@NotNull IElementType type, ArrayFactory<T> constructor) {
  ApplicationManager.getApplication().assertReadAccessAllowed();
  int count = countChildren(type);
  T[] result = constructor.create(count);
  if (count == 0) {
    return result;
  }
  int idx = 0;
  for (ASTNode child = getFirstChildNode(); child != null && idx < count; child = child.getTreeNext()) {
    if (type == child.getElementType()) {
      @SuppressWarnings("unchecked") T element = (T)child.getPsi();
      LOG.assertTrue(element != null, child);
      result[idx++] = element;
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:PyFromImportStatementImpl.java   
@NotNull
public PyImportElement[] getImportElements() {
  final PyFromImportStatementStub stub = getStub();
  if (stub != null) {
    return stub.getChildrenByType(PyElementTypes.IMPORT_ELEMENT, new ArrayFactory<PyImportElement>() {
      @NotNull
      public PyImportElement[] create(int count) {
        return new PyImportElement[count];
      }
    });
  }
  List<PyImportElement> result = new ArrayList<PyImportElement>();
  final ASTNode importKeyword = getNode().findChildByType(PyTokenTypes.IMPORT_KEYWORD);
  if (importKeyword != null) {
    for (ASTNode node = importKeyword.getTreeNext(); node != null; node = node.getTreeNext()) {
      if (node.getElementType() == PyElementTypes.IMPORT_ELEMENT) {
        result.add((PyImportElement)node.getPsi());
      }
    }
  }
  return result.toArray(new PyImportElement[result.size()]);
}
项目:tools-idea    文件:CompositeElement.java   
@NotNull
public <T extends PsiElement> T[] getChildrenAsPsiElements(@Nullable TokenSet filter, ArrayFactory<T> constructor) {
  ApplicationManager.getApplication().assertReadAccessAllowed();
  int count = countChildren(filter);
  T[] result = constructor.create(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())) {
      @SuppressWarnings("unchecked") T element = (T)child.getPsi();
      LOG.assertTrue(element != null, child);
      result[idx++] = element;
    }
  }
  return result;
}
项目:tools-idea    文件:CompositeElement.java   
@NotNull
public <T extends PsiElement> T[] getChildrenAsPsiElements(@NotNull IElementType type, ArrayFactory<T> constructor) {
  ApplicationManager.getApplication().assertReadAccessAllowed();
  int count = countChildren(type);
  T[] result = constructor.create(count);
  if (count == 0) {
    return result;
  }
  int idx = 0;
  for (ASTNode child = getFirstChildNode(); child != null && idx < count; child = child.getTreeNext()) {
    if (type == child.getElementType()) {
      @SuppressWarnings("unchecked") T element = (T)child.getPsi();
      LOG.assertTrue(element != null, child);
      result[idx++] = element;
    }
  }
  return result;
}
项目:consulo    文件:StubBasedPsiElementBase.java   
/**
 * @return children of specified type, taken from stubs (if this element is currently stub-based) or AST (otherwise).
 */
@Nonnull
public <S extends StubElement, Psi extends PsiElement> Psi[] getStubOrPsiChildren(@Nonnull IStubElementType<S, ? extends Psi> elementType, @Nonnull ArrayFactory<Psi> f) {
  T stub = getGreenStub();
  if (stub != null) {
    //noinspection unchecked
    return (Psi[])stub.getChildrenByType(elementType, f);
  }
  else {
    final ASTNode[] nodes = SharedImplUtil.getChildrenOfType(getNode(), elementType);
    Psi[] psiElements = f.create(nodes.length);
    for (int i = 0; i < nodes.length; i++) {
      //noinspection unchecked
      psiElements[i] = (Psi)nodes[i].getPsi();
    }
    return psiElements;
  }
}
项目:consulo    文件:StubBasedPsiElementBase.java   
/**
 * @return children of specified type, taken from stubs (if this element is currently stub-based) or AST (otherwise).
 */
@Nonnull
public <Psi extends PsiElement> Psi[] getStubOrPsiChildren(@Nonnull TokenSet filter, @Nonnull ArrayFactory<Psi> f) {
  T stub = getGreenStub();
  if (stub != null) {
    //noinspection unchecked
    return (Psi[])stub.getChildrenByType(filter, f);
  }
  else {
    final ASTNode[] nodes = getNode().getChildren(filter);
    Psi[] psiElements = f.create(nodes.length);
    for (int i = 0; i < nodes.length; i++) {
      //noinspection unchecked
      psiElements[i] = (Psi)nodes[i].getPsi();
    }
    return psiElements;
  }
}
项目:consulo    文件:CompositeElement.java   
@Nonnull
public <T extends PsiElement> T[] getChildrenAsPsiElements(@Nullable TokenSet filter, ArrayFactory<T> constructor) {
  ApplicationManager.getApplication().assertReadAccessAllowed();
  int count = countChildren(filter);
  T[] result = constructor.create(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())) {
      @SuppressWarnings("unchecked") T element = (T)child.getPsi();
      LOG.assertTrue(element != null, child);
      result[idx++] = element;
    }
  }
  return result;
}
项目:consulo    文件:CompositeElement.java   
@Nonnull
public <T extends PsiElement> T[] getChildrenAsPsiElements(@Nonnull IElementType type, ArrayFactory<T> constructor) {
  ApplicationManager.getApplication().assertReadAccessAllowed();
  int count = countChildren(type);
  T[] result = constructor.create(count);
  if (count == 0) {
    return result;
  }
  int idx = 0;
  for (ASTNode child = getFirstChildNode(); child != null && idx < count; child = child.getTreeNext()) {
    if (type == child.getElementType()) {
      @SuppressWarnings("unchecked") T element = (T)child.getPsi();
      LOG.assertTrue(element != null, child);
      result[idx++] = element;
    }
  }
  return result;
}
项目:consulo    文件:Sand2PackageProvider.java   
@Nonnull
@Override
public PsiPackage createPackage(@Nonnull PsiManager psiManager,
                                @Nonnull PsiPackageManager packageManager,
                                @Nonnull Class<? extends ModuleExtension> extensionClass,
                                @Nonnull String packageName) {
  return new PsiPackageBase(psiManager, packageManager, extensionClass, packageName) {
    @Override
    protected ArrayFactory<? extends PsiPackage> getPackageArrayFactory() {
      return PsiPackage.ARRAY_FACTORY;
    }

    @RequiredReadAction
    @Nonnull
    @Override
    public Language getLanguage() {
      return SandLanguage.INSTANCE;
    }
  };
}
项目:consulo-javascript    文件:JSClassBase.java   
private static <E extends PsiElement> E[] getStubChildrenByType(JSClassStub stub, final IElementType elementType, ArrayFactory<E> f)
{
    assert JSElementTypes.INCLUDE_DIRECTIVE != elementType;

    ArrayList<E> result = new ArrayList<E>(Arrays.asList(stub.getChildrenByType(elementType, f)));
    JSIncludeDirective[] includes = stub.getChildrenByType(JSElementTypes.INCLUDE_DIRECTIVE, new ArrayFactory<JSIncludeDirective>()
    {
        @Override
        public JSIncludeDirective[] create(final int count)
        {
            return new JSIncludeDirective[count];
        }
    });
    Collection<JSFile> visited = new THashSet<JSFile>();
    TokenSet filter = TokenSet.create(JSElementTypes.INCLUDE_DIRECTIVE, elementType);
    for(JSIncludeDirective include : includes)
    {
        PsiFile file = include.resolveFile();
        if(file instanceof JSFile)
        {
            process(filter, (JSFile) file, result, visited);
        }
    }
    return result.toArray(f.create(result.size()));
}
项目:intellij-ce-playground    文件:StubBase.java   
@Override
public <E extends PsiElement> E[] getChildrenByType(final IElementType elementType, final ArrayFactory<E> f) {
  int count = countChildren(elementType);

  E[] result = f.create(count);
  if (count > 0) fillFilteredChildren(elementType, result);

  return result;
}
项目:intellij-ce-playground    文件:StubBase.java   
@Override
public <E extends PsiElement> E[] getChildrenByType(final TokenSet filter, final ArrayFactory<E> f) {
  final int count = countChildren(filter);

  E[] array = f.create(count);
  if (count == 0) return array;

  fillFilteredChildren(filter, array);

  return array;
}
项目:intellij-ce-playground    文件:PyImportStatementImpl.java   
@NotNull
public PyImportElement[] getImportElements() {
  final PyImportStatementStub stub = getStub();
  if (stub != null) {
    return stub.getChildrenByType(PyElementTypes.IMPORT_ELEMENT, new ArrayFactory<PyImportElement>() {
      @NotNull
      public PyImportElement[] create(int count) {
        return new PyImportElement[count];
      }
    });
  }
  return childrenToPsi(TokenSet.create(PyElementTypes.IMPORT_ELEMENT), new PyImportElement[0]);
}
项目:tools-idea    文件:StubBase.java   
@Override
public <E extends PsiElement> E[] getChildrenByType(final IElementType elementType, final ArrayFactory<E> f) {
  int count = countChildren(elementType);

  E[] result = f.create(count);
  if (count > 0) fillFilteredChildren(elementType, result);

  return result;
}
项目:tools-idea    文件:StubBase.java   
@Override
public <E extends PsiElement> E[] getChildrenByType(final TokenSet filter, final ArrayFactory<E> f) {
  final int count = countChildren(filter);

  E[] array = f.create(count);
  if (count == 0) return array;

  fillFilteredChildren(filter, array);

  return array;
}
项目:tools-idea    文件:StubBasedPsiElementBase.java   
public <Stub extends StubElement, Psi extends PsiElement> Psi[] getStubOrPsiChildren(final IStubElementType<Stub, Psi> elementType, ArrayFactory<Psi> f) {
  T stub = myStub;
  if (stub != null) {
    //noinspection unchecked
    return (Psi[])stub.getChildrenByType(elementType, f);
  }
  else {
    final ASTNode[] nodes = SharedImplUtil.getChildrenOfType(getNode(), elementType);
    Psi[] psiElements = f.create(nodes.length);
    for (int i = 0; i < nodes.length; i++) {
      psiElements[i] = (Psi)nodes[i].getPsi();
    }
    return psiElements;
  }
}
项目:tools-idea    文件:StubBasedPsiElementBase.java   
public <Psi extends PsiElement> Psi[] getStubOrPsiChildren(TokenSet filter, ArrayFactory<Psi> f) {
  T stub = myStub;
  if (stub != null) {
    //noinspection unchecked
    return (Psi[])stub.getChildrenByType(filter, f);
  }
  else {
    final ASTNode[] nodes = getNode().getChildren(filter);
    Psi[] psiElements = f.create(nodes.length);
    for (int i = 0; i < nodes.length; i++) {
      psiElements[i] = (Psi)nodes[i].getPsi();
    }
    return psiElements;
  }
}
项目:consulo    文件:StubBase.java   
@Nonnull
@Override
public <E extends PsiElement> E[] getChildrenByType(@Nonnull final IElementType elementType, @Nonnull final ArrayFactory<E> f) {
  int count = countChildren(elementType);

  E[] result = f.create(count);
  if (count > 0) fillFilteredChildren(elementType, result);

  return result;
}
项目:consulo    文件:StubBase.java   
@Nonnull
@Override
public <E extends PsiElement> E[] getChildrenByType(@Nonnull final TokenSet filter, @Nonnull final ArrayFactory<E> f) {
  final int count = countChildren(filter);

  E[] array = f.create(count);
  if (count == 0) return array;

  fillFilteredChildren(filter, array);

  return array;
}
项目:consulo-haxe    文件:HaxePackageImpl.java   
@Override
protected ArrayFactory<? extends PsiPackage> getPackageArrayFactory()
{
    return HaxePackage.ARRAY_FACTORY;
}
项目:consulo-dotnet    文件:MsilStubElementImpl.java   
@Nullable
public <T extends PsiElement> T getFirstStubOrPsiChild(TokenSet tokenSet, ArrayFactory<T> arrayFactory)
{
    T[] stubOrPsiChildren = getStubOrPsiChildren(tokenSet, arrayFactory);
    return ArrayUtil2.safeGet(stubOrPsiChildren, 0);
}
项目:consulo-dotnet    文件:MsilStubElementImpl.java   
@Nullable
public <T extends PsiElement> T getStubOrPsiChildByIndex(TokenSet tokenSet, ArrayFactory<T> arrayFactory, int index)
{
    T[] stubOrPsiChildren = getStubOrPsiChildren(tokenSet, arrayFactory);
    return ArrayUtil2.safeGet(stubOrPsiChildren, index);
}
项目:consulo-dotnet    文件:DotNetPackage.java   
@Override
protected ArrayFactory<? extends PsiPackage> getPackageArrayFactory()
{
    return DotNetPackage.ARRAY_FACTORY;
}
项目:consulo    文件:LockFreeCOWSortedArray.java   
LockFreeCOWSortedArray(@Nonnull Comparator<? super T> comparator, @Nonnull ArrayFactory<T> arrayFactory) {
  this.comparator = comparator;
  this.arrayFactory = arrayFactory;
  listeners = arrayFactory.create(0);
}
项目:consulo-javascript    文件:JSClassBase.java   
@Override
public JSVariable[] getFields()
{
    final JSClassStub classStub = getStub();
    final List<JSVariable> vars = new ArrayList<JSVariable>(3);

    if(classStub != null)
    {
        for(JSVarStatement var : getStubChildrenByType(classStub, JSElementTypes.VAR_STATEMENT, new ArrayFactory<JSVarStatement>()
        {
            @Override
            public JSVarStatement[] create(final int count)
            {
                return new JSVarStatement[count];
            }
        }))
        {
            vars.addAll(Arrays.asList(var.getVariables()));
        }
    }
    else
    {
        processDeclarations(new PsiScopeProcessor()
        {
            @Override
            public boolean execute(final PsiElement element, final ResolveState state)
            {
                if(element instanceof JSVariable)
                {
                    vars.add((JSVariable) element);
                }
                return true;
            }

            @Override
            public <T> T getHint(final Key<T> hintClass)
            {
                return null;
            }

            @Override
            public void handleEvent(final Event event, final Object associated)
            {
            }
        }, ResolveState.initial(), this, this);
    }
    return vars.toArray(JSVariable.EMPTY_ARRAY);
}
项目:consulo-java    文件:PsiPackageImpl.java   
@Override
protected ArrayFactory<? extends PsiPackage> getPackageArrayFactory()
{
    return PsiJavaPackage.ARRAY_FACTORY;
}
项目:intellij-ce-playground    文件:StubElement.java   
<E extends PsiElement> E[] getChildrenByType(final IElementType elementType, ArrayFactory<E> f);
项目:intellij-ce-playground    文件:StubElement.java   
<E extends PsiElement> E[] getChildrenByType(final TokenSet filter, ArrayFactory<E> f);
项目:tools-idea    文件:StubElement.java   
<E extends PsiElement> E[] getChildrenByType(final IElementType elementType, ArrayFactory<E> f);
项目:tools-idea    文件:StubElement.java   
<E extends PsiElement> E[] getChildrenByType(final TokenSet filter, ArrayFactory<E> f);
项目:consulo    文件:StubElement.java   
<E extends PsiElement> E[] getChildrenByType(final IElementType elementType, ArrayFactory<E> f);
项目:consulo    文件:StubElement.java   
<E extends PsiElement> E[] getChildrenByType(final TokenSet filter, ArrayFactory<E> f);
项目:consulo    文件:PsiPackageBase.java   
protected abstract ArrayFactory<? extends PsiPackage> getPackageArrayFactory();