Search in sources :

Example 1 with ParameterName

use of meghanada.reflect.names.ParameterName in project meghanada-server by mopemope.

the class MethodAnalyzeVisitor method searchParameterNames.

private boolean searchParameterNames(List<List<ParameterName>> pmsList) {
    for (List<ParameterName> pms : pmsList) {
        if (this.parameterTypes.size() != pms.size()) {
            continue;
        }
        boolean match = true;
        int last = this.parameterTypes.size() - 1;
        for (int i = 0; i < this.parameterTypes.size(); i++) {
            TypeInfo ti = this.parameterTypes.get(i);
            ParameterName parameterName = pms.get(i);
            String typeInfoType = ti.toString();
            String parameterNameType = parameterName.type;
            // remove generics
            int idx1 = typeInfoType.indexOf('<');
            if (idx1 > 0) {
                typeInfoType = typeInfoType.substring(0, idx1);
            }
            if (i == last) {
                typeInfoType = ClassNameUtils.replace(typeInfoType, "...", "");
            }
            // replace mark
            typeInfoType = ClassNameUtils.replace(typeInfoType, "%%", "");
            int idx2 = parameterNameType.indexOf('<');
            if (idx2 > 0) {
                parameterNameType = parameterNameType.substring(0, idx2);
            }
            // log.trace("search parameterName idx:{} {}/{}", i, typeInfoType, parameterNameType);
            if (typeInfoType.equals(parameterNameType)) {
                // log.trace("@ match parameterName idx:{} {}/{}", i, typeInfoType, parameterNameType);
                this.parameterNames[i] = parameterName.name;
            } else {
                // fail
                match = false;
            }
        }
        if (match) {
            // all OK
            return true;
        }
    }
    return false;
}
Also used : ParameterName(meghanada.reflect.names.ParameterName)

Aggregations

ParameterName (meghanada.reflect.names.ParameterName)1