use of com.intellij.psi.impl.java.stubs.impl.PsiParameterStubImpl in project intellij-community by JetBrains.
the class JavaParameterElementType method createStub.
@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);
}
use of com.intellij.psi.impl.java.stubs.impl.PsiParameterStubImpl in project intellij-community by JetBrains.
the class JavaParameterElementType method deserialize.
@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);
}
use of com.intellij.psi.impl.java.stubs.impl.PsiParameterStubImpl in project intellij-community by JetBrains.
the class ClsParameterImpl method calcNiceParameterName.
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;
}
use of com.intellij.psi.impl.java.stubs.impl.PsiParameterStubImpl in project intellij-community by JetBrains.
the class ClsParameterImpl method calcName.
@Nullable
private String calcName() {
PsiParameterStubImpl parameterStub = (PsiParameterStubImpl) getStub();
if (!parameterStub.isAutoGeneratedName()) {
return parameterStub.getName();
}
if (DumbService.getInstance(getProject()).isDumb()) {
return null;
}
ClsMethodImpl method = (ClsMethodImpl) getDeclarationScope();
PsiMethod sourceMethod = method.getSourceMirrorMethod();
if (sourceMethod != null) {
assert sourceMethod != method : method;
return sourceMethod.getParameterList().getParameters()[getIndex()].getName();
}
return getMirrorName();
}
Aggregations