private List getVariables()

in core/src/main/java/com/jetbrains/sa/jdi/ConcreteMethodImpl.java [302:361]


    private List<LocalVariableImpl> getVariables() throws AbsentInformationException {
        List<LocalVariableImpl> variables = (variablesRef == null) ? null :
                variablesRef.get();
        if (variables != null) {
            return variables;
        }

        // if there are no locals, there won't be a LVT
        if (saMethod.getMaxLocals() == 0) {
           variables = Collections.unmodifiableList(Collections.<LocalVariableImpl>emptyList());
           variablesRef = new SoftReference<List<LocalVariableImpl>>(variables);
           return variables;
        }

        if (! saMethod.hasLocalVariableTable()) {
            throw new AbsentInformationException();
        }
        //Build up the JDI view of local variable table.
        LocalVariableTableElement[] locals = saMethod.getLocalVariableTable();
        int localCount = locals.length;
        variables = new ArrayList<LocalVariableImpl>(localCount);
        for (LocalVariableTableElement local : locals) {
            String name =
                    saMethod.getConstants().getSymbolAt(local.getNameCPIndex()).asString();
            /*
             * Skip "this$*", "this+*", "this" entries because they are never real
             * variables from the JLS perspective. "this+*" is new with 1.5.
             * Instead of using '+', we check for java letter or digit to avoid
             * depending on javac's current choice of '+'.
             */
            boolean isInternalName = name.startsWith("this") &&
                    (name.length() == 4 || name.charAt(4) == '$' || !Character.isJavaIdentifierPart(name.charAt(4)));
            if (!isInternalName) {
                int slot = local.getSlot();
                long codeIndex = local.getStartBCI();
                int length = local.getLength();
                LocationImpl scopeStart = new LocationImpl(this, codeIndex);
                LocationImpl scopeEnd = new LocationImpl( this, codeIndex + length - 1);
                String signature =
                        saMethod.getConstants().getSymbolAt(local.getDescriptorCPIndex()).asString();

                int genericSigIndex = local.getSignatureCPIndex();
                String genericSignature = null;
                if (genericSigIndex != 0) {
                    genericSignature = saMethod.getConstants().getSymbolAt(genericSigIndex).asString();
                }

                LocalVariableImpl variable =
                        new LocalVariableImpl(this,
                                slot, scopeStart, scopeEnd,
                                name, signature, genericSignature);
                // Add to the variable list
                variables.add(variable);
            }
        }

        variables = Collections.unmodifiableList(variables);
        variablesRef = new SoftReference<List<LocalVariableImpl>>(variables);
        return variables;
    }