@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); }
@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); }
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; }
@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); }
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; }
@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); }
@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()); }
@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); }
public boolean isAutoGeneratedName() { return ((PsiParameterStubImpl)getStub()).isAutoGeneratedName() && !DumbService.getInstance(getProject()).isDumb() && ((ClsMethodImpl)getDeclarationScope()).getSourceMirrorMethod() == null; }
public boolean isAutoGeneratedName() { return ((PsiParameterStubImpl) getStub()).isAutoGeneratedName() && !DumbService.getInstance(getProject()).isDumb() && ((ClsMethodImpl) getDeclarationScope()).getSourceMirrorMethod() == null; }
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; }