public SourceFunction(SourceFile sourceFile, String functionSignature, int startAtLine) { super(sourceFile.getKey() + "#" + functionSignature, functionSignature); setStartAtLine(startAtLine); } }
@Override public SourceCode createSourceCode(SourceCode parentSourceCode, AstNode astNode) { seq++; SourceFunction function = new SourceFunction("function:" + seq); function.setStartAtLine(astNode.getTokenLine()); return function; } }, FlexGrammar.FUNCTION_DEF, FlexGrammar.FUNCTION_EXPR));
@Override public SourceCode createSourceCode(SourceCode parentSourceCode, AstNode astNode) { String functionKey = getFunctionKey(astNode); SourceFunction function = new SourceFunction(functionKey); function.setStartAtLine(astNode.getTokenLine()); return function; }
@Override public SourceCode createSourceCode(SourceCode parentSourceCode, AstNode astNode) { String functionName = astNode.getFirstChild(PythonGrammar.FUNCNAME).getFirstChild().getTokenValue(); SourceFunction function = new SourceFunction(functionName + ":" + astNode.getToken().getLine()); function.setStartAtLine(astNode.getTokenLine()); return function; } }, PythonGrammar.FUNCDEF));
@Override public SourceCode createSourceCode(SourceCode parentSourceCode, AstNode astNode) { AstNode identifier = astNode.getFirstChild(EcmaScriptTokenType.IDENTIFIER, EcmaScriptGrammar.PROPERTY_NAME, Kind.IDENTIFIER); final String functionName = identifier == null ? "anonymous" : identifier.getTokenValue(); final String fileKey = parentSourceCode.isType(SourceFile.class) ? parentSourceCode.getKey() : parentSourceCode.getParent(SourceFile.class).getKey(); SourceFunction function = new SourceFunction(fileKey + ":" + functionName + ":" + astNode.getToken().getLine() + ":" + astNode.getToken().getColumn()); function.setStartAtLine(astNode.getTokenLine()); return function; } }, FUNCTION_NODES));