type-inference.js
// to the proper renaming function (defined below).
to the proper renaming function (defined below).
to the proper renaming function ( defined below ) .
function computeRenaming(ast, file, offset) {
    var node = findNode(ast, file, offset)
    if (node === null)
        return null;
    var idClass = classifyId(node);
    if (idClass === null)
        return null;
    var groups;
    switch (idClass.type) {
        case 'variable':
            var scope = getVarDeclScope(node);
            if (scope.type === 'Program') {
                inferTypes(ast);
                groups = computeGlobalVariableRenaming(ast, node.name);
            } else {
                groups = computeLocalVariableRenaming(scope, node.name);
            }
            break;
        case 'label':
            groups = computeLabelRenaming(node);
            break;
        case 'property':
            inferTypes(ast);
            if (idClass.base.$type_node.rep() === ast.global.rep()) {
                groups = computeGlobalVariableRenaming(ast, node.name);
            } else {
                groups = computePropertyRenaming(ast, node.name);
            }
            break;
        default: throw new Error("unknown id class: " + idClass.type);
    }
    return groups;
}
function computeRenaming ( ast , file , offset ) { var node = findNode ( ast , file , offset ) if ( node === null ) return null ; var idClass = classifyId ( node ) ; if ( idClass === null ) return null ; var groups ; switch ( idClass . type ) { case 'variable' : var scope = getVarDeclScope ( node ) ; if ( scope . type === 'Program' ) { inferTypes ( ast ) ; groups = computeGlobalVariableRenaming ( ast , node . name ) ; } else { groups = computeLocalVariableRenaming ( scope , node . name ) ; } break ; case 'label' : groups = computeLabelRenaming ( node ) ; break ; case 'property' : inferTypes ( ast ) ; if ( idClass . base . $type_node . rep ( ) === ast . global . rep ( ) ) { groups = computeGlobalVariableRenaming ( ast , node . name ) ; } else { groups = computePropertyRenaming ( ast , node . name ) ; } break ; default : throw new Error ( "unknown id class: " + idClass . type ) ; } return groups ; }
to the proper renaming function (defined below).
to the proper renaming function ( defined below ) .