Search in sources :

Example 1 with PsiParameterStubImpl

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);
}
Also used : LighterASTNode(com.intellij.lang.LighterASTNode) PsiParameterStubImpl(com.intellij.psi.impl.java.stubs.impl.PsiParameterStubImpl) TypeInfo(com.intellij.psi.impl.cache.TypeInfo)

Example 2 with PsiParameterStubImpl

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);
}
Also used : PsiParameterStubImpl(com.intellij.psi.impl.java.stubs.impl.PsiParameterStubImpl) StringRef(com.intellij.util.io.StringRef) IOException(java.io.IOException) TypeInfo(com.intellij.psi.impl.cache.TypeInfo) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with PsiParameterStubImpl

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;
}
Also used : PsiParameterStubImpl(com.intellij.psi.impl.java.stubs.impl.PsiParameterStubImpl) JavaCodeStyleManager(com.intellij.psi.codeStyle.JavaCodeStyleManager)

Example 4 with PsiParameterStubImpl

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();
}
Also used : PsiParameterStubImpl(com.intellij.psi.impl.java.stubs.impl.PsiParameterStubImpl) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiParameterStubImpl (com.intellij.psi.impl.java.stubs.impl.PsiParameterStubImpl)4 TypeInfo (com.intellij.psi.impl.cache.TypeInfo)2 LighterASTNode (com.intellij.lang.LighterASTNode)1 JavaCodeStyleManager (com.intellij.psi.codeStyle.JavaCodeStyleManager)1 StringRef (com.intellij.util.io.StringRef)1 IOException (java.io.IOException)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1