Java 类com.intellij.psi.impl.java.stubs.impl.PsiParameterStubImpl 实例源码

项目:intellij-ce-playground    文件:JavaParameterElementType.java   
@Override
public PsiParameterStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
  TypeInfo typeInfo = TypeInfo.create(tree, node, parentStub);
  LighterASTNode id = LightTreeUtil.requiredChildOfType(tree, node, JavaTokenType.IDENTIFIER);
  String name = RecordUtil.intern(tree.getCharTable(), id);
  return new PsiParameterStubImpl(parentStub, name, typeInfo, typeInfo.isEllipsis);
}
项目:intellij-ce-playground    文件:JavaParameterElementType.java   
@NotNull
@Override
public PsiParameterStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
  StringRef name = dataStream.readName();
  TypeInfo type = TypeInfo.readTYPE(dataStream);
  boolean isEllipsis = dataStream.readBoolean();
  return new PsiParameterStubImpl(parentStub, name, type, isEllipsis);
}
项目:intellij-ce-playground    文件:ClsParameterImpl.java   
private String calcNiceParameterName() {
  String name = null;

  PsiParameterStubImpl stub = (PsiParameterStubImpl)getStub();
  if (!stub.isAutoGeneratedName() || DumbService.getInstance(getProject()).isDumb()) {
    name = stub.getName();
  }

  if (name == null) {
    name = "p";

    JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(getProject());
    String[] nameSuggestions = codeStyleManager.suggestCompiledParameterName(getType()).names;
    if (nameSuggestions.length > 0 && nameSuggestions[0] != null) {
      name = nameSuggestions[0];
    }

    String base = name;
    int n = 0;
    AttemptsLoop:
    while (true) {
      for (PsiParameter parameter : ((PsiParameterList)getParent()).getParameters()) {
        if (parameter == this) break AttemptsLoop;
        String prevName = ((ClsParameterImpl)parameter).getMirrorName();
        if (name.equals(prevName)) {
          name = base + (++n);
          continue AttemptsLoop;
        }
      }
    }
  }

  return name;
}
项目:tools-idea    文件:JavaParameterElementType.java   
@Override
public PsiParameterStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
  TypeInfo typeInfo = TypeInfo.create(tree, node, parentStub);
  LighterASTNode id = LightTreeUtil.requiredChildOfType(tree, node, ID_TYPES);
  String name = RecordUtil.intern(tree.getCharTable(), id);
  return new PsiParameterStubImpl(parentStub, name, typeInfo, typeInfo.isEllipsis);
}
项目:tools-idea    文件:JavaParameterElementType.java   
@NotNull
@Override
public PsiParameterStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
  StringRef name = dataStream.readName();
  TypeInfo type = TypeInfo.readTYPE(dataStream);
  boolean isEllipsis = dataStream.readBoolean();
  return new PsiParameterStubImpl(parentStub, name, type, isEllipsis);
}
项目:tools-idea    文件:ClsParameterImpl.java   
private String calcNiceParameterName() {
  String name = null;

  PsiParameterStubImpl stub = (PsiParameterStubImpl)getStub();
  if (!stub.isAutoGeneratedName() || DumbService.getInstance(getProject()).isDumb()) {
    name = stub.getName();
  }

  if (name == null) {
    JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(getProject());
    String[] nameSuggestions = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, null, null, getType()).names;

    name = "p";
    if (nameSuggestions.length > 0 && nameSuggestions[0] != null) {
      name = nameSuggestions[0];
    }

    String base = name;
    int n = 0;
    AttemptsLoop:
    while (true) {
      for (PsiParameter parameter : ((PsiParameterList)getParent()).getParameters()) {
        if (parameter == this) break AttemptsLoop;
        String prevName = ((ClsParameterImpl)parameter).getMirrorName();
        if (name.equals(prevName)) {
          name = base + (++n);
          continue AttemptsLoop;
        }
      }
    }
  }

  return name;
}
项目:consulo-java    文件:JavaParameterElementType.java   
@Override
public PsiParameterStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub)
{
    TypeInfo typeInfo = TypeInfo.create(tree, node, parentStub);
    LighterASTNode id = LightTreeUtil.requiredChildOfType(tree, node, JavaTokenType.IDENTIFIER);
    String name = RecordUtil.intern(tree.getCharTable(), id);
    return new PsiParameterStubImpl(parentStub, name, typeInfo, typeInfo.isEllipsis, false);
}
项目:consulo-java    文件:JavaParameterElementType.java   
@Override
public void serialize(@NotNull PsiParameterStub stub, @NotNull StubOutputStream dataStream) throws IOException
{
    dataStream.writeName(stub.getName());
    TypeInfo.writeTYPE(dataStream, stub.getType(false));
    dataStream.writeByte(((PsiParameterStubImpl) stub).getFlags());
}
项目:consulo-java    文件:JavaParameterElementType.java   
@NotNull
@Override
public PsiParameterStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException
{
    StringRef name = dataStream.readName();
    if(name == null)
    {
        throw new IOException("corrupted indices");
    }
    TypeInfo type = TypeInfo.readTYPE(dataStream);
    byte flags = dataStream.readByte();
    return new PsiParameterStubImpl(parentStub, name.toString(), type, flags);
}
项目:intellij-ce-playground    文件:ClsParameterImpl.java   
public boolean isAutoGeneratedName() {
  return ((PsiParameterStubImpl)getStub()).isAutoGeneratedName() &&
         !DumbService.getInstance(getProject()).isDumb() &&
         ((ClsMethodImpl)getDeclarationScope()).getSourceMirrorMethod() == null;
}
项目:consulo-java    文件:ClsParameterImpl.java   
public boolean isAutoGeneratedName()
{
    return ((PsiParameterStubImpl) getStub()).isAutoGeneratedName() && !DumbService.getInstance(getProject()).isDumb() && ((ClsMethodImpl) getDeclarationScope()).getSourceMirrorMethod() == null;
}
项目:consulo-java    文件:ClsParameterImpl.java   
private String calcNiceParameterName()
{
    String name = null;

    PsiParameterStubImpl stub = (PsiParameterStubImpl) getStub();
    if(!stub.isAutoGeneratedName() || DumbService.getInstance(getProject()).isDumb())
    {
        name = stub.getName();
    }

    if(name == null)
    {
        name = "p";

        JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(getProject());
        String[] nameSuggestions = codeStyleManager.suggestCompiledParameterName(getType()).names;
        if(nameSuggestions.length > 0 && nameSuggestions[0] != null)
        {
            name = nameSuggestions[0];
        }

        String base = name;
        int n = 0;
        AttemptsLoop:
        while(true)
        {
            for(PsiParameter parameter : ((PsiParameterList) getParent()).getParameters())
            {
                if(parameter == this)
                {
                    break AttemptsLoop;
                }
                String prevName = ((ClsParameterImpl) parameter).getMirrorName();
                if(name.equals(prevName))
                {
                    name = base + (++n);
                    continue AttemptsLoop;
                }
            }
        }
    }

    return name;
}