id
int32
0
12.9k
code
sequencelengths
2
264k
6,900
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "groovy", ".", "lang", ".", "GroovyClassLoader", ";", "import", "java", ".", "security", ".", "CodeSource", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "CompilerConfiguration", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "SourceUnit", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "SyntaxErrorMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "SyntaxException", ";", "public", "class", "CompileUnit", "{", "private", "final", "List", "<", "ModuleNode", ">", "modules", "=", "new", "ArrayList", "<", "ModuleNode", ">", "(", ")", ";", "private", "List", "<", "ModuleNode", ">", "sortedModules", ";", "private", "Map", "<", "String", ",", "ClassNode", ">", "classes", "=", "new", "HashMap", "<", "String", ",", "ClassNode", ">", "(", ")", ";", "private", "CompilerConfiguration", "config", ";", "private", "GroovyClassLoader", "classLoader", ";", "private", "CodeSource", "codeSource", ";", "private", "Map", "<", "String", ",", "ClassNode", ">", "classesToCompile", "=", "new", "HashMap", "<", "String", ",", "ClassNode", ">", "(", ")", ";", "private", "Map", "<", "String", ",", "SourceUnit", ">", "classNameToSource", "=", "new", "HashMap", "<", "String", ",", "SourceUnit", ">", "(", ")", ";", "private", "Map", "<", "String", ",", "InnerClassNode", ">", "generatedInnerClasses", "=", "new", "HashMap", "(", ")", ";", "public", "CompileUnit", "(", "GroovyClassLoader", "classLoader", ",", "CompilerConfiguration", "config", ")", "{", "this", "(", "classLoader", ",", "null", ",", "config", ")", ";", "}", "public", "CompileUnit", "(", "GroovyClassLoader", "classLoader", ",", "CodeSource", "codeSource", ",", "CompilerConfiguration", "config", ")", "{", "this", ".", "classLoader", "=", "classLoader", ";", "this", ".", "config", "=", "config", ";", "this", ".", "codeSource", "=", "codeSource", ";", "}", "public", "List", "<", "ModuleNode", ">", "getModules", "(", ")", "{", "return", "modules", ";", "}", "public", "void", "addModule", "(", "ModuleNode", "node", ")", "{", "if", "(", "node", "==", "null", ")", "return", ";", "modules", ".", "add", "(", "node", ")", ";", "this", ".", "sortedModules", "=", "null", ";", "node", ".", "setUnit", "(", "this", ")", ";", "addClasses", "(", "node", ".", "getClasses", "(", ")", ")", ";", "}", "public", "ClassNode", "getClass", "(", "String", "name", ")", "{", "ClassNode", "cn", "=", "classes", ".", "get", "(", "name", ")", ";", "if", "(", "cn", "!=", "null", ")", "return", "cn", ";", "return", "classesToCompile", ".", "get", "(", "name", ")", ";", "}", "public", "List", "getClasses", "(", ")", "{", "List", "<", "ClassNode", ">", "answer", "=", "new", "ArrayList", "<", "ClassNode", ">", "(", ")", ";", "for", "(", "ModuleNode", "module", ":", "modules", ")", "{", "answer", ".", "addAll", "(", "module", ".", "getClasses", "(", ")", ")", ";", "}", "return", "answer", ";", "}", "public", "CompilerConfiguration", "getConfig", "(", ")", "{", "return", "config", ";", "}", "public", "GroovyClassLoader", "getClassLoader", "(", ")", "{", "return", "classLoader", ";", "}", "public", "CodeSource", "getCodeSource", "(", ")", "{", "return", "codeSource", ";", "}", "void", "addClasses", "(", "List", "<", "ClassNode", ">", "classList", ")", "{", "for", "(", "ClassNode", "node", ":", "classList", ")", "{", "addClass", "(", "node", ")", ";", "}", "}", "public", "void", "addClass", "(", "ClassNode", "node", ")", "{", "node", "=", "node", ".", "redirect", "(", ")", ";", "String", "name", "=", "node", ".", "getName", "(", ")", ";", "ClassNode", "stored", "=", "classes", ".", "get", "(", "name", ")", ";", "if", "(", "stored", "!=", "null", "&&", "stored", "!=", "node", ")", "{", "SourceUnit", "nodeSource", "=", "node", ".", "getModule", "(", ")", ".", "getContext", "(", ")", ";", "SourceUnit", "storedSource", "=", "stored", ".", "getModule", "(", ")", ".", "getContext", "(", ")", ";", "String", "txt", "=", "\"\"", "+", "node", ".", "getName", "(", ")", "+", "\"", ":", "\"", ";", "if", "(", "nodeSource", "==", "storedSource", ")", "{", "txt", "+=", "\"The", "source", "\"", "+", "nodeSource", ".", "getName", "(", ")", "+", "\"\"", "+", "node", ".", "getName", "(", ")", "+", "\".n\"", ";", "if", "(", "node", ".", "isScriptBody", "(", ")", "||", "stored", ".", "isScriptBody", "(", ")", ")", "{", "txt", "+=", "\"\"", "+", "\"\"", ";", "}", "}", "else", "{", "txt", "+=", "\"The", "sources", "\"", "+", "nodeSource", ".", "getName", "(", ")", "+", "\"", "and", "\"", "+", "storedSource", ".", "getName", "(", ")", "+", "\"\"", "+", "node", ".", "getName", "(", ")", "+", "\".n\"", ";", "}", "nodeSource", ".", "getErrorCollector", "(", ")", ".", "addErrorAndContinue", "(", "new", "SyntaxErrorMessage", "(", "new", "SyntaxException", "(", "txt", ",", "node", ".", "getLineNumber", "(", ")", ",", "node", ".", "getColumnNumber", "(", ")", ",", "node", ".", "getLastLineNumber", "(", ")", ",", "node", ".", "getLastColumnNumber", "(", ")", ")", ",", "nodeSource", ")", ")", ";", "}", "classes", ".", "put", "(", "name", ",", "node", ")", ";", "if", "(", "classesToCompile", ".", "containsKey", "(", "name", ")", ")", "{", "ClassNode", "cn", "=", "classesToCompile", ".", "get", "(", "name", ")", ";", "cn", ".", "setRedirect", "(", "node", ")", ";", "classesToCompile", ".", "remove", "(", "name", ")", ";", "}", "}", "public", "void", "addClassNodeToCompile", "(", "ClassNode", "node", ",", "SourceUnit", "location", ")", "{", "classesToCompile", ".", "put", "(", "node", ".", "getName", "(", ")", ",", "node", ")", ";", "classNameToSource", ".", "put", "(", "node", ".", "getName", "(", ")", ",", "location", ")", ";", "}", "public", "SourceUnit", "getScriptSourceLocation", "(", "String", "className", ")", "{", "return", "classNameToSource", ".", "get", "(", "className", ")", ";", "}", "public", "boolean", "hasClassNodeToCompile", "(", ")", "{", "return", "!", "classesToCompile", ".", "isEmpty", "(", ")", ";", "}", "public", "Iterator", "<", "String", ">", "iterateClassNodeToCompile", "(", ")", "{", "return", "classesToCompile", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "}", "public", "InnerClassNode", "getGeneratedInnerClass", "(", "String", "name", ")", "{", "return", "generatedInnerClasses", ".", "get", "(", "name", ")", ";", "}", "public", "void", "addGeneratedInnerClass", "(", "InnerClassNode", "icn", ")", "{", "generatedInnerClasses", ".", "put", "(", "icn", ".", "getName", "(", ")", ",", "icn", ")", ";", "}", "public", "List", "<", "ModuleNode", ">", "getSortedModules", "(", ")", "{", "return", "this", ".", "sortedModules", ";", "}", "public", "void", "setSortedModules", "(", "List", "<", "ModuleNode", ">", "sortedModules", ")", "{", "this", ".", "sortedModules", "=", "sortedModules", ";", "}", "}", "</s>" ]
6,901
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "GroovyBugError", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "util", ".", "ListHashMap", ";", "public", "class", "ASTNode", "{", "private", "int", "lineNumber", "=", "-", "1", ";", "private", "int", "columnNumber", "=", "-", "1", ";", "private", "int", "lastLineNumber", "=", "-", "1", ";", "private", "int", "lastColumnNumber", "=", "-", "1", ";", "private", "ListHashMap", "metaDataMap", "=", "new", "ListHashMap", "(", ")", ";", "private", "int", "start", "=", "0", ";", "private", "int", "end", "=", "0", ";", "public", "void", "visit", "(", "GroovyCodeVisitor", "visitor", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", "+", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "String", "getText", "(", ")", "{", "return", "\"\"", "+", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\">\"", ";", "}", "public", "int", "getLineNumber", "(", ")", "{", "return", "lineNumber", ";", "}", "public", "void", "setLineNumber", "(", "int", "lineNumber", ")", "{", "this", ".", "lineNumber", "=", "lineNumber", ";", "}", "public", "int", "getColumnNumber", "(", ")", "{", "return", "columnNumber", ";", "}", "public", "void", "setColumnNumber", "(", "int", "columnNumber", ")", "{", "this", ".", "columnNumber", "=", "columnNumber", ";", "}", "public", "int", "getLastLineNumber", "(", ")", "{", "return", "lastLineNumber", ";", "}", "public", "void", "setLastLineNumber", "(", "int", "lastLineNumber", ")", "{", "this", ".", "lastLineNumber", "=", "lastLineNumber", ";", "}", "public", "int", "getLastColumnNumber", "(", ")", "{", "return", "lastColumnNumber", ";", "}", "public", "void", "setLastColumnNumber", "(", "int", "lastColumnNumber", ")", "{", "this", ".", "lastColumnNumber", "=", "lastColumnNumber", ";", "}", "public", "int", "getStart", "(", ")", "{", "return", "start", ";", "}", "public", "void", "setStart", "(", "int", "start", ")", "{", "this", ".", "start", "=", "start", ";", "}", "public", "int", "getEnd", "(", ")", "{", "return", "end", ";", "}", "public", "void", "setEnd", "(", "int", "end", ")", "{", "this", ".", "end", "=", "end", ";", "}", "public", "int", "getLength", "(", ")", "{", "return", "end", ">=", "0", "&&", "start", ">=", "0", "?", "end", "-", "start", ":", "-", "1", ";", "}", "public", "void", "setSourcePosition", "(", "ASTNode", "node", ")", "{", "this", ".", "columnNumber", "=", "node", ".", "getColumnNumber", "(", ")", ";", "this", ".", "lastLineNumber", "=", "node", ".", "getLastLineNumber", "(", ")", ";", "this", ".", "lastColumnNumber", "=", "node", ".", "getLastColumnNumber", "(", ")", ";", "this", ".", "lineNumber", "=", "node", ".", "getLineNumber", "(", ")", ";", "this", ".", "start", "=", "node", ".", "getStart", "(", ")", ";", "this", ".", "end", "=", "node", ".", "getEnd", "(", ")", ";", "}", "public", "Object", "getNodeMetaData", "(", "Object", "key", ")", "{", "return", "metaDataMap", ".", "get", "(", "key", ")", ";", "}", "public", "void", "copyNodeMetaData", "(", "ASTNode", "other", ")", "{", "metaDataMap", ".", "putAll", "(", "other", ".", "metaDataMap", ")", ";", "}", "public", "void", "setNodeMetaData", "(", "Object", "key", ",", "Object", "value", ")", "{", "if", "(", "key", "==", "null", ")", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "this", "+", "\".\"", ")", ";", "Object", "old", "=", "metaDataMap", ".", "put", "(", "key", ",", "value", ")", ";", "if", "(", "old", "!=", "null", ")", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "this", "+", "\".\"", ")", ";", "}", "public", "Object", "putNodeMetaData", "(", "Object", "key", ",", "Object", "value", ")", "{", "if", "(", "key", "==", "null", ")", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "this", "+", "\".\"", ")", ";", "return", "metaDataMap", ".", "put", "(", "key", ",", "value", ")", ";", "}", "public", "void", "removeNodeMetaData", "(", "Object", "key", ")", "{", "if", "(", "key", "==", "null", ")", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "this", "+", "\".\"", ")", ";", "metaDataMap", ".", "remove", "(", "key", ")", ";", "}", "}", "</s>" ]
6,902
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "List", ";", "public", "abstract", "class", "Comment", "{", "protected", "static", "final", "boolean", "debug", "=", "false", ";", "protected", "static", "final", "int", "BLOCK", "=", "0", ";", "protected", "static", "final", "int", "LINE", "=", "1", ";", "protected", "static", "final", "int", "JAVADOC", "=", "2", ";", "protected", "String", "comment", ";", "private", "int", "kind", ";", "public", "boolean", "usedUp", "=", "false", ";", "public", "int", "sline", ",", "scol", ",", "eline", ",", "ecol", ";", "public", "Comment", "(", "int", "kind", ",", "int", "sline", ",", "int", "scol", ",", "int", "eline", ",", "int", "ecol", ",", "String", "string", ")", "{", "this", ".", "kind", "=", "kind", ";", "this", ".", "sline", "=", "sline", ";", "this", ".", "scol", "=", "scol", ";", "this", ".", "eline", "=", "eline", ";", "this", ".", "ecol", "=", "ecol", ";", "this", ".", "comment", "=", "string", ";", "}", "public", "int", "getLastLine", "(", ")", "{", "return", "eline", ";", "}", "public", "static", "Comment", "makeSingleLineComment", "(", "int", "sline", ",", "int", "scol", ",", "int", "eline", ",", "int", "ecol", ",", "String", "string", ")", "{", "return", "new", "SingleLineComment", "(", "sline", ",", "scol", ",", "eline", ",", "ecol", ",", "string", ")", ";", "}", "public", "static", "Comment", "makeMultiLineComment", "(", "int", "sline", ",", "int", "scol", ",", "int", "eline", ",", "int", "ecol", ",", "String", "string", ")", "{", "return", "new", "MultiLineComment", "(", "sline", ",", "scol", ",", "eline", ",", "ecol", ",", "string", ")", ";", "}", "public", "abstract", "List", "<", "TaskEntry", ">", "getPositionsOf", "(", "String", "taskTag", ",", "String", "taskPriority", ",", "int", "[", "]", "lineseps", ",", "boolean", "caseSensitive", ")", ";", "public", "int", "[", "]", "getPositions", "(", "int", "[", "]", "lineseps", ")", "{", "int", "offsetToStartLine", "=", "(", "sline", "==", "1", "?", "0", ":", "lineseps", "[", "sline", "-", "2", "]", "+", "1", ")", ";", "int", "start", "=", "offsetToStartLine", "+", "(", "scol", "-", "1", ")", ";", "int", "offsetToEndLine", "=", "(", "eline", "==", "1", "?", "0", ":", "lineseps", "[", "eline", "-", "2", "]", "+", "1", ")", ";", "int", "end", "=", "offsetToEndLine", "+", "(", "ecol", "-", "1", ")", ";", "if", "(", "kind", "==", "LINE", ")", "{", "return", "new", "int", "[", "]", "{", "-", "start", ",", "-", "end", "}", ";", "}", "else", "if", "(", "kind", "==", "BLOCK", ")", "{", "return", "new", "int", "[", "]", "{", "start", ",", "-", "end", "}", ";", "}", "else", "{", "return", "new", "int", "[", "]", "{", "start", ",", "end", "}", ";", "}", "}", "public", "String", "toString", "(", ")", "{", "return", "comment", ";", "}", "protected", "boolean", "isValidStartLocationForTask", "(", "String", "text", ",", "int", "index", ",", "String", "taskTag", ")", "{", "int", "tagLen", "=", "taskTag", ".", "length", "(", ")", ";", "if", "(", "comment", ".", "charAt", "(", "index", "-", "1", ")", "==", "'@'", ")", "{", "return", "false", ";", "}", "if", "(", "Character", ".", "isJavaIdentifierStart", "(", "comment", ".", "charAt", "(", "index", ")", ")", ")", "{", "if", "(", "Character", ".", "isJavaIdentifierPart", "(", "comment", ".", "charAt", "(", "index", "-", "1", ")", ")", ")", "{", "return", "false", ";", "}", "}", "if", "(", "(", "index", "+", "tagLen", ")", "<", "comment", ".", "length", "(", ")", "&&", "Character", ".", "isJavaIdentifierStart", "(", "comment", ".", "charAt", "(", "index", "+", "tagLen", "-", "1", ")", ")", ")", "{", "if", "(", "Character", ".", "isJavaIdentifierPart", "(", "comment", ".", "charAt", "(", "index", "+", "tagLen", ")", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "protected", "int", "findTaskTag", "(", "String", "text", ",", "String", "tag", ",", "boolean", "caseSensitive", ",", "int", "fromIndex", ")", "{", "if", "(", "caseSensitive", ")", "{", "return", "text", ".", "indexOf", "(", "tag", ",", "fromIndex", ")", ";", "}", "else", "{", "int", "taglen", "=", "tag", ".", "length", "(", ")", ";", "String", "lcTag", "=", "tag", ".", "toLowerCase", "(", ")", ";", "char", "firstChar", "=", "lcTag", ".", "charAt", "(", "0", ")", ";", "for", "(", "int", "p", "=", "fromIndex", ",", "max", "=", "text", ".", "length", "(", ")", "-", "tag", ".", "length", "(", ")", "+", "1", ";", "p", "<", "max", ";", "p", "++", ")", "{", "if", "(", "Character", ".", "toLowerCase", "(", "text", ".", "charAt", "(", "p", ")", ")", "==", "firstChar", ")", "{", "boolean", "matched", "=", "true", ";", "for", "(", "int", "t", "=", "1", ";", "t", "<", "taglen", ";", "t", "++", ")", "{", "if", "(", "Character", ".", "toLowerCase", "(", "text", ".", "charAt", "(", "p", "+", "t", ")", ")", "!=", "lcTag", ".", "charAt", "(", "t", ")", ")", "{", "matched", "=", "false", ";", "break", ";", "}", "}", "if", "(", "matched", ")", "{", "return", "p", ";", "}", "}", "}", "return", "-", "1", ";", "}", "}", "public", "boolean", "isJavadoc", "(", ")", "{", "return", "kind", "==", "JAVADOC", ";", "}", "}", "class", "SingleLineComment", "extends", "Comment", "{", "public", "SingleLineComment", "(", "int", "sline", ",", "int", "scol", ",", "int", "eline", ",", "int", "ecol", ",", "String", "string", ")", "{", "super", "(", "LINE", ",", "sline", ",", "scol", ",", "eline", ",", "ecol", ",", "string", ")", ";", "if", "(", "debug", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "string", "+", "\"]", "at", "L\"", "+", "sline", "+", "\"C\"", "+", "scol", "+", "\">L\"", "+", "eline", "+", "\"C\"", "+", "ecol", ")", ";", "}", "}", "public", "List", "<", "TaskEntry", ">", "getPositionsOf", "(", "String", "taskTag", ",", "String", "taskPriority", ",", "int", "[", "]", "lineseps", ",", "boolean", "caseSensitive", ")", "{", "int", "i", "=", "findTaskTag", "(", "comment", ",", "taskTag", ",", "caseSensitive", ",", "0", ")", ";", "if", "(", "debug", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "comment", "+", "\"]", "for", "'\"", "+", "taskTag", "+", "\"'", "\"", "+", "i", ")", ";", "}", "if", "(", "i", "==", "-", "1", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "List", "<", "TaskEntry", ">", "tasks", "=", "new", "ArrayList", "<", "TaskEntry", ">", "(", ")", ";", "while", "(", "i", "!=", "-", "1", ")", "{", "if", "(", "isValidStartLocationForTask", "(", "comment", ",", "i", ",", "taskTag", ")", ")", "{", "int", "offsetToLineStart", "=", "(", "sline", "==", "1", "?", "0", ":", "lineseps", "[", "sline", "-", "2", "]", "+", "1", ")", ";", "int", "taskTagStart", "=", "offsetToLineStart", "+", "(", "scol", "-", "1", ")", "+", "i", ";", "int", "taskEnd", "=", "offsetToLineStart", "+", "ecol", "-", "2", ";", "TaskEntry", "taskEntry", "=", "new", "TaskEntry", "(", "taskTagStart", ",", "taskEnd", ",", "taskTag", ",", "taskPriority", ",", "comment", ",", "offsetToLineStart", "+", "scol", "-", "1", ")", ";", "if", "(", "debug", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "taskEntry", ".", "toString", "(", ")", ")", ";", "}", "tasks", ".", "add", "(", "taskEntry", ")", ";", "}", "i", "=", "findTaskTag", "(", "comment", ",", "taskTag", ",", "caseSensitive", ",", "i", "+", "taskTag", ".", "length", "(", ")", ")", ";", "}", "return", "tasks", ";", "}", "}", "class", "MultiLineComment", "extends", "Comment", "{", "public", "MultiLineComment", "(", "int", "sline", ",", "int", "scol", ",", "int", "eline", ",", "int", "ecol", ",", "String", "string", ")", "{", "super", "(", "string", ".", "charAt", "(", "2", ")", "==", "'*'", "?", "JAVADOC", ":", "BLOCK", ",", "sline", ",", "scol", ",", "eline", ",", "ecol", ",", "string", ")", ";", "if", "(", "debug", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "string", "+", "\"]", "at", "L\"", "+", "sline", "+", "\"C\"", "+", "scol", "+", "\">L\"", "+", "eline", "+", "\"C\"", "+", "ecol", ")", ";", "}", "}", "@", "Override", "public", "List", "<", "TaskEntry", ">", "getPositionsOf", "(", "String", "taskTag", ",", "String", "taskPriority", ",", "int", "[", "]", "lineseps", ",", "boolean", "caseSensitive", ")", "{", "int", "i", "=", "findTaskTag", "(", "comment", ",", "taskTag", ",", "caseSensitive", ",", "0", ")", ";", "if", "(", "debug", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "comment", "+", "\"]", "for", "'\"", "+", "taskTag", "+", "\"'", "\"", "+", "i", ")", ";", "}", "if", "(", "i", "==", "-", "1", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "List", "<", "TaskEntry", ">", "taskPositions", "=", "new", "ArrayList", "<", "TaskEntry", ">", "(", ")", ";", "while", "(", "i", "!=", "-", "1", ")", "{", "if", "(", "isValidStartLocationForTask", "(", "comment", ",", "i", ",", "taskTag", ")", ")", "{", "int", "offsetToCommentStart", "=", "(", "sline", "==", "1", "?", "0", ":", "lineseps", "[", "sline", "-", "2", "]", "+", "1", ")", "+", "scol", "-", "1", ";", "int", "taskTagStart", "=", "offsetToCommentStart", "+", "i", ";", "int", "taskEnd", "=", "taskTagStart", ";", "while", "(", "true", ")", "{", "int", "pos", "=", "taskEnd", "-", "offsetToCommentStart", ";", "char", "ch", "=", "comment", ".", "charAt", "(", "pos", ")", ";", "if", "(", "ch", "==", "'\\n'", "||", "ch", "==", "'\\r'", ")", "{", "break", ";", "}", "if", "(", "(", "pos", "+", "2", ")", ">", "comment", ".", "length", "(", ")", ")", "{", "taskEnd", "--", ";", "break", ";", "}", "taskEnd", "++", ";", "}", "TaskEntry", "taskEntry", "=", "new", "TaskEntry", "(", "taskTagStart", ",", "taskEnd", "-", "1", ",", "taskTag", ",", "taskPriority", ",", "comment", ",", "offsetToCommentStart", ")", ";", "if", "(", "debug", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "taskEntry", ".", "toString", "(", ")", ")", ";", "}", "taskPositions", ".", "add", "(", "taskEntry", ")", ";", "}", "i", "=", "findTaskTag", "(", "comment", ",", "taskTag", ",", "caseSensitive", ",", "i", "+", "taskTag", ".", "length", "(", ")", ")", ";", "}", "return", "taskPositions", ";", "}", "}", "</s>" ]
6,903
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "classgen", ".", "BytecodeExpression", ";", "import", "java", ".", "util", ".", "List", ";", "public", "abstract", "class", "CodeVisitorSupport", "implements", "GroovyCodeVisitor", "{", "public", "void", "visitBlockStatement", "(", "BlockStatement", "block", ")", "{", "for", "(", "Statement", "statement", ":", "block", ".", "getStatements", "(", ")", ")", "{", "statement", ".", "visit", "(", "this", ")", ";", "}", "}", "public", "void", "visitForLoop", "(", "ForStatement", "forLoop", ")", "{", "forLoop", ".", "getCollectionExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "forLoop", ".", "getLoopBlock", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitWhileLoop", "(", "WhileStatement", "loop", ")", "{", "loop", ".", "getBooleanExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "loop", ".", "getLoopBlock", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitDoWhileLoop", "(", "DoWhileStatement", "loop", ")", "{", "loop", ".", "getLoopBlock", "(", ")", ".", "visit", "(", "this", ")", ";", "loop", ".", "getBooleanExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitIfElse", "(", "IfStatement", "ifElse", ")", "{", "ifElse", ".", "getBooleanExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "ifElse", ".", "getIfBlock", "(", ")", ".", "visit", "(", "this", ")", ";", "Statement", "elseBlock", "=", "ifElse", ".", "getElseBlock", "(", ")", ";", "if", "(", "elseBlock", "instanceof", "EmptyStatement", ")", "{", "visitEmptyStatement", "(", "(", "EmptyStatement", ")", "elseBlock", ")", ";", "}", "else", "{", "elseBlock", ".", "visit", "(", "this", ")", ";", "}", "}", "public", "void", "visitExpressionStatement", "(", "ExpressionStatement", "statement", ")", "{", "statement", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitReturnStatement", "(", "ReturnStatement", "statement", ")", "{", "statement", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitAssertStatement", "(", "AssertStatement", "statement", ")", "{", "statement", ".", "getBooleanExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "statement", ".", "getMessageExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitTryCatchFinally", "(", "TryCatchStatement", "statement", ")", "{", "statement", ".", "getTryStatement", "(", ")", ".", "visit", "(", "this", ")", ";", "for", "(", "CatchStatement", "catchStatement", ":", "statement", ".", "getCatchStatements", "(", ")", ")", "{", "catchStatement", ".", "visit", "(", "this", ")", ";", "}", "Statement", "finallyStatement", "=", "statement", ".", "getFinallyStatement", "(", ")", ";", "if", "(", "finallyStatement", "instanceof", "EmptyStatement", ")", "{", "visitEmptyStatement", "(", "(", "EmptyStatement", ")", "finallyStatement", ")", ";", "}", "else", "{", "finallyStatement", ".", "visit", "(", "this", ")", ";", "}", "}", "protected", "void", "visitEmptyStatement", "(", "EmptyStatement", "statement", ")", "{", "}", "public", "void", "visitSwitch", "(", "SwitchStatement", "statement", ")", "{", "statement", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "for", "(", "CaseStatement", "caseStatement", ":", "statement", ".", "getCaseStatements", "(", ")", ")", "{", "caseStatement", ".", "visit", "(", "this", ")", ";", "}", "statement", ".", "getDefaultStatement", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitCaseStatement", "(", "CaseStatement", "statement", ")", "{", "statement", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "statement", ".", "getCode", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitBreakStatement", "(", "BreakStatement", "statement", ")", "{", "}", "public", "void", "visitContinueStatement", "(", "ContinueStatement", "statement", ")", "{", "}", "public", "void", "visitSynchronizedStatement", "(", "SynchronizedStatement", "statement", ")", "{", "statement", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "statement", ".", "getCode", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitThrowStatement", "(", "ThrowStatement", "statement", ")", "{", "statement", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitMethodCallExpression", "(", "MethodCallExpression", "call", ")", "{", "call", ".", "getObjectExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "call", ".", "getMethod", "(", ")", ".", "visit", "(", "this", ")", ";", "call", ".", "getArguments", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitStaticMethodCallExpression", "(", "StaticMethodCallExpression", "call", ")", "{", "call", ".", "getArguments", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitConstructorCallExpression", "(", "ConstructorCallExpression", "call", ")", "{", "call", ".", "getArguments", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitBinaryExpression", "(", "BinaryExpression", "expression", ")", "{", "expression", ".", "getLeftExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "expression", ".", "getRightExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitTernaryExpression", "(", "TernaryExpression", "expression", ")", "{", "expression", ".", "getBooleanExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "expression", ".", "getTrueExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "expression", ".", "getFalseExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitShortTernaryExpression", "(", "ElvisOperatorExpression", "expression", ")", "{", "visitTernaryExpression", "(", "expression", ")", ";", "}", "public", "void", "visitPostfixExpression", "(", "PostfixExpression", "expression", ")", "{", "expression", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitPrefixExpression", "(", "PrefixExpression", "expression", ")", "{", "expression", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitBooleanExpression", "(", "BooleanExpression", "expression", ")", "{", "expression", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitNotExpression", "(", "NotExpression", "expression", ")", "{", "expression", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitClosureExpression", "(", "ClosureExpression", "expression", ")", "{", "expression", ".", "getCode", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitTupleExpression", "(", "TupleExpression", "expression", ")", "{", "visitListOfExpressions", "(", "expression", ".", "getExpressions", "(", ")", ")", ";", "}", "public", "void", "visitListExpression", "(", "ListExpression", "expression", ")", "{", "visitListOfExpressions", "(", "expression", ".", "getExpressions", "(", ")", ")", ";", "}", "public", "void", "visitArrayExpression", "(", "ArrayExpression", "expression", ")", "{", "visitListOfExpressions", "(", "expression", ".", "getExpressions", "(", ")", ")", ";", "visitListOfExpressions", "(", "expression", ".", "getSizeExpression", "(", ")", ")", ";", "}", "public", "void", "visitMapExpression", "(", "MapExpression", "expression", ")", "{", "visitListOfExpressions", "(", "expression", ".", "getMapEntryExpressions", "(", ")", ")", ";", "}", "public", "void", "visitMapEntryExpression", "(", "MapEntryExpression", "expression", ")", "{", "expression", ".", "getKeyExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "expression", ".", "getValueExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitRangeExpression", "(", "RangeExpression", "expression", ")", "{", "expression", ".", "getFrom", "(", ")", ".", "visit", "(", "this", ")", ";", "expression", ".", "getTo", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitSpreadExpression", "(", "SpreadExpression", "expression", ")", "{", "expression", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitSpreadMapExpression", "(", "SpreadMapExpression", "expression", ")", "{", "expression", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitMethodPointerExpression", "(", "MethodPointerExpression", "expression", ")", "{", "expression", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "expression", ".", "getMethodName", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitUnaryMinusExpression", "(", "UnaryMinusExpression", "expression", ")", "{", "expression", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitUnaryPlusExpression", "(", "UnaryPlusExpression", "expression", ")", "{", "expression", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitBitwiseNegationExpression", "(", "BitwiseNegationExpression", "expression", ")", "{", "expression", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitCastExpression", "(", "CastExpression", "expression", ")", "{", "expression", ".", "getExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitConstantExpression", "(", "ConstantExpression", "expression", ")", "{", "}", "public", "void", "visitClassExpression", "(", "ClassExpression", "expression", ")", "{", "}", "public", "void", "visitVariableExpression", "(", "VariableExpression", "expression", ")", "{", "}", "public", "void", "visitDeclarationExpression", "(", "DeclarationExpression", "expression", ")", "{", "visitBinaryExpression", "(", "expression", ")", ";", "}", "public", "void", "visitPropertyExpression", "(", "PropertyExpression", "expression", ")", "{", "expression", ".", "getObjectExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "expression", ".", "getProperty", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitAttributeExpression", "(", "AttributeExpression", "expression", ")", "{", "expression", ".", "getObjectExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "expression", ".", "getProperty", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitFieldExpression", "(", "FieldExpression", "expression", ")", "{", "}", "public", "void", "visitGStringExpression", "(", "GStringExpression", "expression", ")", "{", "visitListOfExpressions", "(", "expression", ".", "getStrings", "(", ")", ")", ";", "visitListOfExpressions", "(", "expression", ".", "getValues", "(", ")", ")", ";", "}", "protected", "void", "visitListOfExpressions", "(", "List", "<", "?", "extends", "Expression", ">", "list", ")", "{", "if", "(", "list", "==", "null", ")", "return", ";", "for", "(", "Expression", "expression", ":", "list", ")", "{", "if", "(", "expression", "instanceof", "SpreadExpression", ")", "{", "Expression", "spread", "=", "(", "(", "SpreadExpression", ")", "expression", ")", ".", "getExpression", "(", ")", ";", "spread", ".", "visit", "(", "this", ")", ";", "}", "else", "{", "if", "(", "expression", "!=", "null", ")", "expression", ".", "visit", "(", "this", ")", ";", "}", "}", "}", "public", "void", "visitCatchStatement", "(", "CatchStatement", "statement", ")", "{", "statement", ".", "getCode", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitArgumentlistExpression", "(", "ArgumentListExpression", "ale", ")", "{", "visitTupleExpression", "(", "ale", ")", ";", "}", "public", "void", "visitClosureListExpression", "(", "ClosureListExpression", "cle", ")", "{", "visitListOfExpressions", "(", "cle", ".", "getExpressions", "(", ")", ")", ";", "}", "public", "void", "visitBytecodeExpression", "(", "BytecodeExpression", "cle", ")", "{", "}", "public", "void", "visitEmptyExpression", "(", "EmptyExpression", "expression", ")", "{", "}", "}", "</s>" ]
6,904
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "ConstantExpression", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "public", "class", "ImportNode", "extends", "AnnotatedNode", "implements", "Opcodes", "{", "private", "final", "ClassNode", "type", ";", "private", "final", "String", "alias", ";", "private", "final", "String", "fieldName", ";", "private", "final", "String", "packageName", ";", "private", "final", "boolean", "isStar", ";", "private", "final", "boolean", "isStatic", ";", "public", "ImportNode", "(", "ClassNode", "type", ",", "String", "alias", ")", "{", "this", ".", "type", "=", "type", ";", "this", ".", "alias", "=", "alias", ";", "this", ".", "isStar", "=", "false", ";", "this", ".", "isStatic", "=", "false", ";", "this", ".", "packageName", "=", "null", ";", "this", ".", "fieldName", "=", "null", ";", "}", "public", "ImportNode", "(", "String", "packageName", ")", "{", "this", ".", "type", "=", "null", ";", "this", ".", "alias", "=", "null", ";", "this", ".", "isStar", "=", "true", ";", "this", ".", "isStatic", "=", "false", ";", "this", ".", "packageName", "=", "packageName", ";", "this", ".", "fieldName", "=", "null", ";", "}", "public", "ImportNode", "(", "ClassNode", "type", ")", "{", "this", ".", "type", "=", "type", ";", "this", ".", "alias", "=", "null", ";", "this", ".", "isStar", "=", "true", ";", "this", ".", "isStatic", "=", "true", ";", "this", ".", "packageName", "=", "null", ";", "this", ".", "fieldName", "=", "null", ";", "}", "public", "ImportNode", "(", "ClassNode", "type", ",", "String", "fieldName", ",", "String", "alias", ")", "{", "this", ".", "type", "=", "type", ";", "this", ".", "alias", "=", "alias", ";", "this", ".", "isStar", "=", "false", ";", "this", ".", "isStatic", "=", "true", ";", "this", ".", "packageName", "=", "null", ";", "this", ".", "fieldName", "=", "fieldName", ";", "}", "public", "String", "getText", "(", ")", "{", "String", "typeName", "=", "getClassName", "(", ")", ";", "if", "(", "isStar", "&&", "!", "isStatic", ")", "{", "return", "\"import", "\"", "+", "packageName", "+", "\"*\"", ";", "}", "if", "(", "isStar", ")", "{", "return", "\"\"", "+", "typeName", "+", "\".*\"", ";", "}", "if", "(", "isStatic", ")", "{", "if", "(", "alias", "!=", "null", "&&", "alias", ".", "length", "(", ")", "!=", "0", "&&", "!", "alias", ".", "equals", "(", "fieldName", ")", ")", "{", "return", "\"\"", "+", "typeName", "+", "\".\"", "+", "fieldName", "+", "\"", "as", "\"", "+", "alias", ";", "}", "return", "\"\"", "+", "typeName", "+", "\".\"", "+", "fieldName", ";", "}", "if", "(", "alias", "==", "null", "||", "alias", ".", "length", "(", ")", "==", "0", ")", "{", "return", "\"import", "\"", "+", "typeName", ";", "}", "return", "\"import", "\"", "+", "typeName", "+", "\"", "as", "\"", "+", "alias", ";", "}", "public", "String", "getPackageName", "(", ")", "{", "return", "packageName", ";", "}", "public", "String", "getFieldName", "(", ")", "{", "return", "fieldName", ";", "}", "public", "boolean", "isStar", "(", ")", "{", "return", "isStar", ";", "}", "public", "boolean", "isStatic", "(", ")", "{", "return", "isStatic", ";", "}", "public", "String", "getAlias", "(", ")", "{", "return", "alias", ";", "}", "public", "ClassNode", "getType", "(", ")", "{", "return", "type", ";", "}", "public", "String", "getClassName", "(", ")", "{", "return", "type", "==", "null", "?", "null", ":", "type", ".", "getName", "(", ")", ";", "}", "public", "void", "visit", "(", "GroovyCodeVisitor", "visitor", ")", "{", "}", "private", "boolean", "unresolvable", "=", "false", ";", "private", "ConstantExpression", "aliasExpr", ";", "private", "ConstantExpression", "fieldNameExpr", ";", "public", "ConstantExpression", "getFieldNameExpr", "(", ")", "{", "return", "fieldNameExpr", ";", "}", "public", "void", "setFieldNameExpr", "(", "ConstantExpression", "fieldNameExpr", ")", "{", "this", ".", "fieldNameExpr", "=", "fieldNameExpr", ";", "}", "public", "ConstantExpression", "getAliasExpr", "(", ")", "{", "return", "aliasExpr", ";", "}", "public", "void", "setAliasExpr", "(", "ConstantExpression", "aliasExpr", ")", "{", "this", ".", "aliasExpr", "=", "aliasExpr", ";", "}", "public", "void", "markAsUnresolvable", "(", ")", "{", "unresolvable", "=", "true", ";", "}", "public", "boolean", "isUnresolvable", "(", ")", "{", "return", "unresolvable", ";", "}", "public", "boolean", "isStaticStar", "(", ")", "{", "return", "type", "!=", "null", "&&", "alias", "==", "null", ";", "}", "}", "</s>" ]
6,905
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "tools", ".", "GenericsUtils", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "tools", ".", "WideningCategories", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Set", ";", "public", "class", "GenericsType", "extends", "ASTNode", "{", "protected", "ClassNode", "[", "]", "upperBounds", ";", "protected", "ClassNode", "lowerBound", ";", "protected", "ClassNode", "type", ";", "protected", "String", "name", ";", "protected", "boolean", "placeholder", ";", "private", "boolean", "resolved", ";", "private", "boolean", "wildcard", ";", "public", "GenericsType", "(", "ClassNode", "type", ",", "ClassNode", "[", "]", "upperBounds", ",", "ClassNode", "lowerBound", ")", "{", "this", ".", "type", "=", "type", ";", "this", ".", "name", "=", "type", ".", "isGenericsPlaceHolder", "(", ")", "?", "type", ".", "getUnresolvedName", "(", ")", ":", "type", ".", "getName", "(", ")", ";", "this", ".", "upperBounds", "=", "upperBounds", ";", "this", ".", "lowerBound", "=", "lowerBound", ";", "placeholder", "=", "type", ".", "isGenericsPlaceHolder", "(", ")", ";", "resolved", "=", "false", ";", "}", "public", "GenericsType", "(", ")", "{", "}", "public", "String", "toDetailsString", "(", ")", "{", "StringBuilder", "s", "=", "new", "StringBuilder", "(", ")", ";", "s", ".", "append", "(", "\"\"", ")", ".", "append", "(", "name", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "placeholder", ")", ";", "s", ".", "append", "(", "\",resolved=\"", ")", ".", "append", "(", "resolved", ")", ".", "append", "(", "\",wildcard=\"", ")", ".", "append", "(", "wildcard", ")", ";", "s", ".", "append", "(", "\",type=\"", ")", ".", "append", "(", "type", ")", ";", "if", "(", "lowerBound", "!=", "null", ")", "{", "s", ".", "append", "(", "\",lowerBound=\"", ")", ".", "append", "(", "lowerBound", ")", ";", "}", "if", "(", "upperBounds", "!=", "null", ")", "{", "s", ".", "append", "(", "\"\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "upperBounds", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", ">", "0", ")", "{", "s", ".", "append", "(", "\",\"", ")", ";", "}", "s", ".", "append", "(", "upperBounds", "[", "i", "]", ")", ";", "}", "}", "s", ".", "append", "(", "\"]]\"", ")", ";", "s", ".", "append", "(", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "return", "s", ".", "toString", "(", ")", ";", "}", "public", "GenericsType", "(", "ClassNode", "basicType", ")", "{", "this", "(", "basicType", ",", "null", ",", "null", ")", ";", "}", "public", "ClassNode", "getType", "(", ")", "{", "return", "type", ";", "}", "public", "void", "setType", "(", "ClassNode", "type", ")", "{", "this", ".", "type", "=", "type", ";", "}", "public", "String", "toString", "(", ")", "{", "Set", "<", "String", ">", "visited", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "return", "toString", "(", "visited", ")", ";", "}", "private", "String", "toString", "(", "Set", "<", "String", ">", "visited", ")", "{", "if", "(", "placeholder", ")", "visited", ".", "add", "(", "name", ")", ";", "String", "ret", "=", "(", "type", "==", "null", "||", "placeholder", "||", "wildcard", ")", "?", "name", ":", "genericsBounds", "(", "type", ",", "visited", ")", ";", "if", "(", "upperBounds", "!=", "null", ")", "{", "ret", "+=", "\"", "extends", "\"", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "upperBounds", ".", "length", ";", "i", "++", ")", "{", "ret", "+=", "genericsBounds", "(", "upperBounds", "[", "i", "]", ",", "visited", ")", ";", "if", "(", "i", "+", "1", "<", "upperBounds", ".", "length", ")", "ret", "+=", "\"", "&", "\"", ";", "}", "}", "else", "if", "(", "lowerBound", "!=", "null", ")", "{", "ret", "+=", "\"", "super", "\"", "+", "genericsBounds", "(", "lowerBound", ",", "visited", ")", ";", "}", "return", "ret", ";", "}", "private", "String", "genericsBounds", "(", "ClassNode", "theType", ",", "Set", "<", "String", ">", "visited", ")", "{", "StringBuilder", "ret", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "theType", ".", "isArray", "(", ")", ")", "{", "ret", ".", "append", "(", "theType", ".", "getComponentType", "(", ")", ".", "getName", "(", ")", ")", ";", "ret", ".", "append", "(", "\"[]\"", ")", ";", "}", "else", "if", "(", "theType", ".", "redirect", "(", ")", "instanceof", "InnerClassNode", ")", "{", "InnerClassNode", "innerClassNode", "=", "(", "InnerClassNode", ")", "theType", ".", "redirect", "(", ")", ";", "String", "parentClassNodeName", "=", "innerClassNode", ".", "getOuterClass", "(", ")", ".", "getName", "(", ")", ";", "ret", ".", "append", "(", "genericsBounds", "(", "innerClassNode", ".", "getOuterClass", "(", ")", ",", "new", "HashSet", "<", "String", ">", "(", ")", ")", ")", ";", "ret", ".", "append", "(", "\".\"", ")", ";", "String", "typeName", "=", "theType", ".", "getName", "(", ")", ";", "ret", ".", "append", "(", "typeName", ".", "substring", "(", "parentClassNodeName", ".", "length", "(", ")", "+", "1", ")", ")", ";", "}", "else", "{", "ret", ".", "append", "(", "theType", ".", "getName", "(", ")", ")", ";", "}", "GenericsType", "[", "]", "genericsTypes", "=", "theType", ".", "getGenericsTypes", "(", ")", ";", "if", "(", "genericsTypes", "==", "null", "||", "genericsTypes", ".", "length", "==", "0", ")", "return", "ret", ".", "toString", "(", ")", ";", "if", "(", "genericsTypes", ".", "length", "==", "1", "&&", "genericsTypes", "[", "0", "]", ".", "isPlaceholder", "(", ")", "&&", "theType", ".", "getName", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "return", "genericsTypes", "[", "0", "]", ".", "getName", "(", ")", ";", "}", "ret", ".", "append", "(", "\"<\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "genericsTypes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", "!=", "0", ")", "ret", ".", "append", "(", "\",", "\"", ")", ";", "GenericsType", "type", "=", "genericsTypes", "[", "i", "]", ";", "if", "(", "type", ".", "isPlaceholder", "(", ")", "&&", "visited", ".", "contains", "(", "type", ".", "getName", "(", ")", ")", ")", "{", "ret", ".", "append", "(", "type", ".", "getName", "(", ")", ")", ";", "}", "else", "{", "ret", ".", "append", "(", "type", ".", "toString", "(", "visited", ")", ")", ";", "}", "}", "ret", ".", "append", "(", "\">\"", ")", ";", "return", "ret", ".", "toString", "(", ")", ";", "}", "public", "ClassNode", "[", "]", "getUpperBounds", "(", ")", "{", "return", "upperBounds", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "name", ";", "}", "public", "boolean", "isPlaceholder", "(", ")", "{", "return", "placeholder", ";", "}", "public", "void", "setPlaceholder", "(", "boolean", "placeholder", ")", "{", "this", ".", "placeholder", "=", "placeholder", ";", "type", ".", "setGenericsPlaceHolder", "(", "placeholder", ")", ";", "}", "public", "boolean", "isResolved", "(", ")", "{", "return", "resolved", "||", "placeholder", ";", "}", "public", "void", "setResolved", "(", "boolean", "res", ")", "{", "resolved", "=", "res", ";", "}", "public", "void", "setName", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ";", "}", "public", "boolean", "isWildcard", "(", ")", "{", "return", "wildcard", ";", "}", "public", "void", "setWildcard", "(", "boolean", "wildcard", ")", "{", "this", ".", "wildcard", "=", "wildcard", ";", "}", "public", "ClassNode", "getLowerBound", "(", ")", "{", "return", "lowerBound", ";", "}", "public", "boolean", "isCompatibleWith", "(", "ClassNode", "classNode", ")", "{", "return", "new", "GenericsTypeMatcher", "(", ")", ".", "matches", "(", "classNode", ")", ";", "}", "private", "class", "GenericsTypeMatcher", "{", "public", "boolean", "implementsInterfaceOrIsSubclassOf", "(", "ClassNode", "type", ",", "ClassNode", "superOrInterface", ")", "{", "boolean", "result", "=", "type", ".", "equals", "(", "superOrInterface", ")", "||", "type", ".", "isDerivedFrom", "(", "superOrInterface", ")", "||", "type", ".", "implementsInterface", "(", "superOrInterface", ")", ";", "if", "(", "result", ")", "{", "return", "true", ";", "}", "if", "(", "superOrInterface", "instanceof", "WideningCategories", ".", "LowestUpperBoundClassNode", ")", "{", "WideningCategories", ".", "LowestUpperBoundClassNode", "cn", "=", "(", "WideningCategories", ".", "LowestUpperBoundClassNode", ")", "superOrInterface", ";", "result", "=", "implementsInterfaceOrIsSubclassOf", "(", "type", ",", "cn", ".", "getSuperClass", "(", ")", ")", ";", "if", "(", "result", ")", "{", "for", "(", "ClassNode", "interfaceNode", ":", "cn", ".", "getInterfaces", "(", ")", ")", "{", "result", "=", "implementsInterfaceOrIsSubclassOf", "(", "type", ",", "interfaceNode", ")", ";", "if", "(", "!", "result", ")", "break", ";", "}", "}", "if", "(", "result", ")", "return", "true", ";", "}", "if", "(", "type", ".", "isArray", "(", ")", "&&", "superOrInterface", ".", "isArray", "(", ")", ")", "{", "return", "implementsInterfaceOrIsSubclassOf", "(", "type", ".", "getComponentType", "(", ")", ",", "superOrInterface", ".", "getComponentType", "(", ")", ")", ";", "}", "return", "false", ";", "}", "public", "boolean", "matches", "(", "ClassNode", "classNode", ")", "{", "if", "(", "classNode", ".", "isGenericsPlaceHolder", "(", ")", ")", "{", "GenericsType", "[", "]", "genericsTypes", "=", "classNode", ".", "getGenericsTypes", "(", ")", ";", "if", "(", "genericsTypes", "==", "null", ")", "return", "true", ";", "if", "(", "isWildcard", "(", ")", ")", "{", "if", "(", "lowerBound", "!=", "null", ")", "return", "genericsTypes", "[", "0", "]", ".", "getName", "(", ")", ".", "equals", "(", "lowerBound", ".", "getUnresolvedName", "(", ")", ")", ";", "if", "(", "upperBounds", "!=", "null", ")", "{", "for", "(", "ClassNode", "upperBound", ":", "upperBounds", ")", "{", "if", "(", "genericsTypes", "[", "0", "]", ".", "getName", "(", ")", ".", "equals", "(", "upperBound", ".", "getUnresolvedName", "(", ")", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}", "}", "return", "genericsTypes", "[", "0", "]", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ";", "}", "if", "(", "wildcard", "||", "placeholder", ")", "{", "if", "(", "upperBounds", "!=", "null", ")", "{", "boolean", "upIsOk", "=", "true", ";", "for", "(", "int", "i", "=", "0", ",", "upperBoundsLength", "=", "upperBounds", ".", "length", ";", "i", "<", "upperBoundsLength", "&&", "upIsOk", ";", "i", "++", ")", "{", "final", "ClassNode", "upperBound", "=", "upperBounds", "[", "i", "]", ";", "upIsOk", "=", "implementsInterfaceOrIsSubclassOf", "(", "classNode", ",", "upperBound", ")", ";", "}", "upIsOk", "=", "upIsOk", "&&", "checkGenerics", "(", "classNode", ")", ";", "return", "upIsOk", ";", "}", "if", "(", "lowerBound", "!=", "null", ")", "{", "return", "implementsInterfaceOrIsSubclassOf", "(", "lowerBound", ",", "classNode", ")", "&&", "checkGenerics", "(", "classNode", ")", ";", "}", "}", "if", "(", "(", "type", "!=", "null", "&&", "!", "type", ".", "equals", "(", "classNode", ")", ")", ")", "{", "return", "false", ";", "}", "return", "type", "==", "null", "||", "compareGenericsWithBound", "(", "classNode", ",", "type", ")", ";", "}", "private", "boolean", "checkGenerics", "(", "final", "ClassNode", "classNode", ")", "{", "if", "(", "upperBounds", "!=", "null", ")", "{", "for", "(", "ClassNode", "upperBound", ":", "upperBounds", ")", "{", "if", "(", "!", "compareGenericsWithBound", "(", "classNode", ",", "upperBound", ")", ")", "return", "false", ";", "}", "}", "if", "(", "lowerBound", "!=", "null", ")", "{", "if", "(", "!", "lowerBound", ".", "redirect", "(", ")", ".", "isUsingGenerics", "(", ")", ")", "{", "if", "(", "!", "compareGenericsWithBound", "(", "classNode", ",", "lowerBound", ")", ")", "return", "false", ";", "}", "}", "return", "true", ";", "}", "private", "boolean", "compareGenericsWithBound", "(", "final", "ClassNode", "classNode", ",", "final", "ClassNode", "bound", ")", "{", "if", "(", "classNode", "==", "null", ")", "return", "false", ";", "if", "(", "!", "bound", ".", "isUsingGenerics", "(", ")", ")", "{", "return", "true", ";", "}", "if", "(", "!", "classNode", ".", "equals", "(", "bound", ")", ")", "{", "if", "(", "bound", ".", "isInterface", "(", ")", ")", "{", "Set", "<", "ClassNode", ">", "interfaces", "=", "classNode", ".", "getAllInterfaces", "(", ")", ";", "for", "(", "ClassNode", "anInterface", ":", "interfaces", ")", "{", "if", "(", "anInterface", ".", "equals", "(", "bound", ")", ")", "{", "ClassNode", "node", "=", "GenericsUtils", ".", "parameterizeType", "(", "classNode", ",", "anInterface", ")", ";", "return", "compareGenericsWithBound", "(", "node", ",", "bound", ")", ";", "}", "}", "}", "if", "(", "bound", "instanceof", "WideningCategories", ".", "LowestUpperBoundClassNode", ")", "{", "boolean", "success", "=", "compareGenericsWithBound", "(", "classNode", ",", "bound", ".", "getSuperClass", "(", ")", ")", ";", "if", "(", "success", ")", "{", "ClassNode", "[", "]", "interfaces", "=", "bound", ".", "getInterfaces", "(", ")", ";", "for", "(", "ClassNode", "anInterface", ":", "interfaces", ")", "{", "success", "&=", "compareGenericsWithBound", "(", "classNode", ",", "anInterface", ")", ";", "}", "}", "if", "(", "success", ")", "return", "true", ";", "}", "return", "compareGenericsWithBound", "(", "getParameterizedSuperClass", "(", "classNode", ")", ",", "bound", ")", ";", "}", "GenericsType", "[", "]", "cnTypes", "=", "classNode", ".", "getGenericsTypes", "(", ")", ";", "if", "(", "cnTypes", "==", "null", "&&", "classNode", ".", "isRedirectNode", "(", ")", ")", "cnTypes", "=", "classNode", ".", "redirect", "(", ")", ".", "getGenericsTypes", "(", ")", ";", "if", "(", "cnTypes", "==", "null", ")", "{", "return", "true", ";", "}", "GenericsType", "[", "]", "redirectBoundGenericTypes", "=", "bound", ".", "redirect", "(", ")", ".", "getGenericsTypes", "(", ")", ";", "Map", "<", "String", ",", "GenericsType", ">", "classNodePlaceholders", "=", "GenericsUtils", ".", "extractPlaceholders", "(", "classNode", ")", ";", "Map", "<", "String", ",", "GenericsType", ">", "boundPlaceHolders", "=", "GenericsUtils", ".", "extractPlaceholders", "(", "bound", ")", ";", "boolean", "match", "=", "true", ";", "for", "(", "int", "i", "=", "0", ";", "redirectBoundGenericTypes", "!=", "null", "&&", "i", "<", "redirectBoundGenericTypes", ".", "length", "&&", "match", ";", "i", "++", ")", "{", "GenericsType", "redirectBoundType", "=", "redirectBoundGenericTypes", "[", "i", "]", ";", "GenericsType", "classNodeType", "=", "cnTypes", "[", "i", "]", ";", "if", "(", "classNodeType", ".", "isPlaceholder", "(", ")", ")", "{", "if", "(", "redirectBoundType", ".", "isPlaceholder", "(", ")", ")", "{", "match", "=", "classNodeType", ".", "getName", "(", ")", ".", "equals", "(", "redirectBoundType", ".", "getName", "(", ")", ")", ";", "}", "else", "{", "String", "name", "=", "classNodeType", ".", "getName", "(", ")", ";", "if", "(", "classNodePlaceholders", ".", "containsKey", "(", "name", ")", ")", "classNodeType", "=", "classNodePlaceholders", ".", "get", "(", "name", ")", ";", "match", "=", "classNodeType", ".", "isCompatibleWith", "(", "redirectBoundType", ".", "getType", "(", ")", ")", ";", "}", "}", "else", "{", "if", "(", "redirectBoundType", ".", "isPlaceholder", "(", ")", ")", "{", "if", "(", "classNodeType", ".", "isPlaceholder", "(", ")", ")", "{", "match", "=", "classNodeType", ".", "getName", "(", ")", ".", "equals", "(", "redirectBoundType", ".", "getName", "(", ")", ")", ";", "}", "else", "{", "String", "name", "=", "redirectBoundType", ".", "getName", "(", ")", ";", "if", "(", "boundPlaceHolders", ".", "containsKey", "(", "name", ")", ")", "{", "redirectBoundType", "=", "boundPlaceHolders", ".", "get", "(", "name", ")", ";", "boolean", "wildcard", "=", "redirectBoundType", ".", "isWildcard", "(", ")", ";", "boolean", "placeholder", "=", "redirectBoundType", ".", "isPlaceholder", "(", ")", ";", "if", "(", "placeholder", "||", "wildcard", ")", "{", "if", "(", "wildcard", ")", "{", "if", "(", "redirectBoundType", ".", "lowerBound", "!=", "null", ")", "{", "GenericsType", "gt", "=", "new", "GenericsType", "(", "redirectBoundType", ".", "lowerBound", ")", ";", "if", "(", "gt", ".", "isPlaceholder", "(", ")", ")", "{", "if", "(", "classNodePlaceholders", ".", "containsKey", "(", "gt", ".", "getName", "(", ")", ")", ")", "{", "gt", "=", "classNodePlaceholders", ".", "get", "(", "gt", ".", "getName", "(", ")", ")", ";", "}", "}", "match", "=", "implementsInterfaceOrIsSubclassOf", "(", "gt", ".", "getType", "(", ")", ",", "classNodeType", ".", "getType", "(", ")", ")", ";", "}", "if", "(", "match", "&&", "redirectBoundType", ".", "upperBounds", "!=", "null", ")", "{", "for", "(", "ClassNode", "upperBound", ":", "redirectBoundType", ".", "upperBounds", ")", "{", "GenericsType", "gt", "=", "new", "GenericsType", "(", "upperBound", ")", ";", "if", "(", "gt", ".", "isPlaceholder", "(", ")", ")", "{", "if", "(", "classNodePlaceholders", ".", "containsKey", "(", "gt", ".", "getName", "(", ")", ")", ")", "{", "gt", "=", "classNodePlaceholders", ".", "get", "(", "gt", ".", "getName", "(", ")", ")", ";", "}", "}", "match", "=", "match", "&&", "implementsInterfaceOrIsSubclassOf", "(", "classNodeType", ".", "getType", "(", ")", ",", "gt", ".", "getType", "(", ")", ")", ";", "}", "}", "return", "match", ";", "}", "else", "{", "redirectBoundType", "=", "classNodePlaceholders", ".", "get", "(", "name", ")", ";", "}", "}", "}", "match", "=", "redirectBoundType", ".", "isCompatibleWith", "(", "classNodeType", ".", "getType", "(", ")", ")", ";", "}", "}", "else", "{", "match", "=", "classNodeType", ".", "isCompatibleWith", "(", "redirectBoundType", ".", "getType", "(", ")", ")", ";", "}", "}", "}", "if", "(", "!", "match", ")", "return", "false", ";", "return", "true", ";", "}", "}", "private", "static", "ClassNode", "getParameterizedSuperClass", "(", "ClassNode", "classNode", ")", "{", "if", "(", "ClassHelper", ".", "OBJECT_TYPE", ".", "equals", "(", "classNode", ")", ")", "return", "null", ";", "ClassNode", "superClass", "=", "classNode", ".", "getUnresolvedSuperClass", "(", ")", ";", "if", "(", "superClass", "==", "null", ")", "{", "return", "ClassHelper", ".", "OBJECT_TYPE", ";", "}", "if", "(", "!", "classNode", ".", "isUsingGenerics", "(", ")", "||", "!", "superClass", ".", "isUsingGenerics", "(", ")", ")", "return", "superClass", ";", "GenericsType", "[", "]", "genericsTypes", "=", "classNode", ".", "getGenericsTypes", "(", ")", ";", "GenericsType", "[", "]", "redirectGenericTypes", "=", "classNode", ".", "redirect", "(", ")", ".", "getGenericsTypes", "(", ")", ";", "superClass", "=", "superClass", ".", "getPlainNodeReference", "(", ")", ";", "if", "(", "genericsTypes", "==", "null", "||", "redirectGenericTypes", "==", "null", "||", "superClass", ".", "getGenericsTypes", "(", ")", "==", "null", ")", "return", "superClass", ";", "for", "(", "int", "i", "=", "0", ",", "genericsTypesLength", "=", "genericsTypes", ".", "length", ";", "i", "<", "genericsTypesLength", ";", "i", "++", ")", "{", "if", "(", "redirectGenericTypes", "[", "i", "]", ".", "isPlaceholder", "(", ")", ")", "{", "final", "GenericsType", "genericsType", "=", "genericsTypes", "[", "i", "]", ";", "GenericsType", "[", "]", "superGenericTypes", "=", "superClass", ".", "getGenericsTypes", "(", ")", ";", "for", "(", "int", "j", "=", "0", ",", "superGenericTypesLength", "=", "superGenericTypes", ".", "length", ";", "j", "<", "superGenericTypesLength", ";", "j", "++", ")", "{", "final", "GenericsType", "superGenericType", "=", "superGenericTypes", "[", "j", "]", ";", "if", "(", "superGenericType", ".", "isPlaceholder", "(", ")", "&&", "superGenericType", ".", "getName", "(", ")", ".", "equals", "(", "redirectGenericTypes", "[", "i", "]", ".", "getName", "(", ")", ")", ")", "{", "superGenericTypes", "[", "j", "]", "=", "genericsType", ";", "}", "}", "}", "}", "return", "superClass", ";", "}", "public", "void", "setUpperBounds", "(", "ClassNode", "[", "]", "bounds", ")", "{", "this", ".", "upperBounds", "=", "bounds", ";", "}", "public", "void", "setLowerBound", "(", "ClassNode", "bound", ")", "{", "this", ".", "lowerBound", "=", "bound", ";", "}", "}", "</s>" ]
6,906
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "SortedSet", ";", "import", "java", ".", "util", ".", "TreeSet", ";", "public", "class", "ImportNodeCompatibilityWrapper", "{", "private", "class", "ImportNodeComparator", "implements", "Comparator", "<", "ImportNode", ">", "{", "public", "int", "compare", "(", "ImportNode", "i1", ",", "ImportNode", "i2", ")", "{", "int", "start1", "=", "i1", ".", "getStart", "(", ")", ";", "if", "(", "start1", "<=", "0", "&&", "i1", ".", "getType", "(", ")", "!=", "null", ")", "{", "start1", "=", "i1", ".", "getType", "(", ")", ".", "getStart", "(", ")", ";", "}", "int", "start2", "=", "i2", ".", "getStart", "(", ")", ";", "if", "(", "start2", "<=", "0", "&&", "i2", ".", "getType", "(", ")", "!=", "null", ")", "{", "start2", "=", "i2", ".", "getType", "(", ")", ".", "getStart", "(", ")", ";", "}", "return", "start1", "-", "start2", ";", "}", "}", "private", "SortedSet", "<", "ImportNode", ">", "sortedImports", ";", "private", "ModuleNode", "module", ";", "public", "ImportNodeCompatibilityWrapper", "(", "ModuleNode", "module", ")", "{", "if", "(", "module", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "this", ".", "module", "=", "module", ";", "}", "public", "SortedSet", "<", "ImportNode", ">", "getAllImportNodes", "(", ")", "{", "if", "(", "sortedImports", "==", "null", ")", "{", "initialize", "(", ")", ";", "}", "return", "sortedImports", ";", "}", "private", "void", "initialize", "(", ")", "{", "sortedImports", "=", "new", "TreeSet", "<", "ImportNode", ">", "(", "new", "ImportNodeComparator", "(", ")", ")", ";", "sortedImports", ".", "addAll", "(", "module", ".", "getImports", "(", ")", ")", ";", "sortedImports", ".", "addAll", "(", "module", ".", "getStarImports", "(", ")", ")", ";", "sortedImports", ".", "addAll", "(", "module", ".", "getStaticStarImports", "(", ")", ".", "values", "(", ")", ")", ";", "sortedImports", ".", "addAll", "(", "module", ".", "getStaticImports", "(", ")", ".", "values", "(", ")", ")", ";", "}", "public", "static", "String", "getFieldName", "(", "ImportNode", "node", ")", "{", "return", "node", ".", "getFieldName", "(", ")", ";", "}", "public", "static", "Map", "<", "String", ",", "ImportNode", ">", "getStaticImports", "(", "ModuleNode", "node", ")", "{", "return", "node", ".", "getStaticImports", "(", ")", ";", "}", "public", "static", "Map", "<", "String", ",", "ImportNode", ">", "getStaticStarImports", "(", "ModuleNode", "node", ")", "{", "return", "node", ".", "getStaticStarImports", "(", ")", ";", "}", "public", "static", "List", "<", "ImportNode", ">", "getStarImports", "(", "ModuleNode", "node", ")", "{", "return", "node", ".", "getStarImports", "(", ")", ";", "}", "}", "</s>" ]
6,907
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "public", "class", "ASTNodeCompatibilityWrapper", "{", "private", "ASTNodeCompatibilityWrapper", "(", ")", "{", "}", "public", "static", "ClassNode", "getScriptClassDummy", "(", "ModuleNode", "module", ")", "{", "return", "module", ".", "getScriptClassDummy", "(", ")", ";", "}", "public", "static", "Iterator", "<", "InnerClassNode", ">", "getInnerClasses", "(", "ClassNode", "clazz", ")", "{", "return", "clazz", ".", "getInnerClasses", "(", ")", ";", "}", "}", "</s>" ]
6,908
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "public", "class", "TaskEntry", "{", "public", "int", "start", ";", "private", "int", "end", ";", "public", "String", "taskTag", ";", "public", "String", "taskPriority", ";", "public", "TaskEntry", "isAdjacentTo", ";", "private", "String", "commentText", ";", "private", "int", "offsetToStartOfCommentTextInFile", ";", "public", "TaskEntry", "(", "int", "startOffset", ",", "int", "endOffset", ",", "String", "taskTag", ",", "String", "taskPriority", ",", "String", "commentText", ",", "int", "offsetToStartOfCommentTextInFile", ")", "{", "this", ".", "start", "=", "startOffset", ";", "this", ".", "end", "=", "endOffset", ";", "this", ".", "taskTag", "=", "taskTag", ";", "this", ".", "taskPriority", "=", "taskPriority", ";", "this", ".", "commentText", "=", "commentText", ";", "this", ".", "offsetToStartOfCommentTextInFile", "=", "offsetToStartOfCommentTextInFile", ";", "}", "public", "int", "getEnd", "(", ")", "{", "if", "(", "isAdjacentTo", "!=", "null", ")", "{", "return", "isAdjacentTo", ".", "getEnd", "(", ")", ";", "}", "return", "end", ";", "}", "public", "void", "setEnd", "(", "int", "end", ")", "{", "this", ".", "end", "=", "end", ";", "}", "public", "String", "getText", "(", ")", "{", "if", "(", "isAdjacentTo", "!=", "null", ")", "{", "return", "isAdjacentTo", ".", "getText", "(", ")", ";", "}", "else", "{", "int", "commentStartIndex", "=", "start", "-", "offsetToStartOfCommentTextInFile", "+", "taskTag", ".", "length", "(", ")", ";", "int", "commentEndIndex", "=", "end", "-", "offsetToStartOfCommentTextInFile", "+", "1", ";", "return", "commentText", ".", "substring", "(", "commentStartIndex", ",", "commentEndIndex", ")", ".", "trim", "(", ")", ";", "}", "}", "public", "String", "toString", "(", ")", "{", "StringBuffer", "task", "=", "new", "StringBuffer", "(", ")", ";", "task", ".", "append", "(", "\"Task:\"", "+", "taskTag", "+", "\"[\"", "+", "getText", "(", ")", "+", "\"]", "\"", "+", "start", "+", "\"", ">", "\"", "+", "end", "+", "\"(\"", "+", "getEnd", "(", ")", "+", "\")\"", ")", ";", "return", "task", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
6,909
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "GroovyBugError", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "BinaryExpression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "Expression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "FieldExpression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "MapExpression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "TupleExpression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "ExpressionStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "Statement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "BlockStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "CompilePhase", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "ASTTransformation", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "GroovyASTTransformation", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "vmplugin", ".", "VMPluginFactory", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Array", ";", "import", "java", ".", "util", ".", "*", ";", "public", "class", "ClassNode", "extends", "AnnotatedNode", "implements", "Opcodes", "{", "private", "static", "class", "MapOfLists", "{", "private", "Map", "<", "Object", ",", "List", "<", "MethodNode", ">", ">", "map", "=", "new", "HashMap", "<", "Object", ",", "List", "<", "MethodNode", ">", ">", "(", ")", ";", "public", "List", "<", "MethodNode", ">", "get", "(", "Object", "key", ")", "{", "return", "map", ".", "get", "(", "key", ")", ";", "}", "public", "List", "<", "MethodNode", ">", "getNotNull", "(", "Object", "key", ")", "{", "List", "<", "MethodNode", ">", "ret", "=", "get", "(", "key", ")", ";", "if", "(", "ret", "==", "null", ")", "ret", "=", "Collections", ".", "emptyList", "(", ")", ";", "return", "ret", ";", "}", "public", "void", "put", "(", "Object", "key", ",", "MethodNode", "value", ")", "{", "if", "(", "map", ".", "containsKey", "(", "key", ")", ")", "{", "get", "(", "key", ")", ".", "add", "(", "value", ")", ";", "}", "else", "{", "ArrayList", "<", "MethodNode", ">", "list", "=", "new", "ArrayList", "<", "MethodNode", ">", "(", "2", ")", ";", "list", ".", "add", "(", "value", ")", ";", "map", ".", "put", "(", "key", ",", "list", ")", ";", "}", "}", "}", "public", "static", "final", "ClassNode", "[", "]", "EMPTY_ARRAY", "=", "new", "ClassNode", "[", "0", "]", ";", "public", "static", "final", "ClassNode", "THIS", "=", "new", "ClassNode", "(", "Object", ".", "class", ")", ";", "public", "static", "final", "ClassNode", "SUPER", "=", "new", "ClassNode", "(", "Object", ".", "class", ")", ";", "private", "String", "name", ";", "private", "int", "modifiers", ";", "private", "boolean", "syntheticPublic", ";", "private", "ClassNode", "[", "]", "interfaces", ";", "private", "MixinNode", "[", "]", "mixins", ";", "private", "List", "<", "ConstructorNode", ">", "constructors", ";", "private", "List", "<", "Statement", ">", "objectInitializers", ";", "private", "MapOfLists", "methods", ";", "private", "List", "<", "MethodNode", ">", "methodsList", ";", "private", "LinkedList", "<", "FieldNode", ">", "fields", ";", "private", "List", "<", "PropertyNode", ">", "properties", ";", "private", "Map", "<", "String", ",", "FieldNode", ">", "fieldIndex", ";", "private", "ModuleNode", "module", ";", "private", "CompileUnit", "compileUnit", ";", "private", "boolean", "staticClass", "=", "false", ";", "private", "boolean", "scriptBody", "=", "false", ";", "private", "boolean", "script", ";", "private", "ClassNode", "superClass", ";", "protected", "boolean", "isPrimaryNode", ";", "protected", "List", "<", "InnerClassNode", ">", "innerClasses", ";", "private", "int", "bitflags", "=", "0x0000", ";", "private", "static", "final", "int", "BIT_INCONSISTENT_HIERARCHY", "=", "0x0001", ";", "public", "boolean", "hasInconsistentHierarchy", "(", ")", "{", "return", "(", "(", "redirect", "(", ")", ".", "bitflags", ")", "&", "BIT_INCONSISTENT_HIERARCHY", ")", "!=", "0", ";", "}", "public", "void", "setHasInconsistentHierarchy", "(", "boolean", "b", ")", "{", "ClassNode", "redirect", "=", "redirect", "(", ")", ";", "if", "(", "b", ")", "{", "redirect", ".", "bitflags", "|=", "BIT_INCONSISTENT_HIERARCHY", ";", "}", "else", "{", "redirect", ".", "bitflags", "&=", "~", "BIT_INCONSISTENT_HIERARCHY", ";", "}", "}", "private", "Map", "<", "CompilePhase", ",", "Map", "<", "Class", "<", "?", "extends", "ASTTransformation", ">", ",", "Set", "<", "ASTNode", ">", ">", ">", "transformInstances", ";", "protected", "Object", "lazyInitLock", "=", "new", "Object", "(", ")", ";", "protected", "Class", "clazz", ";", "protected", "boolean", "lazyInitDone", "=", "true", ";", "protected", "ClassNode", "componentType", "=", "null", ";", "protected", "ClassNode", "redirect", "=", "null", ";", "private", "boolean", "annotated", ";", "private", "GenericsType", "[", "]", "genericsTypes", "=", "null", ";", "private", "boolean", "usesGenerics", "=", "false", ";", "private", "boolean", "placeholder", ";", "public", "ClassNode", "redirect", "(", ")", "{", "if", "(", "redirect", "==", "null", ")", "return", "this", ";", "return", "redirect", ".", "redirect", "(", ")", ";", "}", "public", "void", "setRedirect", "(", "ClassNode", "cn", ")", "{", "if", "(", "isPrimaryNode", ")", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "getName", "(", ")", "+", "\"->\"", "+", "cn", ".", "getName", "(", ")", "+", "\").\"", ")", ";", "if", "(", "cn", "!=", "null", ")", "cn", "=", "cn", ".", "redirect", "(", ")", ";", "if", "(", "cn", "==", "this", ")", "return", ";", "redirect", "=", "cn", ";", "}", "public", "ClassNode", "makeArray", "(", ")", "{", "if", "(", "redirect", "!=", "null", ")", "{", "ClassNode", "res", "=", "redirect", "(", ")", ".", "makeArray", "(", ")", ";", "res", ".", "componentType", "=", "this", ";", "return", "res", ";", "}", "ClassNode", "cn", ";", "if", "(", "clazz", "!=", "null", ")", "{", "Class", "ret", "=", "Array", ".", "newInstance", "(", "clazz", ",", "0", ")", ".", "getClass", "(", ")", ";", "cn", "=", "new", "ClassNode", "(", "ret", ",", "this", ")", ";", "}", "else", "{", "cn", "=", "new", "ClassNode", "(", "this", ")", ";", "}", "return", "cn", ";", "}", "public", "boolean", "isPrimaryClassNode", "(", ")", "{", "return", "redirect", "(", ")", ".", "isPrimaryNode", "||", "(", "componentType", "!=", "null", "&&", "componentType", ".", "isPrimaryClassNode", "(", ")", ")", ";", "}", "public", "ClassNode", "(", "ClassNode", "componentType", ")", "{", "this", "(", "computeArrayName", "(", "componentType", ")", ",", "ACC_PUBLIC", ",", "ClassHelper", ".", "OBJECT_TYPE", ")", ";", "this", ".", "componentType", "=", "componentType", ".", "redirect", "(", ")", ";", "isPrimaryNode", "=", "false", ";", "}", "public", "static", "String", "computeArrayName", "(", "ClassNode", "componentType", ")", "{", "String", "n", "=", "componentType", ".", "getName", "(", ")", ";", "if", "(", "componentType", ".", "isPrimitive", "(", ")", ")", "{", "int", "len", "=", "n", ".", "length", "(", ")", ";", "if", "(", "len", "==", "7", ")", "{", "return", "\"[Z\"", ";", "}", "else", "if", "(", "len", "==", "6", ")", "{", "return", "\"[D\"", ";", "}", "else", "if", "(", "len", "==", "5", ")", "{", "if", "(", "n", ".", "charAt", "(", "0", ")", "==", "'f'", ")", "{", "return", "\"[F\"", ";", "}", "else", "{", "return", "\"[S\"", ";", "}", "}", "else", "if", "(", "len", "==", "4", ")", "{", "switch", "(", "n", ".", "charAt", "(", "0", ")", ")", "{", "case", "'b'", ":", "return", "\"[B\"", ";", "case", "'c'", ":", "return", "\"[C\"", ";", "default", ":", "return", "\"[J\"", ";", "}", "}", "else", "{", "return", "\"[I\"", ";", "}", "}", "else", "if", "(", "componentType", ".", "isArray", "(", ")", ")", "{", "if", "(", "n", ".", "charAt", "(", "0", ")", "==", "'['", ")", "{", "return", "new", "StringBuilder", "(", "\"[\"", ")", ".", "append", "(", "n", ")", ".", "toString", "(", ")", ";", "}", "else", "{", "return", "new", "StringBuilder", "(", "n", ")", ".", "append", "(", "\"[]\"", ")", ".", "toString", "(", ")", ";", "}", "}", "else", "{", "return", "new", "StringBuilder", "(", "\"[L\"", ")", ".", "append", "(", "componentType", ".", "getName", "(", ")", ")", ".", "append", "(", "\";\"", ")", ".", "toString", "(", ")", ";", "}", "}", "public", "ClassNode", "(", "Class", "c", ",", "ClassNode", "componentType", ")", "{", "this", "(", "c", ")", ";", "this", ".", "componentType", "=", "componentType", ";", "isPrimaryNode", "=", "false", ";", "}", "public", "ClassNode", "(", "Class", "c", ")", "{", "this", "(", "c", ".", "getName", "(", ")", ",", "c", ".", "getModifiers", "(", ")", ",", "null", ",", "null", ",", "MixinNode", ".", "EMPTY_ARRAY", ")", ";", "clazz", "=", "c", ";", "lazyInitDone", "=", "false", ";", "CompileUnit", "cu", "=", "getCompileUnit", "(", ")", ";", "if", "(", "cu", "!=", "null", ")", "cu", ".", "addClass", "(", "this", ")", ";", "isPrimaryNode", "=", "false", ";", "}", "public", "void", "lazyClassInit", "(", ")", "{", "synchronized", "(", "lazyInitLock", ")", "{", "if", "(", "redirect", "!=", "null", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "\"\"", ")", ";", "}", "if", "(", "lazyInitDone", ")", "return", ";", "VMPluginFactory", ".", "getPlugin", "(", ")", ".", "configureClassNode", "(", "compileUnit", ",", "this", ")", ";", "lazyInitDone", "=", "true", ";", "}", "}", "private", "MethodNode", "enclosingMethod", "=", "null", ";", "public", "MethodNode", "getEnclosingMethod", "(", ")", "{", "return", "redirect", "(", ")", ".", "enclosingMethod", ";", "}", "public", "void", "setEnclosingMethod", "(", "MethodNode", "enclosingMethod", ")", "{", "redirect", "(", ")", ".", "enclosingMethod", "=", "enclosingMethod", ";", "}", "public", "boolean", "isSyntheticPublic", "(", ")", "{", "return", "syntheticPublic", ";", "}", "public", "void", "setSyntheticPublic", "(", "boolean", "syntheticPublic", ")", "{", "this", ".", "syntheticPublic", "=", "syntheticPublic", ";", "}", "public", "ClassNode", "(", "String", "name", ",", "int", "modifiers", ",", "ClassNode", "superClass", ")", "{", "this", "(", "name", ",", "modifiers", ",", "superClass", ",", "EMPTY_ARRAY", ",", "MixinNode", ".", "EMPTY_ARRAY", ")", ";", "}", "public", "ClassNode", "(", "String", "name", ",", "int", "modifiers", ",", "ClassNode", "superClass", ",", "ClassNode", "[", "]", "interfaces", ",", "MixinNode", "[", "]", "mixins", ")", "{", "this", ".", "name", "=", "name", ";", "this", ".", "modifiers", "=", "modifiers", ";", "this", ".", "superClass", "=", "superClass", ";", "this", ".", "interfaces", "=", "interfaces", ";", "this", ".", "mixins", "=", "mixins", ";", "isPrimaryNode", "=", "true", ";", "if", "(", "superClass", "!=", "null", ")", "{", "usesGenerics", "=", "superClass", ".", "isUsingGenerics", "(", ")", ";", "}", "if", "(", "!", "usesGenerics", "&&", "interfaces", "!=", "null", ")", "{", "for", "(", "ClassNode", "anInterface", ":", "interfaces", ")", "{", "usesGenerics", "=", "usesGenerics", "||", "anInterface", ".", "isUsingGenerics", "(", ")", ";", "}", "}", "this", ".", "methods", "=", "new", "MapOfLists", "(", ")", ";", "this", ".", "methodsList", "=", "new", "ArrayList", "<", "MethodNode", ">", "(", ")", ";", "}", "public", "void", "setSuperClass", "(", "ClassNode", "superClass", ")", "{", "redirect", "(", ")", ".", "superClass", "=", "superClass", ";", "}", "public", "List", "<", "FieldNode", ">", "getFields", "(", ")", "{", "if", "(", "!", "redirect", "(", ")", ".", "lazyInitDone", ")", "redirect", "(", ")", ".", "lazyClassInit", "(", ")", ";", "if", "(", "redirect", "!=", "null", ")", "return", "redirect", "(", ")", ".", "getFields", "(", ")", ";", "if", "(", "fields", "==", "null", ")", "fields", "=", "new", "LinkedList", "<", "FieldNode", ">", "(", ")", ";", "return", "fields", ";", "}", "public", "ClassNode", "[", "]", "getInterfaces", "(", ")", "{", "if", "(", "!", "redirect", "(", ")", ".", "lazyInitDone", ")", "redirect", "(", ")", ".", "lazyClassInit", "(", ")", ";", "if", "(", "hasInconsistentHierarchy", "(", ")", ")", "{", "return", "EMPTY_ARRAY", ";", "}", "if", "(", "redirect", "!=", "null", ")", "return", "redirect", "(", ")", ".", "getInterfaces", "(", ")", ";", "return", "interfaces", ";", "}", "public", "void", "setInterfaces", "(", "ClassNode", "[", "]", "interfaces", ")", "{", "if", "(", "redirect", "!=", "null", ")", "{", "redirect", "(", ")", ".", "setInterfaces", "(", "interfaces", ")", ";", "}", "else", "{", "this", ".", "interfaces", "=", "interfaces", ";", "}", "}", "public", "MixinNode", "[", "]", "getMixins", "(", ")", "{", "return", "redirect", "(", ")", ".", "mixins", ";", "}", "public", "List", "<", "MethodNode", ">", "getMethods", "(", ")", "{", "if", "(", "!", "redirect", "(", ")", ".", "lazyInitDone", ")", "redirect", "(", ")", ".", "lazyClassInit", "(", ")", ";", "if", "(", "redirect", "!=", "null", ")", "return", "redirect", "(", ")", ".", "getMethods", "(", ")", ";", "return", "methodsList", ";", "}", "public", "List", "<", "MethodNode", ">", "getAbstractMethods", "(", ")", "{", "List", "<", "MethodNode", ">", "result", "=", "new", "ArrayList", "<", "MethodNode", ">", "(", "3", ")", ";", "for", "(", "MethodNode", "method", ":", "getDeclaredMethodsMap", "(", ")", ".", "values", "(", ")", ")", "{", "if", "(", "method", ".", "isAbstract", "(", ")", ")", "{", "result", ".", "add", "(", "method", ")", ";", "}", "}", "if", "(", "result", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "else", "{", "return", "result", ";", "}", "}", "public", "List", "<", "MethodNode", ">", "getAllDeclaredMethods", "(", ")", "{", "return", "new", "ArrayList", "<", "MethodNode", ">", "(", "getDeclaredMethodsMap", "(", ")", ".", "values", "(", ")", ")", ";", "}", "public", "Set", "<", "ClassNode", ">", "getAllInterfaces", "(", ")", "{", "Set", "<", "ClassNode", ">", "res", "=", "new", "HashSet", "<", "ClassNode", ">", "(", ")", ";", "getAllInterfaces", "(", "res", ")", ";", "return", "res", ";", "}", "private", "void", "getAllInterfaces", "(", "Set", "<", "ClassNode", ">", "res", ")", "{", "if", "(", "isInterface", "(", ")", ")", "res", ".", "add", "(", "this", ")", ";", "for", "(", "ClassNode", "anInterface", ":", "getInterfaces", "(", ")", ")", "{", "res", ".", "add", "(", "anInterface", ")", ";", "anInterface", ".", "getAllInterfaces", "(", "res", ")", ";", "}", "}", "public", "Map", "<", "String", ",", "MethodNode", ">", "getDeclaredMethodsMap", "(", ")", "{", "ClassNode", "parent", "=", "getSuperClass", "(", ")", ";", "Map", "<", "String", ",", "MethodNode", ">", "result", "=", "null", ";", "if", "(", "parent", "!=", "null", ")", "{", "result", "=", "parent", ".", "getDeclaredMethodsMap", "(", ")", ";", "}", "else", "{", "result", "=", "new", "HashMap", "<", "String", ",", "MethodNode", ">", "(", ")", ";", "}", "for", "(", "ClassNode", "iface", ":", "getInterfaces", "(", ")", ")", "{", "Map", "<", "String", ",", "MethodNode", ">", "ifaceMethodsMap", "=", "iface", ".", "getDeclaredMethodsMap", "(", ")", ";", "for", "(", "String", "methSig", ":", "ifaceMethodsMap", ".", "keySet", "(", ")", ")", "{", "if", "(", "!", "result", ".", "containsKey", "(", "methSig", ")", ")", "{", "MethodNode", "methNode", "=", "ifaceMethodsMap", ".", "get", "(", "methSig", ")", ";", "result", ".", "put", "(", "methSig", ",", "methNode", ")", ";", "}", "}", "}", "for", "(", "MethodNode", "method", ":", "getMethods", "(", ")", ")", "{", "String", "sig", "=", "method", ".", "getTypeDescriptor", "(", ")", ";", "result", ".", "put", "(", "sig", ",", "method", ")", ";", "}", "return", "result", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "redirect", "(", ")", ".", "name", ";", "}", "public", "String", "getUnresolvedName", "(", ")", "{", "return", "name", ";", "}", "public", "String", "setName", "(", "String", "name", ")", "{", "return", "redirect", "(", ")", ".", "name", "=", "name", ";", "}", "public", "int", "getModifiers", "(", ")", "{", "return", "redirect", "(", ")", ".", "modifiers", ";", "}", "public", "void", "setModifiers", "(", "int", "modifiers", ")", "{", "redirect", "(", ")", ".", "modifiers", "=", "modifiers", ";", "}", "protected", "void", "ensurePropertiesInitialized", "(", ")", "{", "}", "public", "List", "<", "PropertyNode", ">", "getProperties", "(", ")", "{", "redirect", "(", ")", ".", "ensurePropertiesInitialized", "(", ")", ";", "final", "ClassNode", "r", "=", "redirect", "(", ")", ";", "if", "(", "r", ".", "properties", "==", "null", ")", "r", ".", "properties", "=", "new", "ArrayList", "<", "PropertyNode", ">", "(", ")", ";", "return", "r", ".", "properties", ";", "}", "public", "List", "<", "ConstructorNode", ">", "getDeclaredConstructors", "(", ")", "{", "if", "(", "!", "redirect", "(", ")", ".", "lazyInitDone", ")", "redirect", "(", ")", ".", "lazyClassInit", "(", ")", ";", "final", "ClassNode", "r", "=", "redirect", "(", ")", ";", "if", "(", "r", ".", "constructors", "==", "null", ")", "r", ".", "constructors", "=", "new", "ArrayList", "<", "ConstructorNode", ">", "(", ")", ";", "return", "r", ".", "constructors", ";", "}", "public", "ModuleNode", "getModule", "(", ")", "{", "return", "redirect", "(", ")", ".", "module", ";", "}", "public", "PackageNode", "getPackage", "(", ")", "{", "return", "getModule", "(", ")", "==", "null", "?", "null", ":", "getModule", "(", ")", ".", "getPackage", "(", ")", ";", "}", "public", "void", "setModule", "(", "ModuleNode", "module", ")", "{", "redirect", "(", ")", ".", "module", "=", "module", ";", "if", "(", "module", "!=", "null", ")", "{", "redirect", "(", ")", ".", "compileUnit", "=", "module", ".", "getUnit", "(", ")", ";", "}", "}", "public", "void", "addField", "(", "FieldNode", "node", ")", "{", "final", "ClassNode", "r", "=", "redirect", "(", ")", ";", "node", ".", "setDeclaringClass", "(", "r", ")", ";", "node", ".", "setOwner", "(", "r", ")", ";", "if", "(", "r", ".", "fields", "==", "null", ")", "r", ".", "fields", "=", "new", "LinkedList", "<", "FieldNode", ">", "(", ")", ";", "if", "(", "r", ".", "fieldIndex", "==", "null", ")", "r", ".", "fieldIndex", "=", "new", "HashMap", "<", "String", ",", "FieldNode", ">", "(", ")", ";", "r", ".", "fields", ".", "add", "(", "node", ")", ";", "r", ".", "fieldIndex", ".", "put", "(", "node", ".", "getName", "(", ")", ",", "node", ")", ";", "}", "public", "void", "addFieldFirst", "(", "FieldNode", "node", ")", "{", "final", "ClassNode", "r", "=", "redirect", "(", ")", ";", "node", ".", "setDeclaringClass", "(", "r", ")", ";", "node", ".", "setOwner", "(", "r", ")", ";", "if", "(", "r", ".", "fields", "==", "null", ")", "r", ".", "fields", "=", "new", "LinkedList", "<", "FieldNode", ">", "(", ")", ";", "if", "(", "r", ".", "fieldIndex", "==", "null", ")", "r", ".", "fieldIndex", "=", "new", "HashMap", "<", "String", ",", "FieldNode", ">", "(", ")", ";", "r", ".", "fields", ".", "addFirst", "(", "node", ")", ";", "r", ".", "fieldIndex", ".", "put", "(", "node", ".", "getName", "(", ")", ",", "node", ")", ";", "}", "public", "void", "addPropertyWithoutField", "(", "PropertyNode", "node", ")", "{", "node", ".", "setDeclaringClass", "(", "redirect", "(", ")", ")", ";", "final", "ClassNode", "r", "=", "redirect", "(", ")", ";", "if", "(", "r", ".", "properties", "==", "null", ")", "r", ".", "properties", "=", "new", "ArrayList", "<", "PropertyNode", ">", "(", ")", ";", "r", ".", "properties", ".", "add", "(", "node", ")", ";", "}", "public", "void", "addProperty", "(", "PropertyNode", "node", ")", "{", "node", ".", "setDeclaringClass", "(", "redirect", "(", ")", ")", ";", "FieldNode", "field", "=", "node", ".", "getField", "(", ")", ";", "addField", "(", "field", ")", ";", "final", "ClassNode", "r", "=", "redirect", "(", ")", ";", "if", "(", "r", ".", "properties", "==", "null", ")", "r", ".", "properties", "=", "new", "ArrayList", "<", "PropertyNode", ">", "(", ")", ";", "r", ".", "properties", ".", "add", "(", "node", ")", ";", "}", "public", "PropertyNode", "addProperty", "(", "String", "name", ",", "int", "modifiers", ",", "ClassNode", "type", ",", "Expression", "initialValueExpression", ",", "Statement", "getterBlock", ",", "Statement", "setterBlock", ")", "{", "for", "(", "PropertyNode", "pn", ":", "getProperties", "(", ")", ")", "{", "if", "(", "pn", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "if", "(", "pn", ".", "getInitialExpression", "(", ")", "==", "null", "&&", "initialValueExpression", "!=", "null", ")", "pn", ".", "getField", "(", ")", ".", "setInitialValueExpression", "(", "initialValueExpression", ")", ";", "if", "(", "pn", ".", "getGetterBlock", "(", ")", "==", "null", "&&", "getterBlock", "!=", "null", ")", "pn", ".", "setGetterBlock", "(", "getterBlock", ")", ";", "if", "(", "pn", ".", "getSetterBlock", "(", ")", "==", "null", "&&", "setterBlock", "!=", "null", ")", "pn", ".", "setSetterBlock", "(", "setterBlock", ")", ";", "return", "pn", ";", "}", "}", "PropertyNode", "node", "=", "new", "PropertyNode", "(", "name", ",", "modifiers", ",", "type", ",", "redirect", "(", ")", ",", "initialValueExpression", ",", "getterBlock", ",", "setterBlock", ")", ";", "addProperty", "(", "node", ")", ";", "return", "node", ";", "}", "public", "boolean", "hasProperty", "(", "String", "name", ")", "{", "return", "getProperty", "(", "name", ")", "!=", "null", ";", "}", "public", "PropertyNode", "getProperty", "(", "String", "name", ")", "{", "try", "{", "for", "(", "PropertyNode", "pn", ":", "getProperties", "(", ")", ")", "{", "String", "pname", "=", "pn", ".", "getName", "(", ")", ";", "if", "(", "pname", ".", "equals", "(", "name", ")", ")", "return", "pn", ";", "}", "}", "catch", "(", "NullPointerException", "npe", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", "+", "this", ".", "getName", "(", ")", "+", "\"", "props", "are", "\"", "+", "getProperties", "(", ")", ",", "npe", ")", ";", "}", "return", "null", ";", "}", "public", "void", "addConstructor", "(", "ConstructorNode", "node", ")", "{", "node", ".", "setDeclaringClass", "(", "this", ")", ";", "final", "ClassNode", "r", "=", "redirect", "(", ")", ";", "if", "(", "r", ".", "constructors", "==", "null", ")", "r", ".", "constructors", "=", "new", "ArrayList", "<", "ConstructorNode", ">", "(", ")", ";", "r", ".", "constructors", ".", "add", "(", "node", ")", ";", "}", "public", "ConstructorNode", "addConstructor", "(", "int", "modifiers", ",", "Parameter", "[", "]", "parameters", ",", "ClassNode", "[", "]", "exceptions", ",", "Statement", "code", ")", "{", "ConstructorNode", "node", "=", "new", "ConstructorNode", "(", "modifiers", ",", "parameters", ",", "exceptions", ",", "code", ")", ";", "addConstructor", "(", "node", ")", ";", "return", "node", ";", "}", "public", "void", "addMethod", "(", "MethodNode", "node", ")", "{", "node", ".", "setDeclaringClass", "(", "this", ")", ";", "ClassNode", "redirect", "=", "redirect", "(", ")", ";", "redirect", ".", "methodsList", ".", "add", "(", "node", ")", ";", "redirect", ".", "methods", ".", "put", "(", "node", ".", "getName", "(", ")", ",", "node", ")", ";", "}", "public", "MethodNode", "addMethod", "(", "String", "name", ",", "int", "modifiers", ",", "ClassNode", "returnType", ",", "Parameter", "[", "]", "parameters", ",", "ClassNode", "[", "]", "exceptions", ",", "Statement", "code", ")", "{", "MethodNode", "other", "=", "getDeclaredMethod", "(", "name", ",", "parameters", ")", ";", "if", "(", "other", "!=", "null", ")", "{", "return", "other", ";", "}", "MethodNode", "node", "=", "new", "MethodNode", "(", "name", ",", "modifiers", ",", "returnType", ",", "parameters", ",", "exceptions", ",", "code", ")", ";", "addMethod", "(", "node", ")", ";", "return", "node", ";", "}", "public", "boolean", "hasDeclaredMethod", "(", "String", "name", ",", "Parameter", "[", "]", "parameters", ")", "{", "MethodNode", "other", "=", "getDeclaredMethod", "(", "name", ",", "parameters", ")", ";", "return", "other", "!=", "null", ";", "}", "public", "boolean", "hasMethod", "(", "String", "name", ",", "Parameter", "[", "]", "parameters", ")", "{", "MethodNode", "other", "=", "getMethod", "(", "name", ",", "parameters", ")", ";", "return", "other", "!=", "null", ";", "}", "public", "MethodNode", "addSyntheticMethod", "(", "String", "name", ",", "int", "modifiers", ",", "ClassNode", "returnType", ",", "Parameter", "[", "]", "parameters", ",", "ClassNode", "[", "]", "exceptions", ",", "Statement", "code", ")", "{", "MethodNode", "answer", "=", "addMethod", "(", "name", ",", "modifiers", "|", "ACC_SYNTHETIC", ",", "returnType", ",", "parameters", ",", "exceptions", ",", "code", ")", ";", "answer", ".", "setSynthetic", "(", "true", ")", ";", "return", "answer", ";", "}", "public", "FieldNode", "addField", "(", "String", "name", ",", "int", "modifiers", ",", "ClassNode", "type", ",", "Expression", "initialValue", ")", "{", "FieldNode", "node", "=", "new", "FieldNode", "(", "name", ",", "modifiers", ",", "type", ",", "redirect", "(", ")", ",", "initialValue", ")", ";", "addField", "(", "node", ")", ";", "return", "node", ";", "}", "public", "FieldNode", "addFieldFirst", "(", "String", "name", ",", "int", "modifiers", ",", "ClassNode", "type", ",", "Expression", "initialValue", ")", "{", "FieldNode", "node", "=", "new", "FieldNode", "(", "name", ",", "modifiers", ",", "type", ",", "redirect", "(", ")", ",", "initialValue", ")", ";", "addFieldFirst", "(", "node", ")", ";", "return", "node", ";", "}", "public", "void", "addInterface", "(", "ClassNode", "type", ")", "{", "boolean", "skip", "=", "false", ";", "ClassNode", "[", "]", "interfaces", "=", "redirect", "(", ")", ".", "interfaces", ";", "for", "(", "ClassNode", "existing", ":", "interfaces", ")", "{", "if", "(", "type", ".", "equals", "(", "existing", ")", ")", "{", "skip", "=", "true", ";", "}", "}", "if", "(", "!", "skip", ")", "{", "ClassNode", "[", "]", "newInterfaces", "=", "new", "ClassNode", "[", "interfaces", ".", "length", "+", "1", "]", ";", "System", ".", "arraycopy", "(", "interfaces", ",", "0", ",", "newInterfaces", ",", "0", ",", "interfaces", ".", "length", ")", ";", "newInterfaces", "[", "interfaces", ".", "length", "]", "=", "type", ";", "redirect", "(", ")", ".", "interfaces", "=", "newInterfaces", ";", "}", "}", "public", "boolean", "equals", "(", "Object", "o", ")", "{", "if", "(", "o", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "redirect", "!=", "null", ")", "return", "redirect", "(", ")", ".", "equals", "(", "o", ")", ";", "if", "(", "!", "(", "o", "instanceof", "ClassNode", ")", ")", "return", "false", ";", "ClassNode", "cn", "=", "(", "ClassNode", ")", "o", ";", "return", "(", "cn", ".", "getText", "(", ")", ".", "equals", "(", "getText", "(", ")", ")", ")", ";", "}", "public", "int", "hashCode", "(", ")", "{", "if", "(", "redirect", "!=", "null", ")", "return", "redirect", "(", ")", ".", "hashCode", "(", ")", ";", "return", "getName", "(", ")", ".", "hashCode", "(", ")", ";", "}", "public", "void", "addMixin", "(", "MixinNode", "mixin", ")", "{", "MixinNode", "[", "]", "mixins", "=", "redirect", "(", ")", ".", "mixins", ";", "boolean", "skip", "=", "false", ";", "for", "(", "MixinNode", "existing", ":", "mixins", ")", "{", "if", "(", "mixin", ".", "equals", "(", "existing", ")", ")", "{", "skip", "=", "true", ";", "}", "}", "if", "(", "!", "skip", ")", "{", "MixinNode", "[", "]", "newMixins", "=", "new", "MixinNode", "[", "mixins", ".", "length", "+", "1", "]", ";", "System", ".", "arraycopy", "(", "mixins", ",", "0", ",", "newMixins", ",", "0", ",", "mixins", ".", "length", ")", ";", "newMixins", "[", "mixins", ".", "length", "]", "=", "mixin", ";", "redirect", "(", ")", ".", "mixins", "=", "newMixins", ";", "}", "}", "public", "FieldNode", "getDeclaredField", "(", "String", "name", ")", "{", "if", "(", "!", "redirect", "(", ")", ".", "lazyInitDone", ")", "redirect", "(", ")", ".", "lazyClassInit", "(", ")", ";", "ClassNode", "r", "=", "redirect", "(", ")", ";", "if", "(", "r", ".", "fieldIndex", "==", "null", ")", "r", ".", "fieldIndex", "=", "new", "HashMap", "<", "String", ",", "FieldNode", ">", "(", ")", ";", "return", "r", ".", "fieldIndex", ".", "get", "(", "name", ")", ";", "}", "public", "FieldNode", "getField", "(", "String", "name", ")", "{", "ClassNode", "node", "=", "this", ";", "while", "(", "node", "!=", "null", ")", "{", "FieldNode", "fn", "=", "node", ".", "getDeclaredField", "(", "name", ")", ";", "if", "(", "fn", "!=", "null", ")", "return", "fn", ";", "node", "=", "node", ".", "getSuperClass", "(", ")", ";", "}", "return", "null", ";", "}", "public", "FieldNode", "getOuterField", "(", "String", "name", ")", "{", "return", "null", ";", "}", "public", "ClassNode", "getOuterClass", "(", ")", "{", "return", "null", ";", "}", "public", "void", "addObjectInitializerStatements", "(", "Statement", "statements", ")", "{", "getObjectInitializerStatements", "(", ")", ".", "add", "(", "statements", ")", ";", "}", "public", "List", "<", "Statement", ">", "getObjectInitializerStatements", "(", ")", "{", "if", "(", "objectInitializers", "==", "null", ")", "objectInitializers", "=", "new", "ArrayList", "<", "Statement", ">", "(", ")", ";", "return", "objectInitializers", ";", "}", "private", "MethodNode", "getOrAddStaticConstructorNode", "(", ")", "{", "MethodNode", "method", "=", "null", ";", "List", "declaredMethods", "=", "getDeclaredMethods", "(", "\"<clinit>\"", ")", ";", "if", "(", "declaredMethods", ".", "isEmpty", "(", ")", ")", "{", "method", "=", "addMethod", "(", "\"<clinit>\"", ",", "ACC_STATIC", ",", "ClassHelper", ".", "VOID_TYPE", ",", "Parameter", ".", "EMPTY_ARRAY", ",", "ClassNode", ".", "EMPTY_ARRAY", ",", "new", "BlockStatement", "(", ")", ")", ";", "method", ".", "setSynthetic", "(", "true", ")", ";", "}", "else", "{", "method", "=", "(", "MethodNode", ")", "declaredMethods", ".", "get", "(", "0", ")", ";", "}", "return", "method", ";", "}", "public", "void", "addStaticInitializerStatements", "(", "List", "<", "Statement", ">", "staticStatements", ",", "boolean", "fieldInit", ")", "{", "MethodNode", "method", "=", "getOrAddStaticConstructorNode", "(", ")", ";", "BlockStatement", "block", "=", "null", ";", "Statement", "statement", "=", "method", ".", "getCode", "(", ")", ";", "if", "(", "statement", "==", "null", ")", "{", "block", "=", "new", "BlockStatement", "(", ")", ";", "}", "else", "if", "(", "statement", "instanceof", "BlockStatement", ")", "{", "block", "=", "(", "BlockStatement", ")", "statement", ";", "}", "else", "{", "block", "=", "new", "BlockStatement", "(", ")", ";", "block", ".", "addStatement", "(", "statement", ")", ";", "}", "if", "(", "!", "fieldInit", ")", "{", "block", ".", "addStatements", "(", "staticStatements", ")", ";", "}", "else", "{", "List", "<", "Statement", ">", "blockStatements", "=", "block", ".", "getStatements", "(", ")", ";", "staticStatements", ".", "addAll", "(", "blockStatements", ")", ";", "blockStatements", ".", "clear", "(", ")", ";", "blockStatements", ".", "addAll", "(", "staticStatements", ")", ";", "}", "}", "public", "void", "positionStmtsAfterEnumInitStmts", "(", "List", "<", "Statement", ">", "staticFieldStatements", ")", "{", "MethodNode", "method", "=", "getOrAddStaticConstructorNode", "(", ")", ";", "Statement", "statement", "=", "method", ".", "getCode", "(", ")", ";", "if", "(", "statement", "instanceof", "BlockStatement", ")", "{", "BlockStatement", "block", "=", "(", "BlockStatement", ")", "statement", ";", "List", "<", "Statement", ">", "blockStatements", "=", "block", ".", "getStatements", "(", ")", ";", "ListIterator", "<", "Statement", ">", "litr", "=", "blockStatements", ".", "listIterator", "(", ")", ";", "while", "(", "litr", ".", "hasNext", "(", ")", ")", "{", "Statement", "stmt", "=", "litr", ".", "next", "(", ")", ";", "if", "(", "stmt", "instanceof", "ExpressionStatement", "&&", "(", "(", "ExpressionStatement", ")", "stmt", ")", ".", "getExpression", "(", ")", "instanceof", "BinaryExpression", ")", "{", "BinaryExpression", "bExp", "=", "(", "BinaryExpression", ")", "(", "(", "ExpressionStatement", ")", "stmt", ")", ".", "getExpression", "(", ")", ";", "if", "(", "bExp", ".", "getLeftExpression", "(", ")", "instanceof", "FieldExpression", ")", "{", "FieldExpression", "fExp", "=", "(", "FieldExpression", ")", "bExp", ".", "getLeftExpression", "(", ")", ";", "if", "(", "fExp", ".", "getFieldName", "(", ")", ".", "equals", "(", "\"$VALUES\"", ")", ")", "{", "for", "(", "Statement", "tmpStmt", ":", "staticFieldStatements", ")", "{", "litr", ".", "add", "(", "tmpStmt", ")", ";", "}", "}", "}", "}", "}", "}", "}", "public", "List", "<", "MethodNode", ">", "getDeclaredMethods", "(", "String", "name", ")", "{", "if", "(", "!", "redirect", "(", ")", ".", "lazyInitDone", ")", "redirect", "(", ")", ".", "lazyClassInit", "(", ")", ";", "if", "(", "redirect", "!=", "null", ")", "return", "redirect", "(", ")", ".", "getDeclaredMethods", "(", "name", ")", ";", "return", "methods", ".", "getNotNull", "(", "name", ")", ";", "}", "public", "List", "<", "MethodNode", ">", "getMethods", "(", "String", "name", ")", "{", "List", "<", "MethodNode", ">", "answer", "=", "new", "ArrayList", "<", "MethodNode", ">", "(", ")", ";", "ClassNode", "node", "=", "this", ";", "while", "(", "node", "!=", "null", ")", "{", "answer", ".", "addAll", "(", "node", ".", "getDeclaredMethods", "(", "name", ")", ")", ";", "node", "=", "node", ".", "getSuperClass", "(", ")", ";", "}", "return", "answer", ";", "}", "public", "MethodNode", "getDeclaredMethod", "(", "String", "name", ",", "Parameter", "[", "]", "parameters", ")", "{", "for", "(", "MethodNode", "method", ":", "getDeclaredMethods", "(", "name", ")", ")", "{", "if", "(", "parametersEqual", "(", "method", ".", "getParameters", "(", ")", ",", "parameters", ")", ")", "{", "return", "method", ";", "}", "}", "return", "null", ";", "}", "public", "MethodNode", "getMethod", "(", "String", "name", ",", "Parameter", "[", "]", "parameters", ")", "{", "for", "(", "MethodNode", "method", ":", "getMethods", "(", "name", ")", ")", "{", "if", "(", "parametersEqual", "(", "method", ".", "getParameters", "(", ")", ",", "parameters", ")", ")", "{", "return", "method", ";", "}", "}", "return", "null", ";", "}", "public", "boolean", "isDerivedFrom", "(", "ClassNode", "type", ")", "{", "if", "(", "this", ".", "equals", "(", "ClassHelper", ".", "VOID_TYPE", ")", ")", "{", "return", "type", ".", "equals", "(", "ClassHelper", ".", "VOID_TYPE", ")", ";", "}", "if", "(", "type", ".", "equals", "(", "ClassHelper", ".", "OBJECT_TYPE", ")", ")", "return", "true", ";", "ClassNode", "node", "=", "this", ";", "while", "(", "node", "!=", "null", ")", "{", "if", "(", "type", ".", "equals", "(", "node", ")", ")", "{", "return", "true", ";", "}", "node", "=", "node", ".", "getSuperClass", "(", ")", ";", "}", "return", "false", ";", "}", "public", "boolean", "isDerivedFromGroovyObject", "(", ")", "{", "return", "implementsInterface", "(", "ClassHelper", ".", "GROOVY_OBJECT_TYPE", ")", ";", "}", "public", "boolean", "implementsInterface", "(", "ClassNode", "classNode", ")", "{", "ClassNode", "node", "=", "redirect", "(", ")", ";", "do", "{", "if", "(", "node", ".", "declaresInterface", "(", "classNode", ")", ")", "{", "return", "true", ";", "}", "node", "=", "node", ".", "getSuperClass", "(", ")", ";", "}", "while", "(", "node", "!=", "null", ")", ";", "return", "false", ";", "}", "public", "boolean", "declaresInterface", "(", "ClassNode", "classNode", ")", "{", "ClassNode", "[", "]", "interfaces", "=", "redirect", "(", ")", ".", "getInterfaces", "(", ")", ";", "for", "(", "ClassNode", "cn", ":", "interfaces", ")", "{", "if", "(", "cn", ".", "equals", "(", "classNode", ")", ")", "return", "true", ";", "}", "for", "(", "ClassNode", "cn", ":", "interfaces", ")", "{", "if", "(", "cn", ".", "declaresInterface", "(", "classNode", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}", "public", "ClassNode", "getSuperClass", "(", ")", "{", "if", "(", "!", "lazyInitDone", "&&", "!", "isResolved", "(", ")", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "getName", "(", ")", "+", "\"\"", ")", ";", "}", "if", "(", "hasInconsistentHierarchy", "(", ")", ")", "{", "return", "ClassHelper", ".", "OBJECT_TYPE", ";", "}", "ClassNode", "sn", "=", "redirect", "(", ")", ".", "getUnresolvedSuperClass", "(", ")", ";", "if", "(", "sn", "!=", "null", ")", "sn", "=", "sn", ".", "redirect", "(", ")", ";", "return", "sn", ";", "}", "public", "ClassNode", "getUnresolvedSuperClass", "(", ")", "{", "return", "getUnresolvedSuperClass", "(", "true", ")", ";", "}", "public", "ClassNode", "getUnresolvedSuperClass", "(", "boolean", "useRedirect", ")", "{", "if", "(", "hasInconsistentHierarchy", "(", ")", ")", "{", "return", "ClassHelper", ".", "OBJECT_TYPE", ";", "}", "if", "(", "!", "useRedirect", ")", "return", "superClass", ";", "if", "(", "!", "redirect", "(", ")", ".", "lazyInitDone", ")", "redirect", "(", ")", ".", "lazyClassInit", "(", ")", ";", "return", "redirect", "(", ")", ".", "superClass", ";", "}", "public", "void", "setUnresolvedSuperClass", "(", "ClassNode", "sn", ")", "{", "superClass", "=", "sn", ";", "}", "public", "ClassNode", "[", "]", "getUnresolvedInterfaces", "(", ")", "{", "return", "getUnresolvedInterfaces", "(", "true", ")", ";", "}", "public", "ClassNode", "[", "]", "getUnresolvedInterfaces", "(", "boolean", "useRedirect", ")", "{", "if", "(", "hasInconsistentHierarchy", "(", ")", ")", "{", "return", "EMPTY_ARRAY", ";", "}", "if", "(", "!", "useRedirect", ")", "return", "interfaces", ";", "if", "(", "!", "redirect", "(", ")", ".", "lazyInitDone", ")", "redirect", "(", ")", ".", "lazyClassInit", "(", ")", ";", "return", "redirect", "(", ")", ".", "interfaces", ";", "}", "public", "CompileUnit", "getCompileUnit", "(", ")", "{", "if", "(", "redirect", "!=", "null", ")", "return", "redirect", "(", ")", ".", "getCompileUnit", "(", ")", ";", "if", "(", "compileUnit", "==", "null", "&&", "module", "!=", "null", ")", "{", "compileUnit", "=", "module", ".", "getUnit", "(", ")", ";", "}", "return", "compileUnit", ";", "}", "protected", "void", "setCompileUnit", "(", "CompileUnit", "cu", ")", "{", "if", "(", "redirect", "!=", "null", ")", "redirect", "(", ")", ".", "setCompileUnit", "(", "cu", ")", ";", "if", "(", "compileUnit", "!=", "null", ")", "compileUnit", "=", "cu", ";", "}", "protected", "boolean", "parametersEqual", "(", "Parameter", "[", "]", "a", ",", "Parameter", "[", "]", "b", ")", "{", "if", "(", "a", ".", "length", "==", "b", ".", "length", ")", "{", "boolean", "answer", "=", "true", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "a", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "a", "[", "i", "]", ".", "getType", "(", ")", ".", "equals", "(", "b", "[", "i", "]", ".", "getType", "(", ")", ")", ")", "{", "answer", "=", "false", ";", "break", ";", "}", "}", "return", "answer", ";", "}", "return", "false", ";", "}", "public", "String", "getPackageName", "(", ")", "{", "int", "idx", "=", "getName", "(", ")", ".", "lastIndexOf", "(", "'.'", ")", ";", "if", "(", "idx", ">", "0", ")", "{", "return", "getName", "(", ")", ".", "substring", "(", "0", ",", "idx", ")", ";", "}", "return", "null", ";", "}", "public", "String", "getNameWithoutPackage", "(", ")", "{", "int", "idx", "=", "getName", "(", ")", ".", "lastIndexOf", "(", "'.'", ")", ";", "if", "(", "idx", ">", "0", ")", "{", "return", "getName", "(", ")", ".", "substring", "(", "idx", "+", "1", ")", ";", "}", "return", "getName", "(", ")", ";", "}", "public", "void", "visitContents", "(", "GroovyClassVisitor", "visitor", ")", "{", "for", "(", "PropertyNode", "pn", ":", "getProperties", "(", ")", ")", "{", "visitor", ".", "visitProperty", "(", "pn", ")", ";", "}", "for", "(", "FieldNode", "fn", ":", "getFields", "(", ")", ")", "{", "visitor", ".", "visitField", "(", "fn", ")", ";", "}", "for", "(", "ConstructorNode", "cn", ":", "getDeclaredConstructors", "(", ")", ")", "{", "visitor", ".", "visitConstructor", "(", "cn", ")", ";", "}", "for", "(", "MethodNode", "mn", ":", "getMethods", "(", ")", ")", "{", "visitor", ".", "visitMethod", "(", "mn", ")", ";", "}", "}", "public", "MethodNode", "getGetterMethod", "(", "String", "getterName", ")", "{", "for", "(", "MethodNode", "method", ":", "getDeclaredMethods", "(", "getterName", ")", ")", "{", "if", "(", "getterName", ".", "equals", "(", "method", ".", "getName", "(", ")", ")", "&&", "ClassHelper", ".", "VOID_TYPE", "!=", "method", ".", "getReturnType", "(", ")", "&&", "method", ".", "getParameters", "(", ")", ".", "length", "==", "0", ")", "{", "return", "method", ";", "}", "}", "ClassNode", "parent", "=", "getSuperClass", "(", ")", ";", "if", "(", "parent", "!=", "null", ")", "return", "parent", ".", "getGetterMethod", "(", "getterName", ")", ";", "return", "null", ";", "}", "public", "MethodNode", "getSetterMethod", "(", "String", "setterName", ")", "{", "return", "getSetterMethod", "(", "setterName", ",", "true", ")", ";", "}", "public", "MethodNode", "getSetterMethod", "(", "String", "setterName", ",", "boolean", "voidOnly", ")", "{", "for", "(", "MethodNode", "method", ":", "getDeclaredMethods", "(", "setterName", ")", ")", "{", "if", "(", "setterName", ".", "equals", "(", "method", ".", "getName", "(", ")", ")", "&&", "(", "!", "voidOnly", "||", "ClassHelper", ".", "VOID_TYPE", "==", "method", ".", "getReturnType", "(", ")", ")", "&&", "method", ".", "getParameters", "(", ")", ".", "length", "==", "1", ")", "{", "return", "method", ";", "}", "}", "ClassNode", "parent", "=", "getSuperClass", "(", ")", ";", "if", "(", "parent", "!=", "null", ")", "return", "parent", ".", "getSetterMethod", "(", "setterName", ",", "voidOnly", ")", ";", "return", "null", ";", "}", "public", "boolean", "isStaticClass", "(", ")", "{", "return", "redirect", "(", ")", ".", "staticClass", ";", "}", "public", "void", "setStaticClass", "(", "boolean", "staticClass", ")", "{", "redirect", "(", ")", ".", "staticClass", "=", "staticClass", ";", "}", "public", "boolean", "isScriptBody", "(", ")", "{", "return", "redirect", "(", ")", ".", "scriptBody", ";", "}", "public", "void", "setScriptBody", "(", "boolean", "scriptBody", ")", "{", "redirect", "(", ")", ".", "scriptBody", "=", "scriptBody", ";", "}", "public", "boolean", "isScript", "(", ")", "{", "return", "redirect", "(", ")", ".", "script", "||", "isDerivedFrom", "(", "ClassHelper", ".", "SCRIPT_TYPE", ")", ";", "}", "public", "void", "setScript", "(", "boolean", "script", ")", "{", "redirect", "(", ")", ".", "script", "=", "script", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "toString", "(", "true", ")", ";", "}", "public", "String", "toString", "(", "boolean", "showRedirect", ")", "{", "String", "ret", "=", "getName", "(", ")", ";", "if", "(", "genericsTypes", "!=", "null", ")", "{", "ret", "+=", "\"", "<\"", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "genericsTypes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", "!=", "0", ")", "ret", "+=", "\",", "\"", ";", "GenericsType", "genericsType", "=", "genericsTypes", "[", "i", "]", ";", "ret", "+=", "genericTypeAsString", "(", "genericsType", ",", "showRedirect", ")", ";", "}", "ret", "+=", "\">\"", ";", "}", "if", "(", "redirect", "!=", "null", "&&", "showRedirect", ")", "{", "ret", "+=", "\"", "->", "\"", "+", "redirect", "(", ")", ".", "toString", "(", ")", ";", "}", "return", "ret", ";", "}", "private", "String", "genericTypeAsString", "(", "GenericsType", "genericsType", ",", "boolean", "showRedirect", ")", "{", "String", "ret", "=", "genericsType", ".", "getName", "(", ")", ";", "if", "(", "genericsType", ".", "getUpperBounds", "(", ")", "!=", "null", ")", "{", "ret", "+=", "\"", "extends", "\"", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "genericsType", ".", "getUpperBounds", "(", ")", ".", "length", ";", "i", "++", ")", "{", "ClassNode", "classNode", "=", "genericsType", ".", "getUpperBounds", "(", ")", "[", "i", "]", ";", "if", "(", "classNode", ".", "equals", "(", "this", ")", ")", "{", "ret", "+=", "classNode", ".", "getName", "(", ")", ";", "}", "else", "{", "ret", "+=", "classNode", ".", "toString", "(", "showRedirect", ")", ";", "}", "if", "(", "i", "+", "1", "<", "genericsType", ".", "getUpperBounds", "(", ")", ".", "length", ")", "ret", "+=", "\"", "&", "\"", ";", "}", "}", "else", "if", "(", "genericsType", ".", "getLowerBound", "(", ")", "!=", "null", ")", "{", "ClassNode", "classNode", "=", "genericsType", ".", "getLowerBound", "(", ")", ";", "if", "(", "classNode", ".", "equals", "(", "this", ")", ")", "{", "ret", "+=", "\"", "super", "\"", "+", "classNode", ".", "getName", "(", ")", ";", "}", "else", "{", "ret", "+=", "\"", "super", "\"", "+", "classNode", ";", "}", "}", "return", "ret", ";", "}", "public", "boolean", "hasPossibleMethod", "(", "String", "name", ",", "Expression", "arguments", ")", "{", "int", "count", "=", "0", ";", "if", "(", "arguments", "instanceof", "TupleExpression", ")", "{", "TupleExpression", "tuple", "=", "(", "TupleExpression", ")", "arguments", ";", "count", "=", "tuple", ".", "getExpressions", "(", ")", ".", "size", "(", ")", ";", "}", "ClassNode", "node", "=", "this", ";", "do", "{", "for", "(", "MethodNode", "method", ":", "getMethods", "(", "name", ")", ")", "{", "if", "(", "method", ".", "getParameters", "(", ")", ".", "length", "==", "count", "&&", "!", "method", ".", "isStatic", "(", ")", ")", "{", "return", "true", ";", "}", "}", "node", "=", "node", ".", "getSuperClass", "(", ")", ";", "}", "while", "(", "node", "!=", "null", ")", ";", "return", "false", ";", "}", "public", "MethodNode", "tryFindPossibleMethod", "(", "String", "name", ",", "Expression", "arguments", ")", "{", "int", "count", "=", "0", ";", "if", "(", "arguments", "instanceof", "TupleExpression", ")", "{", "TupleExpression", "tuple", "=", "(", "TupleExpression", ")", "arguments", ";", "count", "=", "tuple", ".", "getExpressions", "(", ")", ".", "size", "(", ")", ";", "}", "else", "return", "null", ";", "MethodNode", "res", "=", "null", ";", "ClassNode", "node", "=", "this", ";", "TupleExpression", "args", "=", "(", "TupleExpression", ")", "arguments", ";", "do", "{", "for", "(", "MethodNode", "method", ":", "node", ".", "getMethods", "(", "name", ")", ")", "{", "if", "(", "method", ".", "getParameters", "(", ")", ".", "length", "==", "count", ")", "{", "boolean", "match", "=", "true", ";", "for", "(", "int", "i", "=", "0", ";", "i", "!=", "count", ";", "++", "i", ")", "if", "(", "!", "args", ".", "getType", "(", ")", ".", "isDerivedFrom", "(", "method", ".", "getParameters", "(", ")", "[", "i", "]", ".", "getType", "(", ")", ")", ")", "{", "match", "=", "false", ";", "break", ";", "}", "if", "(", "match", ")", "{", "if", "(", "res", "==", "null", ")", "res", "=", "method", ";", "else", "{", "if", "(", "res", ".", "getParameters", "(", ")", ".", "length", "!=", "count", ")", "return", "null", ";", "if", "(", "node", ".", "equals", "(", "this", ")", ")", "return", "null", ";", "match", "=", "true", ";", "for", "(", "int", "i", "=", "0", ";", "i", "!=", "count", ";", "++", "i", ")", "if", "(", "!", "res", ".", "getParameters", "(", ")", "[", "i", "]", ".", "getType", "(", ")", ".", "equals", "(", "method", ".", "getParameters", "(", ")", "[", "i", "]", ".", "getType", "(", ")", ")", ")", "{", "match", "=", "false", ";", "break", ";", "}", "if", "(", "!", "match", ")", "return", "null", ";", "}", "}", "}", "}", "node", "=", "node", ".", "getSuperClass", "(", ")", ";", "}", "while", "(", "node", "!=", "null", ")", ";", "return", "res", ";", "}", "public", "boolean", "hasPossibleStaticMethod", "(", "String", "name", ",", "Expression", "arguments", ")", "{", "int", "count", "=", "0", ";", "if", "(", "arguments", "instanceof", "TupleExpression", ")", "{", "TupleExpression", "tuple", "=", "(", "TupleExpression", ")", "arguments", ";", "count", "=", "tuple", ".", "getExpressions", "(", ")", ".", "size", "(", ")", ";", "}", "else", "if", "(", "arguments", "instanceof", "MapExpression", ")", "{", "count", "=", "1", ";", "}", "for", "(", "MethodNode", "method", ":", "getMethods", "(", "name", ")", ")", "{", "if", "(", "method", ".", "isStatic", "(", ")", ")", "{", "Parameter", "[", "]", "parameters", "=", "method", ".", "getParameters", "(", ")", ";", "if", "(", "parameters", ".", "length", "==", "count", ")", "return", "true", ";", "if", "(", "parameters", ".", "length", ">", "0", "&&", "parameters", "[", "parameters", ".", "length", "-", "1", "]", ".", "getType", "(", ")", ".", "isArray", "(", ")", ")", "{", "if", "(", "count", ">=", "parameters", ".", "length", "-", "1", ")", "return", "true", ";", "}", "int", "nonDefaultParameters", "=", "0", ";", "for", "(", "Parameter", "parameter", ":", "parameters", ")", "{", "if", "(", "!", "parameter", ".", "hasInitialExpression", "(", ")", ")", "{", "nonDefaultParameters", "++", ";", "}", "}", "if", "(", "count", "<", "parameters", ".", "length", "&&", "nonDefaultParameters", "<=", "count", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}", "public", "boolean", "isInterface", "(", ")", "{", "return", "(", "getModifiers", "(", ")", "&", "Opcodes", ".", "ACC_INTERFACE", ")", ">", "0", ";", "}", "public", "boolean", "isResolved", "(", ")", "{", "return", "redirect", "(", ")", ".", "isReallyResolved", "(", ")", "||", "redirect", "(", ")", ".", "clazz", "!=", "null", "||", "(", "componentType", "!=", "null", "&&", "componentType", ".", "isResolved", "(", ")", ")", ";", "}", "public", "boolean", "isReallyResolved", "(", ")", "{", "return", "false", ";", "}", "public", "boolean", "isArray", "(", ")", "{", "return", "componentType", "!=", "null", ";", "}", "public", "ClassNode", "getComponentType", "(", ")", "{", "return", "componentType", ";", "}", "public", "boolean", "hasClass", "(", ")", "{", "return", "redirect", "(", ")", ".", "clazz", "!=", "null", ";", "}", "public", "Class", "getTypeClass", "(", ")", "{", "Class", "c", "=", "redirect", "(", ")", ".", "clazz", ";", "if", "(", "c", "!=", "null", ")", "return", "c", ";", "ClassNode", "component", "=", "redirect", "(", ")", ".", "componentType", ";", "if", "(", "component", "!=", "null", "&&", "component", ".", "isResolved", "(", ")", ")", "{", "ClassNode", "cn", "=", "component", ".", "makeArray", "(", ")", ";", "setRedirect", "(", "cn", ")", ";", "return", "redirect", "(", ")", ".", "clazz", ";", "}", "if", "(", "redirect", "(", ")", ".", "getClass", "(", ")", ".", "getName", "(", ")", ".", "endsWith", "(", "\"JDTClassNode\"", ")", ")", "{", "return", "redirect", "(", ")", ".", "getTypeClass", "(", ")", ";", "}", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "getName", "(", ")", "+", "\"\"", ")", ";", "}", "public", "boolean", "hasPackageName", "(", ")", "{", "return", "redirect", "(", ")", ".", "name", ".", "indexOf", "(", "'.'", ")", ">", "0", ";", "}", "public", "void", "setAnnotated", "(", "boolean", "flag", ")", "{", "this", ".", "annotated", "=", "flag", ";", "}", "public", "boolean", "isAnnotated", "(", ")", "{", "return", "this", ".", "annotated", ";", "}", "public", "GenericsType", "[", "]", "getGenericsTypes", "(", ")", "{", "return", "genericsTypes", ";", "}", "public", "void", "setGenericsTypes", "(", "GenericsType", "[", "]", "genericsTypes", ")", "{", "usesGenerics", "=", "usesGenerics", "||", "genericsTypes", "!=", "null", ";", "this", ".", "genericsTypes", "=", "genericsTypes", ";", "}", "public", "void", "setGenericsPlaceHolder", "(", "boolean", "b", ")", "{", "usesGenerics", "=", "usesGenerics", "||", "b", ";", "placeholder", "=", "b", ";", "}", "public", "boolean", "isGenericsPlaceHolder", "(", ")", "{", "return", "placeholder", ";", "}", "public", "boolean", "isUsingGenerics", "(", ")", "{", "return", "usesGenerics", ";", "}", "public", "void", "setUsingGenerics", "(", "boolean", "b", ")", "{", "usesGenerics", "=", "b", ";", "}", "public", "ClassNode", "getPlainNodeReference", "(", ")", "{", "if", "(", "ClassHelper", ".", "isPrimitiveType", "(", "this", ")", ")", "return", "this", ";", "ClassNode", "n", "=", "new", "ClassNode", "(", "getName", "(", ")", ",", "getModifiers", "(", ")", ",", "getSuperClass", "(", ")", ",", "getPlainNodeReferencesFor", "(", "getInterfaces", "(", ")", ")", ",", "null", ")", ";", "n", ".", "isPrimaryNode", "=", "false", ";", "n", ".", "setRedirect", "(", "redirect", "(", ")", ")", ";", "n", ".", "componentType", "=", "redirect", "(", ")", ".", "getComponentType", "(", ")", ";", "return", "n", ";", "}", "public", "ClassNode", "[", "]", "getPlainNodeReferencesFor", "(", "ClassNode", "[", "]", "classNodes", ")", "{", "if", "(", "classNodes", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "classNodes", ".", "length", "==", "0", ")", "{", "return", "ClassNode", ".", "EMPTY_ARRAY", ";", "}", "ClassNode", "[", "]", "result", "=", "new", "ClassNode", "[", "classNodes", ".", "length", "]", ";", "for", "(", "int", "count", "=", "0", ";", "count", "<", "classNodes", ".", "length", ";", "count", "++", ")", "{", "ClassNode", "cn", "=", "classNodes", "[", "count", "]", ";", "if", "(", "cn", ".", "usesGenerics", ")", "{", "result", "[", "count", "]", "=", "cn", ".", "getPlainNodeReference", "(", ")", ";", "}", "else", "{", "result", "[", "count", "]", "=", "cn", ";", "}", "}", "return", "result", ";", "}", "public", "boolean", "isAnnotationDefinition", "(", ")", "{", "return", "redirect", "(", ")", ".", "isPrimaryNode", "&&", "isInterface", "(", ")", "&&", "(", "getModifiers", "(", ")", "&", "Opcodes", ".", "ACC_ANNOTATION", ")", "!=", "0", ";", "}", "public", "List", "<", "AnnotationNode", ">", "getAnnotations", "(", ")", "{", "if", "(", "redirect", "!=", "null", ")", "return", "redirect", ".", "getAnnotations", "(", ")", ";", "lazyClassInit", "(", ")", ";", "return", "super", ".", "getAnnotations", "(", ")", ";", "}", "public", "List", "<", "AnnotationNode", ">", "getAnnotations", "(", "ClassNode", "type", ")", "{", "if", "(", "redirect", "!=", "null", ")", "return", "redirect", ".", "getAnnotations", "(", "type", ")", ";", "lazyClassInit", "(", ")", ";", "return", "super", ".", "getAnnotations", "(", "type", ")", ";", "}", "public", "void", "addTransform", "(", "Class", "<", "?", "extends", "ASTTransformation", ">", "transform", ",", "ASTNode", "node", ")", "{", "GroovyASTTransformation", "annotation", "=", "transform", ".", "getAnnotation", "(", "GroovyASTTransformation", ".", "class", ")", ";", "Set", "<", "ASTNode", ">", "nodes", "=", "getTransformInstances", "(", ")", ".", "get", "(", "annotation", ".", "phase", "(", ")", ")", ".", "get", "(", "transform", ")", ";", "if", "(", "nodes", "==", "null", ")", "{", "nodes", "=", "new", "LinkedHashSet", "<", "ASTNode", ">", "(", ")", ";", "getTransformInstances", "(", ")", ".", "get", "(", "annotation", ".", "phase", "(", ")", ")", ".", "put", "(", "transform", ",", "nodes", ")", ";", "}", "nodes", ".", "add", "(", "node", ")", ";", "}", "public", "Map", "<", "Class", "<", "?", "extends", "ASTTransformation", ">", ",", "Set", "<", "ASTNode", ">", ">", "getTransforms", "(", "CompilePhase", "phase", ")", "{", "return", "getTransformInstances", "(", ")", ".", "get", "(", "phase", ")", ";", "}", "public", "void", "renameField", "(", "String", "oldName", ",", "String", "newName", ")", "{", "ClassNode", "r", "=", "redirect", "(", ")", ";", "if", "(", "r", ".", "fieldIndex", "==", "null", ")", "r", ".", "fieldIndex", "=", "new", "HashMap", "<", "String", ",", "FieldNode", ">", "(", ")", ";", "final", "Map", "<", "String", ",", "FieldNode", ">", "index", "=", "r", ".", "fieldIndex", ";", "index", ".", "put", "(", "newName", ",", "index", ".", "remove", "(", "oldName", ")", ")", ";", "}", "public", "void", "removeField", "(", "String", "oldName", ")", "{", "ClassNode", "r", "=", "redirect", "(", ")", ";", "if", "(", "r", ".", "fieldIndex", "==", "null", ")", "r", ".", "fieldIndex", "=", "new", "HashMap", "<", "String", ",", "FieldNode", ">", "(", ")", ";", "final", "Map", "<", "String", ",", "FieldNode", ">", "index", "=", "r", ".", "fieldIndex", ";", "r", ".", "fields", ".", "remove", "(", "index", ".", "get", "(", "oldName", ")", ")", ";", "index", ".", "remove", "(", "oldName", ")", ";", "}", "public", "boolean", "isEnum", "(", ")", "{", "return", "(", "getModifiers", "(", ")", "&", "Opcodes", ".", "ACC_ENUM", ")", "!=", "0", ";", "}", "public", "Iterator", "<", "InnerClassNode", ">", "getInnerClasses", "(", ")", "{", "return", "(", "innerClasses", "==", "null", "?", "Collections", ".", "<", "InnerClassNode", ">", "emptyList", "(", ")", ":", "innerClasses", ")", ".", "iterator", "(", ")", ";", "}", "public", "void", "forgetInnerClass", "(", "InnerClassNode", "icn", ")", "{", "if", "(", "innerClasses", "!=", "null", ")", "{", "innerClasses", ".", "remove", "(", "icn", ")", ";", "}", "}", "private", "Map", "<", "CompilePhase", ",", "Map", "<", "Class", "<", "?", "extends", "ASTTransformation", ">", ",", "Set", "<", "ASTNode", ">", ">", ">", "getTransformInstances", "(", ")", "{", "if", "(", "transformInstances", "==", "null", ")", "{", "transformInstances", "=", "new", "EnumMap", "<", "CompilePhase", ",", "Map", "<", "Class", "<", "?", "extends", "ASTTransformation", ">", ",", "Set", "<", "ASTNode", ">", ">", ">", "(", "CompilePhase", ".", "class", ")", ";", "for", "(", "CompilePhase", "phase", ":", "CompilePhase", ".", "values", "(", ")", ")", "{", "transformInstances", ".", "put", "(", "phase", ",", "new", "HashMap", "<", "Class", "<", "?", "extends", "ASTTransformation", ">", ",", "Set", "<", "ASTNode", ">", ">", "(", ")", ")", ";", "}", "}", "return", "transformInstances", ";", "}", "public", "boolean", "isRedirectNode", "(", ")", "{", "return", "redirect", "!=", "null", ";", "}", "@", "Override", "public", "String", "getText", "(", ")", "{", "return", "getName", "(", ")", ";", "}", "public", "String", "getClassInternalName", "(", ")", "{", "if", "(", "redirect", "!=", "null", ")", "return", "redirect", "(", ")", ".", "getClassInternalName", "(", ")", ";", "return", "null", ";", "}", "public", "boolean", "isPrimitive", "(", ")", "{", "if", "(", "clazz", "!=", "null", ")", "{", "return", "clazz", ".", "isPrimitive", "(", ")", ";", "}", "return", "false", ";", "}", "public", "boolean", "mightHaveInners", "(", ")", "{", "ClassNode", "redirect", "=", "redirect", "(", ")", ";", "if", "(", "redirect", ".", "hasClass", "(", ")", ")", "{", "return", "true", ";", "}", "boolean", "b", "=", "redirect", ".", "innerClasses", "!=", "null", "&&", "redirect", ".", "innerClasses", ".", "size", "(", ")", ">", "0", ";", "return", "b", ";", "}", "}", "</s>" ]
6,910
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "BlockStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "Statement", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Modifier", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "MethodNode", "extends", "AnnotatedNode", "implements", "Opcodes", "{", "private", "final", "String", "name", ";", "private", "int", "modifiers", ";", "private", "boolean", "syntheticPublic", ";", "private", "ClassNode", "returnType", ";", "private", "Parameter", "[", "]", "parameters", ";", "private", "boolean", "hasDefaultValue", "=", "false", ";", "private", "Statement", "code", ";", "private", "boolean", "dynamicReturnType", ";", "private", "VariableScope", "variableScope", ";", "private", "final", "ClassNode", "[", "]", "exceptions", ";", "private", "final", "boolean", "staticConstructor", ";", "private", "GenericsType", "[", "]", "genericsTypes", "=", "null", ";", "private", "boolean", "hasDefault", ";", "String", "typeDescriptor", ";", "public", "MethodNode", "(", "String", "name", ",", "int", "modifiers", ",", "ClassNode", "returnType", ",", "Parameter", "[", "]", "parameters", ",", "ClassNode", "[", "]", "exceptions", ",", "Statement", "code", ")", "{", "this", ".", "name", "=", "name", ";", "this", ".", "modifiers", "=", "modifiers", ";", "this", ".", "code", "=", "code", ";", "setReturnType", "(", "returnType", ")", ";", "VariableScope", "scope", "=", "new", "VariableScope", "(", ")", ";", "setVariableScope", "(", "scope", ")", ";", "setParameters", "(", "parameters", ")", ";", "this", ".", "hasDefault", "=", "false", ";", "this", ".", "exceptions", "=", "exceptions", ";", "this", ".", "staticConstructor", "=", "(", "name", "!=", "null", "&&", "name", ".", "equals", "(", "\"<clinit>\"", ")", ")", ";", "}", "public", "String", "getTypeDescriptor", "(", ")", "{", "if", "(", "typeDescriptor", "==", "null", ")", "{", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", "name", ".", "length", "(", ")", "+", "parameters", ".", "length", "*", "10", ")", ";", "buf", ".", "append", "(", "returnType", ".", "getName", "(", ")", ")", ";", "buf", ".", "append", "(", "'", "'", ")", ";", "buf", ".", "append", "(", "name", ")", ";", "buf", ".", "append", "(", "'('", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "parameters", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", ">", "0", ")", "{", "buf", ".", "append", "(", "\",", "\"", ")", ";", "}", "Parameter", "param", "=", "parameters", "[", "i", "]", ";", "buf", ".", "append", "(", "param", ".", "getType", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "buf", ".", "append", "(", "')'", ")", ";", "typeDescriptor", "=", "buf", ".", "toString", "(", ")", ";", "}", "return", "typeDescriptor", ";", "}", "private", "void", "invalidateCachedData", "(", ")", "{", "typeDescriptor", "=", "null", ";", "}", "public", "boolean", "isVoidMethod", "(", ")", "{", "return", "returnType", "==", "ClassHelper", ".", "VOID_TYPE", ";", "}", "public", "Statement", "getCode", "(", ")", "{", "return", "code", ";", "}", "public", "void", "setCode", "(", "Statement", "code", ")", "{", "this", ".", "code", "=", "code", ";", "}", "public", "int", "getModifiers", "(", ")", "{", "return", "modifiers", ";", "}", "public", "void", "setModifiers", "(", "int", "modifiers", ")", "{", "invalidateCachedData", "(", ")", ";", "this", ".", "modifiers", "=", "modifiers", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "name", ";", "}", "public", "Parameter", "[", "]", "getParameters", "(", ")", "{", "return", "parameters", ";", "}", "public", "void", "setParameters", "(", "Parameter", "[", "]", "parameters", ")", "{", "invalidateCachedData", "(", ")", ";", "VariableScope", "scope", "=", "new", "VariableScope", "(", ")", ";", "this", ".", "parameters", "=", "parameters", ";", "if", "(", "parameters", "!=", "null", "&&", "parameters", ".", "length", ">", "0", ")", "{", "for", "(", "Parameter", "para", ":", "parameters", ")", "{", "if", "(", "para", ".", "hasInitialExpression", "(", ")", ")", "{", "this", ".", "hasDefaultValue", "=", "true", ";", "}", "para", ".", "setInStaticContext", "(", "isStatic", "(", ")", ")", ";", "scope", ".", "putDeclaredVariable", "(", "para", ")", ";", "}", "}", "setVariableScope", "(", "scope", ")", ";", "}", "public", "ClassNode", "getReturnType", "(", ")", "{", "return", "returnType", ";", "}", "public", "VariableScope", "getVariableScope", "(", ")", "{", "return", "variableScope", ";", "}", "public", "void", "setVariableScope", "(", "VariableScope", "variableScope", ")", "{", "this", ".", "variableScope", "=", "variableScope", ";", "variableScope", ".", "setInStaticContext", "(", "isStatic", "(", ")", ")", ";", "}", "public", "boolean", "isDynamicReturnType", "(", ")", "{", "return", "dynamicReturnType", ";", "}", "public", "boolean", "isAbstract", "(", ")", "{", "return", "(", "modifiers", "&", "ACC_ABSTRACT", ")", "!=", "0", ";", "}", "public", "boolean", "isStatic", "(", ")", "{", "return", "(", "modifiers", "&", "ACC_STATIC", ")", "!=", "0", ";", "}", "public", "boolean", "isPublic", "(", ")", "{", "return", "(", "modifiers", "&", "ACC_PUBLIC", ")", "!=", "0", ";", "}", "public", "boolean", "isPrivate", "(", ")", "{", "return", "(", "modifiers", "&", "ACC_PRIVATE", ")", "!=", "0", ";", "}", "public", "boolean", "isFinal", "(", ")", "{", "return", "(", "modifiers", "&", "ACC_FINAL", ")", "!=", "0", ";", "}", "public", "boolean", "isProtected", "(", ")", "{", "return", "(", "modifiers", "&", "ACC_PROTECTED", ")", "!=", "0", ";", "}", "public", "boolean", "hasDefaultValue", "(", ")", "{", "return", "this", ".", "hasDefaultValue", ";", "}", "public", "boolean", "isScriptBody", "(", ")", "{", "return", "getDeclaringClass", "(", ")", "!=", "null", "&&", "getDeclaringClass", "(", ")", ".", "isScript", "(", ")", "&&", "getName", "(", ")", ".", "equals", "(", "\"run\"", ")", "&&", "(", "parameters", "==", "null", "||", "parameters", ".", "length", "==", "0", ")", "&&", "(", "returnType", "!=", "null", "&&", "returnType", ".", "getName", "(", ")", ".", "equals", "(", "\"\"", ")", ")", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "\"MethodNode@\"", "+", "hashCode", "(", ")", "+", "\"[\"", "+", "getTypeDescriptor", "(", ")", "+", "\"]\"", ";", "}", "public", "void", "setReturnType", "(", "ClassNode", "returnType", ")", "{", "invalidateCachedData", "(", ")", ";", "dynamicReturnType", "|=", "ClassHelper", ".", "DYNAMIC_TYPE", "==", "returnType", ";", "this", ".", "returnType", "=", "returnType", ";", "if", "(", "returnType", "==", "null", ")", "this", ".", "returnType", "=", "ClassHelper", ".", "OBJECT_TYPE", ";", "}", "public", "ClassNode", "[", "]", "getExceptions", "(", ")", "{", "return", "exceptions", ";", "}", "public", "Statement", "getFirstStatement", "(", ")", "{", "if", "(", "code", "==", "null", ")", "return", "null", ";", "Statement", "first", "=", "code", ";", "while", "(", "first", "instanceof", "BlockStatement", ")", "{", "List", "<", "Statement", ">", "list", "=", "(", "(", "BlockStatement", ")", "first", ")", ".", "getStatements", "(", ")", ";", "if", "(", "list", ".", "isEmpty", "(", ")", ")", "{", "first", "=", "null", ";", "}", "else", "{", "first", "=", "list", ".", "get", "(", "0", ")", ";", "}", "}", "return", "first", ";", "}", "public", "GenericsType", "[", "]", "getGenericsTypes", "(", ")", "{", "return", "genericsTypes", ";", "}", "public", "void", "setGenericsTypes", "(", "GenericsType", "[", "]", "genericsTypes", ")", "{", "invalidateCachedData", "(", ")", ";", "this", ".", "genericsTypes", "=", "genericsTypes", ";", "}", "public", "void", "setAnnotationDefault", "(", "boolean", "b", ")", "{", "this", ".", "hasDefault", "=", "b", ";", "}", "public", "boolean", "hasAnnotationDefault", "(", ")", "{", "return", "hasDefault", ";", "}", "public", "boolean", "isStaticConstructor", "(", ")", "{", "return", "staticConstructor", ";", "}", "public", "boolean", "isSyntheticPublic", "(", ")", "{", "return", "syntheticPublic", ";", "}", "public", "void", "setSyntheticPublic", "(", "boolean", "syntheticPublic", ")", "{", "this", ".", "syntheticPublic", "=", "syntheticPublic", ";", "}", "@", "Override", "public", "String", "getText", "(", ")", "{", "String", "retType", "=", "AstToTextHelper", ".", "getClassText", "(", "returnType", ")", ";", "String", "exceptionTypes", "=", "AstToTextHelper", ".", "getThrowsClauseText", "(", "exceptions", ")", ";", "String", "parms", "=", "AstToTextHelper", ".", "getParametersText", "(", "parameters", ")", ";", "return", "AstToTextHelper", ".", "getModifiersText", "(", "modifiers", ")", "+", "\"", "\"", "+", "retType", "+", "\"", "\"", "+", "name", "+", "\"(\"", "+", "parms", "+", "\")", "\"", "+", "exceptionTypes", "+", "\"", "{", "...", "}\"", ";", "}", "private", "MethodNode", "original", "=", "this", ";", "public", "MethodNode", "getOriginal", "(", ")", "{", "return", "original", ";", "}", "public", "void", "setOriginal", "(", "MethodNode", "original", ")", "{", "this", ".", "original", "=", "original", ";", "}", "}", "</s>" ]
6,911
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "class", "VariableScope", "{", "private", "Map", "<", "String", ",", "Variable", ">", "declaredVariables", "=", "Collections", ".", "emptyMap", "(", ")", ";", "private", "Map", "<", "String", ",", "Variable", ">", "referencedLocalVariables", "=", "Collections", ".", "emptyMap", "(", ")", ";", "private", "Map", "<", "String", ",", "Variable", ">", "referencedClassVariables", "=", "Collections", ".", "emptyMap", "(", ")", ";", "private", "boolean", "inStaticContext", "=", "false", ";", "private", "boolean", "resolvesDynamic", "=", "false", ";", "private", "ClassNode", "clazzScope", ";", "private", "VariableScope", "parent", ";", "public", "VariableScope", "(", ")", "{", "}", "public", "VariableScope", "(", "VariableScope", "parent", ")", "{", "this", ".", "parent", "=", "parent", ";", "}", "public", "Variable", "getDeclaredVariable", "(", "String", "name", ")", "{", "return", "declaredVariables", ".", "get", "(", "name", ")", ";", "}", "public", "Iterator", "<", "Variable", ">", "getDeclaredVariablesIterator", "(", ")", "{", "return", "declaredVariables", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "}", "public", "boolean", "isReferencedLocalVariable", "(", "String", "name", ")", "{", "return", "referencedLocalVariables", ".", "containsKey", "(", "name", ")", ";", "}", "public", "boolean", "isReferencedClassVariable", "(", "String", "name", ")", "{", "return", "referencedClassVariables", ".", "containsKey", "(", "name", ")", ";", "}", "public", "VariableScope", "getParent", "(", ")", "{", "return", "parent", ";", "}", "public", "boolean", "isInStaticContext", "(", ")", "{", "return", "inStaticContext", ";", "}", "public", "void", "setInStaticContext", "(", "boolean", "inStaticContext", ")", "{", "this", ".", "inStaticContext", "=", "inStaticContext", ";", "}", "public", "void", "setClassScope", "(", "ClassNode", "node", ")", "{", "this", ".", "clazzScope", "=", "node", ";", "}", "public", "ClassNode", "getClassScope", "(", ")", "{", "return", "clazzScope", ";", "}", "public", "boolean", "isClassScope", "(", ")", "{", "return", "clazzScope", "!=", "null", ";", "}", "public", "boolean", "isRoot", "(", ")", "{", "return", "parent", "==", "null", ";", "}", "public", "VariableScope", "copy", "(", ")", "{", "VariableScope", "copy", "=", "new", "VariableScope", "(", ")", ";", "copy", ".", "clazzScope", "=", "clazzScope", ";", "if", "(", "declaredVariables", ".", "size", "(", ")", ">", "0", ")", "{", "copy", ".", "declaredVariables", "=", "new", "HashMap", "<", "String", ",", "Variable", ">", "(", ")", ";", "copy", ".", "declaredVariables", ".", "putAll", "(", "declaredVariables", ")", ";", "}", "copy", ".", "inStaticContext", "=", "inStaticContext", ";", "copy", ".", "parent", "=", "parent", ";", "if", "(", "referencedClassVariables", ".", "size", "(", ")", ">", "0", ")", "{", "copy", ".", "referencedClassVariables", "=", "new", "HashMap", "<", "String", ",", "Variable", ">", "(", ")", ";", "copy", ".", "referencedClassVariables", ".", "putAll", "(", "referencedClassVariables", ")", ";", "}", "if", "(", "referencedLocalVariables", ".", "size", "(", ")", ">", "0", ")", "{", "copy", ".", "referencedLocalVariables", "=", "new", "HashMap", "<", "String", ",", "Variable", ">", "(", ")", ";", "copy", ".", "referencedLocalVariables", ".", "putAll", "(", "referencedLocalVariables", ")", ";", "}", "copy", ".", "resolvesDynamic", "=", "resolvesDynamic", ";", "return", "copy", ";", "}", "public", "void", "putDeclaredVariable", "(", "Variable", "var", ")", "{", "if", "(", "declaredVariables", "==", "Collections", ".", "EMPTY_MAP", ")", "declaredVariables", "=", "new", "HashMap", "<", "String", ",", "Variable", ">", "(", ")", ";", "declaredVariables", ".", "put", "(", "var", ".", "getName", "(", ")", ",", "var", ")", ";", "}", "public", "Iterator", "<", "Variable", ">", "getReferencedLocalVariablesIterator", "(", ")", "{", "return", "referencedLocalVariables", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "}", "public", "int", "getReferencedLocalVariablesCount", "(", ")", "{", "return", "referencedLocalVariables", ".", "size", "(", ")", ";", "}", "public", "Variable", "getReferencedLocalVariable", "(", "String", "name", ")", "{", "return", "referencedLocalVariables", ".", "get", "(", "name", ")", ";", "}", "public", "void", "putReferencedLocalVariable", "(", "Variable", "var", ")", "{", "if", "(", "referencedLocalVariables", "==", "Collections", ".", "EMPTY_MAP", ")", "referencedLocalVariables", "=", "new", "HashMap", "<", "String", ",", "Variable", ">", "(", ")", ";", "referencedLocalVariables", ".", "put", "(", "var", ".", "getName", "(", ")", ",", "var", ")", ";", "}", "public", "void", "putReferencedClassVariable", "(", "Variable", "var", ")", "{", "if", "(", "referencedClassVariables", "==", "Collections", ".", "EMPTY_MAP", ")", "referencedClassVariables", "=", "new", "HashMap", "<", "String", ",", "Variable", ">", "(", ")", ";", "referencedClassVariables", ".", "put", "(", "var", ".", "getName", "(", ")", ",", "var", ")", ";", "}", "public", "Variable", "getReferencedClassVariable", "(", "String", "name", ")", "{", "return", "referencedClassVariables", ".", "get", "(", "name", ")", ";", "}", "public", "Object", "removeReferencedClassVariable", "(", "String", "name", ")", "{", "if", "(", "referencedClassVariables", "==", "Collections", ".", "EMPTY_MAP", ")", "return", "null", ";", "else", "return", "referencedClassVariables", ".", "remove", "(", "name", ")", ";", "}", "public", "Map", "<", "String", ",", "Variable", ">", "getReferencedClassVariables", "(", ")", "{", "if", "(", "referencedClassVariables", "==", "Collections", ".", "EMPTY_MAP", ")", "{", "return", "referencedClassVariables", ";", "}", "else", "{", "return", "Collections", ".", "unmodifiableMap", "(", "referencedClassVariables", ")", ";", "}", "}", "public", "Iterator", "<", "Variable", ">", "getReferencedClassVariablesIterator", "(", ")", "{", "return", "getReferencedClassVariables", "(", ")", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "}", "}", "</s>" ]
6,912
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "groovy", ".", "lang", ".", "Binding", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "ArgumentListExpression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "ClassExpression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "MethodCallExpression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "VariableExpression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "BlockStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "ExpressionStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "Statement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "SourceUnit", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "runtime", ".", "InvokerHelper", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "util", ".", "*", ";", "public", "class", "ModuleNode", "extends", "ASTNode", "implements", "Opcodes", "{", "private", "BlockStatement", "statementBlock", "=", "new", "BlockStatement", "(", ")", ";", "List", "<", "ClassNode", ">", "classes", "=", "new", "LinkedList", "<", "ClassNode", ">", "(", ")", ";", "private", "List", "<", "MethodNode", ">", "methods", "=", "new", "ArrayList", "<", "MethodNode", ">", "(", ")", ";", "private", "Map", "<", "String", ",", "ImportNode", ">", "imports", "=", "new", "HashMap", "<", "String", ",", "ImportNode", ">", "(", ")", ";", "private", "List", "<", "ImportNode", ">", "starImports", "=", "new", "ArrayList", "<", "ImportNode", ">", "(", ")", ";", "private", "Map", "<", "String", ",", "ImportNode", ">", "staticImports", "=", "new", "LinkedHashMap", "<", "String", ",", "ImportNode", ">", "(", ")", ";", "private", "Map", "<", "String", ",", "ImportNode", ">", "staticStarImports", "=", "new", "LinkedHashMap", "<", "String", ",", "ImportNode", ">", "(", ")", ";", "private", "CompileUnit", "unit", ";", "private", "PackageNode", "packageNode", ";", "private", "String", "description", ";", "private", "boolean", "createClassForStatements", "=", "true", ";", "private", "transient", "SourceUnit", "context", ";", "private", "boolean", "importsResolved", "=", "false", ";", "private", "ClassNode", "scriptDummy", ";", "private", "String", "mainClassName", "=", "null", ";", "public", "ModuleNode", "(", "SourceUnit", "context", ")", "{", "this", ".", "context", "=", "context", ";", "}", "public", "ModuleNode", "(", "CompileUnit", "unit", ")", "{", "this", ".", "unit", "=", "unit", ";", "}", "public", "BlockStatement", "getStatementBlock", "(", ")", "{", "return", "statementBlock", ";", "}", "public", "List", "<", "MethodNode", ">", "getMethods", "(", ")", "{", "return", "methods", ";", "}", "public", "List", "<", "ClassNode", ">", "getClasses", "(", ")", "{", "if", "(", "createClassForStatements", "&&", "(", "!", "statementBlock", ".", "isEmpty", "(", ")", "||", "!", "methods", ".", "isEmpty", "(", ")", "||", "isPackageInfo", "(", ")", ")", ")", "{", "ClassNode", "mainClass", "=", "createStatementsClass", "(", ")", ";", "mainClassName", "=", "mainClass", ".", "getName", "(", ")", ";", "createClassForStatements", "=", "false", ";", "classes", ".", "add", "(", "0", ",", "mainClass", ")", ";", "mainClass", ".", "setModule", "(", "this", ")", ";", "addToCompileUnit", "(", "mainClass", ")", ";", "}", "return", "classes", ";", "}", "private", "int", "knowIfPackageInfo", "=", "0", ";", "private", "boolean", "encounteredUnrecoverableError", ";", "public", "void", "setEncounteredUnrecoverableError", "(", "boolean", "b", ")", "{", "encounteredUnrecoverableError", "=", "b", ";", "}", "public", "boolean", "encounteredUnrecoverableError", "(", ")", "{", "return", "encounteredUnrecoverableError", ";", "}", "private", "boolean", "isPackageInfo", "(", ")", "{", "if", "(", "knowIfPackageInfo", "==", "0", ")", "{", "if", "(", "context", "!=", "null", "&&", "context", ".", "getName", "(", ")", "!=", "null", "&&", "context", ".", "getName", "(", ")", ".", "endsWith", "(", "\"\"", ")", ")", "{", "knowIfPackageInfo", "=", "1", ";", "}", "else", "{", "knowIfPackageInfo", "=", "2", ";", "}", "}", "return", "knowIfPackageInfo", "==", "1", ";", "}", "public", "List", "<", "ImportNode", ">", "getImports", "(", ")", "{", "return", "new", "ArrayList", "<", "ImportNode", ">", "(", "imports", ".", "values", "(", ")", ")", ";", "}", "public", "List", "<", "ImportNode", ">", "getStarImports", "(", ")", "{", "return", "starImports", ";", "}", "public", "ClassNode", "getImportType", "(", "String", "alias", ")", "{", "ImportNode", "importNode", "=", "imports", ".", "get", "(", "alias", ")", ";", "return", "importNode", "==", "null", "?", "null", ":", "importNode", ".", "getType", "(", ")", ";", "}", "public", "ImportNode", "getImport", "(", "String", "alias", ")", "{", "return", "imports", ".", "get", "(", "alias", ")", ";", "}", "public", "void", "addImport", "(", "String", "alias", ",", "ClassNode", "type", ")", "{", "addImport", "(", "alias", ",", "type", ",", "new", "ArrayList", "<", "AnnotationNode", ">", "(", ")", ")", ";", "}", "public", "void", "addImport", "(", "String", "alias", ",", "ClassNode", "type", ",", "List", "<", "AnnotationNode", ">", "annotations", ")", "{", "ImportNode", "importNode", "=", "new", "ImportNode", "(", "type", ",", "alias", ")", ";", "if", "(", "type", "!=", "null", ")", "{", "importNode", ".", "setSourcePosition", "(", "type", ")", ";", "importNode", ".", "setColumnNumber", "(", "1", ")", ";", "importNode", ".", "setStart", "(", "type", ".", "getStart", "(", ")", "-", "type", ".", "getColumnNumber", "(", ")", "+", "1", ")", ";", "}", "imports", ".", "put", "(", "alias", ",", "importNode", ")", ";", "importNode", ".", "addAnnotations", "(", "annotations", ")", ";", "}", "public", "void", "addStarImport", "(", "String", "packageName", ")", "{", "addStarImport", "(", "packageName", ",", "new", "ArrayList", "<", "AnnotationNode", ">", "(", ")", ")", ";", "}", "public", "void", "addStarImport", "(", "String", "packageName", ",", "List", "<", "AnnotationNode", ">", "annotations", ")", "{", "ImportNode", "importNode", "=", "new", "ImportNode", "(", "packageName", ")", ";", "importNode", ".", "addAnnotations", "(", "annotations", ")", ";", "starImports", ".", "add", "(", "importNode", ")", ";", "}", "public", "void", "addStatement", "(", "Statement", "node", ")", "{", "statementBlock", ".", "addStatement", "(", "node", ")", ";", "}", "public", "void", "addClass", "(", "ClassNode", "node", ")", "{", "if", "(", "classes", ".", "isEmpty", "(", ")", ")", "mainClassName", "=", "node", ".", "getName", "(", ")", ";", "classes", ".", "add", "(", "node", ")", ";", "node", ".", "setModule", "(", "this", ")", ";", "addToCompileUnit", "(", "node", ")", ";", "}", "private", "void", "addToCompileUnit", "(", "ClassNode", "node", ")", "{", "if", "(", "unit", "!=", "null", ")", "{", "unit", ".", "addClass", "(", "node", ")", ";", "}", "}", "public", "void", "addMethod", "(", "MethodNode", "node", ")", "{", "methods", ".", "add", "(", "node", ")", ";", "}", "public", "void", "visit", "(", "GroovyCodeVisitor", "visitor", ")", "{", "}", "public", "String", "getPackageName", "(", ")", "{", "return", "packageNode", "==", "null", "?", "null", ":", "packageNode", ".", "getName", "(", ")", ";", "}", "public", "PackageNode", "getPackage", "(", ")", "{", "return", "packageNode", ";", "}", "public", "void", "setPackage", "(", "PackageNode", "packageNode", ")", "{", "this", ".", "packageNode", "=", "packageNode", ";", "}", "public", "void", "setPackageName", "(", "String", "packageName", ")", "{", "this", ".", "packageNode", "=", "new", "PackageNode", "(", "packageName", ")", ";", "}", "public", "boolean", "hasPackageName", "(", ")", "{", "return", "packageNode", "!=", "null", "&&", "packageNode", ".", "getName", "(", ")", "!=", "null", ";", "}", "public", "boolean", "hasPackage", "(", ")", "{", "return", "this", ".", "packageNode", "!=", "null", ";", "}", "public", "SourceUnit", "getContext", "(", ")", "{", "return", "context", ";", "}", "public", "String", "getDescription", "(", ")", "{", "if", "(", "context", "!=", "null", ")", "{", "return", "context", ".", "getName", "(", ")", ";", "}", "else", "{", "return", "this", ".", "description", ";", "}", "}", "public", "void", "setDescription", "(", "String", "description", ")", "{", "this", ".", "description", "=", "description", ";", "}", "public", "CompileUnit", "getUnit", "(", ")", "{", "return", "unit", ";", "}", "void", "setUnit", "(", "CompileUnit", "unit", ")", "{", "this", ".", "unit", "=", "unit", ";", "}", "public", "ClassNode", "getScriptClassDummy", "(", ")", "{", "if", "(", "scriptDummy", "!=", "null", ")", "{", "setScriptBaseClassFromConfig", "(", "scriptDummy", ")", ";", "return", "scriptDummy", ";", "}", "String", "name", "=", "getPackageName", "(", ")", ";", "if", "(", "name", "==", "null", ")", "{", "name", "=", "\"\"", ";", "}", "if", "(", "getDescription", "(", ")", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "name", "+=", "extractClassFromFileDescription", "(", ")", ";", "ClassNode", "classNode", ";", "if", "(", "isPackageInfo", "(", ")", ")", "{", "classNode", "=", "new", "ClassNode", "(", "name", ",", "ACC_ABSTRACT", "|", "ACC_INTERFACE", ",", "ClassHelper", ".", "OBJECT_TYPE", ")", ";", "}", "else", "{", "classNode", "=", "new", "ClassNode", "(", "name", ",", "ACC_PUBLIC", ",", "ClassHelper", ".", "SCRIPT_TYPE", ")", ";", "setScriptBaseClassFromConfig", "(", "classNode", ")", ";", "classNode", ".", "setScript", "(", "true", ")", ";", "classNode", ".", "setScriptBody", "(", "true", ")", ";", "}", "scriptDummy", "=", "classNode", ";", "return", "classNode", ";", "}", "private", "void", "setScriptBaseClassFromConfig", "(", "ClassNode", "cn", ")", "{", "if", "(", "unit", "!=", "null", ")", "{", "String", "baseClassName", "=", "unit", ".", "getConfig", "(", ")", ".", "getScriptBaseClass", "(", ")", ";", "if", "(", "baseClassName", "!=", "null", ")", "{", "if", "(", "!", "cn", ".", "getSuperClass", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "baseClassName", ")", ")", "{", "cn", ".", "setSuperClass", "(", "ClassHelper", ".", "make", "(", "baseClassName", ")", ")", ";", "}", "}", "}", "}", "protected", "ClassNode", "createStatementsClass", "(", ")", "{", "ClassNode", "classNode", "=", "getScriptClassDummy", "(", ")", ";", "if", "(", "classNode", ".", "getName", "(", ")", ".", "endsWith", "(", "\"package-info\"", ")", ")", "{", "return", "classNode", ";", "}", "handleMainMethodIfPresent", "(", "methods", ")", ";", "classNode", ".", "addMethod", "(", "new", "MethodNode", "(", "\"main\"", ",", "ACC_PUBLIC", "|", "ACC_STATIC", ",", "ClassHelper", ".", "VOID_TYPE", ",", "new", "Parameter", "[", "]", "{", "new", "Parameter", "(", "ClassHelper", ".", "STRING_TYPE", ".", "makeArray", "(", ")", ",", "\"args\"", ")", "}", ",", "ClassNode", ".", "EMPTY_ARRAY", ",", "new", "ExpressionStatement", "(", "new", "MethodCallExpression", "(", "new", "ClassExpression", "(", "ClassHelper", ".", "make", "(", "InvokerHelper", ".", "class", ")", ")", ",", "\"runScript\"", ",", "new", "ArgumentListExpression", "(", "new", "ClassExpression", "(", "classNode", ")", ",", "new", "VariableExpression", "(", "\"args\"", ")", ")", ")", ")", ")", ")", ";", "classNode", ".", "addMethod", "(", "new", "MethodNode", "(", "\"run\"", ",", "ACC_PUBLIC", ",", "ClassHelper", ".", "OBJECT_TYPE", ",", "Parameter", ".", "EMPTY_ARRAY", ",", "ClassNode", ".", "EMPTY_ARRAY", ",", "statementBlock", ")", ")", ";", "classNode", ".", "addConstructor", "(", "ACC_PUBLIC", ",", "Parameter", ".", "EMPTY_ARRAY", ",", "ClassNode", ".", "EMPTY_ARRAY", ",", "new", "BlockStatement", "(", ")", ")", ";", "Statement", "stmt", "=", "new", "ExpressionStatement", "(", "new", "MethodCallExpression", "(", "new", "VariableExpression", "(", "\"super\"", ")", ",", "\"setBinding\"", ",", "new", "ArgumentListExpression", "(", "new", "VariableExpression", "(", "\"context\"", ")", ")", ")", ")", ";", "classNode", ".", "addConstructor", "(", "ACC_PUBLIC", ",", "new", "Parameter", "[", "]", "{", "new", "Parameter", "(", "ClassHelper", ".", "make", "(", "Binding", ".", "class", ")", ",", "\"context\"", ")", "}", ",", "ClassNode", ".", "EMPTY_ARRAY", ",", "stmt", ")", ";", "for", "(", "MethodNode", "node", ":", "methods", ")", "{", "int", "modifiers", "=", "node", ".", "getModifiers", "(", ")", ";", "if", "(", "(", "modifiers", "&", "ACC_ABSTRACT", ")", "!=", "0", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", "+", "node", ".", "getName", "(", ")", ")", ";", "}", "node", ".", "setModifiers", "(", "modifiers", ")", ";", "classNode", ".", "addMethod", "(", "node", ")", ";", "}", "return", "classNode", ";", "}", "private", "void", "handleMainMethodIfPresent", "(", "List", "methods", ")", "{", "boolean", "found", "=", "false", ";", "for", "(", "Iterator", "iter", "=", "methods", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "MethodNode", "node", "=", "(", "MethodNode", ")", "iter", ".", "next", "(", ")", ";", "if", "(", "node", ".", "getName", "(", ")", ".", "equals", "(", "\"main\"", ")", ")", "{", "if", "(", "node", ".", "isStatic", "(", ")", "&&", "node", ".", "getParameters", "(", ")", ".", "length", "==", "1", ")", "{", "boolean", "retTypeMatches", ",", "argTypeMatches", ";", "ClassNode", "argType", "=", "node", ".", "getParameters", "(", ")", "[", "0", "]", ".", "getType", "(", ")", ";", "ClassNode", "retType", "=", "node", ".", "getReturnType", "(", ")", ";", "argTypeMatches", "=", "(", "argType", ".", "equals", "(", "ClassHelper", ".", "OBJECT_TYPE", ")", "||", "argType", ".", "getName", "(", ")", ".", "contains", "(", "\"String[]\"", ")", ")", ";", "retTypeMatches", "=", "(", "retType", "==", "ClassHelper", ".", "VOID_TYPE", "||", "retType", "==", "ClassHelper", ".", "OBJECT_TYPE", ")", ";", "if", "(", "retTypeMatches", "&&", "argTypeMatches", ")", "{", "if", "(", "found", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "else", "{", "found", "=", "true", ";", "}", "if", "(", "statementBlock", ".", "isEmpty", "(", ")", ")", "{", "addStatement", "(", "node", ".", "getCode", "(", ")", ")", ";", "}", "iter", ".", "remove", "(", ")", ";", "}", "}", "}", "}", "}", "protected", "String", "extractClassFromFileDescription", "(", ")", "{", "String", "answer", "=", "getDescription", "(", ")", ";", "int", "slashIdx", "=", "answer", ".", "lastIndexOf", "(", "'/'", ")", ";", "int", "separatorIdx", "=", "answer", ".", "lastIndexOf", "(", "File", ".", "separatorChar", ")", ";", "int", "dotIdx", "=", "answer", ".", "lastIndexOf", "(", "'.'", ")", ";", "if", "(", "dotIdx", ">", "0", "&&", "dotIdx", ">", "Math", ".", "max", "(", "slashIdx", ",", "separatorIdx", ")", ")", "{", "answer", "=", "answer", ".", "substring", "(", "0", ",", "dotIdx", ")", ";", "}", "if", "(", "slashIdx", ">=", "0", ")", "{", "answer", "=", "answer", ".", "substring", "(", "slashIdx", "+", "1", ")", ";", "}", "separatorIdx", "=", "answer", ".", "lastIndexOf", "(", "File", ".", "separatorChar", ")", ";", "if", "(", "separatorIdx", ">=", "0", ")", "{", "answer", "=", "answer", ".", "substring", "(", "separatorIdx", "+", "1", ")", ";", "}", "return", "answer", ";", "}", "public", "boolean", "isEmpty", "(", ")", "{", "return", "classes", ".", "isEmpty", "(", ")", "&&", "statementBlock", ".", "getStatements", "(", ")", ".", "isEmpty", "(", ")", ";", "}", "public", "void", "sortClasses", "(", ")", "{", "if", "(", "isEmpty", "(", ")", ")", "return", ";", "List", "<", "ClassNode", ">", "classes", "=", "getClasses", "(", ")", ";", "LinkedList", "<", "ClassNode", ">", "sorted", "=", "new", "LinkedList", "<", "ClassNode", ">", "(", ")", ";", "int", "level", "=", "1", ";", "while", "(", "!", "classes", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "Iterator", "<", "ClassNode", ">", "cni", "=", "classes", ".", "iterator", "(", ")", ";", "cni", ".", "hasNext", "(", ")", ";", ")", "{", "ClassNode", "cn", "=", "cni", ".", "next", "(", ")", ";", "ClassNode", "sn", "=", "cn", ";", "for", "(", "int", "i", "=", "0", ";", "sn", "!=", "null", "&&", "i", "<", "level", ";", "i", "++", ")", "sn", "=", "sn", ".", "getSuperClass", "(", ")", ";", "if", "(", "sn", "!=", "null", "&&", "sn", ".", "isPrimaryClassNode", "(", ")", ")", "continue", ";", "cni", ".", "remove", "(", ")", ";", "sorted", ".", "addLast", "(", "cn", ")", ";", "}", "level", "++", ";", "}", "this", ".", "classes", "=", "sorted", ";", "}", "public", "boolean", "hasImportsResolved", "(", ")", "{", "return", "importsResolved", ";", "}", "public", "void", "setImportsResolved", "(", "boolean", "importsResolved", ")", "{", "this", ".", "importsResolved", "=", "importsResolved", ";", "}", "public", "Map", "<", "String", ",", "ImportNode", ">", "getStaticImports", "(", ")", "{", "return", "staticImports", ";", "}", "public", "Map", "<", "String", ",", "ImportNode", ">", "getStaticStarImports", "(", ")", "{", "return", "staticStarImports", ";", "}", "public", "void", "addStaticImport", "(", "ClassNode", "type", ",", "String", "fieldName", ",", "String", "alias", ")", "{", "addStaticImport", "(", "type", ",", "fieldName", ",", "alias", ",", "new", "ArrayList", "<", "AnnotationNode", ">", "(", ")", ")", ";", "}", "public", "void", "addStaticImport", "(", "ClassNode", "type", ",", "String", "fieldName", ",", "String", "alias", ",", "List", "<", "AnnotationNode", ">", "annotations", ")", "{", "ImportNode", "node", "=", "new", "ImportNode", "(", "type", ",", "fieldName", ",", "alias", ")", ";", "node", ".", "addAnnotations", "(", "annotations", ")", ";", "staticImports", ".", "put", "(", "alias", ",", "node", ")", ";", "}", "public", "void", "addStaticStarImport", "(", "String", "name", ",", "ClassNode", "type", ")", "{", "addStaticStarImport", "(", "name", ",", "type", ",", "new", "ArrayList", "<", "AnnotationNode", ">", "(", ")", ")", ";", "}", "public", "void", "addStaticStarImport", "(", "String", "name", ",", "ClassNode", "type", ",", "List", "<", "AnnotationNode", ">", "annotations", ")", "{", "ImportNode", "node", "=", "new", "ImportNode", "(", "type", ")", ";", "node", ".", "addAnnotations", "(", "annotations", ")", ";", "staticStarImports", ".", "put", "(", "name", ",", "node", ")", ";", "}", "public", "String", "getMainClassName", "(", ")", "{", "return", "mainClassName", ";", "}", "}", "</s>" ]
6,913
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "GroovyCodeVisitor", ";", "public", "class", "EmptyExpression", "extends", "Expression", "{", "public", "static", "final", "EmptyExpression", "INSTANCE", "=", "new", "EmptyExpression", "(", ")", ";", "public", "Expression", "transformExpression", "(", "ExpressionTransformer", "transformer", ")", "{", "return", "this", ";", "}", "public", "void", "visit", "(", "GroovyCodeVisitor", "visitor", ")", "{", "visitor", ".", "visitEmptyExpression", "(", "this", ")", ";", "return", ";", "}", "}", "</s>" ]
6,914
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "groovy", ".", "lang", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "runtime", ".", "GeneratedClosure", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "util", ".", "ManagedConcurrentMap", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "util", ".", "ReferenceBundle", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "vmplugin", ".", "VMPluginFactory", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "java", ".", "math", ".", "BigDecimal", ";", "import", "java", ".", "math", ".", "BigInteger", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "java", ".", "lang", ".", "ref", ".", "SoftReference", ";", "public", "class", "ClassHelper", "{", "public", "static", "final", "Class", "[", "]", "classes", "=", "new", "Class", "[", "]", "{", "Object", ".", "class", ",", "Boolean", ".", "TYPE", ",", "Character", ".", "TYPE", ",", "Byte", ".", "TYPE", ",", "Short", ".", "TYPE", ",", "Integer", ".", "TYPE", ",", "Long", ".", "TYPE", ",", "Double", ".", "TYPE", ",", "Float", ".", "TYPE", ",", "Void", ".", "TYPE", ",", "Closure", ".", "class", ",", "GString", ".", "class", ",", "List", ".", "class", ",", "Map", ".", "class", ",", "Range", ".", "class", ",", "Pattern", ".", "class", ",", "Script", ".", "class", ",", "String", ".", "class", ",", "Boolean", ".", "class", ",", "Character", ".", "class", ",", "Byte", ".", "class", ",", "Short", ".", "class", ",", "Integer", ".", "class", ",", "Long", ".", "class", ",", "Double", ".", "class", ",", "Float", ".", "class", ",", "BigDecimal", ".", "class", ",", "BigInteger", ".", "class", ",", "Number", ".", "class", ",", "Void", ".", "class", ",", "Reference", ".", "class", ",", "Class", ".", "class", ",", "MetaClass", ".", "class", ",", "Iterator", ".", "class", ",", "GeneratedClosure", ".", "class", ",", "GroovyObjectSupport", ".", "class", "}", ";", "private", "static", "final", "String", "[", "]", "primitiveClassNames", "=", "new", "String", "[", "]", "{", "\"\"", ",", "\"boolean\"", ",", "\"char\"", ",", "\"byte\"", ",", "\"short\"", ",", "\"int\"", ",", "\"long\"", ",", "\"double\"", ",", "\"float\"", ",", "\"void\"", "}", ";", "public", "static", "final", "ClassNode", "DYNAMIC_TYPE", "=", "makeCached", "(", "Object", ".", "class", ")", ",", "OBJECT_TYPE", "=", "DYNAMIC_TYPE", ",", "VOID_TYPE", "=", "makeCached", "(", "Void", ".", "TYPE", ")", ",", "CLOSURE_TYPE", "=", "makeCached", "(", "Closure", ".", "class", ")", ",", "GSTRING_TYPE", "=", "makeCached", "(", "GString", ".", "class", ")", ",", "LIST_TYPE", "=", "makeWithoutCaching", "(", "List", ".", "class", ")", ",", "MAP_TYPE", "=", "makeWithoutCaching", "(", "Map", ".", "class", ")", ",", "RANGE_TYPE", "=", "makeCached", "(", "Range", ".", "class", ")", ",", "PATTERN_TYPE", "=", "makeCached", "(", "Pattern", ".", "class", ")", ",", "STRING_TYPE", "=", "makeCached", "(", "String", ".", "class", ")", ",", "SCRIPT_TYPE", "=", "makeCached", "(", "Script", ".", "class", ")", ",", "REFERENCE_TYPE", "=", "makeWithoutCaching", "(", "Reference", ".", "class", ")", ",", "boolean_TYPE", "=", "makeCached", "(", "boolean", ".", "class", ")", ",", "char_TYPE", "=", "makeCached", "(", "char", ".", "class", ")", ",", "byte_TYPE", "=", "makeCached", "(", "byte", ".", "class", ")", ",", "int_TYPE", "=", "makeCached", "(", "int", ".", "class", ")", ",", "long_TYPE", "=", "makeCached", "(", "long", ".", "class", ")", ",", "short_TYPE", "=", "makeCached", "(", "short", ".", "class", ")", ",", "double_TYPE", "=", "makeCached", "(", "double", ".", "class", ")", ",", "float_TYPE", "=", "makeCached", "(", "float", ".", "class", ")", ",", "Byte_TYPE", "=", "makeCached", "(", "Byte", ".", "class", ")", ",", "Short_TYPE", "=", "makeCached", "(", "Short", ".", "class", ")", ",", "Integer_TYPE", "=", "makeCached", "(", "Integer", ".", "class", ")", ",", "Long_TYPE", "=", "makeCached", "(", "Long", ".", "class", ")", ",", "Character_TYPE", "=", "makeCached", "(", "Character", ".", "class", ")", ",", "Float_TYPE", "=", "makeCached", "(", "Float", ".", "class", ")", ",", "Double_TYPE", "=", "makeCached", "(", "Double", ".", "class", ")", ",", "Boolean_TYPE", "=", "makeCached", "(", "Boolean", ".", "class", ")", ",", "BigInteger_TYPE", "=", "makeCached", "(", "java", ".", "math", ".", "BigInteger", ".", "class", ")", ",", "BigDecimal_TYPE", "=", "makeCached", "(", "java", ".", "math", ".", "BigDecimal", ".", "class", ")", ",", "Number_TYPE", "=", "makeCached", "(", "Number", ".", "class", ")", ",", "void_WRAPPER_TYPE", "=", "makeCached", "(", "Void", ".", "class", ")", ",", "METACLASS_TYPE", "=", "makeCached", "(", "MetaClass", ".", "class", ")", ",", "Iterator_TYPE", "=", "makeCached", "(", "Iterator", ".", "class", ")", ",", "CLASS_Type", "=", "makeWithoutCaching", "(", "Class", ".", "class", ")", ",", "COMPARABLE_TYPE", "=", "makeWithoutCaching", "(", "Comparable", ".", "class", ")", ",", "GENERATED_CLOSURE_Type", "=", "makeWithoutCaching", "(", "GeneratedClosure", ".", "class", ")", ",", "GROOVY_OBJECT_SUPPORT_TYPE", "=", "makeWithoutCaching", "(", "GroovyObjectSupport", ".", "class", ")", ",", "GROOVY_OBJECT_TYPE", "=", "makeWithoutCaching", "(", "GroovyObject", ".", "class", ")", ",", "GROOVY_INTERCEPTABLE_TYPE", "=", "makeWithoutCaching", "(", "GroovyInterceptable", ".", "class", ")", ",", "Enum_Type", "=", "new", "ClassNode", "(", "\"\"", ",", "0", ",", "OBJECT_TYPE", ")", ",", "Annotation_TYPE", "=", "new", "ClassNode", "(", "\"\"", ",", "0", ",", "OBJECT_TYPE", ")", ",", "ELEMENT_TYPE_TYPE", "=", "new", "ClassNode", "(", "\"\"", ",", "0", ",", "Enum_Type", ")", ";", "static", "{", "Enum_Type", ".", "isPrimaryNode", "=", "false", ";", "Annotation_TYPE", ".", "isPrimaryNode", "=", "false", ";", "}", "private", "static", "ClassNode", "[", "]", "types", "=", "new", "ClassNode", "[", "]", "{", "OBJECT_TYPE", ",", "boolean_TYPE", ",", "char_TYPE", ",", "byte_TYPE", ",", "short_TYPE", ",", "int_TYPE", ",", "long_TYPE", ",", "double_TYPE", ",", "float_TYPE", ",", "VOID_TYPE", ",", "CLOSURE_TYPE", ",", "GSTRING_TYPE", ",", "LIST_TYPE", ",", "MAP_TYPE", ",", "RANGE_TYPE", ",", "PATTERN_TYPE", ",", "SCRIPT_TYPE", ",", "STRING_TYPE", ",", "Boolean_TYPE", ",", "Character_TYPE", ",", "Byte_TYPE", ",", "Short_TYPE", ",", "Integer_TYPE", ",", "Long_TYPE", ",", "Double_TYPE", ",", "Float_TYPE", ",", "BigDecimal_TYPE", ",", "BigInteger_TYPE", ",", "Number_TYPE", ",", "void_WRAPPER_TYPE", ",", "REFERENCE_TYPE", ",", "CLASS_Type", ",", "METACLASS_TYPE", ",", "Iterator_TYPE", ",", "GENERATED_CLOSURE_Type", ",", "GROOVY_OBJECT_SUPPORT_TYPE", ",", "GROOVY_OBJECT_TYPE", ",", "GROOVY_INTERCEPTABLE_TYPE", ",", "Enum_Type", ",", "Annotation_TYPE", "}", ";", "private", "static", "ClassNode", "[", "]", "numbers", "=", "new", "ClassNode", "[", "]", "{", "char_TYPE", ",", "byte_TYPE", ",", "short_TYPE", ",", "int_TYPE", ",", "long_TYPE", ",", "double_TYPE", ",", "float_TYPE", ",", "Short_TYPE", ",", "Byte_TYPE", ",", "Character_TYPE", ",", "Integer_TYPE", ",", "Float_TYPE", ",", "Long_TYPE", ",", "Double_TYPE", ",", "BigInteger_TYPE", ",", "BigDecimal_TYPE", "}", ";", "protected", "static", "final", "ClassNode", "[", "]", "EMPTY_TYPE_ARRAY", "=", "{", "}", ";", "public", "static", "final", "String", "OBJECT", "=", "\"\"", ";", "public", "static", "ClassNode", "makeCached", "(", "Class", "c", ")", "{", "final", "SoftReference", "<", "ClassNode", ">", "classNodeSoftReference", "=", "ClassHelperCache", ".", "classCache", ".", "get", "(", "c", ")", ";", "ClassNode", "classNode", ";", "if", "(", "classNodeSoftReference", "==", "null", "||", "(", "classNode", "=", "classNodeSoftReference", ".", "get", "(", ")", ")", "==", "null", ")", "{", "classNode", "=", "new", "ImmutableClassNode", "(", "c", ")", ";", "ClassHelperCache", ".", "classCache", ".", "put", "(", "c", ",", "new", "SoftReference", "<", "ClassNode", ">", "(", "classNode", ")", ")", ";", "VMPluginFactory", ".", "getPlugin", "(", ")", ".", "setAdditionalClassInformation", "(", "classNode", ")", ";", "}", "return", "classNode", ";", "}", "public", "static", "ClassNode", "[", "]", "make", "(", "Class", "[", "]", "classes", ")", "{", "ClassNode", "[", "]", "cns", "=", "new", "ClassNode", "[", "classes", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cns", ".", "length", ";", "i", "++", ")", "{", "cns", "[", "i", "]", "=", "make", "(", "classes", "[", "i", "]", ")", ";", "}", "return", "cns", ";", "}", "public", "static", "ClassNode", "make", "(", "Class", "c", ")", "{", "return", "make", "(", "c", ",", "true", ")", ";", "}", "public", "static", "ClassNode", "make", "(", "Class", "c", ",", "boolean", "includeGenerics", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "classes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "c", "==", "classes", "[", "i", "]", ")", "return", "types", "[", "i", "]", ";", "}", "if", "(", "c", ".", "isArray", "(", ")", ")", "{", "ClassNode", "cn", "=", "make", "(", "c", ".", "getComponentType", "(", ")", ",", "includeGenerics", ")", ";", "return", "cn", ".", "makeArray", "(", ")", ";", "}", "return", "makeWithoutCaching", "(", "c", ",", "includeGenerics", ")", ";", "}", "public", "static", "ClassNode", "makeWithoutCaching", "(", "Class", "c", ")", "{", "return", "makeWithoutCaching", "(", "c", ",", "true", ")", ";", "}", "public", "static", "ClassNode", "makeWithoutCaching", "(", "Class", "c", ",", "boolean", "includeGenerics", ")", "{", "if", "(", "c", ".", "isArray", "(", ")", ")", "{", "ClassNode", "cn", "=", "makeWithoutCaching", "(", "c", ".", "getComponentType", "(", ")", ",", "includeGenerics", ")", ";", "return", "cn", ".", "makeArray", "(", ")", ";", "}", "final", "ClassNode", "cached", "=", "makeCached", "(", "c", ")", ";", "if", "(", "includeGenerics", ")", "{", "return", "cached", ";", "}", "else", "{", "ClassNode", "t", "=", "makeWithoutCaching", "(", "c", ".", "getName", "(", ")", ")", ";", "t", ".", "setRedirect", "(", "cached", ")", ";", "return", "t", ";", "}", "}", "public", "static", "ClassNode", "makeWithoutCaching", "(", "String", "name", ")", "{", "ClassNode", "cn", "=", "new", "ClassNode", "(", "name", ",", "Opcodes", ".", "ACC_PUBLIC", ",", "OBJECT_TYPE", ")", ";", "cn", ".", "isPrimaryNode", "=", "false", ";", "return", "cn", ";", "}", "public", "static", "ClassNode", "make", "(", "String", "name", ")", "{", "if", "(", "name", "==", "null", "||", "name", ".", "length", "(", ")", "==", "0", ")", "return", "DYNAMIC_TYPE", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "primitiveClassNames", ".", "length", ";", "i", "++", ")", "{", "if", "(", "primitiveClassNames", "[", "i", "]", ".", "equals", "(", "name", ")", ")", "return", "types", "[", "i", "]", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "classes", ".", "length", ";", "i", "++", ")", "{", "String", "cname", "=", "classes", "[", "i", "]", ".", "getName", "(", ")", ";", "if", "(", "name", ".", "equals", "(", "cname", ")", ")", "return", "types", "[", "i", "]", ";", "}", "return", "makeWithoutCaching", "(", "name", ")", ";", "}", "public", "static", "ClassNode", "getWrapper", "(", "ClassNode", "cn", ")", "{", "cn", "=", "cn", ".", "redirect", "(", ")", ";", "if", "(", "!", "isPrimitiveType", "(", "cn", ")", ")", "return", "cn", ";", "if", "(", "cn", "==", "boolean_TYPE", ")", "{", "return", "Boolean_TYPE", ";", "}", "else", "if", "(", "cn", "==", "byte_TYPE", ")", "{", "return", "Byte_TYPE", ";", "}", "else", "if", "(", "cn", "==", "char_TYPE", ")", "{", "return", "Character_TYPE", ";", "}", "else", "if", "(", "cn", "==", "short_TYPE", ")", "{", "return", "Short_TYPE", ";", "}", "else", "if", "(", "cn", "==", "int_TYPE", ")", "{", "return", "Integer_TYPE", ";", "}", "else", "if", "(", "cn", "==", "long_TYPE", ")", "{", "return", "Long_TYPE", ";", "}", "else", "if", "(", "cn", "==", "float_TYPE", ")", "{", "return", "Float_TYPE", ";", "}", "else", "if", "(", "cn", "==", "double_TYPE", ")", "{", "return", "Double_TYPE", ";", "}", "else", "if", "(", "cn", "==", "VOID_TYPE", ")", "{", "return", "void_WRAPPER_TYPE", ";", "}", "else", "{", "return", "cn", ";", "}", "}", "public", "static", "ClassNode", "getUnwrapper", "(", "ClassNode", "cn", ")", "{", "cn", "=", "cn", ".", "redirect", "(", ")", ";", "if", "(", "isPrimitiveType", "(", "cn", ")", ")", "return", "cn", ";", "if", "(", "cn", "==", "Boolean_TYPE", ")", "{", "return", "boolean_TYPE", ";", "}", "else", "if", "(", "cn", "==", "Byte_TYPE", ")", "{", "return", "byte_TYPE", ";", "}", "else", "if", "(", "cn", "==", "Character_TYPE", ")", "{", "return", "char_TYPE", ";", "}", "else", "if", "(", "cn", "==", "Short_TYPE", ")", "{", "return", "short_TYPE", ";", "}", "else", "if", "(", "cn", "==", "Integer_TYPE", ")", "{", "return", "int_TYPE", ";", "}", "else", "if", "(", "cn", "==", "Long_TYPE", ")", "{", "return", "long_TYPE", ";", "}", "else", "if", "(", "cn", "==", "Float_TYPE", ")", "{", "return", "float_TYPE", ";", "}", "else", "if", "(", "cn", "==", "Double_TYPE", ")", "{", "return", "double_TYPE", ";", "}", "else", "{", "return", "cn", ";", "}", "}", "public", "static", "boolean", "isPrimitiveType", "(", "ClassNode", "cn", ")", "{", "return", "cn", "==", "boolean_TYPE", "||", "cn", "==", "char_TYPE", "||", "cn", "==", "byte_TYPE", "||", "cn", "==", "short_TYPE", "||", "cn", "==", "int_TYPE", "||", "cn", "==", "long_TYPE", "||", "cn", "==", "float_TYPE", "||", "cn", "==", "double_TYPE", "||", "cn", "==", "VOID_TYPE", ";", "}", "public", "static", "boolean", "isStaticConstantInitializerType", "(", "ClassNode", "cn", ")", "{", "return", "cn", "==", "int_TYPE", "||", "cn", "==", "float_TYPE", "||", "cn", "==", "long_TYPE", "||", "cn", "==", "double_TYPE", "||", "cn", "==", "STRING_TYPE", "||", "cn", "==", "byte_TYPE", "||", "cn", "==", "char_TYPE", "||", "cn", "==", "short_TYPE", ";", "}", "public", "static", "boolean", "isNumberType", "(", "ClassNode", "cn", ")", "{", "return", "cn", ".", "equals", "(", "Byte_TYPE", ")", "||", "cn", ".", "equals", "(", "Short_TYPE", ")", "||", "cn", ".", "equals", "(", "Integer_TYPE", ")", "||", "cn", ".", "equals", "(", "Long_TYPE", ")", "||", "cn", ".", "equals", "(", "Float_TYPE", ")", "||", "cn", ".", "equals", "(", "Double_TYPE", ")", "||", "cn", "==", "byte_TYPE", "||", "cn", "==", "short_TYPE", "||", "cn", "==", "int_TYPE", "||", "cn", "==", "long_TYPE", "||", "cn", "==", "float_TYPE", "||", "cn", "==", "double_TYPE", ";", "}", "public", "static", "ClassNode", "makeReference", "(", ")", "{", "return", "REFERENCE_TYPE", ".", "getPlainNodeReference", "(", ")", ";", "}", "public", "static", "boolean", "isCachedType", "(", "ClassNode", "type", ")", "{", "for", "(", "ClassNode", "cachedType", ":", "types", ")", "{", "if", "(", "cachedType", "==", "type", ")", "return", "true", ";", "}", "return", "false", ";", "}", "static", "class", "ClassHelperCache", "{", "static", "ManagedConcurrentMap", "<", "Class", ",", "SoftReference", "<", "ClassNode", ">", ">", "classCache", "=", "new", "ManagedConcurrentMap", "<", "Class", ",", "SoftReference", "<", "ClassNode", ">", ">", "(", "ReferenceBundle", ".", "getWeakBundle", "(", ")", ")", ";", "}", "}", "</s>" ]
6,915
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "DeclarationExpression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "Expression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "AssertStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "BlockStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "BreakStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "CaseStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "CatchStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "ContinueStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "DoWhileStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "ExpressionStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "ForStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "IfStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "ReturnStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "Statement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "SwitchStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "SynchronizedStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "ThrowStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "TryCatchStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "WhileStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "SourceUnit", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "SyntaxErrorMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "SyntaxException", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "PreciseSyntaxException", ";", "public", "abstract", "class", "ClassCodeVisitorSupport", "extends", "CodeVisitorSupport", "implements", "GroovyClassVisitor", "{", "public", "void", "visitClass", "(", "ClassNode", "node", ")", "{", "visitAnnotations", "(", "node", ")", ";", "visitPackage", "(", "node", ".", "getPackage", "(", ")", ")", ";", "visitImports", "(", "node", ".", "getModule", "(", ")", ")", ";", "node", ".", "visitContents", "(", "this", ")", ";", "visitObjectInitializerStatements", "(", "node", ")", ";", "}", "protected", "void", "visitObjectInitializerStatements", "(", "ClassNode", "node", ")", "{", "for", "(", "Statement", "element", ":", "node", ".", "getObjectInitializerStatements", "(", ")", ")", "{", "element", ".", "visit", "(", "this", ")", ";", "}", "}", "public", "void", "visitPackage", "(", "PackageNode", "node", ")", "{", "if", "(", "node", "!=", "null", ")", "{", "visitAnnotations", "(", "node", ")", ";", "node", ".", "visit", "(", "this", ")", ";", "}", "}", "public", "void", "visitImports", "(", "ModuleNode", "node", ")", "{", "if", "(", "node", "!=", "null", ")", "{", "for", "(", "ImportNode", "importNode", ":", "node", ".", "getImports", "(", ")", ")", "{", "visitAnnotations", "(", "importNode", ")", ";", "importNode", ".", "visit", "(", "this", ")", ";", "}", "for", "(", "ImportNode", "importStarNode", ":", "node", ".", "getStarImports", "(", ")", ")", "{", "visitAnnotations", "(", "importStarNode", ")", ";", "importStarNode", ".", "visit", "(", "this", ")", ";", "}", "for", "(", "ImportNode", "importStaticNode", ":", "node", ".", "getStaticImports", "(", ")", ".", "values", "(", ")", ")", "{", "visitAnnotations", "(", "importStaticNode", ")", ";", "importStaticNode", ".", "visit", "(", "this", ")", ";", "}", "for", "(", "ImportNode", "importStaticStarNode", ":", "node", ".", "getStaticStarImports", "(", ")", ".", "values", "(", ")", ")", "{", "visitAnnotations", "(", "importStaticStarNode", ")", ";", "importStaticStarNode", ".", "visit", "(", "this", ")", ";", "}", "}", "}", "public", "void", "visitAnnotations", "(", "AnnotatedNode", "node", ")", "{", "List", "<", "AnnotationNode", ">", "annotations", "=", "node", ".", "getAnnotations", "(", ")", ";", "if", "(", "annotations", ".", "isEmpty", "(", ")", ")", "return", ";", "for", "(", "AnnotationNode", "an", ":", "annotations", ")", "{", "if", "(", "an", ".", "isBuiltIn", "(", ")", ")", "continue", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Expression", ">", "member", ":", "an", ".", "getMembers", "(", ")", ".", "entrySet", "(", ")", ")", "{", "member", ".", "getValue", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "}", "}", "protected", "void", "visitClassCodeContainer", "(", "Statement", "code", ")", "{", "if", "(", "code", "!=", "null", ")", "code", ".", "visit", "(", "this", ")", ";", "}", "@", "Override", "public", "void", "visitDeclarationExpression", "(", "DeclarationExpression", "expression", ")", "{", "visitAnnotations", "(", "expression", ")", ";", "super", ".", "visitDeclarationExpression", "(", "expression", ")", ";", "}", "protected", "void", "visitConstructorOrMethod", "(", "MethodNode", "node", ",", "boolean", "isConstructor", ")", "{", "visitAnnotations", "(", "node", ")", ";", "visitClassCodeContainer", "(", "node", ".", "getCode", "(", ")", ")", ";", "for", "(", "Parameter", "param", ":", "node", ".", "getParameters", "(", ")", ")", "{", "visitAnnotations", "(", "param", ")", ";", "}", "}", "public", "void", "visitConstructor", "(", "ConstructorNode", "node", ")", "{", "visitConstructorOrMethod", "(", "node", ",", "true", ")", ";", "}", "public", "void", "visitMethod", "(", "MethodNode", "node", ")", "{", "visitConstructorOrMethod", "(", "node", ",", "false", ")", ";", "}", "public", "void", "visitField", "(", "FieldNode", "node", ")", "{", "visitAnnotations", "(", "node", ")", ";", "Expression", "init", "=", "node", ".", "getInitialExpression", "(", ")", ";", "if", "(", "init", "!=", "null", ")", "init", ".", "visit", "(", "this", ")", ";", "}", "public", "void", "visitProperty", "(", "PropertyNode", "node", ")", "{", "visitAnnotations", "(", "node", ")", ";", "Statement", "statement", "=", "node", ".", "getGetterBlock", "(", ")", ";", "visitClassCodeContainer", "(", "statement", ")", ";", "statement", "=", "node", ".", "getSetterBlock", "(", ")", ";", "visitClassCodeContainer", "(", "statement", ")", ";", "Expression", "init", "=", "node", ".", "getInitialExpression", "(", ")", ";", "if", "(", "init", "!=", "null", ")", "init", ".", "visit", "(", "this", ")", ";", "}", "protected", "void", "addError", "(", "String", "msg", ",", "ASTNode", "expr", ")", "{", "int", "line", "=", "expr", ".", "getLineNumber", "(", ")", ";", "int", "col", "=", "expr", ".", "getColumnNumber", "(", ")", ";", "SourceUnit", "source", "=", "getSourceUnit", "(", ")", ";", "source", ".", "getErrorCollector", "(", ")", ".", "addErrorAndContinue", "(", "new", "SyntaxErrorMessage", "(", "new", "SyntaxException", "(", "msg", "+", "'\\n'", ",", "line", ",", "col", ")", ",", "source", ")", ")", ";", "}", "protected", "void", "addTypeError", "(", "String", "msg", ",", "ClassNode", "expr", ")", "{", "int", "line", "=", "expr", ".", "getLineNumber", "(", ")", ";", "int", "col", "=", "expr", ".", "getColumnNumber", "(", ")", ";", "SourceUnit", "source", "=", "getSourceUnit", "(", ")", ";", "source", ".", "getErrorCollector", "(", ")", ".", "addErrorAndContinue", "(", "new", "SyntaxErrorMessage", "(", "new", "PreciseSyntaxException", "(", "msg", "+", "'\\n'", ",", "line", ",", "col", ",", "expr", ".", "getNameStart", "(", ")", ",", "expr", ".", "getNameEnd", "(", ")", ")", ",", "source", ")", ")", ";", "}", "protected", "abstract", "SourceUnit", "getSourceUnit", "(", ")", ";", "protected", "void", "visitStatement", "(", "Statement", "statement", ")", "{", "}", "public", "void", "visitAssertStatement", "(", "AssertStatement", "statement", ")", "{", "visitStatement", "(", "statement", ")", ";", "super", ".", "visitAssertStatement", "(", "statement", ")", ";", "}", "public", "void", "visitBlockStatement", "(", "BlockStatement", "block", ")", "{", "visitStatement", "(", "block", ")", ";", "super", ".", "visitBlockStatement", "(", "block", ")", ";", "}", "public", "void", "visitBreakStatement", "(", "BreakStatement", "statement", ")", "{", "visitStatement", "(", "statement", ")", ";", "super", ".", "visitBreakStatement", "(", "statement", ")", ";", "}", "public", "void", "visitCaseStatement", "(", "CaseStatement", "statement", ")", "{", "visitStatement", "(", "statement", ")", ";", "super", ".", "visitCaseStatement", "(", "statement", ")", ";", "}", "public", "void", "visitCatchStatement", "(", "CatchStatement", "statement", ")", "{", "visitStatement", "(", "statement", ")", ";", "super", ".", "visitCatchStatement", "(", "statement", ")", ";", "}", "public", "void", "visitContinueStatement", "(", "ContinueStatement", "statement", ")", "{", "visitStatement", "(", "statement", ")", ";", "super", ".", "visitContinueStatement", "(", "statement", ")", ";", "}", "public", "void", "visitDoWhileLoop", "(", "DoWhileStatement", "loop", ")", "{", "visitStatement", "(", "loop", ")", ";", "super", ".", "visitDoWhileLoop", "(", "loop", ")", ";", "}", "public", "void", "visitExpressionStatement", "(", "ExpressionStatement", "statement", ")", "{", "visitStatement", "(", "statement", ")", ";", "super", ".", "visitExpressionStatement", "(", "statement", ")", ";", "}", "public", "void", "visitForLoop", "(", "ForStatement", "forLoop", ")", "{", "visitStatement", "(", "forLoop", ")", ";", "super", ".", "visitForLoop", "(", "forLoop", ")", ";", "}", "public", "void", "visitIfElse", "(", "IfStatement", "ifElse", ")", "{", "visitStatement", "(", "ifElse", ")", ";", "super", ".", "visitIfElse", "(", "ifElse", ")", ";", "}", "public", "void", "visitReturnStatement", "(", "ReturnStatement", "statement", ")", "{", "visitStatement", "(", "statement", ")", ";", "super", ".", "visitReturnStatement", "(", "statement", ")", ";", "}", "public", "void", "visitSwitch", "(", "SwitchStatement", "statement", ")", "{", "visitStatement", "(", "statement", ")", ";", "super", ".", "visitSwitch", "(", "statement", ")", ";", "}", "public", "void", "visitSynchronizedStatement", "(", "SynchronizedStatement", "statement", ")", "{", "visitStatement", "(", "statement", ")", ";", "super", ".", "visitSynchronizedStatement", "(", "statement", ")", ";", "}", "public", "void", "visitThrowStatement", "(", "ThrowStatement", "statement", ")", "{", "visitStatement", "(", "statement", ")", ";", "super", ".", "visitThrowStatement", "(", "statement", ")", ";", "}", "public", "void", "visitTryCatchFinally", "(", "TryCatchStatement", "statement", ")", "{", "visitStatement", "(", "statement", ")", ";", "super", ".", "visitTryCatchFinally", "(", "statement", ")", ";", "}", "public", "void", "visitWhileLoop", "(", "WhileStatement", "loop", ")", "{", "visitStatement", "(", "loop", ")", ";", "super", ".", "visitWhileLoop", "(", "loop", ")", ";", "}", "}", "</s>" ]
6,916
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "GroovyBugError", ";", "class", "ImmutableClassNode", "extends", "ClassNode", "{", "class", "ImmutableGenericsType", "extends", "GenericsType", "{", "ImmutableGenericsType", "(", "GenericsType", "delegate", ")", "{", "super", ".", "setType", "(", "delegate", ".", "getType", "(", ")", ")", ";", "super", ".", "setPlaceholder", "(", "delegate", ".", "isPlaceholder", "(", ")", ")", ";", "super", ".", "setResolved", "(", "delegate", ".", "isResolved", "(", ")", ")", ";", "super", ".", "setName", "(", "delegate", ".", "getName", "(", ")", ")", ";", "super", ".", "setWildcard", "(", "delegate", ".", "isWildcard", "(", ")", ")", ";", "super", ".", "setUpperBounds", "(", "delegate", ".", "getUpperBounds", "(", ")", ")", ";", "super", ".", "setLowerBound", "(", "delegate", ".", "getLowerBound", "(", ")", ")", ";", "}", "@", "Override", "public", "void", "setType", "(", "ClassNode", "type", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "ImmutableClassNode", ".", "this", ".", "getName", "(", ")", ")", ";", "}", "@", "Override", "public", "void", "setPlaceholder", "(", "boolean", "placeholder", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "ImmutableClassNode", ".", "this", ".", "getName", "(", ")", ")", ";", "}", "@", "Override", "public", "void", "setResolved", "(", "boolean", "res", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "ImmutableClassNode", ".", "this", ".", "getName", "(", ")", ")", ";", "}", "@", "Override", "public", "void", "setName", "(", "String", "name", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "ImmutableClassNode", ".", "this", ".", "getName", "(", ")", ")", ";", "}", "@", "Override", "public", "void", "setWildcard", "(", "boolean", "wildcard", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "ImmutableClassNode", ".", "this", ".", "getName", "(", ")", ")", ";", "}", "@", "Override", "public", "void", "setUpperBounds", "(", "ClassNode", "[", "]", "bounds", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "ImmutableClassNode", ".", "this", ".", "getName", "(", ")", ")", ";", "}", "@", "Override", "public", "void", "setLowerBound", "(", "ClassNode", "bound", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "ImmutableClassNode", ".", "this", ".", "getName", "(", ")", ")", ";", "}", "}", "private", "boolean", "genericsInitialized", "=", "false", ";", "public", "ImmutableClassNode", "(", "Class", "c", ")", "{", "super", "(", "c", ")", ";", "}", "@", "Override", "public", "void", "setGenericsTypes", "(", "GenericsType", "[", "]", "genericsTypes", ")", "{", "if", "(", "genericsInitialized", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "this", ".", "getName", "(", ")", ")", ";", "}", "if", "(", "genericsTypes", "!=", "null", ")", "{", "GenericsType", "[", "]", "immutable", "=", "new", "GenericsType", "[", "genericsTypes", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "genericsTypes", ".", "length", ";", "i", "++", ")", "{", "immutable", "[", "i", "]", "=", "new", "ImmutableGenericsType", "(", "genericsTypes", "[", "i", "]", ")", ";", "}", "genericsTypes", "=", "immutable", ";", "}", "super", ".", "setGenericsTypes", "(", "genericsTypes", ")", ";", "genericsInitialized", "=", "true", ";", "}", "}", "</s>" ]
6,917
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "java", ".", "util", ".", "*", ";", "public", "class", "AnnotatedNode", "extends", "ASTNode", "{", "private", "List", "<", "AnnotationNode", ">", "annotations", "=", "Collections", ".", "emptyList", "(", ")", ";", "private", "boolean", "synthetic", ";", "ClassNode", "declaringClass", ";", "private", "boolean", "hasNoRealSourcePositionFlag", ";", "private", "int", "nameEnd", ";", "private", "int", "nameStart", ";", "public", "AnnotatedNode", "(", ")", "{", "}", "public", "List", "<", "AnnotationNode", ">", "getAnnotations", "(", ")", "{", "return", "annotations", ";", "}", "public", "List", "<", "AnnotationNode", ">", "getAnnotations", "(", "ClassNode", "type", ")", "{", "List", "<", "AnnotationNode", ">", "ret", "=", "new", "ArrayList", "<", "AnnotationNode", ">", "(", "annotations", ".", "size", "(", ")", ")", ";", "for", "(", "AnnotationNode", "node", ":", "annotations", ")", "{", "if", "(", "type", ".", "equals", "(", "node", ".", "getClassNode", "(", ")", ")", ")", "ret", ".", "add", "(", "node", ")", ";", "}", "return", "ret", ";", "}", "public", "void", "addAnnotation", "(", "AnnotationNode", "value", ")", "{", "checkInit", "(", ")", ";", "annotations", ".", "add", "(", "value", ")", ";", "}", "private", "void", "checkInit", "(", ")", "{", "if", "(", "annotations", "==", "Collections", ".", "EMPTY_LIST", ")", "annotations", "=", "new", "ArrayList", "<", "AnnotationNode", ">", "(", "3", ")", ";", "}", "public", "void", "addAnnotations", "(", "List", "<", "AnnotationNode", ">", "annotations", ")", "{", "for", "(", "AnnotationNode", "node", ":", "annotations", ")", "{", "addAnnotation", "(", "node", ")", ";", "}", "}", "public", "boolean", "isSynthetic", "(", ")", "{", "return", "synthetic", ";", "}", "public", "void", "setSynthetic", "(", "boolean", "synthetic", ")", "{", "this", ".", "synthetic", "=", "synthetic", ";", "}", "public", "ClassNode", "getDeclaringClass", "(", ")", "{", "return", "declaringClass", ";", "}", "public", "void", "setDeclaringClass", "(", "ClassNode", "declaringClass", ")", "{", "this", ".", "declaringClass", "=", "declaringClass", ";", "}", "public", "boolean", "hasNoRealSourcePosition", "(", ")", "{", "return", "hasNoRealSourcePositionFlag", ";", "}", "public", "void", "setHasNoRealSourcePosition", "(", "boolean", "value", ")", "{", "this", ".", "hasNoRealSourcePositionFlag", "=", "value", ";", "}", "public", "int", "getNameStart", "(", ")", "{", "return", "nameStart", ";", "}", "public", "void", "setNameStart", "(", "int", "nameStart", ")", "{", "this", ".", "nameStart", "=", "nameStart", ";", "}", "public", "int", "getNameEnd", "(", ")", "{", "return", "nameEnd", ";", "}", "public", "void", "setNameEnd", "(", "int", "nameEnd", ")", "{", "this", ".", "nameEnd", "=", "nameEnd", ";", "}", "@", "Override", "public", "void", "setSourcePosition", "(", "ASTNode", "node", ")", "{", "super", ".", "setSourcePosition", "(", "node", ")", ";", "if", "(", "node", "instanceof", "AnnotatedNode", ")", "{", "AnnotatedNode", "aNode", "=", "(", "AnnotatedNode", ")", "node", ";", "setNameStart", "(", "aNode", ".", "getNameStart", "(", ")", ")", ";", "setNameEnd", "(", "aNode", ".", "getNameEnd", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
6,918
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "ast", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "classgen", ".", "BytecodeExpression", ";", "public", "interface", "GroovyCodeVisitor", "{", "void", "visitBlockStatement", "(", "BlockStatement", "statement", ")", ";", "void", "visitForLoop", "(", "ForStatement", "forLoop", ")", ";", "void", "visitWhileLoop", "(", "WhileStatement", "loop", ")", ";", "void", "visitDoWhileLoop", "(", "DoWhileStatement", "loop", ")", ";", "void", "visitIfElse", "(", "IfStatement", "ifElse", ")", ";", "void", "visitExpressionStatement", "(", "ExpressionStatement", "statement", ")", ";", "void", "visitReturnStatement", "(", "ReturnStatement", "statement", ")", ";", "void", "visitAssertStatement", "(", "AssertStatement", "statement", ")", ";", "void", "visitTryCatchFinally", "(", "TryCatchStatement", "finally1", ")", ";", "void", "visitSwitch", "(", "SwitchStatement", "statement", ")", ";", "void", "visitCaseStatement", "(", "CaseStatement", "statement", ")", ";", "void", "visitBreakStatement", "(", "BreakStatement", "statement", ")", ";", "void", "visitContinueStatement", "(", "ContinueStatement", "statement", ")", ";", "void", "visitThrowStatement", "(", "ThrowStatement", "statement", ")", ";", "void", "visitSynchronizedStatement", "(", "SynchronizedStatement", "statement", ")", ";", "void", "visitCatchStatement", "(", "CatchStatement", "statement", ")", ";", "void", "visitMethodCallExpression", "(", "MethodCallExpression", "call", ")", ";", "void", "visitStaticMethodCallExpression", "(", "StaticMethodCallExpression", "expression", ")", ";", "void", "visitConstructorCallExpression", "(", "ConstructorCallExpression", "expression", ")", ";", "void", "visitTernaryExpression", "(", "TernaryExpression", "expression", ")", ";", "void", "visitShortTernaryExpression", "(", "ElvisOperatorExpression", "expression", ")", ";", "void", "visitBinaryExpression", "(", "BinaryExpression", "expression", ")", ";", "void", "visitPrefixExpression", "(", "PrefixExpression", "expression", ")", ";", "void", "visitPostfixExpression", "(", "PostfixExpression", "expression", ")", ";", "void", "visitBooleanExpression", "(", "BooleanExpression", "expression", ")", ";", "void", "visitClosureExpression", "(", "ClosureExpression", "expression", ")", ";", "void", "visitTupleExpression", "(", "TupleExpression", "expression", ")", ";", "void", "visitMapExpression", "(", "MapExpression", "expression", ")", ";", "void", "visitMapEntryExpression", "(", "MapEntryExpression", "expression", ")", ";", "void", "visitListExpression", "(", "ListExpression", "expression", ")", ";", "void", "visitRangeExpression", "(", "RangeExpression", "expression", ")", ";", "void", "visitPropertyExpression", "(", "PropertyExpression", "expression", ")", ";", "void", "visitAttributeExpression", "(", "AttributeExpression", "attributeExpression", ")", ";", "void", "visitFieldExpression", "(", "FieldExpression", "expression", ")", ";", "void", "visitMethodPointerExpression", "(", "MethodPointerExpression", "expression", ")", ";", "void", "visitConstantExpression", "(", "ConstantExpression", "expression", ")", ";", "void", "visitClassExpression", "(", "ClassExpression", "expression", ")", ";", "void", "visitVariableExpression", "(", "VariableExpression", "expression", ")", ";", "void", "visitDeclarationExpression", "(", "DeclarationExpression", "expression", ")", ";", "void", "visitGStringExpression", "(", "GStringExpression", "expression", ")", ";", "void", "visitArrayExpression", "(", "ArrayExpression", "expression", ")", ";", "void", "visitSpreadExpression", "(", "SpreadExpression", "expression", ")", ";", "void", "visitSpreadMapExpression", "(", "SpreadMapExpression", "expression", ")", ";", "void", "visitNotExpression", "(", "NotExpression", "expression", ")", ";", "void", "visitUnaryMinusExpression", "(", "UnaryMinusExpression", "expression", ")", ";", "void", "visitUnaryPlusExpression", "(", "UnaryPlusExpression", "expression", ")", ";", "void", "visitBitwiseNegationExpression", "(", "BitwiseNegationExpression", "expression", ")", ";", "void", "visitCastExpression", "(", "CastExpression", "expression", ")", ";", "void", "visitArgumentlistExpression", "(", "ArgumentListExpression", "expression", ")", ";", "void", "visitClosureListExpression", "(", "ClosureListExpression", "closureListExpression", ")", ";", "void", "visitBytecodeExpression", "(", "BytecodeExpression", "expression", ")", ";", "void", "visitEmptyExpression", "(", "EmptyExpression", "expression", ")", ";", "}", "</s>" ]
6,919
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "transform", ";", "import", "groovy", ".", "transform", ".", "CompilationUnitAware", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "GroovyException", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "classgen", ".", "GeneratorContext", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "SimpleMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "SyntaxErrorMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "WarningMessage", ";", "import", "groovy", ".", "lang", ".", "GroovyClassLoader", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "*", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "eclipse", ".", "GroovyLogManager", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "eclipse", ".", "TraceCategory", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "SyntaxException", ";", "public", "final", "class", "ASTTransformationVisitor", "extends", "ClassCodeVisitorSupport", "{", "private", "final", "ASTTransformationsContext", "context", ";", "private", "final", "CompilePhase", "phase", ";", "private", "SourceUnit", "source", ";", "private", "List", "<", "ASTNode", "[", "]", ">", "targetNodes", ";", "private", "Map", "<", "ASTNode", ",", "List", "<", "ASTTransformation", ">", ">", "transforms", ";", "private", "Map", "<", "Class", "<", "?", "extends", "ASTTransformation", ">", ",", "ASTTransformation", ">", "transformInstances", ";", "private", "static", "CompilationUnit", "compUnit", ";", "private", "static", "Set", "<", "String", ">", "globalTransformNames", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "private", "ASTTransformationVisitor", "(", "final", "CompilePhase", "phase", ",", "final", "ASTTransformationsContext", "context", ")", "{", "this", ".", "phase", "=", "phase", ";", "this", ".", "context", "=", "context", ";", "}", "protected", "SourceUnit", "getSourceUnit", "(", ")", "{", "return", "source", ";", "}", "public", "void", "visitClass", "(", "ClassNode", "classNode", ")", "{", "Map", "<", "Class", "<", "?", "extends", "ASTTransformation", ">", ",", "Set", "<", "ASTNode", ">", ">", "baseTransforms", "=", "classNode", ".", "getTransforms", "(", "phase", ")", ";", "if", "(", "!", "baseTransforms", ".", "isEmpty", "(", ")", ")", "{", "final", "Map", "<", "Class", "<", "?", "extends", "ASTTransformation", ">", ",", "ASTTransformation", ">", "transformInstances", "=", "new", "HashMap", "<", "Class", "<", "?", "extends", "ASTTransformation", ">", ",", "ASTTransformation", ">", "(", ")", ";", "for", "(", "Class", "<", "?", "extends", "ASTTransformation", ">", "transformClass", ":", "baseTransforms", ".", "keySet", "(", ")", ")", "{", "try", "{", "transformInstances", ".", "put", "(", "transformClass", ",", "transformClass", ".", "newInstance", "(", ")", ")", ";", "}", "catch", "(", "InstantiationException", "e", ")", "{", "source", ".", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SimpleMessage", "(", "\"\"", "+", "transformClass", ",", "source", ")", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "source", ".", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SimpleMessage", "(", "\"\"", "+", "transformClass", ",", "source", ")", ")", ";", "}", "}", "transforms", "=", "new", "HashMap", "<", "ASTNode", ",", "List", "<", "ASTTransformation", ">", ">", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "Class", "<", "?", "extends", "ASTTransformation", ">", ",", "Set", "<", "ASTNode", ">", ">", "entry", ":", "baseTransforms", ".", "entrySet", "(", ")", ")", "{", "for", "(", "ASTNode", "node", ":", "entry", ".", "getValue", "(", ")", ")", "{", "List", "<", "ASTTransformation", ">", "list", "=", "transforms", ".", "get", "(", "node", ")", ";", "if", "(", "list", "==", "null", ")", "{", "list", "=", "new", "ArrayList", "<", "ASTTransformation", ">", "(", ")", ";", "transforms", ".", "put", "(", "node", ",", "list", ")", ";", "}", "list", ".", "add", "(", "transformInstances", ".", "get", "(", "entry", ".", "getKey", "(", ")", ")", ")", ";", "}", "}", "targetNodes", "=", "new", "LinkedList", "<", "ASTNode", "[", "]", ">", "(", ")", ";", "super", ".", "visitClass", "(", "classNode", ")", ";", "for", "(", "ASTNode", "[", "]", "node", ":", "targetNodes", ")", "{", "for", "(", "ASTTransformation", "snt", ":", "transforms", ".", "get", "(", "node", "[", "0", "]", ")", ")", "{", "try", "{", "long", "stime", "=", "System", ".", "nanoTime", "(", ")", ";", "boolean", "okToSet", "=", "source", "!=", "null", "&&", "source", ".", "getErrorCollector", "(", ")", "!=", "null", ";", "try", "{", "if", "(", "okToSet", ")", "{", "source", ".", "getErrorCollector", "(", ")", ".", "transformActive", "=", "true", ";", "}", "if", "(", "snt", "instanceof", "CompilationUnitAware", ")", "{", "(", "(", "CompilationUnitAware", ")", "snt", ")", ".", "setCompilationUnit", "(", "context", ".", "getCompilationUnit", "(", ")", ")", ";", "}", "snt", ".", "visit", "(", "node", ",", "source", ")", ";", "}", "finally", "{", "if", "(", "okToSet", ")", "{", "source", ".", "getErrorCollector", "(", ")", ".", "transformActive", "=", "false", ";", "}", "}", "long", "etime", "=", "System", ".", "nanoTime", "(", ")", ";", "if", "(", "GroovyLogManager", ".", "manager", ".", "hasLoggers", "(", ")", ")", "{", "try", "{", "GroovyLogManager", ".", "manager", ".", "log", "(", "TraceCategory", ".", "AST_TRANSFORM", ",", "\"\"", "+", "snt", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"", "on", "\"", "+", "classNode", ".", "getName", "(", ")", "+", "\":\"", "+", "node", "[", "1", "]", "+", "\"", "=", "\"", "+", "(", "(", "etime", "-", "stime", ")", "/", "1000000", ")", "+", "\"ms\"", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "t", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "catch", "(", "NoClassDefFoundError", "ncdfe", ")", "{", "String", "transformName", "=", "snt", ".", "getClass", "(", ")", ".", "getName", "(", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"\"", "+", "transformName", "+", "\"\"", "+", "ncdfe", ".", "getMessage", "(", ")", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "source", ".", "addError", "(", "new", "SyntaxException", "(", "sb", ".", "toString", "(", ")", ",", "ncdfe", ",", "0", ",", "0", ")", ")", ";", "}", "}", "}", "}", "}", "public", "void", "visitAnnotations", "(", "AnnotatedNode", "node", ")", "{", "super", ".", "visitAnnotations", "(", "node", ")", ";", "for", "(", "AnnotationNode", "annotation", ":", "node", ".", "getAnnotations", "(", ")", ")", "{", "if", "(", "transforms", ".", "containsKey", "(", "annotation", ")", ")", "{", "targetNodes", ".", "add", "(", "new", "ASTNode", "[", "]", "{", "annotation", ",", "node", "}", ")", ";", "}", "}", "}", "public", "static", "void", "addPhaseOperations", "(", "final", "CompilationUnit", "compilationUnit", ")", "{", "final", "ASTTransformationsContext", "context", "=", "compilationUnit", ".", "getASTTransformationsContext", "(", ")", ";", "addGlobalTransforms", "(", "context", ")", ";", "compilationUnit", ".", "addPhaseOperation", "(", "new", "CompilationUnit", ".", "PrimaryClassNodeOperation", "(", ")", "{", "public", "void", "call", "(", "SourceUnit", "source", ",", "GeneratorContext", "context", ",", "ClassNode", "classNode", ")", "throws", "CompilationFailedException", "{", "ASTTransformationCollectorCodeVisitor", "collector", "=", "new", "ASTTransformationCollectorCodeVisitor", "(", "source", ",", "compilationUnit", ".", "getTransformLoader", "(", ")", ",", "compilationUnit", ".", "allowTransforms", ",", "compilationUnit", ".", "localTransformsToRunOnReconcile", ")", ";", "collector", ".", "visitClass", "(", "classNode", ")", ";", "}", "}", ",", "Phases", ".", "SEMANTIC_ANALYSIS", ")", ";", "for", "(", "CompilePhase", "phase", ":", "CompilePhase", ".", "values", "(", ")", ")", "{", "final", "ASTTransformationVisitor", "visitor", "=", "new", "ASTTransformationVisitor", "(", "phase", ",", "context", ")", ";", "switch", "(", "phase", ")", "{", "case", "INITIALIZATION", ":", "case", "PARSING", ":", "case", "CONVERSION", ":", "break", ";", "default", ":", "compilationUnit", ".", "addPhaseOperation", "(", "new", "CompilationUnit", ".", "PrimaryClassNodeOperation", "(", ")", "{", "public", "void", "call", "(", "SourceUnit", "source", ",", "GeneratorContext", "context", ",", "ClassNode", "classNode", ")", "throws", "CompilationFailedException", "{", "visitor", ".", "source", "=", "source", ";", "visitor", ".", "visitClass", "(", "classNode", ")", ";", "}", "}", ",", "phase", ".", "getPhaseNumber", "(", ")", ")", ";", "break", ";", "}", "}", "}", "public", "static", "void", "addGlobalTransformsAfterGrab", "(", "ASTTransformationsContext", "context", ")", "{", "doAddGlobalTransforms", "(", "context", ",", "false", ")", ";", "}", "public", "static", "void", "addGlobalTransforms", "(", "ASTTransformationsContext", "context", ")", "{", "doAddGlobalTransforms", "(", "context", ",", "true", ")", ";", "}", "private", "static", "void", "doAddGlobalTransforms", "(", "ASTTransformationsContext", "context", ",", "boolean", "isFirstScan", ")", "{", "final", "CompilationUnit", "compilationUnit", "=", "context", ".", "getCompilationUnit", "(", ")", ";", "ensurelobalTransformsAllowedInReconcileInitialized", "(", ")", ";", "GroovyClassLoader", "transformLoader", "=", "compilationUnit", ".", "getTransformLoader", "(", ")", ";", "Map", "<", "String", ",", "URL", ">", "transformNames", "=", "new", "LinkedHashMap", "<", "String", ",", "URL", ">", "(", ")", ";", "try", "{", "Enumeration", "<", "URL", ">", "globalServices", "=", "transformLoader", ".", "getResources", "(", "\"\"", ")", ";", "while", "(", "globalServices", ".", "hasMoreElements", "(", ")", ")", "{", "URL", "service", "=", "globalServices", ".", "nextElement", "(", ")", ";", "String", "className", ";", "BufferedReader", "svcIn", "=", "null", ";", "InputStream", "is", "=", "service", ".", "openStream", "(", ")", ";", "try", "{", "svcIn", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "is", ")", ")", ";", "try", "{", "className", "=", "svcIn", ".", "readLine", "(", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "compilationUnit", ".", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SimpleMessage", "(", "\"\"", "+", "service", ".", "toExternalForm", "(", ")", "+", "\"\"", "+", "ioe", ".", "toString", "(", ")", ",", "null", ")", ")", ";", "continue", ";", "}", "Set", "<", "String", ">", "disabledGlobalTransforms", "=", "compilationUnit", ".", "getConfiguration", "(", ")", ".", "getDisabledGlobalASTTransformations", "(", ")", ";", "if", "(", "disabledGlobalTransforms", "==", "null", ")", "disabledGlobalTransforms", "=", "Collections", ".", "emptySet", "(", ")", ";", "while", "(", "className", "!=", "null", ")", "{", "if", "(", "!", "className", ".", "startsWith", "(", "\"#\"", ")", "&&", "className", ".", "length", "(", ")", ">", "0", ")", "{", "if", "(", "!", "disabledGlobalTransforms", ".", "contains", "(", "className", ")", ")", "{", "if", "(", "transformNames", ".", "containsKey", "(", "className", ")", ")", "{", "if", "(", "!", "service", ".", "equals", "(", "transformNames", ".", "get", "(", "className", ")", ")", ")", "{", "compilationUnit", ".", "getErrorCollector", "(", ")", ".", "addWarning", "(", "WarningMessage", ".", "POSSIBLE_ERRORS", ",", "\"\"", "+", "className", "+", "\"\"", "+", "transformNames", ".", "get", "(", "className", ")", ".", "toExternalForm", "(", ")", "+", "\"", "and", "\"", "+", "service", ".", "toExternalForm", "(", ")", "+", "\"\"", ",", "null", ",", "null", ")", ";", "}", "}", "else", "{", "if", "(", "compilationUnit", ".", "allowTransforms", "||", "globalTransformsAllowedInReconcile", ".", "contains", "(", "className", ")", ")", "{", "transformNames", ".", "put", "(", "className", ",", "service", ")", ";", "}", "}", "}", "}", "try", "{", "className", "=", "svcIn", ".", "readLine", "(", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "compilationUnit", ".", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SimpleMessage", "(", "\"\"", "+", "service", ".", "toExternalForm", "(", ")", "+", "\"\"", "+", "ioe", ".", "toString", "(", ")", ",", "null", ")", ")", ";", "continue", ";", "}", "}", "}", "finally", "{", "if", "(", "svcIn", "!=", "null", ")", "svcIn", ".", "close", "(", ")", ";", "}", "is", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "compilationUnit", ".", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SimpleMessage", "(", "\"\"", "+", "e", ".", "getMessage", "(", ")", ",", "null", ")", ")", ";", "}", "try", "{", "Class", ".", "forName", "(", "\"\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "URL", ">", "entry", ":", "transformNames", ".", "entrySet", "(", ")", ")", "{", "sb", ".", "append", "(", "'\\t'", ")", ";", "sb", ".", "append", "(", "entry", ".", "getKey", "(", ")", ")", ";", "sb", ".", "append", "(", "'\\n'", ")", ";", "}", "compilationUnit", ".", "getErrorCollector", "(", ")", ".", "addWarning", "(", "new", "WarningMessage", "(", "WarningMessage", ".", "POSSIBLE_ERRORS", ",", "sb", ".", "toString", "(", ")", ",", "null", ",", "null", ")", ")", ";", "return", ";", "}", "if", "(", "isFirstScan", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "URL", ">", "entry", ":", "transformNames", ".", "entrySet", "(", ")", ")", "{", "context", ".", "getGlobalTransformNames", "(", ")", ".", "add", "(", "entry", ".", "getKey", "(", ")", ")", ";", "}", "addPhaseOperationsForGlobalTransforms", "(", "context", ".", "getCompilationUnit", "(", ")", ",", "transformNames", ",", "isFirstScan", ")", ";", "}", "else", "{", "Iterator", "<", "Map", ".", "Entry", "<", "String", ",", "URL", ">", ">", "it", "=", "transformNames", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "Map", ".", "Entry", "<", "String", ",", "URL", ">", "entry", "=", "it", ".", "next", "(", ")", ";", "if", "(", "!", "context", ".", "getGlobalTransformNames", "(", ")", ".", "add", "(", "entry", ".", "getKey", "(", ")", ")", ")", "{", "it", ".", "remove", "(", ")", ";", "}", "}", "addPhaseOperationsForGlobalTransforms", "(", "context", ".", "getCompilationUnit", "(", ")", ",", "transformNames", ",", "isFirstScan", ")", ";", "}", "}", "private", "static", "List", "<", "String", ">", "globalTransformsAllowedInReconcile", "=", "null", ";", "private", "static", "void", "ensurelobalTransformsAllowedInReconcileInitialized", "(", ")", "{", "if", "(", "globalTransformsAllowedInReconcile", "==", "null", ")", "{", "globalTransformsAllowedInReconcile", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "try", "{", "String", "s", "=", "System", ".", "getProperty", "(", "\"\"", ",", "\"\"", ")", ";", "StringTokenizer", "st", "=", "new", "StringTokenizer", "(", "s", ",", "\",\"", ")", ";", "while", "(", "st", ".", "hasMoreElements", "(", ")", ")", "{", "String", "classname", "=", "st", ".", "nextToken", "(", ")", ";", "globalTransformsAllowedInReconcile", ".", "add", "(", "classname", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "globalTransformsAllowedInReconcile", ".", "add", "(", "\"\"", ")", ";", "}", "}", "private", "static", "void", "addPhaseOperationsForGlobalTransforms", "(", "CompilationUnit", "compilationUnit", ",", "Map", "<", "String", ",", "URL", ">", "transformNames", ",", "boolean", "isFirstScan", ")", "{", "GroovyClassLoader", "transformLoader", "=", "compilationUnit", ".", "getTransformLoader", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "URL", ">", "entry", ":", "transformNames", ".", "entrySet", "(", ")", ")", "{", "try", "{", "Class", "gTransClass", "=", "transformLoader", ".", "loadClass", "(", "entry", ".", "getKey", "(", ")", ",", "false", ",", "true", ",", "false", ")", ";", "GroovyASTTransformation", "transformAnnotation", "=", "(", "GroovyASTTransformation", ")", "gTransClass", ".", "getAnnotation", "(", "GroovyASTTransformation", ".", "class", ")", ";", "if", "(", "transformAnnotation", "==", "null", ")", "{", "compilationUnit", ".", "getErrorCollector", "(", ")", ".", "addWarning", "(", "new", "WarningMessage", "(", "WarningMessage", ".", "POSSIBLE_ERRORS", ",", "\"\"", "+", "entry", ".", "getKey", "(", ")", "+", "\"\"", "+", "entry", ".", "getValue", "(", ")", ".", "toExternalForm", "(", ")", "+", "\"\"", "+", "GroovyASTTransformation", ".", "class", ".", "getName", "(", ")", "+", "\"\"", ",", "null", ",", "null", ")", ")", ";", "continue", ";", "}", "if", "(", "ASTTransformation", ".", "class", ".", "isAssignableFrom", "(", "gTransClass", ")", ")", "{", "try", "{", "final", "ASTTransformation", "instance", "=", "(", "ASTTransformation", ")", "gTransClass", ".", "newInstance", "(", ")", ";", "if", "(", "instance", "instanceof", "CompilationUnitAware", ")", "{", "(", "(", "CompilationUnitAware", ")", "instance", ")", ".", "setCompilationUnit", "(", "compilationUnit", ")", ";", "}", "CompilationUnit", ".", "SourceUnitOperation", "suOp", "=", "new", "CompilationUnit", ".", "SourceUnitOperation", "(", ")", "{", "private", "boolean", "isBuggered", "=", "false", ";", "public", "void", "call", "(", "SourceUnit", "source", ")", "throws", "CompilationFailedException", "{", "if", "(", "isBuggered", ")", "return", ";", "try", "{", "long", "stime", "=", "System", ".", "nanoTime", "(", ")", ";", "boolean", "okToSet", "=", "source", "!=", "null", "&&", "source", ".", "getErrorCollector", "(", ")", "!=", "null", ";", "try", "{", "if", "(", "okToSet", ")", "{", "source", ".", "getErrorCollector", "(", ")", ".", "transformActive", "=", "true", ";", "}", "instance", ".", "visit", "(", "new", "ASTNode", "[", "]", "{", "source", ".", "getAST", "(", ")", "}", ",", "source", ")", ";", "}", "finally", "{", "if", "(", "okToSet", ")", "{", "source", ".", "getErrorCollector", "(", ")", ".", "transformActive", "=", "false", ";", "}", "}", "long", "etime", "=", "System", ".", "nanoTime", "(", ")", ";", "if", "(", "GroovyLogManager", ".", "manager", ".", "hasLoggers", "(", ")", ")", "{", "long", "timetaken", "=", "(", "etime", "-", "stime", ")", "/", "1000000", ";", "if", "(", "timetaken", ">", "0", ")", "{", "try", "{", "GroovyLogManager", ".", "manager", ".", "log", "(", "TraceCategory", ".", "AST_TRANSFORM", ",", "\"\"", "+", "instance", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"", "on", "\"", "+", "source", ".", "getName", "(", ")", "+", "\"", "=", "\"", "+", "timetaken", "+", "\"ms\"", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "t", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "}", "catch", "(", "NoClassDefFoundError", "ncdfe", ")", "{", "new", "RuntimeException", "(", "\"Transform", "\"", "+", "instance", ".", "toString", "(", ")", "+", "\"\"", ",", "ncdfe", ")", ".", "printStackTrace", "(", ")", ";", "source", ".", "addException", "(", "new", "GroovyException", "(", "\"Transform", "\"", "+", "instance", ".", "toString", "(", ")", "+", "\"\"", ",", "ncdfe", ")", ")", ";", "isBuggered", "=", "true", ";", "}", "}", "}", ";", "if", "(", "isFirstScan", ")", "{", "compilationUnit", ".", "addPhaseOperation", "(", "suOp", ",", "transformAnnotation", ".", "phase", "(", ")", ".", "getPhaseNumber", "(", ")", ")", ";", "}", "else", "{", "compilationUnit", ".", "addNewPhaseOperation", "(", "suOp", ",", "transformAnnotation", ".", "phase", "(", ")", ".", "getPhaseNumber", "(", ")", ")", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "compilationUnit", ".", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SimpleMessage", "(", "\"\"", "+", "t", ".", "getMessage", "(", ")", ",", "null", ")", ")", ";", "t", ".", "printStackTrace", "(", ")", ";", "}", "}", "else", "{", "compilationUnit", ".", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SimpleMessage", "(", "\"\"", "+", "entry", ".", "getKey", "(", ")", "+", "\"\"", "+", "entry", ".", "getValue", "(", ")", ".", "toExternalForm", "(", ")", "+", "\"\"", ",", "null", ")", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "compilationUnit", ".", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SimpleMessage", "(", "\"\"", "+", "entry", ".", "getKey", "(", ")", "+", "\"\"", "+", "entry", ".", "getValue", "(", ")", ".", "toExternalForm", "(", ")", "+", "\"\"", "+", "e", ".", "toString", "(", ")", ",", "null", ")", ")", ";", "}", "}", "}", "}", "</s>" ]
6,920
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "transform", ";", "import", "groovy", ".", "lang", ".", "MetaClass", ";", "import", "groovy", ".", "lang", ".", "MissingPropertyException", ";", "import", "groovy", ".", "lang", ".", "ReadOnlyPropertyException", ";", "import", "groovy", ".", "transform", ".", "Immutable", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ASTNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "AnnotatedNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "AnnotationNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ClassHelper", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ClassNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ConstructorNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "FieldNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "InnerClassNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "Parameter", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "PropertyNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "BlockStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "EmptyStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "ExpressionStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "IfStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "Statement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "ThrowStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "CompilePhase", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "SourceUnit", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "runtime", ".", "DefaultGroovyMethods", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "runtime", ".", "InvokerHelper", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Modifier", ";", "import", "java", ".", "util", ".", "*", ";", "import", "static", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "AbstractASTTransformUtil", ".", "*", ";", "import", "static", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "EqualsAndHashCodeASTTransformation", ".", "createEquals", ";", "import", "static", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "EqualsAndHashCodeASTTransformation", ".", "createHashCode", ";", "import", "static", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "ToStringASTTransformation", ".", "createToString", ";", "@", "GroovyASTTransformation", "(", "phase", "=", "CompilePhase", ".", "CANONICALIZATION", ")", "public", "class", "ImmutableASTTransformation", "extends", "AbstractASTTransformation", "{", "private", "static", "List", "<", "String", ">", "immutableList", "=", "Arrays", ".", "asList", "(", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"java.net.URI\"", ",", "\"\"", ")", ";", "private", "static", "final", "Class", "MY_CLASS", "=", "groovy", ".", "transform", ".", "Immutable", ".", "class", ";", "static", "final", "ClassNode", "MY_TYPE", "=", "ClassHelper", ".", "make", "(", "MY_CLASS", ")", ";", "static", "final", "String", "MY_TYPE_NAME", "=", "\"@\"", "+", "MY_TYPE", ".", "getNameWithoutPackage", "(", ")", ";", "static", "final", "String", "MEMBER_KNOWN_IMMUTABLE_CLASSES", "=", "\"\"", ";", "private", "static", "final", "ClassNode", "DATE_TYPE", "=", "ClassHelper", ".", "make", "(", "Date", ".", "class", ")", ";", "private", "static", "final", "ClassNode", "CLONEABLE_TYPE", "=", "ClassHelper", ".", "make", "(", "Cloneable", ".", "class", ")", ";", "private", "static", "final", "ClassNode", "COLLECTION_TYPE", "=", "ClassHelper", ".", "makeWithoutCaching", "(", "Collection", ".", "class", ",", "false", ")", ";", "private", "static", "final", "ClassNode", "READONLYEXCEPTION_TYPE", "=", "ClassHelper", ".", "make", "(", "ReadOnlyPropertyException", ".", "class", ")", ";", "private", "static", "final", "ClassNode", "DGM_TYPE", "=", "ClassHelper", ".", "make", "(", "DefaultGroovyMethods", ".", "class", ")", ";", "private", "static", "final", "ClassNode", "SELF_TYPE", "=", "ClassHelper", ".", "make", "(", "ImmutableASTTransformation", ".", "class", ")", ";", "private", "static", "final", "ClassNode", "HASHMAP_TYPE", "=", "ClassHelper", ".", "makeWithoutCaching", "(", "HashMap", ".", "class", ",", "false", ")", ";", "private", "static", "final", "ClassNode", "MAP_TYPE", "=", "ClassHelper", ".", "makeWithoutCaching", "(", "Map", ".", "class", ",", "false", ")", ";", "public", "void", "visit", "(", "ASTNode", "[", "]", "nodes", ",", "SourceUnit", "source", ")", "{", "init", "(", "nodes", ",", "source", ")", ";", "AnnotatedNode", "parent", "=", "(", "AnnotatedNode", ")", "nodes", "[", "1", "]", ";", "AnnotationNode", "node", "=", "(", "AnnotationNode", ")", "nodes", "[", "0", "]", ";", "if", "(", "!", "node", ".", "getClassNode", "(", ")", ".", "getName", "(", ")", ".", "endsWith", "(", "\".Immutable\"", ")", ")", "return", ";", "List", "<", "PropertyNode", ">", "newProperties", "=", "new", "ArrayList", "<", "PropertyNode", ">", "(", ")", ";", "if", "(", "parent", "instanceof", "ClassNode", ")", "{", "final", "List", "<", "String", ">", "knownImmutableClasses", "=", "getKnownImmutableClasses", "(", "node", ")", ";", "ClassNode", "cNode", "=", "(", "ClassNode", ")", "parent", ";", "String", "cName", "=", "cNode", ".", "getName", "(", ")", ";", "checkNotInterface", "(", "cNode", ",", "MY_TYPE_NAME", ")", ";", "makeClassFinal", "(", "cNode", ")", ";", "final", "List", "<", "PropertyNode", ">", "pList", "=", "getInstanceProperties", "(", "cNode", ")", ";", "for", "(", "PropertyNode", "pNode", ":", "pList", ")", "{", "adjustPropertyForImmutability", "(", "pNode", ",", "newProperties", ")", ";", "}", "for", "(", "PropertyNode", "pNode", ":", "newProperties", ")", "{", "cNode", ".", "getProperties", "(", ")", ".", "remove", "(", "pNode", ")", ";", "addProperty", "(", "cNode", ",", "pNode", ")", ";", "}", "final", "List", "<", "FieldNode", ">", "fList", "=", "cNode", ".", "getFields", "(", ")", ";", "for", "(", "FieldNode", "fNode", ":", "fList", ")", "{", "ensureNotPublic", "(", "cName", ",", "fNode", ")", ";", "}", "createConstructors", "(", "cNode", ",", "knownImmutableClasses", ")", ";", "createHashCode", "(", "cNode", ",", "true", ",", "false", ",", "false", ",", "null", ",", "null", ")", ";", "createEquals", "(", "cNode", ",", "false", ",", "false", ",", "false", ",", "null", ",", "null", ")", ";", "if", "(", "!", "hasAnnotation", "(", "cNode", ",", "ToStringASTTransformation", ".", "MY_TYPE", ")", ")", "{", "createToString", "(", "cNode", ",", "false", ",", "false", ",", "null", ",", "null", ",", "false", ")", ";", "}", "}", "}", "private", "List", "<", "String", ">", "getKnownImmutableClasses", "(", "AnnotationNode", "node", ")", "{", "final", "ArrayList", "<", "String", ">", "immutableClasses", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "final", "Expression", "expression", "=", "node", ".", "getMember", "(", "MEMBER_KNOWN_IMMUTABLE_CLASSES", ")", ";", "if", "(", "expression", "==", "null", ")", "return", "immutableClasses", ";", "if", "(", "!", "(", "expression", "instanceof", "ListExpression", ")", ")", "{", "addError", "(", "\"\"", "+", "MEMBER_KNOWN_IMMUTABLE_CLASSES", "+", "\"\\\"\"", ",", "node", ")", ";", "return", "immutableClasses", ";", "}", "final", "ListExpression", "listExpression", "=", "(", "ListExpression", ")", "expression", ";", "for", "(", "Expression", "listItemExpression", ":", "listExpression", ".", "getExpressions", "(", ")", ")", "{", "if", "(", "listItemExpression", "instanceof", "ClassExpression", ")", "{", "immutableClasses", ".", "add", "(", "listItemExpression", ".", "getType", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "}", "return", "immutableClasses", ";", "}", "private", "void", "makeClassFinal", "(", "ClassNode", "cNode", ")", "{", "if", "(", "(", "cNode", ".", "getModifiers", "(", ")", "&", "ACC_FINAL", ")", "==", "0", ")", "{", "cNode", ".", "setModifiers", "(", "cNode", ".", "getModifiers", "(", ")", "|", "ACC_FINAL", ")", ";", "}", "}", "private", "void", "createConstructors", "(", "ClassNode", "cNode", ",", "List", "<", "String", ">", "knownImmutableClasses", ")", "{", "if", "(", "!", "validateConstructors", "(", "cNode", ")", ")", "return", ";", "List", "<", "PropertyNode", ">", "list", "=", "getInstanceProperties", "(", "cNode", ")", ";", "boolean", "specialHashMapCase", "=", "list", ".", "size", "(", ")", "==", "1", "&&", "list", ".", "get", "(", "0", ")", ".", "getField", "(", ")", ".", "getType", "(", ")", ".", "equals", "(", "HASHMAP_TYPE", ")", ";", "if", "(", "specialHashMapCase", ")", "{", "createConstructorMapSpecial", "(", "cNode", ",", "list", ")", ";", "}", "else", "{", "createConstructorMap", "(", "cNode", ",", "list", ",", "knownImmutableClasses", ")", ";", "createConstructorOrdered", "(", "cNode", ",", "list", ")", ";", "}", "}", "private", "void", "createConstructorOrdered", "(", "ClassNode", "cNode", ",", "List", "<", "PropertyNode", ">", "list", ")", "{", "final", "MapExpression", "argMap", "=", "new", "MapExpression", "(", ")", ";", "final", "Parameter", "[", "]", "orderedParams", "=", "new", "Parameter", "[", "list", ".", "size", "(", ")", "]", ";", "int", "index", "=", "0", ";", "for", "(", "PropertyNode", "pNode", ":", "list", ")", "{", "Parameter", "param", "=", "new", "Parameter", "(", "pNode", ".", "getField", "(", ")", ".", "getType", "(", ")", ",", "pNode", ".", "getField", "(", ")", ".", "getName", "(", ")", ")", ";", "orderedParams", "[", "index", "++", "]", "=", "param", ";", "argMap", ".", "addMapEntryExpression", "(", "new", "ConstantExpression", "(", "pNode", ".", "getName", "(", ")", ")", ",", "new", "VariableExpression", "(", "pNode", ".", "getName", "(", ")", ")", ")", ";", "}", "final", "BlockStatement", "orderedBody", "=", "new", "BlockStatement", "(", ")", ";", "orderedBody", ".", "addStatement", "(", "new", "ExpressionStatement", "(", "new", "ConstructorCallExpression", "(", "ClassNode", ".", "THIS", ",", "new", "ArgumentListExpression", "(", "new", "CastExpression", "(", "HASHMAP_TYPE", ",", "argMap", ")", ")", ")", ")", ")", ";", "cNode", ".", "addConstructor", "(", "new", "ConstructorNode", "(", "ACC_PUBLIC", ",", "orderedParams", ",", "ClassNode", ".", "EMPTY_ARRAY", ",", "orderedBody", ")", ")", ";", "}", "private", "Statement", "createGetterBodyDefault", "(", "FieldNode", "fNode", ")", "{", "final", "Expression", "fieldExpr", "=", "new", "VariableExpression", "(", "fNode", ")", ";", "return", "new", "ExpressionStatement", "(", "fieldExpr", ")", ";", "}", "private", "Expression", "cloneCollectionExpr", "(", "Expression", "fieldExpr", ")", "{", "return", "new", "StaticMethodCallExpression", "(", "DGM_TYPE", ",", "\"asImmutable\"", ",", "fieldExpr", ")", ";", "}", "private", "Expression", "cloneArrayOrCloneableExpr", "(", "Expression", "fieldExpr", ")", "{", "return", "new", "MethodCallExpression", "(", "fieldExpr", ",", "\"clone\"", ",", "MethodCallExpression", ".", "NO_ARGUMENTS", ")", ";", "}", "private", "void", "createConstructorMapSpecial", "(", "ClassNode", "cNode", ",", "List", "<", "PropertyNode", ">", "list", ")", "{", "final", "BlockStatement", "body", "=", "new", "BlockStatement", "(", ")", ";", "body", ".", "addStatement", "(", "createConstructorStatementMapSpecial", "(", "list", ".", "get", "(", "0", ")", ".", "getField", "(", ")", ")", ")", ";", "createConstructorMapCommon", "(", "cNode", ",", "body", ")", ";", "}", "private", "void", "createConstructorMap", "(", "ClassNode", "cNode", ",", "List", "<", "PropertyNode", ">", "list", ",", "List", "<", "String", ">", "knownImmutableClasses", ")", "{", "final", "BlockStatement", "body", "=", "new", "BlockStatement", "(", ")", ";", "for", "(", "PropertyNode", "pNode", ":", "list", ")", "{", "body", ".", "addStatement", "(", "createConstructorStatement", "(", "cNode", ",", "pNode", ",", "knownImmutableClasses", ")", ")", ";", "}", "Expression", "checkArgs", "=", "new", "ArgumentListExpression", "(", "new", "VariableExpression", "(", "\"this\"", ")", ",", "new", "VariableExpression", "(", "\"args\"", ")", ")", ";", "body", ".", "addStatement", "(", "new", "ExpressionStatement", "(", "new", "StaticMethodCallExpression", "(", "SELF_TYPE", ",", "\"\"", ",", "checkArgs", ")", ")", ")", ";", "createConstructorMapCommon", "(", "cNode", ",", "body", ")", ";", "}", "private", "void", "createConstructorMapCommon", "(", "ClassNode", "cNode", ",", "BlockStatement", "body", ")", "{", "final", "List", "<", "FieldNode", ">", "fList", "=", "cNode", ".", "getFields", "(", ")", ";", "for", "(", "FieldNode", "fNode", ":", "fList", ")", "{", "if", "(", "fNode", ".", "isPublic", "(", ")", ")", "continue", ";", "if", "(", "cNode", ".", "getProperty", "(", "fNode", ".", "getName", "(", ")", ")", "!=", "null", ")", "continue", ";", "if", "(", "fNode", ".", "isFinal", "(", ")", "&&", "fNode", ".", "isStatic", "(", ")", ")", "continue", ";", "if", "(", "fNode", ".", "getName", "(", ")", ".", "contains", "(", "\"$\"", ")", ")", "continue", ";", "if", "(", "fNode", ".", "isFinal", "(", ")", "&&", "fNode", ".", "getInitialExpression", "(", ")", "!=", "null", ")", "body", ".", "addStatement", "(", "checkFinalArgNotOverridden", "(", "cNode", ",", "fNode", ")", ")", ";", "body", ".", "addStatement", "(", "createConstructorStatementDefault", "(", "fNode", ")", ")", ";", "}", "final", "Parameter", "[", "]", "params", "=", "new", "Parameter", "[", "]", "{", "new", "Parameter", "(", "HASHMAP_TYPE", ",", "\"args\"", ")", "}", ";", "cNode", ".", "addConstructor", "(", "new", "ConstructorNode", "(", "ACC_PUBLIC", ",", "params", ",", "ClassNode", ".", "EMPTY_ARRAY", ",", "new", "IfStatement", "(", "equalsNullExpr", "(", "new", "VariableExpression", "(", "\"args\"", ")", ")", ",", "new", "EmptyStatement", "(", ")", ",", "body", ")", ")", ")", ";", "}", "private", "Statement", "checkFinalArgNotOverridden", "(", "ClassNode", "cNode", ",", "FieldNode", "fNode", ")", "{", "final", "String", "name", "=", "fNode", ".", "getName", "(", ")", ";", "Expression", "value", "=", "findArg", "(", "name", ")", ";", "return", "new", "IfStatement", "(", "equalsNullExpr", "(", "value", ")", ",", "new", "EmptyStatement", "(", ")", ",", "new", "ThrowStatement", "(", "new", "ConstructorCallExpression", "(", "READONLYEXCEPTION_TYPE", ",", "new", "ArgumentListExpression", "(", "new", "ConstantExpression", "(", "name", ")", ",", "new", "ConstantExpression", "(", "cNode", ".", "getName", "(", ")", ")", ")", ")", ")", ")", ";", "}", "private", "Statement", "createConstructorStatementMapSpecial", "(", "FieldNode", "fNode", ")", "{", "final", "Expression", "fieldExpr", "=", "new", "VariableExpression", "(", "fNode", ")", ";", "Expression", "initExpr", "=", "fNode", ".", "getInitialValueExpression", "(", ")", ";", "if", "(", "initExpr", "==", "null", ")", "initExpr", "=", "ConstantExpression", ".", "NULL", ";", "Expression", "namedArgs", "=", "findArg", "(", "fNode", ".", "getName", "(", ")", ")", ";", "Expression", "baseArgs", "=", "new", "VariableExpression", "(", "\"args\"", ")", ";", "return", "new", "IfStatement", "(", "equalsNullExpr", "(", "baseArgs", ")", ",", "new", "IfStatement", "(", "equalsNullExpr", "(", "initExpr", ")", ",", "new", "EmptyStatement", "(", ")", ",", "assignStatement", "(", "fieldExpr", ",", "cloneCollectionExpr", "(", "initExpr", ")", ")", ")", ",", "new", "IfStatement", "(", "equalsNullExpr", "(", "namedArgs", ")", ",", "new", "IfStatement", "(", "isTrueExpr", "(", "new", "MethodCallExpression", "(", "baseArgs", ",", "\"containsKey\"", ",", "new", "ConstantExpression", "(", "fNode", ".", "getName", "(", ")", ")", ")", ")", ",", "assignStatement", "(", "fieldExpr", ",", "namedArgs", ")", ",", "assignStatement", "(", "fieldExpr", ",", "cloneCollectionExpr", "(", "baseArgs", ")", ")", ")", ",", "new", "IfStatement", "(", "isOneExpr", "(", "new", "MethodCallExpression", "(", "baseArgs", ",", "\"size\"", ",", "MethodCallExpression", ".", "NO_ARGUMENTS", ")", ")", ",", "assignStatement", "(", "fieldExpr", ",", "cloneCollectionExpr", "(", "namedArgs", ")", ")", ",", "assignStatement", "(", "fieldExpr", ",", "cloneCollectionExpr", "(", "baseArgs", ")", ")", ")", ")", ")", ";", "}", "private", "void", "ensureNotPublic", "(", "String", "cNode", ",", "FieldNode", "fNode", ")", "{", "String", "fName", "=", "fNode", ".", "getName", "(", ")", ";", "if", "(", "fNode", ".", "isPublic", "(", ")", "&&", "!", "fName", ".", "contains", "(", "\"$\"", ")", "&&", "!", "(", "fNode", ".", "isStatic", "(", ")", "&&", "fNode", ".", "isFinal", "(", ")", ")", ")", "{", "addError", "(", "\"\"", "+", "fName", "+", "\"\"", "+", "MY_TYPE_NAME", "+", "\"", "class", "'\"", "+", "cNode", "+", "\"'.\"", ",", "fNode", ")", ";", "}", "}", "private", "void", "addProperty", "(", "ClassNode", "cNode", ",", "PropertyNode", "pNode", ")", "{", "final", "FieldNode", "fn", "=", "pNode", ".", "getField", "(", ")", ";", "cNode", ".", "getFields", "(", ")", ".", "remove", "(", "fn", ")", ";", "cNode", ".", "addProperty", "(", "pNode", ".", "getName", "(", ")", ",", "pNode", ".", "getModifiers", "(", ")", "|", "ACC_FINAL", ",", "pNode", ".", "getType", "(", ")", ",", "pNode", ".", "getInitialExpression", "(", ")", ",", "pNode", ".", "getGetterBlock", "(", ")", ",", "pNode", ".", "getSetterBlock", "(", ")", ")", ";", "final", "FieldNode", "newfn", "=", "cNode", ".", "getField", "(", "fn", ".", "getName", "(", ")", ")", ";", "cNode", ".", "getFields", "(", ")", ".", "remove", "(", "newfn", ")", ";", "cNode", ".", "addField", "(", "fn", ")", ";", "}", "private", "boolean", "validateConstructors", "(", "ClassNode", "cNode", ")", "{", "if", "(", "cNode", ".", "getDeclaredConstructors", "(", ")", ".", "size", "(", ")", "!=", "0", ")", "{", "addError", "(", "\"\"", "+", "ImmutableASTTransformation", ".", "MY_TYPE_NAME", "+", "\"", "class:", "\"", "+", "cNode", ".", "getNameWithoutPackage", "(", ")", ",", "cNode", ".", "getDeclaredConstructors", "(", ")", ".", "get", "(", "0", ")", ")", ";", "}", "return", "true", ";", "}", "private", "Statement", "createConstructorStatement", "(", "ClassNode", "cNode", ",", "PropertyNode", "pNode", ",", "List", "<", "String", ">", "knownImmutableClasses", ")", "{", "FieldNode", "fNode", "=", "pNode", ".", "getField", "(", ")", ";", "final", "ClassNode", "fieldType", "=", "fNode", ".", "getType", "(", ")", ";", "Statement", "statement", "=", "null", ";", "if", "(", "fieldType", ".", "isArray", "(", ")", "||", "isOrImplements", "(", "fieldType", ",", "CLONEABLE_TYPE", ")", ")", "{", "statement", "=", "createConstructorStatementArrayOrCloneable", "(", "fNode", ")", ";", "}", "else", "if", "(", "fieldType", ".", "isDerivedFrom", "(", "DATE_TYPE", ")", ")", "{", "statement", "=", "createConstructorStatementDate", "(", "fNode", ")", ";", "}", "else", "if", "(", "isOrImplements", "(", "fieldType", ",", "COLLECTION_TYPE", ")", "||", "fieldType", ".", "isDerivedFrom", "(", "COLLECTION_TYPE", ")", "||", "isOrImplements", "(", "fieldType", ",", "MAP_TYPE", ")", "||", "fieldType", ".", "isDerivedFrom", "(", "MAP_TYPE", ")", ")", "{", "statement", "=", "createConstructorStatementCollection", "(", "fNode", ")", ";", "}", "else", "if", "(", "isKnownImmutable", "(", "fieldType", ",", "knownImmutableClasses", ")", ")", "{", "statement", "=", "createConstructorStatementDefault", "(", "fNode", ")", ";", "}", "else", "if", "(", "fieldType", ".", "isResolved", "(", ")", ")", "{", "addError", "(", "createErrorMessage", "(", "cNode", ".", "getName", "(", ")", ",", "fNode", ".", "getName", "(", ")", ",", "fieldType", ".", "getName", "(", ")", ",", "\"compiling\"", ")", ",", "fNode", ")", ";", "}", "else", "{", "statement", "=", "createConstructorStatementGuarded", "(", "cNode", ",", "fNode", ")", ";", "}", "return", "statement", ";", "}", "private", "Statement", "createConstructorStatementGuarded", "(", "ClassNode", "cNode", ",", "FieldNode", "fNode", ")", "{", "final", "Expression", "fieldExpr", "=", "new", "VariableExpression", "(", "fNode", ")", ";", "Expression", "initExpr", "=", "fNode", ".", "getInitialValueExpression", "(", ")", ";", "if", "(", "initExpr", "==", "null", ")", "initExpr", "=", "ConstantExpression", ".", "NULL", ";", "Expression", "unknown", "=", "findArg", "(", "fNode", ".", "getName", "(", ")", ")", ";", "return", "new", "IfStatement", "(", "equalsNullExpr", "(", "unknown", ")", ",", "new", "IfStatement", "(", "equalsNullExpr", "(", "initExpr", ")", ",", "new", "EmptyStatement", "(", ")", ",", "assignStatement", "(", "fieldExpr", ",", "checkUnresolved", "(", "cNode", ",", "fNode", ",", "initExpr", ")", ")", ")", ",", "assignStatement", "(", "fieldExpr", ",", "checkUnresolved", "(", "cNode", ",", "fNode", ",", "unknown", ")", ")", ")", ";", "}", "private", "Expression", "checkUnresolved", "(", "ClassNode", "cNode", ",", "FieldNode", "fNode", ",", "Expression", "value", ")", "{", "Expression", "args", "=", "new", "TupleExpression", "(", "new", "MethodCallExpression", "(", "VariableExpression", ".", "THIS_EXPRESSION", ",", "\"getClass\"", ",", "ArgumentListExpression", ".", "EMPTY_ARGUMENTS", ")", ",", "new", "ConstantExpression", "(", "fNode", ".", "getName", "(", ")", ")", ",", "value", ")", ";", "return", "new", "StaticMethodCallExpression", "(", "SELF_TYPE", ",", "\"\"", ",", "args", ")", ";", "}", "private", "Statement", "createConstructorStatementCollection", "(", "FieldNode", "fNode", ")", "{", "final", "Expression", "fieldExpr", "=", "new", "VariableExpression", "(", "fNode", ")", ";", "Expression", "initExpr", "=", "fNode", ".", "getInitialValueExpression", "(", ")", ";", "if", "(", "initExpr", "==", "null", ")", "initExpr", "=", "ConstantExpression", ".", "NULL", ";", "Expression", "collection", "=", "findArg", "(", "fNode", ".", "getName", "(", ")", ")", ";", "return", "new", "IfStatement", "(", "equalsNullExpr", "(", "collection", ")", ",", "new", "IfStatement", "(", "equalsNullExpr", "(", "initExpr", ")", ",", "new", "EmptyStatement", "(", ")", ",", "assignStatement", "(", "fieldExpr", ",", "cloneCollectionExpr", "(", "initExpr", ")", ")", ")", ",", "new", "IfStatement", "(", "isInstanceOf", "(", "collection", ",", "CLONEABLE_TYPE", ")", ",", "assignStatement", "(", "fieldExpr", ",", "cloneCollectionExpr", "(", "cloneArrayOrCloneableExpr", "(", "collection", ")", ")", ")", ",", "assignStatement", "(", "fieldExpr", ",", "cloneCollectionExpr", "(", "collection", ")", ")", ")", ")", ";", "}", "private", "boolean", "isKnownImmutable", "(", "ClassNode", "fieldType", ",", "List", "<", "String", ">", "knownImmutableClasses", ")", "{", "if", "(", "!", "fieldType", ".", "isResolved", "(", ")", ")", "return", "false", ";", "String", "s", "=", "fieldType", ".", "getName", "(", ")", ";", "return", "fieldType", ".", "isPrimitive", "(", ")", "||", "fieldType", ".", "isEnum", "(", ")", "||", "inImmutableList", "(", "fieldType", ".", "getName", "(", ")", ")", "||", "knownImmutableClasses", ".", "contains", "(", "fieldType", ".", "getName", "(", ")", ")", ";", "}", "private", "static", "boolean", "inImmutableList", "(", "String", "typeName", ")", "{", "return", "immutableList", ".", "contains", "(", "typeName", ")", ";", "}", "private", "Statement", "createConstructorStatementArrayOrCloneable", "(", "FieldNode", "fNode", ")", "{", "final", "Expression", "fieldExpr", "=", "new", "VariableExpression", "(", "fNode", ")", ";", "Expression", "initExpr", "=", "fNode", ".", "getInitialValueExpression", "(", ")", ";", "if", "(", "initExpr", "==", "null", ")", "initExpr", "=", "ConstantExpression", ".", "NULL", ";", "final", "Expression", "array", "=", "findArg", "(", "fNode", ".", "getName", "(", ")", ")", ";", "return", "new", "IfStatement", "(", "equalsNullExpr", "(", "array", ")", ",", "new", "IfStatement", "(", "equalsNullExpr", "(", "initExpr", ")", ",", "assignStatement", "(", "fieldExpr", ",", "ConstantExpression", ".", "NULL", ")", ",", "assignStatement", "(", "fieldExpr", ",", "cloneArrayOrCloneableExpr", "(", "initExpr", ")", ")", ")", ",", "assignStatement", "(", "fieldExpr", ",", "cloneArrayOrCloneableExpr", "(", "array", ")", ")", ")", ";", "}", "private", "Statement", "createConstructorStatementDate", "(", "FieldNode", "fNode", ")", "{", "final", "Expression", "fieldExpr", "=", "new", "VariableExpression", "(", "fNode", ")", ";", "Expression", "initExpr", "=", "fNode", ".", "getInitialValueExpression", "(", ")", ";", "if", "(", "initExpr", "==", "null", ")", "initExpr", "=", "ConstantExpression", ".", "NULL", ";", "final", "Expression", "date", "=", "findArg", "(", "fNode", ".", "getName", "(", ")", ")", ";", "return", "new", "IfStatement", "(", "equalsNullExpr", "(", "date", ")", ",", "new", "IfStatement", "(", "equalsNullExpr", "(", "initExpr", ")", ",", "assignStatement", "(", "fieldExpr", ",", "ConstantExpression", ".", "NULL", ")", ",", "assignStatement", "(", "fieldExpr", ",", "cloneDateExpr", "(", "initExpr", ")", ")", ")", ",", "assignStatement", "(", "fieldExpr", ",", "cloneDateExpr", "(", "date", ")", ")", ")", ";", "}", "private", "Expression", "cloneDateExpr", "(", "Expression", "origDate", ")", "{", "return", "new", "ConstructorCallExpression", "(", "DATE_TYPE", ",", "new", "MethodCallExpression", "(", "origDate", ",", "\"getTime\"", ",", "MethodCallExpression", ".", "NO_ARGUMENTS", ")", ")", ";", "}", "private", "void", "adjustPropertyForImmutability", "(", "PropertyNode", "pNode", ",", "List", "<", "PropertyNode", ">", "newNodes", ")", "{", "final", "FieldNode", "fNode", "=", "pNode", ".", "getField", "(", ")", ";", "fNode", ".", "setModifiers", "(", "(", "pNode", ".", "getModifiers", "(", ")", "&", "(", "~", "ACC_PUBLIC", ")", ")", "|", "ACC_FINAL", "|", "ACC_PRIVATE", ")", ";", "adjustPropertyNode", "(", "pNode", ",", "createGetterBody", "(", "fNode", ")", ")", ";", "newNodes", ".", "add", "(", "pNode", ")", ";", "}", "private", "void", "adjustPropertyNode", "(", "PropertyNode", "pNode", ",", "Statement", "getterBody", ")", "{", "pNode", ".", "setSetterBlock", "(", "null", ")", ";", "pNode", ".", "setGetterBlock", "(", "getterBody", ")", ";", "}", "private", "Statement", "createGetterBody", "(", "FieldNode", "fNode", ")", "{", "BlockStatement", "body", "=", "new", "BlockStatement", "(", ")", ";", "final", "ClassNode", "fieldType", "=", "fNode", ".", "getType", "(", ")", ";", "final", "Statement", "statement", ";", "if", "(", "fieldType", ".", "isArray", "(", ")", "||", "fieldType", ".", "implementsInterface", "(", "CLONEABLE_TYPE", ")", ")", "{", "statement", "=", "createGetterBodyArrayOrCloneable", "(", "fNode", ")", ";", "}", "else", "if", "(", "fieldType", ".", "isDerivedFrom", "(", "DATE_TYPE", ")", ")", "{", "statement", "=", "createGetterBodyDate", "(", "fNode", ")", ";", "}", "else", "{", "statement", "=", "createGetterBodyDefault", "(", "fNode", ")", ";", "}", "body", ".", "addStatement", "(", "statement", ")", ";", "return", "body", ";", "}", "private", "static", "String", "createErrorMessage", "(", "String", "className", ",", "String", "fieldName", ",", "String", "typeName", ",", "String", "mode", ")", "{", "return", "MY_TYPE_NAME", "+", "\"\"", "+", "fieldName", "+", "\"'", "of", "type", "'\"", "+", "prettyTypeName", "(", "typeName", ")", "+", "\"'", "while", "\"", "+", "mode", "+", "\"", "class", "\"", "+", "className", "+", "\".n\"", "+", "MY_TYPE_NAME", "+", "\"\"", "+", "\"\"", "+", "\"-", "other", "\"", "+", "MY_TYPE_NAME", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "MY_TYPE_NAME", "+", "\"\"", ";", "}", "private", "static", "String", "prettyTypeName", "(", "String", "name", ")", "{", "return", "name", ".", "equals", "(", "\"\"", ")", "?", "name", "+", "\"", "or", "def\"", ":", "name", ";", "}", "private", "Statement", "createGetterBodyArrayOrCloneable", "(", "FieldNode", "fNode", ")", "{", "final", "Expression", "fieldExpr", "=", "new", "VariableExpression", "(", "fNode", ")", ";", "final", "Expression", "expression", "=", "cloneArrayOrCloneableExpr", "(", "fieldExpr", ")", ";", "return", "safeExpression", "(", "fieldExpr", ",", "expression", ")", ";", "}", "private", "Statement", "createGetterBodyDate", "(", "FieldNode", "fNode", ")", "{", "final", "Expression", "fieldExpr", "=", "new", "VariableExpression", "(", "fNode", ")", ";", "final", "Expression", "expression", "=", "cloneDateExpr", "(", "fieldExpr", ")", ";", "return", "safeExpression", "(", "fieldExpr", ",", "expression", ")", ";", "}", "@", "SuppressWarnings", "(", "\"Unchecked\"", ")", "public", "static", "Object", "checkImmutable", "(", "String", "className", ",", "String", "fieldName", ",", "Object", "field", ")", "{", "if", "(", "field", "==", "null", "||", "field", "instanceof", "Enum", "||", "inImmutableList", "(", "field", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ")", "return", "field", ";", "if", "(", "field", "instanceof", "Collection", ")", "return", "DefaultGroovyMethods", ".", "asImmutable", "(", "(", "Collection", ")", "field", ")", ";", "if", "(", "field", ".", "getClass", "(", ")", ".", "getAnnotation", "(", "MY_CLASS", ")", "!=", "null", ")", "return", "field", ";", "final", "String", "typeName", "=", "field", ".", "getClass", "(", ")", ".", "getName", "(", ")", ";", "throw", "new", "RuntimeException", "(", "createErrorMessage", "(", "className", ",", "fieldName", ",", "typeName", ",", "\"constructing\"", ")", ")", ";", "}", "@", "SuppressWarnings", "(", "\"Unchecked\"", ")", "public", "static", "Object", "checkImmutable", "(", "Class", "<", "?", ">", "clazz", ",", "String", "fieldName", ",", "Object", "field", ")", "{", "Immutable", "immutable", "=", "(", "Immutable", ")", "clazz", ".", "getAnnotation", "(", "MY_CLASS", ")", ";", "List", "<", "Class", ">", "knownImmutableClasses", "=", "new", "ArrayList", "<", "Class", ">", "(", ")", ";", "if", "(", "immutable", "!=", "null", "&&", "immutable", ".", "knownImmutableClasses", "(", ")", ".", "length", ">", "0", ")", "{", "knownImmutableClasses", "=", "Arrays", ".", "asList", "(", "immutable", ".", "knownImmutableClasses", "(", ")", ")", ";", "}", "if", "(", "field", "==", "null", "||", "field", "instanceof", "Enum", "||", "inImmutableList", "(", "field", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", "||", "knownImmutableClasses", ".", "contains", "(", "field", ".", "getClass", "(", ")", ")", ")", "return", "field", ";", "if", "(", "field", "instanceof", "Collection", ")", "return", "DefaultGroovyMethods", ".", "asImmutable", "(", "(", "Collection", ")", "field", ")", ";", "if", "(", "field", ".", "getClass", "(", ")", ".", "getAnnotation", "(", "MY_CLASS", ")", "!=", "null", ")", "return", "field", ";", "final", "String", "typeName", "=", "field", ".", "getClass", "(", ")", ".", "getName", "(", ")", ";", "throw", "new", "RuntimeException", "(", "createErrorMessage", "(", "clazz", ".", "getName", "(", ")", ",", "fieldName", ",", "typeName", ",", "\"constructing\"", ")", ")", ";", "}", "public", "static", "void", "checkPropNames", "(", "Object", "instance", ",", "Map", "<", "String", ",", "Object", ">", "args", ")", "{", "final", "MetaClass", "metaClass", "=", "InvokerHelper", ".", "getMetaClass", "(", "instance", ")", ";", "for", "(", "String", "k", ":", "args", ".", "keySet", "(", ")", ")", "{", "if", "(", "metaClass", ".", "hasProperty", "(", "instance", ",", "k", ")", "==", "null", ")", "throw", "new", "MissingPropertyException", "(", "k", ",", "instance", ".", "getClass", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
6,921
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "transform", ";", "import", "groovy", ".", "lang", ".", "GroovyObject", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "GroovyBugError", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "ExpressionStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "ReturnStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "classgen", ".", "Verifier", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "CompilePhase", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "SourceUnit", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "SyntaxErrorMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "SyntaxException", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "Token", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "Types", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Modifier", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "@", "GroovyASTTransformation", "(", "phase", "=", "CompilePhase", ".", "CANONICALIZATION", ")", "public", "class", "DelegateASTTransformation", "implements", "ASTTransformation", ",", "Opcodes", "{", "private", "static", "final", "ClassNode", "DEPRECATED_TYPE", "=", "ClassHelper", ".", "make", "(", "Deprecated", ".", "class", ")", ";", "private", "static", "final", "ClassNode", "GROOVYOBJECT_TYPE", "=", "ClassHelper", ".", "make", "(", "GroovyObject", ".", "class", ")", ";", "public", "void", "visit", "(", "ASTNode", "[", "]", "nodes", ",", "SourceUnit", "source", ")", "{", "if", "(", "nodes", ".", "length", "!=", "2", "||", "!", "(", "nodes", "[", "0", "]", "instanceof", "AnnotationNode", ")", "||", "!", "(", "nodes", "[", "1", "]", "instanceof", "AnnotatedNode", ")", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "Arrays", ".", "asList", "(", "nodes", ")", ")", ";", "}", "AnnotatedNode", "parent", "=", "(", "AnnotatedNode", ")", "nodes", "[", "1", "]", ";", "AnnotationNode", "node", "=", "(", "AnnotationNode", ")", "nodes", "[", "0", "]", ";", "if", "(", "parent", "instanceof", "FieldNode", ")", "{", "FieldNode", "fieldNode", "=", "(", "FieldNode", ")", "parent", ";", "final", "ClassNode", "type", "=", "fieldNode", ".", "getType", "(", ")", ";", "final", "ClassNode", "owner", "=", "fieldNode", ".", "getOwner", "(", ")", ";", "if", "(", "type", ".", "equals", "(", "ClassHelper", ".", "OBJECT_TYPE", ")", "||", "type", ".", "equals", "(", "GROOVYOBJECT_TYPE", ")", ")", "{", "addError", "(", "\"\"", "+", "fieldNode", ".", "getName", "(", ")", "+", "\"\"", "+", "type", ".", "getName", "(", ")", "+", "\"\"", ",", "parent", ",", "source", ")", ";", "return", ";", "}", "if", "(", "type", ".", "equals", "(", "owner", ")", ")", "{", "addError", "(", "\"\"", "+", "fieldNode", ".", "getName", "(", ")", "+", "\"\"", "+", "type", ".", "getName", "(", ")", "+", "\"\"", ",", "parent", ",", "source", ")", ";", "return", ";", "}", "final", "List", "<", "MethodNode", ">", "fieldMethods", "=", "getAllMethods", "(", "type", ")", ";", "for", "(", "ClassNode", "next", ":", "type", ".", "getAllInterfaces", "(", ")", ")", "{", "fieldMethods", ".", "addAll", "(", "getAllMethods", "(", "next", ")", ")", ";", "}", "final", "Expression", "deprecatedElement", "=", "node", ".", "getMember", "(", "\"deprecated\"", ")", ";", "final", "boolean", "deprecated", "=", "hasBooleanValue", "(", "deprecatedElement", ",", "true", ")", ";", "final", "List", "<", "MethodNode", ">", "ownerMethods", "=", "getAllMethods", "(", "owner", ")", ";", "for", "(", "MethodNode", "mn", ":", "fieldMethods", ")", "{", "addDelegateMethod", "(", "fieldNode", ",", "owner", ",", "ownerMethods", ",", "mn", ",", "deprecated", ")", ";", "}", "for", "(", "PropertyNode", "prop", ":", "type", ".", "getProperties", "(", ")", ")", "{", "if", "(", "prop", ".", "isStatic", "(", ")", "||", "!", "prop", ".", "isPublic", "(", ")", ")", "continue", ";", "String", "name", "=", "prop", ".", "getName", "(", ")", ";", "addGetterIfNeeded", "(", "fieldNode", ",", "owner", ",", "prop", ",", "name", ")", ";", "addSetterIfNeeded", "(", "fieldNode", ",", "owner", ",", "prop", ",", "name", ")", ";", "}", "final", "Expression", "interfacesElement", "=", "node", ".", "getMember", "(", "\"interfaces\"", ")", ";", "if", "(", "hasBooleanValue", "(", "interfacesElement", ",", "false", ")", ")", "return", ";", "final", "Set", "<", "ClassNode", ">", "allInterfaces", "=", "type", ".", "getAllInterfaces", "(", ")", ";", "final", "Set", "<", "ClassNode", ">", "ownerIfaces", "=", "owner", ".", "getAllInterfaces", "(", ")", ";", "for", "(", "ClassNode", "iface", ":", "allInterfaces", ")", "{", "if", "(", "Modifier", ".", "isPublic", "(", "iface", ".", "getModifiers", "(", ")", ")", "&&", "!", "ownerIfaces", ".", "contains", "(", "iface", ")", ")", "{", "final", "ClassNode", "[", "]", "ifaces", "=", "owner", ".", "getInterfaces", "(", ")", ";", "final", "ClassNode", "[", "]", "newIfaces", "=", "new", "ClassNode", "[", "ifaces", ".", "length", "+", "1", "]", ";", "System", ".", "arraycopy", "(", "ifaces", ",", "0", ",", "newIfaces", ",", "0", ",", "ifaces", ".", "length", ")", ";", "newIfaces", "[", "ifaces", ".", "length", "]", "=", "iface", ";", "owner", ".", "setInterfaces", "(", "newIfaces", ")", ";", "}", "}", "}", "}", "private", "List", "<", "MethodNode", ">", "getAllMethods", "(", "ClassNode", "type", ")", "{", "ClassNode", "node", "=", "type", ";", "List", "<", "MethodNode", ">", "result", "=", "new", "ArrayList", "<", "MethodNode", ">", "(", ")", ";", "while", "(", "node", "!=", "null", ")", "{", "result", ".", "addAll", "(", "node", ".", "getMethods", "(", ")", ")", ";", "node", "=", "node", ".", "getSuperClass", "(", ")", ";", "}", "return", "result", ";", "}", "private", "boolean", "hasBooleanValue", "(", "Expression", "expression", ",", "boolean", "bool", ")", "{", "return", "expression", "instanceof", "ConstantExpression", "&&", "(", "(", "ConstantExpression", ")", "expression", ")", ".", "getValue", "(", ")", ".", "equals", "(", "bool", ")", ";", "}", "private", "void", "addSetterIfNeeded", "(", "FieldNode", "fieldNode", ",", "ClassNode", "owner", ",", "PropertyNode", "prop", ",", "String", "name", ")", "{", "String", "setterName", "=", "\"set\"", "+", "Verifier", ".", "capitalize", "(", "name", ")", ";", "if", "(", "(", "prop", ".", "getModifiers", "(", ")", "&", "ACC_FINAL", ")", "==", "0", "&&", "owner", ".", "getSetterMethod", "(", "setterName", ")", "==", "null", ")", "{", "owner", ".", "addMethod", "(", "setterName", ",", "ACC_PUBLIC", ",", "ClassHelper", ".", "VOID_TYPE", ",", "new", "Parameter", "[", "]", "{", "new", "Parameter", "(", "nonGeneric", "(", "prop", ".", "getType", "(", ")", ")", ",", "\"value\"", ")", "}", ",", "null", ",", "new", "ExpressionStatement", "(", "new", "BinaryExpression", "(", "new", "PropertyExpression", "(", "new", "VariableExpression", "(", "fieldNode", ")", ",", "name", ")", ",", "Token", ".", "newSymbol", "(", "Types", ".", "EQUAL", ",", "-", "1", ",", "-", "1", ")", ",", "new", "VariableExpression", "(", "\"value\"", ")", ")", ")", ")", ";", "}", "}", "private", "void", "addGetterIfNeeded", "(", "FieldNode", "fieldNode", ",", "ClassNode", "owner", ",", "PropertyNode", "prop", ",", "String", "name", ")", "{", "String", "getterName", "=", "\"get\"", "+", "Verifier", ".", "capitalize", "(", "name", ")", ";", "if", "(", "owner", ".", "getGetterMethod", "(", "getterName", ")", "==", "null", ")", "{", "owner", ".", "addMethod", "(", "getterName", ",", "ACC_PUBLIC", ",", "nonGeneric", "(", "prop", ".", "getType", "(", ")", ")", ",", "Parameter", ".", "EMPTY_ARRAY", ",", "null", ",", "new", "ReturnStatement", "(", "new", "PropertyExpression", "(", "new", "VariableExpression", "(", "fieldNode", ")", ",", "name", ")", ")", ")", ";", "}", "}", "private", "void", "addDelegateMethod", "(", "FieldNode", "fieldNode", ",", "ClassNode", "owner", ",", "List", "<", "MethodNode", ">", "ownMethods", ",", "MethodNode", "candidate", ",", "boolean", "deprecated", ")", "{", "if", "(", "!", "candidate", ".", "isPublic", "(", ")", "||", "candidate", ".", "isStatic", "(", ")", "||", "0", "!=", "(", "candidate", ".", "getModifiers", "(", ")", "&", "Opcodes", ".", "ACC_SYNTHETIC", ")", ")", "return", ";", "if", "(", "!", "candidate", ".", "getAnnotations", "(", "DEPRECATED_TYPE", ")", ".", "isEmpty", "(", ")", "&&", "!", "deprecated", ")", "return", ";", "for", "(", "MethodNode", "mn", ":", "GROOVYOBJECT_TYPE", ".", "getMethods", "(", ")", ")", "{", "if", "(", "mn", ".", "getTypeDescriptor", "(", ")", ".", "equals", "(", "candidate", ".", "getTypeDescriptor", "(", ")", ")", ")", "{", "return", ";", "}", "}", "for", "(", "MethodNode", "mn", ":", "owner", ".", "getMethods", "(", ")", ")", "{", "if", "(", "mn", ".", "getTypeDescriptor", "(", ")", ".", "equals", "(", "candidate", ".", "getTypeDescriptor", "(", ")", ")", ")", "{", "return", ";", "}", "}", "MethodNode", "existingNode", "=", "null", ";", "for", "(", "MethodNode", "mn", ":", "ownMethods", ")", "{", "if", "(", "mn", ".", "getTypeDescriptor", "(", ")", ".", "equals", "(", "candidate", ".", "getTypeDescriptor", "(", ")", ")", "&&", "!", "mn", ".", "isAbstract", "(", ")", "&&", "!", "mn", ".", "isStatic", "(", ")", ")", "{", "existingNode", "=", "mn", ";", "break", ";", "}", "}", "if", "(", "existingNode", "==", "null", "||", "existingNode", ".", "getCode", "(", ")", "==", "null", ")", "{", "final", "ArgumentListExpression", "args", "=", "new", "ArgumentListExpression", "(", ")", ";", "final", "Parameter", "[", "]", "params", "=", "candidate", ".", "getParameters", "(", ")", ";", "final", "Parameter", "[", "]", "newParams", "=", "new", "Parameter", "[", "params", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "newParams", ".", "length", ";", "i", "++", ")", "{", "Parameter", "newParam", "=", "new", "Parameter", "(", "nonGeneric", "(", "params", "[", "i", "]", ".", "getType", "(", ")", ")", ",", "params", "[", "i", "]", ".", "getName", "(", ")", ")", ";", "newParam", ".", "setInitialExpression", "(", "params", "[", "i", "]", ".", "getInitialExpression", "(", ")", ")", ";", "newParams", "[", "i", "]", "=", "newParam", ";", "args", ".", "addExpression", "(", "new", "VariableExpression", "(", "newParam", ")", ")", ";", "}", "MethodNode", "newMethod", "=", "owner", ".", "addMethod", "(", "candidate", ".", "getName", "(", ")", ",", "candidate", ".", "getModifiers", "(", ")", "&", "(", "~", "ACC_ABSTRACT", ")", "&", "(", "~", "ACC_NATIVE", ")", ",", "nonGeneric", "(", "candidate", ".", "getReturnType", "(", ")", ")", ",", "newParams", ",", "candidate", ".", "getExceptions", "(", ")", ",", "new", "ExpressionStatement", "(", "new", "MethodCallExpression", "(", "new", "VariableExpression", "(", "fieldNode", ")", ",", "candidate", ".", "getName", "(", ")", ",", "args", ")", ")", ")", ";", "newMethod", ".", "setGenericsTypes", "(", "candidate", ".", "getGenericsTypes", "(", ")", ")", ";", "}", "}", "private", "ClassNode", "nonGeneric", "(", "ClassNode", "type", ")", "{", "if", "(", "type", ".", "isUsingGenerics", "(", ")", ")", "{", "final", "ClassNode", "nonGen", "=", "ClassHelper", ".", "makeWithoutCaching", "(", "type", ".", "getName", "(", ")", ")", ";", "nonGen", ".", "setRedirect", "(", "type", ")", ";", "nonGen", ".", "setGenericsTypes", "(", "null", ")", ";", "nonGen", ".", "setUsingGenerics", "(", "false", ")", ";", "return", "nonGen", ";", "}", "else", "if", "(", "type", ".", "isArray", "(", ")", "&&", "type", ".", "getComponentType", "(", ")", ".", "isUsingGenerics", "(", ")", ")", "{", "return", "type", ".", "getComponentType", "(", ")", ".", "getPlainNodeReference", "(", ")", ".", "makeArray", "(", ")", ";", "}", "else", "{", "return", "type", ";", "}", "}", "public", "void", "addError", "(", "String", "msg", ",", "ASTNode", "expr", ",", "SourceUnit", "source", ")", "{", "source", ".", "getErrorCollector", "(", ")", ".", "addErrorAndContinue", "(", "new", "SyntaxErrorMessage", "(", "new", "SyntaxException", "(", "msg", "+", "'\\n'", ",", "expr", ".", "getLineNumber", "(", ")", ",", "expr", ".", "getColumnNumber", "(", ")", ",", "expr", ".", "getLastLineNumber", "(", ")", ",", "expr", ".", "getLastColumnNumber", "(", ")", ")", ",", "source", ")", ")", ";", "}", "}", "</s>" ]
6,922
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "sc", ".", "transformers", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ClassHelper", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ClassNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "GroovyCodeVisitor", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "BinaryExpression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "Expression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "ExpressionTransformer", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "classgen", ".", "AsmClassGenerator", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "classgen", ".", "asm", ".", "WriterController", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "Token", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "Types", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Label", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "MethodVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "public", "class", "CompareIdentityExpression", "extends", "BinaryExpression", "implements", "Opcodes", "{", "private", "final", "Expression", "leftExpression", ";", "private", "final", "Expression", "rightExpression", ";", "public", "CompareIdentityExpression", "(", "final", "Expression", "leftExpression", ",", "final", "Expression", "rightExpression", ")", "{", "super", "(", "leftExpression", ",", "new", "Token", "(", "Types", ".", "COMPARE_TO", ",", "\"==\"", ",", "-", "1", ",", "-", "1", ")", ",", "rightExpression", ")", ";", "this", ".", "leftExpression", "=", "leftExpression", ";", "this", ".", "rightExpression", "=", "rightExpression", ";", "}", "@", "Override", "public", "Expression", "transformExpression", "(", "final", "ExpressionTransformer", "transformer", ")", "{", "return", "this", ";", "}", "@", "Override", "public", "void", "visit", "(", "final", "GroovyCodeVisitor", "visitor", ")", "{", "if", "(", "visitor", "instanceof", "AsmClassGenerator", ")", "{", "AsmClassGenerator", "acg", "=", "(", "AsmClassGenerator", ")", "visitor", ";", "WriterController", "controller", "=", "acg", ".", "getController", "(", ")", ";", "ClassNode", "leftType", "=", "controller", ".", "getTypeChooser", "(", ")", ".", "resolveType", "(", "leftExpression", ",", "controller", ".", "getClassNode", "(", ")", ")", ";", "ClassNode", "rightType", "=", "controller", ".", "getTypeChooser", "(", ")", ".", "resolveType", "(", "rightExpression", ",", "controller", ".", "getClassNode", "(", ")", ")", ";", "if", "(", "ClassHelper", ".", "isPrimitiveType", "(", "leftType", ")", "||", "ClassHelper", ".", "isPrimitiveType", "(", "rightType", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "MethodVisitor", "mv", "=", "controller", ".", "getMethodVisitor", "(", ")", ";", "leftExpression", ".", "visit", "(", "acg", ")", ";", "rightExpression", ".", "visit", "(", "acg", ")", ";", "Label", "l1", "=", "new", "Label", "(", ")", ";", "mv", ".", "visitJumpInsn", "(", "IF_ACMPNE", ",", "l1", ")", ";", "mv", ".", "visitInsn", "(", "ICONST_1", ")", ";", "Label", "l2", "=", "new", "Label", "(", ")", ";", "mv", ".", "visitJumpInsn", "(", "GOTO", ",", "l2", ")", ";", "mv", ".", "visitLabel", "(", "l1", ")", ";", "mv", ".", "visitInsn", "(", "ICONST_0", ")", ";", "mv", ".", "visitLabel", "(", "l2", ")", ";", "controller", ".", "getOperandStack", "(", ")", ".", "replace", "(", "ClassHelper", ".", "boolean_TYPE", ",", "2", ")", ";", "}", "else", "{", "super", ".", "visit", "(", "visitor", ")", ";", "}", "}", "}", "</s>" ]
6,923
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "sc", ".", "transformers", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ClassHelper", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ClassNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "MethodNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "classgen", ".", "asm", ".", "sc", ".", "StaticTypesTypeChooser", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "Token", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "Types", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "sc", ".", "ListOfExpressionsExpression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "stc", ".", "StaticTypeCheckingSupport", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "stc", ".", "StaticTypesMarker", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "static", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "sc", ".", "StaticCompilationMetadataKeys", ".", "*", ";", "public", "class", "BinaryExpressionTransformer", "{", "private", "final", "static", "MethodNode", "COMPARE_TO_METHOD", "=", "ClassHelper", ".", "COMPARABLE_TYPE", ".", "getMethods", "(", "\"compareTo\"", ")", ".", "get", "(", "0", ")", ";", "private", "static", "final", "ConstantExpression", "CONSTANT_ZERO", "=", "new", "ConstantExpression", "(", "0", ",", "true", ")", ";", "private", "static", "final", "ConstantExpression", "CONSTANT_MINUS_ONE", "=", "new", "ConstantExpression", "(", "-", "1", ",", "true", ")", ";", "private", "static", "final", "ConstantExpression", "CONSTANT_ONE", "=", "new", "ConstantExpression", "(", "1", ",", "true", ")", ";", "static", "{", "CONSTANT_ZERO", ".", "setType", "(", "ClassHelper", ".", "int_TYPE", ")", ";", "CONSTANT_ONE", ".", "setType", "(", "ClassHelper", ".", "int_TYPE", ")", ";", "CONSTANT_MINUS_ONE", ".", "setType", "(", "ClassHelper", ".", "int_TYPE", ")", ";", "}", "private", "final", "StaticCompilationTransformer", "staticCompilationTransformer", ";", "public", "BinaryExpressionTransformer", "(", "StaticCompilationTransformer", "staticCompilationTransformer", ")", "{", "this", ".", "staticCompilationTransformer", "=", "staticCompilationTransformer", ";", "}", "Expression", "transformBinaryExpression", "(", "final", "BinaryExpression", "bin", ")", "{", "Object", "[", "]", "list", "=", "(", "Object", "[", "]", ")", "bin", ".", "getNodeMetaData", "(", "BINARY_EXP_TARGET", ")", ";", "Token", "operation", "=", "bin", ".", "getOperation", "(", ")", ";", "int", "operationType", "=", "operation", ".", "getType", "(", ")", ";", "if", "(", "operationType", "==", "Types", ".", "COMPARE_EQUAL", "||", "operationType", "==", "Types", ".", "COMPARE_NOT_EQUAL", ")", "{", "CompareToNullExpression", "compareToNullExpression", "=", "null", ";", "if", "(", "isNullConstant", "(", "bin", ".", "getLeftExpression", "(", ")", ")", ")", "{", "compareToNullExpression", "=", "new", "CompareToNullExpression", "(", "staticCompilationTransformer", ".", "transform", "(", "bin", ".", "getRightExpression", "(", ")", ")", ",", "operationType", "==", "Types", ".", "COMPARE_EQUAL", ")", ";", "}", "else", "if", "(", "isNullConstant", "(", "bin", ".", "getRightExpression", "(", ")", ")", ")", "{", "compareToNullExpression", "=", "new", "CompareToNullExpression", "(", "staticCompilationTransformer", ".", "transform", "(", "bin", ".", "getLeftExpression", "(", ")", ")", ",", "operationType", "==", "Types", ".", "COMPARE_EQUAL", ")", ";", "}", "if", "(", "compareToNullExpression", "!=", "null", ")", "{", "compareToNullExpression", ".", "setSourcePosition", "(", "bin", ")", ";", "return", "compareToNullExpression", ";", "}", "}", "if", "(", "list", "!=", "null", ")", "{", "if", "(", "operationType", "==", "Types", ".", "COMPARE_TO", ")", "{", "StaticTypesTypeChooser", "typeChooser", "=", "staticCompilationTransformer", ".", "getTypeChooser", "(", ")", ";", "ClassNode", "classNode", "=", "staticCompilationTransformer", ".", "getClassNode", "(", ")", ";", "ClassNode", "leftType", "=", "typeChooser", ".", "resolveType", "(", "bin", ".", "getLeftExpression", "(", ")", ",", "classNode", ")", ";", "if", "(", "leftType", ".", "implementsInterface", "(", "ClassHelper", ".", "COMPARABLE_TYPE", ")", ")", "{", "ClassNode", "rightType", "=", "typeChooser", ".", "resolveType", "(", "bin", ".", "getRightExpression", "(", ")", ",", "classNode", ")", ";", "if", "(", "rightType", ".", "implementsInterface", "(", "ClassHelper", ".", "COMPARABLE_TYPE", ")", ")", "{", "Expression", "left", "=", "staticCompilationTransformer", ".", "transform", "(", "bin", ".", "getLeftExpression", "(", ")", ")", ";", "Expression", "right", "=", "staticCompilationTransformer", ".", "transform", "(", "bin", ".", "getRightExpression", "(", ")", ")", ";", "MethodCallExpression", "call", "=", "new", "MethodCallExpression", "(", "left", ",", "\"compareTo\"", ",", "new", "ArgumentListExpression", "(", "right", ")", ")", ";", "call", ".", "setImplicitThis", "(", "false", ")", ";", "call", ".", "setMethodTarget", "(", "COMPARE_TO_METHOD", ")", ";", "CompareIdentityExpression", "compareIdentity", "=", "new", "CompareIdentityExpression", "(", "left", ",", "right", ")", ";", "compareIdentity", ".", "setSourcePosition", "(", "bin", ")", ";", "compareIdentity", ".", "putNodeMetaData", "(", "StaticTypesMarker", ".", "INFERRED_RETURN_TYPE", ",", "ClassHelper", ".", "boolean_TYPE", ")", ";", "TernaryExpression", "result", "=", "new", "TernaryExpression", "(", "new", "BooleanExpression", "(", "compareIdentity", ")", ",", "CONSTANT_ZERO", ",", "new", "TernaryExpression", "(", "new", "BooleanExpression", "(", "new", "CompareToNullExpression", "(", "left", ",", "true", ")", ")", ",", "CONSTANT_MINUS_ONE", ",", "new", "TernaryExpression", "(", "new", "BooleanExpression", "(", "new", "CompareToNullExpression", "(", "right", ",", "true", ")", ")", ",", "CONSTANT_ONE", ",", "call", ")", ")", ")", ";", "compareIdentity", ".", "putNodeMetaData", "(", "StaticTypesMarker", ".", "INFERRED_RETURN_TYPE", ",", "ClassHelper", ".", "int_TYPE", ")", ";", "result", ".", "putNodeMetaData", "(", "StaticTypesMarker", ".", "INFERRED_TYPE", ",", "ClassHelper", ".", "int_TYPE", ")", ";", "TernaryExpression", "expr", "=", "(", "TernaryExpression", ")", "result", ".", "getFalseExpression", "(", ")", ";", "expr", ".", "putNodeMetaData", "(", "StaticTypesMarker", ".", "INFERRED_TYPE", ",", "ClassHelper", ".", "int_TYPE", ")", ";", "expr", ".", "getFalseExpression", "(", ")", ".", "putNodeMetaData", "(", "StaticTypesMarker", ".", "INFERRED_TYPE", ",", "ClassHelper", ".", "int_TYPE", ")", ";", "return", "result", ";", "}", "}", "}", "boolean", "isAssignment", "=", "StaticTypeCheckingSupport", ".", "isAssignment", "(", "operationType", ")", ";", "MethodCallExpression", "call", ";", "MethodNode", "node", "=", "(", "MethodNode", ")", "list", "[", "0", "]", ";", "String", "name", "=", "(", "String", ")", "list", "[", "1", "]", ";", "Expression", "left", "=", "staticCompilationTransformer", ".", "transform", "(", "bin", ".", "getLeftExpression", "(", ")", ")", ";", "Expression", "right", "=", "staticCompilationTransformer", ".", "transform", "(", "bin", ".", "getRightExpression", "(", ")", ")", ";", "call", "=", "new", "MethodCallExpression", "(", "left", ",", "name", ",", "new", "ArgumentListExpression", "(", "right", ")", ")", ";", "call", ".", "setImplicitThis", "(", "false", ")", ";", "call", ".", "setMethodTarget", "(", "node", ")", ";", "MethodNode", "adapter", "=", "StaticCompilationTransformer", ".", "BYTECODE_BINARY_ADAPTERS", ".", "get", "(", "operationType", ")", ";", "if", "(", "adapter", "!=", "null", ")", "{", "ClassExpression", "sba", "=", "new", "ClassExpression", "(", "StaticCompilationTransformer", ".", "BYTECODE_ADAPTER_CLASS", ")", ";", "call", "=", "new", "MethodCallExpression", "(", "sba", ",", "\"\"", ",", "new", "ArgumentListExpression", "(", "left", ",", "right", ")", ")", ";", "call", ".", "setMethodTarget", "(", "adapter", ")", ";", "call", ".", "setImplicitThis", "(", "false", ")", ";", "}", "if", "(", "!", "isAssignment", ")", "return", "call", ";", "return", "new", "BinaryExpression", "(", "left", ",", "Token", ".", "newSymbol", "(", "\"=\"", ",", "operation", ".", "getStartLine", "(", ")", ",", "operation", ".", "getStartColumn", "(", ")", ")", ",", "call", ")", ";", "}", "if", "(", "bin", ".", "getOperation", "(", ")", ".", "getType", "(", ")", "==", "Types", ".", "EQUAL", "&&", "bin", ".", "getLeftExpression", "(", ")", "instanceof", "TupleExpression", "&&", "bin", ".", "getRightExpression", "(", ")", "instanceof", "ListExpression", ")", "{", "ListOfExpressionsExpression", "cle", "=", "new", "ListOfExpressionsExpression", "(", ")", ";", "boolean", "isDeclaration", "=", "bin", "instanceof", "DeclarationExpression", ";", "List", "<", "Expression", ">", "leftExpressions", "=", "(", "(", "TupleExpression", ")", "bin", ".", "getLeftExpression", "(", ")", ")", ".", "getExpressions", "(", ")", ";", "List", "<", "Expression", ">", "rightExpressions", "=", "(", "(", "ListExpression", ")", "bin", ".", "getRightExpression", "(", ")", ")", ".", "getExpressions", "(", ")", ";", "Iterator", "<", "Expression", ">", "leftIt", "=", "leftExpressions", ".", "iterator", "(", ")", ";", "Iterator", "<", "Expression", ">", "rightIt", "=", "rightExpressions", ".", "iterator", "(", ")", ";", "while", "(", "leftIt", ".", "hasNext", "(", ")", ")", "{", "Expression", "left", "=", "leftIt", ".", "next", "(", ")", ";", "if", "(", "rightIt", ".", "hasNext", "(", ")", ")", "{", "Expression", "right", "=", "rightIt", ".", "next", "(", ")", ";", "BinaryExpression", "bexp", "=", "isDeclaration", "?", "new", "DeclarationExpression", "(", "left", ",", "bin", ".", "getOperation", "(", ")", ",", "right", ")", ":", "new", "BinaryExpression", "(", "left", ",", "bin", ".", "getOperation", "(", ")", ",", "right", ")", ";", "bexp", ".", "setSourcePosition", "(", "right", ")", ";", "cle", ".", "addExpression", "(", "bexp", ")", ";", "}", "}", "return", "staticCompilationTransformer", ".", "transform", "(", "cle", ")", ";", "}", "return", "staticCompilationTransformer", ".", "superTransform", "(", "bin", ")", ";", "}", "protected", "static", "boolean", "isNullConstant", "(", "final", "Expression", "expression", ")", "{", "return", "expression", "instanceof", "ConstantExpression", "&&", "(", "(", "ConstantExpression", ")", "expression", ")", ".", "getValue", "(", ")", "==", "null", ";", "}", "}", "</s>" ]
6,924
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "sc", ".", "transformers", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ClassHelper", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ClassNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "GroovyCodeVisitor", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "BinaryExpression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "ConstantExpression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "Expression", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "ExpressionTransformer", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "classgen", ".", "AsmClassGenerator", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "classgen", ".", "asm", ".", "WriterController", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "Token", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "Types", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Label", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "MethodVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "public", "class", "CompareToNullExpression", "extends", "BinaryExpression", "implements", "Opcodes", "{", "private", "final", "boolean", "equalsNull", ";", "private", "final", "Expression", "objectExpression", ";", "public", "CompareToNullExpression", "(", "final", "Expression", "objectExpression", ",", "final", "boolean", "compareToNull", ")", "{", "super", "(", "objectExpression", ",", "new", "Token", "(", "Types", ".", "COMPARE_TO", ",", "compareToNull", "?", "\"==\"", ":", "\"!=\"", ",", "-", "1", ",", "-", "1", ")", ",", "ConstantExpression", ".", "NULL", ")", ";", "this", ".", "objectExpression", "=", "objectExpression", ";", "this", ".", "equalsNull", "=", "compareToNull", ";", "}", "public", "Expression", "getObjectExpression", "(", ")", "{", "return", "objectExpression", ";", "}", "@", "Override", "public", "Expression", "transformExpression", "(", "final", "ExpressionTransformer", "transformer", ")", "{", "return", "this", ";", "}", "@", "Override", "public", "void", "visit", "(", "final", "GroovyCodeVisitor", "visitor", ")", "{", "if", "(", "visitor", "instanceof", "AsmClassGenerator", ")", "{", "AsmClassGenerator", "acg", "=", "(", "AsmClassGenerator", ")", "visitor", ";", "WriterController", "controller", "=", "acg", ".", "getController", "(", ")", ";", "ClassNode", "objectType", "=", "controller", ".", "getTypeChooser", "(", ")", ".", "resolveType", "(", "objectExpression", ",", "controller", ".", "getClassNode", "(", ")", ")", ";", "MethodVisitor", "mv", "=", "controller", ".", "getMethodVisitor", "(", ")", ";", "if", "(", "ClassHelper", ".", "isPrimitiveType", "(", "objectType", ")", ")", "{", "mv", ".", "visitInsn", "(", "ICONST_0", ")", ";", "controller", ".", "getOperandStack", "(", ")", ".", "push", "(", "ClassHelper", ".", "boolean_TYPE", ")", ";", "}", "else", "{", "objectExpression", ".", "visit", "(", "acg", ")", ";", "Label", "zero", "=", "new", "Label", "(", ")", ";", "mv", ".", "visitJumpInsn", "(", "equalsNull", "?", "IFNONNULL", ":", "IFNULL", ",", "zero", ")", ";", "mv", ".", "visitInsn", "(", "ICONST_1", ")", ";", "Label", "end", "=", "new", "Label", "(", ")", ";", "mv", ".", "visitJumpInsn", "(", "GOTO", ",", "end", ")", ";", "mv", ".", "visitLabel", "(", "zero", ")", ";", "mv", ".", "visitInsn", "(", "ICONST_0", ")", ";", "mv", ".", "visitLabel", "(", "end", ")", ";", "controller", ".", "getOperandStack", "(", ")", ".", "replace", "(", "ClassHelper", ".", "boolean_TYPE", ")", ";", "}", "}", "else", "{", "super", ".", "visit", "(", "visitor", ")", ";", "}", "}", "}", "</s>" ]
6,925
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "stc", ";", "import", "groovy", ".", "lang", ".", "GroovySystem", ";", "import", "groovy", ".", "lang", ".", "MetaClassRegistry", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "tools", ".", "GenericsUtils", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "tools", ".", "WideningCategories", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "runtime", ".", "DefaultGroovyMethods", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "runtime", ".", "DefaultGroovyStaticMethods", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "runtime", ".", "m12n", ".", "ExtensionModule", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "runtime", ".", "m12n", ".", "ExtensionModuleRegistry", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "runtime", ".", "m12n", ".", "MetaInfExtensionModule", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "runtime", ".", "metaclass", ".", "MetaClassRegistryImpl", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "java", ".", "util", ".", "*", ";", "import", "java", ".", "util", ".", "concurrent", ".", "locks", ".", "ReentrantReadWriteLock", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "static", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ClassHelper", ".", "*", ";", "import", "static", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "Types", ".", "*", ";", "public", "abstract", "class", "StaticTypeCheckingSupport", "{", "final", "static", "ClassNode", "Collection_TYPE", "=", "makeWithoutCaching", "(", "Collection", ".", "class", ")", ";", "final", "static", "ClassNode", "Deprecated_TYPE", "=", "makeWithoutCaching", "(", "Deprecated", ".", "class", ")", ";", "final", "static", "ClassNode", "Matcher_TYPE", "=", "makeWithoutCaching", "(", "Matcher", ".", "class", ")", ";", "final", "static", "ClassNode", "ArrayList_TYPE", "=", "makeWithoutCaching", "(", "ArrayList", ".", "class", ")", ";", "final", "static", "ExtensionMethodCache", "EXTENSION_METHOD_CACHE", "=", "new", "ExtensionMethodCache", "(", ")", ";", "final", "static", "Map", "<", "ClassNode", ",", "Integer", ">", "NUMBER_TYPES", "=", "Collections", ".", "unmodifiableMap", "(", "new", "HashMap", "<", "ClassNode", ",", "Integer", ">", "(", ")", "{", "{", "put", "(", "ClassHelper", ".", "byte_TYPE", ",", "0", ")", ";", "put", "(", "ClassHelper", ".", "Byte_TYPE", ",", "0", ")", ";", "put", "(", "ClassHelper", ".", "short_TYPE", ",", "1", ")", ";", "put", "(", "ClassHelper", ".", "Short_TYPE", ",", "1", ")", ";", "put", "(", "ClassHelper", ".", "int_TYPE", ",", "2", ")", ";", "put", "(", "ClassHelper", ".", "Integer_TYPE", ",", "2", ")", ";", "put", "(", "ClassHelper", ".", "Long_TYPE", ",", "3", ")", ";", "put", "(", "ClassHelper", ".", "long_TYPE", ",", "3", ")", ";", "put", "(", "ClassHelper", ".", "float_TYPE", ",", "4", ")", ";", "put", "(", "ClassHelper", ".", "Float_TYPE", ",", "4", ")", ";", "put", "(", "ClassHelper", ".", "double_TYPE", ",", "5", ")", ";", "put", "(", "ClassHelper", ".", "Double_TYPE", ",", "5", ")", ";", "}", "}", ")", ";", "final", "static", "ClassNode", "GSTRING_STRING_CLASSNODE", "=", "WideningCategories", ".", "lowestUpperBound", "(", "ClassHelper", ".", "STRING_TYPE", ",", "ClassHelper", ".", "GSTRING_TYPE", ")", ";", "final", "static", "ClassNode", "UNKNOWN_PARAMETER_TYPE", "=", "ClassHelper", ".", "make", "(", "\"\"", ")", ";", "private", "static", "final", "Comparator", "<", "MethodNode", ">", "DGM_METHOD_NODE_COMPARATOR", "=", "new", "Comparator", "<", "MethodNode", ">", "(", ")", "{", "public", "int", "compare", "(", "final", "MethodNode", "o1", ",", "final", "MethodNode", "o2", ")", "{", "if", "(", "o1", ".", "getName", "(", ")", ".", "equals", "(", "o2", ".", "getName", "(", ")", ")", ")", "{", "Parameter", "[", "]", "o1ps", "=", "o1", ".", "getParameters", "(", ")", ";", "Parameter", "[", "]", "o2ps", "=", "o2", ".", "getParameters", "(", ")", ";", "if", "(", "o1ps", ".", "length", "==", "o2ps", ".", "length", ")", "{", "boolean", "allEqual", "=", "true", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "o1ps", ".", "length", "&&", "allEqual", ";", "i", "++", ")", "{", "allEqual", "=", "o1ps", "[", "i", "]", ".", "getType", "(", ")", ".", "equals", "(", "o2ps", "[", "i", "]", ".", "getType", "(", ")", ")", ";", "}", "if", "(", "allEqual", ")", "{", "if", "(", "o1", "instanceof", "ExtensionMethodNode", "&&", "o2", "instanceof", "ExtensionMethodNode", ")", "{", "return", "compare", "(", "(", "(", "ExtensionMethodNode", ")", "o1", ")", ".", "getExtensionMethodNode", "(", ")", ",", "(", "(", "ExtensionMethodNode", ")", "o2", ")", ".", "getExtensionMethodNode", "(", ")", ")", ";", "}", "return", "0", ";", "}", "}", "else", "{", "return", "o1ps", ".", "length", "-", "o2ps", ".", "length", ";", "}", "}", "return", "1", ";", "}", "}", ";", "static", "boolean", "isArrayAccessExpression", "(", "Expression", "expression", ")", "{", "return", "expression", "instanceof", "BinaryExpression", "&&", "isArrayOp", "(", "(", "(", "BinaryExpression", ")", "expression", ")", ".", "getOperation", "(", ")", ".", "getType", "(", ")", ")", ";", "}", "public", "static", "boolean", "isWithCall", "(", "final", "String", "name", ",", "final", "Expression", "callArguments", ")", "{", "boolean", "isWithCall", "=", "\"with\"", ".", "equals", "(", "name", ")", "&&", "callArguments", "instanceof", "ArgumentListExpression", ";", "if", "(", "isWithCall", ")", "{", "ArgumentListExpression", "argList", "=", "(", "ArgumentListExpression", ")", "callArguments", ";", "List", "<", "Expression", ">", "expressions", "=", "argList", ".", "getExpressions", "(", ")", ";", "isWithCall", "=", "expressions", ".", "size", "(", ")", "==", "1", "&&", "expressions", ".", "get", "(", "0", ")", "instanceof", "ClosureExpression", ";", "}", "return", "isWithCall", ";", "}", "static", "Variable", "findTargetVariable", "(", "VariableExpression", "ve", ")", "{", "final", "Variable", "accessedVariable", "=", "ve", ".", "getAccessedVariable", "(", ")", "!=", "null", "?", "ve", ".", "getAccessedVariable", "(", ")", ":", "ve", ";", "if", "(", "accessedVariable", "!=", "ve", ")", "{", "if", "(", "accessedVariable", "instanceof", "VariableExpression", ")", "return", "findTargetVariable", "(", "(", "VariableExpression", ")", "accessedVariable", ")", ";", "}", "return", "accessedVariable", ";", "}", "static", "Set", "<", "MethodNode", ">", "findDGMMethodsForClassNode", "(", "ClassNode", "clazz", ",", "String", "name", ")", "{", "TreeSet", "<", "MethodNode", ">", "accumulator", "=", "new", "TreeSet", "<", "MethodNode", ">", "(", "DGM_METHOD_NODE_COMPARATOR", ")", ";", "findDGMMethodsForClassNode", "(", "clazz", ",", "name", ",", "accumulator", ")", ";", "return", "accumulator", ";", "}", "static", "void", "findDGMMethodsForClassNode", "(", "ClassNode", "clazz", ",", "String", "name", ",", "TreeSet", "<", "MethodNode", ">", "accumulator", ")", "{", "List", "<", "MethodNode", ">", "fromDGM", "=", "EXTENSION_METHOD_CACHE", ".", "getExtensionMethods", "(", ")", ".", "get", "(", "clazz", ".", "getName", "(", ")", ")", ";", "if", "(", "fromDGM", "!=", "null", ")", "{", "for", "(", "MethodNode", "node", ":", "fromDGM", ")", "{", "if", "(", "node", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "accumulator", ".", "add", "(", "node", ")", ";", "}", "}", "for", "(", "ClassNode", "node", ":", "clazz", ".", "getInterfaces", "(", ")", ")", "{", "findDGMMethodsForClassNode", "(", "node", ",", "name", ",", "accumulator", ")", ";", "}", "if", "(", "clazz", ".", "isArray", "(", ")", ")", "{", "ClassNode", "componentClass", "=", "clazz", ".", "getComponentType", "(", ")", ";", "if", "(", "!", "componentClass", ".", "equals", "(", "OBJECT_TYPE", ")", ")", "{", "if", "(", "componentClass", ".", "isInterface", "(", ")", "||", "componentClass", ".", "getSuperClass", "(", ")", "==", "null", ")", "{", "findDGMMethodsForClassNode", "(", "OBJECT_TYPE", ".", "makeArray", "(", ")", ",", "name", ",", "accumulator", ")", ";", "}", "else", "{", "findDGMMethodsForClassNode", "(", "componentClass", ".", "getSuperClass", "(", ")", ".", "makeArray", "(", ")", ",", "name", ",", "accumulator", ")", ";", "}", "}", "}", "if", "(", "clazz", ".", "getSuperClass", "(", ")", "!=", "null", ")", "{", "findDGMMethodsForClassNode", "(", "clazz", ".", "getSuperClass", "(", ")", ",", "name", ",", "accumulator", ")", ";", "}", "else", "if", "(", "!", "clazz", ".", "equals", "(", "ClassHelper", ".", "OBJECT_TYPE", ")", ")", "{", "findDGMMethodsForClassNode", "(", "ClassHelper", ".", "OBJECT_TYPE", ",", "name", ",", "accumulator", ")", ";", "}", "}", "public", "static", "int", "allParametersAndArgumentsMatch", "(", "Parameter", "[", "]", "params", ",", "ClassNode", "[", "]", "args", ")", "{", "if", "(", "params", "==", "null", ")", "{", "params", "=", "Parameter", ".", "EMPTY_ARRAY", ";", "}", "int", "dist", "=", "0", ";", "if", "(", "args", ".", "length", "<", "params", ".", "length", ")", "return", "-", "1", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "params", ".", "length", ";", "i", "++", ")", "{", "ClassNode", "paramType", "=", "params", "[", "i", "]", ".", "getType", "(", ")", ";", "ClassNode", "argType", "=", "args", "[", "i", "]", ";", "if", "(", "!", "isAssignableTo", "(", "argType", ",", "paramType", ")", ")", "return", "-", "1", ";", "else", "{", "if", "(", "!", "paramType", ".", "equals", "(", "argType", ")", ")", "dist", "+=", "getDistance", "(", "argType", ",", "paramType", ")", ";", "}", "}", "return", "dist", ";", "}", "static", "int", "allParametersAndArgumentsMatchWithDefaultParams", "(", "Parameter", "[", "]", "params", ",", "ClassNode", "[", "]", "args", ")", "{", "int", "dist", "=", "0", ";", "ClassNode", "ptype", "=", "null", ";", "for", "(", "int", "i", "=", "0", ",", "j", "=", "0", ";", "i", "<", "params", ".", "length", ";", "i", "++", ")", "{", "Parameter", "param", "=", "params", "[", "i", "]", ";", "ClassNode", "paramType", "=", "param", ".", "getType", "(", ")", ";", "ClassNode", "arg", "=", "j", ">=", "args", ".", "length", "?", "null", ":", "args", "[", "j", "]", ";", "if", "(", "arg", "==", "null", "||", "!", "isAssignableTo", "(", "arg", ",", "paramType", ")", ")", "{", "if", "(", "!", "param", ".", "hasInitialExpression", "(", ")", "&&", "(", "ptype", "==", "null", "||", "!", "ptype", ".", "equals", "(", "paramType", ")", ")", ")", "{", "return", "-", "1", ";", "}", "ptype", "=", "null", ";", "}", "else", "{", "j", "++", ";", "if", "(", "!", "paramType", ".", "equals", "(", "arg", ")", ")", "dist", "+=", "getDistance", "(", "arg", ",", "paramType", ")", ";", "if", "(", "param", ".", "hasInitialExpression", "(", ")", ")", "{", "ptype", "=", "arg", ";", "}", "else", "{", "ptype", "=", "null", ";", "}", "}", "}", "return", "dist", ";", "}", "static", "int", "excessArgumentsMatchesVargsParameter", "(", "Parameter", "[", "]", "params", ",", "ClassNode", "[", "]", "args", ")", "{", "int", "dist", "=", "0", ";", "ClassNode", "vargsBase", "=", "params", "[", "params", ".", "length", "-", "1", "]", ".", "getType", "(", ")", ".", "getComponentType", "(", ")", ";", "for", "(", "int", "i", "=", "params", ".", "length", ";", "i", "<", "args", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "isAssignableTo", "(", "args", "[", "i", "]", ",", "vargsBase", ")", ")", "return", "-", "1", ";", "else", "if", "(", "!", "args", "[", "i", "]", ".", "equals", "(", "vargsBase", ")", ")", "dist", "+=", "getDistance", "(", "args", "[", "i", "]", ",", "vargsBase", ")", ";", "}", "return", "dist", ";", "}", "static", "int", "lastArgMatchesVarg", "(", "Parameter", "[", "]", "params", ",", "ClassNode", "...", "args", ")", "{", "if", "(", "!", "isVargs", "(", "params", ")", ")", "return", "-", "1", ";", "ClassNode", "ptype", "=", "params", "[", "params", ".", "length", "-", "1", "]", ".", "getType", "(", ")", ".", "getComponentType", "(", ")", ";", "ClassNode", "arg", "=", "args", "[", "args", ".", "length", "-", "1", "]", ";", "if", "(", "isNumberType", "(", "ptype", ")", "&&", "isNumberType", "(", "arg", ")", "&&", "!", "ptype", ".", "equals", "(", "arg", ")", ")", "return", "-", "1", ";", "return", "isAssignableTo", "(", "arg", ",", "ptype", ")", "?", "getDistance", "(", "arg", ",", "ptype", ")", ":", "-", "1", ";", "}", "static", "boolean", "isAssignableTo", "(", "ClassNode", "type", ",", "ClassNode", "toBeAssignedTo", ")", "{", "if", "(", "UNKNOWN_PARAMETER_TYPE", "==", "type", ")", "return", "true", ";", "if", "(", "toBeAssignedTo", ".", "redirect", "(", ")", "==", "STRING_TYPE", "&&", "type", ".", "redirect", "(", ")", "==", "GSTRING_TYPE", ")", "{", "return", "true", ";", "}", "if", "(", "isPrimitiveType", "(", "toBeAssignedTo", ")", ")", "toBeAssignedTo", "=", "getWrapper", "(", "toBeAssignedTo", ")", ";", "if", "(", "isPrimitiveType", "(", "type", ")", ")", "type", "=", "getWrapper", "(", "type", ")", ";", "if", "(", "ClassHelper", ".", "Double_TYPE", "==", "toBeAssignedTo", ")", "{", "return", "type", ".", "isDerivedFrom", "(", "Number_TYPE", ")", ";", "}", "if", "(", "ClassHelper", ".", "Float_TYPE", "==", "toBeAssignedTo", ")", "{", "return", "type", ".", "isDerivedFrom", "(", "Number_TYPE", ")", "&&", "ClassHelper", ".", "Double_TYPE", "!=", "type", ";", "}", "if", "(", "ClassHelper", ".", "Long_TYPE", "==", "toBeAssignedTo", ")", "{", "return", "type", ".", "isDerivedFrom", "(", "Number_TYPE", ")", "&&", "ClassHelper", ".", "Double_TYPE", "!=", "type", "&&", "ClassHelper", ".", "Float_TYPE", "!=", "type", ";", "}", "if", "(", "ClassHelper", ".", "Integer_TYPE", "==", "toBeAssignedTo", ")", "{", "return", "type", ".", "isDerivedFrom", "(", "Number_TYPE", ")", "&&", "ClassHelper", ".", "Double_TYPE", "!=", "type", "&&", "ClassHelper", ".", "Float_TYPE", "!=", "type", "&&", "ClassHelper", ".", "Long_TYPE", "!=", "type", ";", "}", "if", "(", "ClassHelper", ".", "Short_TYPE", "==", "toBeAssignedTo", ")", "{", "return", "type", ".", "isDerivedFrom", "(", "Number_TYPE", ")", "&&", "ClassHelper", ".", "Double_TYPE", "!=", "type", "&&", "ClassHelper", ".", "Float_TYPE", "!=", "type", "&&", "ClassHelper", ".", "Long_TYPE", "!=", "type", "&&", "ClassHelper", ".", "Integer_TYPE", "!=", "type", ";", "}", "if", "(", "ClassHelper", ".", "Byte_TYPE", "==", "toBeAssignedTo", ")", "{", "return", "type", "==", "ClassHelper", ".", "Byte_TYPE", ";", "}", "if", "(", "type", ".", "isArray", "(", ")", "&&", "toBeAssignedTo", ".", "isArray", "(", ")", ")", "{", "return", "isAssignableTo", "(", "type", ".", "getComponentType", "(", ")", ",", "toBeAssignedTo", ".", "getComponentType", "(", ")", ")", ";", "}", "if", "(", "type", ".", "isDerivedFrom", "(", "GSTRING_TYPE", ")", "&&", "STRING_TYPE", ".", "equals", "(", "toBeAssignedTo", ")", ")", "{", "return", "true", ";", "}", "if", "(", "toBeAssignedTo", ".", "isDerivedFrom", "(", "GSTRING_TYPE", ")", "&&", "STRING_TYPE", ".", "equals", "(", "type", ")", ")", "{", "return", "true", ";", "}", "if", "(", "implementsInterfaceOrIsSubclassOf", "(", "type", ",", "toBeAssignedTo", ")", ")", "{", "if", "(", "OBJECT_TYPE", ".", "equals", "(", "toBeAssignedTo", ")", ")", "return", "true", ";", "if", "(", "toBeAssignedTo", ".", "isUsingGenerics", "(", ")", ")", "{", "GenericsType", "gt", "=", "GenericsUtils", ".", "buildWildcardType", "(", "toBeAssignedTo", ")", ";", "return", "gt", ".", "isCompatibleWith", "(", "type", ")", ";", "}", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "static", "boolean", "isVargs", "(", "Parameter", "[", "]", "params", ")", "{", "if", "(", "params", ".", "length", "==", "0", ")", "return", "false", ";", "if", "(", "params", "[", "params", ".", "length", "-", "1", "]", ".", "getType", "(", ")", ".", "isArray", "(", ")", ")", "return", "true", ";", "return", "false", ";", "}", "static", "boolean", "isCompareToBoolean", "(", "int", "op", ")", "{", "return", "op", "==", "COMPARE_GREATER_THAN", "||", "op", "==", "COMPARE_GREATER_THAN_EQUAL", "||", "op", "==", "COMPARE_LESS_THAN", "||", "op", "==", "COMPARE_LESS_THAN_EQUAL", ";", "}", "static", "boolean", "isArrayOp", "(", "int", "op", ")", "{", "return", "op", "==", "LEFT_SQUARE_BRACKET", ";", "}", "static", "boolean", "isBoolIntrinsicOp", "(", "int", "op", ")", "{", "return", "op", "==", "LOGICAL_AND", "||", "op", "==", "LOGICAL_OR", "||", "op", "==", "MATCH_REGEX", "||", "op", "==", "KEYWORD_INSTANCEOF", ";", "}", "static", "boolean", "isPowerOperator", "(", "int", "op", ")", "{", "return", "op", "==", "POWER", "||", "op", "==", "POWER_EQUAL", ";", "}", "static", "String", "getOperationName", "(", "int", "op", ")", "{", "switch", "(", "op", ")", "{", "case", "COMPARE_EQUAL", ":", "case", "COMPARE_NOT_EQUAL", ":", "return", "\"equals\"", ";", "case", "COMPARE_TO", ":", "case", "COMPARE_GREATER_THAN", ":", "case", "COMPARE_GREATER_THAN_EQUAL", ":", "case", "COMPARE_LESS_THAN", ":", "case", "COMPARE_LESS_THAN_EQUAL", ":", "return", "\"compareTo\"", ";", "case", "BITWISE_AND", ":", "case", "BITWISE_AND_EQUAL", ":", "return", "\"and\"", ";", "case", "BITWISE_OR", ":", "case", "BITWISE_OR_EQUAL", ":", "return", "\"or\"", ";", "case", "BITWISE_XOR", ":", "case", "BITWISE_XOR_EQUAL", ":", "return", "\"xor\"", ";", "case", "PLUS", ":", "case", "PLUS_EQUAL", ":", "return", "\"plus\"", ";", "case", "MINUS", ":", "case", "MINUS_EQUAL", ":", "return", "\"minus\"", ";", "case", "MULTIPLY", ":", "case", "MULTIPLY_EQUAL", ":", "return", "\"multiply\"", ";", "case", "DIVIDE", ":", "case", "DIVIDE_EQUAL", ":", "return", "\"div\"", ";", "case", "INTDIV", ":", "case", "INTDIV_EQUAL", ":", "return", "\"intdiv\"", ";", "case", "MOD", ":", "case", "MOD_EQUAL", ":", "return", "\"mod\"", ";", "case", "POWER", ":", "case", "POWER_EQUAL", ":", "return", "\"power\"", ";", "case", "LEFT_SHIFT", ":", "case", "LEFT_SHIFT_EQUAL", ":", "return", "\"leftShift\"", ";", "case", "RIGHT_SHIFT", ":", "case", "RIGHT_SHIFT_EQUAL", ":", "return", "\"rightShift\"", ";", "case", "RIGHT_SHIFT_UNSIGNED", ":", "case", "RIGHT_SHIFT_UNSIGNED_EQUAL", ":", "return", "\"\"", ";", "case", "KEYWORD_IN", ":", "return", "\"isCase\"", ";", "default", ":", "return", "null", ";", "}", "}", "static", "boolean", "isShiftOperation", "(", "String", "name", ")", "{", "return", "\"leftShift\"", ".", "equals", "(", "name", ")", "||", "\"rightShift\"", ".", "equals", "(", "name", ")", "||", "\"\"", ".", "equals", "(", "name", ")", ";", "}", "static", "boolean", "isOperationInGroup", "(", "int", "op", ")", "{", "switch", "(", "op", ")", "{", "case", "PLUS", ":", "case", "PLUS_EQUAL", ":", "case", "MINUS", ":", "case", "MINUS_EQUAL", ":", "case", "MULTIPLY", ":", "case", "MULTIPLY_EQUAL", ":", "return", "true", ";", "default", ":", "return", "false", ";", "}", "}", "static", "boolean", "isBitOperator", "(", "int", "op", ")", "{", "switch", "(", "op", ")", "{", "case", "BITWISE_OR_EQUAL", ":", "case", "BITWISE_OR", ":", "case", "BITWISE_AND_EQUAL", ":", "case", "BITWISE_AND", ":", "case", "BITWISE_XOR_EQUAL", ":", "case", "BITWISE_XOR", ":", "return", "true", ";", "default", ":", "return", "false", ";", "}", "}", "public", "static", "boolean", "isAssignment", "(", "int", "op", ")", "{", "switch", "(", "op", ")", "{", "case", "ASSIGN", ":", "case", "LOGICAL_OR_EQUAL", ":", "case", "LOGICAL_AND_EQUAL", ":", "case", "PLUS_EQUAL", ":", "case", "MINUS_EQUAL", ":", "case", "MULTIPLY_EQUAL", ":", "case", "DIVIDE_EQUAL", ":", "case", "INTDIV_EQUAL", ":", "case", "MOD_EQUAL", ":", "case", "POWER_EQUAL", ":", "case", "LEFT_SHIFT_EQUAL", ":", "case", "RIGHT_SHIFT_EQUAL", ":", "case", "RIGHT_SHIFT_UNSIGNED_EQUAL", ":", "case", "BITWISE_OR_EQUAL", ":", "case", "BITWISE_AND_EQUAL", ":", "case", "BITWISE_XOR_EQUAL", ":", "return", "true", ";", "default", ":", "return", "false", ";", "}", "}", "public", "static", "boolean", "checkCompatibleAssignmentTypes", "(", "ClassNode", "left", ",", "ClassNode", "right", ")", "{", "return", "checkCompatibleAssignmentTypes", "(", "left", ",", "right", ",", "null", ")", ";", "}", "public", "static", "boolean", "checkCompatibleAssignmentTypes", "(", "ClassNode", "left", ",", "ClassNode", "right", ",", "Expression", "rightExpression", ")", "{", "ClassNode", "leftRedirect", "=", "left", ".", "redirect", "(", ")", ";", "ClassNode", "rightRedirect", "=", "right", ".", "redirect", "(", ")", ";", "if", "(", "right", "==", "VOID_TYPE", "||", "right", "==", "void_WRAPPER_TYPE", ")", "{", "return", "left", "==", "VOID_TYPE", "||", "left", "==", "void_WRAPPER_TYPE", ";", "}", "if", "(", "(", "isNumberType", "(", "rightRedirect", ")", "||", "WideningCategories", ".", "isNumberCategory", "(", "rightRedirect", ")", ")", ")", "{", "if", "(", "BigDecimal_TYPE", "==", "leftRedirect", ")", "{", "return", "true", ";", "}", "if", "(", "BigInteger_TYPE", "==", "leftRedirect", ")", "{", "return", "WideningCategories", ".", "isBigIntCategory", "(", "getUnwrapper", "(", "rightRedirect", ")", ")", ";", "}", "}", "boolean", "rightExpressionIsNull", "=", "rightExpression", "instanceof", "ConstantExpression", "&&", "(", "(", "ConstantExpression", ")", "rightExpression", ")", ".", "getValue", "(", ")", "==", "null", ";", "if", "(", "rightExpressionIsNull", "&&", "!", "isPrimitiveType", "(", "left", ")", ")", "{", "return", "true", ";", "}", "if", "(", "leftRedirect", ".", "equals", "(", "OBJECT_TYPE", ")", "||", "leftRedirect", ".", "equals", "(", "STRING_TYPE", ")", "||", "leftRedirect", ".", "equals", "(", "boolean_TYPE", ")", "||", "leftRedirect", ".", "equals", "(", "Boolean_TYPE", ")", "||", "leftRedirect", ".", "equals", "(", "CLASS_Type", ")", ")", "{", "return", "true", ";", "}", "if", "(", "leftRedirect", "==", "char_TYPE", "&&", "rightRedirect", "==", "STRING_TYPE", ")", "{", "if", "(", "rightExpression", "!=", "null", "&&", "rightExpression", "instanceof", "ConstantExpression", ")", "{", "String", "value", "=", "rightExpression", ".", "getText", "(", ")", ";", "return", "value", ".", "length", "(", ")", "==", "1", ";", "}", "}", "if", "(", "leftRedirect", "==", "Character_TYPE", "&&", "(", "rightRedirect", "==", "STRING_TYPE", "||", "rightExpressionIsNull", ")", ")", "{", "return", "rightExpressionIsNull", "||", "(", "rightExpression", "instanceof", "ConstantExpression", "&&", "rightExpression", ".", "getText", "(", ")", ".", "length", "(", ")", "==", "1", ")", ";", "}", "if", "(", "leftRedirect", ".", "isDerivedFrom", "(", "Enum_Type", ")", "&&", "(", "rightRedirect", "==", "GSTRING_TYPE", "||", "rightRedirect", "==", "STRING_TYPE", ")", ")", "{", "return", "true", ";", "}", "if", "(", "rightRedirect", ".", "implementsInterface", "(", "MAP_TYPE", ")", "||", "rightRedirect", ".", "implementsInterface", "(", "Collection_TYPE", ")", "||", "rightRedirect", ".", "equals", "(", "MAP_TYPE", ")", "||", "rightRedirect", ".", "equals", "(", "Collection_TYPE", ")", "||", "rightRedirect", ".", "isArray", "(", ")", ")", "{", "if", "(", "leftRedirect", ".", "isArray", "(", ")", "&&", "rightRedirect", ".", "isArray", "(", ")", ")", "{", "return", "checkCompatibleAssignmentTypes", "(", "leftRedirect", ".", "getComponentType", "(", ")", ",", "rightRedirect", ".", "getComponentType", "(", ")", ")", ";", "}", "else", "if", "(", "rightRedirect", ".", "isArray", "(", ")", "&&", "!", "leftRedirect", ".", "isArray", "(", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "if", "(", "right", ".", "isDerivedFrom", "(", "left", ")", "||", "(", "left", ".", "isInterface", "(", ")", "&&", "right", ".", "implementsInterface", "(", "left", ")", ")", ")", "return", "true", ";", "if", "(", "isPrimitiveType", "(", "leftRedirect", ")", "&&", "isPrimitiveType", "(", "rightRedirect", ")", ")", "return", "true", ";", "if", "(", "isNumberType", "(", "leftRedirect", ")", "&&", "isNumberType", "(", "rightRedirect", ")", ")", "return", "true", ";", "if", "(", "WideningCategories", ".", "isFloatingCategory", "(", "leftRedirect", ")", "&&", "BigDecimal_TYPE", ".", "equals", "(", "rightRedirect", ")", ")", "{", "return", "true", ";", "}", "if", "(", "GROOVY_OBJECT_TYPE", ".", "equals", "(", "leftRedirect", ")", "&&", "isBeingCompiled", "(", "right", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "public", "static", "boolean", "isBeingCompiled", "(", "ClassNode", "node", ")", "{", "return", "node", ".", "getCompileUnit", "(", ")", "!=", "null", ";", "}", "static", "boolean", "checkPossibleLooseOfPrecision", "(", "ClassNode", "left", ",", "ClassNode", "right", ",", "Expression", "rightExpr", ")", "{", "if", "(", "left", "==", "right", "||", "left", ".", "equals", "(", "right", ")", ")", "return", "false", ";", "int", "leftIndex", "=", "NUMBER_TYPES", ".", "get", "(", "left", ")", ";", "int", "rightIndex", "=", "NUMBER_TYPES", ".", "get", "(", "right", ")", ";", "if", "(", "leftIndex", ">=", "rightIndex", ")", "return", "false", ";", "if", "(", "rightExpr", "instanceof", "ConstantExpression", ")", "{", "Object", "value", "=", "(", "(", "ConstantExpression", ")", "rightExpr", ")", ".", "getValue", "(", ")", ";", "if", "(", "!", "(", "value", "instanceof", "Number", ")", ")", "return", "true", ";", "Number", "number", "=", "(", "Number", ")", "value", ";", "switch", "(", "leftIndex", ")", "{", "case", "0", ":", "{", "byte", "val", "=", "number", ".", "byteValue", "(", ")", ";", "if", "(", "number", "instanceof", "Short", ")", "{", "return", "!", "Short", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "if", "(", "number", "instanceof", "Integer", ")", "{", "return", "!", "Integer", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "if", "(", "number", "instanceof", "Long", ")", "{", "return", "!", "Long", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "if", "(", "number", "instanceof", "Float", ")", "{", "return", "!", "Float", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "return", "!", "Double", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "case", "1", ":", "{", "short", "val", "=", "number", ".", "shortValue", "(", ")", ";", "if", "(", "number", "instanceof", "Integer", ")", "{", "return", "!", "Integer", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "if", "(", "number", "instanceof", "Long", ")", "{", "return", "!", "Long", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "if", "(", "number", "instanceof", "Float", ")", "{", "return", "!", "Float", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "return", "!", "Double", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "case", "2", ":", "{", "int", "val", "=", "number", ".", "intValue", "(", ")", ";", "if", "(", "number", "instanceof", "Long", ")", "{", "return", "!", "Long", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "if", "(", "number", "instanceof", "Float", ")", "{", "return", "!", "Float", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "return", "!", "Double", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "case", "3", ":", "{", "long", "val", "=", "number", ".", "longValue", "(", ")", ";", "if", "(", "number", "instanceof", "Float", ")", "{", "return", "!", "Float", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "return", "!", "Double", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "case", "4", ":", "{", "float", "val", "=", "number", ".", "floatValue", "(", ")", ";", "return", "!", "Double", ".", "valueOf", "(", "val", ")", ".", "equals", "(", "number", ")", ";", "}", "default", ":", "return", "false", ";", "}", "}", "return", "true", ";", "}", "static", "String", "toMethodParametersString", "(", "String", "methodName", ",", "ClassNode", "...", "parameters", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "methodName", ")", ".", "append", "(", "\"(\"", ")", ";", "if", "(", "parameters", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ",", "parametersLength", "=", "parameters", ".", "length", ";", "i", "<", "parametersLength", ";", "i", "++", ")", "{", "final", "ClassNode", "parameter", "=", "parameters", "[", "i", "]", ";", "sb", ".", "append", "(", "prettyPrintType", "(", "parameter", ")", ")", ";", "if", "(", "i", "<", "parametersLength", "-", "1", ")", "sb", ".", "append", "(", "\",", "\"", ")", ";", "}", "}", "sb", ".", "append", "(", "\")\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "static", "String", "prettyPrintType", "(", "ClassNode", "type", ")", "{", "if", "(", "type", ".", "isArray", "(", ")", ")", "{", "return", "prettyPrintType", "(", "type", ".", "getComponentType", "(", ")", ")", "+", "\"[]\"", ";", "}", "return", "type", ".", "toString", "(", "false", ")", ";", "}", "public", "static", "boolean", "implementsInterfaceOrIsSubclassOf", "(", "ClassNode", "type", ",", "ClassNode", "superOrInterface", ")", "{", "boolean", "result", "=", "type", ".", "equals", "(", "superOrInterface", ")", "||", "type", ".", "isDerivedFrom", "(", "superOrInterface", ")", "||", "type", ".", "implementsInterface", "(", "superOrInterface", ")", "||", "type", "==", "UNKNOWN_PARAMETER_TYPE", ";", "if", "(", "result", ")", "{", "return", "true", ";", "}", "if", "(", "superOrInterface", "instanceof", "WideningCategories", ".", "LowestUpperBoundClassNode", ")", "{", "WideningCategories", ".", "LowestUpperBoundClassNode", "cn", "=", "(", "WideningCategories", ".", "LowestUpperBoundClassNode", ")", "superOrInterface", ";", "result", "=", "implementsInterfaceOrIsSubclassOf", "(", "type", ",", "cn", ".", "getSuperClass", "(", ")", ")", ";", "if", "(", "result", ")", "{", "for", "(", "ClassNode", "interfaceNode", ":", "cn", ".", "getInterfaces", "(", ")", ")", "{", "result", "=", "type", ".", "implementsInterface", "(", "interfaceNode", ")", ";", "if", "(", "!", "result", ")", "break", ";", "}", "}", "if", "(", "result", ")", "return", "true", ";", "}", "else", "if", "(", "superOrInterface", "instanceof", "UnionTypeClassNode", ")", "{", "UnionTypeClassNode", "union", "=", "(", "UnionTypeClassNode", ")", "superOrInterface", ";", "for", "(", "ClassNode", "delegate", ":", "union", ".", "getDelegates", "(", ")", ")", "{", "if", "(", "implementsInterfaceOrIsSubclassOf", "(", "type", ",", "delegate", ")", ")", "return", "true", ";", "}", "}", "if", "(", "type", ".", "isArray", "(", ")", "&&", "superOrInterface", ".", "isArray", "(", ")", ")", "{", "return", "implementsInterfaceOrIsSubclassOf", "(", "type", ".", "getComponentType", "(", ")", ",", "superOrInterface", ".", "getComponentType", "(", ")", ")", ";", "}", "if", "(", "GROOVY_OBJECT_TYPE", ".", "equals", "(", "superOrInterface", ")", "&&", "!", "type", ".", "isInterface", "(", ")", "&&", "isBeingCompiled", "(", "type", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "static", "int", "getPrimitiveDistance", "(", "ClassNode", "primA", ",", "ClassNode", "primB", ")", "{", "return", "Math", ".", "abs", "(", "NUMBER_TYPES", ".", "get", "(", "primA", ")", "-", "NUMBER_TYPES", ".", "get", "(", "primB", ")", ")", ";", "}", "static", "int", "getDistance", "(", "final", "ClassNode", "receiver", ",", "final", "ClassNode", "compare", ")", "{", "int", "dist", "=", "0", ";", "ClassNode", "unwrapReceiver", "=", "ClassHelper", ".", "getUnwrapper", "(", "receiver", ")", ";", "ClassNode", "unwrapCompare", "=", "ClassHelper", ".", "getUnwrapper", "(", "compare", ")", ";", "if", "(", "ClassHelper", ".", "isPrimitiveType", "(", "unwrapReceiver", ")", "&&", "ClassHelper", ".", "isPrimitiveType", "(", "unwrapCompare", ")", "&&", "unwrapReceiver", "!=", "unwrapCompare", ")", "{", "dist", "=", "getPrimitiveDistance", "(", "unwrapReceiver", ",", "unwrapCompare", ")", ";", "}", "if", "(", "isPrimitiveType", "(", "receiver", ")", "&&", "!", "isPrimitiveType", "(", "compare", ")", ")", "{", "dist", "=", "(", "dist", "+", "1", ")", "<<", "1", ";", "}", "if", "(", "unwrapCompare", ".", "equals", "(", "unwrapReceiver", ")", ")", "return", "dist", ";", "if", "(", "receiver", ".", "isArray", "(", ")", "&&", "!", "compare", ".", "isArray", "(", ")", ")", "{", "dist", "+=", "256", ";", "}", "if", "(", "receiver", "==", "UNKNOWN_PARAMETER_TYPE", ")", "{", "return", "dist", ";", "}", "ClassNode", "ref", "=", "receiver", ";", "while", "(", "ref", "!=", "null", ")", "{", "if", "(", "compare", ".", "equals", "(", "ref", ")", ")", "{", "break", ";", "}", "if", "(", "compare", ".", "isInterface", "(", ")", "&&", "ref", ".", "implementsInterface", "(", "compare", ")", ")", "{", "dist", "+=", "getMaximumInterfaceDistance", "(", "ref", ",", "compare", ")", ";", "break", ";", "}", "ref", "=", "ref", ".", "getSuperClass", "(", ")", ";", "if", "(", "ref", "==", "null", ")", "dist", "+=", "2", ";", "dist", "=", "(", "dist", "+", "1", ")", "<<", "1", ";", "}", "return", "dist", ";", "}", "private", "static", "int", "getMaximumInterfaceDistance", "(", "ClassNode", "c", ",", "ClassNode", "interfaceClass", ")", "{", "if", "(", "c", "==", "null", ")", "return", "-", "1", ";", "if", "(", "c", ".", "equals", "(", "interfaceClass", ")", ")", "return", "0", ";", "ClassNode", "[", "]", "interfaces", "=", "c", ".", "getInterfaces", "(", ")", ";", "int", "max", "=", "-", "1", ";", "for", "(", "ClassNode", "anInterface", ":", "interfaces", ")", "{", "int", "sub", "=", "getMaximumInterfaceDistance", "(", "anInterface", ",", "interfaceClass", ")", ";", "if", "(", "sub", "!=", "-", "1", ")", "sub", "++", ";", "max", "=", "Math", ".", "max", "(", "max", ",", "sub", ")", ";", "}", "int", "superClassMax", "=", "getMaximumInterfaceDistance", "(", "c", ".", "getSuperClass", "(", ")", ",", "interfaceClass", ")", ";", "return", "Math", ".", "max", "(", "max", ",", "superClassMax", ")", ";", "}", "public", "static", "List", "<", "MethodNode", ">", "findDGMMethodsByNameAndArguments", "(", "final", "ClassNode", "receiver", ",", "final", "String", "name", ",", "final", "ClassNode", "[", "]", "args", ")", "{", "return", "findDGMMethodsByNameAndArguments", "(", "receiver", ",", "name", ",", "args", ",", "new", "LinkedList", "<", "MethodNode", ">", "(", ")", ")", ";", "}", "public", "static", "List", "<", "MethodNode", ">", "findDGMMethodsByNameAndArguments", "(", "final", "ClassNode", "receiver", ",", "final", "String", "name", ",", "final", "ClassNode", "[", "]", "args", ",", "final", "List", "<", "MethodNode", ">", "methods", ")", "{", "final", "List", "<", "MethodNode", ">", "chosen", ";", "methods", ".", "addAll", "(", "findDGMMethodsForClassNode", "(", "receiver", ",", "name", ")", ")", ";", "chosen", "=", "chooseBestMethod", "(", "receiver", ",", "methods", ",", "args", ")", ";", "Iterator", "<", "MethodNode", ">", "iterator", "=", "chosen", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "ExtensionMethodNode", "emn", "=", "(", "ExtensionMethodNode", ")", "iterator", ".", "next", "(", ")", ";", "MethodNode", "dgmMethod", "=", "emn", ".", "getExtensionMethodNode", "(", ")", ";", "GenericsType", "[", "]", "methodGenericTypes", "=", "dgmMethod", ".", "getGenericsTypes", "(", ")", ";", "if", "(", "methodGenericTypes", "!=", "null", "&&", "methodGenericTypes", ".", "length", ">", "0", ")", "{", "Parameter", "[", "]", "parameters", "=", "dgmMethod", ".", "getParameters", "(", ")", ";", "ClassNode", "dgmOwnerType", "=", "parameters", "[", "0", "]", ".", "getOriginType", "(", ")", ";", "if", "(", "dgmOwnerType", ".", "isGenericsPlaceHolder", "(", ")", "||", "dgmOwnerType", ".", "isArray", "(", ")", "&&", "dgmOwnerType", ".", "getComponentType", "(", ")", ".", "isGenericsPlaceHolder", "(", ")", ")", "{", "ClassNode", "receiverBase", "=", "receiver", ".", "isArray", "(", ")", "?", "receiver", ".", "getComponentType", "(", ")", ":", "receiver", ";", "ClassNode", "receiverBaseRedirect", "=", "dgmOwnerType", ".", "isArray", "(", ")", "?", "dgmOwnerType", ".", "getComponentType", "(", ")", ":", "dgmOwnerType", ";", "boolean", "mismatch", "=", "false", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "parameters", ".", "length", "&&", "!", "mismatch", ";", "i", "++", ")", "{", "final", "int", "k", "=", "i", "-", "1", ";", "ClassNode", "type", "=", "parameters", "[", "i", "]", ".", "getOriginType", "(", ")", ";", "if", "(", "isUsingGenericsOrIsArrayUsingGenerics", "(", "type", ")", ")", "{", "String", "receiverPlaceholder", "=", "receiverBaseRedirect", ".", "getGenericsTypes", "(", ")", "[", "0", "]", ".", "getName", "(", ")", ";", "ClassNode", "parameterBaseType", "=", "args", "[", "k", "]", ".", "isArray", "(", ")", "?", "args", "[", "k", "]", ".", "getComponentType", "(", ")", ":", "args", "[", "k", "]", ";", "ClassNode", "parameterBaseTypeRedirect", "=", "type", ".", "isArray", "(", ")", "?", "type", ".", "getComponentType", "(", ")", ":", "type", ";", "GenericsType", "[", "]", "paramRedirectGenericsTypes", "=", "parameterBaseTypeRedirect", ".", "getGenericsTypes", "(", ")", ";", "GenericsType", "[", "]", "paramGenericTypes", "=", "parameterBaseType", ".", "getGenericsTypes", "(", ")", ";", "if", "(", "paramGenericTypes", "==", "null", ")", "{", "paramGenericTypes", "=", "new", "GenericsType", "[", "paramRedirectGenericsTypes", ".", "length", "]", ";", "Arrays", ".", "fill", "(", "paramGenericTypes", ",", "new", "GenericsType", "(", "OBJECT_TYPE", ")", ")", ";", "}", "else", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "paramGenericTypes", ".", "length", ";", "j", "++", ")", "{", "GenericsType", "paramGenericType", "=", "paramGenericTypes", "[", "j", "]", ";", "if", "(", "paramGenericType", ".", "isWildcard", "(", ")", "||", "paramGenericType", ".", "isPlaceholder", "(", ")", ")", "{", "paramGenericTypes", "[", "j", "]", "=", "new", "GenericsType", "(", "OBJECT_TYPE", ")", ";", "}", "}", "}", "for", "(", "int", "j", "=", "0", ",", "genericsTypesLength", "=", "paramRedirectGenericsTypes", ".", "length", ";", "j", "<", "genericsTypesLength", "&&", "!", "mismatch", ";", "j", "++", ")", "{", "final", "GenericsType", "gt", "=", "paramRedirectGenericsTypes", "[", "j", "]", ";", "if", "(", "gt", ".", "isPlaceholder", "(", ")", ")", "{", "List", "<", "GenericsType", ">", "fromMethodGenerics", "=", "new", "LinkedList", "<", "GenericsType", ">", "(", ")", ";", "for", "(", "GenericsType", "methodGenericType", ":", "methodGenericTypes", ")", "{", "if", "(", "methodGenericType", ".", "getName", "(", ")", ".", "equals", "(", "gt", ".", "getName", "(", ")", ")", ")", "{", "fromMethodGenerics", ".", "add", "(", "methodGenericType", ")", ";", "break", ";", "}", "}", "while", "(", "!", "fromMethodGenerics", ".", "isEmpty", "(", ")", ")", "{", "GenericsType", "test", "=", "fromMethodGenerics", ".", "remove", "(", "0", ")", ";", "if", "(", "test", ".", "getName", "(", ")", ".", "equals", "(", "receiverPlaceholder", ")", ")", "{", "if", "(", "!", "implementsInterfaceOrIsSubclassOf", "(", "getWrapper", "(", "args", "[", "k", "]", ")", ",", "getWrapper", "(", "receiverBase", ")", ")", ")", "{", "mismatch", "=", "true", ";", "break", ";", "}", "}", "else", "if", "(", "test", ".", "getUpperBounds", "(", ")", "!=", "null", ")", "{", "for", "(", "ClassNode", "classNode", ":", "test", ".", "getUpperBounds", "(", ")", ")", "{", "GenericsType", "[", "]", "genericsTypes", "=", "classNode", ".", "getGenericsTypes", "(", ")", ";", "if", "(", "genericsTypes", "!=", "null", ")", "{", "for", "(", "GenericsType", "genericsType", ":", "genericsTypes", ")", "{", "if", "(", "genericsType", ".", "isPlaceholder", "(", ")", ")", "{", "for", "(", "GenericsType", "methodGenericType", ":", "methodGenericTypes", ")", "{", "if", "(", "methodGenericType", ".", "getName", "(", ")", ".", "equals", "(", "genericsType", ".", "getName", "(", ")", ")", ")", "{", "fromMethodGenerics", ".", "add", "(", "methodGenericType", ")", ";", "break", ";", "}", "}", "}", "}", "}", "}", "}", "}", "}", "}", "if", "(", "mismatch", ")", "{", "iterator", ".", "remove", "(", ")", ";", "}", "}", "}", "}", "}", "}", "return", "chosen", ";", "}", "public", "static", "List", "<", "MethodNode", ">", "chooseBestMethod", "(", "final", "ClassNode", "receiver", ",", "Collection", "<", "MethodNode", ">", "methods", ",", "ClassNode", "...", "args", ")", "{", "if", "(", "methods", ".", "isEmpty", "(", ")", ")", "return", "Collections", ".", "emptyList", "(", ")", ";", "List", "<", "MethodNode", ">", "bestChoices", "=", "new", "LinkedList", "<", "MethodNode", ">", "(", ")", ";", "int", "bestDist", "=", "Integer", ".", "MAX_VALUE", ";", "ClassNode", "actualReceiver", ";", "Collection", "<", "MethodNode", ">", "choicesLeft", "=", "removeCovariants", "(", "methods", ")", ";", "for", "(", "MethodNode", "m", ":", "choicesLeft", ")", "{", "final", "ClassNode", "declaringClass", "=", "m", ".", "getDeclaringClass", "(", ")", ";", "actualReceiver", "=", "receiver", "!=", "null", "?", "receiver", ":", "declaringClass", ";", "Parameter", "[", "]", "params", "=", "parameterizeArguments", "(", "actualReceiver", ",", "m", ")", ";", "if", "(", "params", ".", "length", ">", "args", ".", "length", "&&", "!", "isVargs", "(", "params", ")", ")", "{", "int", "dist", "=", "allParametersAndArgumentsMatchWithDefaultParams", "(", "params", ",", "args", ")", ";", "if", "(", "dist", ">=", "0", "&&", "!", "actualReceiver", ".", "equals", "(", "declaringClass", ")", ")", "dist", "+=", "getDistance", "(", "actualReceiver", ",", "declaringClass", ")", ";", "if", "(", "dist", ">=", "0", "&&", "dist", "<", "bestDist", ")", "{", "bestChoices", ".", "clear", "(", ")", ";", "bestChoices", ".", "add", "(", "m", ")", ";", "bestDist", "=", "dist", ";", "}", "else", "if", "(", "dist", ">=", "0", "&&", "dist", "==", "bestDist", ")", "{", "bestChoices", ".", "add", "(", "m", ")", ";", "}", "}", "else", "if", "(", "params", ".", "length", "==", "args", ".", "length", ")", "{", "int", "allPMatch", "=", "allParametersAndArgumentsMatch", "(", "params", ",", "args", ")", ";", "boolean", "firstParamMatches", "=", "true", ";", "if", "(", "args", ".", "length", ">", "0", ")", "{", "Parameter", "[", "]", "firstParams", "=", "new", "Parameter", "[", "params", ".", "length", "-", "1", "]", ";", "System", ".", "arraycopy", "(", "params", ",", "0", ",", "firstParams", ",", "0", ",", "firstParams", ".", "length", ")", ";", "firstParamMatches", "=", "allParametersAndArgumentsMatch", "(", "firstParams", ",", "args", ")", ">=", "0", ";", "}", "int", "lastArgMatch", "=", "isVargs", "(", "params", ")", "&&", "firstParamMatches", "?", "lastArgMatchesVarg", "(", "params", ",", "args", ")", ":", "-", "1", ";", "if", "(", "lastArgMatch", ">=", "0", ")", "{", "lastArgMatch", "+=", "256", "-", "params", ".", "length", ";", "}", "int", "dist", "=", "allPMatch", ">=", "0", "?", "Math", ".", "max", "(", "allPMatch", ",", "lastArgMatch", ")", ":", "lastArgMatch", ";", "if", "(", "dist", ">=", "0", "&&", "!", "actualReceiver", ".", "equals", "(", "declaringClass", ")", ")", "dist", "+=", "getDistance", "(", "actualReceiver", ",", "declaringClass", ")", ";", "if", "(", "dist", ">=", "0", "&&", "dist", "<", "bestDist", ")", "{", "bestChoices", ".", "clear", "(", ")", ";", "bestChoices", ".", "add", "(", "m", ")", ";", "bestDist", "=", "dist", ";", "}", "else", "if", "(", "dist", ">=", "0", "&&", "dist", "==", "bestDist", ")", "{", "bestChoices", ".", "add", "(", "m", ")", ";", "}", "}", "else", "if", "(", "isVargs", "(", "params", ")", ")", "{", "boolean", "firstParamMatches", "=", "true", ";", "if", "(", "args", ".", "length", ">", "0", ")", "{", "Parameter", "[", "]", "firstParams", "=", "new", "Parameter", "[", "params", ".", "length", "-", "1", "]", ";", "System", ".", "arraycopy", "(", "params", ",", "0", ",", "firstParams", ",", "0", ",", "firstParams", ".", "length", ")", ";", "firstParamMatches", "=", "allParametersAndArgumentsMatch", "(", "firstParams", ",", "args", ")", ">=", "0", ";", "}", "if", "(", "firstParamMatches", ")", "{", "if", "(", "params", ".", "length", "==", "args", ".", "length", "+", "1", ")", "{", "if", "(", "bestDist", ">", "1", ")", "{", "bestChoices", ".", "clear", "(", ")", ";", "bestChoices", ".", "add", "(", "m", ")", ";", "bestDist", "=", "1", ";", "}", "}", "else", "{", "int", "dist", "=", "excessArgumentsMatchesVargsParameter", "(", "params", ",", "args", ")", ";", "if", "(", "dist", ">=", "0", "&&", "!", "actualReceiver", ".", "equals", "(", "declaringClass", ")", ")", "dist", "+=", "getDistance", "(", "actualReceiver", ",", "declaringClass", ")", ";", "dist", "+=", "256", "-", "params", ".", "length", ";", "if", "(", "params", ".", "length", "<", "args", ".", "length", "&&", "dist", ">=", "0", ")", "{", "if", "(", "dist", ">=", "0", "&&", "dist", "<", "bestDist", ")", "{", "bestChoices", ".", "clear", "(", ")", ";", "bestChoices", ".", "add", "(", "m", ")", ";", "bestDist", "=", "dist", ";", "}", "else", "if", "(", "dist", ">=", "0", "&&", "dist", "==", "bestDist", ")", "{", "bestChoices", ".", "add", "(", "m", ")", ";", "}", "}", "}", "}", "}", "}", "return", "bestChoices", ";", "}", "private", "static", "Collection", "<", "MethodNode", ">", "removeCovariants", "(", "Collection", "<", "MethodNode", ">", "collection", ")", "{", "if", "(", "collection", ".", "size", "(", ")", "<=", "1", ")", "return", "collection", ";", "List", "<", "MethodNode", ">", "toBeRemoved", "=", "new", "LinkedList", "<", "MethodNode", ">", "(", ")", ";", "List", "<", "MethodNode", ">", "list", "=", "new", "LinkedList", "<", "MethodNode", ">", "(", "new", "HashSet", "<", "MethodNode", ">", "(", "collection", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "list", ".", "size", "(", ")", "-", "1", ";", "i", "++", ")", "{", "MethodNode", "one", "=", "list", ".", "get", "(", "i", ")", ";", "if", "(", "toBeRemoved", ".", "contains", "(", "one", ")", ")", "continue", ";", "for", "(", "int", "j", "=", "i", "+", "1", ";", "j", "<", "list", ".", "size", "(", ")", ";", "j", "++", ")", "{", "MethodNode", "two", "=", "list", ".", "get", "(", "j", ")", ";", "if", "(", "toBeRemoved", ".", "contains", "(", "two", ")", ")", "continue", ";", "if", "(", "one", ".", "getName", "(", ")", ".", "equals", "(", "two", ".", "getName", "(", ")", ")", "&&", "one", ".", "getDeclaringClass", "(", ")", "==", "two", ".", "getDeclaringClass", "(", ")", ")", "{", "Parameter", "[", "]", "onePars", "=", "one", ".", "getParameters", "(", ")", ";", "Parameter", "[", "]", "twoPars", "=", "two", ".", "getParameters", "(", ")", ";", "if", "(", "onePars", ".", "length", "==", "twoPars", ".", "length", ")", "{", "boolean", "sameTypes", "=", "true", ";", "for", "(", "int", "k", "=", "0", ";", "k", "<", "onePars", ".", "length", ";", "k", "++", ")", "{", "Parameter", "onePar", "=", "onePars", "[", "k", "]", ";", "Parameter", "twoPar", "=", "twoPars", "[", "k", "]", ";", "if", "(", "!", "onePar", ".", "getType", "(", ")", ".", "equals", "(", "twoPar", ".", "getType", "(", ")", ")", ")", "{", "sameTypes", "=", "false", ";", "break", ";", "}", "}", "if", "(", "sameTypes", ")", "{", "ClassNode", "oneRT", "=", "one", ".", "getReturnType", "(", ")", ";", "ClassNode", "twoRT", "=", "two", ".", "getReturnType", "(", ")", ";", "if", "(", "oneRT", ".", "isDerivedFrom", "(", "twoRT", ")", "||", "oneRT", ".", "implementsInterface", "(", "twoRT", ")", ")", "{", "toBeRemoved", ".", "add", "(", "two", ")", ";", "}", "else", "if", "(", "twoRT", ".", "isDerivedFrom", "(", "oneRT", ")", "||", "twoRT", ".", "implementsInterface", "(", "oneRT", ")", ")", "{", "toBeRemoved", ".", "add", "(", "one", ")", ";", "}", "}", "}", "}", "}", "}", "if", "(", "toBeRemoved", ".", "isEmpty", "(", ")", ")", "return", "list", ";", "List", "<", "MethodNode", ">", "result", "=", "new", "LinkedList", "<", "MethodNode", ">", "(", "list", ")", ";", "result", ".", "removeAll", "(", "toBeRemoved", ")", ";", "return", "result", ";", "}", "public", "static", "Parameter", "[", "]", "parameterizeArguments", "(", "final", "ClassNode", "receiver", ",", "final", "MethodNode", "m", ")", "{", "MethodNode", "mn", "=", "m", ";", "ClassNode", "actualReceiver", "=", "receiver", ";", "List", "<", "GenericsType", ">", "redirectTypes", "=", "new", "ArrayList", "<", "GenericsType", ">", "(", ")", ";", "if", "(", "actualReceiver", ".", "redirect", "(", ")", ".", "getGenericsTypes", "(", ")", "!=", "null", ")", "{", "Collections", ".", "addAll", "(", "redirectTypes", ",", "actualReceiver", ".", "redirect", "(", ")", ".", "getGenericsTypes", "(", ")", ")", ";", "}", "if", "(", "redirectTypes", ".", "isEmpty", "(", ")", ")", "{", "return", "m", ".", "getParameters", "(", ")", ";", "}", "GenericsType", "[", "]", "redirectReceiverTypes", "=", "redirectTypes", ".", "toArray", "(", "new", "GenericsType", "[", "redirectTypes", ".", "size", "(", ")", "]", ")", ";", "Parameter", "[", "]", "methodParameters", "=", "mn", ".", "getParameters", "(", ")", ";", "Parameter", "[", "]", "params", "=", "new", "Parameter", "[", "methodParameters", ".", "length", "]", ";", "GenericsType", "[", "]", "receiverParameterizedTypes", "=", "actualReceiver", ".", "getGenericsTypes", "(", ")", ";", "if", "(", "receiverParameterizedTypes", "==", "null", ")", "{", "receiverParameterizedTypes", "=", "redirectReceiverTypes", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "methodParameters", ".", "length", ";", "i", "++", ")", "{", "Parameter", "methodParameter", "=", "methodParameters", "[", "i", "]", ";", "ClassNode", "paramType", "=", "methodParameter", ".", "getType", "(", ")", ";", "if", "(", "paramType", ".", "isUsingGenerics", "(", ")", ")", "{", "GenericsType", "[", "]", "alignmentTypes", "=", "paramType", ".", "getGenericsTypes", "(", ")", ";", "GenericsType", "[", "]", "genericsTypes", "=", "GenericsUtils", ".", "alignGenericTypes", "(", "redirectReceiverTypes", ",", "receiverParameterizedTypes", ",", "alignmentTypes", ")", ";", "if", "(", "genericsTypes", ".", "length", "==", "1", ")", "{", "ClassNode", "parameterizedCN", ";", "if", "(", "paramType", ".", "equals", "(", "OBJECT_TYPE", ")", ")", "{", "parameterizedCN", "=", "genericsTypes", "[", "0", "]", ".", "getType", "(", ")", ";", "}", "else", "{", "parameterizedCN", "=", "paramType", ".", "getPlainNodeReference", "(", ")", ";", "parameterizedCN", ".", "setGenericsTypes", "(", "genericsTypes", ")", ";", "}", "params", "[", "i", "]", "=", "new", "Parameter", "(", "parameterizedCN", ",", "methodParameter", ".", "getName", "(", ")", ")", ";", "}", "else", "{", "params", "[", "i", "]", "=", "methodParameter", ";", "}", "}", "else", "{", "params", "[", "i", "]", "=", "methodParameter", ";", "}", "}", "return", "params", ";", "}", "static", "boolean", "isUsingGenericsOrIsArrayUsingGenerics", "(", "ClassNode", "cn", ")", "{", "return", "cn", ".", "isUsingGenerics", "(", ")", "||", "cn", ".", "isArray", "(", ")", "&&", "cn", ".", "getComponentType", "(", ")", ".", "isUsingGenerics", "(", ")", ";", "}", "private", "static", "class", "ObjectArrayStaticTypesHelper", "{", "public", "static", "<", "T", ">", "T", "getAt", "(", "T", "[", "]", "arr", ",", "int", "index", ")", "{", "return", "null", ";", "}", "public", "static", "<", "T", ",", "U", "extends", "T", ">", "void", "putAt", "(", "T", "[", "]", "arr", ",", "int", "index", ",", "U", "object", ")", "{", "}", "}", "private", "static", "class", "ExtensionMethodCache", "{", "private", "final", "ReentrantReadWriteLock", "lock", "=", "new", "ReentrantReadWriteLock", "(", ")", ";", "private", "List", "<", "ExtensionModule", ">", "modules", "=", "Collections", ".", "emptyList", "(", ")", ";", "private", "Map", "<", "String", ",", "List", "<", "MethodNode", ">", ">", "cachedMethods", "=", "null", ";", "public", "Map", "<", "String", ",", "List", "<", "MethodNode", ">", ">", "getExtensionMethods", "(", ")", "{", "lock", ".", "readLock", "(", ")", ".", "lock", "(", ")", ";", "MetaClassRegistry", "registry", "=", "GroovySystem", ".", "getMetaClassRegistry", "(", ")", ";", "if", "(", "registry", "instanceof", "MetaClassRegistryImpl", ")", "{", "MetaClassRegistryImpl", "impl", "=", "(", "MetaClassRegistryImpl", ")", "registry", ";", "ExtensionModuleRegistry", "moduleRegistry", "=", "impl", ".", "getModuleRegistry", "(", ")", ";", "if", "(", "!", "modules", ".", "equals", "(", "moduleRegistry", ".", "getModules", "(", ")", ")", ")", "{", "lock", ".", "readLock", "(", ")", ".", "unlock", "(", ")", ";", "lock", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "!", "modules", ".", "equals", "(", "moduleRegistry", ".", "getModules", "(", ")", ")", ")", "{", "modules", "=", "moduleRegistry", ".", "getModules", "(", ")", ";", "cachedMethods", "=", "getDGMMethods", "(", "registry", ")", ";", "}", "}", "finally", "{", "lock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "lock", ".", "readLock", "(", ")", ".", "lock", "(", ")", ";", "}", "}", "else", "if", "(", "cachedMethods", "==", "null", ")", "{", "lock", ".", "readLock", "(", ")", ".", "unlock", "(", ")", ";", "lock", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "cachedMethods", "=", "getDGMMethods", "(", "registry", ")", ";", "}", "finally", "{", "lock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "lock", ".", "readLock", "(", ")", ".", "lock", "(", ")", ";", "}", "}", "}", "try", "{", "return", "Collections", ".", "unmodifiableMap", "(", "cachedMethods", ")", ";", "}", "finally", "{", "lock", ".", "readLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}", "private", "static", "Map", "<", "String", ",", "List", "<", "MethodNode", ">", ">", "getDGMMethods", "(", "final", "MetaClassRegistry", "registry", ")", "{", "Set", "<", "Class", ">", "instanceExtClasses", "=", "new", "LinkedHashSet", "<", "Class", ">", "(", ")", ";", "Set", "<", "Class", ">", "staticExtClasses", "=", "new", "LinkedHashSet", "<", "Class", ">", "(", ")", ";", "if", "(", "registry", "instanceof", "MetaClassRegistryImpl", ")", "{", "MetaClassRegistryImpl", "impl", "=", "(", "MetaClassRegistryImpl", ")", "registry", ";", "List", "<", "ExtensionModule", ">", "modules", "=", "impl", ".", "getModuleRegistry", "(", ")", ".", "getModules", "(", ")", ";", "for", "(", "ExtensionModule", "module", ":", "modules", ")", "{", "if", "(", "module", "instanceof", "MetaInfExtensionModule", ")", "{", "MetaInfExtensionModule", "extensionModule", "=", "(", "MetaInfExtensionModule", ")", "module", ";", "instanceExtClasses", ".", "addAll", "(", "extensionModule", ".", "getInstanceMethodsExtensionClasses", "(", ")", ")", ";", "staticExtClasses", ".", "addAll", "(", "extensionModule", ".", "getStaticMethodsExtensionClasses", "(", ")", ")", ";", "}", "}", "}", "Map", "<", "String", ",", "List", "<", "MethodNode", ">", ">", "methods", "=", "new", "HashMap", "<", "String", ",", "List", "<", "MethodNode", ">", ">", "(", ")", ";", "Collections", ".", "addAll", "(", "instanceExtClasses", ",", "DefaultGroovyMethods", ".", "DGM_LIKE_CLASSES", ")", ";", "Collections", ".", "addAll", "(", "instanceExtClasses", ",", "DefaultGroovyMethods", ".", "additionals", ")", ";", "staticExtClasses", ".", "add", "(", "DefaultGroovyStaticMethods", ".", "class", ")", ";", "instanceExtClasses", ".", "add", "(", "ObjectArrayStaticTypesHelper", ".", "class", ")", ";", "List", "<", "Class", ">", "allClasses", "=", "new", "ArrayList", "<", "Class", ">", "(", "instanceExtClasses", ".", "size", "(", ")", "+", "staticExtClasses", ".", "size", "(", ")", ")", ";", "allClasses", ".", "addAll", "(", "instanceExtClasses", ")", ";", "allClasses", ".", "addAll", "(", "staticExtClasses", ")", ";", "for", "(", "Class", "dgmLikeClass", ":", "allClasses", ")", "{", "ClassNode", "cn", "=", "ClassHelper", ".", "makeWithoutCaching", "(", "dgmLikeClass", ",", "true", ")", ";", "for", "(", "MethodNode", "metaMethod", ":", "cn", ".", "getMethods", "(", ")", ")", "{", "Parameter", "[", "]", "types", "=", "metaMethod", ".", "getParameters", "(", ")", ";", "if", "(", "metaMethod", ".", "isStatic", "(", ")", "&&", "metaMethod", ".", "isPublic", "(", ")", "&&", "types", ".", "length", ">", "0", "&&", "metaMethod", ".", "getAnnotations", "(", "Deprecated_TYPE", ")", ".", "isEmpty", "(", ")", ")", "{", "Parameter", "[", "]", "parameters", "=", "new", "Parameter", "[", "types", ".", "length", "-", "1", "]", ";", "System", ".", "arraycopy", "(", "types", ",", "1", ",", "parameters", ",", "0", ",", "parameters", ".", "length", ")", ";", "MethodNode", "node", "=", "new", "ExtensionMethodNode", "(", "metaMethod", ",", "metaMethod", ".", "getName", "(", ")", ",", "metaMethod", ".", "getModifiers", "(", ")", ",", "metaMethod", ".", "getReturnType", "(", ")", ",", "parameters", ",", "ClassNode", ".", "EMPTY_ARRAY", ",", "null", ")", ";", "if", "(", "staticExtClasses", ".", "contains", "(", "dgmLikeClass", ")", ")", "{", "node", ".", "setModifiers", "(", "node", ".", "getModifiers", "(", ")", "|", "Opcodes", ".", "ACC_STATIC", ")", ";", "}", "node", ".", "setGenericsTypes", "(", "metaMethod", ".", "getGenericsTypes", "(", ")", ")", ";", "ClassNode", "declaringClass", "=", "types", "[", "0", "]", ".", "getType", "(", ")", ";", "String", "declaringClassName", "=", "declaringClass", ".", "getName", "(", ")", ";", "node", ".", "setDeclaringClass", "(", "declaringClass", ")", ";", "List", "<", "MethodNode", ">", "nodes", "=", "methods", ".", "get", "(", "declaringClassName", ")", ";", "if", "(", "nodes", "==", "null", ")", "{", "nodes", "=", "new", "LinkedList", "<", "MethodNode", ">", "(", ")", ";", "methods", ".", "put", "(", "declaringClassName", ",", "nodes", ")", ";", "}", "nodes", ".", "add", "(", "node", ")", ";", "}", "}", "}", "return", "methods", ";", "}", "}", "public", "static", "boolean", "isGStringOrGStringStringLUB", "(", "ClassNode", "node", ")", "{", "return", "ClassHelper", ".", "GSTRING_TYPE", ".", "equals", "(", "node", ")", "||", "GSTRING_STRING_CLASSNODE", ".", "equals", "(", "node", ")", ";", "}", "public", "static", "boolean", "isParameterizedWithGStringOrGStringString", "(", "ClassNode", "node", ")", "{", "if", "(", "node", ".", "isArray", "(", ")", ")", "return", "isParameterizedWithGStringOrGStringString", "(", "node", ".", "getComponentType", "(", ")", ")", ";", "if", "(", "node", ".", "isUsingGenerics", "(", ")", ")", "{", "GenericsType", "[", "]", "genericsTypes", "=", "node", ".", "getGenericsTypes", "(", ")", ";", "if", "(", "genericsTypes", "!=", "null", ")", "{", "for", "(", "GenericsType", "genericsType", ":", "genericsTypes", ")", "{", "if", "(", "isGStringOrGStringStringLUB", "(", "genericsType", ".", "getType", "(", ")", ")", ")", "return", "true", ";", "}", "}", "}", "return", "node", ".", "getSuperClass", "(", ")", "!=", "null", "&&", "isParameterizedWithGStringOrGStringString", "(", "node", ".", "getUnresolvedSuperClass", "(", ")", ")", ";", "}", "public", "static", "boolean", "isParameterizedWithString", "(", "ClassNode", "node", ")", "{", "if", "(", "node", ".", "isArray", "(", ")", ")", "return", "isParameterizedWithString", "(", "node", ".", "getComponentType", "(", ")", ")", ";", "if", "(", "node", ".", "isUsingGenerics", "(", ")", ")", "{", "GenericsType", "[", "]", "genericsTypes", "=", "node", ".", "getGenericsTypes", "(", ")", ";", "if", "(", "genericsTypes", "!=", "null", ")", "{", "for", "(", "GenericsType", "genericsType", ":", "genericsTypes", ")", "{", "if", "(", "STRING_TYPE", ".", "equals", "(", "genericsType", ".", "getType", "(", ")", ")", ")", "return", "true", ";", "}", "}", "}", "return", "node", ".", "getSuperClass", "(", ")", "!=", "null", "&&", "isParameterizedWithString", "(", "node", ".", "getUnresolvedSuperClass", "(", ")", ")", ";", "}", "public", "static", "boolean", "missesGenericsTypes", "(", "ClassNode", "cn", ")", "{", "if", "(", "cn", ".", "isArray", "(", ")", ")", "return", "missesGenericsTypes", "(", "cn", ".", "getComponentType", "(", ")", ")", ";", "if", "(", "cn", ".", "redirect", "(", ")", ".", "isUsingGenerics", "(", ")", "&&", "!", "cn", ".", "isUsingGenerics", "(", ")", ")", "return", "true", ";", "if", "(", "cn", ".", "isUsingGenerics", "(", ")", ")", "{", "if", "(", "cn", ".", "getGenericsTypes", "(", ")", "==", "null", ")", "return", "true", ";", "for", "(", "GenericsType", "genericsType", ":", "cn", ".", "getGenericsTypes", "(", ")", ")", "{", "if", "(", "genericsType", ".", "isPlaceholder", "(", ")", ")", "return", "true", ";", "}", "}", "return", "false", ";", "}", "}", "</s>" ]
6,926
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "transform", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "AnnotatedNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "AnnotationNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ClassCodeVisitorSupport", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ClassNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "CompilePhase", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "SourceUnit", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "SimpleMessage", ";", "import", "groovy", ".", "lang", ".", "GroovyClassLoader", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Annotation", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "ASTTransformationCollectorCodeVisitor", "extends", "ClassCodeVisitorSupport", "{", "private", "SourceUnit", "source", ";", "private", "ClassNode", "classNode", ";", "private", "GroovyClassLoader", "transformLoader", ";", "private", "boolean", "allowTransforms", ";", "private", "List", "<", "String", ">", "localTransformsAllowed", ";", "public", "ASTTransformationCollectorCodeVisitor", "(", "SourceUnit", "source", ",", "GroovyClassLoader", "transformLoader", ",", "boolean", "allowTransforms", ",", "List", "<", "String", ">", "localTransformsAllowed", ")", "{", "this", "(", "source", ",", "transformLoader", ")", ";", "this", ".", "allowTransforms", "=", "allowTransforms", ";", "this", ".", "localTransformsAllowed", "=", "localTransformsAllowed", ";", "}", "public", "ASTTransformationCollectorCodeVisitor", "(", "SourceUnit", "source", ",", "GroovyClassLoader", "transformLoader", ")", "{", "this", ".", "source", "=", "source", ";", "this", ".", "transformLoader", "=", "transformLoader", ";", "}", "protected", "SourceUnit", "getSourceUnit", "(", ")", "{", "return", "source", ";", "}", "public", "void", "visitClass", "(", "ClassNode", "klassNode", ")", "{", "ClassNode", "oldClass", "=", "classNode", ";", "classNode", "=", "klassNode", ";", "super", ".", "visitClass", "(", "classNode", ")", ";", "classNode", "=", "oldClass", ";", "}", "private", "final", "static", "String", "[", "]", "NONE", "=", "new", "String", "[", "0", "]", ";", "private", "final", "static", "Class", "[", "]", "NO_CLASSES", "=", "new", "Class", "[", "0", "]", ";", "private", "String", "[", "]", "getTransformClassNames", "(", "ClassNode", "cn", ")", "{", "if", "(", "!", "cn", ".", "hasClass", "(", ")", ")", "{", "List", "<", "AnnotationNode", ">", "annotations", "=", "cn", ".", "getAnnotations", "(", ")", ";", "AnnotationNode", "transformAnnotation", "=", "null", ";", "for", "(", "AnnotationNode", "anno", ":", "annotations", ")", "{", "if", "(", "anno", ".", "getClassNode", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "GroovyASTTransformationClass", ".", "class", ".", "getName", "(", ")", ")", ")", "{", "transformAnnotation", "=", "anno", ";", "break", ";", "}", "}", "if", "(", "transformAnnotation", "!=", "null", ")", "{", "Expression", "expr2", "=", "transformAnnotation", ".", "getMember", "(", "\"value\"", ")", ";", "String", "[", "]", "values", "=", "null", ";", "if", "(", "expr2", "==", "null", ")", "{", "return", "NONE", ";", "}", "if", "(", "expr2", "instanceof", "ListExpression", ")", "{", "ListExpression", "expression", "=", "(", "ListExpression", ")", "expr2", ";", "List", "<", "Expression", ">", "expressions", "=", "expression", ".", "getExpressions", "(", ")", ";", "values", "=", "new", "String", "[", "expressions", ".", "size", "(", ")", "]", ";", "int", "e", "=", "0", ";", "for", "(", "Expression", "expr", ":", "expressions", ")", "{", "values", "[", "e", "++", "]", "=", "(", "(", "ConstantExpression", ")", "expr", ")", ".", "getText", "(", ")", ";", "}", "}", "else", "if", "(", "expr2", "instanceof", "ConstantExpression", ")", "{", "values", "=", "new", "String", "[", "1", "]", ";", "values", "[", "0", "]", "=", "(", "(", "ConstantExpression", ")", "expr2", ")", ".", "getText", "(", ")", ";", "}", "else", "{", "throw", "new", "IllegalStateException", "(", "\"\"", "+", "expr2", "+", "\"", "(class=\"", "+", "expr2", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\")\"", ")", ";", "}", "return", "values", ";", "}", "return", "null", ";", "}", "else", "{", "Annotation", "transformClassAnnotation", "=", "getTransformClassAnnotation", "(", "cn", ")", ";", "if", "(", "transformClassAnnotation", "==", "null", ")", "{", "return", "null", ";", "}", "return", "getTransformClassNames", "(", "transformClassAnnotation", ")", ";", "}", "}", "private", "Class", "[", "]", "getTransformClasses", "(", "ClassNode", "classNode", ")", "{", "if", "(", "!", "classNode", ".", "hasClass", "(", ")", ")", "{", "List", "<", "AnnotationNode", ">", "annotations", "=", "classNode", ".", "getAnnotations", "(", ")", ";", "AnnotationNode", "transformAnnotation", "=", "null", ";", "for", "(", "AnnotationNode", "anno", ":", "annotations", ")", "{", "if", "(", "anno", ".", "getClassNode", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "GroovyASTTransformationClass", ".", "class", ".", "getName", "(", ")", ")", ")", "{", "transformAnnotation", "=", "anno", ";", "break", ";", "}", "}", "if", "(", "transformAnnotation", "!=", "null", ")", "{", "Expression", "expr", "=", "(", "Expression", ")", "transformAnnotation", ".", "getMember", "(", "\"classes\"", ")", ";", "if", "(", "expr", "==", "null", ")", "{", "return", "NO_CLASSES", ";", "}", "Class", "<", "?", ">", "[", "]", "values", "=", "NO_CLASSES", ";", "if", "(", "expr", "instanceof", "ListExpression", ")", "{", "List", "<", "Class", "<", "?", ">", ">", "loadedClasses", "=", "new", "ArrayList", "<", "Class", "<", "?", ">", ">", "(", ")", ";", "ListExpression", "expression", "=", "(", "ListExpression", ")", "expr", ";", "List", "<", "Expression", ">", "expressions", "=", "expression", ".", "getExpressions", "(", ")", ";", "for", "(", "Expression", "oneExpr", ":", "expressions", ")", "{", "String", "classname", "=", "(", "(", "ClassExpression", ")", "oneExpr", ")", ".", "getType", "(", ")", ".", "getName", "(", ")", ";", "try", "{", "Class", "<", "?", ">", "clazz", "=", "Class", ".", "forName", "(", "classname", ",", "false", ",", "transformLoader", ")", ";", "loadedClasses", ".", "add", "(", "clazz", ")", ";", "}", "catch", "(", "ClassNotFoundException", "cnfe", ")", "{", "source", ".", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SimpleMessage", "(", "\"\"", "+", "classname", ",", "source", ")", ")", ";", "}", "}", "if", "(", "loadedClasses", ".", "size", "(", ")", "!=", "0", ")", "{", "values", "=", "loadedClasses", ".", "toArray", "(", "new", "Class", "<", "?", ">", "[", "loadedClasses", ".", "size", "(", ")", "]", ")", ";", "}", "return", "values", ";", "}", "else", "{", "}", "throw", "new", "RuntimeException", "(", "\"\"", "+", "expr", "+", "\"", "(class=\"", "+", "expr", ".", "getClass", "(", ")", "+", "\")\"", ")", ";", "}", "return", "null", ";", "}", "else", "{", "Annotation", "transformClassAnnotation", "=", "getTransformClassAnnotation", "(", "classNode", ")", ";", "if", "(", "transformClassAnnotation", "==", "null", ")", "{", "return", "null", ";", "}", "return", "getTransformClasses", "(", "transformClassAnnotation", ")", ";", "}", "}", "public", "void", "visitAnnotations", "(", "AnnotatedNode", "node", ")", "{", "super", ".", "visitAnnotations", "(", "node", ")", ";", "for", "(", "AnnotationNode", "annotation", ":", "node", ".", "getAnnotations", "(", ")", ")", "{", "if", "(", "!", "this", ".", "allowTransforms", ")", "{", "if", "(", "!", "isAllowed", "(", "annotation", ".", "getClassNode", "(", ")", ".", "getName", "(", ")", ")", ")", "{", "continue", ";", "}", "}", "String", "[", "]", "transformClassNames", "=", "getTransformClassNames", "(", "annotation", ".", "getClassNode", "(", ")", ")", ";", "Class", "[", "]", "transformClasses", "=", "getTransformClasses", "(", "annotation", ".", "getClassNode", "(", ")", ")", ";", "if", "(", "transformClassNames", "==", "null", "&&", "transformClasses", "==", "null", ")", "{", "continue", ";", "}", "if", "(", "transformClassNames", "==", "null", ")", "{", "transformClassNames", "=", "NONE", ";", "}", "if", "(", "transformClasses", "==", "null", ")", "{", "transformClasses", "=", "NO_CLASSES", ";", "}", "addTransformsToClassNode", "(", "annotation", ",", "transformClassNames", ",", "transformClasses", ")", ";", "}", "}", "private", "boolean", "isAllowed", "(", "String", "transformName", ")", "{", "if", "(", "transformName", ".", "equals", "(", "\"\"", ")", ")", "{", "return", "true", ";", "}", "if", "(", "transformName", ".", "equals", "(", "\"\"", ")", ")", "{", "return", "true", ";", "}", "for", "(", "String", "localTransformAllowed", ":", "localTransformsAllowed", ")", "{", "if", "(", "localTransformAllowed", ".", "equals", "(", "\"*\"", ")", ")", "{", "return", "true", ";", "}", "else", "if", "(", "localTransformAllowed", ".", "endsWith", "(", "\"$\"", ")", ")", "{", "if", "(", "transformName", ".", "endsWith", "(", "localTransformAllowed", ".", "substring", "(", "0", ",", "localTransformAllowed", ".", "length", "(", ")", "-", "1", ")", ")", ")", "{", "return", "true", ";", "}", "}", "else", "{", "boolean", "b", "=", "transformName", ".", "indexOf", "(", "localTransformAllowed", ")", "!=", "-", "1", ";", "if", "(", "b", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}", "private", "void", "addTransformsToClassNode", "(", "AnnotationNode", "annotation", ",", "Annotation", "transformClassAnnotation", ")", "{", "String", "[", "]", "transformClassNames", "=", "getTransformClassNames", "(", "annotation", ".", "getClassNode", "(", ")", ")", ";", "Class", "[", "]", "transformClasses", "=", "getTransformClasses", "(", "transformClassAnnotation", ")", ";", "addTransformsToClassNode", "(", "annotation", ",", "transformClassNames", ",", "transformClasses", ")", ";", "}", "private", "void", "addTransformsToClassNode", "(", "AnnotationNode", "annotation", ",", "String", "[", "]", "transformClassNames", ",", "Class", "[", "]", "transformClasses", ")", "{", "if", "(", "transformClassNames", ".", "length", "==", "0", "&&", "transformClasses", ".", "length", "==", "0", ")", "{", "source", ".", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SimpleMessage", "(", "\"\"", "+", "annotation", ".", "getClassNode", "(", ")", ".", "getName", "(", ")", "+", "\"\"", ",", "source", ")", ")", ";", "}", "if", "(", "transformClassNames", ".", "length", ">", "0", "&&", "transformClasses", ".", "length", ">", "0", ")", "{", "source", ".", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SimpleMessage", "(", "\"\"", "+", "annotation", ".", "getClassNode", "(", ")", ".", "getName", "(", ")", "+", "\"\"", ",", "source", ")", ")", ";", "}", "for", "(", "String", "transformClass", ":", "transformClassNames", ")", "{", "try", "{", "Class", "klass", "=", "transformLoader", ".", "loadClass", "(", "transformClass", ",", "false", ",", "true", ",", "false", ")", ";", "verifyAndAddTransform", "(", "annotation", ",", "klass", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "source", ".", "getErrorCollector", "(", ")", ".", "addErrorAndContinue", "(", "new", "SimpleMessage", "(", "\"\"", "+", "transformClass", "+", "\"\"", "+", "annotation", ".", "getClassNode", "(", ")", ".", "getName", "(", ")", ",", "source", ")", ")", ";", "}", "}", "for", "(", "Class", "klass", ":", "transformClasses", ")", "{", "verifyAndAddTransform", "(", "annotation", ",", "klass", ")", ";", "}", "}", "private", "void", "verifyAndAddTransform", "(", "AnnotationNode", "annotation", ",", "Class", "klass", ")", "{", "verifyClass", "(", "annotation", ",", "klass", ")", ";", "verifyCompilePhase", "(", "annotation", ",", "klass", ")", ";", "addTransform", "(", "annotation", ",", "klass", ")", ";", "}", "private", "void", "verifyCompilePhase", "(", "AnnotationNode", "annotation", ",", "Class", "klass", ")", "{", "GroovyASTTransformation", "transformationClass", "=", "(", "GroovyASTTransformation", ")", "klass", ".", "getAnnotation", "(", "GroovyASTTransformation", ".", "class", ")", ";", "if", "(", "transformationClass", "!=", "null", ")", "{", "CompilePhase", "specifiedCompilePhase", "=", "transformationClass", ".", "phase", "(", ")", ";", "if", "(", "specifiedCompilePhase", ".", "getPhaseNumber", "(", ")", "<", "CompilePhase", ".", "SEMANTIC_ANALYSIS", ".", "getPhaseNumber", "(", ")", ")", "{", "source", ".", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SimpleMessage", "(", "annotation", ".", "getClassNode", "(", ")", ".", "getName", "(", ")", "+", "\"\"", "+", "specifiedCompilePhase", "+", "\"\"", "+", "CompilePhase", ".", "SEMANTIC_ANALYSIS", "+", "\"", "or", "later!\"", ",", "source", ")", ")", ";", "}", "}", "}", "private", "void", "verifyClass", "(", "AnnotationNode", "annotation", ",", "Class", "klass", ")", "{", "if", "(", "!", "ASTTransformation", ".", "class", ".", "isAssignableFrom", "(", "klass", ")", ")", "{", "source", ".", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SimpleMessage", "(", "\"\"", "+", "klass", ".", "getName", "(", ")", "+", "\"\"", "+", "annotation", ".", "getClassNode", "(", ")", ".", "getName", "(", ")", ",", "source", ")", ")", ";", "}", "}", "private", "void", "addTransform", "(", "AnnotationNode", "annotation", ",", "Class", "klass", ")", "{", "classNode", ".", "addTransform", "(", "klass", ",", "annotation", ")", ";", "}", "private", "static", "Annotation", "getTransformClassAnnotation", "(", "ClassNode", "annotatedType", ")", "{", "if", "(", "!", "annotatedType", ".", "isResolved", "(", ")", ")", "return", "null", ";", "for", "(", "Annotation", "ann", ":", "annotatedType", ".", "getTypeClass", "(", ")", ".", "getAnnotations", "(", ")", ")", "{", "if", "(", "ann", ".", "annotationType", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "GroovyASTTransformationClass", ".", "class", ".", "getName", "(", ")", ")", ")", "{", "return", "ann", ";", "}", "}", "return", "null", ";", "}", "private", "String", "[", "]", "getTransformClassNames", "(", "Annotation", "transformClassAnnotation", ")", "{", "try", "{", "Method", "valueMethod", "=", "transformClassAnnotation", ".", "getClass", "(", ")", ".", "getMethod", "(", "\"value\"", ")", ";", "return", "(", "String", "[", "]", ")", "valueMethod", ".", "invoke", "(", "transformClassAnnotation", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "source", ".", "addException", "(", "e", ")", ";", "return", "new", "String", "[", "0", "]", ";", "}", "}", "private", "Class", "[", "]", "getTransformClasses", "(", "Annotation", "transformClassAnnotation", ")", "{", "try", "{", "Method", "classesMethod", "=", "transformClassAnnotation", ".", "getClass", "(", ")", ".", "getMethod", "(", "\"classes\"", ")", ";", "return", "(", "Class", "[", "]", ")", "classesMethod", ".", "invoke", "(", "transformClassAnnotation", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "source", ".", "addException", "(", "e", ")", ";", "return", "new", "Class", "[", "0", "]", ";", "}", "}", "}", "</s>" ]
6,927
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "transform", ";", "import", "groovy", ".", "lang", ".", "GroovyClassLoader", ";", "import", "groovy", ".", "lang", ".", "GroovyRuntimeException", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "GroovyBugError", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "CompilePhase", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "SourceUnit", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "SyntaxErrorMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "runtime", ".", "DefaultGroovyMethods", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "SyntaxException", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Modifier", ";", "import", "java", ".", "util", ".", "Arrays", ";", "@", "GroovyASTTransformation", "(", "phase", "=", "CompilePhase", ".", "SEMANTIC_ANALYSIS", ")", "public", "class", "LogASTTransformation", "implements", "ASTTransformation", "{", "public", "void", "visit", "(", "ASTNode", "[", "]", "nodes", ",", "final", "SourceUnit", "source", ")", "{", "if", "(", "nodes", ".", "length", "!=", "2", "||", "!", "(", "nodes", "[", "0", "]", "instanceof", "AnnotationNode", ")", "||", "!", "(", "nodes", "[", "1", "]", "instanceof", "AnnotatedNode", ")", ")", "{", "addError", "(", "\"\"", "+", "Arrays", ".", "asList", "(", "nodes", ")", ",", "nodes", "[", "0", "]", ",", "source", ")", ";", "}", "AnnotatedNode", "targetClass", "=", "(", "AnnotatedNode", ")", "nodes", "[", "1", "]", ";", "AnnotationNode", "logAnnotation", "=", "(", "AnnotationNode", ")", "nodes", "[", "0", "]", ";", "final", "LoggingStrategy", "loggingStrategy", "=", "createLoggingStrategy", "(", "logAnnotation", ",", "source", ".", "getClassLoader", "(", ")", ")", ";", "if", "(", "loggingStrategy", "==", "null", ")", "return", ";", "final", "String", "logFieldName", "=", "lookupLogFieldName", "(", "logAnnotation", ")", ";", "if", "(", "!", "(", "targetClass", "instanceof", "ClassNode", ")", ")", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "logAnnotation", ".", "getClassNode", "(", ")", ".", "getName", "(", ")", "+", "\"\"", ")", ";", "final", "ClassNode", "classNode", "=", "(", "ClassNode", ")", "targetClass", ";", "ClassCodeExpressionTransformer", "transformer", "=", "new", "ClassCodeExpressionTransformer", "(", ")", "{", "private", "FieldNode", "logNode", ";", "@", "Override", "protected", "SourceUnit", "getSourceUnit", "(", ")", "{", "return", "source", ";", "}", "public", "Expression", "transform", "(", "Expression", "exp", ")", "{", "if", "(", "exp", "==", "null", ")", "return", "null", ";", "if", "(", "exp", "instanceof", "MethodCallExpression", ")", "{", "return", "transformMethodCallExpression", "(", "exp", ")", ";", "}", "return", "super", ".", "transform", "(", "exp", ")", ";", "}", "@", "Override", "public", "void", "visitClass", "(", "ClassNode", "node", ")", "{", "FieldNode", "logField", "=", "node", ".", "getField", "(", "logFieldName", ")", ";", "if", "(", "logField", "!=", "null", "&&", "logField", ".", "getOwner", "(", ")", ".", "equals", "(", "node", ")", ")", "{", "addError", "(", "\"\"", ",", "logField", ")", ";", "}", "else", "if", "(", "logField", "!=", "null", "&&", "!", "Modifier", ".", "isPrivate", "(", "logField", ".", "getModifiers", "(", ")", ")", ")", "{", "addError", "(", "\"\"", "+", "logField", ".", "getOwner", "(", ")", ".", "getName", "(", ")", ",", "logField", ")", ";", "}", "else", "{", "logNode", "=", "loggingStrategy", ".", "addLoggerFieldToClass", "(", "node", ",", "logFieldName", ")", ";", "}", "super", ".", "visitClass", "(", "node", ")", ";", "}", "private", "Expression", "transformMethodCallExpression", "(", "Expression", "exp", ")", "{", "MethodCallExpression", "mce", "=", "(", "MethodCallExpression", ")", "exp", ";", "if", "(", "!", "(", "mce", ".", "getObjectExpression", "(", ")", "instanceof", "VariableExpression", ")", ")", "{", "return", "exp", ";", "}", "VariableExpression", "variableExpression", "=", "(", "VariableExpression", ")", "mce", ".", "getObjectExpression", "(", ")", ";", "if", "(", "!", "variableExpression", ".", "getName", "(", ")", ".", "equals", "(", "logFieldName", ")", "||", "!", "(", "variableExpression", ".", "getAccessedVariable", "(", ")", "instanceof", "DynamicVariable", ")", ")", "{", "return", "exp", ";", "}", "String", "methodName", "=", "mce", ".", "getMethodAsString", "(", ")", ";", "if", "(", "methodName", "==", "null", ")", "return", "exp", ";", "if", "(", "usesSimpleMethodArgumentsOnly", "(", "mce", ")", ")", "return", "exp", ";", "variableExpression", ".", "setAccessedVariable", "(", "logNode", ")", ";", "if", "(", "!", "loggingStrategy", ".", "isLoggingMethod", "(", "methodName", ")", ")", "return", "exp", ";", "return", "loggingStrategy", ".", "wrapLoggingMethodCall", "(", "variableExpression", ",", "methodName", ",", "exp", ")", ";", "}", "private", "boolean", "usesSimpleMethodArgumentsOnly", "(", "MethodCallExpression", "mce", ")", "{", "Expression", "arguments", "=", "mce", ".", "getArguments", "(", ")", ";", "if", "(", "arguments", "instanceof", "TupleExpression", ")", "{", "TupleExpression", "tuple", "=", "(", "TupleExpression", ")", "arguments", ";", "for", "(", "Expression", "exp", ":", "tuple", ".", "getExpressions", "(", ")", ")", "{", "if", "(", "!", "isSimpleExpression", "(", "exp", ")", ")", "return", "false", ";", "}", "return", "true", ";", "}", "return", "!", "isSimpleExpression", "(", "arguments", ")", ";", "}", "private", "boolean", "isSimpleExpression", "(", "Expression", "exp", ")", "{", "if", "(", "exp", "instanceof", "ConstantExpression", ")", "return", "true", ";", "if", "(", "exp", "instanceof", "VariableExpression", ")", "return", "true", ";", "return", "false", ";", "}", "}", ";", "transformer", ".", "visitClass", "(", "classNode", ")", ";", "}", "private", "String", "lookupLogFieldName", "(", "AnnotationNode", "logAnnotation", ")", "{", "Expression", "member", "=", "logAnnotation", ".", "getMember", "(", "\"value\"", ")", ";", "if", "(", "member", "!=", "null", "&&", "member", ".", "getText", "(", ")", "!=", "null", ")", "{", "return", "member", ".", "getText", "(", ")", ";", "}", "else", "{", "return", "\"log\"", ";", "}", "}", "public", "void", "addError", "(", "String", "msg", ",", "ASTNode", "expr", ",", "SourceUnit", "source", ")", "{", "source", ".", "getErrorCollector", "(", ")", ".", "addErrorAndContinue", "(", "new", "SyntaxErrorMessage", "(", "new", "SyntaxException", "(", "msg", "+", "'\\n'", ",", "expr", ".", "getLineNumber", "(", ")", ",", "expr", ".", "getColumnNumber", "(", ")", ",", "expr", ".", "getLastLineNumber", "(", ")", ",", "expr", ".", "getLastColumnNumber", "(", ")", ")", ",", "source", ")", ")", ";", "}", "private", "LoggingStrategy", "createLoggingStrategy", "(", "AnnotationNode", "logAnnotation", ",", "GroovyClassLoader", "loader", ")", "{", "String", "annotationName", "=", "logAnnotation", ".", "getClassNode", "(", ")", ".", "getName", "(", ")", ";", "Class", "annotationClass", ";", "try", "{", "annotationClass", "=", "Class", ".", "forName", "(", "annotationName", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", "+", "annotationName", ")", ";", "}", "Method", "annotationMethod", ";", "try", "{", "annotationMethod", "=", "annotationClass", ".", "getDeclaredMethod", "(", "\"\"", ",", "(", "Class", "[", "]", ")", "null", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", "+", "annotationName", ")", ";", "}", "Object", "defaultValue", ";", "try", "{", "defaultValue", "=", "annotationMethod", ".", "getDefaultValue", "(", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", "+", "annotationName", ")", ";", "}", "if", "(", "!", "LoggingStrategy", ".", "class", ".", "isAssignableFrom", "(", "(", "Class", ")", "defaultValue", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", "+", "annotationName", "+", "\"\"", ")", ";", "}", "try", "{", "Class", "<", "?", "extends", "LoggingStrategy", ">", "strategyClass", "=", "(", "Class", "<", "?", "extends", "LoggingStrategy", ">", ")", "defaultValue", ";", "if", "(", "AbstractLoggingStrategy", ".", "class", ".", "isAssignableFrom", "(", "strategyClass", ")", ")", "{", "return", "DefaultGroovyMethods", ".", "newInstance", "(", "strategyClass", ",", "new", "Object", "[", "]", "{", "loader", "}", ")", ";", "}", "else", "{", "return", "strategyClass", ".", "newInstance", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "return", "null", ";", "}", "}", "public", "interface", "LoggingStrategy", "{", "FieldNode", "addLoggerFieldToClass", "(", "ClassNode", "classNode", ",", "String", "fieldName", ")", ";", "boolean", "isLoggingMethod", "(", "String", "methodName", ")", ";", "Expression", "wrapLoggingMethodCall", "(", "Expression", "logVariable", ",", "String", "methodName", ",", "Expression", "originalExpression", ")", ";", "}", "public", "static", "abstract", "class", "AbstractLoggingStrategy", "implements", "LoggingStrategy", "{", "protected", "final", "GroovyClassLoader", "loader", ";", "protected", "AbstractLoggingStrategy", "(", "final", "GroovyClassLoader", "loader", ")", "{", "this", ".", "loader", "=", "loader", ";", "}", "protected", "AbstractLoggingStrategy", "(", ")", "{", "this", "(", "null", ")", ";", "}", "protected", "ClassNode", "classNode", "(", "String", "name", ")", "{", "ClassLoader", "cl", "=", "loader", "==", "null", "?", "this", ".", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ":", "loader", ";", "try", "{", "return", "ClassHelper", ".", "make", "(", "Class", ".", "forName", "(", "name", ",", "false", ",", "cl", ")", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "return", "ClassHelper", ".", "make", "(", "name", ")", ";", "}", "}", "}", "}", "</s>" ]
6,928
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "vmplugin", ".", "v5", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "GroovyBugError", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "ReturnStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "vmplugin", ".", "VMPlugin", ";", "import", "java", ".", "lang", ".", "annotation", ".", "*", ";", "import", "java", ".", "lang", ".", "reflect", ".", "*", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "Java5", "implements", "VMPlugin", "{", "private", "static", "Class", "[", "]", "EMPTY_CLASS_ARRAY", "=", "new", "Class", "[", "0", "]", ";", "private", "static", "final", "Class", "[", "]", "PLUGIN_DGM", "=", "{", "PluginDefaultGroovyMethods", ".", "class", "}", ";", "public", "void", "setAdditionalClassInformation", "(", "ClassNode", "cn", ")", "{", "setGenericsTypes", "(", "cn", ")", ";", "}", "private", "void", "setGenericsTypes", "(", "ClassNode", "cn", ")", "{", "TypeVariable", "[", "]", "tvs", "=", "cn", ".", "getTypeClass", "(", ")", ".", "getTypeParameters", "(", ")", ";", "GenericsType", "[", "]", "gts", "=", "configureTypeVariable", "(", "tvs", ")", ";", "cn", ".", "setGenericsTypes", "(", "gts", ")", ";", "}", "private", "GenericsType", "[", "]", "configureTypeVariable", "(", "TypeVariable", "[", "]", "tvs", ")", "{", "if", "(", "tvs", ".", "length", "==", "0", ")", "return", "null", ";", "GenericsType", "[", "]", "gts", "=", "new", "GenericsType", "[", "tvs", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "tvs", ".", "length", ";", "i", "++", ")", "{", "gts", "[", "i", "]", "=", "configureTypeVariableDefinition", "(", "tvs", "[", "i", "]", ")", ";", "}", "return", "gts", ";", "}", "private", "GenericsType", "configureTypeVariableDefinition", "(", "TypeVariable", "tv", ")", "{", "ClassNode", "base", "=", "configureTypeVariableReference", "(", "tv", ")", ";", "ClassNode", "redirect", "=", "base", ".", "redirect", "(", ")", ";", "base", ".", "setRedirect", "(", "null", ")", ";", "Type", "[", "]", "tBounds", "=", "tv", ".", "getBounds", "(", ")", ";", "GenericsType", "gt", ";", "if", "(", "tBounds", ".", "length", "==", "0", ")", "{", "gt", "=", "new", "GenericsType", "(", "base", ")", ";", "}", "else", "{", "ClassNode", "[", "]", "cBounds", "=", "configureTypes", "(", "tBounds", ")", ";", "gt", "=", "new", "GenericsType", "(", "base", ",", "cBounds", ",", "null", ")", ";", "gt", ".", "setName", "(", "base", ".", "getName", "(", ")", ")", ";", "gt", ".", "setPlaceholder", "(", "true", ")", ";", "}", "base", ".", "setRedirect", "(", "redirect", ")", ";", "return", "gt", ";", "}", "private", "ClassNode", "[", "]", "configureTypes", "(", "Type", "[", "]", "types", ")", "{", "if", "(", "types", ".", "length", "==", "0", ")", "return", "null", ";", "ClassNode", "[", "]", "nodes", "=", "new", "ClassNode", "[", "types", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "types", ".", "length", ";", "i", "++", ")", "{", "nodes", "[", "i", "]", "=", "configureType", "(", "types", "[", "i", "]", ")", ";", "}", "return", "nodes", ";", "}", "private", "ClassNode", "configureType", "(", "Type", "type", ")", "{", "if", "(", "type", "instanceof", "WildcardType", ")", "{", "return", "configureWildcardType", "(", "(", "WildcardType", ")", "type", ")", ";", "}", "else", "if", "(", "type", "instanceof", "ParameterizedType", ")", "{", "return", "configureParameterizedType", "(", "(", "ParameterizedType", ")", "type", ")", ";", "}", "else", "if", "(", "type", "instanceof", "GenericArrayType", ")", "{", "return", "configureGenericArray", "(", "(", "GenericArrayType", ")", "type", ")", ";", "}", "else", "if", "(", "type", "instanceof", "TypeVariable", ")", "{", "return", "configureTypeVariableReference", "(", "(", "TypeVariable", ")", "type", ")", ";", "}", "else", "if", "(", "type", "instanceof", "Class", ")", "{", "return", "configureClass", "(", "(", "Class", ")", "type", ")", ";", "}", "else", "if", "(", "type", "==", "null", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", ")", ";", "}", "else", "{", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "type", "+", "\"", ":=", "\"", "+", "type", ".", "getClass", "(", ")", ")", ";", "}", "}", "private", "ClassNode", "configureClass", "(", "Class", "c", ")", "{", "if", "(", "c", ".", "isPrimitive", "(", ")", ")", "{", "return", "ClassHelper", ".", "make", "(", "c", ")", ";", "}", "else", "{", "return", "ClassHelper", ".", "makeWithoutCaching", "(", "c", ",", "false", ")", ";", "}", "}", "private", "ClassNode", "configureGenericArray", "(", "GenericArrayType", "genericArrayType", ")", "{", "Type", "component", "=", "genericArrayType", ".", "getGenericComponentType", "(", ")", ";", "ClassNode", "node", "=", "configureType", "(", "component", ")", ";", "return", "node", ".", "makeArray", "(", ")", ";", "}", "private", "ClassNode", "configureWildcardType", "(", "WildcardType", "wildcardType", ")", "{", "ClassNode", "base", "=", "ClassHelper", ".", "makeWithoutCaching", "(", "\"?\"", ")", ";", "base", ".", "setRedirect", "(", "ClassHelper", ".", "OBJECT_TYPE", ")", ";", "ClassNode", "[", "]", "lowers", "=", "configureTypes", "(", "wildcardType", ".", "getLowerBounds", "(", ")", ")", ";", "ClassNode", "lower", "=", "null", ";", "if", "(", "lower", "!=", "null", ")", "lower", "=", "lowers", "[", "0", "]", ";", "ClassNode", "[", "]", "upper", "=", "configureTypes", "(", "wildcardType", ".", "getUpperBounds", "(", ")", ")", ";", "GenericsType", "t", "=", "new", "GenericsType", "(", "base", ",", "upper", ",", "lower", ")", ";", "t", ".", "setWildcard", "(", "true", ")", ";", "ClassNode", "ref", "=", "ClassHelper", ".", "makeWithoutCaching", "(", "Object", ".", "class", ",", "false", ")", ";", "ref", ".", "setGenericsTypes", "(", "new", "GenericsType", "[", "]", "{", "t", "}", ")", ";", "return", "ref", ";", "}", "private", "ClassNode", "configureParameterizedType", "(", "ParameterizedType", "parameterizedType", ")", "{", "ClassNode", "base", "=", "configureType", "(", "parameterizedType", ".", "getRawType", "(", ")", ")", ";", "GenericsType", "[", "]", "gts", "=", "configureTypeArguments", "(", "parameterizedType", ".", "getActualTypeArguments", "(", ")", ")", ";", "base", ".", "setGenericsTypes", "(", "gts", ")", ";", "return", "base", ";", "}", "private", "ClassNode", "configureTypeVariableReference", "(", "TypeVariable", "tv", ")", "{", "ClassNode", "cn", "=", "ClassHelper", ".", "makeWithoutCaching", "(", "tv", ".", "getName", "(", ")", ")", ";", "cn", ".", "setGenericsPlaceHolder", "(", "true", ")", ";", "ClassNode", "cn2", "=", "ClassHelper", ".", "makeWithoutCaching", "(", "tv", ".", "getName", "(", ")", ")", ";", "cn2", ".", "setGenericsPlaceHolder", "(", "true", ")", ";", "GenericsType", "[", "]", "gts", "=", "new", "GenericsType", "[", "]", "{", "new", "GenericsType", "(", "cn2", ")", "}", ";", "cn", ".", "setGenericsTypes", "(", "gts", ")", ";", "cn", ".", "setRedirect", "(", "ClassHelper", ".", "OBJECT_TYPE", ")", ";", "return", "cn", ";", "}", "private", "GenericsType", "[", "]", "configureTypeArguments", "(", "Type", "[", "]", "ta", ")", "{", "if", "(", "ta", ".", "length", "==", "0", ")", "return", "null", ";", "GenericsType", "[", "]", "gts", "=", "new", "GenericsType", "[", "ta", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ta", ".", "length", ";", "i", "++", ")", "{", "ClassNode", "t", "=", "configureType", "(", "ta", "[", "i", "]", ")", ";", "if", "(", "ta", "[", "i", "]", "instanceof", "WildcardType", ")", "{", "GenericsType", "[", "]", "gen", "=", "t", ".", "getGenericsTypes", "(", ")", ";", "gts", "[", "i", "]", "=", "gen", "[", "0", "]", ";", "}", "else", "{", "gts", "[", "i", "]", "=", "new", "GenericsType", "(", "t", ")", ";", "}", "}", "return", "gts", ";", "}", "public", "Class", "[", "]", "getPluginDefaultGroovyMethods", "(", ")", "{", "return", "PLUGIN_DGM", ";", "}", "public", "Class", "[", "]", "getPluginStaticGroovyMethods", "(", ")", "{", "return", "EMPTY_CLASS_ARRAY", ";", "}", "private", "void", "setAnnotationMetaData", "(", "Annotation", "[", "]", "annotations", ",", "AnnotatedNode", "an", ")", "{", "for", "(", "Annotation", "annotation", ":", "annotations", ")", "{", "AnnotationNode", "node", "=", "new", "AnnotationNode", "(", "ClassHelper", ".", "make", "(", "annotation", ".", "annotationType", "(", ")", ")", ")", ";", "configureAnnotation", "(", "node", ",", "annotation", ")", ";", "an", ".", "addAnnotation", "(", "node", ")", ";", "}", "}", "private", "void", "configureAnnotationFromDefinition", "(", "AnnotationNode", "definition", ",", "AnnotationNode", "root", ")", "{", "ClassNode", "type", "=", "definition", ".", "getClassNode", "(", ")", ";", "if", "(", "!", "type", ".", "isResolved", "(", ")", ")", "return", ";", "if", "(", "type", ".", "hasClass", "(", ")", ")", "{", "Class", "clazz", "=", "type", ".", "getTypeClass", "(", ")", ";", "if", "(", "clazz", "==", "Retention", ".", "class", ")", "{", "Expression", "exp", "=", "definition", ".", "getMember", "(", "\"value\"", ")", ";", "if", "(", "!", "(", "exp", "instanceof", "PropertyExpression", ")", ")", "return", ";", "PropertyExpression", "pe", "=", "(", "PropertyExpression", ")", "exp", ";", "String", "name", "=", "pe", ".", "getPropertyAsString", "(", ")", ";", "RetentionPolicy", "policy", "=", "RetentionPolicy", ".", "valueOf", "(", "name", ")", ";", "setRetentionPolicy", "(", "policy", ",", "root", ")", ";", "}", "else", "if", "(", "clazz", "==", "Target", ".", "class", ")", "{", "Expression", "exp", "=", "definition", ".", "getMember", "(", "\"value\"", ")", ";", "if", "(", "!", "(", "exp", "instanceof", "ListExpression", ")", ")", "return", ";", "ListExpression", "le", "=", "(", "ListExpression", ")", "exp", ";", "int", "bitmap", "=", "0", ";", "for", "(", "Expression", "e", ":", "le", ".", "getExpressions", "(", ")", ")", "{", "PropertyExpression", "element", "=", "(", "PropertyExpression", ")", "e", ";", "String", "name", "=", "element", ".", "getPropertyAsString", "(", ")", ";", "ElementType", "value", "=", "ElementType", ".", "valueOf", "(", "name", ")", ";", "bitmap", "|=", "getElementCode", "(", "value", ")", ";", "}", "root", ".", "setAllowedTargets", "(", "bitmap", ")", ";", "}", "}", "else", "{", "String", "typename", "=", "type", ".", "getName", "(", ")", ";", "if", "(", "typename", ".", "equals", "(", "\"\"", ")", ")", "{", "Expression", "exp", "=", "definition", ".", "getMember", "(", "\"value\"", ")", ";", "if", "(", "!", "(", "exp", "instanceof", "PropertyExpression", ")", ")", "return", ";", "PropertyExpression", "pe", "=", "(", "PropertyExpression", ")", "exp", ";", "String", "name", "=", "pe", ".", "getPropertyAsString", "(", ")", ";", "RetentionPolicy", "policy", "=", "RetentionPolicy", ".", "valueOf", "(", "name", ")", ";", "setRetentionPolicy", "(", "policy", ",", "root", ")", ";", "}", "else", "if", "(", "typename", ".", "equals", "(", "\"\"", ")", ")", "{", "Expression", "exp", "=", "definition", ".", "getMember", "(", "\"value\"", ")", ";", "if", "(", "!", "(", "exp", "instanceof", "ListExpression", ")", ")", "return", ";", "ListExpression", "le", "=", "(", "ListExpression", ")", "exp", ";", "int", "bitmap", "=", "0", ";", "for", "(", "Expression", "expression", ":", "le", ".", "getExpressions", "(", ")", ")", "{", "PropertyExpression", "element", "=", "(", "PropertyExpression", ")", "expression", ";", "String", "name", "=", "element", ".", "getPropertyAsString", "(", ")", ";", "ElementType", "value", "=", "ElementType", ".", "valueOf", "(", "name", ")", ";", "bitmap", "|=", "getElementCode", "(", "value", ")", ";", "}", "root", ".", "setAllowedTargets", "(", "bitmap", ")", ";", "}", "}", "}", "public", "void", "configureAnnotation", "(", "AnnotationNode", "node", ")", "{", "ClassNode", "type", "=", "node", ".", "getClassNode", "(", ")", ";", "List", "<", "AnnotationNode", ">", "annotations", "=", "type", ".", "getAnnotations", "(", ")", ";", "for", "(", "AnnotationNode", "an", ":", "annotations", ")", "{", "configureAnnotationFromDefinition", "(", "an", ",", "node", ")", ";", "}", "configureAnnotationFromDefinition", "(", "node", ",", "node", ")", ";", "}", "private", "void", "configureAnnotation", "(", "AnnotationNode", "node", ",", "Annotation", "annotation", ")", "{", "Class", "type", "=", "annotation", ".", "annotationType", "(", ")", ";", "if", "(", "type", "==", "Retention", ".", "class", ")", "{", "Retention", "r", "=", "(", "Retention", ")", "annotation", ";", "RetentionPolicy", "value", "=", "r", ".", "value", "(", ")", ";", "setRetentionPolicy", "(", "value", ",", "node", ")", ";", "node", ".", "setMember", "(", "\"value\"", ",", "new", "PropertyExpression", "(", "new", "ClassExpression", "(", "ClassHelper", ".", "makeWithoutCaching", "(", "RetentionPolicy", ".", "class", ",", "false", ")", ")", ",", "value", ".", "toString", "(", ")", ")", ")", ";", "}", "else", "if", "(", "type", "==", "Target", ".", "class", ")", "{", "Target", "t", "=", "(", "Target", ")", "annotation", ";", "ElementType", "[", "]", "elements", "=", "t", ".", "value", "(", ")", ";", "ListExpression", "elementExprs", "=", "new", "ListExpression", "(", ")", ";", "for", "(", "ElementType", "element", ":", "elements", ")", "{", "elementExprs", ".", "addExpression", "(", "new", "PropertyExpression", "(", "new", "ClassExpression", "(", "ClassHelper", ".", "ELEMENT_TYPE_TYPE", ")", ",", "element", ".", "name", "(", ")", ")", ")", ";", "}", "node", ".", "setMember", "(", "\"value\"", ",", "elementExprs", ")", ";", "}", "else", "{", "Method", "[", "]", "declaredMethods", "=", "type", ".", "getDeclaredMethods", "(", ")", ";", "for", "(", "Method", "declaredMethod", ":", "declaredMethods", ")", "{", "try", "{", "Object", "value", "=", "declaredMethod", ".", "invoke", "(", "annotation", ")", ";", "Expression", "valueExpression", "=", "annotationValueToExpression", "(", "value", ")", ";", "if", "(", "valueExpression", "==", "null", ")", "continue", ";", "node", ".", "setMember", "(", "declaredMethod", ".", "getName", "(", ")", ",", "valueExpression", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "}", "}", "}", "}", "private", "Expression", "annotationValueToExpression", "(", "Object", "value", ")", "{", "if", "(", "value", "==", "null", "||", "value", "instanceof", "String", "||", "value", "instanceof", "Number", "||", "value", "instanceof", "Character", "||", "value", "instanceof", "Boolean", ")", "return", "new", "ConstantExpression", "(", "value", ")", ";", "if", "(", "value", "instanceof", "Class", ")", "return", "new", "ClassExpression", "(", "ClassHelper", ".", "makeWithoutCaching", "(", "(", "Class", ")", "value", ")", ")", ";", "if", "(", "value", ".", "getClass", "(", ")", ".", "isArray", "(", ")", ")", "{", "ListExpression", "elementExprs", "=", "new", "ListExpression", "(", ")", ";", "int", "len", "=", "Array", ".", "getLength", "(", "value", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "!=", "len", ";", "++", "i", ")", "elementExprs", ".", "addExpression", "(", "annotationValueToExpression", "(", "Array", ".", "get", "(", "value", ",", "i", ")", ")", ")", ";", "return", "elementExprs", ";", "}", "return", "null", ";", "}", "private", "void", "setRetentionPolicy", "(", "RetentionPolicy", "value", ",", "AnnotationNode", "node", ")", "{", "switch", "(", "value", ")", "{", "case", "RUNTIME", ":", "node", ".", "setRuntimeRetention", "(", "true", ")", ";", "break", ";", "case", "SOURCE", ":", "node", ".", "setSourceRetention", "(", "true", ")", ";", "break", ";", "case", "CLASS", ":", "node", ".", "setClassRetention", "(", "true", ")", ";", "break", ";", "default", ":", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "value", ")", ";", "}", "}", "private", "int", "getElementCode", "(", "ElementType", "value", ")", "{", "switch", "(", "value", ")", "{", "case", "TYPE", ":", "return", "AnnotationNode", ".", "TYPE_TARGET", ";", "case", "CONSTRUCTOR", ":", "return", "AnnotationNode", ".", "CONSTRUCTOR_TARGET", ";", "case", "METHOD", ":", "return", "AnnotationNode", ".", "METHOD_TARGET", ";", "case", "FIELD", ":", "return", "AnnotationNode", ".", "FIELD_TARGET", ";", "case", "PARAMETER", ":", "return", "AnnotationNode", ".", "PARAMETER_TARGET", ";", "case", "LOCAL_VARIABLE", ":", "return", "AnnotationNode", ".", "LOCAL_VARIABLE_TARGET", ";", "case", "ANNOTATION_TYPE", ":", "return", "AnnotationNode", ".", "ANNOTATION_TARGET", ";", "case", "PACKAGE", ":", "return", "AnnotationNode", ".", "PACKAGE_TARGET", ";", "default", ":", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "value", ")", ";", "}", "}", "private", "void", "setMethodDefaultValue", "(", "MethodNode", "mn", ",", "Method", "m", ")", "{", "Object", "defaultValue", "=", "m", ".", "getDefaultValue", "(", ")", ";", "ConstantExpression", "cExp", "=", "ConstantExpression", ".", "NULL", ";", "if", "(", "defaultValue", "!=", "null", ")", "cExp", "=", "new", "ConstantExpression", "(", "defaultValue", ")", ";", "mn", ".", "setCode", "(", "new", "ReturnStatement", "(", "cExp", ")", ")", ";", "mn", ".", "setAnnotationDefault", "(", "true", ")", ";", "}", "public", "void", "configureClassNode", "(", "CompileUnit", "compileUnit", ",", "ClassNode", "classNode", ")", "{", "Class", "clazz", "=", "classNode", ".", "getTypeClass", "(", ")", ";", "Field", "[", "]", "fields", "=", "clazz", ".", "getDeclaredFields", "(", ")", ";", "for", "(", "Field", "f", ":", "fields", ")", "{", "ClassNode", "ret", "=", "makeClassNode", "(", "compileUnit", ",", "f", ".", "getGenericType", "(", ")", ",", "f", ".", "getType", "(", ")", ")", ";", "FieldNode", "fn", "=", "new", "FieldNode", "(", "f", ".", "getName", "(", ")", ",", "f", ".", "getModifiers", "(", ")", ",", "ret", ",", "classNode", ",", "null", ")", ";", "setAnnotationMetaData", "(", "f", ".", "getAnnotations", "(", ")", ",", "fn", ")", ";", "classNode", ".", "addField", "(", "fn", ")", ";", "}", "Method", "[", "]", "methods", "=", "clazz", ".", "getDeclaredMethods", "(", ")", ";", "for", "(", "Method", "m", ":", "methods", ")", "{", "ClassNode", "ret", "=", "makeClassNode", "(", "compileUnit", ",", "m", ".", "getGenericReturnType", "(", ")", ",", "m", ".", "getReturnType", "(", ")", ")", ";", "Parameter", "[", "]", "params", "=", "makeParameters", "(", "compileUnit", ",", "m", ".", "getGenericParameterTypes", "(", ")", ",", "m", ".", "getParameterTypes", "(", ")", ",", "m", ".", "getParameterAnnotations", "(", ")", ")", ";", "ClassNode", "[", "]", "exceptions", "=", "makeClassNodes", "(", "compileUnit", ",", "m", ".", "getGenericExceptionTypes", "(", ")", ",", "m", ".", "getExceptionTypes", "(", ")", ")", ";", "MethodNode", "mn", "=", "new", "MethodNode", "(", "m", ".", "getName", "(", ")", ",", "m", ".", "getModifiers", "(", ")", ",", "ret", ",", "params", ",", "exceptions", ",", "null", ")", ";", "setMethodDefaultValue", "(", "mn", ",", "m", ")", ";", "setAnnotationMetaData", "(", "m", ".", "getAnnotations", "(", ")", ",", "mn", ")", ";", "mn", ".", "setGenericsTypes", "(", "configureTypeVariable", "(", "m", ".", "getTypeParameters", "(", ")", ")", ")", ";", "classNode", ".", "addMethod", "(", "mn", ")", ";", "}", "Constructor", "[", "]", "constructors", "=", "clazz", ".", "getDeclaredConstructors", "(", ")", ";", "for", "(", "Constructor", "ctor", ":", "constructors", ")", "{", "Parameter", "[", "]", "params", "=", "makeParameters", "(", "compileUnit", ",", "ctor", ".", "getGenericParameterTypes", "(", ")", ",", "ctor", ".", "getParameterTypes", "(", ")", ",", "ctor", ".", "getParameterAnnotations", "(", ")", ")", ";", "ClassNode", "[", "]", "exceptions", "=", "makeClassNodes", "(", "compileUnit", ",", "ctor", ".", "getGenericExceptionTypes", "(", ")", ",", "ctor", ".", "getExceptionTypes", "(", ")", ")", ";", "classNode", ".", "addConstructor", "(", "ctor", ".", "getModifiers", "(", ")", ",", "params", ",", "exceptions", ",", "null", ")", ";", "}", "Class", "sc", "=", "clazz", ".", "getSuperclass", "(", ")", ";", "if", "(", "sc", "!=", "null", ")", "classNode", ".", "setUnresolvedSuperClass", "(", "makeClassNode", "(", "compileUnit", ",", "clazz", ".", "getGenericSuperclass", "(", ")", ",", "sc", ")", ")", ";", "makeInterfaceTypes", "(", "compileUnit", ",", "classNode", ",", "clazz", ")", ";", "setAnnotationMetaData", "(", "classNode", ".", "getTypeClass", "(", ")", ".", "getAnnotations", "(", ")", ",", "classNode", ")", ";", "PackageNode", "packageNode", "=", "classNode", ".", "getPackage", "(", ")", ";", "if", "(", "packageNode", "!=", "null", ")", "{", "setAnnotationMetaData", "(", "classNode", ".", "getTypeClass", "(", ")", ".", "getPackage", "(", ")", ".", "getAnnotations", "(", ")", ",", "packageNode", ")", ";", "}", "}", "private", "void", "makeInterfaceTypes", "(", "CompileUnit", "cu", ",", "ClassNode", "classNode", ",", "Class", "clazz", ")", "{", "Type", "[", "]", "interfaceTypes", "=", "clazz", ".", "getGenericInterfaces", "(", ")", ";", "if", "(", "interfaceTypes", ".", "length", "==", "0", ")", "{", "classNode", ".", "setInterfaces", "(", "ClassNode", ".", "EMPTY_ARRAY", ")", ";", "}", "else", "{", "Class", "[", "]", "interfaceClasses", "=", "clazz", ".", "getInterfaces", "(", ")", ";", "ClassNode", "[", "]", "ret", "=", "new", "ClassNode", "[", "interfaceTypes", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "interfaceTypes", ".", "length", ";", "i", "++", ")", "{", "ret", "[", "i", "]", "=", "makeClassNode", "(", "cu", ",", "interfaceTypes", "[", "i", "]", ",", "interfaceClasses", "[", "i", "]", ")", ";", "}", "classNode", ".", "setInterfaces", "(", "ret", ")", ";", "}", "}", "private", "ClassNode", "[", "]", "makeClassNodes", "(", "CompileUnit", "cu", ",", "Type", "[", "]", "types", ",", "Class", "[", "]", "cls", ")", "{", "ClassNode", "[", "]", "nodes", "=", "new", "ClassNode", "[", "types", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "i", "++", ")", "{", "nodes", "[", "i", "]", "=", "makeClassNode", "(", "cu", ",", "types", "[", "i", "]", ",", "cls", "[", "i", "]", ")", ";", "}", "return", "nodes", ";", "}", "private", "ClassNode", "makeClassNode", "(", "CompileUnit", "cu", ",", "Type", "t", ",", "Class", "c", ")", "{", "ClassNode", "back", "=", "null", ";", "if", "(", "cu", "!=", "null", ")", "back", "=", "cu", ".", "getClass", "(", "c", ".", "getName", "(", ")", ")", ";", "if", "(", "back", "==", "null", ")", "back", "=", "ClassHelper", ".", "make", "(", "c", ")", ";", "if", "(", "!", "(", "t", "instanceof", "Class", ")", ")", "{", "ClassNode", "front", "=", "configureType", "(", "t", ")", ";", "front", ".", "setRedirect", "(", "back", ")", ";", "return", "front", ";", "}", "return", "back", ";", "}", "private", "Parameter", "[", "]", "makeParameters", "(", "CompileUnit", "cu", ",", "Type", "[", "]", "types", ",", "Class", "[", "]", "cls", ",", "Annotation", "[", "]", "[", "]", "parameterAnnotations", ")", "{", "Parameter", "[", "]", "params", "=", "Parameter", ".", "EMPTY_ARRAY", ";", "if", "(", "types", ".", "length", ">", "0", ")", "{", "params", "=", "new", "Parameter", "[", "types", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "params", ".", "length", ";", "i", "++", ")", "{", "params", "[", "i", "]", "=", "makeParameter", "(", "cu", ",", "types", "[", "i", "]", ",", "cls", "[", "i", "]", ",", "parameterAnnotations", "[", "i", "]", ",", "i", ")", ";", "}", "}", "return", "params", ";", "}", "private", "Parameter", "makeParameter", "(", "CompileUnit", "cu", ",", "Type", "type", ",", "Class", "cl", ",", "Annotation", "[", "]", "annotations", ",", "int", "idx", ")", "{", "ClassNode", "cn", "=", "makeClassNode", "(", "cu", ",", "type", ",", "cl", ")", ";", "Parameter", "parameter", "=", "new", "Parameter", "(", "cn", ",", "\"param\"", "+", "idx", ")", ";", "setAnnotationMetaData", "(", "annotations", ",", "parameter", ")", ";", "return", "parameter", ";", "}", "public", "void", "invalidateCallSites", "(", ")", "{", "}", "}", "</s>" ]
6,929
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "activator", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "FileLocator", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "IStatus", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Plugin", ";", "import", "org", ".", "eclipse", ".", "core", ".", "runtime", ".", "Status", ";", "import", "org", ".", "osgi", ".", "framework", ".", "BundleContext", ";", "public", "class", "GroovyActivator", "extends", "Plugin", "{", "public", "static", "final", "String", "PLUGIN_ID", "=", "\"\"", ";", "public", "static", "final", "String", "GROOVY_ALL_JAR", "=", "\"\"", ";", "public", "static", "final", "String", "GROOVY_JAR", "=", "\"\"", ";", "public", "static", "final", "String", "ASM_JAR", "=", "\"\"", ";", "public", "static", "URL", "GROOVY_JAR_URL", ";", "public", "static", "URL", "GROOVY_GPP_URL", ";", "public", "static", "URL", "GROOVY_ALL_JAR_URL", ";", "public", "static", "URL", "ASM_JAR_URL", ";", "private", "static", "GroovyActivator", "DEFAULT", ";", "public", "GroovyActivator", "(", ")", "{", "DEFAULT", "=", "this", ";", "}", "public", "static", "GroovyActivator", "getDefault", "(", ")", "{", "return", "DEFAULT", ";", "}", "@", "Override", "public", "void", "start", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "super", ".", "start", "(", "context", ")", ";", "try", "{", "GROOVY_JAR_URL", "=", "FileLocator", ".", "resolve", "(", "context", ".", "getBundle", "(", ")", ".", "getEntry", "(", "GroovyActivator", ".", "GROOVY_JAR", ")", ")", ";", "GROOVY_ALL_JAR_URL", "=", "FileLocator", ".", "resolve", "(", "context", ".", "getBundle", "(", ")", ".", "getEntry", "(", "GroovyActivator", ".", "GROOVY_ALL_JAR", ")", ")", ";", "ASM_JAR_URL", "=", "FileLocator", ".", "resolve", "(", "context", ".", "getBundle", "(", ")", ".", "getEntry", "(", "GroovyActivator", ".", "ASM_JAR", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "getLog", "(", ")", ".", "log", "(", "new", "Status", "(", "IStatus", ".", "ERROR", ",", "PLUGIN_ID", ",", "\"\"", ",", "e", ")", ")", ";", "}", "}", "@", "Override", "public", "void", "stop", "(", "BundleContext", "context", ")", "throws", "Exception", "{", "super", ".", "stop", "(", "context", ")", ";", "}", "}", "</s>" ]
6,930
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "tools", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ClassNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "SourceUnit", ";", "public", "class", "GroovyClass", "{", "public", "static", "final", "GroovyClass", "[", "]", "EMPTY_ARRAY", "=", "new", "GroovyClass", "[", "0", "]", ";", "private", "String", "name", ";", "private", "byte", "[", "]", "bytes", ";", "private", "ClassNode", "classNode", ";", "private", "SourceUnit", "source", ";", "public", "GroovyClass", "(", "String", "name", ",", "byte", "[", "]", "bytes", ",", "ClassNode", "classNode", ",", "SourceUnit", "source", ")", "{", "this", ".", "name", "=", "name", ";", "this", ".", "bytes", "=", "bytes", ";", "this", ".", "classNode", "=", "classNode", ";", "this", ".", "source", "=", "source", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "this", ".", "name", ";", "}", "public", "byte", "[", "]", "getBytes", "(", ")", "{", "return", "this", ".", "bytes", ";", "}", "public", "SourceUnit", "getSourceUnit", "(", ")", "{", "return", "source", ";", "}", "public", "ClassNode", "getClassNode", "(", ")", "{", "return", "classNode", ";", "}", "}", "</s>" ]
6,931
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "bsf", ";", "import", "groovy", ".", "lang", ".", "Closure", ";", "import", "groovy", ".", "lang", ".", "GroovyShell", ";", "import", "org", ".", "apache", ".", "bsf", ".", "BSFDeclaredBean", ";", "import", "org", ".", "apache", ".", "bsf", ".", "BSFException", ";", "import", "org", ".", "apache", ".", "bsf", ".", "BSFManager", ";", "import", "org", ".", "apache", ".", "bsf", ".", "util", ".", "BSFEngineImpl", ";", "import", "org", ".", "apache", ".", "bsf", ".", "util", ".", "BSFFunctions", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "runtime", ".", "InvokerHelper", ";", "import", "java", ".", "util", ".", "Vector", ";", "public", "class", "GroovyEngine", "extends", "BSFEngineImpl", "{", "protected", "GroovyShell", "shell", ";", "private", "String", "convertToValidJavaClassname", "(", "String", "inName", ")", "{", "if", "(", "inName", "==", "null", "||", "inName", ".", "equals", "(", "\"\"", ")", ")", "{", "return", "\"_\"", ";", "}", "if", "(", "inName", ".", "startsWith", "(", "\"scriptdef_\"", ")", ")", "{", "inName", "=", "inName", ".", "substring", "(", "\"scriptdef_\"", ".", "length", "(", ")", ")", ";", "}", "StringBuffer", "output", "=", "new", "StringBuffer", "(", "inName", ".", "length", "(", ")", ")", ";", "boolean", "firstChar", "=", "true", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "inName", ".", "length", "(", ")", ";", "++", "i", ")", "{", "char", "ch", "=", "inName", ".", "charAt", "(", "i", ")", ";", "if", "(", "firstChar", "&&", "!", "Character", ".", "isJavaIdentifierStart", "(", "ch", ")", ")", "{", "ch", "=", "'_'", ";", "}", "else", "if", "(", "!", "firstChar", "&&", "!", "(", "Character", ".", "isJavaIdentifierPart", "(", "ch", ")", "||", "ch", "==", "'.'", ")", ")", "{", "ch", "=", "'_'", ";", "}", "firstChar", "=", "(", "ch", "==", "'.'", ")", ";", "output", ".", "append", "(", "ch", ")", ";", "}", "return", "output", ".", "toString", "(", ")", ";", "}", "public", "Object", "apply", "(", "String", "source", ",", "int", "lineNo", ",", "int", "columnNo", ",", "Object", "funcBody", ",", "Vector", "paramNames", ",", "Vector", "arguments", ")", "throws", "BSFException", "{", "Object", "object", "=", "eval", "(", "source", ",", "lineNo", ",", "columnNo", ",", "funcBody", ")", ";", "if", "(", "object", "instanceof", "Closure", ")", "{", "Closure", "closure", "=", "(", "Closure", ")", "object", ";", "return", "closure", ".", "call", "(", "arguments", ".", "toArray", "(", ")", ")", ";", "}", "return", "object", ";", "}", "public", "Object", "call", "(", "Object", "object", ",", "String", "method", ",", "Object", "[", "]", "args", ")", "throws", "BSFException", "{", "return", "InvokerHelper", ".", "invokeMethod", "(", "object", ",", "method", ",", "args", ")", ";", "}", "public", "Object", "eval", "(", "String", "source", ",", "int", "lineNo", ",", "int", "columnNo", ",", "Object", "script", ")", "throws", "BSFException", "{", "try", "{", "source", "=", "convertToValidJavaClassname", "(", "source", ")", ";", "return", "getEvalShell", "(", ")", ".", "evaluate", "(", "script", ".", "toString", "(", ")", ",", "source", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "BSFException", "(", "BSFException", ".", "REASON_EXECUTION_ERROR", ",", "\"\"", "+", "e", ",", "e", ")", ";", "}", "}", "public", "void", "exec", "(", "String", "source", ",", "int", "lineNo", ",", "int", "columnNo", ",", "Object", "script", ")", "throws", "BSFException", "{", "try", "{", "source", "=", "convertToValidJavaClassname", "(", "source", ")", ";", "getEvalShell", "(", ")", ".", "evaluate", "(", "script", ".", "toString", "(", ")", ",", "source", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "BSFException", "(", "BSFException", ".", "REASON_EXECUTION_ERROR", ",", "\"\"", "+", "e", ",", "e", ")", ";", "}", "}", "public", "void", "initialize", "(", "BSFManager", "mgr", ",", "String", "lang", ",", "Vector", "declaredBeans", ")", "throws", "BSFException", "{", "super", ".", "initialize", "(", "mgr", ",", "lang", ",", "declaredBeans", ")", ";", "shell", "=", "new", "GroovyShell", "(", "mgr", ".", "getClassLoader", "(", ")", ")", ";", "shell", ".", "setVariable", "(", "\"bsf\"", ",", "new", "BSFFunctions", "(", "mgr", ",", "this", ")", ")", ";", "int", "size", "=", "declaredBeans", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "declareBean", "(", "(", "BSFDeclaredBean", ")", "declaredBeans", ".", "elementAt", "(", "i", ")", ")", ";", "}", "}", "public", "void", "declareBean", "(", "BSFDeclaredBean", "bean", ")", "throws", "BSFException", "{", "shell", ".", "setVariable", "(", "bean", ".", "name", ",", "bean", ".", "bean", ")", ";", "}", "public", "void", "undeclareBean", "(", "BSFDeclaredBean", "bean", ")", "throws", "BSFException", "{", "shell", ".", "setVariable", "(", "bean", ".", "name", ",", "null", ")", ";", "}", "protected", "GroovyShell", "getEvalShell", "(", ")", "{", "return", "new", "GroovyShell", "(", "shell", ")", ";", "}", "}", "</s>" ]
6,932
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "control", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "antlr", ".", "AntlrParserPluginFactory", ";", "public", "abstract", "class", "ParserPluginFactory", "{", "public", "static", "ParserPluginFactory", "newInstance", "(", "boolean", "useNewParser", ")", "{", "if", "(", "useNewParser", ")", "{", "Class", "type", "=", "null", ";", "String", "name", "=", "\"\"", ";", "try", "{", "type", "=", "Class", ".", "forName", "(", "name", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "try", "{", "type", "=", "ParserPluginFactory", ".", "class", ".", "getClassLoader", "(", ")", ".", "loadClass", "(", "name", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e1", ")", "{", "ClassLoader", "contextClassLoader", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "if", "(", "contextClassLoader", "!=", "null", ")", "{", "try", "{", "type", "=", "contextClassLoader", ".", "loadClass", "(", "name", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e2", ")", "{", "}", "}", "}", "}", "if", "(", "type", "!=", "null", ")", "{", "try", "{", "return", "(", "ParserPluginFactory", ")", "type", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", "+", "e", ",", "e", ")", ";", "}", "}", "}", "return", "new", "AntlrParserPluginFactory", "(", ")", ";", "}", "public", "abstract", "ParserPlugin", "createParserPlugin", "(", ")", ";", "}", "</s>" ]
6,933
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "control", ";", "import", "groovy", ".", "lang", ".", "GroovyClassLoader", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "BlockStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "CatchStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "ForStatement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "Statement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "ClassNodeResolver", ".", "LookupResult", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "classgen", ".", "Verifier", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "ExceptionMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "Types", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "GroovyBugError", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Modifier", ";", "import", "java", ".", "net", ".", "MalformedURLException", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "net", ".", "URLConnection", ";", "import", "java", ".", "util", ".", "*", ";", "public", "class", "ResolveVisitor", "extends", "ClassCodeExpressionTransformer", "{", "public", "ClassNode", "currentClass", ";", "public", "static", "final", "String", "[", "]", "DEFAULT_IMPORTS", "=", "{", "\"java.lang.\"", ",", "\"java.io.\"", ",", "\"java.net.\"", ",", "\"java.util.\"", ",", "\"groovy.lang.\"", ",", "\"groovy.util.\"", "}", ";", "public", "CompilationUnit", "compilationUnit", ";", "private", "Map", "cachedClasses", "=", "new", "HashMap", "(", ")", ";", "private", "static", "final", "Object", "NO_CLASS", "=", "new", "Object", "(", ")", ";", "private", "SourceUnit", "source", ";", "private", "VariableScope", "currentScope", ";", "private", "boolean", "isTopLevelProperty", "=", "true", ";", "private", "boolean", "inPropertyExpression", "=", "false", ";", "private", "boolean", "inClosure", "=", "false", ";", "private", "Map", "<", "String", ",", "GenericsType", ">", "genericParameterNames", "=", "new", "HashMap", "<", "String", ",", "GenericsType", ">", "(", ")", ";", "private", "Set", "<", "FieldNode", ">", "fieldTypesChecked", "=", "new", "HashSet", "<", "FieldNode", ">", "(", ")", ";", "private", "boolean", "checkingVariableTypeInDeclaration", "=", "false", ";", "private", "ImportNode", "currImportNode", "=", "null", ";", "private", "MethodNode", "currentMethod", ";", "private", "ClassNodeResolver", "classNodeResolver", ";", "public", "static", "class", "ConstructedClassWithPackage", "extends", "ClassNode", "{", "String", "prefix", ";", "String", "className", ";", "public", "ConstructedClassWithPackage", "(", "String", "pkg", ",", "String", "name", ")", "{", "super", "(", "pkg", "+", "name", ",", "Opcodes", ".", "ACC_PUBLIC", ",", "ClassHelper", ".", "OBJECT_TYPE", ")", ";", "isPrimaryNode", "=", "false", ";", "this", ".", "prefix", "=", "pkg", ";", "this", ".", "className", "=", "name", ";", "}", "public", "String", "getName", "(", ")", "{", "if", "(", "redirect", "(", ")", "!=", "this", ")", "return", "super", ".", "getName", "(", ")", ";", "return", "prefix", "+", "className", ";", "}", "public", "boolean", "hasPackageName", "(", ")", "{", "if", "(", "redirect", "(", ")", "!=", "this", ")", "return", "super", ".", "hasPackageName", "(", ")", ";", "return", "className", ".", "indexOf", "(", "'.'", ")", "!=", "-", "1", ";", "}", "public", "String", "setName", "(", "String", "name", ")", "{", "if", "(", "redirect", "(", ")", "!=", "this", ")", "{", "return", "super", ".", "setName", "(", "name", ")", ";", "}", "else", "{", "throw", "new", "GroovyBugError", "(", "\"\"", ")", ";", "}", "}", "}", "public", "static", "class", "LowerCaseClass", "extends", "ClassNode", "{", "String", "className", ";", "public", "LowerCaseClass", "(", "String", "name", ")", "{", "super", "(", "name", ",", "Opcodes", ".", "ACC_PUBLIC", ",", "ClassHelper", ".", "OBJECT_TYPE", ")", ";", "isPrimaryNode", "=", "false", ";", "this", ".", "className", "=", "name", ";", "}", "public", "String", "getName", "(", ")", "{", "if", "(", "redirect", "(", ")", "!=", "this", ")", "return", "super", ".", "getName", "(", ")", ";", "return", "className", ";", "}", "public", "boolean", "hasPackageName", "(", ")", "{", "if", "(", "redirect", "(", ")", "!=", "this", ")", "return", "super", ".", "hasPackageName", "(", ")", ";", "return", "false", ";", "}", "public", "String", "setName", "(", "String", "name", ")", "{", "if", "(", "redirect", "(", ")", "!=", "this", ")", "{", "return", "super", ".", "setName", "(", "name", ")", ";", "}", "else", "{", "throw", "new", "GroovyBugError", "(", "\"\"", ")", ";", "}", "}", "}", "public", "ResolveVisitor", "(", "CompilationUnit", "cu", ")", "{", "compilationUnit", "=", "cu", ";", "this", ".", "classNodeResolver", "=", "new", "ClassNodeResolver", "(", ")", ";", "}", "public", "void", "startResolving", "(", "ClassNode", "node", ",", "SourceUnit", "source", ")", "{", "this", ".", "source", "=", "source", ";", "visitClass", "(", "node", ")", ";", "}", "protected", "void", "visitConstructorOrMethod", "(", "MethodNode", "node", ",", "boolean", "isConstructor", ")", "{", "VariableScope", "oldScope", "=", "currentScope", ";", "currentScope", "=", "node", ".", "getVariableScope", "(", ")", ";", "Map", "<", "String", ",", "GenericsType", ">", "oldPNames", "=", "genericParameterNames", ";", "genericParameterNames", "=", "new", "HashMap", "<", "String", ",", "GenericsType", ">", "(", "genericParameterNames", ")", ";", "resolveGenericsHeader", "(", "node", ".", "getGenericsTypes", "(", ")", ")", ";", "Parameter", "[", "]", "paras", "=", "node", ".", "getParameters", "(", ")", ";", "for", "(", "Parameter", "p", ":", "paras", ")", "{", "p", ".", "setInitialExpression", "(", "transform", "(", "p", ".", "getInitialExpression", "(", ")", ")", ")", ";", "resolveOrFail", "(", "p", ".", "getType", "(", ")", ",", "p", ".", "getType", "(", ")", ")", ";", "visitAnnotations", "(", "p", ")", ";", "}", "ClassNode", "[", "]", "exceptions", "=", "node", ".", "getExceptions", "(", ")", ";", "for", "(", "ClassNode", "t", ":", "exceptions", ")", "{", "resolveOrFail", "(", "t", ",", "node", ")", ";", "}", "resolveOrFail", "(", "node", ".", "getReturnType", "(", ")", ",", "node", ")", ";", "MethodNode", "oldCurrentMethod", "=", "currentMethod", ";", "currentMethod", "=", "node", ";", "super", ".", "visitConstructorOrMethod", "(", "node", ",", "isConstructor", ")", ";", "currentMethod", "=", "oldCurrentMethod", ";", "genericParameterNames", "=", "oldPNames", ";", "currentScope", "=", "oldScope", ";", "}", "public", "void", "visitField", "(", "FieldNode", "node", ")", "{", "ClassNode", "t", "=", "node", ".", "getType", "(", ")", ";", "if", "(", "!", "fieldTypesChecked", ".", "contains", "(", "node", ")", ")", "{", "resolveOrFail", "(", "t", ",", "node", ")", ";", "}", "super", ".", "visitField", "(", "node", ")", ";", "}", "public", "void", "visitProperty", "(", "PropertyNode", "node", ")", "{", "ClassNode", "t", "=", "node", ".", "getType", "(", ")", ";", "resolveOrFail", "(", "t", ",", "node", ")", ";", "super", ".", "visitProperty", "(", "node", ")", ";", "fieldTypesChecked", ".", "add", "(", "node", ".", "getField", "(", ")", ")", ";", "}", "protected", "boolean", "resolveToInner", "(", "ClassNode", "type", ")", "{", "if", "(", "type", "instanceof", "ConstructedClassWithPackage", ")", "return", "false", ";", "String", "name", "=", "type", ".", "getName", "(", ")", ";", "String", "saved", "=", "name", ";", "while", "(", "true", ")", "{", "int", "len", "=", "name", ".", "lastIndexOf", "(", "'.'", ")", ";", "if", "(", "len", "==", "-", "1", ")", "break", ";", "name", "=", "name", ".", "substring", "(", "0", ",", "len", ")", "+", "\"$\"", "+", "name", ".", "substring", "(", "len", "+", "1", ")", ";", "type", ".", "setName", "(", "name", ")", ";", "if", "(", "resolve", "(", "type", ")", ")", "return", "true", ";", "}", "if", "(", "resolveToInnerEnum", "(", "type", ")", ")", "return", "true", ";", "type", ".", "setName", "(", "saved", ")", ";", "return", "false", ";", "}", "protected", "boolean", "resolveToInnerEnum", "(", "ClassNode", "type", ")", "{", "String", "name", "=", "type", ".", "getName", "(", ")", ";", "if", "(", "currentClass", "!=", "type", "&&", "!", "name", ".", "contains", "(", "\".\"", ")", "&&", "type", ".", "getClass", "(", ")", ".", "equals", "(", "ClassNode", ".", "class", ")", ")", "{", "type", ".", "setName", "(", "currentClass", ".", "getName", "(", ")", "+", "\"$\"", "+", "name", ")", ";", "if", "(", "resolve", "(", "type", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}", "private", "void", "resolveOrFail", "(", "ClassNode", "type", ",", "String", "msg", ",", "ASTNode", "node", ")", "{", "if", "(", "resolve", "(", "type", ")", ")", "return", ";", "if", "(", "resolveToInner", "(", "type", ")", ")", "return", ";", "addError", "(", "\"\"", "+", "toNiceName", "(", "type", ")", "+", "\"", "\"", "+", "msg", ",", "node", ")", ";", "}", "private", "String", "toNiceName", "(", "ClassNode", "node", ")", "{", "if", "(", "node", ".", "isArray", "(", ")", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "toNiceName", "(", "node", ".", "getComponentType", "(", ")", ")", ")", ";", "sb", ".", "append", "(", "\"[]\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "return", "node", ".", "getName", "(", ")", ";", "}", "private", "void", "resolveOrFail", "(", "ClassNode", "type", ",", "ASTNode", "node", ",", "boolean", "prefereImports", ")", "{", "resolveGenericsTypes", "(", "type", ".", "getGenericsTypes", "(", ")", ")", ";", "if", "(", "prefereImports", "&&", "resolveAliasFromModule", "(", "type", ")", ")", "return", ";", "resolveOrFail", "(", "type", ",", "node", ")", ";", "}", "private", "void", "resolveOrFail", "(", "ClassNode", "type", ",", "ASTNode", "node", ")", "{", "resolveOrFail", "(", "type", ",", "\"\"", ",", "node", ")", ";", "}", "protected", "boolean", "resolve", "(", "ClassNode", "type", ")", "{", "return", "resolve", "(", "type", ",", "true", ",", "true", ",", "true", ")", ";", "}", "protected", "boolean", "resolve", "(", "ClassNode", "type", ",", "boolean", "testModuleImports", ",", "boolean", "testDefaultImports", ",", "boolean", "testStaticInnerClasses", ")", "{", "resolveGenericsTypes", "(", "type", ".", "getGenericsTypes", "(", ")", ")", ";", "if", "(", "type", ".", "isResolved", "(", ")", "||", "type", ".", "isPrimaryClassNode", "(", ")", ")", "return", "true", ";", "if", "(", "type", ".", "isArray", "(", ")", ")", "{", "ClassNode", "element", "=", "type", ".", "getComponentType", "(", ")", ";", "boolean", "resolved", "=", "resolve", "(", "element", ",", "testModuleImports", ",", "testDefaultImports", ",", "testStaticInnerClasses", ")", ";", "if", "(", "resolved", ")", "{", "ClassNode", "cn", "=", "element", ".", "makeArray", "(", ")", ";", "type", ".", "setRedirect", "(", "cn", ")", ";", "}", "return", "resolved", ";", "}", "if", "(", "currentClass", "==", "type", ")", "return", "true", ";", "if", "(", "genericParameterNames", ".", "get", "(", "type", ".", "getName", "(", ")", ")", "!=", "null", ")", "{", "GenericsType", "gt", "=", "genericParameterNames", ".", "get", "(", "type", ".", "getName", "(", ")", ")", ";", "type", ".", "setRedirect", "(", "gt", ".", "getType", "(", ")", ")", ";", "type", ".", "setGenericsTypes", "(", "new", "GenericsType", "[", "]", "{", "gt", "}", ")", ";", "type", ".", "setGenericsPlaceHolder", "(", "true", ")", ";", "return", "true", ";", "}", "if", "(", "currentClass", ".", "getNameWithoutPackage", "(", ")", ".", "equals", "(", "type", ".", "getName", "(", ")", ")", ")", "{", "type", ".", "setRedirect", "(", "currentClass", ")", ";", "return", "true", ";", "}", "return", "resolveNestedClass", "(", "type", ")", "||", "resolveFromModule", "(", "type", ",", "testModuleImports", ")", "||", "resolveFromCompileUnit", "(", "type", ")", "||", "resolveFromDefaultImports", "(", "type", ",", "testDefaultImports", ")", "||", "resolveFromStaticInnerClasses", "(", "type", ",", "testStaticInnerClasses", ")", "||", "resolveToOuter", "(", "type", ")", ";", "}", "private", "boolean", "resolveNestedClass", "(", "ClassNode", "type", ")", "{", "Map", "<", "String", ",", "ClassNode", ">", "hierClasses", "=", "new", "LinkedHashMap", "<", "String", ",", "ClassNode", ">", "(", ")", ";", "ClassNode", "val", ";", "String", "name", ";", "for", "(", "ClassNode", "classToCheck", "=", "currentClass", ";", "classToCheck", "!=", "ClassHelper", ".", "OBJECT_TYPE", ";", "classToCheck", "=", "classToCheck", ".", "getSuperClass", "(", ")", ")", "{", "if", "(", "classToCheck", "==", "null", "||", "hierClasses", ".", "containsKey", "(", "classToCheck", ".", "getName", "(", ")", ")", ")", "break", ";", "hierClasses", ".", "put", "(", "classToCheck", ".", "getName", "(", ")", ",", "classToCheck", ")", ";", "}", "for", "(", "ClassNode", "classToCheck", ":", "hierClasses", ".", "values", "(", ")", ")", "{", "if", "(", "classToCheck", ".", "mightHaveInners", "(", ")", ")", "{", "name", "=", "classToCheck", ".", "getName", "(", ")", "+", "\"$\"", "+", "type", ".", "getName", "(", ")", ";", "val", "=", "ClassHelper", ".", "make", "(", "name", ")", ";", "if", "(", "resolveFromCompileUnit", "(", "val", ")", ")", "{", "type", ".", "setRedirect", "(", "val", ")", ";", "return", "true", ";", "}", "}", "}", "if", "(", "!", "(", "currentClass", "instanceof", "InnerClassNode", ")", ")", "return", "false", ";", "LinkedList", "<", "ClassNode", ">", "outerClasses", "=", "new", "LinkedList", "<", "ClassNode", ">", "(", ")", ";", "ClassNode", "outer", "=", "currentClass", ".", "getOuterClass", "(", ")", ";", "while", "(", "outer", "!=", "null", ")", "{", "outerClasses", ".", "addFirst", "(", "outer", ")", ";", "outer", "=", "outer", ".", "getOuterClass", "(", ")", ";", "}", "for", "(", "ClassNode", "testNode", ":", "outerClasses", ")", "{", "name", "=", "testNode", ".", "getName", "(", ")", "+", "\"$\"", "+", "type", ".", "getName", "(", ")", ";", "val", "=", "ClassHelper", ".", "make", "(", "name", ")", ";", "if", "(", "resolveFromCompileUnit", "(", "val", ")", ")", "{", "type", ".", "setRedirect", "(", "val", ")", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}", "protected", "boolean", "resolveFromClassCache", "(", "ClassNode", "type", ")", "{", "String", "name", "=", "type", ".", "getName", "(", ")", ";", "Object", "val", "=", "cachedClasses", ".", "get", "(", "name", ")", ";", "if", "(", "val", "==", "null", "||", "val", "==", "NO_CLASS", ")", "{", "return", "false", ";", "}", "else", "{", "type", ".", "setRedirect", "(", "(", "ClassNode", ")", "val", ")", ";", "return", "true", ";", "}", "}", "private", "long", "getTimeStamp", "(", "Class", "cls", ")", "{", "return", "Verifier", ".", "getTimestamp", "(", "cls", ")", ";", "}", "private", "boolean", "isSourceNewer", "(", "URL", "source", ",", "Class", "cls", ")", "{", "try", "{", "long", "lastMod", ";", "if", "(", "source", ".", "getProtocol", "(", ")", ".", "equals", "(", "\"file\"", ")", ")", "{", "String", "path", "=", "source", ".", "getPath", "(", ")", ".", "replace", "(", "'/'", ",", "File", ".", "separatorChar", ")", ".", "replace", "(", "'|'", ",", "':'", ")", ";", "File", "file", "=", "new", "File", "(", "path", ")", ";", "lastMod", "=", "file", ".", "lastModified", "(", ")", ";", "}", "else", "{", "URLConnection", "conn", "=", "source", ".", "openConnection", "(", ")", ";", "lastMod", "=", "conn", ".", "getLastModified", "(", ")", ";", "conn", ".", "getInputStream", "(", ")", ".", "close", "(", ")", ";", "}", "return", "lastMod", ">", "getTimeStamp", "(", "cls", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "return", "false", ";", "}", "}", "protected", "boolean", "resolveToScript", "(", "ClassNode", "type", ")", "{", "String", "name", "=", "type", ".", "getName", "(", ")", ";", "if", "(", "name", ".", "startsWith", "(", "\"java.\"", ")", ")", "return", "type", ".", "isResolved", "(", ")", ";", "if", "(", "name", ".", "indexOf", "(", "'$'", ")", "!=", "-", "1", ")", "return", "type", ".", "isResolved", "(", ")", ";", "ModuleNode", "module", "=", "currentClass", ".", "getModule", "(", ")", ";", "if", "(", "module", ".", "hasPackageName", "(", ")", "&&", "name", ".", "indexOf", "(", "'.'", ")", "==", "-", "1", ")", "return", "type", ".", "isResolved", "(", ")", ";", "GroovyClassLoader", "gcl", "=", "compilationUnit", ".", "getClassLoader", "(", ")", ";", "URL", "url", "=", "null", ";", "return", "type", ".", "isResolved", "(", ")", ";", "}", "private", "String", "replaceLastPoint", "(", "String", "name", ")", "{", "int", "lastPoint", "=", "name", ".", "lastIndexOf", "(", "'.'", ")", ";", "name", "=", "new", "StringBuffer", "(", ")", ".", "append", "(", "name", ".", "substring", "(", "0", ",", "lastPoint", ")", ")", ".", "append", "(", "\"$\"", ")", ".", "append", "(", "name", ".", "substring", "(", "lastPoint", "+", "1", ")", ")", ".", "toString", "(", ")", ";", "return", "name", ";", "}", "protected", "boolean", "resolveFromStaticInnerClasses", "(", "ClassNode", "type", ",", "boolean", "testStaticInnerClasses", ")", "{", "if", "(", "type", "instanceof", "LowerCaseClass", ")", "return", "false", ";", "testStaticInnerClasses", "&=", "type", ".", "hasPackageName", "(", ")", ";", "if", "(", "testStaticInnerClasses", ")", "{", "if", "(", "type", "instanceof", "ConstructedClassWithPackage", ")", "{", "ConstructedClassWithPackage", "tmp", "=", "(", "ConstructedClassWithPackage", ")", "type", ";", "String", "savedName", "=", "tmp", ".", "className", ";", "tmp", ".", "className", "=", "replaceLastPoint", "(", "savedName", ")", ";", "if", "(", "resolve", "(", "tmp", ",", "false", ",", "true", ",", "true", ")", ")", "{", "type", ".", "setRedirect", "(", "tmp", ".", "redirect", "(", ")", ")", ";", "return", "true", ";", "}", "tmp", ".", "className", "=", "savedName", ";", "}", "else", "{", "return", "resolveStaticInner", "(", "type", ")", ";", "}", "}", "return", "false", ";", "}", "protected", "boolean", "resolveStaticInner", "(", "ClassNode", "type", ")", "{", "String", "name", "=", "type", ".", "getName", "(", ")", ";", "String", "replacedPointType", "=", "replaceLastPoint", "(", "name", ")", ";", "type", ".", "setName", "(", "replacedPointType", ")", ";", "if", "(", "resolve", "(", "type", ",", "false", ",", "true", ",", "true", ")", ")", "return", "true", ";", "type", ".", "setName", "(", "name", ")", ";", "return", "false", ";", "}", "protected", "boolean", "resolveFromDefaultImports", "(", "ClassNode", "type", ",", "boolean", "testDefaultImports", ")", "{", "testDefaultImports", "&=", "!", "type", ".", "hasPackageName", "(", ")", ";", "testDefaultImports", "&=", "!", "(", "type", "instanceof", "LowerCaseClass", ")", ";", "if", "(", "testDefaultImports", ")", "{", "for", "(", "int", "i", "=", "0", ",", "size", "=", "DEFAULT_IMPORTS", ".", "length", ";", "i", "<", "size", ";", "i", "++", ")", "{", "String", "packagePrefix", "=", "DEFAULT_IMPORTS", "[", "i", "]", ";", "String", "name", "=", "type", ".", "getName", "(", ")", ";", "ConstructedClassWithPackage", "tmp", "=", "new", "ConstructedClassWithPackage", "(", "packagePrefix", ",", "name", ")", ";", "if", "(", "resolve", "(", "tmp", ",", "false", ",", "false", ",", "false", ")", ")", "{", "type", ".", "setRedirect", "(", "tmp", ".", "redirect", "(", ")", ")", ";", "return", "true", ";", "}", "}", "String", "name", "=", "type", ".", "getName", "(", ")", ";", "if", "(", "name", ".", "equals", "(", "\"BigInteger\"", ")", ")", "{", "type", ".", "setRedirect", "(", "ClassHelper", ".", "BigInteger_TYPE", ")", ";", "return", "true", ";", "}", "else", "if", "(", "name", ".", "equals", "(", "\"BigDecimal\"", ")", ")", "{", "type", ".", "setRedirect", "(", "ClassHelper", ".", "BigDecimal_TYPE", ")", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}", "protected", "boolean", "resolveFromCompileUnit", "(", "ClassNode", "type", ")", "{", "CompileUnit", "compileUnit", "=", "currentClass", ".", "getCompileUnit", "(", ")", ";", "if", "(", "compileUnit", "==", "null", ")", "return", "false", ";", "ClassNode", "cuClass", "=", "compileUnit", ".", "getClass", "(", "type", ".", "getName", "(", ")", ")", ";", "if", "(", "cuClass", "!=", "null", ")", "{", "if", "(", "type", "!=", "cuClass", ")", "type", ".", "setRedirect", "(", "cuClass", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "private", "void", "ambiguousClass", "(", "ClassNode", "type", ",", "ClassNode", "iType", ",", "String", "name", ")", "{", "if", "(", "type", ".", "getName", "(", ")", ".", "equals", "(", "iType", ".", "getName", "(", ")", ")", ")", "{", "addError", "(", "\"\"", "+", "name", "+", "\"\"", "+", "type", ".", "getName", "(", ")", "+", "\"", "and", "\"", "+", "iType", ".", "getName", "(", ")", "+", "\"", "match\"", ",", "type", ")", ";", "}", "else", "{", "type", ".", "setRedirect", "(", "iType", ")", ";", "}", "}", "private", "boolean", "resolveAliasFromModule", "(", "ClassNode", "type", ")", "{", "if", "(", "type", "instanceof", "ConstructedClassWithPackage", ")", "return", "false", ";", "ModuleNode", "module", "=", "currentClass", ".", "getModule", "(", ")", ";", "if", "(", "module", "==", "null", ")", "return", "false", ";", "String", "name", "=", "type", ".", "getName", "(", ")", ";", "String", "pname", "=", "name", ";", "int", "index", "=", "name", ".", "length", "(", ")", ";", "while", "(", "true", ")", "{", "pname", "=", "name", ".", "substring", "(", "0", ",", "index", ")", ";", "ClassNode", "aliasedNode", "=", "null", ";", "ImportNode", "importNode", "=", "module", ".", "getImport", "(", "pname", ")", ";", "if", "(", "importNode", "!=", "null", "&&", "importNode", "!=", "currImportNode", ")", "{", "aliasedNode", "=", "importNode", ".", "getType", "(", ")", ";", "}", "if", "(", "aliasedNode", "==", "null", ")", "{", "importNode", "=", "module", ".", "getStaticImports", "(", ")", ".", "get", "(", "pname", ")", ";", "if", "(", "importNode", "!=", "null", "&&", "importNode", "!=", "currImportNode", ")", "{", "ClassNode", "tmp", "=", "ClassHelper", ".", "make", "(", "importNode", ".", "getType", "(", ")", ".", "getName", "(", ")", "+", "\"$\"", "+", "importNode", ".", "getFieldName", "(", ")", ")", ";", "if", "(", "resolve", "(", "tmp", ",", "false", ",", "false", ",", "true", ")", ")", "{", "if", "(", "(", "tmp", ".", "getModifiers", "(", ")", "&", "Opcodes", ".", "ACC_STATIC", ")", "!=", "0", ")", "{", "type", ".", "setRedirect", "(", "tmp", ".", "redirect", "(", ")", ")", ";", "return", "true", ";", "}", "}", "}", "}", "if", "(", "aliasedNode", "!=", "null", ")", "{", "if", "(", "pname", ".", "length", "(", ")", "==", "name", ".", "length", "(", ")", ")", "{", "type", ".", "setRedirect", "(", "aliasedNode", ")", ";", "return", "true", ";", "}", "else", "{", "String", "className", "=", "aliasedNode", ".", "getNameWithoutPackage", "(", ")", "+", "'$'", "+", "name", ".", "substring", "(", "pname", ".", "length", "(", ")", "+", "1", ")", ".", "replace", "(", "'.'", ",", "'$'", ")", ";", "ConstructedClassWithPackage", "tmp", "=", "new", "ConstructedClassWithPackage", "(", "aliasedNode", ".", "getPackageName", "(", ")", "+", "\".\"", ",", "className", ")", ";", "if", "(", "resolve", "(", "tmp", ",", "true", ",", "true", ",", "false", ")", ")", "{", "type", ".", "setRedirect", "(", "tmp", ".", "redirect", "(", ")", ")", ";", "return", "true", ";", "}", "}", "}", "index", "=", "pname", ".", "lastIndexOf", "(", "'.'", ")", ";", "if", "(", "index", "==", "-", "1", ")", "break", ";", "}", "return", "false", ";", "}", "protected", "boolean", "resolveFromModule", "(", "ClassNode", "type", ",", "boolean", "testModuleImports", ")", "{", "if", "(", "type", "instanceof", "LowerCaseClass", ")", "{", "return", "resolveAliasFromModule", "(", "type", ")", ";", "}", "String", "name", "=", "type", ".", "getName", "(", ")", ";", "ModuleNode", "module", "=", "currentClass", ".", "getModule", "(", ")", ";", "if", "(", "module", "==", "null", ")", "return", "false", ";", "boolean", "newNameUsed", "=", "false", ";", "if", "(", "!", "type", ".", "hasPackageName", "(", ")", "&&", "module", ".", "hasPackageName", "(", ")", "&&", "!", "(", "type", "instanceof", "ConstructedClassWithPackage", ")", ")", "{", "type", ".", "setName", "(", "module", ".", "getPackageName", "(", ")", "+", "name", ")", ";", "newNameUsed", "=", "true", ";", "}", "List", "<", "ClassNode", ">", "moduleClasses", "=", "module", ".", "getClasses", "(", ")", ";", "for", "(", "ClassNode", "mClass", ":", "moduleClasses", ")", "{", "if", "(", "mClass", ".", "getName", "(", ")", ".", "equals", "(", "type", ".", "getName", "(", ")", ")", ")", "{", "if", "(", "mClass", "!=", "type", ")", "type", ".", "setRedirect", "(", "mClass", ")", ";", "return", "true", ";", "}", "}", "if", "(", "newNameUsed", ")", "type", ".", "setName", "(", "name", ")", ";", "if", "(", "testModuleImports", ")", "{", "if", "(", "resolveAliasFromModule", "(", "type", ")", ")", "return", "true", ";", "if", "(", "module", ".", "hasPackageName", "(", ")", ")", "{", "ConstructedClassWithPackage", "tmp", "=", "new", "ConstructedClassWithPackage", "(", "module", ".", "getPackageName", "(", ")", ",", "name", ")", ";", "if", "(", "resolve", "(", "tmp", ",", "false", ",", "false", ",", "false", ")", ")", "{", "ambiguousClass", "(", "type", ",", "tmp", ",", "name", ")", ";", "type", ".", "setRedirect", "(", "tmp", ".", "redirect", "(", ")", ")", ";", "return", "true", ";", "}", "}", "for", "(", "ImportNode", "importNode", ":", "module", ".", "getStaticImports", "(", ")", ".", "values", "(", ")", ")", "{", "if", "(", "importNode", ".", "getFieldName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "ClassNode", "tmp", "=", "ClassHelper", ".", "make", "(", "importNode", ".", "getType", "(", ")", ".", "getName", "(", ")", "+", "\"$\"", "+", "name", ")", ";", "if", "(", "resolve", "(", "tmp", ",", "false", ",", "false", ",", "true", ")", ")", "{", "if", "(", "(", "tmp", ".", "getModifiers", "(", ")", "&", "Opcodes", ".", "ACC_STATIC", ")", "!=", "0", ")", "{", "type", ".", "setRedirect", "(", "tmp", ".", "redirect", "(", ")", ")", ";", "return", "true", ";", "}", "}", "}", "}", "for", "(", "ImportNode", "importNode", ":", "module", ".", "getStarImports", "(", ")", ")", "{", "String", "packagePrefix", "=", "importNode", ".", "getPackageName", "(", ")", ";", "ConstructedClassWithPackage", "tmp", "=", "new", "ConstructedClassWithPackage", "(", "packagePrefix", ",", "name", ")", ";", "if", "(", "resolve", "(", "tmp", ",", "false", ",", "false", ",", "true", ")", ")", "{", "ambiguousClass", "(", "type", ",", "tmp", ",", "name", ")", ";", "type", ".", "setRedirect", "(", "tmp", ".", "redirect", "(", ")", ")", ";", "return", "true", ";", "}", "}", "for", "(", "ImportNode", "importNode", ":", "module", ".", "getStaticStarImports", "(", ")", ".", "values", "(", ")", ")", "{", "if", "(", "!", "importNode", ".", "isUnresolvable", "(", ")", ")", "{", "ClassNode", "tmp", "=", "ClassHelper", ".", "make", "(", "importNode", ".", "getClassName", "(", ")", "+", "\"$\"", "+", "name", ")", ";", "if", "(", "resolve", "(", "tmp", ",", "false", ",", "false", ",", "true", ")", ")", "{", "if", "(", "(", "tmp", ".", "getModifiers", "(", ")", "&", "Opcodes", ".", "ACC_STATIC", ")", "!=", "0", ")", "{", "ambiguousClass", "(", "type", ",", "tmp", ",", "name", ")", ";", "type", ".", "setRedirect", "(", "tmp", ".", "redirect", "(", ")", ")", ";", "return", "true", ";", "}", "}", "}", "}", "}", "return", "false", ";", "}", "protected", "ClassNode", "resolveNewName", "(", "String", "fullname", ")", "{", "return", "null", ";", "}", "protected", "boolean", "resolveToOuter", "(", "ClassNode", "type", ")", "{", "String", "name", "=", "type", ".", "getName", "(", ")", ";", "if", "(", "type", "instanceof", "LowerCaseClass", ")", "{", "classNodeResolver", ".", "cacheClass", "(", "name", ",", "ClassNodeResolver", ".", "NO_CLASS", ")", ";", "return", "false", ";", "}", "if", "(", "currentClass", ".", "getModule", "(", ")", ".", "hasPackageName", "(", ")", "&&", "name", ".", "indexOf", "(", "'.'", ")", "==", "-", "1", ")", "return", "false", ";", "LookupResult", "lr", "=", "null", ";", "lr", "=", "classNodeResolver", ".", "resolveName", "(", "name", ",", "compilationUnit", ")", ";", "if", "(", "lr", "!=", "null", ")", "{", "if", "(", "lr", ".", "isSourceUnit", "(", ")", ")", "{", "SourceUnit", "su", "=", "lr", ".", "getSourceUnit", "(", ")", ";", "currentClass", ".", "getCompileUnit", "(", ")", ".", "addClassNodeToCompile", "(", "type", ",", "su", ")", ";", "}", "else", "{", "type", ".", "setRedirect", "(", "lr", ".", "getClassNode", "(", ")", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}", "public", "Expression", "transform", "(", "Expression", "exp", ")", "{", "if", "(", "exp", "==", "null", ")", "return", "null", ";", "Expression", "ret", "=", "null", ";", "if", "(", "exp", "instanceof", "VariableExpression", ")", "{", "ret", "=", "transformVariableExpression", "(", "(", "VariableExpression", ")", "exp", ")", ";", "}", "else", "if", "(", "exp", ".", "getClass", "(", ")", "==", "PropertyExpression", ".", "class", ")", "{", "ret", "=", "transformPropertyExpression", "(", "(", "PropertyExpression", ")", "exp", ")", ";", "}", "else", "if", "(", "exp", "instanceof", "DeclarationExpression", ")", "{", "ret", "=", "transformDeclarationExpression", "(", "(", "DeclarationExpression", ")", "exp", ")", ";", "}", "else", "if", "(", "exp", "instanceof", "BinaryExpression", "&&", "exp", ".", "getClass", "(", ")", "==", "BinaryExpression", ".", "class", ")", "{", "ret", "=", "transformBinaryExpression", "(", "(", "BinaryExpression", ")", "exp", ")", ";", "}", "else", "if", "(", "exp", "instanceof", "MethodCallExpression", ")", "{", "ret", "=", "transformMethodCallExpression", "(", "(", "MethodCallExpression", ")", "exp", ")", ";", "}", "else", "if", "(", "exp", "instanceof", "ClosureExpression", ")", "{", "ret", "=", "transformClosureExpression", "(", "(", "ClosureExpression", ")", "exp", ")", ";", "}", "else", "if", "(", "exp", "instanceof", "ConstructorCallExpression", ")", "{", "ret", "=", "transformConstructorCallExpression", "(", "(", "ConstructorCallExpression", ")", "exp", ")", ";", "}", "else", "if", "(", "exp", "instanceof", "AnnotationConstantExpression", ")", "{", "ret", "=", "transformAnnotationConstantExpression", "(", "(", "AnnotationConstantExpression", ")", "exp", ")", ";", "}", "else", "{", "resolveOrFail", "(", "exp", ".", "getType", "(", ")", ",", "exp", ")", ";", "ret", "=", "exp", ".", "transformExpression", "(", "this", ")", ";", "}", "if", "(", "ret", "!=", "null", "&&", "ret", "!=", "exp", ")", "ret", ".", "setSourcePosition", "(", "exp", ")", ";", "return", "ret", ";", "}", "private", "String", "lookupClassName", "(", "PropertyExpression", "pe", ")", "{", "boolean", "doInitialClassTest", "=", "true", ";", "String", "name", "=", "\"\"", ";", "for", "(", "Expression", "it", "=", "pe", ";", "it", "!=", "null", ";", "it", "=", "(", "(", "PropertyExpression", ")", "it", ")", ".", "getObjectExpression", "(", ")", ")", "{", "if", "(", "it", "instanceof", "VariableExpression", ")", "{", "VariableExpression", "ve", "=", "(", "VariableExpression", ")", "it", ";", "if", "(", "ve", ".", "isSuperExpression", "(", ")", "||", "ve", ".", "isThisExpression", "(", ")", ")", "{", "return", "null", ";", "}", "String", "varName", "=", "ve", ".", "getName", "(", ")", ";", "if", "(", "doInitialClassTest", ")", "{", "if", "(", "!", "testVanillaNameForClass", "(", "varName", ")", ")", "return", "null", ";", "doInitialClassTest", "=", "false", ";", "name", "=", "varName", ";", "}", "else", "{", "name", "=", "varName", "+", "\".\"", "+", "name", ";", "}", "break", ";", "}", "else", "if", "(", "it", ".", "getClass", "(", ")", "!=", "PropertyExpression", ".", "class", ")", "{", "return", "null", ";", "}", "else", "{", "PropertyExpression", "current", "=", "(", "PropertyExpression", ")", "it", ";", "String", "propertyPart", "=", "current", ".", "getPropertyAsString", "(", ")", ";", "if", "(", "propertyPart", "==", "null", "||", "propertyPart", ".", "equals", "(", "\"class\"", ")", ")", "{", "return", "null", ";", "}", "if", "(", "doInitialClassTest", ")", "{", "if", "(", "!", "testVanillaNameForClass", "(", "propertyPart", ")", ")", "return", "null", ";", "doInitialClassTest", "=", "false", ";", "name", "=", "propertyPart", ";", "}", "else", "{", "name", "=", "propertyPart", "+", "\".\"", "+", "name", ";", "}", "}", "}", "if", "(", "name", ".", "length", "(", ")", "==", "0", ")", "return", "null", ";", "return", "name", ";", "}", "private", "Expression", "correctClassClassChain", "(", "PropertyExpression", "pe", ")", "{", "LinkedList", "<", "Expression", ">", "stack", "=", "new", "LinkedList", "<", "Expression", ">", "(", ")", ";", "ClassExpression", "found", "=", "null", ";", "for", "(", "Expression", "it", "=", "pe", ";", "it", "!=", "null", ";", "it", "=", "(", "(", "PropertyExpression", ")", "it", ")", ".", "getObjectExpression", "(", ")", ")", "{", "if", "(", "it", "instanceof", "ClassExpression", ")", "{", "found", "=", "(", "ClassExpression", ")", "it", ";", "break", ";", "}", "else", "if", "(", "!", "(", "it", ".", "getClass", "(", ")", "==", "PropertyExpression", ".", "class", ")", ")", "{", "return", "pe", ";", "}", "stack", ".", "addFirst", "(", "it", ")", ";", "}", "if", "(", "found", "==", "null", ")", "return", "pe", ";", "if", "(", "stack", ".", "isEmpty", "(", ")", ")", "return", "pe", ";", "Object", "stackElement", "=", "stack", ".", "removeFirst", "(", ")", ";", "if", "(", "!", "(", "stackElement", ".", "getClass", "(", ")", "==", "PropertyExpression", ".", "class", ")", ")", "return", "pe", ";", "PropertyExpression", "classPropertyExpression", "=", "(", "PropertyExpression", ")", "stackElement", ";", "String", "propertyNamePart", "=", "classPropertyExpression", ".", "getPropertyAsString", "(", ")", ";", "if", "(", "propertyNamePart", "==", "null", "||", "!", "propertyNamePart", ".", "equals", "(", "\"class\"", ")", ")", "return", "pe", ";", "found", ".", "setSourcePosition", "(", "classPropertyExpression", ")", ";", "if", "(", "stack", ".", "isEmpty", "(", ")", ")", "return", "found", ";", "stackElement", "=", "stack", ".", "removeFirst", "(", ")", ";", "if", "(", "!", "(", "stackElement", ".", "getClass", "(", ")", "==", "PropertyExpression", ".", "class", ")", ")", "return", "pe", ";", "PropertyExpression", "classPropertyExpressionContainer", "=", "(", "PropertyExpression", ")", "stackElement", ";", "classPropertyExpressionContainer", ".", "setObjectExpression", "(", "found", ")", ";", "return", "pe", ";", "}", "protected", "Expression", "transformPropertyExpression", "(", "PropertyExpression", "pe", ")", "{", "boolean", "itlp", "=", "isTopLevelProperty", ";", "boolean", "ipe", "=", "inPropertyExpression", ";", "Expression", "objectExpression", "=", "pe", ".", "getObjectExpression", "(", ")", ";", "inPropertyExpression", "=", "true", ";", "isTopLevelProperty", "=", "(", "objectExpression", ".", "getClass", "(", ")", "!=", "PropertyExpression", ".", "class", ")", ";", "objectExpression", "=", "transform", "(", "objectExpression", ")", ";", "inPropertyExpression", "=", "false", ";", "Expression", "property", "=", "transform", "(", "pe", ".", "getProperty", "(", ")", ")", ";", "isTopLevelProperty", "=", "itlp", ";", "inPropertyExpression", "=", "ipe", ";", "boolean", "spreadSafe", "=", "pe", ".", "isSpreadSafe", "(", ")", ";", "PropertyExpression", "old", "=", "pe", ";", "pe", "=", "new", "PropertyExpression", "(", "objectExpression", ",", "property", ",", "pe", ".", "isSafe", "(", ")", ")", ";", "pe", ".", "setSpreadSafe", "(", "spreadSafe", ")", ";", "pe", ".", "setSourcePosition", "(", "old", ")", ";", "String", "className", "=", "lookupClassName", "(", "pe", ")", ";", "if", "(", "className", "!=", "null", ")", "{", "ClassNode", "type", "=", "ClassHelper", ".", "make", "(", "className", ")", ";", "if", "(", "resolve", "(", "type", ")", ")", "{", "Expression", "ret", "=", "new", "ClassExpression", "(", "type", ")", ";", "ret", ".", "setSourcePosition", "(", "pe", ")", ";", "return", "ret", ";", "}", "}", "if", "(", "objectExpression", "instanceof", "ClassExpression", "&&", "pe", ".", "getPropertyAsString", "(", ")", "!=", "null", ")", "{", "ClassExpression", "ce", "=", "(", "ClassExpression", ")", "objectExpression", ";", "ClassNode", "type", "=", "ClassHelper", ".", "make", "(", "ce", ".", "getType", "(", ")", ".", "getName", "(", ")", "+", "\"$\"", "+", "pe", ".", "getPropertyAsString", "(", ")", ")", ";", "if", "(", "resolve", "(", "type", ",", "false", ",", "false", ",", "false", ")", ")", "{", "Expression", "ret", "=", "new", "ClassExpression", "(", "type", ")", ";", "ret", ".", "setSourcePosition", "(", "ce", ")", ";", "return", "ret", ";", "}", "}", "Expression", "ret", "=", "pe", ";", "checkThisAndSuperAsPropertyAccess", "(", "pe", ")", ";", "if", "(", "isTopLevelProperty", ")", "ret", "=", "correctClassClassChain", "(", "pe", ")", ";", "return", "ret", ";", "}", "private", "void", "checkThisAndSuperAsPropertyAccess", "(", "PropertyExpression", "expression", ")", "{", "if", "(", "expression", ".", "isImplicitThis", "(", ")", ")", "return", ";", "String", "prop", "=", "expression", ".", "getPropertyAsString", "(", ")", ";", "if", "(", "prop", "==", "null", ")", "return", ";", "if", "(", "!", "prop", ".", "equals", "(", "\"this\"", ")", "&&", "!", "prop", ".", "equals", "(", "\"super\"", ")", ")", "return", ";", "if", "(", "expression", ".", "getObjectExpression", "(", ")", "instanceof", "ClassExpression", ")", "{", "if", "(", "!", "(", "currentClass", "instanceof", "InnerClassNode", ")", ")", "{", "addError", "(", "\"\"", ",", "expression", ")", ";", "return", ";", "}", "ClassNode", "type", "=", "expression", ".", "getObjectExpression", "(", ")", ".", "getType", "(", ")", ";", "ClassNode", "iterType", "=", "currentClass", ";", "while", "(", "iterType", "!=", "null", ")", "{", "if", "(", "iterType", ".", "equals", "(", "type", ")", ")", "break", ";", "iterType", "=", "iterType", ".", "getOuterClass", "(", ")", ";", "}", "if", "(", "iterType", "==", "null", ")", "{", "addError", "(", "\"The", "class", "'\"", "+", "type", ".", "getName", "(", ")", "+", "\"\"", "+", "currentClass", ".", "getName", "(", ")", "+", "\"\"", ",", "expression", ")", ";", "}", "if", "(", "(", "currentClass", ".", "getModifiers", "(", ")", "&", "Opcodes", ".", "ACC_STATIC", ")", "==", "0", ")", "return", ";", "if", "(", "!", "currentScope", ".", "isInStaticContext", "(", ")", ")", "return", ";", "addError", "(", "\"\"", "+", "currentClass", ".", "getName", "(", ")", "+", "\"\"", ",", "expression", ")", ";", "}", "}", "protected", "Expression", "transformVariableExpression", "(", "VariableExpression", "ve", ")", "{", "visitAnnotations", "(", "ve", ")", ";", "Variable", "v", "=", "ve", ".", "getAccessedVariable", "(", ")", ";", "if", "(", "!", "(", "v", "instanceof", "DynamicVariable", ")", "&&", "!", "checkingVariableTypeInDeclaration", ")", "{", "return", "ve", ";", "}", "if", "(", "v", "instanceof", "DynamicVariable", ")", "{", "String", "name", "=", "ve", ".", "getName", "(", ")", ";", "ClassNode", "t", "=", "ClassHelper", ".", "make", "(", "name", ")", ";", "boolean", "isClass", "=", "t", ".", "isResolved", "(", ")", ";", "if", "(", "!", "isClass", ")", "{", "if", "(", "Character", ".", "isLowerCase", "(", "name", ".", "charAt", "(", "0", ")", ")", ")", "{", "t", "=", "new", "LowerCaseClass", "(", "name", ")", ";", "}", "isClass", "=", "resolve", "(", "t", ")", ";", "if", "(", "!", "isClass", ")", "isClass", "=", "resolveToInnerEnum", "(", "t", ")", ";", "}", "if", "(", "isClass", ")", "{", "for", "(", "VariableScope", "scope", "=", "currentScope", ";", "scope", "!=", "null", "&&", "!", "scope", ".", "isRoot", "(", ")", ";", "scope", "=", "scope", ".", "getParent", "(", ")", ")", "{", "if", "(", "scope", ".", "isRoot", "(", ")", ")", "break", ";", "if", "(", "scope", ".", "removeReferencedClassVariable", "(", "ve", ".", "getName", "(", ")", ")", "==", "null", ")", "break", ";", "}", "ClassExpression", "ce", "=", "new", "ClassExpression", "(", "t", ")", ";", "ce", ".", "setSourcePosition", "(", "ve", ")", ";", "return", "ce", ";", "}", "}", "resolveOrFail", "(", "ve", ".", "getType", "(", ")", ",", "ve", ")", ";", "return", "ve", ";", "}", "private", "boolean", "testVanillaNameForClass", "(", "String", "name", ")", "{", "if", "(", "name", "==", "null", "||", "name", ".", "length", "(", ")", "==", "0", ")", "return", "false", ";", "return", "!", "Character", ".", "isLowerCase", "(", "name", ".", "charAt", "(", "0", ")", ")", ";", "}", "protected", "Expression", "transformBinaryExpression", "(", "BinaryExpression", "be", ")", "{", "Expression", "left", "=", "transform", "(", "be", ".", "getLeftExpression", "(", ")", ")", ";", "int", "type", "=", "be", ".", "getOperation", "(", ")", ".", "getType", "(", ")", ";", "if", "(", "(", "type", "==", "Types", ".", "ASSIGNMENT_OPERATOR", "||", "type", "==", "Types", ".", "EQUAL", ")", "&&", "left", "instanceof", "ClassExpression", ")", "{", "ClassExpression", "ce", "=", "(", "ClassExpression", ")", "left", ";", "String", "error", "=", "\"\"", "+", "ce", ".", "getType", "(", ")", ".", "getName", "(", ")", "+", "\"'\"", ";", "if", "(", "ce", ".", "getType", "(", ")", ".", "isScript", "(", ")", ")", "{", "error", "+=", "\"\"", ";", "}", "addError", "(", "error", ",", "be", ".", "getLeftExpression", "(", ")", ")", ";", "return", "be", ";", "}", "if", "(", "left", "instanceof", "ClassExpression", ")", "{", "if", "(", "be", ".", "getRightExpression", "(", ")", "instanceof", "ListExpression", ")", "{", "ListExpression", "list", "=", "(", "ListExpression", ")", "be", ".", "getRightExpression", "(", ")", ";", "if", "(", "list", ".", "getExpressions", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "final", "ClassExpression", "ce", "=", "new", "ClassExpression", "(", "left", ".", "getType", "(", ")", ".", "makeArray", "(", ")", ")", ";", "ce", ".", "setSourcePosition", "(", "be", ")", ";", "return", "ce", ";", "}", "else", "{", "boolean", "map", "=", "true", ";", "for", "(", "Expression", "expression", ":", "list", ".", "getExpressions", "(", ")", ")", "{", "if", "(", "!", "(", "expression", "instanceof", "MapEntryExpression", ")", ")", "{", "map", "=", "false", ";", "break", ";", "}", "}", "if", "(", "map", ")", "{", "final", "MapExpression", "me", "=", "new", "MapExpression", "(", ")", ";", "for", "(", "Expression", "expression", ":", "list", ".", "getExpressions", "(", ")", ")", "{", "me", ".", "addMapEntryExpression", "(", "(", "MapEntryExpression", ")", "transform", "(", "expression", ")", ")", ";", "}", "me", ".", "setSourcePosition", "(", "list", ")", ";", "final", "CastExpression", "ce", "=", "new", "CastExpression", "(", "left", ".", "getType", "(", ")", ",", "me", ")", ";", "ce", ".", "setSourcePosition", "(", "be", ")", ";", "return", "ce", ";", "}", "}", "}", "if", "(", "be", ".", "getRightExpression", "(", ")", "instanceof", "MapEntryExpression", ")", "{", "final", "MapExpression", "me", "=", "new", "MapExpression", "(", ")", ";", "me", ".", "addMapEntryExpression", "(", "(", "MapEntryExpression", ")", "transform", "(", "be", ".", "getRightExpression", "(", ")", ")", ")", ";", "me", ".", "setSourcePosition", "(", "be", ".", "getRightExpression", "(", ")", ")", ";", "final", "CastExpression", "ce", "=", "new", "CastExpression", "(", "left", ".", "getType", "(", ")", ",", "me", ")", ";", "ce", ".", "setSourcePosition", "(", "be", ")", ";", "return", "ce", ";", "}", "}", "Expression", "right", "=", "transform", "(", "be", ".", "getRightExpression", "(", ")", ")", ";", "be", ".", "setLeftExpression", "(", "left", ")", ";", "be", ".", "setRightExpression", "(", "right", ")", ";", "return", "be", ";", "}", "protected", "Expression", "transformClosureExpression", "(", "ClosureExpression", "ce", ")", "{", "boolean", "oldInClosure", "=", "inClosure", ";", "inClosure", "=", "true", ";", "Parameter", "[", "]", "paras", "=", "ce", ".", "getParameters", "(", ")", ";", "if", "(", "paras", "!=", "null", ")", "{", "for", "(", "Parameter", "para", ":", "paras", ")", "{", "ClassNode", "t", "=", "para", ".", "getType", "(", ")", ";", "resolveOrFail", "(", "t", ",", "ce", ")", ";", "visitAnnotations", "(", "para", ")", ";", "if", "(", "para", ".", "hasInitialExpression", "(", ")", ")", "{", "Object", "initialVal", "=", "para", ".", "getInitialExpression", "(", ")", ";", "if", "(", "initialVal", "instanceof", "Expression", ")", "{", "para", ".", "setInitialExpression", "(", "transform", "(", "(", "Expression", ")", "initialVal", ")", ")", ";", "}", "}", "visitAnnotations", "(", "para", ")", ";", "}", "}", "Statement", "code", "=", "ce", ".", "getCode", "(", ")", ";", "if", "(", "code", "!=", "null", ")", "code", ".", "visit", "(", "this", ")", ";", "inClosure", "=", "oldInClosure", ";", "return", "ce", ";", "}", "protected", "Expression", "transformConstructorCallExpression", "(", "ConstructorCallExpression", "cce", ")", "{", "ClassNode", "type", "=", "cce", ".", "getType", "(", ")", ";", "resolveOrFail", "(", "type", ",", "cce", ")", ";", "if", "(", "Modifier", ".", "isAbstract", "(", "type", ".", "getModifiers", "(", ")", ")", ")", "{", "addError", "(", "\"\"", "+", "getDescription", "(", "type", ")", "+", "\".\"", ",", "cce", ")", ";", "}", "Expression", "ret", "=", "cce", ".", "transformExpression", "(", "this", ")", ";", "return", "ret", ";", "}", "private", "String", "getDescription", "(", "ClassNode", "node", ")", "{", "return", "(", "node", ".", "isInterface", "(", ")", "?", "\"interface\"", ":", "\"class\"", ")", "+", "\"", "'\"", "+", "node", ".", "getName", "(", ")", "+", "\"'\"", ";", "}", "protected", "Expression", "transformMethodCallExpression", "(", "MethodCallExpression", "mce", ")", "{", "Expression", "args", "=", "transform", "(", "mce", ".", "getArguments", "(", ")", ")", ";", "Expression", "method", "=", "transform", "(", "mce", ".", "getMethod", "(", ")", ")", ";", "Expression", "object", "=", "transform", "(", "mce", ".", "getObjectExpression", "(", ")", ")", ";", "resolveGenericsTypes", "(", "mce", ".", "getGenericsTypes", "(", ")", ")", ";", "MethodCallExpression", "result", "=", "new", "MethodCallExpression", "(", "object", ",", "method", ",", "args", ")", ";", "result", ".", "setSafe", "(", "mce", ".", "isSafe", "(", ")", ")", ";", "result", ".", "setImplicitThis", "(", "mce", ".", "isImplicitThis", "(", ")", ")", ";", "result", ".", "setSpreadSafe", "(", "mce", ".", "isSpreadSafe", "(", ")", ")", ";", "result", ".", "setSourcePosition", "(", "mce", ")", ";", "result", ".", "setGenericsTypes", "(", "mce", ".", "getGenericsTypes", "(", ")", ")", ";", "result", ".", "setMethodTarget", "(", "mce", ".", "getMethodTarget", "(", ")", ")", ";", "return", "result", ";", "}", "protected", "Expression", "transformDeclarationExpression", "(", "DeclarationExpression", "de", ")", "{", "visitAnnotations", "(", "de", ")", ";", "Expression", "oldLeft", "=", "de", ".", "getLeftExpression", "(", ")", ";", "checkingVariableTypeInDeclaration", "=", "true", ";", "Expression", "left", "=", "transform", "(", "oldLeft", ")", ";", "checkingVariableTypeInDeclaration", "=", "false", ";", "if", "(", "left", "instanceof", "ClassExpression", ")", "{", "ClassExpression", "ce", "=", "(", "ClassExpression", ")", "left", ";", "addError", "(", "\"\"", "+", "ce", ".", "getType", "(", ")", ".", "getName", "(", ")", ",", "oldLeft", ")", ";", "return", "de", ";", "}", "Expression", "right", "=", "transform", "(", "de", ".", "getRightExpression", "(", ")", ")", ";", "if", "(", "right", "==", "de", ".", "getRightExpression", "(", ")", ")", "{", "fixDeclaringClass", "(", "de", ")", ";", "return", "de", ";", "}", "DeclarationExpression", "newDeclExpr", "=", "new", "DeclarationExpression", "(", "left", ",", "de", ".", "getOperation", "(", ")", ",", "right", ")", ";", "newDeclExpr", ".", "setDeclaringClass", "(", "de", ".", "getDeclaringClass", "(", ")", ")", ";", "fixDeclaringClass", "(", "newDeclExpr", ")", ";", "newDeclExpr", ".", "setSourcePosition", "(", "de", ")", ";", "newDeclExpr", ".", "addAnnotations", "(", "de", ".", "getAnnotations", "(", ")", ")", ";", "return", "newDeclExpr", ";", "}", "private", "void", "fixDeclaringClass", "(", "DeclarationExpression", "newDeclExpr", ")", "{", "if", "(", "newDeclExpr", ".", "getDeclaringClass", "(", ")", "==", "null", "&&", "currentMethod", "!=", "null", ")", "{", "newDeclExpr", ".", "setDeclaringClass", "(", "currentMethod", ".", "getDeclaringClass", "(", ")", ")", ";", "}", "}", "protected", "Expression", "transformAnnotationConstantExpression", "(", "AnnotationConstantExpression", "ace", ")", "{", "AnnotationNode", "an", "=", "(", "AnnotationNode", ")", "ace", ".", "getValue", "(", ")", ";", "ClassNode", "type", "=", "an", ".", "getClassNode", "(", ")", ";", "resolveOrFail", "(", "type", ",", "\"\"", ",", "an", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Expression", ">", "member", ":", "an", ".", "getMembers", "(", ")", ".", "entrySet", "(", ")", ")", "{", "member", ".", "setValue", "(", "transform", "(", "member", ".", "getValue", "(", ")", ")", ")", ";", "}", "return", "ace", ";", "}", "public", "void", "visitAnnotations", "(", "AnnotatedNode", "node", ")", "{", "List", "<", "AnnotationNode", ">", "annotations", "=", "node", ".", "getAnnotations", "(", ")", ";", "if", "(", "annotations", ".", "isEmpty", "(", ")", ")", "return", ";", "Map", "<", "String", ",", "AnnotationNode", ">", "tmpAnnotations", "=", "new", "HashMap", "<", "String", ",", "AnnotationNode", ">", "(", ")", ";", "ClassNode", "annType", ";", "for", "(", "AnnotationNode", "an", ":", "annotations", ")", "{", "if", "(", "an", ".", "isBuiltIn", "(", ")", ")", "continue", ";", "annType", "=", "an", ".", "getClassNode", "(", ")", ";", "resolveOrFail", "(", "annType", ",", "\"\"", ",", "an", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Expression", ">", "member", ":", "an", ".", "getMembers", "(", ")", ".", "entrySet", "(", ")", ")", "{", "Expression", "newValue", "=", "transform", "(", "member", ".", "getValue", "(", ")", ")", ";", "newValue", "=", "transformInlineConstants", "(", "newValue", ")", ";", "member", ".", "setValue", "(", "newValue", ")", ";", "checkAnnotationMemberValue", "(", "newValue", ")", ";", "}", "}", "}", "private", "Expression", "transformInlineConstants", "(", "Expression", "exp", ")", "{", "if", "(", "exp", "instanceof", "PropertyExpression", ")", "{", "PropertyExpression", "pe", "=", "(", "PropertyExpression", ")", "exp", ";", "if", "(", "pe", ".", "getObjectExpression", "(", ")", "instanceof", "ClassExpression", ")", "{", "ClassExpression", "ce", "=", "(", "ClassExpression", ")", "pe", ".", "getObjectExpression", "(", ")", ";", "ClassNode", "type", "=", "ce", ".", "getType", "(", ")", ";", "if", "(", "type", ".", "isEnum", "(", ")", ")", "return", "exp", ";", "FieldNode", "fn", "=", "type", ".", "getField", "(", "pe", ".", "getPropertyAsString", "(", ")", ")", ";", "if", "(", "fn", "!=", "null", "&&", "!", "fn", ".", "isEnum", "(", ")", "&&", "fn", ".", "isStatic", "(", ")", "&&", "fn", ".", "isFinal", "(", ")", ")", "{", "if", "(", "fn", ".", "getInitialValueExpression", "(", ")", "instanceof", "ConstantExpression", ")", "{", "return", "fn", ".", "getInitialValueExpression", "(", ")", ";", "}", "}", "}", "}", "else", "if", "(", "exp", "instanceof", "ListExpression", ")", "{", "ListExpression", "le", "=", "(", "ListExpression", ")", "exp", ";", "ListExpression", "result", "=", "new", "ListExpression", "(", ")", ";", "for", "(", "Expression", "e", ":", "le", ".", "getExpressions", "(", ")", ")", "{", "result", ".", "addExpression", "(", "transformInlineConstants", "(", "e", ")", ")", ";", "}", "return", "result", ";", "}", "else", "if", "(", "exp", "instanceof", "AnnotationConstantExpression", ")", "{", "ConstantExpression", "ce", "=", "(", "ConstantExpression", ")", "exp", ";", "if", "(", "ce", ".", "getValue", "(", ")", "instanceof", "AnnotationNode", ")", "{", "AnnotationNode", "an", "=", "(", "AnnotationNode", ")", "ce", ".", "getValue", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Expression", ">", "member", ":", "an", ".", "getMembers", "(", ")", ".", "entrySet", "(", ")", ")", "{", "member", ".", "setValue", "(", "transformInlineConstants", "(", "member", ".", "getValue", "(", ")", ")", ")", ";", "}", "}", "}", "return", "exp", ";", "}", "protected", "boolean", "commencingResolution", "(", ")", "{", "return", "true", ";", "}", "protected", "void", "finishedResolution", "(", ")", "{", "}", "private", "void", "checkAnnotationMemberValue", "(", "Expression", "newValue", ")", "{", "if", "(", "newValue", "instanceof", "PropertyExpression", ")", "{", "PropertyExpression", "pe", "=", "(", "PropertyExpression", ")", "newValue", ";", "if", "(", "!", "(", "pe", ".", "getObjectExpression", "(", ")", "instanceof", "ClassExpression", ")", ")", "{", "addError", "(", "\"\"", "+", "pe", ".", "getText", "(", ")", "+", "\"\"", ",", "pe", ".", "getObjectExpression", "(", ")", ")", ";", "}", "}", "else", "if", "(", "newValue", "instanceof", "ListExpression", ")", "{", "ListExpression", "le", "=", "(", "ListExpression", ")", "newValue", ";", "for", "(", "Expression", "e", ":", "le", ".", "getExpressions", "(", ")", ")", "{", "checkAnnotationMemberValue", "(", "e", ")", ";", "}", "}", "}", "public", "void", "visitClass", "(", "ClassNode", "node", ")", "{", "ClassNode", "oldNode", "=", "currentClass", ";", "if", "(", "node", "instanceof", "InnerClassNode", ")", "{", "if", "(", "Modifier", ".", "isStatic", "(", "node", ".", "getModifiers", "(", ")", ")", ")", "{", "genericParameterNames", "=", "new", "HashMap", "<", "String", ",", "GenericsType", ">", "(", ")", ";", "}", "}", "else", "{", "genericParameterNames", "=", "new", "HashMap", "<", "String", ",", "GenericsType", ">", "(", ")", ";", "}", "currentClass", "=", "node", ";", "if", "(", "!", "commencingResolution", "(", ")", ")", "{", "return", ";", "}", "resolveGenericsHeader", "(", "node", ".", "getGenericsTypes", "(", ")", ")", ";", "ModuleNode", "module", "=", "node", ".", "getModule", "(", ")", ";", "if", "(", "!", "module", ".", "hasImportsResolved", "(", ")", ")", "{", "for", "(", "ImportNode", "importNode", ":", "module", ".", "getImports", "(", ")", ")", "{", "currImportNode", "=", "importNode", ";", "ClassNode", "type", "=", "importNode", ".", "getType", "(", ")", ";", "if", "(", "resolve", "(", "type", ",", "false", ",", "false", ",", "true", ")", ")", "{", "currImportNode", "=", "null", ";", "continue", ";", "}", "currImportNode", "=", "null", ";", "addError", "(", "\"\"", "+", "type", ".", "getName", "(", ")", ",", "type", ")", ";", "}", "for", "(", "ImportNode", "importNode", ":", "module", ".", "getStaticStarImports", "(", ")", ".", "values", "(", ")", ")", "{", "ClassNode", "type", "=", "importNode", ".", "getType", "(", ")", ";", "if", "(", "resolve", "(", "type", ",", "false", ",", "false", ",", "true", ")", ")", "continue", ";", "if", "(", "type", ".", "getPackageName", "(", ")", "==", "null", "&&", "node", ".", "getPackageName", "(", ")", "!=", "null", ")", "{", "String", "oldTypeName", "=", "type", ".", "getName", "(", ")", ";", "type", ".", "setName", "(", "node", ".", "getPackageName", "(", ")", "+", "\".\"", "+", "oldTypeName", ")", ";", "if", "(", "resolve", "(", "type", ",", "false", ",", "false", ",", "true", ")", ")", "continue", ";", "type", ".", "setName", "(", "oldTypeName", ")", ";", "}", "addError", "(", "\"\"", "+", "type", ".", "getName", "(", ")", ",", "type", ")", ";", "importNode", ".", "markAsUnresolvable", "(", ")", ";", "}", "for", "(", "ImportNode", "importNode", ":", "module", ".", "getStaticImports", "(", ")", ".", "values", "(", ")", ")", "{", "ClassNode", "type", "=", "importNode", ".", "getType", "(", ")", ";", "if", "(", "resolve", "(", "type", ",", "true", ",", "true", ",", "true", ")", ")", "continue", ";", "addError", "(", "\"\"", "+", "type", ".", "getName", "(", ")", ",", "type", ")", ";", "}", "for", "(", "ImportNode", "importNode", ":", "module", ".", "getStaticStarImports", "(", ")", ".", "values", "(", ")", ")", "{", "ClassNode", "type", "=", "importNode", ".", "getType", "(", ")", ";", "if", "(", "resolve", "(", "type", ",", "true", ",", "true", ",", "true", ")", ")", "continue", ";", "if", "(", "!", "importNode", ".", "isUnresolvable", "(", ")", ")", "{", "addError", "(", "\"\"", "+", "type", ".", "getName", "(", ")", ",", "type", ")", ";", "}", "}", "module", ".", "setImportsResolved", "(", "true", ")", ";", "}", "ClassNode", "sn", "=", "node", ".", "getUnresolvedSuperClass", "(", ")", ";", "if", "(", "sn", "!=", "null", ")", "resolveOrFail", "(", "sn", ",", "node", ",", "true", ")", ";", "for", "(", "ClassNode", "anInterface", ":", "node", ".", "getInterfaces", "(", ")", ")", "{", "resolveOrFail", "(", "anInterface", ",", "node", ",", "true", ")", ";", "}", "checkCyclicInheritence", "(", "node", ",", "node", ".", "getUnresolvedSuperClass", "(", ")", ",", "node", ".", "getInterfaces", "(", ")", ")", ";", "super", ".", "visitClass", "(", "node", ")", ";", "finishedResolution", "(", ")", ";", "currentClass", "=", "oldNode", ";", "}", "private", "void", "checkCyclicInheritence", "(", "ClassNode", "originalNode", ",", "ClassNode", "parentToCompare", ",", "ClassNode", "[", "]", "interfacesToCompare", ")", "{", "if", "(", "!", "originalNode", ".", "isInterface", "(", ")", ")", "{", "if", "(", "parentToCompare", "==", "null", ")", "return", ";", "if", "(", "originalNode", "==", "parentToCompare", ".", "redirect", "(", ")", ")", "{", "addError", "(", "\"\"", "+", "parentToCompare", ".", "getName", "(", ")", "+", "\"", "in", "class", "\"", "+", "originalNode", ".", "getName", "(", ")", ",", "originalNode", ")", ";", "originalNode", ".", "redirect", "(", ")", ".", "setHasInconsistentHierarchy", "(", "true", ")", ";", "return", ";", "}", "if", "(", "interfacesToCompare", "!=", "null", "&&", "interfacesToCompare", ".", "length", ">", "0", ")", "{", "for", "(", "ClassNode", "intfToCompare", ":", "interfacesToCompare", ")", "{", "if", "(", "originalNode", "==", "intfToCompare", ".", "redirect", "(", ")", ")", "{", "addError", "(", "\"\"", "+", "originalNode", ".", "getName", "(", ")", "+", "\"\"", ",", "originalNode", ")", ";", "originalNode", ".", "redirect", "(", ")", ".", "setHasInconsistentHierarchy", "(", "true", ")", ";", "return", ";", "}", "}", "}", "if", "(", "parentToCompare", "==", "ClassHelper", ".", "OBJECT_TYPE", ")", "return", ";", "checkCyclicInheritence", "(", "originalNode", ",", "parentToCompare", ".", "getUnresolvedSuperClass", "(", ")", ",", "null", ")", ";", "}", "else", "{", "if", "(", "interfacesToCompare", "!=", "null", "&&", "interfacesToCompare", ".", "length", ">", "0", ")", "{", "for", "(", "ClassNode", "intfToCompare", ":", "interfacesToCompare", ")", "{", "if", "(", "originalNode", "==", "intfToCompare", ".", "redirect", "(", ")", ")", "{", "addError", "(", "\"\"", "+", "intfToCompare", ".", "getName", "(", ")", "+", "\"\"", "+", "originalNode", ".", "getName", "(", ")", ",", "originalNode", ")", ";", "originalNode", ".", "redirect", "(", ")", ".", "setHasInconsistentHierarchy", "(", "true", ")", ";", "return", ";", "}", "}", "for", "(", "ClassNode", "intf", ":", "interfacesToCompare", ")", "{", "checkCyclicInheritence", "(", "originalNode", ",", "null", ",", "intf", ".", "getInterfaces", "(", ")", ")", ";", "}", "}", "else", "{", "return", ";", "}", "}", "}", "public", "void", "visitCatchStatement", "(", "CatchStatement", "cs", ")", "{", "resolveOrFail", "(", "cs", ".", "getExceptionType", "(", ")", ",", "cs", ")", ";", "if", "(", "cs", ".", "getExceptionType", "(", ")", "==", "ClassHelper", ".", "DYNAMIC_TYPE", ")", "{", "cs", ".", "getVariable", "(", ")", ".", "setType", "(", "ClassHelper", ".", "make", "(", "Exception", ".", "class", ")", ")", ";", "}", "super", ".", "visitCatchStatement", "(", "cs", ")", ";", "}", "public", "void", "visitForLoop", "(", "ForStatement", "forLoop", ")", "{", "resolveOrFail", "(", "forLoop", ".", "getVariableType", "(", ")", ",", "forLoop", ")", ";", "super", ".", "visitForLoop", "(", "forLoop", ")", ";", "}", "public", "void", "visitBlockStatement", "(", "BlockStatement", "block", ")", "{", "VariableScope", "oldScope", "=", "currentScope", ";", "currentScope", "=", "block", ".", "getVariableScope", "(", ")", ";", "super", ".", "visitBlockStatement", "(", "block", ")", ";", "currentScope", "=", "oldScope", ";", "}", "protected", "SourceUnit", "getSourceUnit", "(", ")", "{", "return", "source", ";", "}", "private", "void", "resolveGenericsTypes", "(", "GenericsType", "[", "]", "types", ")", "{", "if", "(", "types", "==", "null", ")", "return", ";", "currentClass", ".", "setUsingGenerics", "(", "true", ")", ";", "for", "(", "GenericsType", "type", ":", "types", ")", "{", "resolveGenericsType", "(", "type", ")", ";", "}", "}", "private", "void", "resolveGenericsHeader", "(", "GenericsType", "[", "]", "types", ")", "{", "if", "(", "types", "==", "null", ")", "return", ";", "currentClass", ".", "setUsingGenerics", "(", "true", ")", ";", "for", "(", "GenericsType", "type", ":", "types", ")", "{", "ClassNode", "classNode", "=", "type", ".", "getType", "(", ")", ";", "String", "name", "=", "type", ".", "getName", "(", ")", ";", "ClassNode", "[", "]", "bounds", "=", "type", ".", "getUpperBounds", "(", ")", ";", "if", "(", "bounds", "!=", "null", ")", "{", "boolean", "nameAdded", "=", "false", ";", "for", "(", "ClassNode", "upperBound", ":", "bounds", ")", "{", "if", "(", "!", "nameAdded", "&&", "upperBound", "!=", "null", "||", "!", "resolve", "(", "classNode", ")", ")", "{", "genericParameterNames", ".", "put", "(", "name", ",", "type", ")", ";", "type", ".", "setPlaceholder", "(", "true", ")", ";", "classNode", ".", "setRedirect", "(", "upperBound", ")", ";", "nameAdded", "=", "true", ";", "}", "resolveOrFail", "(", "upperBound", ",", "classNode", ")", ";", "}", "}", "else", "{", "genericParameterNames", ".", "put", "(", "name", ",", "type", ")", ";", "classNode", ".", "setRedirect", "(", "ClassHelper", ".", "OBJECT_TYPE", ")", ";", "type", ".", "setPlaceholder", "(", "true", ")", ";", "}", "}", "}", "private", "void", "resolveGenericsType", "(", "GenericsType", "genericsType", ")", "{", "if", "(", "genericsType", ".", "isResolved", "(", ")", ")", "return", ";", "currentClass", ".", "setUsingGenerics", "(", "true", ")", ";", "ClassNode", "type", "=", "genericsType", ".", "getType", "(", ")", ";", "String", "name", "=", "type", ".", "getName", "(", ")", ";", "ClassNode", "[", "]", "bounds", "=", "genericsType", ".", "getUpperBounds", "(", ")", ";", "if", "(", "!", "genericParameterNames", ".", "containsKey", "(", "name", ")", ")", "{", "if", "(", "bounds", "!=", "null", ")", "{", "for", "(", "ClassNode", "upperBound", ":", "bounds", ")", "{", "resolveOrFail", "(", "upperBound", ",", "genericsType", ")", ";", "type", ".", "setRedirect", "(", "upperBound", ")", ";", "resolveGenericsTypes", "(", "upperBound", ".", "getGenericsTypes", "(", ")", ")", ";", "}", "}", "else", "if", "(", "genericsType", ".", "isWildcard", "(", ")", ")", "{", "type", ".", "setRedirect", "(", "ClassHelper", ".", "OBJECT_TYPE", ")", ";", "}", "else", "{", "resolveOrFail", "(", "type", ",", "genericsType", ")", ";", "}", "}", "else", "{", "GenericsType", "gt", "=", "genericParameterNames", ".", "get", "(", "name", ")", ";", "type", ".", "setRedirect", "(", "gt", ".", "getType", "(", ")", ")", ";", "genericsType", ".", "setPlaceholder", "(", "true", ")", ";", "}", "if", "(", "genericsType", ".", "getLowerBound", "(", ")", "!=", "null", ")", "{", "resolveOrFail", "(", "genericsType", ".", "getLowerBound", "(", ")", ",", "genericsType", ")", ";", "}", "resolveGenericsTypes", "(", "type", ".", "getGenericsTypes", "(", ")", ")", ";", "genericsType", ".", "setResolved", "(", "genericsType", ".", "getType", "(", ")", ".", "isResolved", "(", ")", ")", ";", "}", "public", "void", "setClassNodeResolver", "(", "ClassNodeResolver", "classNodeResolver", ")", "{", "this", ".", "classNodeResolver", "=", "classNodeResolver", ";", "}", "}", "</s>" ]
6,934
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "control", ";", "import", "groovy", ".", "lang", ".", "GroovyClassLoader", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileWriter", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "Reader", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "security", ".", "AccessController", ";", "import", "java", ".", "security", ".", "PrivilegedAction", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "GroovyBugError", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ClassNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "Comment", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "GenericsType", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "ModuleNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "io", ".", "FileReaderSource", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "io", ".", "ReaderSource", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "io", ".", "StringReaderSource", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "io", ".", "URLReaderSource", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "Message", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "SimpleMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "SyntaxErrorMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "tools", ".", "Utilities", ";", "import", "antlr", ".", "CharScanner", ";", "import", "antlr", ".", "MismatchedTokenException", ";", "import", "antlr", ".", "MismatchedCharException", ";", "import", "antlr", ".", "NoViableAltException", ";", "import", "antlr", ".", "NoViableAltForCharException", ";", "public", "class", "SourceUnit", "extends", "ProcessingUnit", "{", "private", "List", "<", "Comment", ">", "comments", ";", "private", "ParserPlugin", "parserPlugin", ";", "protected", "ReaderSource", "source", ";", "protected", "String", "name", ";", "protected", "Reduction", "cst", ";", "protected", "ModuleNode", "ast", ";", "public", "boolean", "isReconcile", ";", "public", "SourceUnit", "(", "String", "name", ",", "ReaderSource", "source", ",", "CompilerConfiguration", "flags", ",", "GroovyClassLoader", "loader", ",", "ErrorCollector", "er", ")", "{", "super", "(", "flags", ",", "loader", ",", "er", ")", ";", "this", ".", "name", "=", "name", ";", "this", ".", "source", "=", "source", ";", "}", "public", "SourceUnit", "(", "File", "source", ",", "CompilerConfiguration", "configuration", ",", "GroovyClassLoader", "loader", ",", "ErrorCollector", "er", ")", "{", "this", "(", "source", ".", "getPath", "(", ")", ",", "new", "FileReaderSource", "(", "source", ",", "configuration", ")", ",", "configuration", ",", "loader", ",", "er", ")", ";", "}", "public", "SourceUnit", "(", "URL", "source", ",", "CompilerConfiguration", "configuration", ",", "GroovyClassLoader", "loader", ",", "ErrorCollector", "er", ")", "{", "this", "(", "source", ".", "toExternalForm", "(", ")", ",", "new", "URLReaderSource", "(", "source", ",", "configuration", ")", ",", "configuration", ",", "loader", ",", "er", ")", ";", "}", "public", "SourceUnit", "(", "String", "name", ",", "String", "source", ",", "CompilerConfiguration", "configuration", ",", "GroovyClassLoader", "loader", ",", "ErrorCollector", "er", ")", "{", "this", "(", "name", ",", "new", "StringReaderSource", "(", "source", ",", "configuration", ")", ",", "configuration", ",", "loader", ",", "er", ")", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "name", ";", "}", "public", "Reduction", "getCST", "(", ")", "{", "return", "this", ".", "cst", ";", "}", "public", "ModuleNode", "getAST", "(", ")", "{", "return", "this", ".", "ast", ";", "}", "public", "boolean", "failedWithUnexpectedEOF", "(", ")", "{", "if", "(", "getErrorCollector", "(", ")", ".", "hasErrors", "(", ")", ")", "{", "Message", "last", "=", "(", "Message", ")", "getErrorCollector", "(", ")", ".", "getLastError", "(", ")", ";", "Throwable", "cause", "=", "null", ";", "if", "(", "last", "instanceof", "SyntaxErrorMessage", ")", "{", "cause", "=", "(", "(", "SyntaxErrorMessage", ")", "last", ")", ".", "getCause", "(", ")", ".", "getCause", "(", ")", ";", "}", "if", "(", "cause", "!=", "null", ")", "{", "if", "(", "cause", "instanceof", "NoViableAltException", ")", "{", "return", "isEofToken", "(", "(", "(", "NoViableAltException", ")", "cause", ")", ".", "token", ")", ";", "}", "else", "if", "(", "cause", "instanceof", "NoViableAltForCharException", ")", "{", "char", "badChar", "=", "(", "(", "NoViableAltForCharException", ")", "cause", ")", ".", "foundChar", ";", "return", "badChar", "==", "CharScanner", ".", "EOF_CHAR", ";", "}", "else", "if", "(", "cause", "instanceof", "MismatchedCharException", ")", "{", "char", "badChar", "=", "(", "char", ")", "(", "(", "MismatchedCharException", ")", "cause", ")", ".", "foundChar", ";", "return", "badChar", "==", "CharScanner", ".", "EOF_CHAR", ";", "}", "else", "if", "(", "cause", "instanceof", "MismatchedTokenException", ")", "{", "return", "isEofToken", "(", "(", "(", "MismatchedTokenException", ")", "cause", ")", ".", "token", ")", ";", "}", "}", "}", "return", "false", ";", "}", "protected", "boolean", "isEofToken", "(", "antlr", ".", "Token", "token", ")", "{", "return", "token", ".", "getType", "(", ")", "==", "antlr", ".", "Token", ".", "EOF_TYPE", ";", "}", "public", "static", "SourceUnit", "create", "(", "String", "name", ",", "String", "source", ")", "{", "CompilerConfiguration", "configuration", "=", "new", "CompilerConfiguration", "(", ")", ";", "configuration", ".", "setTolerance", "(", "1", ")", ";", "return", "new", "SourceUnit", "(", "name", ",", "source", ",", "configuration", ",", "null", ",", "new", "ErrorCollector", "(", "configuration", ")", ")", ";", "}", "public", "static", "SourceUnit", "create", "(", "String", "name", ",", "String", "source", ",", "int", "tolerance", ")", "{", "CompilerConfiguration", "configuration", "=", "new", "CompilerConfiguration", "(", ")", ";", "configuration", ".", "setTolerance", "(", "tolerance", ")", ";", "return", "new", "SourceUnit", "(", "name", ",", "source", ",", "configuration", ",", "null", ",", "new", "ErrorCollector", "(", "configuration", ")", ")", ";", "}", "public", "void", "parse", "(", ")", "throws", "CompilationFailedException", "{", "if", "(", "this", ".", "phase", ">", "Phases", ".", "PARSING", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", ")", ";", "}", "if", "(", "this", ".", "phase", "==", "Phases", ".", "INITIALIZATION", ")", "{", "nextPhase", "(", ")", ";", "}", "Reader", "reader", "=", "null", ";", "try", "{", "reader", "=", "source", ".", "getReader", "(", ")", ";", "parserPlugin", "=", "getConfiguration", "(", ")", ".", "getPluginFactory", "(", ")", ".", "createParserPlugin", "(", ")", ";", "cst", "=", "parserPlugin", ".", "parseCST", "(", "this", ",", "reader", ")", ";", "reader", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "getErrorCollector", "(", ")", ".", "addFatalError", "(", "new", "SimpleMessage", "(", "e", ".", "getMessage", "(", ")", ",", "this", ")", ")", ";", "}", "finally", "{", "if", "(", "reader", "!=", "null", ")", "{", "try", "{", "reader", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "}", "}", "public", "void", "convert", "(", ")", "throws", "CompilationFailedException", "{", "if", "(", "this", ".", "phase", "==", "Phases", ".", "PARSING", "&&", "this", ".", "phaseComplete", ")", "{", "gotoPhase", "(", "Phases", ".", "CONVERSION", ")", ";", "}", "if", "(", "this", ".", "phase", "!=", "Phases", ".", "CONVERSION", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", ")", ";", "}", "try", "{", "this", ".", "ast", "=", "parserPlugin", ".", "buildAST", "(", "this", ",", "this", ".", "classLoader", ",", "this", ".", "cst", ")", ";", "this", ".", "ast", ".", "setDescription", "(", "this", ".", "name", ")", ";", "}", "catch", "(", "SyntaxException", "e", ")", "{", "if", "(", "this", ".", "ast", "==", "null", ")", "{", "this", ".", "ast", "=", "new", "ModuleNode", "(", "this", ")", ";", "}", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SyntaxErrorMessage", "(", "e", ",", "this", ")", ")", ";", "}", "String", "property", "=", "(", "String", ")", "AccessController", ".", "doPrivileged", "(", "new", "PrivilegedAction", "(", ")", "{", "public", "Object", "run", "(", ")", "{", "return", "System", ".", "getProperty", "(", "\"groovy.ast\"", ")", ";", "}", "}", ")", ";", "if", "(", "\"xml\"", ".", "equals", "(", "property", ")", ")", "{", "saveAsXML", "(", "name", ",", "ast", ")", ";", "}", "}", "private", "void", "saveAsXML", "(", "String", "name", ",", "ModuleNode", "ast", ")", "{", "}", "public", "String", "getSample", "(", "int", "line", ",", "int", "column", ",", "Janitor", "janitor", ")", "{", "String", "sample", "=", "null", ";", "String", "text", "=", "source", ".", "getLine", "(", "line", ",", "janitor", ")", ";", "if", "(", "text", "!=", "null", ")", "{", "if", "(", "column", ">", "0", ")", "{", "String", "marker", "=", "Utilities", ".", "repeatString", "(", "\"", "\"", ",", "column", "-", "1", ")", "+", "\"^\"", ";", "if", "(", "column", ">", "40", ")", "{", "int", "start", "=", "column", "-", "30", "-", "1", ";", "int", "end", "=", "(", "column", "+", "10", ">", "text", ".", "length", "(", ")", "?", "text", ".", "length", "(", ")", ":", "column", "+", "10", "-", "1", ")", ";", "sample", "=", "\"", "\"", "+", "text", ".", "substring", "(", "start", ",", "end", ")", "+", "Utilities", ".", "eol", "(", ")", "+", "\"", "\"", "+", "marker", ".", "substring", "(", "start", ",", "marker", ".", "length", "(", ")", ")", ";", "}", "else", "{", "sample", "=", "\"", "\"", "+", "text", "+", "Utilities", ".", "eol", "(", ")", "+", "\"", "\"", "+", "marker", ";", "}", "}", "else", "{", "sample", "=", "text", ";", "}", "}", "return", "sample", ";", "}", "public", "void", "addException", "(", "Exception", "e", ")", "throws", "CompilationFailedException", "{", "getErrorCollector", "(", ")", ".", "addException", "(", "e", ",", "this", ")", ";", "}", "public", "void", "addError", "(", "SyntaxException", "se", ")", "throws", "CompilationFailedException", "{", "getErrorCollector", "(", ")", ".", "addError", "(", "se", ",", "this", ")", ";", "}", "public", "ReaderSource", "getSource", "(", ")", "{", "return", "source", ";", "}", "public", "List", "<", "Comment", ">", "getComments", "(", ")", "{", "return", "comments", ";", "}", "public", "void", "setComments", "(", "List", "<", "Comment", ">", "comments", ")", "{", "this", ".", "comments", "=", "comments", ";", "}", "}", "</s>" ]
6,935
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "control", ";", "import", "java", ".", "io", ".", "PrintWriter", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "ExceptionMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "LocatedMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "Message", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "SyntaxErrorMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "WarningMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "CSTNode", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "SyntaxException", ";", "public", "class", "ErrorCollector", "{", "public", "boolean", "transformActive", "=", "false", ";", "protected", "LinkedList", "warnings", ";", "protected", "LinkedList", "errors", ";", "protected", "CompilerConfiguration", "configuration", ";", "public", "ErrorCollector", "(", "CompilerConfiguration", "configuration", ")", "{", "this", ".", "warnings", "=", "null", ";", "this", ".", "errors", "=", "null", ";", "this", ".", "configuration", "=", "configuration", ";", "}", "public", "void", "addCollectorContents", "(", "ErrorCollector", "er", ")", "{", "if", "(", "er", ".", "errors", "!=", "null", ")", "{", "if", "(", "errors", "==", "null", ")", "{", "errors", "=", "er", ".", "errors", ";", "}", "else", "{", "errors", ".", "addAll", "(", "er", ".", "errors", ")", ";", "}", "}", "if", "(", "er", ".", "warnings", "!=", "null", ")", "{", "if", "(", "warnings", "==", "null", ")", "{", "warnings", "=", "er", ".", "warnings", ";", "}", "else", "{", "warnings", ".", "addAll", "(", "er", ".", "warnings", ")", ";", "}", "}", "}", "public", "void", "addErrorAndContinue", "(", "Message", "message", ")", "{", "if", "(", "this", ".", "errors", "==", "null", ")", "{", "this", ".", "errors", "=", "new", "LinkedList", "(", ")", ";", "}", "this", ".", "errors", ".", "add", "(", "message", ")", ";", "}", "public", "void", "addError", "(", "Message", "message", ")", "throws", "CompilationFailedException", "{", "addErrorAndContinue", "(", "message", ")", ";", "if", "(", "errors", "!=", "null", "&&", "this", ".", "errors", ".", "size", "(", ")", ">=", "configuration", ".", "getTolerance", "(", ")", ")", "{", "failIfErrors", "(", ")", ";", "}", "}", "public", "void", "addError", "(", "Message", "message", ",", "boolean", "fatal", ")", "throws", "CompilationFailedException", "{", "if", "(", "fatal", ")", "{", "addFatalError", "(", "message", ")", ";", "}", "else", "{", "addError", "(", "message", ")", ";", "}", "}", "public", "void", "addError", "(", "SyntaxException", "error", ",", "SourceUnit", "source", ")", "throws", "CompilationFailedException", "{", "addError", "(", "Message", ".", "create", "(", "error", ",", "source", ")", ",", "error", ".", "isFatal", "(", ")", ")", ";", "}", "public", "void", "addError", "(", "String", "text", ",", "CSTNode", "context", ",", "SourceUnit", "source", ")", "throws", "CompilationFailedException", "{", "addError", "(", "new", "LocatedMessage", "(", "text", ",", "context", ",", "source", ")", ")", ";", "}", "public", "void", "addFatalError", "(", "Message", "message", ")", "throws", "CompilationFailedException", "{", "addError", "(", "message", ")", ";", "failIfErrors", "(", ")", ";", "}", "public", "void", "addException", "(", "Exception", "cause", ",", "SourceUnit", "source", ")", "throws", "CompilationFailedException", "{", "addError", "(", "new", "ExceptionMessage", "(", "cause", ",", "configuration", ".", "getDebug", "(", ")", ",", "source", ")", ")", ";", "failIfErrors", "(", ")", ";", "}", "public", "boolean", "hasErrors", "(", ")", "{", "return", "this", ".", "errors", "!=", "null", ";", "}", "public", "CompilerConfiguration", "getConfiguration", "(", ")", "{", "return", "configuration", ";", "}", "public", "boolean", "hasWarnings", "(", ")", "{", "return", "this", ".", "warnings", "!=", "null", ";", "}", "public", "List", "getWarnings", "(", ")", "{", "return", "this", ".", "warnings", ";", "}", "public", "List", "getErrors", "(", ")", "{", "return", "this", ".", "errors", ";", "}", "public", "int", "getWarningCount", "(", ")", "{", "return", "(", "(", "this", ".", "warnings", "==", "null", ")", "?", "0", ":", "this", ".", "warnings", ".", "size", "(", ")", ")", ";", "}", "public", "int", "getErrorCount", "(", ")", "{", "return", "(", "(", "this", ".", "errors", "==", "null", ")", "?", "0", ":", "this", ".", "errors", ".", "size", "(", ")", ")", ";", "}", "public", "WarningMessage", "getWarning", "(", "int", "index", ")", "{", "if", "(", "index", "<", "getWarningCount", "(", ")", ")", "{", "return", "(", "WarningMessage", ")", "this", ".", "warnings", ".", "get", "(", "index", ")", ";", "}", "return", "null", ";", "}", "public", "Message", "getError", "(", "int", "index", ")", "{", "if", "(", "index", "<", "getErrorCount", "(", ")", ")", "{", "return", "(", "Message", ")", "this", ".", "errors", ".", "get", "(", "index", ")", ";", "}", "return", "null", ";", "}", "public", "Message", "getLastError", "(", ")", "{", "return", "(", "Message", ")", "this", ".", "errors", ".", "getLast", "(", ")", ";", "}", "public", "SyntaxException", "getSyntaxError", "(", "int", "index", ")", "{", "SyntaxException", "exception", "=", "null", ";", "Message", "message", "=", "getError", "(", "index", ")", ";", "if", "(", "message", "!=", "null", "&&", "message", "instanceof", "SyntaxErrorMessage", ")", "{", "exception", "=", "(", "(", "SyntaxErrorMessage", ")", "message", ")", ".", "getCause", "(", ")", ";", "}", "return", "exception", ";", "}", "public", "Exception", "getException", "(", "int", "index", ")", "{", "Exception", "exception", "=", "null", ";", "Message", "message", "=", "getError", "(", "index", ")", ";", "if", "(", "message", "!=", "null", ")", "{", "if", "(", "message", "instanceof", "ExceptionMessage", ")", "{", "exception", "=", "(", "(", "ExceptionMessage", ")", "message", ")", ".", "getCause", "(", ")", ";", "}", "else", "if", "(", "message", "instanceof", "SyntaxErrorMessage", ")", "{", "exception", "=", "(", "(", "SyntaxErrorMessage", ")", "message", ")", ".", "getCause", "(", ")", ";", "}", "}", "return", "exception", ";", "}", "public", "void", "addWarning", "(", "WarningMessage", "message", ")", "{", "if", "(", "message", ".", "isRelevant", "(", "configuration", ".", "getWarningLevel", "(", ")", ")", ")", "{", "if", "(", "this", ".", "warnings", "==", "null", ")", "{", "this", ".", "warnings", "=", "new", "LinkedList", "(", ")", ";", "}", "this", ".", "warnings", ".", "add", "(", "message", ")", ";", "}", "}", "public", "void", "addWarning", "(", "int", "importance", ",", "String", "text", ",", "CSTNode", "context", ",", "SourceUnit", "source", ")", "{", "if", "(", "WarningMessage", ".", "isRelevant", "(", "importance", ",", "configuration", ".", "getWarningLevel", "(", ")", ")", ")", "{", "addWarning", "(", "new", "WarningMessage", "(", "importance", ",", "text", ",", "context", ",", "source", ")", ")", ";", "}", "}", "public", "void", "addWarning", "(", "int", "importance", ",", "String", "text", ",", "Object", "data", ",", "CSTNode", "context", ",", "SourceUnit", "source", ")", "{", "if", "(", "WarningMessage", ".", "isRelevant", "(", "importance", ",", "configuration", ".", "getWarningLevel", "(", ")", ")", ")", "{", "addWarning", "(", "new", "WarningMessage", "(", "importance", ",", "text", ",", "data", ",", "context", ",", "source", ")", ")", ";", "}", "}", "protected", "void", "failIfErrors", "(", ")", "throws", "CompilationFailedException", "{", "if", "(", "hasErrors", "(", ")", ")", "{", "throw", "new", "MultipleCompilationErrorsException", "(", "this", ")", ";", "}", "}", "private", "void", "write", "(", "PrintWriter", "writer", ",", "Janitor", "janitor", ",", "List", "messages", ",", "String", "txt", ")", "{", "if", "(", "messages", "==", "null", "||", "messages", ".", "size", "(", ")", "==", "0", ")", "return", ";", "Iterator", "iterator", "=", "messages", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "Message", "message", "=", "(", "Message", ")", "iterator", ".", "next", "(", ")", ";", "message", ".", "write", "(", "writer", ",", "janitor", ")", ";", "if", "(", "configuration", ".", "getDebug", "(", ")", "&&", "(", "message", "instanceof", "SyntaxErrorMessage", ")", ")", "{", "SyntaxErrorMessage", "sem", "=", "(", "SyntaxErrorMessage", ")", "message", ";", "sem", ".", "getCause", "(", ")", ".", "printStackTrace", "(", "writer", ")", ";", "}", "writer", ".", "println", "(", ")", ";", "}", "writer", ".", "print", "(", "messages", ".", "size", "(", ")", ")", ";", "writer", ".", "print", "(", "\"", "\"", "+", "txt", ")", ";", "if", "(", "messages", ".", "size", "(", ")", ">", "1", ")", "writer", ".", "print", "(", "\"s\"", ")", ";", "writer", ".", "println", "(", ")", ";", "}", "public", "void", "write", "(", "PrintWriter", "writer", ",", "Janitor", "janitor", ")", "{", "write", "(", "writer", ",", "janitor", ",", "warnings", ",", "\"warning\"", ")", ";", "write", "(", "writer", ",", "janitor", ",", "errors", ",", "\"error\"", ")", ";", "}", "}", "</s>" ]
6,936
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "control", ";", "import", "groovy", ".", "lang", ".", "GroovyClassLoader", ";", "public", "abstract", "class", "ProcessingUnit", "{", "protected", "int", "phase", ";", "protected", "boolean", "phaseComplete", ";", "protected", "int", "erroredAtPhase", "=", "-", "1", ";", "protected", "CompilerConfiguration", "configuration", ";", "protected", "GroovyClassLoader", "classLoader", ";", "protected", "ErrorCollector", "errorCollector", ";", "public", "ProcessingUnit", "(", "CompilerConfiguration", "configuration", ",", "GroovyClassLoader", "classLoader", ",", "ErrorCollector", "er", ")", "{", "this", ".", "phase", "=", "Phases", ".", "INITIALIZATION", ";", "this", ".", "configuration", "=", "configuration", ";", "this", ".", "setClassLoader", "(", "classLoader", ")", ";", "configure", "(", "(", "configuration", "==", "null", "?", "new", "CompilerConfiguration", "(", ")", ":", "configuration", ")", ")", ";", "if", "(", "er", "==", "null", ")", "er", "=", "new", "ErrorCollector", "(", "getConfiguration", "(", ")", ")", ";", "this", ".", "errorCollector", "=", "er", ";", "}", "public", "void", "configure", "(", "CompilerConfiguration", "configuration", ")", "{", "this", ".", "configuration", "=", "configuration", ";", "}", "public", "CompilerConfiguration", "getConfiguration", "(", ")", "{", "return", "configuration", ";", "}", "public", "void", "setConfiguration", "(", "CompilerConfiguration", "configuration", ")", "{", "this", ".", "configuration", "=", "configuration", ";", "}", "public", "GroovyClassLoader", "getClassLoader", "(", ")", "{", "return", "classLoader", ";", "}", "public", "void", "setClassLoader", "(", "GroovyClassLoader", "loader", ")", "{", "ClassLoader", "parent", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "if", "(", "parent", "==", "null", ")", "parent", "=", "ProcessingUnit", ".", "class", ".", "getClassLoader", "(", ")", ";", "this", ".", "classLoader", "=", "(", "loader", "==", "null", "?", "new", "GroovyClassLoader", "(", "parent", ",", "configuration", ")", ":", "loader", ")", ";", "}", "public", "int", "getPhase", "(", ")", "{", "return", "this", ".", "phase", ";", "}", "public", "String", "getPhaseDescription", "(", ")", "{", "return", "Phases", ".", "getDescription", "(", "this", ".", "phase", ")", ";", "}", "public", "ErrorCollector", "getErrorCollector", "(", ")", "{", "return", "errorCollector", ";", "}", "public", "void", "completePhase", "(", ")", "throws", "CompilationFailedException", "{", "if", "(", "errorCollector", ".", "hasErrors", "(", ")", ")", "{", "erroredAtPhase", "=", "phase", ";", "}", "phaseComplete", "=", "true", ";", "}", "public", "void", "nextPhase", "(", ")", "throws", "CompilationFailedException", "{", "gotoPhase", "(", "this", ".", "phase", "+", "1", ")", ";", "}", "public", "void", "gotoPhase", "(", "int", "phase", ")", "throws", "CompilationFailedException", "{", "if", "(", "!", "this", ".", "phaseComplete", ")", "{", "completePhase", "(", ")", ";", "}", "this", ".", "phase", "=", "phase", ";", "this", ".", "phaseComplete", "=", "false", ";", "}", "}", "</s>" ]
6,937
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ";", "import", "java", ".", "io", ".", "PrintWriter", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "Janitor", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "SourceUnit", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "CSTNode", ";", "public", "class", "LocatedMessage", "extends", "SimpleMessage", "{", "protected", "CSTNode", "context", ";", "public", "LocatedMessage", "(", "String", "message", ",", "CSTNode", "context", ",", "SourceUnit", "source", ")", "{", "super", "(", "message", ",", "source", ")", ";", "this", ".", "context", "=", "context", ";", "}", "public", "LocatedMessage", "(", "String", "message", ",", "Object", "data", ",", "CSTNode", "context", ",", "SourceUnit", "source", ")", "{", "super", "(", "message", ",", "data", ",", "source", ")", ";", "this", ".", "context", "=", "context", ";", "}", "public", "CSTNode", "getContext", "(", ")", "{", "return", "context", ";", "}", "public", "void", "write", "(", "PrintWriter", "writer", ",", "Janitor", "janitor", ")", "{", "if", "(", "owner", "instanceof", "SourceUnit", ")", "{", "SourceUnit", "source", "=", "(", "SourceUnit", ")", "owner", ";", "String", "name", "=", "source", ".", "getName", "(", ")", ";", "int", "line", "=", "context", ".", "getStartLine", "(", ")", ";", "int", "column", "=", "context", ".", "getStartColumn", "(", ")", ";", "String", "sample", "=", "source", ".", "getSample", "(", "line", ",", "column", ",", "janitor", ")", ";", "if", "(", "sample", "!=", "null", ")", "{", "writer", ".", "println", "(", "source", ".", "getSample", "(", "line", ",", "column", ",", "janitor", ")", ")", ";", "}", "writer", ".", "println", "(", "name", "+", "\":", "\"", "+", "line", "+", "\":", "\"", "+", "this", ".", "message", ")", ";", "writer", ".", "println", "(", "\"\"", ")", ";", "}", "else", "{", "writer", ".", "println", "(", "\"\"", "+", "this", ".", "message", ")", ";", "writer", ".", "println", "(", "\"\"", ")", ";", "}", "}", "}", "</s>" ]
6,938
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "control", ";", "import", "groovy", ".", "lang", ".", "GroovyClassLoader", ";", "import", "groovy", ".", "lang", ".", "GroovyRuntimeException", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "GroovyBugError", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "classgen", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "customizers", ".", "CompilationCustomizer", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "io", ".", "InputStreamReaderSource", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "io", ".", "ReaderSource", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "ExceptionMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "Message", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "control", ".", "messages", ".", "SimpleMessage", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "SyntaxException", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "tools", ".", "GroovyClass", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "transform", ".", "ASTTransformationVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "ClassVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "ClassWriter", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "security", ".", "CodeSource", ";", "import", "java", ".", "util", ".", "*", ";", "public", "class", "CompilationUnit", "extends", "ProcessingUnit", "{", "protected", "ASTTransformationsContext", "astTransformationsContext", ";", "protected", "Map", "<", "String", ",", "SourceUnit", ">", "sources", ";", "protected", "Map", "summariesBySourceName", ";", "protected", "Map", "summariesByPublicClassName", ";", "protected", "Map", "classSourcesByPublicClassName", ";", "protected", "List", "<", "String", ">", "names", ";", "protected", "LinkedList", "<", "SourceUnit", ">", "queuedSources", ";", "protected", "CompileUnit", "ast", ";", "protected", "List", "<", "GroovyClass", ">", "generatedClasses", ";", "protected", "Verifier", "verifier", ";", "protected", "boolean", "debug", ";", "protected", "boolean", "configured", ";", "protected", "ClassgenCallback", "classgenCallback", ";", "protected", "ProgressCallback", "progressCallback", ";", "protected", "ResolveVisitor", "resolveVisitor", ";", "protected", "StaticImportVisitor", "staticImportVisitor", ";", "protected", "OptimizerVisitor", "optimizer", ";", "protected", "ClassNodeResolver", "classNodeResolver", ";", "LinkedList", "[", "]", "phaseOperations", ";", "LinkedList", "[", "]", "newPhaseOperations", ";", "public", "CompilationUnit", "(", ")", "{", "this", "(", "null", ",", "null", ",", "null", ")", ";", "}", "public", "CompilationUnit", "(", "GroovyClassLoader", "loader", ")", "{", "this", "(", "null", ",", "null", ",", "loader", ")", ";", "}", "public", "CompilationUnit", "(", "CompilerConfiguration", "configuration", ")", "{", "this", "(", "configuration", ",", "null", ",", "null", ")", ";", "}", "public", "CompilationUnit", "(", "CompilerConfiguration", "configuration", ",", "CodeSource", "security", ",", "GroovyClassLoader", "loader", ")", "{", "this", "(", "configuration", ",", "security", ",", "loader", ",", "null", ",", "true", ",", "null", ")", ";", "}", "public", "CompilationUnit", "(", "CompilerConfiguration", "configuration", ",", "CodeSource", "security", ",", "GroovyClassLoader", "loader", ",", "GroovyClassLoader", "transformLoader", ",", "boolean", "allowTransforms", ",", "String", "localTransformsToRunOnReconcile", ")", "{", "super", "(", "configuration", ",", "loader", ",", "null", ")", ";", "this", ".", "allowTransforms", "=", "allowTransforms", ";", "this", ".", "astTransformationsContext", "=", "new", "ASTTransformationsContext", "(", "this", ",", "transformLoader", ")", ";", "this", ".", "names", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "this", ".", "queuedSources", "=", "new", "LinkedList", "<", "SourceUnit", ">", "(", ")", ";", "this", ".", "sources", "=", "new", "HashMap", "<", "String", ",", "SourceUnit", ">", "(", ")", ";", "this", ".", "summariesBySourceName", "=", "new", "HashMap", "(", ")", ";", "this", ".", "summariesByPublicClassName", "=", "new", "HashMap", "(", ")", ";", "this", ".", "classSourcesByPublicClassName", "=", "new", "HashMap", "(", ")", ";", "this", ".", "ast", "=", "new", "CompileUnit", "(", "this", ".", "classLoader", ",", "security", ",", "this", ".", "configuration", ")", ";", "this", ".", "generatedClasses", "=", "new", "ArrayList", "<", "GroovyClass", ">", "(", ")", ";", "this", ".", "verifier", "=", "new", "Verifier", "(", ")", ";", "this", ".", "resolveVisitor", "=", "new", "ResolveVisitor", "(", "this", ")", ";", "this", ".", "staticImportVisitor", "=", "new", "StaticImportVisitor", "(", ")", ";", "this", ".", "optimizer", "=", "new", "OptimizerVisitor", "(", "this", ")", ";", "if", "(", "localTransformsToRunOnReconcile", "==", "null", ")", "{", "this", ".", "localTransformsToRunOnReconcile", "=", "Collections", ".", "emptyList", "(", ")", ";", "}", "else", "{", "this", ".", "localTransformsToRunOnReconcile", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "try", "{", "StringTokenizer", "st", "=", "new", "StringTokenizer", "(", "localTransformsToRunOnReconcile", ",", "\",\"", ")", ";", "while", "(", "st", ".", "hasMoreElements", "(", ")", ")", "{", "String", "classname", "=", "st", ".", "nextToken", "(", ")", ";", "this", ".", "localTransformsToRunOnReconcile", ".", "add", "(", "classname", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "phaseOperations", "=", "new", "LinkedList", "[", "Phases", ".", "ALL", "+", "1", "]", ";", "newPhaseOperations", "=", "new", "LinkedList", "[", "Phases", ".", "ALL", "+", "1", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "phaseOperations", ".", "length", ";", "i", "++", ")", "{", "phaseOperations", "[", "i", "]", "=", "new", "LinkedList", "(", ")", ";", "newPhaseOperations", "[", "i", "]", "=", "new", "LinkedList", "(", ")", ";", "}", "addPhaseOperation", "(", "new", "SourceUnitOperation", "(", ")", "{", "public", "void", "call", "(", "SourceUnit", "source", ")", "throws", "CompilationFailedException", "{", "source", ".", "parse", "(", ")", ";", "}", "}", ",", "Phases", ".", "PARSING", ")", ";", "addPhaseOperation", "(", "convert", ",", "Phases", ".", "CONVERSION", ")", ";", "addPhaseOperation", "(", "new", "PrimaryClassNodeOperation", "(", ")", "{", "public", "void", "call", "(", "SourceUnit", "source", ",", "GeneratorContext", "context", ",", "ClassNode", "classNode", ")", "throws", "CompilationFailedException", "{", "EnumVisitor", "ev", "=", "new", "EnumVisitor", "(", "CompilationUnit", ".", "this", ",", "source", ")", ";", "ev", ".", "visitClass", "(", "classNode", ")", ";", "}", "}", ",", "Phases", ".", "CONVERSION", ")", ";", "addPhaseOperation", "(", "resolve", ",", "Phases", ".", "SEMANTIC_ANALYSIS", ")", ";", "addPhaseOperation", "(", "staticImport", ",", "Phases", ".", "SEMANTIC_ANALYSIS", ")", ";", "addPhaseOperation", "(", "new", "PrimaryClassNodeOperation", "(", ")", "{", "@", "Override", "public", "void", "call", "(", "SourceUnit", "source", ",", "GeneratorContext", "context", ",", "ClassNode", "classNode", ")", "throws", "CompilationFailedException", "{", "InnerClassVisitor", "iv", "=", "new", "InnerClassVisitor", "(", "CompilationUnit", ".", "this", ",", "source", ")", ";", "iv", ".", "visitClass", "(", "classNode", ")", ";", "}", "}", ",", "Phases", ".", "SEMANTIC_ANALYSIS", ")", ";", "addPhaseOperation", "(", "compileCompleteCheck", ",", "Phases", ".", "CANONICALIZATION", ")", ";", "addPhaseOperation", "(", "classgen", ",", "Phases", ".", "CLASS_GENERATION", ")", ";", "ASTTransformationVisitor", ".", "addPhaseOperations", "(", "this", ")", ";", "addPhaseOperation", "(", "new", "PrimaryClassNodeOperation", "(", ")", "{", "@", "Override", "public", "void", "call", "(", "SourceUnit", "source", ",", "GeneratorContext", "context", ",", "ClassNode", "classNode", ")", "throws", "CompilationFailedException", "{", "StaticVerifier", "sv", "=", "new", "StaticVerifier", "(", ")", ";", "sv", ".", "visitClass", "(", "classNode", ",", "source", ")", ";", "}", "}", ",", "Phases", ".", "SEMANTIC_ANALYSIS", ")", ";", "addPhaseOperation", "(", "new", "PrimaryClassNodeOperation", "(", ")", "{", "@", "Override", "public", "void", "call", "(", "SourceUnit", "source", ",", "GeneratorContext", "context", ",", "ClassNode", "classNode", ")", "throws", "CompilationFailedException", "{", "InnerClassCompletionVisitor", "iv", "=", "new", "InnerClassCompletionVisitor", "(", "CompilationUnit", ".", "this", ",", "source", ")", ";", "iv", ".", "visitClass", "(", "classNode", ")", ";", "}", "}", ",", "Phases", ".", "CANONICALIZATION", ")", ";", "addPhaseOperation", "(", "new", "PrimaryClassNodeOperation", "(", ")", "{", "public", "void", "call", "(", "SourceUnit", "source", ",", "GeneratorContext", "context", ",", "ClassNode", "classNode", ")", "throws", "CompilationFailedException", "{", "EnumCompletionVisitor", "ecv", "=", "new", "EnumCompletionVisitor", "(", "CompilationUnit", ".", "this", ",", "source", ")", ";", "ecv", ".", "visitClass", "(", "classNode", ")", ";", "}", "}", ",", "Phases", ".", "CANONICALIZATION", ")", ";", "if", "(", "configuration", "!=", "null", ")", "{", "final", "List", "<", "CompilationCustomizer", ">", "customizers", "=", "configuration", ".", "getCompilationCustomizers", "(", ")", ";", "for", "(", "CompilationCustomizer", "customizer", ":", "customizers", ")", "{", "addPhaseOperation", "(", "customizer", ",", "customizer", ".", "getPhase", "(", ")", ".", "getPhaseNumber", "(", ")", ")", ";", "}", "}", "this", ".", "classgenCallback", "=", "null", ";", "this", ".", "classNodeResolver", "=", "new", "ClassNodeResolver", "(", ")", ";", "}", "public", "void", "ensureASTTransformVisitorAdded", "(", ")", "{", "ASTTransformationVisitor", ".", "addPhaseOperations", "(", "this", ")", ";", "}", "public", "GroovyClassLoader", "getTransformLoader", "(", ")", "{", "return", "astTransformationsContext", ".", "getTransformLoader", "(", ")", "==", "null", "?", "getClassLoader", "(", ")", ":", "astTransformationsContext", ".", "getTransformLoader", "(", ")", ";", "}", "public", "void", "addPhaseOperation", "(", "SourceUnitOperation", "op", ",", "int", "phase", ")", "{", "if", "(", "phase", "<", "0", "||", "phase", ">", "Phases", ".", "ALL", ")", "throw", "new", "IllegalArgumentException", "(", "\"phase", "\"", "+", "phase", "+", "\"", "is", "unknown\"", ")", ";", "phaseOperations", "[", "phase", "]", ".", "add", "(", "op", ")", ";", "}", "public", "void", "addPhaseOperation", "(", "PrimaryClassNodeOperation", "op", ",", "int", "phase", ")", "{", "if", "(", "phase", "<", "0", "||", "phase", ">", "Phases", ".", "ALL", ")", "throw", "new", "IllegalArgumentException", "(", "\"phase", "\"", "+", "phase", "+", "\"", "is", "unknown\"", ")", ";", "phaseOperations", "[", "phase", "]", ".", "add", "(", "op", ")", ";", "}", "public", "void", "addPhaseOperation", "(", "GroovyClassOperation", "op", ")", "{", "phaseOperations", "[", "Phases", ".", "OUTPUT", "]", ".", "addFirst", "(", "op", ")", ";", "}", "public", "void", "addNewPhaseOperation", "(", "SourceUnitOperation", "op", ",", "int", "phase", ")", "{", "if", "(", "phase", "<", "0", "||", "phase", ">", "Phases", ".", "ALL", ")", "throw", "new", "IllegalArgumentException", "(", "\"phase", "\"", "+", "phase", "+", "\"", "is", "unknown\"", ")", ";", "newPhaseOperations", "[", "phase", "]", ".", "add", "(", "op", ")", ";", "}", "public", "boolean", "removeOutputPhaseOperation", "(", ")", "{", "return", "phaseOperations", "[", "Phases", ".", "OUTPUT", "]", ".", "remove", "(", "output", ")", ";", "}", "public", "void", "configure", "(", "CompilerConfiguration", "configuration", ")", "{", "super", ".", "configure", "(", "configuration", ")", ";", "this", ".", "debug", "=", "configuration", ".", "getDebug", "(", ")", ";", "if", "(", "!", "this", ".", "configured", "&&", "this", ".", "classLoader", "instanceof", "GroovyClassLoader", ")", "{", "appendCompilerConfigurationClasspathToClassLoader", "(", "configuration", ",", "(", "GroovyClassLoader", ")", "this", ".", "classLoader", ")", ";", "}", "this", ".", "configured", "=", "true", ";", "}", "private", "void", "appendCompilerConfigurationClasspathToClassLoader", "(", "CompilerConfiguration", "configuration", ",", "GroovyClassLoader", "classLoader", ")", "{", "}", "public", "CompileUnit", "getAST", "(", ")", "{", "return", "this", ".", "ast", ";", "}", "public", "Map", "getSummariesBySourceName", "(", ")", "{", "return", "summariesBySourceName", ";", "}", "public", "Map", "getSummariesByPublicClassName", "(", ")", "{", "return", "summariesByPublicClassName", ";", "}", "public", "Map", "getClassSourcesByPublicClassName", "(", ")", "{", "return", "classSourcesByPublicClassName", ";", "}", "public", "boolean", "isPublicClass", "(", "String", "className", ")", "{", "return", "summariesByPublicClassName", ".", "containsKey", "(", "className", ")", ";", "}", "public", "List", "getClasses", "(", ")", "{", "return", "generatedClasses", ";", "}", "public", "ClassNode", "getFirstClassNode", "(", ")", "{", "return", "this", ".", "ast", ".", "getModules", "(", ")", ".", "get", "(", "0", ")", ".", "getClasses", "(", ")", ".", "get", "(", "0", ")", ";", "}", "public", "ClassNode", "getClassNode", "(", "final", "String", "name", ")", "{", "final", "ClassNode", "[", "]", "result", "=", "new", "ClassNode", "[", "]", "{", "null", "}", ";", "PrimaryClassNodeOperation", "handler", "=", "new", "PrimaryClassNodeOperation", "(", ")", "{", "public", "void", "call", "(", "SourceUnit", "source", ",", "GeneratorContext", "context", ",", "ClassNode", "classNode", ")", "{", "if", "(", "classNode", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "result", "[", "0", "]", "=", "classNode", ";", "}", "}", "}", ";", "try", "{", "applyToPrimaryClassNodes", "(", "handler", ")", ";", "}", "catch", "(", "CompilationFailedException", "e", ")", "{", "if", "(", "debug", ")", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "result", "[", "0", "]", ";", "}", "public", "ASTTransformationsContext", "getASTTransformationsContext", "(", ")", "{", "return", "astTransformationsContext", ";", "}", "public", "void", "addSources", "(", "String", "[", "]", "paths", ")", "{", "for", "(", "String", "path", ":", "paths", ")", "{", "addSource", "(", "new", "File", "(", "path", ")", ")", ";", "}", "}", "public", "void", "addSources", "(", "File", "[", "]", "files", ")", "{", "for", "(", "File", "file", ":", "files", ")", "{", "addSource", "(", "file", ")", ";", "}", "}", "public", "SourceUnit", "addSource", "(", "File", "file", ")", "{", "return", "addSource", "(", "new", "SourceUnit", "(", "file", ",", "configuration", ",", "classLoader", ",", "getErrorCollector", "(", ")", ")", ")", ";", "}", "public", "SourceUnit", "addSource", "(", "URL", "url", ")", "{", "return", "addSource", "(", "new", "SourceUnit", "(", "url", ",", "configuration", ",", "classLoader", ",", "getErrorCollector", "(", ")", ")", ")", ";", "}", "public", "SourceUnit", "addSource", "(", "String", "name", ",", "InputStream", "stream", ")", "{", "ReaderSource", "source", "=", "new", "InputStreamReaderSource", "(", "stream", ",", "configuration", ")", ";", "return", "addSource", "(", "new", "SourceUnit", "(", "name", ",", "source", ",", "configuration", ",", "classLoader", ",", "getErrorCollector", "(", ")", ")", ")", ";", "}", "public", "SourceUnit", "addSource", "(", "String", "name", ",", "String", "scriptText", ")", "{", "return", "addSource", "(", "new", "SourceUnit", "(", "name", ",", "scriptText", ",", "configuration", ",", "classLoader", ",", "getErrorCollector", "(", ")", ")", ")", ";", "}", "public", "SourceUnit", "addSource", "(", "SourceUnit", "source", ")", "{", "String", "name", "=", "source", ".", "getName", "(", ")", ";", "source", ".", "setClassLoader", "(", "this", ".", "classLoader", ")", ";", "for", "(", "SourceUnit", "su", ":", "queuedSources", ")", "{", "if", "(", "name", ".", "equals", "(", "su", ".", "getName", "(", ")", ")", ")", "return", "su", ";", "}", "if", "(", "iterating", ")", "{", "GroovyBugError", "gbe", "=", "new", "GroovyBugError", "(", "\"\"", "+", "source", ".", "getName", "(", ")", "+", "\"'\"", ")", ";", "gbe", ".", "printStackTrace", "(", ")", ";", "throw", "gbe", ";", "}", "queuedSources", ".", "add", "(", "source", ")", ";", "return", "source", ";", "}", "public", "Iterator", "<", "SourceUnit", ">", "iterator", "(", ")", "{", "return", "new", "Iterator", "<", "SourceUnit", ">", "(", ")", "{", "Iterator", "<", "String", ">", "nameIterator", "=", "names", ".", "iterator", "(", ")", ";", "public", "boolean", "hasNext", "(", ")", "{", "return", "nameIterator", ".", "hasNext", "(", ")", ";", "}", "public", "SourceUnit", "next", "(", ")", "{", "String", "name", "=", "nameIterator", ".", "next", "(", ")", ";", "return", "sources", ".", "get", "(", "name", ")", ";", "}", "public", "void", "remove", "(", ")", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "}", ";", "}", "public", "void", "addClassNode", "(", "ClassNode", "node", ")", "{", "ModuleNode", "module", "=", "new", "ModuleNode", "(", "this", ".", "ast", ")", ";", "this", ".", "ast", ".", "addModule", "(", "module", ")", ";", "module", ".", "addClass", "(", "node", ")", ";", "}", "public", "abstract", "static", "class", "ClassgenCallback", "{", "public", "abstract", "void", "call", "(", "ClassVisitor", "writer", ",", "ClassNode", "node", ")", "throws", "CompilationFailedException", ";", "}", "public", "void", "setClassgenCallback", "(", "ClassgenCallback", "visitor", ")", "{", "this", ".", "classgenCallback", "=", "visitor", ";", "}", "public", "abstract", "static", "class", "ProgressCallback", "{", "public", "abstract", "void", "call", "(", "ProcessingUnit", "context", ",", "int", "phase", ")", "throws", "CompilationFailedException", ";", "}", "public", "interface", "ProgressListener", "{", "void", "parseComplete", "(", "int", "phase", ",", "String", "sourceUnitName", ")", ";", "void", "generateComplete", "(", "int", "phase", ",", "ClassNode", "classNode", ")", ";", "}", "private", "ProgressListener", "getProgressListener", "(", ")", "{", "return", "this", ".", "listener", ";", "}", "public", "void", "setProgressListener", "(", "ProgressListener", "listener", ")", "{", "this", ".", "listener", "=", "listener", ";", "}", "private", "ProgressListener", "listener", ";", "public", "void", "setProgressCallback", "(", "ProgressCallback", "callback", ")", "{", "this", ".", "progressCallback", "=", "callback", ";", "}", "public", "ClassgenCallback", "getClassgenCallback", "(", ")", "{", "return", "classgenCallback", ";", "}", "public", "ProgressCallback", "getProgressCallback", "(", ")", "{", "return", "progressCallback", ";", "}", "public", "void", "compile", "(", ")", "throws", "CompilationFailedException", "{", "compile", "(", "Phases", ".", "ALL", ")", ";", "}", "public", "void", "compile", "(", "int", "throughPhase", ")", "throws", "CompilationFailedException", "{", "gotoPhase", "(", "Phases", ".", "INITIALIZATION", ")", ";", "throughPhase", "=", "Math", ".", "min", "(", "throughPhase", ",", "Phases", ".", "ALL", ")", ";", "while", "(", "throughPhase", ">=", "phase", "&&", "phase", "<=", "Phases", ".", "ALL", ")", "{", "if", "(", "phase", "==", "Phases", ".", "SEMANTIC_ANALYSIS", ")", "{", "doPhaseOperation", "(", "resolve", ")", ";", "if", "(", "dequeued", "(", ")", ")", "continue", ";", "}", "processPhaseOperations", "(", "phase", ")", ";", "processNewPhaseOperations", "(", "phase", ")", ";", "if", "(", "progressCallback", "!=", "null", ")", "progressCallback", ".", "call", "(", "this", ",", "phase", ")", ";", "completePhase", "(", ")", ";", "applyToSourceUnits", "(", "mark", ")", ";", "if", "(", "dequeued", "(", ")", ")", "continue", ";", "gotoPhase", "(", "phase", "+", "1", ")", ";", "if", "(", "phase", "==", "Phases", ".", "CLASS_GENERATION", ")", "{", "sortClasses", "(", ")", ";", "}", "}", "errorCollector", ".", "failIfErrors", "(", ")", ";", "}", "private", "void", "processPhaseOperations", "(", "int", "ph", ")", "{", "LinkedList", "ops", "=", "phaseOperations", "[", "ph", "]", ";", "for", "(", "Object", "next", ":", "ops", ")", "{", "doPhaseOperation", "(", "next", ")", ";", "}", "}", "private", "void", "processNewPhaseOperations", "(", "int", "currPhase", ")", "{", "recordPhaseOpsInAllOtherPhases", "(", "currPhase", ")", ";", "LinkedList", "currentPhaseNewOps", "=", "newPhaseOperations", "[", "currPhase", "]", ";", "while", "(", "!", "currentPhaseNewOps", ".", "isEmpty", "(", ")", ")", "{", "Object", "operation", "=", "currentPhaseNewOps", ".", "removeFirst", "(", ")", ";", "phaseOperations", "[", "currPhase", "]", ".", "add", "(", "operation", ")", ";", "doPhaseOperation", "(", "operation", ")", ";", "recordPhaseOpsInAllOtherPhases", "(", "currPhase", ")", ";", "currentPhaseNewOps", "=", "newPhaseOperations", "[", "currPhase", "]", ";", "}", "}", "private", "void", "doPhaseOperation", "(", "Object", "operation", ")", "{", "if", "(", "operation", "instanceof", "PrimaryClassNodeOperation", ")", "{", "applyToPrimaryClassNodes", "(", "(", "PrimaryClassNodeOperation", ")", "operation", ")", ";", "}", "else", "if", "(", "operation", "instanceof", "SourceUnitOperation", ")", "{", "applyToSourceUnits", "(", "(", "SourceUnitOperation", ")", "operation", ")", ";", "}", "else", "{", "applyToGeneratedGroovyClasses", "(", "(", "GroovyClassOperation", ")", "operation", ")", ";", "}", "}", "private", "void", "recordPhaseOpsInAllOtherPhases", "(", "int", "currPhase", ")", "{", "for", "(", "int", "ph", "=", "Phases", ".", "INITIALIZATION", ";", "ph", "<=", "Phases", ".", "ALL", ";", "ph", "++", ")", "{", "if", "(", "ph", "!=", "currPhase", "&&", "!", "newPhaseOperations", "[", "ph", "]", ".", "isEmpty", "(", ")", ")", "{", "phaseOperations", "[", "ph", "]", ".", "addAll", "(", "newPhaseOperations", "[", "ph", "]", ")", ";", "newPhaseOperations", "[", "ph", "]", ".", "clear", "(", ")", ";", "}", "}", "}", "private", "void", "sortClasses", "(", ")", "throws", "CompilationFailedException", "{", "for", "(", "ModuleNode", "module", ":", "this", ".", "ast", ".", "getModules", "(", ")", ")", "{", "module", ".", "sortClasses", "(", ")", ";", "}", "}", "protected", "boolean", "dequeued", "(", ")", "throws", "CompilationFailedException", "{", "boolean", "dequeue", "=", "!", "queuedSources", ".", "isEmpty", "(", ")", ";", "while", "(", "!", "queuedSources", ".", "isEmpty", "(", ")", ")", "{", "SourceUnit", "su", "=", "queuedSources", ".", "removeFirst", "(", ")", ";", "String", "name", "=", "su", ".", "getName", "(", ")", ";", "if", "(", "iterating", ")", "{", "GroovyBugError", "gbe", "=", "new", "GroovyBugError", "(", "\"\"", "+", "su", ".", "getName", "(", ")", "+", "\"'\"", ")", ";", "gbe", ".", "printStackTrace", "(", ")", ";", "throw", "gbe", ";", "}", "names", ".", "add", "(", "name", ")", ";", "sources", ".", "put", "(", "name", ",", "su", ")", ";", "}", "if", "(", "dequeue", ")", "{", "gotoPhase", "(", "Phases", ".", "INITIALIZATION", ")", ";", "}", "return", "dequeue", ";", "}", "private", "final", "SourceUnitOperation", "resolve", "=", "new", "SourceUnitOperation", "(", ")", "{", "public", "void", "call", "(", "SourceUnit", "source", ")", "throws", "CompilationFailedException", "{", "List", "<", "ClassNode", ">", "classes", "=", "source", ".", "ast", ".", "getClasses", "(", ")", ";", "for", "(", "ClassNode", "node", ":", "classes", ")", "{", "VariableScopeVisitor", "scopeVisitor", "=", "new", "VariableScopeVisitor", "(", "source", ")", ";", "scopeVisitor", ".", "visitClass", "(", "node", ")", ";", "resolveVisitor", ".", "setClassNodeResolver", "(", "classNodeResolver", ")", ";", "resolveVisitor", ".", "startResolving", "(", "node", ",", "source", ")", ";", "}", "}", "}", ";", "private", "PrimaryClassNodeOperation", "staticImport", "=", "new", "PrimaryClassNodeOperation", "(", ")", "{", "public", "void", "call", "(", "SourceUnit", "source", ",", "GeneratorContext", "context", ",", "ClassNode", "classNode", ")", "throws", "CompilationFailedException", "{", "staticImportVisitor", ".", "visitClass", "(", "classNode", ",", "source", ")", ";", "}", "}", ";", "private", "SourceUnitOperation", "convert", "=", "new", "SourceUnitOperation", "(", ")", "{", "public", "void", "call", "(", "SourceUnit", "source", ")", "throws", "CompilationFailedException", "{", "source", ".", "convert", "(", ")", ";", "CompilationUnit", ".", "this", ".", "ast", ".", "addModule", "(", "source", ".", "getAST", "(", ")", ")", ";", "if", "(", "CompilationUnit", ".", "this", ".", "progressCallback", "!=", "null", ")", "{", "CompilationUnit", ".", "this", ".", "progressCallback", ".", "call", "(", "source", ",", "CompilationUnit", ".", "this", ".", "phase", ")", ";", "}", "}", "}", ";", "private", "GroovyClassOperation", "output", "=", "new", "GroovyClassOperation", "(", ")", "{", "public", "void", "call", "(", "GroovyClass", "gclass", ")", "throws", "CompilationFailedException", "{", "String", "name", "=", "gclass", ".", "getName", "(", ")", ".", "replace", "(", "'.'", ",", "File", ".", "separatorChar", ")", "+", "\".class\"", ";", "File", "path", "=", "new", "File", "(", "configuration", ".", "getTargetDirectory", "(", ")", ",", "name", ")", ";", "File", "directory", "=", "path", ".", "getParentFile", "(", ")", ";", "if", "(", "directory", "!=", "null", "&&", "!", "directory", ".", "exists", "(", ")", ")", "{", "directory", ".", "mkdirs", "(", ")", ";", "}", "byte", "[", "]", "bytes", "=", "gclass", ".", "getBytes", "(", ")", ";", "FileOutputStream", "stream", "=", "null", ";", "try", "{", "stream", "=", "new", "FileOutputStream", "(", "path", ")", ";", "stream", ".", "write", "(", "bytes", ",", "0", ",", "bytes", ".", "length", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "getErrorCollector", "(", ")", ".", "addError", "(", "Message", ".", "create", "(", "e", ".", "getMessage", "(", ")", ",", "CompilationUnit", ".", "this", ")", ")", ";", "}", "finally", "{", "if", "(", "stream", "!=", "null", ")", "{", "try", "{", "stream", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "}", "}", "}", ";", "private", "SourceUnitOperation", "compileCompleteCheck", "=", "new", "SourceUnitOperation", "(", ")", "{", "public", "void", "call", "(", "SourceUnit", "source", ")", "throws", "CompilationFailedException", "{", "List", "<", "ClassNode", ">", "classes", "=", "source", ".", "ast", ".", "getClasses", "(", ")", ";", "for", "(", "ClassNode", "node", ":", "classes", ")", "{", "CompileUnit", "cu", "=", "node", ".", "getCompileUnit", "(", ")", ";", "for", "(", "Iterator", "iter", "=", "cu", ".", "iterateClassNodeToCompile", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "String", "name", "=", "(", "String", ")", "iter", ".", "next", "(", ")", ";", "SourceUnit", "su", "=", "ast", ".", "getScriptSourceLocation", "(", "name", ")", ";", "List", "<", "ClassNode", ">", "classesInSourceUnit", "=", "su", ".", "ast", ".", "getClasses", "(", ")", ";", "StringBuffer", "message", "=", "new", "StringBuffer", "(", ")", ";", "message", ".", "append", "(", "\"\"", ")", ".", "append", "(", "name", ")", ".", "append", "(", "\"", "in", "\"", ")", ".", "append", "(", "su", ".", "getName", "(", ")", ")", ";", "if", "(", "classesInSourceUnit", ".", "isEmpty", "(", ")", ")", "{", "message", ".", "append", "(", "\"\"", ")", ";", "}", "else", "{", "message", ".", "append", "(", "\"\"", ")", ";", "boolean", "first", "=", "true", ";", "for", "(", "ClassNode", "cn", ":", "classesInSourceUnit", ")", "{", "if", "(", "!", "first", ")", "{", "message", ".", "append", "(", "\",", "\"", ")", ";", "}", "else", "{", "first", "=", "false", ";", "}", "message", ".", "append", "(", "cn", ".", "getName", "(", ")", ")", ";", "}", "}", "getErrorCollector", "(", ")", ".", "addErrorAndContinue", "(", "new", "SimpleMessage", "(", "message", ".", "toString", "(", ")", ",", "CompilationUnit", ".", "this", ")", ")", ";", "iter", ".", "remove", "(", ")", ";", "}", "}", "}", "}", ";", "private", "PrimaryClassNodeOperation", "classgen", "=", "new", "PrimaryClassNodeOperation", "(", ")", "{", "public", "boolean", "needSortedInput", "(", ")", "{", "return", "true", ";", "}", "public", "void", "call", "(", "SourceUnit", "source", ",", "GeneratorContext", "context", ",", "ClassNode", "classNode", ")", "throws", "CompilationFailedException", "{", "optimizer", ".", "visitClass", "(", "classNode", ",", "source", ")", ";", "if", "(", "!", "classNode", ".", "isSynthetic", "(", ")", ")", "{", "GenericsVisitor", "genericsVisitor", "=", "new", "GenericsVisitor", "(", "source", ")", ";", "genericsVisitor", ".", "visitClass", "(", "classNode", ")", ";", "}", "try", "{", "verifier", ".", "visitClass", "(", "classNode", ")", ";", "}", "catch", "(", "GroovyRuntimeException", "rpe", ")", "{", "ASTNode", "node", "=", "rpe", ".", "getNode", "(", ")", ";", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "SyntaxException", "(", "rpe", ".", "getMessage", "(", ")", ",", "node", ".", "getLineNumber", "(", ")", ",", "node", ".", "getColumnNumber", "(", ")", ",", "node", ".", "getLastLineNumber", "(", ")", ",", "node", ".", "getLastColumnNumber", "(", ")", ")", ",", "source", ")", ";", "}", "LabelVerifier", "lv", "=", "new", "LabelVerifier", "(", "source", ")", ";", "lv", ".", "visitClass", "(", "classNode", ")", ";", "ClassCompletionVerifier", "completionVerifier", "=", "new", "ClassCompletionVerifier", "(", "source", ")", ";", "completionVerifier", ".", "visitClass", "(", "classNode", ")", ";", "ExtendedVerifier", "xverifier", "=", "new", "ExtendedVerifier", "(", "source", ")", ";", "xverifier", ".", "visitClass", "(", "classNode", ")", ";", "getErrorCollector", "(", ")", ".", "failIfErrors", "(", ")", ";", "ClassVisitor", "visitor", "=", "createClassVisitor", "(", ")", ";", "String", "sourceName", "=", "(", "source", "==", "null", "?", "classNode", ".", "getModule", "(", ")", ".", "getDescription", "(", ")", ":", "source", ".", "getName", "(", ")", ")", ";", "if", "(", "sourceName", "!=", "null", ")", "sourceName", "=", "sourceName", ".", "substring", "(", "Math", ".", "max", "(", "sourceName", ".", "lastIndexOf", "(", "'\\\\'", ")", ",", "sourceName", ".", "lastIndexOf", "(", "'/'", ")", ")", "+", "1", ")", ";", "AsmClassGenerator", "generator", "=", "new", "AsmClassGenerator", "(", "source", ",", "context", ",", "visitor", ",", "sourceName", ")", ";", "if", "(", "!", "source", ".", "getErrorCollector", "(", ")", ".", "hasErrors", "(", ")", ")", "{", "generator", ".", "visitClass", "(", "classNode", ")", ";", "byte", "[", "]", "bytes", "=", "(", "(", "ClassWriter", ")", "visitor", ")", ".", "toByteArray", "(", ")", ";", "generatedClasses", ".", "add", "(", "new", "GroovyClass", "(", "classNode", ".", "getName", "(", ")", ",", "bytes", ",", "classNode", ",", "source", ")", ")", ";", "if", "(", "CompilationUnit", ".", "this", ".", "classgenCallback", "!=", "null", ")", "{", "classgenCallback", ".", "call", "(", "visitor", ",", "classNode", ")", ";", "}", "LinkedList", "innerClasses", "=", "generator", ".", "getInnerClasses", "(", ")", ";", "while", "(", "!", "innerClasses", ".", "isEmpty", "(", ")", ")", "{", "classgen", ".", "call", "(", "source", ",", "context", ",", "(", "ClassNode", ")", "innerClasses", ".", "removeFirst", "(", ")", ")", ";", "}", "}", "}", "}", ";", "protected", "ClassVisitor", "createClassVisitor", "(", ")", "{", "CompilerConfiguration", "config", "=", "getConfiguration", "(", ")", ";", "int", "computeMaxStackAndFrames", "=", "ClassWriter", ".", "COMPUTE_MAXS", ";", "if", "(", "Boolean", ".", "TRUE", ".", "equals", "(", "config", ".", "getOptimizationOptions", "(", ")", ".", "get", "(", "\"indy\"", ")", ")", ")", "{", "computeMaxStackAndFrames", "+=", "ClassWriter", ".", "COMPUTE_FRAMES", ";", "}", "return", "new", "ClassWriter", "(", "computeMaxStackAndFrames", ")", "{", "private", "ClassNode", "getClassNode", "(", "String", "name", ")", "{", "CompileUnit", "cu", "=", "getAST", "(", ")", ";", "ClassNode", "cn", "=", "cu", ".", "getClass", "(", "name", ")", ";", "if", "(", "cn", "!=", "null", ")", "return", "cn", ";", "cn", "=", "cu", ".", "getGeneratedInnerClass", "(", "name", ")", ";", "if", "(", "cn", "!=", "null", ")", "return", "cn", ";", "try", "{", "cn", "=", "ClassHelper", ".", "make", "(", "cu", ".", "getClassLoader", "(", ")", ".", "loadClass", "(", "name", ",", "false", ",", "true", ")", ",", "false", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "GroovyBugError", "(", "e", ")", ";", "}", "return", "cn", ";", "}", "private", "ClassNode", "getCommonSuperClassNode", "(", "ClassNode", "c", ",", "ClassNode", "d", ")", "{", "if", "(", "c", ".", "isDerivedFrom", "(", "d", ")", ")", "return", "d", ";", "if", "(", "d", ".", "isDerivedFrom", "(", "c", ")", ")", "return", "c", ";", "if", "(", "c", ".", "isInterface", "(", ")", "||", "d", ".", "isInterface", "(", ")", ")", "return", "ClassHelper", ".", "OBJECT_TYPE", ";", "do", "{", "c", "=", "c", ".", "getSuperClass", "(", ")", ";", "}", "while", "(", "c", "!=", "null", "&&", "!", "d", ".", "isDerivedFrom", "(", "c", ")", ")", ";", "if", "(", "c", "==", "null", ")", "return", "ClassHelper", ".", "OBJECT_TYPE", ";", "return", "c", ";", "}", "@", "Override", "protected", "String", "getCommonSuperClass", "(", "String", "arg1", ",", "String", "arg2", ")", "{", "ClassNode", "a", "=", "getClassNode", "(", "arg1", ".", "replace", "(", "'/'", ",", "'.'", ")", ")", ";", "ClassNode", "b", "=", "getClassNode", "(", "arg2", ".", "replace", "(", "'/'", ",", "'.'", ")", ")", ";", "return", "getCommonSuperClassNode", "(", "a", ",", "b", ")", ".", "getName", "(", ")", ".", "replace", "(", "'.'", ",", "'/'", ")", ";", "}", "}", ";", "}", "protected", "void", "mark", "(", ")", "throws", "CompilationFailedException", "{", "applyToSourceUnits", "(", "mark", ")", ";", "}", "private", "SourceUnitOperation", "mark", "=", "new", "SourceUnitOperation", "(", ")", "{", "public", "void", "call", "(", "SourceUnit", "source", ")", "throws", "CompilationFailedException", "{", "if", "(", "source", ".", "phase", "<", "phase", ")", "{", "source", ".", "gotoPhase", "(", "phase", ")", ";", "}", "if", "(", "source", ".", "phase", "==", "phase", "&&", "phaseComplete", "&&", "!", "source", ".", "phaseComplete", ")", "{", "source", ".", "completePhase", "(", ")", ";", "}", "}", "}", ";", "public", "abstract", "static", "class", "SourceUnitOperation", "{", "public", "abstract", "void", "call", "(", "SourceUnit", "source", ")", "throws", "CompilationFailedException", ";", "}", "private", "boolean", "iterating", "=", "false", ";", "public", "void", "applyToSourceUnits", "(", "SourceUnitOperation", "body", ")", "throws", "CompilationFailedException", "{", "try", "{", "iterating", "=", "true", ";", "for", "(", "String", "name", ":", "names", ")", "{", "SourceUnit", "source", "=", "sources", ".", "get", "(", "name", ")", ";", "if", "(", "(", "source", ".", "phase", "<", "phase", ")", "||", "(", "source", ".", "phase", "==", "phase", "&&", "!", "source", ".", "phaseComplete", ")", ")", "{", "try", "{", "body", ".", "call", "(", "source", ")", ";", "if", "(", "phase", "==", "Phases", ".", "CONVERSION", "&&", "getProgressListener", "(", ")", "!=", "null", "&&", "body", "==", "phaseOperations", "[", "phase", "]", ".", "getLast", "(", ")", ")", "{", "getProgressListener", "(", ")", ".", "parseComplete", "(", "phase", ",", "name", ")", ";", "}", "}", "catch", "(", "CompilationFailedException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Exception", "e", ")", "{", "GroovyBugError", "gbe", "=", "new", "GroovyBugError", "(", "e", ")", ";", "changeBugText", "(", "gbe", ",", "source", ")", ";", "throw", "gbe", ";", "}", "catch", "(", "GroovyBugError", "e", ")", "{", "changeBugText", "(", "e", ",", "source", ")", ";", "throw", "e", ";", "}", "}", "}", "}", "finally", "{", "iterating", "=", "false", ";", "}", "getErrorCollector", "(", ")", ".", "failIfErrors", "(", ")", ";", "}", "public", "abstract", "static", "class", "PrimaryClassNodeOperation", "{", "public", "abstract", "void", "call", "(", "SourceUnit", "source", ",", "GeneratorContext", "context", ",", "ClassNode", "classNode", ")", "throws", "CompilationFailedException", ";", "public", "boolean", "needSortedInput", "(", ")", "{", "return", "false", ";", "}", "}", "public", "abstract", "static", "class", "GroovyClassOperation", "{", "public", "abstract", "void", "call", "(", "GroovyClass", "gclass", ")", "throws", "CompilationFailedException", ";", "}", "private", "int", "getSuperClassCount", "(", "ClassNode", "element", ")", "{", "int", "count", "=", "0", ";", "while", "(", "element", "!=", "null", ")", "{", "count", "++", ";", "element", "=", "element", ".", "getSuperClass", "(", ")", ";", "}", "return", "count", ";", "}", "private", "int", "getSuperInterfaceCount", "(", "ClassNode", "element", ")", "{", "int", "count", "=", "1", ";", "ClassNode", "[", "]", "interfaces", "=", "element", ".", "getInterfaces", "(", ")", ";", "for", "(", "ClassNode", "anInterface", ":", "interfaces", ")", "{", "count", "=", "Math", ".", "max", "(", "count", ",", "getSuperInterfaceCount", "(", "anInterface", ")", "+", "1", ")", ";", "}", "return", "count", ";", "}", "private", "List", "getPrimaryClassNodes", "(", "boolean", "sort", ")", "{", "if", "(", "sort", "==", "true", ")", "{", "List", "<", "ModuleNode", ">", "sortedModules", "=", "this", ".", "ast", ".", "getSortedModules", "(", ")", ";", "if", "(", "sortedModules", "!=", "null", ")", "{", "return", "sortedModules", ";", "}", "}", "List", "<", "ClassNode", ">", "unsorted", "=", "new", "ArrayList", "<", "ClassNode", ">", "(", ")", ";", "for", "(", "ModuleNode", "module", ":", "this", ".", "ast", ".", "getModules", "(", ")", ")", "{", "unsorted", ".", "addAll", "(", "module", ".", "getClasses", "(", ")", ")", ";", "}", "if", "(", "!", "sort", ")", "return", "unsorted", ";", "List", "<", "Integer", ">", "countIndexPairs", "=", "new", "ArrayList", "<", "Integer", ">", "(", ")", ";", "{", "int", "i", "=", "0", ";", "for", "(", "Iterator", "iter", "=", "unsorted", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", "i", "++", ")", "{", "ClassNode", "node", "=", "(", "ClassNode", ")", "iter", ".", "next", "(", ")", ";", "if", "(", "node", ".", "isInterface", "(", ")", ")", "{", "countIndexPairs", ".", "add", "(", "(", "getSuperInterfaceCount", "(", "node", ")", "<<", "16", ")", "+", "i", ")", ";", "}", "else", "{", "countIndexPairs", ".", "add", "(", "(", "(", "getSuperClassCount", "(", "node", ")", "+", "2000", ")", "<<", "16", ")", "+", "i", ")", ";", "}", "}", "}", "Collections", ".", "sort", "(", "countIndexPairs", ")", ";", "List", "sorted", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "int", "i", ":", "countIndexPairs", ")", "{", "sorted", ".", "add", "(", "unsorted", ".", "get", "(", "i", "&", "0xffff", ")", ")", ";", "}", "this", ".", "ast", ".", "setSortedModules", "(", "sorted", ")", ";", "return", "sorted", ";", "}", "private", "List", "<", "ClassNode", ">", "getSorted", "(", "int", "[", "]", "index", ",", "List", "<", "ClassNode", ">", "unsorted", ")", "{", "List", "<", "ClassNode", ">", "sorted", "=", "new", "ArrayList", "<", "ClassNode", ">", "(", "unsorted", ".", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "unsorted", ".", "size", "(", ")", ";", "i", "++", ")", "{", "int", "min", "=", "-", "1", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "unsorted", ".", "size", "(", ")", ";", "j", "++", ")", "{", "if", "(", "index", "[", "j", "]", "==", "-", "1", ")", "continue", ";", "if", "(", "min", "==", "-", "1", ")", "{", "min", "=", "j", ";", "}", "else", "if", "(", "index", "[", "j", "]", "<", "index", "[", "min", "]", ")", "{", "min", "=", "j", ";", "}", "}", "if", "(", "min", "==", "-", "1", ")", "break", ";", "sorted", ".", "add", "(", "unsorted", ".", "get", "(", "min", ")", ")", ";", "index", "[", "min", "]", "=", "-", "1", ";", "}", "return", "sorted", ";", "}", "public", "void", "applyToPrimaryClassNodes", "(", "PrimaryClassNodeOperation", "body", ")", "throws", "CompilationFailedException", "{", "List", "primaryClassNodes", "=", "getPrimaryClassNodes", "(", "body", ".", "needSortedInput", "(", ")", ")", ";", "Iterator", "classNodes", "=", "primaryClassNodes", ".", "iterator", "(", ")", ";", "while", "(", "classNodes", ".", "hasNext", "(", ")", ")", "{", "SourceUnit", "context", "=", "null", ";", "try", "{", "ClassNode", "classNode", "=", "(", "ClassNode", ")", "classNodes", ".", "next", "(", ")", ";", "context", "=", "classNode", ".", "getModule", "(", ")", ".", "getContext", "(", ")", ";", "if", "(", "context", "==", "null", "||", "context", ".", "phase", "<", "phase", "||", "(", "context", ".", "phase", "==", "phase", "&&", "!", "context", ".", "phaseComplete", ")", ")", "{", "int", "offset", "=", "1", ";", "Iterator", "<", "InnerClassNode", ">", "iterator", "=", "classNode", ".", "getInnerClasses", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "iterator", ".", "next", "(", ")", ";", "offset", "++", ";", "}", "body", ".", "call", "(", "context", ",", "new", "GeneratorContext", "(", "this", ".", "ast", ",", "offset", ")", ",", "classNode", ")", ";", "}", "}", "catch", "(", "CompilationFailedException", "e", ")", "{", "}", "catch", "(", "NullPointerException", "npe", ")", "{", "throw", "npe", ";", "}", "catch", "(", "GroovyBugError", "e", ")", "{", "changeBugText", "(", "e", ",", "context", ")", ";", "throw", "e", ";", "}", "catch", "(", "Exception", "e", ")", "{", "ErrorCollector", "nestedCollector", "=", "null", ";", "for", "(", "Throwable", "next", "=", "e", ".", "getCause", "(", ")", ";", "next", "!=", "e", "&&", "next", "!=", "null", ";", "next", "=", "next", ".", "getCause", "(", ")", ")", "{", "if", "(", "!", "(", "next", "instanceof", "MultipleCompilationErrorsException", ")", ")", "continue", ";", "MultipleCompilationErrorsException", "mcee", "=", "(", "MultipleCompilationErrorsException", ")", "next", ";", "nestedCollector", "=", "mcee", ".", "collector", ";", "break", ";", "}", "if", "(", "nestedCollector", "!=", "null", ")", "{", "getErrorCollector", "(", ")", ".", "addCollectorContents", "(", "nestedCollector", ")", ";", "}", "else", "{", "getErrorCollector", "(", ")", ".", "addError", "(", "new", "ExceptionMessage", "(", "e", ",", "configuration", ".", "getDebug", "(", ")", ",", "this", ")", ")", ";", "}", "}", "}", "getErrorCollector", "(", ")", ".", "failIfErrors", "(", ")", ";", "}", "public", "void", "applyToGeneratedGroovyClasses", "(", "GroovyClassOperation", "body", ")", "throws", "CompilationFailedException", "{", "if", "(", "this", ".", "phase", "!=", "Phases", ".", "OUTPUT", "&&", "!", "(", "this", ".", "phase", "==", "Phases", ".", "CLASS_GENERATION", "&&", "this", ".", "phaseComplete", ")", ")", "{", "throw", "new", "GroovyBugError", "(", "\"\"", "+", "getPhaseDescription", "(", ")", ")", ";", "}", "for", "(", "GroovyClass", "gclass", ":", "this", ".", "generatedClasses", ")", "{", "try", "{", "body", ".", "call", "(", "gclass", ")", ";", "}", "catch", "(", "CompilationFailedException", "e", ")", "{", "}", "catch", "(", "NullPointerException", "npe", ")", "{", "throw", "npe", ";", "}", "catch", "(", "GroovyBugError", "e", ")", "{", "changeBugText", "(", "e", ",", "null", ")", ";", "throw", "e", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "GroovyBugError", "(", "e", ")", ";", "}", "}", "getErrorCollector", "(", ")", ".", "failIfErrors", "(", ")", ";", "}", "private", "void", "changeBugText", "(", "GroovyBugError", "e", ",", "SourceUnit", "context", ")", "{", "e", ".", "setBugText", "(", "\"\"", "+", "getPhaseDescription", "(", ")", "+", "\"\"", "+", "(", "(", "context", "!=", "null", ")", "?", "context", ".", "getName", "(", ")", ":", "\"?\"", ")", "+", "\"'", "\"", "+", "e", ".", "getBugText", "(", ")", ")", ";", "}", "public", "ClassNodeResolver", "getClassNodeResolver", "(", ")", "{", "return", "classNodeResolver", ";", "}", "public", "void", "setClassNodeResolver", "(", "ClassNodeResolver", "classNodeResolver", ")", "{", "this", ".", "classNodeResolver", "=", "classNodeResolver", ";", "}", "public", "void", "setResolveVisitor", "(", "ResolveVisitor", "resolveVisitor2", ")", "{", "this", ".", "resolveVisitor", "=", "resolveVisitor2", ";", "}", "public", "ResolveVisitor", "getResolveVisitor", "(", ")", "{", "return", "this", ".", "resolveVisitor", ";", "}", "public", "String", "toString", "(", ")", "{", "if", "(", "sources", "==", "null", "||", "sources", ".", "isEmpty", "(", ")", ")", "return", "super", ".", "toString", "(", ")", ";", "Set", "s", "=", "sources", ".", "keySet", "(", ")", ";", "for", "(", "Object", "o", ":", "s", ")", "{", "return", "\"\"", "+", "o", ".", "toString", "(", ")", ";", "}", "return", "\"\"", ";", "}", "public", "boolean", "allowTransforms", "=", "true", ";", "public", "boolean", "isReconcile", "=", "false", ";", "public", "List", "<", "String", ">", "localTransformsToRunOnReconcile", "=", "null", ";", "public", "void", "tweak", "(", "boolean", "isReconcile", ")", "{", "if", "(", "isReconcile", ")", "{", "verifier", ".", "inlineStaticFieldInitializersIntoClinit", "=", "false", ";", "staticImportVisitor", ".", "isReconcile", "=", "true", ";", "}", "else", "{", "verifier", ".", "inlineStaticFieldInitializersIntoClinit", "=", "true", ";", "}", "this", ".", "isReconcile", "=", "isReconcile", ";", "}", "}", "</s>" ]
6,939
[ "<s>", "package", "org", ".", "codehaus", ".", "groovy", ".", "control", ";", "import", "static", "org", ".", "codehaus", ".", "groovy", ".", "runtime", ".", "MetaClassHelper", ".", "capitalize", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "expr", ".", "*", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "ast", ".", "stmt", ".", "Statement", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "syntax", ".", "Types", ";", "import", "java", ".", "util", ".", "*", ";", "public", "class", "StaticImportVisitor", "extends", "ClassCodeExpressionTransformer", "{", "private", "ClassNode", "currentClass", ";", "private", "MethodNode", "currentMethod", ";", "private", "SourceUnit", "source", ";", "private", "boolean", "inSpecialConstructorCall", ";", "private", "boolean", "inClosure", ";", "private", "boolean", "inPropertyExpression", ";", "private", "Expression", "foundConstant", ";", "private", "Expression", "foundArgs", ";", "private", "boolean", "inAnnotation", ";", "private", "boolean", "inLeftExpression", ";", "boolean", "isReconcile", "=", "false", ";", "public", "void", "visitClass", "(", "ClassNode", "node", ",", "SourceUnit", "source", ")", "{", "this", ".", "currentClass", "=", "node", ";", "this", ".", "source", "=", "source", ";", "super", ".", "visitClass", "(", "node", ")", ";", "}", "@", "Override", "protected", "void", "visitConstructorOrMethod", "(", "MethodNode", "node", ",", "boolean", "isConstructor", ")", "{", "this", ".", "currentMethod", "=", "node", ";", "super", ".", "visitConstructorOrMethod", "(", "node", ",", "isConstructor", ")", ";", "this", ".", "currentMethod", "=", "null", ";", "}", "@", "Override", "public", "void", "visitAnnotations", "(", "AnnotatedNode", "node", ")", "{", "boolean", "oldInAnnotation", "=", "inAnnotation", ";", "inAnnotation", "=", "true", ";", "super", ".", "visitAnnotations", "(", "node", ")", ";", "inAnnotation", "=", "oldInAnnotation", ";", "}", "public", "Expression", "transform", "(", "Expression", "exp", ")", "{", "if", "(", "exp", "==", "null", ")", "return", "null", ";", "if", "(", "exp", ".", "getClass", "(", ")", "==", "VariableExpression", ".", "class", ")", "{", "return", "transformVariableExpression", "(", "(", "VariableExpression", ")", "exp", ")", ";", "}", "if", "(", "exp", ".", "getClass", "(", ")", "==", "BinaryExpression", ".", "class", ")", "{", "return", "transformBinaryExpression", "(", "(", "BinaryExpression", ")", "exp", ")", ";", "}", "if", "(", "exp", ".", "getClass", "(", ")", "==", "PropertyExpression", ".", "class", ")", "{", "return", "transformPropertyExpression", "(", "(", "PropertyExpression", ")", "exp", ")", ";", "}", "if", "(", "exp", ".", "getClass", "(", ")", "==", "MethodCallExpression", ".", "class", ")", "{", "return", "transformMethodCallExpression", "(", "(", "MethodCallExpression", ")", "exp", ")", ";", "}", "if", "(", "exp", ".", "getClass", "(", ")", "==", "ClosureExpression", ".", "class", ")", "{", "return", "transformClosureExpression", "(", "(", "ClosureExpression", ")", "exp", ")", ";", "}", "if", "(", "exp", ".", "getClass", "(", ")", "==", "ConstructorCallExpression", ".", "class", ")", "{", "return", "transformConstructorCallExpression", "(", "(", "ConstructorCallExpression", ")", "exp", ")", ";", "}", "if", "(", "exp", ".", "getClass", "(", ")", "==", "ArgumentListExpression", ".", "class", ")", "{", "Expression", "result", "=", "exp", ".", "transformExpression", "(", "this", ")", ";", "if", "(", "inPropertyExpression", ")", "{", "foundArgs", "=", "result", ";", "}", "return", "result", ";", "}", "if", "(", "exp", "instanceof", "ConstantExpression", ")", "{", "Expression", "result", "=", "exp", ".", "transformExpression", "(", "this", ")", ";", "if", "(", "inPropertyExpression", ")", "{", "foundConstant", "=", "result", ";", "}", "if", "(", "inAnnotation", "&&", "exp", "instanceof", "AnnotationConstantExpression", ")", "{", "ConstantExpression", "ce", "=", "(", "ConstantExpression", ")", "result", ";", "if", "(", "ce", ".", "getValue", "(", ")", "instanceof", "AnnotationNode", ")", "{", "AnnotationNode", "an", "=", "(", "AnnotationNode", ")", "ce", ".", "getValue", "(", ")", ";", "Map", "<", "String", ",", "Expression", ">", "attributes", "=", "an", ".", "getMembers", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Expression", ">", "entry", ":", "attributes", ".", "entrySet", "(", ")", ")", "{", "Expression", "attrExpr", "=", "transform", "(", "entry", ".", "getValue", "(", ")", ")", ";", "entry", ".", "setValue", "(", "attrExpr", ")", ";", "}", "}", "}", "return", "result", ";", "}", "return", "exp", ".", "transformExpression", "(", "this", ")", ";", "}", "private", "Expression", "transformMapEntryExpression", "(", "MapEntryExpression", "me", ",", "ClassNode", "constructorCallType", ")", "{", "Expression", "key", "=", "me", ".", "getKeyExpression", "(", ")", ";", "Expression", "value", "=", "me", ".", "getValueExpression", "(", ")", ";", "ModuleNode", "module", "=", "currentClass", ".", "getModule", "(", ")", ";", "if", "(", "module", "!=", "null", "&&", "key", "instanceof", "ConstantExpression", ")", "{", "Map", "<", "String", ",", "ImportNode", ">", "importNodes", "=", "module", ".", "getStaticImports", "(", ")", ";", "if", "(", "importNodes", ".", "containsKey", "(", "key", ".", "getText", "(", ")", ")", ")", "{", "ImportNode", "importNode", "=", "importNodes", ".", "get", "(", "key", ".", "getText", "(", ")", ")", ";", "if", "(", "importNode", ".", "getType", "(", ")", ".", "equals", "(", "constructorCallType", ")", ")", "{", "String", "newKey", "=", "importNode", ".", "getFieldName", "(", ")", ";", "return", "new", "MapEntryExpression", "(", "new", "ConstantExpression", "(", "newKey", ")", ",", "value", ".", "transformExpression", "(", "this", ")", ")", ";", "}", "}", "}", "return", "me", ";", "}", "protected", "Expression", "transformBinaryExpression", "(", "BinaryExpression", "be", ")", "{", "int", "type", "=", "be", ".", "getOperation", "(", ")", ".", "getType", "(", ")", ";", "boolean", "oldInLeftExpression", ";", "Expression", "right", "=", "transform", "(", "be", ".", "getRightExpression", "(", ")", ")", ";", "be", ".", "setRightExpression", "(", "right", ")", ";", "Expression", "left", ";", "if", "(", "type", "==", "Types", ".", "EQUAL", "&&", "be", ".", "getLeftExpression", "(", ")", "instanceof", "VariableExpression", ")", "{", "oldInLeftExpression", "=", "inLeftExpression", ";", "inLeftExpression", "=", "true", ";", "left", "=", "transform", "(", "be", ".", "getLeftExpression", "(", ")", ")", ";", "inLeftExpression", "=", "oldInLeftExpression", ";", "if", "(", "left", "instanceof", "StaticMethodCallExpression", ")", "{", "StaticMethodCallExpression", "smce", "=", "(", "StaticMethodCallExpression", ")", "left", ";", "StaticMethodCallExpression", "result", "=", "new", "StaticMethodCallExpression", "(", "smce", ".", "getOwnerType", "(", ")", ",", "smce", ".", "getMethod", "(", ")", ",", "right", ")", ";", "setSourcePosition", "(", "result", ",", "be", ")", ";", "return", "result", ";", "}", "}", "else", "{", "left", "=", "transform", "(", "be", ".", "getLeftExpression", "(", ")", ")", ";", "}", "be", ".", "setLeftExpression", "(", "left", ")", ";", "return", "be", ";", "}", "protected", "Expression", "transformVariableExpression", "(", "VariableExpression", "ve", ")", "{", "Variable", "v", "=", "ve", ".", "getAccessedVariable", "(", ")", ";", "if", "(", "v", "!=", "null", "&&", "v", "instanceof", "DynamicVariable", ")", "{", "Expression", "result", "=", "findStaticFieldOrPropAccessorImportFromModule", "(", "v", ".", "getName", "(", ")", ")", ";", "if", "(", "result", "!=", "null", ")", "{", "setSourcePosition", "(", "result", ",", "ve", ")", ";", "if", "(", "inAnnotation", ")", "{", "result", "=", "transformInlineConstants", "(", "result", ")", ";", "}", "return", "result", ";", "}", "}", "return", "ve", ";", "}", "private", "void", "setSourcePosition", "(", "Expression", "toSet", ",", "Expression", "origNode", ")", "{", "toSet", ".", "setSourcePosition", "(", "origNode", ")", ";", "if", "(", "toSet", "instanceof", "PropertyExpression", ")", "{", "(", "(", "PropertyExpression", ")", "toSet", ")", ".", "getProperty", "(", ")", ".", "setSourcePosition", "(", "origNode", ")", ";", "}", "}", "private", "Expression", "transformInlineConstants", "(", "Expression", "exp", ")", "{", "if", "(", "exp", "instanceof", "PropertyExpression", ")", "{", "PropertyExpression", "pe", "=", "(", "PropertyExpression", ")", "exp", ";", "if", "(", "pe", ".", "getObjectExpression", "(", ")", "instanceof", "ClassExpression", ")", "{", "ClassExpression", "ce", "=", "(", "ClassExpression", ")", "pe", ".", "getObjectExpression", "(", ")", ";", "ClassNode", "type", "=", "ce", ".", "getType", "(", ")", ";", "if", "(", "type", ".", "isEnum", "(", ")", ")", "return", "exp", ";", "Expression", "constant", "=", "findConstant", "(", "type", ".", "getField", "(", "pe", ".", "getPropertyAsString", "(", ")", ")", ")", ";", "if", "(", "constant", "!=", "null", ")", "return", "constant", ";", "}", "}", "else", "if", "(", "exp", "instanceof", "ListExpression", ")", "{", "ListExpression", "le", "=", "(", "ListExpression", ")", "exp", ";", "ListExpression", "result", "=", "new", "ListExpression", "(", ")", ";", "for", "(", "Expression", "e", ":", "le", ".", "getExpressions", "(", ")", ")", "{", "result", ".", "addExpression", "(", "transformInlineConstants", "(", "e", ")", ")", ";", "}", "return", "result", ";", "}", "return", "exp", ";", "}", "private", "Expression", "findConstant", "(", "FieldNode", "fn", ")", "{", "if", "(", "fn", "!=", "null", "&&", "!", "fn", ".", "isEnum", "(", ")", "&&", "fn", ".", "isStatic", "(", ")", "&&", "fn", ".", "isFinal", "(", ")", ")", "{", "if", "(", "fn", ".", "getInitialValueExpression", "(", ")", "instanceof", "ConstantExpression", ")", "{", "return", "fn", ".", "getInitialValueExpression", "(", ")", ";", "}", "}", "return", "null", ";", "}", "protected", "Expression", "transformMethodCallExpression", "(", "MethodCallExpression", "mce", ")", "{", "Expression", "args", "=", "transform", "(", "mce", ".", "getArguments", "(", ")", ")", ";", "Expression", "method", "=", "transform", "(", "mce", ".", "getMethod", "(", ")", ")", ";", "Expression", "object", "=", "transform", "(", "mce", ".", "getObjectExpression", "(", ")", ")", ";", "boolean", "isExplicitThisOrSuper", "=", "false", ";", "if", "(", "object", "instanceof", "VariableExpression", ")", "{", "VariableExpression", "ve", "=", "(", "VariableExpression", ")", "object", ";", "isExplicitThisOrSuper", "=", "!", "mce", ".", "isImplicitThis", "(", ")", "&&", "(", "ve", ".", "getName", "(", ")", ".", "equals", "(", "\"this\"", ")", "||", "ve", ".", "getName", "(", ")", ".", "equals", "(", "\"super\"", ")", ")", ";", "}", "if", "(", "mce", ".", "isImplicitThis", "(", ")", "||", "isExplicitThisOrSuper", ")", "{", "if", "(", "mce", ".", "isImplicitThis", "(", ")", ")", "{", "Expression", "ret", "=", "findStaticMethodImportFromModule", "(", "method", ",", "args", ")", ";", "if", "(", "ret", "!=", "null", ")", "{", "setSourcePosition", "(", "ret", ",", "mce", ")", ";", "return", "ret", ";", "}", "if", "(", "method", "instanceof", "ConstantExpression", "&&", "!", "inLeftExpression", ")", "{", "String", "methodName", "=", "(", "String", ")", "(", "(", "ConstantExpression", ")", "method", ")", ".", "getValue", "(", ")", ";", "ret", "=", "findStaticFieldOrPropAccessorImportFromModule", "(", "methodName", ")", ";", "if", "(", "ret", "!=", "null", ")", "{", "ret", "=", "new", "MethodCallExpression", "(", "ret", ",", "\"call\"", ",", "args", ")", ";", "setSourcePosition", "(", "ret", ",", "mce", ")", ";", "return", "ret", ";", "}", "}", "}", "if", "(", "method", "instanceof", "ConstantExpression", ")", "{", "ConstantExpression", "ce", "=", "(", "ConstantExpression", ")", "method", ";", "Object", "value", "=", "ce", ".", "getValue", "(", ")", ";", "if", "(", "value", "instanceof", "String", ")", "{", "String", "methodName", "=", "(", "String", ")", "value", ";", "boolean", "lookForPossibleStaticMethod", "=", "!", "methodName", ".", "equals", "(", "\"call\"", ")", ";", "if", "(", "currentMethod", "!=", "null", "&&", "!", "currentMethod", ".", "isStatic", "(", ")", ")", "{", "if", "(", "currentClass", ".", "hasPossibleMethod", "(", "methodName", ",", "args", ")", ")", "{", "lookForPossibleStaticMethod", "=", "false", ";", "}", "}", "if", "(", "inSpecialConstructorCall", "||", "(", "lookForPossibleStaticMethod", "&&", "currentClass", ".", "hasPossibleStaticMethod", "(", "methodName", ",", "args", ")", ")", ")", "{", "StaticMethodCallExpression", "smce", "=", "new", "StaticMethodCallExpression", "(", "currentClass", ",", "methodName", ",", "args", ")", ";", "setSourcePosition", "(", "smce", ",", "mce", ")", ";", "return", "smce", ";", "}", "}", "}", "}", "MethodCallExpression", "result", "=", "new", "MethodCallExpression", "(", "object", ",", "method", ",", "args", ")", ";", "result", ".", "setSafe", "(", "mce", ".", "isSafe", "(", ")", ")", ";", "result", ".", "setImplicitThis", "(", "mce", ".", "isImplicitThis", "(", ")", ")", ";", "result", ".", "setSpreadSafe", "(", "mce", ".", "isSpreadSafe", "(", ")", ")", ";", "result", ".", "setMethodTarget", "(", "mce", ".", "getMethodTarget", "(", ")", ")", ";", "setSourcePosition", "(", "result", ",", "mce", ")", ";", "return", "result", ";", "}", "protected", "Expression", "transformConstructorCallExpression", "(", "ConstructorCallExpression", "cce", ")", "{", "inSpecialConstructorCall", "=", "cce", ".", "isSpecialCall", "(", ")", ";", "Expression", "expression", "=", "cce", ".", "getArguments", "(", ")", ";", "if", "(", "expression", "instanceof", "TupleExpression", ")", "{", "TupleExpression", "tuple", "=", "(", "TupleExpression", ")", "expression", ";", "if", "(", "tuple", ".", "getExpressions", "(", ")", ".", "size", "(", ")", "==", "1", ")", "{", "expression", "=", "tuple", ".", "getExpression", "(", "0", ")", ";", "if", "(", "expression", "instanceof", "NamedArgumentListExpression", ")", "{", "NamedArgumentListExpression", "namedArgs", "=", "(", "NamedArgumentListExpression", ")", "expression", ";", "List", "<", "MapEntryExpression", ">", "entryExpressions", "=", "namedArgs", ".", "getMapEntryExpressions", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "entryExpressions", ".", "size", "(", ")", ";", "i", "++", ")", "{", "entryExpressions", ".", "set", "(", "i", ",", "(", "MapEntryExpression", ")", "transformMapEntryExpression", "(", "entryExpressions", ".", "get", "(", "i", ")", ",", "cce", ".", "getType", "(", ")", ")", ")", ";", "}", "}", "}", "}", "Expression", "ret", "=", "cce", ".", "transformExpression", "(", "this", ")", ";", "inSpecialConstructorCall", "=", "false", ";", "return", "ret", ";", "}", "protected", "Expression", "transformClosureExpression", "(", "ClosureExpression", "ce", ")", "{", "boolean", "oldInClosure", "=", "inClosure", ";", "inClosure", "=", "true", ";", "Statement", "code", "=", "ce", ".", "getCode", "(", ")", ";", "if", "(", "code", "!=", "null", ")", "code", ".", "visit", "(", "this", ")", ";", "inClosure", "=", "oldInClosure", ";", "return", "ce", ";", "}", "protected", "Expression", "transformPropertyExpression", "(", "PropertyExpression", "pe", ")", "{", "boolean", "oldInPropertyExpression", "=", "inPropertyExpression", ";", "Expression", "oldFoundArgs", "=", "foundArgs", ";", "Expression", "oldFoundConstant", "=", "foundConstant", ";", "inPropertyExpression", "=", "true", ";", "foundArgs", "=", "null", ";", "foundConstant", "=", "null", ";", "Expression", "objectExpression", "=", "transform", "(", "pe", ".", "getObjectExpression", "(", ")", ")", ";", "boolean", "candidate", "=", "false", ";", "if", "(", "objectExpression", "instanceof", "MethodCallExpression", ")", "{", "candidate", "=", "(", "(", "MethodCallExpression", ")", "objectExpression", ")", ".", "isImplicitThis", "(", ")", ";", "}", "if", "(", "foundArgs", "!=", "null", "&&", "foundConstant", "!=", "null", "&&", "candidate", ")", "{", "Expression", "result", "=", "findStaticMethodImportFromModule", "(", "foundConstant", ",", "foundArgs", ")", ";", "if", "(", "result", "!=", "null", ")", "{", "objectExpression", "=", "result", ";", "objectExpression", ".", "setSourcePosition", "(", "pe", ")", ";", "}", "}", "inPropertyExpression", "=", "oldInPropertyExpression", ";", "foundArgs", "=", "oldFoundArgs", ";", "foundConstant", "=", "oldFoundConstant", ";", "pe", ".", "setObjectExpression", "(", "objectExpression", ")", ";", "return", "pe", ";", "}", "private", "Expression", "findStaticFieldOrPropAccessorImportFromModule", "(", "String", "name", ")", "{", "ModuleNode", "module", "=", "currentClass", ".", "getModule", "(", ")", ";", "if", "(", "module", "==", "null", ")", "return", "null", ";", "Map", "<", "String", ",", "ImportNode", ">", "importNodes", "=", "module", ".", "getStaticImports", "(", ")", ";", "Expression", "expression", ";", "String", "accessorName", "=", "getAccessorName", "(", "name", ")", ";", "if", "(", "importNodes", ".", "containsKey", "(", "accessorName", ")", ")", "{", "ImportNode", "importNode", "=", "importNodes", ".", "get", "(", "accessorName", ")", ";", "expression", "=", "findStaticPropertyAccessorByFullName", "(", "importNode", ".", "getType", "(", ")", ",", "importNode", ".", "getFieldName", "(", ")", ")", ";", "if", "(", "expression", "!=", "null", ")", "return", "expression", ";", "expression", "=", "findStaticPropertyAccessor", "(", "importNode", ".", "getType", "(", ")", ",", "getPropNameForAccessor", "(", "importNode", ".", "getFieldName", "(", ")", ")", ")", ";", "if", "(", "expression", "!=", "null", ")", "return", "expression", ";", "}", "if", "(", "accessorName", ".", "startsWith", "(", "\"get\"", ")", ")", "{", "accessorName", "=", "\"is\"", "+", "accessorName", ".", "substring", "(", "3", ")", ";", "if", "(", "importNodes", ".", "containsKey", "(", "accessorName", ")", ")", "{", "ImportNode", "importNode", "=", "importNodes", ".", "get", "(", "accessorName", ")", ";", "expression", "=", "findStaticPropertyAccessorByFullName", "(", "importNode", ".", "getType", "(", ")", ",", "importNode", ".", "getFieldName", "(", ")", ")", ";", "if", "(", "expression", "!=", "null", ")", "return", "expression", ";", "expression", "=", "findStaticPropertyAccessor", "(", "importNode", ".", "getType", "(", ")", ",", "getPropNameForAccessor", "(", "importNode", ".", "getFieldName", "(", ")", ")", ")", ";", "if", "(", "expression", "!=", "null", ")", "return", "expression", ";", "}", "}", "if", "(", "importNodes", ".", "containsKey", "(", "name", ")", ")", "{", "ImportNode", "importNode", "=", "importNodes", ".", "get", "(", "name", ")", ";", "if", "(", "!", "isReconcile", ")", "{", "expression", "=", "findStaticPropertyAccessor", "(", "importNode", ".", "getType", "(", ")", ",", "importNode", ".", "getFieldName", "(", ")", ")", ";", "if", "(", "expression", "!=", "null", ")", "return", "expression", ";", "}", "expression", "=", "findStaticField", "(", "importNode", ".", "getType", "(", ")", ",", "importNode", ".", "getFieldName", "(", ")", ")", ";", "if", "(", "expression", "!=", "null", ")", "return", "expression", ";", "}", "for", "(", "ImportNode", "importNode", ":", "module", ".", "getStaticStarImports", "(", ")", ".", "values", "(", ")", ")", "{", "ClassNode", "node", "=", "importNode", ".", "getType", "(", ")", ";", "expression", "=", "findStaticPropertyAccessor", "(", "node", ",", "name", ")", ";", "if", "(", "expression", "!=", "null", ")", "return", "expression", ";", "expression", "=", "findStaticField", "(", "node", ",", "name", ")", ";", "if", "(", "expression", "!=", "null", ")", "return", "expression", ";", "}", "return", "null", ";", "}", "private", "Expression", "findStaticMethodImportFromModule", "(", "Expression", "method", ",", "Expression", "args", ")", "{", "ModuleNode", "module", "=", "currentClass", ".", "getModule", "(", ")", ";", "if", "(", "module", "==", "null", "||", "!", "(", "method", "instanceof", "ConstantExpression", ")", ")", "return", "null", ";", "Map", "<", "String", ",", "ImportNode", ">", "importNodes", "=", "module", ".", "getStaticImports", "(", ")", ";", "ConstantExpression", "ce", "=", "(", "ConstantExpression", ")", "method", ";", "Expression", "expression", ";", "Object", "value", "=", "ce", ".", "getValue", "(", ")", ";", "if", "(", "!", "(", "value", "instanceof", "String", ")", ")", "return", "null", ";", "final", "String", "name", "=", "(", "String", ")", "value", ";", "if", "(", "importNodes", ".", "containsKey", "(", "name", ")", ")", "{", "ImportNode", "importNode", "=", "importNodes", ".", "get", "(", "name", ")", ";", "expression", "=", "findStaticMethod", "(", "importNode", ".", "getType", "(", ")", ",", "importNode", ".", "getFieldName", "(", ")", ",", "args", ")", ";", "if", "(", "expression", "!=", "null", ")", "return", "expression", ";", "expression", "=", "findStaticPropertyAccessorGivenArgs", "(", "importNode", ".", "getType", "(", ")", ",", "getPropNameForAccessor", "(", "importNode", ".", "getFieldName", "(", ")", ")", ",", "args", ")", ";", "if", "(", "expression", "!=", "null", ")", "{", "return", "new", "StaticMethodCallExpression", "(", "importNode", ".", "getType", "(", ")", ",", "importNode", ".", "getFieldName", "(", ")", ",", "args", ")", ";", "}", "}", "if", "(", "validPropName", "(", "name", ")", ")", "{", "String", "propName", "=", "getPropNameForAccessor", "(", "name", ")", ";", "if", "(", "importNodes", ".", "containsKey", "(", "propName", ")", ")", "{", "ImportNode", "importNode", "=", "importNodes", ".", "get", "(", "propName", ")", ";", "expression", "=", "findStaticMethod", "(", "importNode", ".", "getType", "(", ")", ",", "prefix", "(", "name", ")", "+", "capitalize", "(", "importNode", ".", "getFieldName", "(", ")", ")", ",", "args", ")", ";", "if", "(", "expression", "!=", "null", ")", "return", "expression", ";", "expression", "=", "findStaticPropertyAccessorGivenArgs", "(", "importNode", ".", "getType", "(", ")", ",", "importNode", ".", "getFieldName", "(", ")", ",", "args", ")", ";", "if", "(", "expression", "!=", "null", ")", "{", "return", "new", "StaticMethodCallExpression", "(", "importNode", ".", "getType", "(", ")", ",", "prefix", "(", "name", ")", "+", "capitalize", "(", "importNode", ".", "getFieldName", "(", ")", ")", ",", "args", ")", ";", "}", "}", "}", "Map", "<", "String", ",", "ImportNode", ">", "starImports", "=", "module", ".", "getStaticStarImports", "(", ")", ";", "ClassNode", "starImportType", ";", "if", "(", "currentClass", ".", "isEnum", "(", ")", "&&", "starImports", ".", "containsKey", "(", "currentClass", ".", "getName", "(", ")", ")", ")", "{", "ImportNode", "importNode", "=", "starImports", ".", "get", "(", "currentClass", ".", "getName", "(", ")", ")", ";", "starImportType", "=", "importNode", "==", "null", "?", "null", ":", "importNode", ".", "getType", "(", ")", ";", "expression", "=", "findStaticMethod", "(", "starImportType", ",", "name", ",", "args", ")", ";", "if", "(", "expression", "!=", "null", ")", "return", "expression", ";", "}", "else", "{", "for", "(", "ImportNode", "importNode", ":", "starImports", ".", "values", "(", ")", ")", "{", "starImportType", "=", "importNode", "==", "null", "?", "null", ":", "importNode", ".", "getType", "(", ")", ";", "expression", "=", "findStaticMethod", "(", "starImportType", ",", "name", ",", "args", ")", ";", "if", "(", "expression", "!=", "null", ")", "return", "expression", ";", "expression", "=", "findStaticPropertyAccessorGivenArgs", "(", "starImportType", ",", "getPropNameForAccessor", "(", "name", ")", ",", "args", ")", ";", "if", "(", "expression", "!=", "null", ")", "{", "return", "new", "StaticMethodCallExpression", "(", "starImportType", ",", "name", ",", "args", ")", ";", "}", "}", "}", "return", "null", ";", "}", "private", "String", "prefix", "(", "String", "name", ")", "{", "return", "name", ".", "startsWith", "(", "\"is\"", ")", "?", "\"is\"", ":", "name", ".", "substring", "(", "0", ",", "3", ")", ";", "}", "private", "String", "getPropNameForAccessor", "(", "String", "fieldName", ")", "{", "int", "prefixLength", "=", "fieldName", ".", "startsWith", "(", "\"is\"", ")", "?", "2", ":", "3", ";", "if", "(", "fieldName", ".", "length", "(", ")", "<", "prefixLength", "+", "1", ")", "return", "fieldName", ";", "if", "(", "!", "validPropName", "(", "fieldName", ")", ")", "return", "fieldName", ";", "return", "String", ".", "valueOf", "(", "fieldName", ".", "charAt", "(", "prefixLength", ")", ")", ".", "toLowerCase", "(", ")", "+", "fieldName", ".", "substring", "(", "prefixLength", "+", "1", ")", ";", "}", "private", "boolean", "validPropName", "(", "String", "propName", ")", "{", "return", "propName", ".", "startsWith", "(", "\"get\"", ")", "||", "propName", ".", "startsWith", "(", "\"is\"", ")", "||", "propName", ".", "startsWith", "(", "\"set\"", ")", ";", "}", "private", "String", "getAccessorName", "(", "String", "name", ")", "{", "return", "(", "inLeftExpression", "?", "\"set\"", ":", "\"get\"", ")", "+", "capitalize", "(", "name", ")", ";", "}", "private", "Expression", "findStaticPropertyAccessorGivenArgs", "(", "ClassNode", "staticImportType", ",", "String", "propName", ",", "Expression", "args", ")", "{", "return", "findStaticPropertyAccessor", "(", "staticImportType", ",", "propName", ")", ";", "}", "private", "Expression", "findStaticPropertyAccessor", "(", "ClassNode", "staticImportType", ",", "String", "propName", ")", "{", "String", "accessorName", "=", "getAccessorName", "(", "propName", ")", ";", "Expression", "accessor", "=", "findStaticPropertyAccessorByFullName", "(", "staticImportType", ",", "accessorName", ")", ";", "if", "(", "accessor", "==", "null", "&&", "accessorName", ".", "startsWith", "(", "\"get\"", ")", ")", "{", "accessor", "=", "findStaticPropertyAccessorByFullName", "(", "staticImportType", ",", "\"is\"", "+", "accessorName", ".", "substring", "(", "3", ")", ")", ";", "}", "if", "(", "accessor", "==", "null", "&&", "hasStaticProperty", "(", "staticImportType", ",", "propName", ")", ")", "{", "if", "(", "inLeftExpression", ")", "accessor", "=", "new", "StaticMethodCallExpression", "(", "staticImportType", ",", "accessorName", ",", "ArgumentListExpression", ".", "EMPTY_ARGUMENTS", ")", ";", "else", "accessor", "=", "new", "PropertyExpression", "(", "new", "ClassExpression", "(", "staticImportType", ")", ",", "propName", ")", ";", "}", "return", "accessor", ";", "}", "private", "boolean", "hasStaticProperty", "(", "ClassNode", "staticImportType", ",", "String", "propName", ")", "{", "ClassNode", "classNode", "=", "staticImportType", ";", "while", "(", "classNode", "!=", "null", ")", "{", "for", "(", "PropertyNode", "pn", ":", "classNode", ".", "getProperties", "(", ")", ")", "{", "if", "(", "pn", ".", "getName", "(", ")", ".", "equals", "(", "propName", ")", "&&", "pn", ".", "isStatic", "(", ")", ")", "return", "true", ";", "}", "classNode", "=", "classNode", ".", "getSuperClass", "(", ")", ";", "}", "return", "false", ";", "}", "private", "Expression", "findStaticPropertyAccessorByFullName", "(", "ClassNode", "staticImportType", ",", "String", "accessorMethodName", ")", "{", "ArgumentListExpression", "dummyArgs", "=", "new", "ArgumentListExpression", "(", ")", ";", "dummyArgs", ".", "addExpression", "(", "new", "EmptyExpression", "(", ")", ")", ";", "return", "findStaticMethod", "(", "staticImportType", ",", "accessorMethodName", ",", "(", "inLeftExpression", "?", "dummyArgs", ":", "ArgumentListExpression", ".", "EMPTY_ARGUMENTS", ")", ")", ";", "}", "private", "Expression", "findStaticField", "(", "ClassNode", "staticImportType", ",", "String", "fieldName", ")", "{", "if", "(", "staticImportType", ".", "isPrimaryClassNode", "(", ")", "||", "staticImportType", ".", "isResolved", "(", ")", ")", "{", "FieldNode", "field", "=", "staticImportType", ".", "getField", "(", "fieldName", ")", ";", "if", "(", "field", "!=", "null", "&&", "field", ".", "isStatic", "(", ")", ")", "return", "new", "PropertyExpression", "(", "new", "ClassExpression", "(", "staticImportType", ")", ",", "fieldName", ")", ";", "}", "return", "null", ";", "}", "private", "Expression", "findStaticMethod", "(", "ClassNode", "staticImportType", ",", "String", "methodName", ",", "Expression", "args", ")", "{", "if", "(", "staticImportType", ".", "isPrimaryClassNode", "(", ")", "||", "staticImportType", ".", "isResolved", "(", ")", ")", "{", "if", "(", "staticImportType", ".", "hasPossibleStaticMethod", "(", "methodName", ",", "args", ")", ")", "{", "return", "new", "StaticMethodCallExpression", "(", "staticImportType", ",", "methodName", ",", "args", ")", ";", "}", "}", "return", "null", ";", "}", "protected", "SourceUnit", "getSourceUnit", "(", ")", "{", "return", "source", ";", "}", "}", "</s>" ]
6,940
[ "<s>", "package", "org", ".", "codehaus", ".", "greclipse", ";", "import", "org", ".", "codehaus", ".", "groovy", ".", "antlr", ".", "parser", ".", "GroovyTokenTypes", ";", "public", "class", "GroovyTokenTypeBridge", "{", "public", "static", "int", "IDENT", "=", "GroovyTokenTypes", ".", "IDENT", ";", "public", "static", "int", "LBRACK", "=", "GroovyTokenTypes", ".", "LBRACK", ";", "public", "static", "int", "LCURLY", "=", "GroovyTokenTypes", ".", "LCURLY", ";", "public", "static", "int", "LPAREN", "=", "GroovyTokenTypes", ".", "LPAREN", ";", "public", "static", "int", "NLS", "=", "GroovyTokenTypes", ".", "NLS", ";", "public", "static", "int", "RPAREN", "=", "GroovyTokenTypes", ".", "RPAREN", ";", "public", "static", "int", "STRING_CTOR_START", "=", "GroovyTokenTypes", ".", "STRING_CTOR_START", ";", "public", "static", "int", "WS", "=", "GroovyTokenTypes", ".", "WS", ";", "public", "static", "int", "COMMA", "=", "GroovyTokenTypes", ".", "COMMA", ";", "public", "static", "int", "SEMI", "=", "GroovyTokenTypes", ".", "SEMI", ";", "public", "static", "int", "RCURLY", "=", "GroovyTokenTypes", ".", "RCURLY", ";", "public", "static", "int", "SL_COMMENT", "=", "GroovyTokenTypes", ".", "SL_COMMENT", ";", "public", "static", "int", "CLOSABLE_BLOCK_OP", "=", "GroovyTokenTypes", ".", "CLOSABLE_BLOCK_OP", ";", "public", "static", "int", "EOF", "=", "GroovyTokenTypes", ".", "EOF", ";", "public", "static", "int", "LITERAL_if", "=", "GroovyTokenTypes", ".", "LITERAL_if", ";", "public", "static", "int", "LITERAL_else", "=", "GroovyTokenTypes", ".", "LITERAL_else", ";", "public", "static", "int", "LITERAL_for", "=", "GroovyTokenTypes", ".", "LITERAL_for", ";", "public", "static", "int", "LITERAL_switch", "=", "GroovyTokenTypes", ".", "LITERAL_switch", ";", "public", "static", "int", "LITERAL_while", "=", "GroovyTokenTypes", ".", "LITERAL_while", ";", "public", "static", "int", "RBRACK", "=", "GroovyTokenTypes", ".", "RBRACK", ";", "public", "static", "int", "ML_COMMENT", "=", "GroovyTokenTypes", ".", "ML_COMMENT", ";", "public", "static", "int", "STRING_CTOR_END", "=", "GroovyTokenTypes", ".", "STRING_CTOR_END", ";", "public", "static", "int", "LITERAL_as", "=", "GroovyTokenTypes", ".", "LITERAL_as", ";", "}", "</s>" ]
6,941
[ "<s>", "package", "com", ".", "senseidb", ".", "test", ".", "client", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "SenseiServiceProxy", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "FacetInit", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "FacetType", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Selection", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "SenseiClientRequest", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "TweetsTest", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "addSelection", "(", "Selection", ".", "terms", "(", "\"timeRange\"", ",", "\"000120000\"", ")", ")", ".", "addFacetInit", "(", "\"timeRange\"", ",", "\"time\"", ",", "FacetInit", ".", "build", "(", "FacetType", ".", "type_long", ",", "System", ".", "currentTimeMillis", "(", ")", ")", ")", ".", "build", "(", ")", ";", "SenseiServiceProxy", "senseiServiceProxy", "=", "new", "SenseiServiceProxy", "(", "\"localhost\"", ",", "8080", ")", ";", "System", ".", "out", ".", "println", "(", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ")", ";", "}", "@", "Test", "public", "void", "bareEntry", "(", ")", "throws", "Exception", "{", "}", "}", "</s>" ]
6,942
[ "<s>", "package", "com", ".", "senseidb", ".", "test", ".", "client", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "SenseiServiceProxy", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonSerializer", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Facet", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "FacetInit", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "FacetType", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Operator", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Selection", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "SenseiClientRequest", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Sort", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ".", "Filters", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Queries", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "TextQuery", ".", "Type", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "res", ".", "SenseiResult", ";", "public", "class", "Examples", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "Exception", "{", "SenseiClientRequest", "senseiRequest", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "addFacet", "(", "\"color\"", ",", "Facet", ".", "builder", "(", ")", ".", "minHit", "(", "1", ")", ".", "expand", "(", "true", ")", ".", "orderByHits", "(", ")", ".", "max", "(", "10", ")", ".", "addProperty", "(", "\"\"", ",", "\"3\"", ")", ".", "build", "(", ")", ")", ".", "addFacet", "(", "\"year\"", ",", "Facet", ".", "builder", "(", ")", ".", "minHit", "(", "1", ")", ".", "expand", "(", "true", ")", ".", "orderByVal", "(", ")", ".", "max", "(", "10", ")", ".", "build", "(", ")", ")", ".", "query", "(", "Queries", ".", "stringQuery", "(", "\"cool\"", ")", ")", ".", "addSelection", "(", "Selection", ".", "terms", "(", "\"tags\"", ",", "Arrays", ".", "asList", "(", "\"cool\"", ",", "\"hybrid\"", ")", ",", "Arrays", ".", "asList", "(", "\"favorite\"", ")", ",", "Operator", ".", "and", ")", ")", ".", "addSelection", "(", "Selection", ".", "terms", "(", "\"color\"", ",", "Arrays", ".", "asList", "(", "\"red\"", ")", ",", "new", "ArrayList", "<", "String", ">", "(", ")", ",", "Operator", ".", "or", ")", ")", ".", "paging", "(", "10", ",", "0", ")", ".", "fetchStored", "(", "true", ")", ".", "addSort", "(", "Sort", ".", "desc", "(", "\"price\"", ")", ")", ".", "build", "(", ")", ";", "JSONObject", "serialized", "=", "(", "JSONObject", ")", "JsonSerializer", ".", "serialize", "(", "senseiRequest", ")", ";", "System", ".", "out", ".", "println", "(", "serialized", ".", "toString", "(", "2", ")", ")", ";", "SenseiResult", "senseiResult", "=", "new", "SenseiServiceProxy", "(", "\"localhost\"", ",", "8080", ")", ".", "sendSearchRequest", "(", "senseiRequest", ")", ";", "System", ".", "out", ".", "println", "(", "senseiResult", ")", ";", "}", "public", "static", "SenseiClientRequest", ".", "Builder", "basicWithSelections", "(", "SenseiClientRequest", ".", "Builder", "builder", ")", "{", "builder", ".", "paging", "(", "5", ",", "2", ")", ".", "groupBy", "(", "7", ",", "\"car\"", ",", "\"year\"", ")", ".", "addSelection", "(", "Selection", ".", "path", "(", "\"field\"", ",", "\"value\"", ",", "true", ",", "1", ")", ")", ".", "addSelection", "(", "Selection", ".", "range", "(", "\"color\"", ",", "\"*\"", ",", "\"*\"", ")", ")", ".", "addFacet", "(", "\"facet1\"", ",", "Facet", ".", "builder", "(", ")", ".", "max", "(", "2", ")", ".", "minHit", "(", "1", ")", ".", "orderByVal", "(", ")", ".", "build", "(", ")", ")", ".", "addFacetInit", "(", "\"name\"", ",", "\"parameter\"", ",", "FacetInit", ".", "build", "(", "FacetType", ".", "type_double", ",", "\"val1\"", ",", "\"val2\"", ")", ")", ".", "addTermVector", "(", "\"Term1\"", ")", ".", "explain", "(", "true", ")", ".", "partitions", "(", "Arrays", ".", "asList", "(", "1", ",", "2", ")", ")", ";", "return", "builder", ";", "}", "public", "static", "SenseiClientRequest", ".", "Builder", "filters", "(", "SenseiClientRequest", ".", "Builder", "builder", ")", "{", "builder", ".", "filter", "(", "Filters", ".", "or", "(", "Filters", ".", "and", "(", "Filters", ".", "boolMust", "(", "Filters", ".", "or", "(", "Filters", ".", "term", "(", "\"field\"", ",", "\"value\"", ")", ")", ")", ",", "Filters", ".", "and", "(", "Filters", ".", "or", "(", "Filters", ".", "term", "(", "\"field\"", ",", "\"value\"", ")", ",", "Filters", ".", "terms", "(", "\"Field\"", ",", "Arrays", ".", "asList", "(", "\"a\"", ",", "\"b\"", ")", ",", "Arrays", ".", "asList", "(", "\"a\"", ",", "\"b\"", ")", ",", "Operator", ".", "or", ")", ")", ")", ",", "Filters", ".", "ids", "(", "Arrays", ".", "asList", "(", "\"val2\"", ",", "\"val3\"", ")", ",", "Arrays", ".", "asList", "(", "\"\"", ")", ")", ",", "Filters", ".", "range", "(", "\"field1\"", ",", "\"*\"", ",", "\"*\"", ")", ")", ",", "Filters", ".", "or", "(", "Filters", ".", "ids", "(", "Arrays", ".", "asList", "(", "\"val2\"", ",", "\"val3\"", ")", ",", "Arrays", ".", "asList", "(", "\"\"", ")", ")", ",", "Filters", ".", "range", "(", "\"field1\"", ",", "\"*\"", ",", "\"*\"", ",", "true", ",", "true", ")", ")", ",", "Filters", ".", "ids", "(", "Arrays", ".", "asList", "(", "\"val2\"", ",", "\"val3\"", ")", ",", "Arrays", ".", "asList", "(", "\"\"", ")", ")", ",", "Filters", ".", "term", "(", "\"field\"", ",", "\"value\"", ")", ",", "Filters", ".", "boolShould", "(", "Filters", ".", "or", "(", "Filters", ".", "term", "(", "\"field\"", ",", "\"value\"", ")", ")", ")", ")", ")", ";", "return", "builder", ";", "}", "public", "static", "SenseiClientRequest", ".", "Builder", "queries", "(", "SenseiClientRequest", ".", "Builder", "builder", ")", "{", "List", "<", "Query", ">", "innerQueries", "=", "Arrays", ".", "asList", "(", "Queries", ".", "matchAllQuery", "(", "3", ")", ",", "Queries", ".", "disMax", "(", "2.0", ",", "1.0", ",", "Queries", ".", "term", "(", "\"field1\"", ",", "\"value1\"", ",", "1.0", ")", ")", ",", "Queries", ".", "ids", "(", "Arrays", ".", "asList", "(", "\"val2\"", ",", "\"val3\"", ")", ",", "Arrays", ".", "asList", "(", "\"\"", ")", ",", "1.0", ")", ",", "Queries", ".", "matchAllQuery", "(", "3.0", ")", ",", "Queries", ".", "path", "(", "\"field\"", ",", "\"/path1/path2\"", ",", "1.0", ")", ",", "Queries", ".", "prefix", "(", "\"field\"", ",", "\"prefix\"", ",", "2.0", ")", ",", "Queries", ".", "wildcard", "(", "\"field\"", ",", "\"wildcard\"", ",", "3.0", ")", ",", "Queries", ".", "spanFirst", "(", "Queries", ".", "spanTerm", "(", "\"field\"", ",", "\"val\"", ",", "3.5", ")", ",", "3", ",", "1.0", ")", ",", "Queries", ".", "spanNear", "(", "Arrays", ".", "asList", "(", "Queries", ".", "spanTerm", "(", "\"field\"", ",", "\"val\"", ",", "3.5", ")", ")", ",", "3", ",", "true", ",", "true", ",", "1.0", ")", ",", "Queries", ".", "spanNot", "(", "Queries", ".", "spanTerm", "(", "\"field\"", ",", "\"val\"", ",", "3.5", ")", ",", "Queries", ".", "spanTerm", "(", "\"field\"", ",", "\"val2\"", ",", "3.5", ")", ",", "1.0", ")", ",", "Queries", ".", "spanOr", "(", "1.0", ",", "Queries", ".", "spanTerm", "(", "\"field\"", ",", "\"val\"", ",", "3.5", ")", ")", ",", "Queries", ".", "spanTerm", "(", "\"field\"", ",", "\"val\"", ",", "3.5", ")", ",", "Queries", ".", "textQuery", "(", "\"column\"", ",", "\"text\"", ",", "Operator", ".", "or", ",", "Type", ".", "phrase", ",", "1.0", ")", ",", "Queries", ".", "stringQueryBuilder", "(", ")", ".", "query", "(", "\"\"", ")", ".", "autoGeneratePhraseQueries", "(", "true", ")", ".", "defaultField", "(", "\"field\"", ")", ".", "defaultOperator", "(", "Operator", ".", "and", ")", ".", "fields", "(", "\"field1\"", ",", "\"field2\"", ")", ".", "tieBreaker", "(", "2", ")", ".", "build", "(", ")", ")", ";", "builder", ".", "query", "(", "Queries", ".", "bool", "(", "innerQueries", ",", "null", ",", "null", ",", "2", ",", "2.0", ",", "true", ")", ")", ";", "return", "builder", ";", "}", "public", "static", "SenseiClientRequest", ".", "Builder", "mapReduce", "(", "SenseiClientRequest", ".", "Builder", "builder", ")", "{", "Map", "<", "String", ",", "Object", ">", "params", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "params", ".", "put", "(", "\"column\"", ",", "\"price\"", ")", ";", "builder", ".", "mapReduce", "(", "\"\"", ",", "params", ")", ".", "build", "(", ")", ";", "return", "builder", ";", "}", "}", "</s>" ]
6,943
[ "<s>", "package", "com", ".", "senseidb", ".", "test", ".", "client", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "SenseiServiceProxy", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "SenseiClientRequest", ";", "public", "class", "EmptyRequest", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "SenseiServiceProxy", "senseiServiceProxy", "=", "new", "SenseiServiceProxy", "(", "\"localhost\"", ",", "8080", ")", ";", "System", ".", "out", ".", "println", "(", "senseiServiceProxy", ".", "sendSearchRequest", "(", "SenseiClientRequest", ".", "builder", "(", ")", ".", "build", "(", ")", ")", ")", ";", "}", "}", "</s>" ]
6,944
[ "<s>", "package", "com", ".", "senseidb", ".", "test", ".", "client", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "SenseiServiceProxy", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonSerializer", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Operator", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Selection", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "SenseiClientRequest", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "res", ".", "SenseiResult", ";", "public", "class", "SendRawQuery", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "Exception", "{", "SenseiClientRequest", "senseiRequest", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "paging", "(", "10", ",", "0", ")", ".", "fetchStored", "(", "true", ")", ".", "addSelection", "(", "Selection", ".", "terms", "(", "\"color\"", ",", "Arrays", ".", "asList", "(", "\"red\"", ",", "\"blue\"", ")", ",", "Collections", ".", "EMPTY_LIST", ",", "Operator", ".", "or", ")", ")", ".", "build", "(", ")", ";", "String", "requestStr", "=", "JsonSerializer", ".", "serialize", "(", "senseiRequest", ")", ".", "toString", "(", ")", ";", "System", ".", "out", ".", "println", "(", "requestStr", ")", ";", "SenseiResult", "senseiResult", "=", "new", "SenseiServiceProxy", "(", "\"localhost\"", ",", "8081", ")", ".", "sendBQL", "(", "\"SELECT", "*\"", ")", ";", "System", ".", "out", ".", "println", "(", "senseiResult", ".", "toString", "(", ")", ")", ";", "}", "}", "</s>" ]
6,945
[ "<s>", "package", "com", ".", "senseidb", ".", "test", ".", "client", ";", "import", "java", ".", "io", ".", "ByteArrayInputStream", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "public", "class", "IOUtils", "{", "public", "static", "byte", "[", "]", "getBytes", "(", "InputStream", "is", ")", "throws", "IOException", "{", "int", "len", ";", "int", "size", "=", "1024", ";", "byte", "[", "]", "buf", ";", "if", "(", "is", "instanceof", "ByteArrayInputStream", ")", "{", "size", "=", "is", ".", "available", "(", ")", ";", "buf", "=", "new", "byte", "[", "size", "]", ";", "len", "=", "is", ".", "read", "(", "buf", ",", "0", ",", "size", ")", ";", "}", "else", "{", "ByteArrayOutputStream", "bos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "buf", "=", "new", "byte", "[", "size", "]", ";", "while", "(", "(", "len", "=", "is", ".", "read", "(", "buf", ",", "0", ",", "size", ")", ")", "!=", "-", "1", ")", "bos", ".", "write", "(", "buf", ",", "0", ",", "len", ")", ";", "buf", "=", "bos", ".", "toByteArray", "(", ")", ";", "}", "return", "buf", ";", "}", "}", "</s>" ]
6,946
[ "<s>", "package", "com", ".", "senseidb", ".", "test", ".", "client", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "SenseiServiceProxy", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonSerializer", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "SenseiClientRequest", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Sort", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Queries", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "relevance", ".", "Model", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "relevance", ".", "Relevance", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "relevance", ".", "RelevanceFacetType", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "relevance", ".", "RelevanceValues", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "relevance", ".", "VariableType", ";", "public", "class", "RelevanceExample", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "Exception", "{", "SenseiServiceProxy", "senseiServiceProxy", "=", "new", "SenseiServiceProxy", "(", "\"localhost\"", ",", "8080", ")", ";", "Model", "model", "=", "Model", ".", "builder", "(", ")", ".", "addFacets", "(", "RelevanceFacetType", ".", "type_int", ",", "\"year\"", ",", "\"mileage\"", ")", ".", "addFacets", "(", "RelevanceFacetType", ".", "type_long", ",", "\"groupid\"", ")", ".", "addFacets", "(", "RelevanceFacetType", ".", "type_string", ",", "\"color\"", ",", "\"category\"", ")", ".", "addFunctionParams", "(", "\"_INNER_SCORE\"", ",", "\"thisYear\"", ",", "\"year\"", ",", "\"goodYear\"", ",", "\"\"", ",", "\"mileage\"", ",", "\"color\"", ",", "\"yearcolor\"", ",", "\"colorweight\"", ",", "\"category\"", ",", "\"\"", ")", ".", "addVariables", "(", "VariableType", ".", "set_int", ",", "\"goodYear\"", ")", ".", "addVariables", "(", "VariableType", ".", "type_int", ",", "\"thisYear\"", ")", ".", "addVariables", "(", "VariableType", ".", "map_int_float", ",", "\"\"", ")", ".", "addVariables", "(", "VariableType", ".", "map_int_string", ",", "\"yearcolor\"", ")", ".", "addVariables", "(", "VariableType", ".", "map_string_float", ",", "\"colorweight\"", ")", ".", "addVariables", "(", "VariableType", ".", "map_string_string", ",", "\"\"", ")", ".", "function", "(", "\"\"", ")", ".", "build", "(", ")", ";", "Map", "<", "Object", ",", "Object", ">", "map", "=", "new", "HashMap", "<", "Object", ",", "Object", ">", "(", ")", ";", "map", ".", "put", "(", "\"red\"", ",", "335.5", ")", ";", "RelevanceValues", ".", "RelevanceValuesBuilder", "valuesBuilder", "=", "new", "RelevanceValues", ".", "RelevanceValuesBuilder", "(", ")", ".", "addAtomicValue", "(", "\"thisYear\"", ",", "2001", ")", ".", "addListValue", "(", "\"goodYear\"", ",", "1996", ",", "1997", ")", ".", "addMapValue", "(", "\"\"", ",", "Arrays", ".", "asList", "(", "11400", ",", "11000", ")", ",", "Arrays", ".", "asList", "(", "777.9", ",", "10.2", ")", ")", ".", "addMapValue", "(", "\"colorweight\"", ",", "map", ")", ";", "map", ".", "clear", "(", ")", ";", "map", ".", "put", "(", "1998", ",", "\"red\"", ")", ";", "valuesBuilder", ".", "addMapValue", "(", "\"yearcolor\"", ",", "map", ")", ";", "valuesBuilder", ".", "addMapValue", "(", "\"\"", ",", "Arrays", ".", "asList", "(", "\"compact\"", ")", ",", "Arrays", ".", "asList", "(", "\"white\"", ")", ")", ";", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "addSort", "(", "Sort", ".", "byRelevance", "(", ")", ")", ".", "query", "(", "Queries", ".", "stringQuery", "(", "\"\"", ")", ".", "setRelevance", "(", "Relevance", ".", "valueOf", "(", "model", ",", "valuesBuilder", ".", "build", "(", ")", ")", ")", ")", ".", "showOnlyFields", "(", "\"color\"", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "(", "(", "JSONObject", ")", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ".", "toString", "(", "1", ")", ")", ";", "System", ".", "out", ".", "println", "(", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ")", ";", "}", "}", "</s>" ]
6,947
[ "<s>", "package", "com", ".", "senseidb", ".", "test", ".", "client", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "import", "org", ".", "junit", ".", "Assert", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonDeserializer", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonSerializer", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "FacetInit", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "FacetType", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "SenseiClientRequest", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "res", ".", "SenseiResult", ";", "public", "class", "JsonSerializationTest", "extends", "Assert", "{", "@", "Test", "public", "void", "test1Deserialization", "(", ")", "throws", "Exception", "{", "String", "response", "=", "new", "String", "(", "IOUtils", ".", "getBytes", "(", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ".", "getResourceAsStream", "(", "\"\"", ")", ")", ",", "\"UTF-8\"", ")", ";", "System", ".", "out", ".", "println", "(", "new", "JSONObject", "(", "response", ")", ".", "toString", "(", "2", ")", ")", ";", "SenseiResult", "senseiResult", "=", "JsonDeserializer", ".", "deserialize", "(", "SenseiResult", ".", "class", ",", "new", "JSONObject", "(", "response", ")", ")", ";", "assertEquals", "(", "senseiResult", ".", "getFacets", "(", ")", ".", "size", "(", ")", ",", "2", ")", ";", "System", ".", "out", ".", "println", "(", "senseiResult", ")", ";", "}", "@", "Test", "public", "void", "test2Serialization", "(", ")", "throws", "Exception", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "SenseiClientRequest", "senseiRequest", "=", "Examples", ".", "basicWithSelections", "(", "SenseiClientRequest", ".", "builder", "(", ")", ")", ".", "build", "(", ")", ";", "String", "strRepresentation", "=", "JsonSerializer", ".", "serialize", "(", "senseiRequest", ")", ".", "toString", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "strRepresentation", ")", ";", "SenseiClientRequest", "senseiRequest2", "=", "JsonDeserializer", ".", "deserialize", "(", "SenseiClientRequest", ".", "class", ",", "new", "JSONObject", "(", "strRepresentation", ")", ")", ";", "assertEquals", "(", "senseiRequest2", ".", "getFacets", "(", ")", ".", "size", "(", ")", ",", "1", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "senseiRequest2", ".", "toString", "(", ")", ")", ";", "String", "strRepresentation2", "=", "JsonSerializer", ".", "serialize", "(", "senseiRequest2", ")", ".", "toString", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "strRepresentation2", ")", ";", "assertEquals", "(", "strRepresentation2", ",", "strRepresentation", ")", ";", "}", "public", "void", "test3DeserializeFacetInit", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "senseiRequest", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "addFacetInit", "(", "\"name\"", ",", "\"parameter\"", ",", "FacetInit", ".", "build", "(", "FacetType", ".", "type_float", ",", "\"val1\"", ",", "\"val2\"", ")", ")", ".", "build", "(", ")", ";", "String", "strRepresentation", "=", "JsonSerializer", ".", "serialize", "(", "senseiRequest", ")", ".", "toString", "(", ")", ";", "SenseiClientRequest", "senseiRequest2", "=", "JsonDeserializer", ".", "deserialize", "(", "SenseiClientRequest", ".", "class", ",", "new", "JSONObject", "(", "strRepresentation", ")", ")", ";", "String", "strRepresentation2", "=", "JsonSerializer", ".", "serialize", "(", "senseiRequest2", ")", ".", "toString", "(", ")", ";", "System", ".", "out", ".", "println", "(", "strRepresentation2", ")", ";", "assertEquals", "(", "strRepresentation2", ",", "strRepresentation", ")", ";", "}", "public", "void", "test4FiltersSerialization", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "senseiRequest", "=", "Examples", ".", "filters", "(", "SenseiClientRequest", ".", "builder", "(", ")", ")", ".", "build", "(", ")", ";", "JSONObject", "json", "=", "(", "JSONObject", ")", "JsonSerializer", ".", "serialize", "(", "senseiRequest", ")", ";", "System", ".", "out", ".", "println", "(", "json", ".", "toString", "(", "3", ")", ")", ";", "}", "public", "void", "test5QueriesSerialization", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "senseiRequest", "=", "Examples", ".", "queries", "(", "SenseiClientRequest", ".", "builder", "(", ")", ")", ".", "build", "(", ")", ";", "JSONObject", "json", "=", "(", "JSONObject", ")", "JsonSerializer", ".", "serialize", "(", "senseiRequest", ")", ";", "System", ".", "out", ".", "println", "(", "json", ".", "toString", "(", "3", ")", ")", ";", "}", "}", "</s>" ]
6,948
[ "<s>", "package", "com", ".", "senseidb", ".", "test", ".", "client", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "import", "org", ".", "junit", ".", "Assert", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Ignore", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "SenseiServiceProxy", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonSerializer", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Operator", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Selection", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "SenseiClientRequest", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Sort", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ".", "Filter", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ".", "Filters", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Queries", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "relevance", ".", "Model", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "relevance", ".", "Relevance", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "relevance", ".", "RelevanceFacetType", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "relevance", ".", "RelevanceValues", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "relevance", ".", "VariableType", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "res", ".", "SenseiResult", ";", "@", "Ignore", "public", "class", "JavaClientIntegrationTest", "extends", "Assert", "{", "private", "SenseiServiceProxy", "senseiServiceProxy", ";", "@", "Before", "public", "void", "setUp", "(", ")", "{", "senseiServiceProxy", "=", "new", "SenseiServiceProxy", "(", "\"localhost\"", ",", "8080", ")", ";", "}", "@", "Test", "public", "void", "testSelectionRange", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "addSelection", "(", "Selection", ".", "range", "(", "\"year\"", ",", "\"2000\"", ",", "\"2002\"", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "4455", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "addSelection", "(", "Selection", ".", "range", "(", "\"year\"", ",", "\"2000\"", ",", "\"2002\"", ",", "false", ",", "false", ")", ")", ".", "build", "(", ")", ";", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "1443", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "addSelection", "(", "Selection", ".", "range", "(", "\"year\"", ",", "\"2000\"", ",", "\"2002\"", ",", "false", ",", "true", ")", ")", ".", "build", "(", ")", ";", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "2907", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "addSelection", "(", "Selection", ".", "range", "(", "\"year\"", ",", "\"2000\"", ",", "\"2002\"", ",", "true", ",", "false", ")", ")", ".", "build", "(", ")", ";", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "2991", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testMatchAllWithBoostQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "matchAllQuery", "(", "1.2", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "15000", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testQueryStringQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "stringQuery", "(", "\"red", "AND", "cool\"", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "1070", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "public", "void", "testUIDQueryRaw", "(", ")", "throws", "Exception", "{", "String", "req", "=", "\"\"", ";", "System", ".", "out", ".", "println", "(", "req", ")", ";", "JSONObject", "res", "=", "new", "JSONObject", "(", "senseiServiceProxy", ".", "sendPostRaw", "(", "senseiServiceProxy", ".", "getSearchUrl", "(", ")", ",", "req", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "2", ",", "res", ".", "getInt", "(", "\"numhits\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "1", ",", "res", ".", "getJSONArray", "(", "\"hits\"", ")", ".", "getJSONObject", "(", "0", ")", ".", "getInt", "(", "\"uid\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "3", ",", "res", ".", "getJSONArray", "(", "\"hits\"", ")", ".", "getJSONObject", "(", "1", ")", ".", "getInt", "(", "\"uid\"", ")", ")", ";", "}", "@", "Test", "public", "void", "testUIDQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "ids", "(", "Arrays", ".", "asList", "(", "\"1\"", ",", "\"2\"", ",", "\"3\"", ")", ",", "Arrays", ".", "asList", "(", "\"2\"", ")", ",", "1.0", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "2", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "1", ",", "res", ".", "getHits", "(", ")", ".", "get", "(", "0", ")", ".", "getUid", "(", ")", ".", "intValue", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "3", ",", "res", ".", "getHits", "(", ")", ".", "get", "(", "1", ")", ".", "getUid", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testTextQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "textQuery", "(", "\"contents\"", ",", "\"red", "cool\"", ",", "Operator", ".", "and", ",", "1.0", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "1070", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testTermQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "term", "(", "\"color\"", ",", "\"red\"", ",", "1.0", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "2160", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testSimpleBQL", "(", ")", "throws", "Exception", "{", "String", "bql", "=", "\"\"", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendBQL", "(", "bql", ")", ";", "assertEquals", "(", "\"\"", ",", "2160", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testTermsQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "terms", "(", "\"tags\"", ",", "Arrays", ".", "asList", "(", "\"leather\"", ",", "\"moon-roof\"", ")", ",", "Arrays", ".", "asList", "(", "\"hybrid\"", ")", ",", "Operator", ".", "or", ",", "0", ",", "1.0", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "5777", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testBooleanQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "bool", "(", "Arrays", ".", "asList", "(", "(", "Query", ")", "Queries", ".", "term", "(", "\"color\"", ",", "\"red\"", ",", "1.0", ")", ")", ",", "Arrays", ".", "asList", "(", "(", "Query", ")", "Queries", ".", "term", "(", "\"category\"", ",", "\"compact\"", ",", "1.0", ")", ")", ",", "null", ",", "1.0", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "1652", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testDisMaxQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "disMax", "(", "0.7", ",", "1.2", ",", "Queries", ".", "term", "(", "\"color\"", ",", "\"red\"", ",", "1.0", ")", ",", "Queries", ".", "term", "(", "\"color\"", ",", "\"blue\"", ",", "1.0", ")", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "3264", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testPathQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "path", "(", "\"makemodel\"", ",", "\"\"", ",", "1.0", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "126", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testPrefixQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "prefix", "(", "\"color\"", ",", "\"blu\"", ",", "2.0", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "1104", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testWildcardQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "wildcard", "(", "\"color\"", ",", "\"bl*e\"", ",", "2.0", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "1104", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testRangeQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "range", "(", "\"year\"", ",", "\"1999\"", ",", "\"2000\"", ",", "true", ",", "true", ",", "2.0", ",", "false", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "3015", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testRangeQuery2", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "range", "(", "\"year\"", ",", "\"1999\"", ",", "\"2000\"", ",", "true", ",", "true", ",", "2.0", ",", "false", ",", "\"int\"", ")", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "3015", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testFilteredQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "filteredQuery", "(", "Queries", ".", "term", "(", "\"color\"", ",", "\"red\"", ",", "1.0", ")", ",", "Filters", ".", "range", "(", "\"year\"", ",", "\"1999\"", ",", "\"2000\"", ")", ",", "1.0", ")", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "447", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testSpanTermQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "spanTerm", "(", "\"color\"", ",", "\"red\"", ",", "1.0", ")", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "2160", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testSpanOrQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "spanOr", "(", "1.0", ",", "Queries", ".", "spanTerm", "(", "\"color\"", ",", "\"red\"", ",", "1.0", ")", ",", "Queries", ".", "spanTerm", "(", "\"color\"", ",", "\"blue\"", ")", ")", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "3264", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "public", "void", "testSpanOrQueryRaw", "(", ")", "throws", "Exception", "{", "String", "req", "=", "\"\"", ";", "System", ".", "out", ".", "println", "(", "req", ")", ";", "JSONObject", "res", "=", "new", "JSONObject", "(", "senseiServiceProxy", ".", "sendPostRaw", "(", "senseiServiceProxy", ".", "getSearchUrl", "(", ")", ",", "req", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "3264", ",", "res", ".", "getInt", "(", "\"numhits\"", ")", ")", ";", "}", "@", "Test", "public", "void", "testSpanNotQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "spanNot", "(", "Queries", ".", "spanTerm", "(", "\"contents\"", ",", "\"compact\"", ",", "1.0", ")", ",", "Queries", ".", "spanTerm", "(", "\"contents\"", ",", "\"red\"", ",", "1.0", ")", ",", "1.0", ")", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "4596", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testSpanNearQuery1", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "spanNear", "(", "Arrays", ".", "asList", "(", "Queries", ".", "spanTerm", "(", "\"contents\"", ",", "\"red\"", ")", ",", "Queries", ".", "spanTerm", "(", "\"contents\"", ",", "\"compact\"", ")", ",", "Queries", ".", "spanTerm", "(", "\"contents\"", ",", "\"hybrid\"", ")", ")", ",", "12", ",", "false", ",", "false", ",", "1.0", ")", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "274", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testSpanNearQuery2", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "spanNear", "(", "Arrays", ".", "asList", "(", "Queries", ".", "spanTerm", "(", "\"contents\"", ",", "\"red\"", ")", ",", "Queries", ".", "spanTerm", "(", "\"contents\"", ",", "\"compact\"", ")", ",", "Queries", ".", "spanTerm", "(", "\"contents\"", ",", "\"favorite\"", ")", ")", ",", "0", ",", "true", ",", "false", ",", "1.0", ")", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "63", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testSpanFirstQuery", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "query", "(", "Queries", ".", "spanFirst", "(", "Queries", ".", "spanTerm", "(", "\"color\"", ",", "\"red\"", ")", ",", "2", ",", "1.0", ")", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "2160", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testUIDFilter", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "filter", "(", "Filters", ".", "ids", "(", "Arrays", ".", "asList", "(", "\"1\"", ",", "\"2\"", ",", "\"3\"", ")", ",", "Arrays", ".", "asList", "(", "\"2\"", ")", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "2", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "1", ",", "res", ".", "getHits", "(", ")", ".", "get", "(", "0", ")", ".", "getUid", "(", ")", ".", "intValue", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "3", ",", "res", ".", "getHits", "(", ")", ".", "get", "(", "1", ")", ".", "getUid", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testAndFilter", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "filter", "(", "Filters", ".", "and", "(", "Filters", ".", "term", "(", "\"tags\"", ",", "\"mp3\"", ")", ",", "Filters", ".", "term", "(", "\"color\"", ",", "\"red\"", ")", ")", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "439", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testOrFilter", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "filter", "(", "Filters", ".", "or", "(", "Filters", ".", "term", "(", "\"color\"", ",", "\"blue\"", ")", ",", "Filters", ".", "term", "(", "\"color\"", ",", "\"red\"", ")", ")", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "3264", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testBooleanFilter", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "filter", "(", "Filters", ".", "bool", "(", "Arrays", ".", "asList", "(", "(", "Filter", ")", "Filters", ".", "term", "(", "\"color\"", ",", "\"red\"", ")", ")", ",", "Arrays", ".", "asList", "(", "(", "Filter", ")", "Filters", ".", "term", "(", "\"category\"", ",", "\"compact\"", ")", ")", ",", "Arrays", ".", "asList", "(", "(", "Filter", ")", "Filters", ".", "term", "(", "\"color\"", ",", "\"red\"", ")", ")", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "1652", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testQueryFilter", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "filter", "(", "Filters", ".", "query", "(", "Queries", ".", "range", "(", "\"year\"", ",", "\"1999\"", ",", "\"2000\"", ",", "true", ",", "true", ",", "1.0", ",", "false", ")", ")", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "3015", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testTermFilter", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "filter", "(", "Filters", ".", "term", "(", "\"color\"", ",", "\"red\"", ")", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "2160", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testSingleField", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "showOnlyFields", "(", "\"color\"", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "1", ",", "res", ".", "getHits", "(", ")", ".", "get", "(", "0", ")", ".", "getFieldValues", "(", ")", ".", "size", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testTermsFilter", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "filter", "(", "Filters", ".", "terms", "(", "\"tags\"", ",", "Arrays", ".", "asList", "(", "\"leather\"", ",", "\"moon-roof\"", ")", ",", "Arrays", ".", "asList", "(", "\"hybrid\"", ")", ",", "Operator", ".", "or", ")", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "5777", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testTemplateMapping", "(", ")", "throws", "Exception", "{", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "filter", "(", "Filters", ".", "range", "(", "\"year\"", ",", "\"$from\"", ",", "\"$to\"", ")", ")", ".", "explain", "(", "true", ")", ".", "addTemplateMapping", "(", "\"from\"", ",", "\"1999\"", ")", ".", "addTemplateMapping", "(", "\"to\"", ",", "\"2000\"", ")", ".", "build", "(", ")", ";", "System", ".", "out", ".", "println", "(", "JsonSerializer", ".", "serialize", "(", "request", ")", ")", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "\"\"", ",", "3015", ",", "res", ".", "getNumhits", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testGetStoreQuery", "(", ")", "throws", "Exception", "{", "Map", "<", "Long", ",", "JSONObject", ">", "ret", "=", "senseiServiceProxy", ".", "sendGetRequest", "(", "1L", ",", "2L", ",", "3L", ",", "5L", ")", ";", "assertEquals", "(", "4", ",", "ret", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "Integer", ".", "valueOf", "(", "1", ")", ",", "ret", ".", "get", "(", "1L", ")", ".", "get", "(", "\"id\"", ")", ")", ";", "assertEquals", "(", "11", ",", "ret", ".", "get", "(", "1L", ")", ".", "names", "(", ")", ".", "length", "(", ")", ")", ";", "assertEquals", "(", "Integer", ".", "valueOf", "(", "2", ")", ",", "ret", ".", "get", "(", "2L", ")", ".", "get", "(", "\"id\"", ")", ")", ";", "assertEquals", "(", "Integer", ".", "valueOf", "(", "3", ")", ",", "ret", ".", "get", "(", "3L", ")", ".", "get", "(", "\"id\"", ")", ")", ";", "assertEquals", "(", "Integer", ".", "valueOf", "(", "5", ")", ",", "ret", ".", "get", "(", "5L", ")", ".", "get", "(", "\"id\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "ret", ".", "get", "(", "5L", ")", ".", "get", "(", "\"tags\"", ")", ")", ";", "}", "@", "Test", "public", "void", "testRelevance", "(", ")", "throws", "Exception", "{", "Model", "model", "=", "Model", ".", "builder", "(", ")", ".", "addFacets", "(", "RelevanceFacetType", ".", "type_int", ",", "\"year\"", ",", "\"mileage\"", ")", ".", "addFacets", "(", "RelevanceFacetType", ".", "type_long", ",", "\"groupid\"", ")", ".", "addFacets", "(", "RelevanceFacetType", ".", "type_string", ",", "\"color\"", ",", "\"category\"", ")", ".", "addFunctionParams", "(", "\"_INNER_SCORE\"", ",", "\"thisYear\"", ",", "\"year\"", ",", "\"goodYear\"", ",", "\"\"", ",", "\"mileage\"", ",", "\"color\"", ",", "\"yearcolor\"", ",", "\"colorweight\"", ",", "\"category\"", ",", "\"\"", ")", ".", "addVariables", "(", "VariableType", ".", "set_int", ",", "\"goodYear\"", ")", ".", "addVariables", "(", "VariableType", ".", "type_int", ",", "\"thisYear\"", ")", ".", "addVariables", "(", "VariableType", ".", "map_int_float", ",", "\"\"", ")", ".", "addVariables", "(", "VariableType", ".", "map_int_string", ",", "\"yearcolor\"", ")", ".", "addVariables", "(", "VariableType", ".", "map_string_float", ",", "\"colorweight\"", ")", ".", "addVariables", "(", "VariableType", ".", "map_string_string", ",", "\"\"", ")", ".", "saveAs", "(", "\"model\"", ",", "true", ")", ".", "function", "(", "\"\"", ")", ".", "build", "(", ")", ";", "Map", "<", "Object", ",", "Object", ">", "map", "=", "new", "HashMap", "<", "Object", ",", "Object", ">", "(", ")", ";", "map", ".", "put", "(", "\"red\"", ",", "335.5", ")", ";", "RelevanceValues", ".", "RelevanceValuesBuilder", "valuesBuilder", "=", "new", "RelevanceValues", ".", "RelevanceValuesBuilder", "(", ")", ".", "addAtomicValue", "(", "\"thisYear\"", ",", "2001", ")", ".", "addListValue", "(", "\"goodYear\"", ",", "1996", ",", "1997", ")", ".", "addMapValue", "(", "\"\"", ",", "Arrays", ".", "asList", "(", "11400", ",", "11000", ")", ",", "Arrays", ".", "asList", "(", "777.9", ",", "10.2", ")", ")", ".", "addMapValue", "(", "\"colorweight\"", ",", "map", ")", ";", "map", ".", "clear", "(", ")", ";", "map", ".", "put", "(", "1998", ",", "\"red\"", ")", ";", "valuesBuilder", ".", "addMapValue", "(", "\"yearcolor\"", ",", "map", ")", ";", "valuesBuilder", ".", "addMapValue", "(", "\"\"", ",", "Arrays", ".", "asList", "(", "\"compact\"", ")", ",", "Arrays", ".", "asList", "(", "\"white\"", ")", ")", ";", "SenseiClientRequest", "request", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "addSort", "(", "Sort", ".", "byRelevance", "(", ")", ")", ".", "query", "(", "Queries", ".", "stringQuery", "(", "\"\"", ")", ".", "setRelevance", "(", "Relevance", ".", "valueOf", "(", "model", ",", "valuesBuilder", ".", "build", "(", ")", ")", ")", ")", ".", "build", "(", ")", ";", "SenseiResult", "senseiResult", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "request", ")", ";", "assertEquals", "(", "10777", ",", "senseiResult", ".", "getHits", "(", ")", ".", "get", "(", "0", ")", ".", "getScore", "(", ")", ".", "intValue", "(", ")", ")", ";", "assertEquals", "(", "0", ",", "senseiResult", ".", "getErrorCode", "(", ")", ".", "intValue", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testError", "(", ")", "throws", "Exception", "{", "String", "bql", "=", "\"\"", ";", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendBQL", "(", "bql", ")", ";", "assertEquals", "(", "150", ",", "res", ".", "getErrorCode", "(", ")", ".", "intValue", "(", ")", ")", ";", "assertEquals", "(", "1", ",", "res", ".", "getErrors", "(", ")", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "res", ".", "getErrors", "(", ")", ".", "get", "(", "0", ")", ".", "getMessage", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "res", ".", "getErrors", "(", ")", ".", "get", "(", "0", ")", ".", "getErrorType", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testMapReduce", "(", ")", "throws", "Exception", "{", "SenseiResult", "res", "=", "senseiServiceProxy", ".", "sendSearchRequest", "(", "Examples", ".", "mapReduce", "(", "SenseiClientRequest", ".", "builder", "(", ")", ")", ".", "build", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "res", ".", "getMapReduceResult", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "}", "</s>" ]
6,949
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ";", "import", "java", ".", "io", ".", "BufferedInputStream", ";", "import", "java", ".", "io", ".", "BufferedOutputStream", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "net", ".", "HttpURLConnection", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "LinkedHashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Map", ".", "Entry", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "java", ".", "util", ".", "zip", ".", "GZIPInputStream", ";", "import", "org", ".", "json", ".", "JSONArray", ";", "import", "org", ".", "json", ".", "JSONException", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonDeserializer", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonSerializer", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "SenseiClientRequest", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "res", ".", "SenseiResult", ";", "public", "class", "SenseiServiceProxy", "{", "private", "String", "host", ";", "private", "int", "port", ";", "private", "final", "String", "url", ";", "public", "SenseiServiceProxy", "(", "String", "host", ",", "int", "port", ")", "{", "this", ".", "host", "=", "host", ";", "this", ".", "port", "=", "port", ";", "this", ".", "url", "=", "null", ";", "}", "public", "SenseiServiceProxy", "(", "String", "url", ")", "{", "this", ".", "url", "=", "url", ";", "}", "public", "SenseiResult", "sendSearchRequest", "(", "SenseiClientRequest", "request", ")", "{", "try", "{", "String", "requestStr", "=", "JsonSerializer", ".", "serialize", "(", "request", ")", ".", "toString", "(", ")", ";", "String", "output", "=", "sendPostRaw", "(", "getSearchUrl", "(", ")", ",", "requestStr", ")", ";", "return", "JsonDeserializer", ".", "deserialize", "(", "SenseiResult", ".", "class", ",", "jsonResponse", "(", "output", ")", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "ex", ")", ";", "}", "}", "public", "SenseiResult", "sendBQL", "(", "String", "bql", ")", "{", "try", "{", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", ")", ";", "buffer", ".", "append", "(", "\"{'bql':\"", ")", ".", "append", "(", "bql", ")", ".", "append", "(", "\"}\"", ")", ";", "String", "requestStr", "=", "buffer", ".", "toString", "(", ")", ";", "String", "output", "=", "sendPostRaw", "(", "getSearchUrl", "(", ")", ",", "requestStr", ")", ";", "return", "JsonDeserializer", ".", "deserialize", "(", "SenseiResult", ".", "class", ",", "jsonResponse", "(", "output", ")", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "ex", ")", ";", "}", "}", "public", "Map", "<", "Long", ",", "JSONObject", ">", "sendGetRequest", "(", "long", "...", "uids", ")", "throws", "IOException", ",", "JSONException", "{", "Map", "<", "Long", ",", "JSONObject", ">", "ret", "=", "new", "LinkedHashMap", "<", "Long", ",", "JSONObject", ">", "(", "uids", ".", "length", ")", ";", "String", "response", "=", "sendPostRaw", "(", "getStoreGetUrl", "(", ")", ",", "new", "JSONArray", "(", "uids", ")", ".", "toString", "(", ")", ")", ";", "if", "(", "response", "==", "null", "||", "response", ".", "length", "(", ")", "==", "0", ")", "{", "return", "ret", ";", "}", "JSONObject", "responseJson", "=", "new", "JSONObject", "(", "response", ")", ";", "Iterator", "keys", "=", "responseJson", ".", "keys", "(", ")", ";", "while", "(", "keys", ".", "hasNext", "(", ")", ")", "{", "String", "key", "=", "(", "String", ")", "keys", ".", "next", "(", ")", ";", "ret", ".", "put", "(", "Long", ".", "parseLong", "(", "key", ")", ",", "responseJson", ".", "optJSONObject", "(", "key", ")", ")", ";", "}", "return", "ret", ";", "}", "public", "String", "getSearchUrl", "(", ")", "{", "if", "(", "url", "!=", "null", ")", "return", "url", ";", "return", "\"http://\"", "+", "host", "+", "\":\"", "+", "port", "+", "\"/sensei\"", ";", "}", "public", "String", "getStoreGetUrl", "(", ")", "{", "if", "(", "url", "!=", "null", ")", "return", "url", "+", "\"/get\"", ";", "return", "\"http://\"", "+", "host", "+", "\":\"", "+", "port", "+", "\"/sensei/get\"", ";", "}", "private", "JSONObject", "jsonResponse", "(", "String", "output", ")", "throws", "JSONException", "{", "return", "new", "JSONObject", "(", "output", ")", ";", "}", "byte", "[", "]", "drain", "(", "InputStream", "inputStream", ")", "throws", "IOException", "{", "try", "{", "byte", "[", "]", "buf", "=", "new", "byte", "[", "1024", "]", ";", "int", "len", ";", "ByteArrayOutputStream", "byteArrayOutputStream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "while", "(", "(", "len", "=", "inputStream", ".", "read", "(", "buf", ")", ")", ">", "0", ")", "{", "byteArrayOutputStream", ".", "write", "(", "buf", ",", "0", ",", "len", ")", ";", "}", "return", "byteArrayOutputStream", ".", "toByteArray", "(", ")", ";", "}", "finally", "{", "inputStream", ".", "close", "(", ")", ";", "}", "}", "public", "String", "sendPostRaw", "(", "String", "urlStr", ",", "String", "requestStr", ")", "{", "return", "this", ".", "sendPostRaw", "(", "urlStr", ",", "requestStr", ",", "null", ")", ";", "}", "public", "String", "sendPostRaw", "(", "String", "urlStr", ",", "String", "requestStr", ",", "Map", "<", "String", ",", "String", ">", "headers", ")", "{", "HttpURLConnection", "conn", "=", "null", ";", "try", "{", "URL", "url", "=", "new", "URL", "(", "urlStr", ")", ";", "conn", "=", "(", "HttpURLConnection", ")", "url", ".", "openConnection", "(", ")", ";", "conn", ".", "setDoOutput", "(", "true", ")", ";", "conn", ".", "setRequestMethod", "(", "\"POST\"", ")", ";", "conn", ".", "setRequestProperty", "(", "\"\"", ",", "\"gzip\"", ")", ";", "String", "string", "=", "requestStr", ";", "byte", "[", "]", "requestBytes", "=", "string", ".", "getBytes", "(", "\"UTF-8\"", ")", ";", "conn", ".", "setRequestProperty", "(", "\"\"", ",", "String", ".", "valueOf", "(", "requestBytes", ".", "length", ")", ")", ";", "conn", ".", "setRequestProperty", "(", "\"\"", ",", "String", ".", "valueOf", "(", "true", ")", ")", ";", "conn", ".", "setRequestProperty", "(", "\"default\"", ",", "String", ".", "valueOf", "(", "true", ")", ")", ";", "if", "(", "headers", "!=", "null", "&&", "headers", ".", "size", "(", ")", ">", "0", ")", "{", "Set", "<", "Entry", "<", "String", ",", "String", ">", ">", "entries", "=", "headers", ".", "entrySet", "(", ")", ";", "for", "(", "Entry", "<", "String", ",", "String", ">", "entry", ":", "entries", ")", "{", "conn", ".", "setRequestProperty", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "OutputStream", "os", "=", "new", "BufferedOutputStream", "(", "conn", ".", "getOutputStream", "(", ")", ")", ";", "os", ".", "write", "(", "requestBytes", ")", ";", "os", ".", "flush", "(", ")", ";", "os", ".", "close", "(", ")", ";", "int", "responseCode", "=", "conn", ".", "getResponseCode", "(", ")", ";", "if", "(", "responseCode", "!=", "HttpURLConnection", ".", "HTTP_OK", ")", "{", "throw", "new", "IOException", "(", "\"\"", "+", "responseCode", ")", ";", "}", "byte", "[", "]", "bytes", "=", "drain", "(", "new", "GZIPInputStream", "(", "new", "BufferedInputStream", "(", "conn", ".", "getInputStream", "(", ")", ")", ")", ")", ";", "String", "output", "=", "new", "String", "(", "bytes", ",", "\"UTF-8\"", ")", ";", "return", "output", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "ex", ")", ";", "}", "finally", "{", "if", "(", "conn", "!=", "null", ")", "conn", ".", "disconnect", "(", ")", ";", "}", "}", "}", "</s>" ]
6,950
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "res", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "json", ".", "JSONArray", ";", "import", "org", ".", "json", ".", "JSONException", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonDeserializer", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonHandler", ";", "public", "class", "SenseiHitJsonHandler", "implements", "JsonHandler", "<", "SenseiHit", ">", "{", "private", "static", "final", "Set", "<", "String", ">", "PREDEFINED_FIELDS", "=", "new", "HashSet", "<", "String", ">", "(", "Arrays", ".", "asList", "(", "\"uid\"", ",", "\"docid\"", ",", "\"score\"", ",", "\"srcdata\"", ",", "\"\"", ",", "\"groupHits\"", ",", "\"stored\"", ",", "\"termvectors\"", ",", "\"explanation\"", ")", ")", ";", "@", "Override", "public", "JSONObject", "serialize", "(", "SenseiHit", "bean", ")", "throws", "JSONException", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "@", "Override", "public", "SenseiHit", "deserialize", "(", "JSONObject", "json", ")", "throws", "JSONException", "{", "if", "(", "json", "==", "null", ")", "{", "return", "null", ";", "}", "SenseiHit", "senseiHit", "=", "JsonDeserializer", ".", "deserialize", "(", "SenseiHit", ".", "class", ",", "json", ",", "false", ")", ";", "JSONArray", "storedFieldsArr", "=", "json", ".", "optJSONArray", "(", "\"stored\"", ")", ";", "if", "(", "storedFieldsArr", "!=", "null", ")", "{", "List", "<", "FieldValue", ">", "storedFields", "=", "new", "ArrayList", "<", "FieldValue", ">", "(", "storedFieldsArr", ".", "length", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "storedFieldsArr", ".", "length", "(", ")", ";", "i", "++", ")", "{", "JSONObject", "storedJson", "=", "storedFieldsArr", ".", "optJSONObject", "(", "i", ")", ";", "if", "(", "storedJson", "!=", "null", ")", "{", "String", "fieldName", "=", "(", "String", ")", "storedJson", ".", "keys", "(", ")", ".", "next", "(", ")", ";", "storedFields", ".", "add", "(", "new", "FieldValue", "(", "fieldName", ",", "storedJson", ".", "optString", "(", "fieldName", ")", ")", ")", ";", "}", "}", "senseiHit", ".", "setStoredFields", "(", "storedFields", ")", ";", "}", "Iterator", "iterator", "=", "json", ".", "keys", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "String", "field", "=", "(", "String", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "PREDEFINED_FIELDS", ".", "contains", "(", "field", ")", ")", "{", "continue", ";", "}", "JSONArray", "jsonArr", "=", "json", ".", "optJSONArray", "(", "field", ")", ";", "if", "(", "jsonArr", "!=", "null", ")", "{", "List", "<", "String", ">", "values", "=", "new", "ArrayList", "<", "String", ">", "(", "jsonArr", ".", "length", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "jsonArr", ".", "length", "(", ")", ";", "i", "++", ")", "{", "values", ".", "add", "(", "jsonArr", ".", "getString", "(", "i", ")", ")", ";", "}", "senseiHit", ".", "getFieldValues", "(", ")", ".", "put", "(", "field", ",", "values", ")", ";", "}", "}", "return", "senseiHit", ";", "}", "}", "</s>" ]
6,951
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "res", ";", "public", "class", "FacetResult", "{", "private", "String", "value", ";", "private", "Boolean", "selected", "=", "false", ";", "private", "Integer", "count", ";", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "value", "+", "\",", "selected=\"", "+", "selected", "+", "\",", "count=\"", "+", "count", "+", "\"]\"", ";", "}", "public", "String", "getValue", "(", ")", "{", "return", "value", ";", "}", "public", "Boolean", "getSelected", "(", ")", "{", "return", "selected", ";", "}", "public", "Integer", "getCount", "(", ")", "{", "return", "count", ";", "}", "}", "</s>" ]
6,952
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "res", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonField", ";", "@", "CustomJsonHandler", "(", "SenseiHitJsonHandler", ".", "class", ")", "public", "class", "SenseiHit", "{", "@", "JsonField", "(", "\"_uid\"", ")", "private", "Long", "uid", ";", "@", "JsonField", "(", "\"_docid\"", ")", "private", "Integer", "docid", ";", "@", "JsonField", "(", "\"_score\"", ")", "private", "Double", "score", ";", "@", "JsonField", "(", "\"_srcdata\"", ")", "private", "String", "srcdata", ";", "@", "JsonField", "(", "\"\"", ")", "private", "Integer", "grouphitscount", ";", "private", "List", "<", "SenseiHit", ">", "groupHits", "=", "new", "ArrayList", "<", "SenseiHit", ">", "(", ")", ";", "private", "List", "<", "FieldValue", ">", "storedFields", "=", "new", "ArrayList", "<", "FieldValue", ">", "(", ")", ";", "@", "JsonField", "(", "\"termvectors\"", ")", "private", "Map", "<", "String", ",", "List", "<", "TermFrequency", ">", ">", "fieldTermFrequencies", "=", "new", "HashMap", "<", "String", ",", "List", "<", "TermFrequency", ">", ">", "(", ")", ";", "private", "Explanation", "explanation", ";", "private", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "fieldValues", "=", "new", "HashMap", "<", "String", ",", "List", "<", "String", ">", ">", "(", ")", ";", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "\"\"", "+", "uid", "+", "\",", "docid=\"", "+", "docid", "+", "\",", "score=\"", "+", "score", "+", "\",", "srcdata=\"", "+", "srcdata", "+", "\"\"", "+", "grouphitscount", "+", "\"\"", "+", "groupHits", "+", "\"\"", "+", "storedFields", "+", "\"\"", "+", "fieldTermFrequencies", "+", "\"\"", "+", "explanation", "+", "\"\"", "+", "fieldValues", "+", "\"]\"", ";", "}", "public", "Long", "getUid", "(", ")", "{", "return", "uid", ";", "}", "public", "Integer", "getDocid", "(", ")", "{", "return", "docid", ";", "}", "public", "Double", "getScore", "(", ")", "{", "return", "score", ";", "}", "public", "String", "getSrcdata", "(", ")", "{", "return", "srcdata", ";", "}", "public", "Integer", "getGrouphitscount", "(", ")", "{", "return", "grouphitscount", ";", "}", "public", "List", "<", "SenseiHit", ">", "getGroupHits", "(", ")", "{", "return", "groupHits", ";", "}", "public", "void", "setUid", "(", "Long", "uid", ")", "{", "this", ".", "uid", "=", "uid", ";", "}", "public", "void", "setDocid", "(", "Integer", "docid", ")", "{", "this", ".", "docid", "=", "docid", ";", "}", "public", "void", "setScore", "(", "Double", "score", ")", "{", "this", ".", "score", "=", "score", ";", "}", "public", "void", "setSrcdata", "(", "String", "srcdata", ")", "{", "this", ".", "srcdata", "=", "srcdata", ";", "}", "public", "void", "setGrouphitscount", "(", "Integer", "grouphitscount", ")", "{", "this", ".", "grouphitscount", "=", "grouphitscount", ";", "}", "public", "void", "setGroupHits", "(", "List", "<", "SenseiHit", ">", "groupHits", ")", "{", "this", ".", "groupHits", "=", "groupHits", ";", "}", "public", "List", "<", "FieldValue", ">", "getStoredFields", "(", ")", "{", "return", "storedFields", ";", "}", "public", "void", "setStoredFields", "(", "List", "<", "FieldValue", ">", "storedFields", ")", "{", "this", ".", "storedFields", "=", "storedFields", ";", "}", "public", "Map", "<", "String", ",", "List", "<", "TermFrequency", ">", ">", "getFieldTermFrequencies", "(", ")", "{", "return", "fieldTermFrequencies", ";", "}", "public", "Explanation", "getExplanation", "(", ")", "{", "return", "explanation", ";", "}", "public", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "getFieldValues", "(", ")", "{", "return", "fieldValues", ";", "}", "}", "</s>" ]
6,953
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "res", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonField", ";", "public", "class", "SenseiResult", "{", "private", "Long", "tid", ";", "private", "Integer", "totaldocs", ";", "private", "Integer", "numhits", ";", "private", "Integer", "numgroups", ";", "private", "List", "<", "SenseiHit", ">", "hits", "=", "new", "ArrayList", "<", "SenseiHit", ">", "(", ")", ";", "@", "JsonField", "(", "\"parsedquery\"", ")", "private", "String", "parsedQuery", ";", "private", "Long", "time", ";", "private", "Map", "<", "String", ",", "List", "<", "FacetResult", ">", ">", "facets", ";", "private", "JSONObject", "mapReduceResult", ";", "private", "Integer", "errorCode", ";", "private", "List", "<", "Error", ">", "errors", ";", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "tid", "+", "\",", "totaldocs=\"", "+", "totaldocs", "+", "\",", "numhits=\"", "+", "numhits", "+", "\",", "numgroups=\"", "+", "numgroups", "+", "\",", "nhits=\"", "+", "hits", "+", "\"\"", "+", "mapReduceResult", "+", "\"\"", "+", "parsedQuery", "+", "\",", "time=\"", "+", "time", "+", "\",", "nfacets=\"", "+", "facets", "+", "\"]\"", ";", "}", "public", "Long", "getTid", "(", ")", "{", "return", "tid", ";", "}", "public", "void", "setTid", "(", "Long", "tid", ")", "{", "this", ".", "tid", "=", "tid", ";", "}", "public", "Integer", "getTotaldocs", "(", ")", "{", "return", "totaldocs", ";", "}", "public", "void", "setTotaldocs", "(", "Integer", "totaldocs", ")", "{", "this", ".", "totaldocs", "=", "totaldocs", ";", "}", "public", "Integer", "getNumhits", "(", ")", "{", "return", "numhits", ";", "}", "public", "void", "setNumhits", "(", "Integer", "numhits", ")", "{", "this", ".", "numhits", "=", "numhits", ";", "}", "public", "Integer", "getNumgroups", "(", ")", "{", "return", "numgroups", ";", "}", "public", "void", "setNumgroups", "(", "Integer", "numgroups", ")", "{", "this", ".", "numgroups", "=", "numgroups", ";", "}", "public", "List", "<", "SenseiHit", ">", "getHits", "(", ")", "{", "return", "hits", ";", "}", "public", "void", "setHits", "(", "List", "<", "SenseiHit", ">", "hits", ")", "{", "this", ".", "hits", "=", "hits", ";", "}", "public", "String", "getParsedQuery", "(", ")", "{", "return", "parsedQuery", ";", "}", "public", "void", "setParsedQuery", "(", "String", "parsedQuery", ")", "{", "this", ".", "parsedQuery", "=", "parsedQuery", ";", "}", "public", "Long", "getTime", "(", ")", "{", "return", "time", ";", "}", "public", "void", "setTime", "(", "Long", "time", ")", "{", "this", ".", "time", "=", "time", ";", "}", "public", "Map", "<", "String", ",", "List", "<", "FacetResult", ">", ">", "getFacets", "(", ")", "{", "return", "facets", ";", "}", "public", "void", "setFacets", "(", "Map", "<", "String", ",", "List", "<", "FacetResult", ">", ">", "facets", ")", "{", "this", ".", "facets", "=", "facets", ";", "}", "public", "JSONObject", "getMapReduceResult", "(", ")", "{", "return", "mapReduceResult", ";", "}", "public", "void", "setMapReduceResult", "(", "JSONObject", "mapReduceResult", ")", "{", "this", ".", "mapReduceResult", "=", "mapReduceResult", ";", "}", "public", "Integer", "getErrorCode", "(", ")", "{", "return", "errorCode", ";", "}", "public", "void", "setErrorCode", "(", "Integer", "errorCode", ")", "{", "this", ".", "errorCode", "=", "errorCode", ";", "}", "public", "List", "<", "Error", ">", "getErrors", "(", ")", "{", "if", "(", "errors", "==", "null", ")", "errors", "=", "new", "ArrayList", "<", "Error", ">", "(", ")", ";", "return", "errors", ";", "}", "public", "void", "setErrors", "(", "List", "<", "Error", ">", "errors", ")", "{", "this", ".", "errors", "=", "errors", ";", "}", "}", "</s>" ]
6,954
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "res", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonField", ";", "public", "class", "TermFrequency", "{", "private", "String", "term", ";", "@", "JsonField", "(", "\"freq\"", ")", "private", "Integer", "frequency", ";", "public", "String", "getTerm", "(", ")", "{", "return", "term", ";", "}", "public", "void", "setTerm", "(", "String", "term", ")", "{", "this", ".", "term", "=", "term", ";", "}", "public", "int", "getFrequency", "(", ")", "{", "return", "frequency", ";", "}", "public", "void", "setFrequency", "(", "int", "frequency", ")", "{", "this", ".", "frequency", "=", "frequency", ";", "}", "public", "TermFrequency", "(", "String", "term", ",", "int", "frequency", ")", "{", "super", "(", ")", ";", "this", ".", "term", "=", "term", ";", "this", ".", "frequency", "=", "frequency", ";", "}", "public", "TermFrequency", "(", ")", "{", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "term", "+", "\",", "frequency=\"", "+", "frequency", "+", "\"]\"", ";", "}", "}", "</s>" ]
6,955
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "res", ";", "public", "class", "Error", "{", "private", "String", "message", ";", "private", "String", "errorType", ";", "public", "String", "getMessage", "(", ")", "{", "return", "message", ";", "}", "public", "void", "setMessage", "(", "String", "message", ")", "{", "this", ".", "message", "=", "message", ";", "}", "public", "String", "getErrorType", "(", ")", "{", "return", "errorType", ";", "}", "public", "void", "setErrorType", "(", "String", "errorType", ")", "{", "this", ".", "errorType", "=", "errorType", ";", "}", "}", "</s>" ]
6,956
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "res", ";", "public", "class", "FieldValue", "{", "private", "String", "fieldName", ";", "private", "String", "fieldValues", ";", "public", "FieldValue", "(", "String", "fieldName", ",", "String", "fieldValues", ")", "{", "super", "(", ")", ";", "this", ".", "fieldName", "=", "fieldName", ";", "this", ".", "fieldValues", "=", "fieldValues", ";", "}", "public", "String", "getFieldName", "(", ")", "{", "return", "fieldName", ";", "}", "public", "void", "setFieldName", "(", "String", "fieldName", ")", "{", "this", ".", "fieldName", "=", "fieldName", ";", "}", "public", "String", "getFieldValues", "(", ")", "{", "return", "fieldValues", ";", "}", "public", "void", "setFieldValues", "(", "String", "fieldValues", ")", "{", "this", ".", "fieldValues", "=", "fieldValues", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "fieldName", "+", "\"\"", "+", "fieldValues", "+", "\"]\"", ";", "}", "}", "</s>" ]
6,957
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "res", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "Explanation", "{", "Double", "value", ";", "String", "description", ";", "List", "<", "Explanation", ">", "details", "=", "new", "ArrayList", "<", "Explanation", ">", "(", ")", ";", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "value", "+", "\"\"", "+", "description", "+", "\",", "details=\"", "+", "details", "+", "\"]\"", ";", "}", "public", "Double", "getValue", "(", ")", "{", "return", "value", ";", "}", "public", "String", "getDescription", "(", ")", "{", "return", "description", ";", "}", "public", "List", "<", "Explanation", ">", "getDetails", "(", ")", "{", "return", "details", ";", "}", "}", "</s>" ]
6,958
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Annotation", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Set", ";", "public", "class", "ReflectionUtil", "{", "public", "static", "Set", "<", "Annotation", ">", "getAnnotations", "(", "Class", "cls", ")", "{", "Set", "<", "Annotation", ">", "ret", "=", "new", "HashSet", "<", "Annotation", ">", "(", ")", ";", "ret", ".", "addAll", "(", "Arrays", ".", "asList", "(", "cls", ".", "getAnnotations", "(", ")", ")", ")", ";", "if", "(", "cls", ".", "getSuperclass", "(", ")", "!=", "null", ")", "{", "ret", ".", "addAll", "(", "getAnnotations", "(", "cls", ".", "getSuperclass", "(", ")", ")", ")", ";", "}", "for", "(", "Class", "intrface", ":", "cls", ".", "getInterfaces", "(", ")", ")", "{", "ret", ".", "addAll", "(", "getAnnotations", "(", "intrface", ")", ")", ";", "}", "return", "ret", ";", "}", "public", "static", "Annotation", "getAnnotation", "(", "Class", "cls", ",", "Class", "annotationCls", ")", "{", "if", "(", "cls", "==", "null", ")", "{", "return", "null", ";", "}", "Annotation", "ret", "=", "cls", ".", "getAnnotation", "(", "annotationCls", ")", ";", "if", "(", "ret", "!=", "null", ")", "{", "return", "ret", ";", "}", "ret", "=", "getAnnotation", "(", "cls", ".", "getSuperclass", "(", ")", ",", "annotationCls", ")", ";", "if", "(", "ret", "!=", "null", ")", "{", "return", "ret", ";", "}", "for", "(", "Class", "intrface", ":", "cls", ".", "getInterfaces", "(", ")", ")", "{", "ret", "=", "getAnnotation", "(", "intrface", ",", "annotationCls", ")", ";", "if", "(", "ret", "!=", "null", ")", "{", "return", "ret", ";", "}", "}", "return", "null", ";", "}", "}", "</s>" ]
6,959
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Field", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Modifier", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "IdentityHashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "java", ".", "util", ".", "WeakHashMap", ";", "import", "org", ".", "json", ".", "JSONArray", ";", "import", "org", ".", "json", ".", "JSONException", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "ReflectionUtil", ";", "public", "class", "JsonSerializer", "{", "public", "static", "String", "NULL", "=", "\"__NULL__\"", ";", "public", "static", "Object", "serialize", "(", "Object", "object", ")", "{", "try", "{", "return", "serialize", "(", "object", ",", "true", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "ex", ")", ";", "}", "}", "public", "static", "Object", "serialize", "(", "Object", "object", ",", "boolean", "handleCustomJsonHandler", ")", "throws", "JSONException", "{", "return", "serialize", "(", "Collections", ".", "newSetFromMap", "(", "new", "IdentityHashMap", "(", ")", ")", ",", "object", ",", "handleCustomJsonHandler", ")", ";", "}", "private", "static", "Object", "serialize", "(", "Set", "<", "Object", ">", "parents", ",", "Object", "object", ",", "boolean", "handleCustomJsonHandler", ")", "throws", "JSONException", "{", "if", "(", "object", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "parents", ".", "contains", "(", "object", ")", ")", "{", "return", "null", ";", "}", "parents", ".", "add", "(", "object", ")", ";", "try", "{", "if", "(", "object", "instanceof", "String", "||", "object", "instanceof", "Number", "||", "object", "instanceof", "Boolean", "||", "object", ".", "getClass", "(", ")", ".", "isPrimitive", "(", ")", "||", "object", "instanceof", "JSONObject", ")", "{", "return", "object", ";", "}", "CustomJsonHandler", "customJsonHandler", "=", "getCustomJsonHandlerByType", "(", "object", ".", "getClass", "(", ")", ")", ";", "if", "(", "customJsonHandler", "!=", "null", "&&", "handleCustomJsonHandler", ")", "{", "JsonHandler", "jsonHandler", "=", "instantiate", "(", "customJsonHandler", ".", "value", "(", ")", ")", ";", "return", "jsonHandler", ".", "serialize", "(", "object", ")", ";", "}", "if", "(", "object", ".", "getClass", "(", ")", ".", "isEnum", "(", ")", ")", "{", "return", "object", ".", "toString", "(", ")", ";", "}", "if", "(", "object", "instanceof", "Collection", ")", "{", "Collection", "collection", "=", "(", "Collection", ")", "object", ";", "List", "<", "Object", ">", "arr", "=", "new", "ArrayList", "<", "Object", ">", "(", "collection", ".", "size", "(", ")", ")", ";", "for", "(", "Object", "obj", ":", "collection", ")", "{", "arr", ".", "add", "(", "serialize", "(", "parents", ",", "obj", ",", "true", ")", ")", ";", "}", "return", "new", "JSONArray", "(", "arr", ")", ";", "}", "if", "(", "object", "instanceof", "Map", ")", "{", "Map", "map", "=", "(", "Map", ")", "object", ";", "JSONObject", "ret", "=", "new", "JSONObject", "(", ")", ";", "for", "(", "Map", ".", "Entry", "entry", ":", "(", "Set", "<", "Map", ".", "Entry", ">", ")", "map", ".", "entrySet", "(", ")", ")", "{", "Object", "key", "=", "serialize", "(", "parents", ",", "entry", ".", "getKey", "(", ")", ",", "true", ")", ";", "if", "(", "key", "==", "null", ")", "key", "=", "NULL", ";", "else", "key", "=", "key", ".", "toString", "(", ")", ";", "ret", ".", "put", "(", "(", "String", ")", "key", ",", "serialize", "(", "parents", ",", "entry", ".", "getValue", "(", ")", ",", "true", ")", ")", ";", "}", "return", "ret", ";", "}", "JSONObject", "ret", "=", "new", "JSONObject", "(", ")", ";", "for", "(", "Field", "field", ":", "object", ".", "getClass", "(", ")", ".", "getDeclaredFields", "(", ")", ")", "{", "if", "(", "Modifier", ".", "isStatic", "(", "field", ".", "getModifiers", "(", ")", ")", ")", "continue", ";", "field", ".", "setAccessible", "(", "true", ")", ";", "String", "name", "=", "field", ".", "getName", "(", ")", ";", "if", "(", "field", ".", "isAnnotationPresent", "(", "JsonField", ".", "class", ")", ")", "{", "name", "=", "field", ".", "getAnnotation", "(", "JsonField", ".", "class", ")", ".", "value", "(", ")", ";", "}", "try", "{", "CustomJsonHandler", "customJsonHandlerAnnotation", "=", "getCustomJsonHandlerByField", "(", "field", ")", ";", "Object", "fieldValue", "=", "field", ".", "get", "(", "object", ")", ";", "if", "(", "customJsonHandlerAnnotation", "==", "null", ")", "{", "ret", ".", "put", "(", "name", ",", "serialize", "(", "parents", ",", "fieldValue", ",", "true", ")", ")", ";", "}", "else", "{", "JsonHandler", "jsonHandler", "=", "instantiate", "(", "customJsonHandlerAnnotation", ".", "value", "(", ")", ")", ";", "Object", "fieldJson", "=", "jsonHandler", ".", "serialize", "(", "fieldValue", ")", ";", "if", "(", "customJsonHandlerAnnotation", ".", "flatten", "(", ")", "&&", "fieldJson", "!=", "null", ")", "{", "String", "[", "]", "names", "=", "JSONObject", ".", "getNames", "(", "(", "JSONObject", ")", "fieldJson", ")", ";", "if", "(", "names", "==", "null", "||", "names", ".", "length", "!=", "1", ")", "{", "throw", "new", "IllegalStateException", "(", "\"\"", "+", "fieldJson", ")", ";", "}", "Object", "internalJson", "=", "(", "(", "JSONObject", ")", "fieldJson", ")", ".", "opt", "(", "names", "[", "0", "]", ")", ";", "if", "(", "customJsonHandlerAnnotation", ".", "overrideColumnName", "(", ")", ")", "{", "name", "=", "names", "[", "0", "]", ";", "}", "fieldJson", "=", "internalJson", ";", "}", "ret", ".", "put", "(", "name", ",", "fieldJson", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "return", "ret", ";", "}", "finally", "{", "parents", ".", "remove", "(", "object", ")", ";", "}", "}", "private", "static", "Map", "<", "Class", "<", "?", ">", ",", "CustomJsonHandler", ">", "jsonHandlersByType", "=", "Collections", ".", "synchronizedMap", "(", "new", "WeakHashMap", "<", "Class", "<", "?", ">", ",", "CustomJsonHandler", ">", "(", ")", ")", ";", "private", "static", "Map", "<", "Field", ",", "CustomJsonHandler", ">", "jsonHandlersByField", "=", "Collections", ".", "synchronizedMap", "(", "new", "WeakHashMap", "<", "Field", ",", "CustomJsonHandler", ">", "(", ")", ")", ";", "private", "static", "Map", "<", "Class", "<", "?", "extends", "JsonHandler", ">", ",", "JsonHandler", ">", "jsonHandlers", "=", "Collections", ".", "synchronizedMap", "(", "new", "WeakHashMap", "<", "Class", "<", "?", "extends", "JsonHandler", ">", ",", "JsonHandler", ">", "(", ")", ")", ";", "private", "static", "CustomJsonHandler", "getCustomJsonHandlerByType", "(", "Class", "<", "?", ">", "cls", ")", "{", "if", "(", "!", "jsonHandlersByType", ".", "containsKey", "(", "cls", ")", ")", "{", "CustomJsonHandler", "customJsonHandler", "=", "(", "CustomJsonHandler", ")", "ReflectionUtil", ".", "getAnnotation", "(", "cls", ",", "CustomJsonHandler", ".", "class", ")", ";", "jsonHandlersByType", ".", "put", "(", "cls", ",", "customJsonHandler", ")", ";", "}", "return", "jsonHandlersByType", ".", "get", "(", "cls", ")", ";", "}", "private", "static", "CustomJsonHandler", "getCustomJsonHandlerByField", "(", "Field", "field", ")", "{", "if", "(", "!", "jsonHandlersByField", ".", "containsKey", "(", "field", ")", ")", "{", "CustomJsonHandler", "customJsonHandler", "=", "field", ".", "getAnnotation", "(", "CustomJsonHandler", ".", "class", ")", ";", "jsonHandlersByField", ".", "put", "(", "field", ",", "customJsonHandler", ")", ";", "}", "return", "jsonHandlersByField", ".", "get", "(", "field", ")", ";", "}", "private", "static", "JsonHandler", "instantiate", "(", "Class", "<", "?", "extends", "JsonHandler", ">", "cls", ")", "{", "if", "(", "!", "jsonHandlers", ".", "containsKey", "(", "cls", ")", ")", "{", "try", "{", "jsonHandlers", ".", "put", "(", "cls", ",", "cls", ".", "newInstance", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "return", "jsonHandlers", ".", "get", "(", "cls", ")", ";", "}", "}", "</s>" ]
6,960
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ";", "import", "java", ".", "lang", ".", "annotation", ".", "ElementType", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Target", ";", "@", "Target", "(", "{", "ElementType", ".", "TYPE", ",", "ElementType", ".", "FIELD", "}", ")", "@", "Retention", "(", "RetentionPolicy", ".", "RUNTIME", ")", "public", "@", "interface", "CustomJsonHandler", "{", "Class", "<", "?", "extends", "JsonHandler", "<", "?", ">", ">", "value", "(", ")", ";", "boolean", "flatten", "(", ")", "default", "false", ";", "boolean", "overrideColumnName", "(", ")", "default", "false", ";", "}", "</s>" ]
6,961
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ";", "import", "java", ".", "lang", ".", "annotation", ".", "ElementType", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Target", ";", "@", "Target", "(", "{", "ElementType", ".", "FIELD", "}", ")", "@", "Retention", "(", "RetentionPolicy", ".", "RUNTIME", ")", "public", "@", "interface", "JsonField", "{", "String", "value", "(", ")", "default", "\"\"", ";", "}", "</s>" ]
6,962
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Field", ";", "import", "java", ".", "lang", ".", "reflect", ".", "ParameterizedType", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Type", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "json", ".", "JSONArray", ";", "import", "org", ".", "json", ".", "JSONException", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "ReflectionUtil", ";", "public", "class", "JsonDeserializer", "{", "public", "static", "<", "T", ">", "T", "deserialize", "(", "Class", "<", "T", ">", "cls", ",", "JSONObject", "jsonObject", ")", "{", "return", "deserialize", "(", "cls", ",", "jsonObject", ",", "true", ")", ";", "}", "public", "static", "<", "T", ">", "T", "deserialize", "(", "Class", "<", "T", ">", "cls", ",", "JSONObject", "jsonObject", ",", "boolean", "handleCustomJsonHandler", ")", "{", "try", "{", "if", "(", "jsonObject", "==", "null", ")", "{", "return", "null", ";", "}", "CustomJsonHandler", "customJsonHandler", "=", "(", "CustomJsonHandler", ")", "ReflectionUtil", ".", "getAnnotation", "(", "cls", ",", "CustomJsonHandler", ".", "class", ")", ";", "if", "(", "customJsonHandler", "!=", "null", "&&", "handleCustomJsonHandler", ")", "{", "JsonHandler", "jsonHandler", ";", "try", "{", "jsonHandler", "=", "customJsonHandler", ".", "value", "(", ")", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "return", "(", "T", ")", "jsonHandler", ".", "deserialize", "(", "jsonObject", ")", ";", "}", "T", "obj", "=", "cls", ".", "newInstance", "(", ")", ";", "for", "(", "Field", "field", ":", "cls", ".", "getDeclaredFields", "(", ")", ")", "{", "field", ".", "setAccessible", "(", "true", ")", ";", "Class", "<", "?", ">", "type", "=", "field", ".", "getType", "(", ")", ";", "String", "name", "=", "field", ".", "getName", "(", ")", ";", "if", "(", "field", ".", "isAnnotationPresent", "(", "JsonField", ".", "class", ")", ")", "{", "name", "=", "field", ".", "getAnnotation", "(", "JsonField", ".", "class", ")", ".", "value", "(", ")", ";", "}", "Type", "genericType", "=", "field", ".", "getGenericType", "(", ")", ";", "Object", "value", "=", "null", ";", "if", "(", "jsonObject", ".", "opt", "(", "name", ")", "==", "null", ")", "{", "continue", ";", "}", "if", "(", "type", "==", "Integer", ".", "class", ")", "{", "value", "=", "jsonObject", ".", "optInt", "(", "name", ")", ";", "}", "else", "if", "(", "type", ".", "isPrimitive", "(", ")", ")", "{", "value", "=", "jsonObject", ".", "opt", "(", "name", ")", ";", "}", "else", "if", "(", "type", "==", "Boolean", ".", "class", ")", "{", "value", "=", "jsonObject", ".", "optBoolean", "(", "name", ")", ";", "}", "else", "if", "(", "type", "==", "Long", ".", "class", ")", "{", "try", "{", "value", "=", "Long", ".", "parseLong", "(", "jsonObject", ".", "optString", "(", "name", ",", "\"0\"", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "value", "=", "0L", ";", "}", "}", "else", "if", "(", "type", "==", "String", ".", "class", ")", "{", "value", "=", "jsonObject", ".", "optString", "(", "name", ")", ";", "}", "else", "if", "(", "type", "==", "Double", ".", "class", ")", "{", "value", "=", "jsonObject", ".", "optDouble", "(", "name", ")", ";", "}", "else", "if", "(", "type", "==", "JSONObject", ".", "class", ")", "{", "value", "=", "jsonObject", ".", "optJSONObject", "(", "name", ")", ";", "}", "else", "if", "(", "type", ".", "isEnum", "(", ")", ")", "{", "value", "=", "jsonObject", ".", "optString", "(", "name", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "value", "=", "Enum", ".", "valueOf", "(", "(", "Class", ")", "type", ",", "value", ".", "toString", "(", ")", ")", ";", "}", "}", "else", "if", "(", "type", "==", "List", ".", "class", ")", "{", "JSONArray", "jsonArray", "=", "jsonObject", ".", "optJSONArray", "(", "name", ")", ";", "if", "(", "jsonArray", "==", "null", ")", "{", "continue", ";", "}", "boolean", "isParameterizedType", "=", "genericType", "instanceof", "ParameterizedType", ";", "value", "=", "deserializeArray", "(", "(", "isParameterizedType", "?", "getGenericType", "(", "genericType", ",", "0", ")", ":", "null", ")", ",", "jsonArray", ")", ";", "}", "else", "if", "(", "type", "==", "Map", ".", "class", ")", "{", "value", "=", "deserializeMap", "(", "genericType", ",", "jsonObject", ".", "getJSONObject", "(", "name", ")", ")", ";", "if", "(", "value", "==", "null", ")", "{", "continue", ";", "}", "}", "else", "{", "JSONObject", "propObj", "=", "jsonObject", ".", "optJSONObject", "(", "name", ")", ";", "if", "(", "propObj", "==", "null", ")", "{", "continue", ";", "}", "if", "(", "type", "==", "JSONObject", ".", "class", ")", "{", "value", "=", "propObj", ";", "}", "else", "{", "value", "=", "deserialize", "(", "type", ",", "propObj", ")", ";", "}", "}", "field", ".", "set", "(", "obj", ",", "value", ")", ";", "}", "return", "obj", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "ex", ".", "getMessage", "(", ")", ",", "ex", ")", ";", "}", "}", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "private", "static", "Map", "deserializeMap", "(", "Type", "genericType", ",", "JSONObject", "mapJson", ")", "throws", "Exception", "{", "Map", "map", "=", "new", "HashMap", "(", ")", ";", "if", "(", "mapJson", "==", "null", ")", "{", "return", "null", ";", "}", "String", "[", "]", "names", "=", "JSONObject", ".", "getNames", "(", "mapJson", ")", ";", "if", "(", "names", "==", "null", ")", "{", "return", "null", ";", "}", "Type", "valueType", "=", "getGenericType", "(", "genericType", ",", "1", ")", ";", "for", "(", "String", "paramName", ":", "names", ")", "{", "Object", "mapValue", "=", "mapJson", ".", "opt", "(", "paramName", ")", ";", "if", "(", "JsonSerializer", ".", "NULL", ".", "equals", "(", "paramName", ")", ")", "paramName", "=", "null", ";", "if", "(", "mapValue", "==", "null", ")", "{", "map", ".", "put", "(", "paramName", ",", "null", ")", ";", "}", "else", "if", "(", "mapValue", "instanceof", "JSONArray", ")", "{", "if", "(", "valueType", "instanceof", "ParameterizedType", ")", "{", "map", ".", "put", "(", "paramName", ",", "deserializeArray", "(", "getGenericType", "(", "valueType", ",", "0", ")", ",", "(", "JSONArray", ")", "mapValue", ")", ")", ";", "}", "else", "{", "map", ".", "put", "(", "paramName", ",", "deserializeArray", "(", "null", ",", "(", "JSONArray", ")", "mapValue", ")", ")", ";", "}", "}", "else", "if", "(", "valueType", "instanceof", "ParameterizedType", "&&", "Map", ".", "class", ".", "isAssignableFrom", "(", "(", "(", "Class", ")", "(", "(", "ParameterizedType", ")", "valueType", ")", ".", "getRawType", "(", ")", ")", ")", ")", "{", "map", ".", "put", "(", "paramName", ",", "deserializeMap", "(", "valueType", ",", "(", "JSONObject", ")", "mapValue", ")", ")", ";", "}", "else", "if", "(", "mapValue", "instanceof", "JSONObject", ")", "{", "map", ".", "put", "(", "paramName", ",", "deserialize", "(", "(", "Class", ")", "valueType", ",", "(", "JSONObject", ")", "mapValue", ")", ")", ";", "}", "else", "{", "map", ".", "put", "(", "paramName", ",", "mapValue", ")", ";", "}", "}", "return", "map", ";", "}", "private", "static", "List", "deserializeArray", "(", "Type", "type", ",", "JSONArray", "jsonArray", ")", "throws", "JSONException", "{", "ArrayList", "value", "=", "new", "ArrayList", "(", "jsonArray", ".", "length", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "jsonArray", ".", "length", "(", ")", ";", "i", "++", ")", "{", "Object", "elem", "=", "jsonArray", ".", "get", "(", "i", ")", ";", "if", "(", "elem", "instanceof", "JSONObject", ")", "{", "(", "(", "List", ")", "value", ")", ".", "add", "(", "deserialize", "(", "(", "Class", ")", "type", ",", "(", "JSONObject", ")", "elem", ")", ")", ";", "}", "else", "{", "(", "(", "List", ")", "value", ")", ".", "add", "(", "elem", ")", ";", "}", "}", "return", "value", ";", "}", "private", "static", "Type", "getGenericType", "(", "Field", "field", ")", "{", "ParameterizedType", "paramType", "=", "(", "ParameterizedType", ")", "field", ".", "getGenericType", "(", ")", ";", "return", "paramType", ".", "getActualTypeArguments", "(", ")", "[", "0", "]", ";", "}", "private", "static", "Type", "getGenericType", "(", "Type", "cls", ",", "int", "paramIndex", ")", "{", "return", "(", "(", "ParameterizedType", ")", "cls", ")", ".", "getActualTypeArguments", "(", ")", "[", "paramIndex", "]", ";", "}", "}", "</s>" ]
6,963
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ";", "import", "org", ".", "json", ".", "JSONException", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "public", "interface", "JsonHandler", "<", "T", ">", "{", "JSONObject", "serialize", "(", "T", "bean", ")", "throws", "JSONException", ";", "T", "deserialize", "(", "JSONObject", "json", ")", "throws", "JSONException", ";", "}", "</s>" ]
6,964
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonSerializer", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Facet", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Selection", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "SenseiClientRequest", ";", "public", "class", "Test", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "Exception", "{", "SenseiServiceProxy", "senseiServiceProxy", "=", "new", "SenseiServiceProxy", "(", "\"localhost\"", ",", "8080", ")", ";", "SenseiClientRequest", "clientRequest", "=", "SenseiClientRequest", ".", "builder", "(", ")", ".", "filter", "(", "Selection", ".", "terms", "(", "\"account_id\"", ",", "\"1139\"", ")", ")", ".", "paging", "(", "1000", ",", "10", ")", ".", "addFacet", "(", "\"account_id\"", ",", "Facet", ".", "builder", "(", ")", ".", "minHit", "(", "0", ")", ".", "max", "(", "200", ")", ".", "build", "(", ")", ")", ".", "build", "(", ")", ";", "JSONObject", "json", "=", "(", "JSONObject", ")", "JsonSerializer", ".", "serialize", "(", "clientRequest", ")", ";", "JSONObject", "mapReduce", "=", "new", "JSONObject", "(", ")", ".", "put", "(", "\"function\"", ",", "\"\"", ")", ".", "put", "(", "\"parameters\"", ",", "new", "JSONObject", "(", ")", ".", "put", "(", "\"column\"", ",", "\"account_id\"", ")", ")", ";", "json", ".", "put", "(", "\"mapReduce\"", ",", "mapReduce", ")", ";", "System", ".", "out", ".", "println", "(", "new", "JSONObject", "(", "senseiServiceProxy", ".", "sendPostRaw", "(", "senseiServiceProxy", ".", "getSearchUrl", "(", ")", ",", "json", ".", "toString", "(", ")", ")", ")", ".", "toString", "(", "1", ")", ")", ";", "}", "}", "</s>" ]
6,965
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Query", ";", "public", "class", "Term", "extends", "Selection", "{", "private", "String", "value", ";", "private", "double", "boost", ";", "public", "Term", "(", "String", "value", ")", "{", "super", "(", ")", ";", "this", ".", "value", "=", "value", ";", "}", "public", "Term", "(", "String", "value", ",", "double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "value", "=", "value", ";", "this", ".", "boost", "=", "boost", ";", "}", "public", "Term", "(", ")", "{", "}", "}", "</s>" ]
6,966
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ";", "public", "enum", "FacetType", "{", "type_int", ",", "type_long", ",", "type_double", ",", "type_float", ",", "type_short", ",", "type_string", ";", "public", "String", "getValue", "(", ")", "{", "return", "this", ".", "name", "(", ")", ".", "substring", "(", "\"type_\"", ".", "length", "(", ")", ")", ";", "}", "}", "</s>" ]
6,967
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ";", "public", "class", "Sort", "{", "private", "String", "field", ";", "private", "String", "order", ";", "public", "static", "Sort", "asc", "(", "String", "field", ")", "{", "Sort", "sort", "=", "new", "Sort", "(", ")", ";", "sort", ".", "field", "=", "field", ";", "sort", ".", "order", "=", "Order", ".", "asc", ".", "name", "(", ")", ";", "return", "sort", ";", "}", "public", "static", "Sort", "desc", "(", "String", "field", ")", "{", "Sort", "sort", "=", "new", "Sort", "(", ")", ";", "sort", ".", "field", "=", "field", ";", "sort", ".", "order", "=", "Order", ".", "desc", ".", "name", "(", ")", ";", "return", "sort", ";", "}", "public", "static", "Sort", "byRelevance", "(", ")", "{", "Sort", "sort", "=", "new", "Sort", "(", ")", ";", "sort", ".", "field", "=", "\"_score\"", ";", "return", "sort", ";", "}", "public", "static", "enum", "Order", "{", "desc", ",", "asc", ";", "}", "public", "String", "getField", "(", ")", "{", "return", "field", ";", "}", "public", "Order", "getOrder", "(", ")", "{", "if", "(", "order", "==", "null", ")", "{", "return", "null", ";", "}", "return", "Order", ".", "valueOf", "(", "order", ")", ";", "}", "}", "</s>" ]
6,968
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "class", "MapReduce", "{", "private", "String", "function", ";", "private", "Map", "<", "String", ",", "Object", ">", "parameters", ";", "public", "String", "getFunction", "(", ")", "{", "return", "function", ";", "}", "public", "void", "setFunction", "(", "String", "function", ")", "{", "this", ".", "function", "=", "function", ";", "}", "public", "Map", "<", "String", ",", "Object", ">", "getParameters", "(", ")", "{", "return", "parameters", ";", "}", "public", "void", "setParameters", "(", "Map", "<", "String", ",", "Object", ">", "parameters", ")", "{", "this", ".", "parameters", "=", "parameters", ";", "}", "public", "MapReduce", "(", "String", "function", ",", "Map", "<", "String", ",", "Object", ">", "parameters", ")", "{", "super", "(", ")", ";", "this", ".", "function", "=", "function", ";", "this", ".", "parameters", "=", "parameters", ";", "}", "}", "</s>" ]
6,969
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "FacetInit", "{", "String", "type", ";", "List", "<", "Object", ">", "values", ";", "public", "static", "FacetInit", "build", "(", "FacetType", "type", ",", "Object", "...", "values", ")", "{", "FacetInit", "facetInit", "=", "new", "FacetInit", "(", ")", ";", "facetInit", ".", "type", "=", "type", ".", "getValue", "(", ")", ";", "facetInit", ".", "values", "=", "Arrays", ".", "asList", "(", "values", ")", ";", "return", "facetInit", ";", "}", "public", "static", "FacetInit", "build", "(", "FacetType", "type", ",", "List", "<", "Object", ">", "values", ")", "{", "FacetInit", "facetInit", "=", "new", "FacetInit", "(", ")", ";", "facetInit", ".", "type", "=", "type", ".", "getValue", "(", ")", ";", "facetInit", ".", "values", "=", "values", ";", "return", "facetInit", ";", "}", "}", "</s>" ]
6,970
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Operator", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Path", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Range", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Selection", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Term", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Terms", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ".", "Filter", ".", "AndOr", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Query", ";", "public", "class", "Filters", "{", "public", "static", "Ids", "ids", "(", "List", "<", "String", ">", "values", ",", "List", "<", "String", ">", "excludes", ")", "{", "return", "new", "Ids", "(", "values", ",", "excludes", ")", ";", "}", "public", "static", "AndOr", "and", "(", "Filter", "...", "filters", ")", "{", "return", "new", "AndOr", "(", "Arrays", ".", "asList", "(", "filters", ")", ",", "Operator", ".", "and", ")", ";", "}", "public", "static", "AndOr", "or", "(", "Filter", "...", "filters", ")", "{", "return", "new", "AndOr", "(", "Arrays", ".", "asList", "(", "filters", ")", ",", "Operator", ".", "or", ")", ";", "}", "public", "static", "QueryFilter", "query", "(", "Query", "query", ")", "{", "return", "new", "QueryFilter", "(", "query", ")", ";", "}", "public", "static", "BoolFilter", "bool", "(", "List", "<", "Filter", ">", "must", ",", "List", "<", "Filter", ">", "must_not", ",", "List", "<", "Filter", ">", "should", ")", "{", "return", "new", "BoolFilter", "(", "must", ",", "must_not", ",", "should", ")", ";", "}", "public", "static", "BoolFilter", "boolMust", "(", "Filter", "...", "must", ")", "{", "return", "new", "BoolFilter", "(", "Arrays", ".", "asList", "(", "must", ")", ",", "null", ",", "null", ")", ";", "}", "public", "static", "BoolFilter", "boolMustNot", "(", "Filter", "...", "mustNot", ")", "{", "return", "new", "BoolFilter", "(", "null", ",", "Arrays", ".", "asList", "(", "mustNot", ")", ",", "null", ")", ";", "}", "public", "static", "BoolFilter", "boolShould", "(", "Filter", "...", "should", ")", "{", "return", "new", "BoolFilter", "(", "null", ",", "null", ",", "Arrays", ".", "asList", "(", "should", ")", ")", ";", "}", "public", "static", "IsNull", "isNull", "(", "String", "fieldName", ")", "{", "return", "new", "IsNull", "(", "fieldName", ")", ";", "}", "public", "static", "Term", "term", "(", "String", "field", ",", "String", "value", ")", "{", "return", "(", "Term", ")", "new", "Term", "(", "value", ")", ".", "setField", "(", "field", ")", ";", "}", "public", "static", "Selection", "terms", "(", "String", "field", ",", "List", "<", "String", ">", "values", ",", "List", "<", "String", ">", "excludes", ",", "Operator", "op", ")", "{", "return", "new", "Terms", "(", "values", ",", "excludes", ",", "op", ")", ".", "setField", "(", "field", ")", ";", "}", "public", "static", "Selection", "range", "(", "String", "field", ",", "String", "lower", ",", "String", "upper", ",", "boolean", "includeUpper", ",", "boolean", "includeLower", ")", "{", "return", "new", "Range", "(", "lower", ",", "upper", ",", "includeUpper", ",", "includeLower", ")", ".", "setField", "(", "field", ")", ";", "}", "public", "static", "Selection", "range", "(", "String", "field", ",", "String", "lower", ",", "String", "upper", ")", "{", "return", "new", "Range", "(", "lower", ",", "upper", ",", "true", ",", "true", ")", ".", "setField", "(", "field", ")", ";", "}", "public", "static", "Range", "range", "(", "String", "field", ",", "String", "from", ",", "String", "to", ",", "boolean", "includeLower", ",", "boolean", "includeUpper", ",", "boolean", "noOptimize", ",", "String", "type", ")", "{", "return", "(", "Range", ")", "new", "Range", "(", "from", ",", "to", ",", "includeLower", ",", "includeUpper", ",", "(", "Double", ")", "null", ",", "noOptimize", ")", ".", "setField", "(", "field", ")", ";", "}", "public", "static", "Selection", "path", "(", "String", "field", ",", "String", "value", ",", "boolean", "strict", ",", "int", "depth", ")", "{", "return", "new", "Path", "(", "value", ",", "strict", ",", "depth", ")", ".", "setField", "(", "field", ")", ";", "}", "}", "</s>" ]
6,971
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ";", "public", "class", "IsNull", "implements", "Filter", "{", "private", "String", "field", ";", "public", "IsNull", "(", "String", "field", ")", "{", "super", "(", ")", ";", "this", ".", "field", "=", "field", ";", "}", "public", "String", "getField", "(", ")", "{", "return", "field", ";", "}", "public", "void", "setField", "(", "String", "field", ")", "{", "this", ".", "field", "=", "field", ";", "}", "}", "</s>" ]
6,972
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ";", "import", "java", ".", "util", ".", "List", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonField", ";", "@", "CustomJsonHandler", "(", "FilterJsonHandler", ".", "class", ")", "public", "class", "BoolFilter", "implements", "Filter", "{", "List", "<", "Filter", ">", "must", ";", "List", "<", "Filter", ">", "must_not", ";", "List", "<", "Filter", ">", "should", ";", "@", "JsonField", "(", "\"\"", ")", "Boolean", "minimumNumberShouldMatch", ";", "Double", "boost", ";", "Boolean", "disableCoord", ";", "public", "BoolFilter", "(", "List", "<", "Filter", ">", "must", ",", "List", "<", "Filter", ">", "must_not", ",", "List", "<", "Filter", ">", "should", ")", "{", "super", "(", ")", ";", "this", ".", "must", "=", "must", ";", "this", ".", "must_not", "=", "must_not", ";", "this", ".", "should", "=", "should", ";", "}", "public", "List", "<", "Filter", ">", "getMust", "(", ")", "{", "return", "must", ";", "}", "public", "void", "setMust", "(", "List", "<", "Filter", ">", "must", ")", "{", "this", ".", "must", "=", "must", ";", "}", "public", "List", "<", "Filter", ">", "getMust_not", "(", ")", "{", "return", "must_not", ";", "}", "public", "void", "setMust_not", "(", "List", "<", "Filter", ">", "must_not", ")", "{", "this", ".", "must_not", "=", "must_not", ";", "}", "public", "List", "<", "Filter", ">", "getShould", "(", ")", "{", "return", "should", ";", "}", "public", "void", "setShould", "(", "List", "<", "Filter", ">", "should", ")", "{", "this", ".", "should", "=", "should", ";", "}", "}", "</s>" ]
6,973
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Query", ";", "@", "CustomJsonHandler", "(", "FilterJsonHandler", ".", "class", ")", "public", "class", "QueryFilter", "implements", "Filter", "{", "private", "Query", "query", ";", "public", "QueryFilter", "(", "Query", "query", ")", "{", "super", "(", ")", ";", "this", ".", "query", "=", "query", ";", "}", "public", "Query", "getQuery", "(", ")", "{", "return", "query", ";", "}", "}", "</s>" ]
6,974
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Operator", ";", "public", "interface", "Filter", "{", "public", "static", "class", "AndOr", "implements", "Filter", "{", "List", "<", "Filter", ">", "filters", "=", "new", "ArrayList", "<", "Filter", ">", "(", ")", ";", ";", "Operator", "operation", ";", "public", "AndOr", "(", "List", "<", "Filter", ">", "filters", ",", "Operator", "operation", ")", "{", "super", "(", ")", ";", "this", ".", "filters", "=", "filters", ";", "this", ".", "operation", "=", "operation", ";", "}", "public", "List", "<", "Filter", ">", "getFilters", "(", ")", "{", "return", "filters", ";", "}", "public", "Operator", "getOperation", "(", ")", "{", "return", "operation", ";", "}", "}", "}", "</s>" ]
6,975
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ";", "import", "java", ".", "util", ".", "List", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "QueryJsonHandler", ";", "@", "CustomJsonHandler", "(", "QueryJsonHandler", ".", "class", ")", "public", "class", "Ids", "extends", "Query", "implements", "Filter", "{", "List", "<", "String", ">", "values", ";", "List", "<", "String", ">", "excludes", ";", "private", "double", "boost", ";", "public", "Ids", "(", "List", "<", "String", ">", "values", ",", "List", "<", "String", ">", "excludes", ")", "{", "super", "(", ")", ";", "this", ".", "values", "=", "values", ";", "this", ".", "excludes", "=", "excludes", ";", "}", "public", "Ids", "(", "List", "<", "String", ">", "values", ",", "List", "<", "String", ">", "excludes", ",", "double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "values", "=", "values", ";", "this", ".", "excludes", "=", "excludes", ";", "this", ".", "boost", "=", "boost", ";", "}", "public", "List", "<", "String", ">", "getValues", "(", ")", "{", "return", "values", ";", "}", "public", "List", "<", "String", ">", "getExcludes", "(", ")", "{", "return", "excludes", ";", "}", "}", "</s>" ]
6,976
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "json", ".", "JSONArray", ";", "import", "org", ".", "json", ".", "JSONException", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonSerializer", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Selection", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "SelectionJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ".", "Filter", ".", "AndOr", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "QueryJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "StringQuery", ";", "public", "class", "FilterJsonHandler", "implements", "JsonHandler", "<", "Filter", ">", "{", "private", "SelectionJsonHandler", "selectionJsonHandler", "=", "new", "SelectionJsonHandler", "(", ")", ";", "private", "QueryJsonHandler", "queryJsonHandler", "=", "new", "QueryJsonHandler", "(", ")", ";", "@", "Override", "public", "JSONObject", "serialize", "(", "Filter", "bean", ")", "throws", "JSONException", "{", "if", "(", "bean", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "bean", "instanceof", "Selection", ")", "{", "return", "selectionJsonHandler", ".", "serialize", "(", "(", "Selection", ")", "bean", ")", ";", "}", "if", "(", "bean", "instanceof", "StringQuery", ")", "{", "JSONObject", "ret", "=", "(", "JSONObject", ")", "JsonSerializer", ".", "serialize", "(", "bean", ")", ";", "return", "new", "JSONObject", "(", ")", ".", "put", "(", "\"query\"", ",", "ret", ")", ";", "}", "if", "(", "bean", "instanceof", "AndOr", ")", "{", "AndOr", "andOr", "=", "(", "AndOr", ")", "bean", ";", "String", "operation", "=", "andOr", ".", "getOperation", "(", ")", ".", "name", "(", ")", ";", "List", "<", "JSONObject", ">", "filters", "=", "convertToJson", "(", "andOr", ".", "filters", ")", ";", "return", "new", "JSONObject", "(", ")", ".", "put", "(", "operation", ",", "new", "JSONArray", "(", "filters", ")", ")", ";", "}", "if", "(", "bean", "instanceof", "BoolFilter", ")", "{", "BoolFilter", "bool", "=", "(", "BoolFilter", ")", "bean", ";", "JSONObject", "ret", "=", "new", "JSONObject", "(", ")", ";", "if", "(", "bool", ".", "getMust", "(", ")", "!=", "null", ")", "{", "ret", ".", "put", "(", "\"must\"", ",", "new", "JSONArray", "(", "convertToJson", "(", "bool", ".", "getMust", "(", ")", ")", ")", ")", ";", "}", "if", "(", "bool", ".", "getMust_not", "(", ")", "!=", "null", ")", "{", "ret", ".", "put", "(", "\"must_not\"", ",", "new", "JSONArray", "(", "convertToJson", "(", "bool", ".", "getMust_not", "(", ")", ")", ")", ")", ";", "}", "if", "(", "bool", ".", "getShould", "(", ")", "!=", "null", ")", "{", "ret", ".", "put", "(", "\"should\"", ",", "new", "JSONArray", "(", "convertToJson", "(", "bool", ".", "getShould", "(", ")", ")", ")", ")", ";", "}", "return", "new", "JSONObject", "(", ")", ".", "put", "(", "\"bool\"", ",", "ret", ")", ";", "}", "if", "(", "bean", "instanceof", "Ids", ")", "{", "Ids", "ids", "=", "(", "Ids", ")", "bean", ";", "JSONObject", "ret", "=", "new", "JSONObject", "(", ")", ";", "if", "(", "ids", ".", "getValues", "(", ")", "!=", "null", ")", "{", "ret", ".", "put", "(", "\"values\"", ",", "new", "JSONArray", "(", "ids", ".", "getValues", "(", ")", ")", ")", ";", "}", "if", "(", "ids", ".", "getExcludes", "(", ")", "!=", "null", ")", "{", "ret", ".", "put", "(", "\"excludes\"", ",", "new", "JSONArray", "(", "ids", ".", "getExcludes", "(", ")", ")", ")", ";", "}", "return", "new", "JSONObject", "(", ")", ".", "put", "(", "\"ids\"", ",", "ret", ")", ";", "}", "if", "(", "bean", "instanceof", "IsNull", ")", "{", "IsNull", "isNull", "=", "(", "IsNull", ")", "bean", ";", "return", "new", "JSONObject", "(", ")", ".", "put", "(", "\"isNull\"", ",", "new", "JSONObject", "(", ")", ".", "put", "(", "\"field\"", ",", "isNull", ".", "getField", "(", ")", ")", ")", ";", "}", "if", "(", "bean", "instanceof", "Query", ")", "{", "return", "queryJsonHandler", ".", "serialize", "(", "(", "Query", ")", "bean", ")", ";", "}", "if", "(", "bean", "instanceof", "QueryFilter", ")", "{", "return", "new", "JSONObject", "(", ")", ".", "put", "(", "\"query\"", ",", "queryJsonHandler", ".", "serialize", "(", "(", "(", "QueryFilter", ")", "bean", ")", ".", "getQuery", "(", ")", ")", ")", ";", "}", "throw", "new", "UnsupportedOperationException", "(", "bean", ".", "getClass", "(", ")", "+", "\"\"", ")", ";", "}", "private", "List", "<", "JSONObject", ">", "convertToJson", "(", "List", "<", "Filter", ">", "filters2", ")", "throws", "JSONException", "{", "List", "<", "JSONObject", ">", "filters", "=", "new", "ArrayList", "<", "JSONObject", ">", "(", "filters2", ".", "size", "(", ")", ")", ";", "for", "(", "Filter", "filter", ":", "filters2", ")", "{", "filters", ".", "add", "(", "serialize", "(", "filter", ")", ")", ";", "}", "return", "filters", ";", "}", "@", "Override", "public", "Filter", "deserialize", "(", "JSONObject", "json", ")", "throws", "JSONException", "{", "return", "null", ";", "}", "}", "</s>" ]
6,977
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "import", "java", ".", "util", ".", "List", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonField", ";", "@", "CustomJsonHandler", "(", "QueryJsonHandler", ".", "class", ")", "public", "class", "BoolQuery", "extends", "Query", "{", "List", "<", "Query", ">", "must", ";", "List", "<", "Query", ">", "must_not", ";", "List", "<", "Query", ">", "should", ";", "@", "JsonField", "(", "\"\"", ")", "Integer", "minimumNumberShouldMatch", ";", "double", "boost", ";", "Boolean", "disableCoord", ";", "public", "BoolQuery", "(", "List", "<", "Query", ">", "must", ",", "List", "<", "Query", ">", "must_not", ",", "List", "<", "Query", ">", "should", ",", "Integer", "minimumNumberShouldMatch", ",", "double", "boost", ",", "Boolean", "disableCoord", ")", "{", "super", "(", ")", ";", "this", ".", "must", "=", "must", ";", "this", ".", "must_not", "=", "must_not", ";", "this", ".", "should", "=", "should", ";", "this", ".", "minimumNumberShouldMatch", "=", "minimumNumberShouldMatch", ";", "this", ".", "boost", "=", "boost", ";", "this", ".", "disableCoord", "=", "disableCoord", ";", "}", "}", "</s>" ]
6,978
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ".", "Filter", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ".", "FilterJsonHandler", ";", "@", "CustomJsonHandler", "(", "value", "=", "QueryJsonHandler", ".", "class", ")", "public", "class", "FilteredQuery", "extends", "Query", "{", "private", "Query", "query", ";", "@", "CustomJsonHandler", "(", "value", "=", "FilterJsonHandler", ".", "class", ",", "flatten", "=", "false", ")", "private", "Filter", "filter", ";", "private", "double", "boost", ";", "public", "FilteredQuery", "(", "Query", "query", ",", "Filter", "filter", ",", "double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "query", "=", "query", ";", "this", ".", "filter", "=", "filter", ";", "}", "}", "</s>" ]
6,979
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Operator", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Range", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Term", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Terms", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ".", "Filter", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ".", "Ids", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "TextQuery", ".", "Type", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ".", "SpanTerm", ";", "public", "class", "Queries", "{", "public", "static", "CustomQuery", "customQuery", "(", "String", "cls", ",", "Map", "<", "String", ",", "String", ">", "params", ",", "double", "boost", ")", "{", "return", "new", "CustomQuery", "(", "cls", ",", "params", ",", "boost", ")", ";", "}", "public", "static", "DisMax", "disMax", "(", "double", "tieBraker", ",", "double", "boost", ",", "Term", "...", "queries", ")", "{", "return", "new", "DisMax", "(", "tieBraker", ",", "Arrays", ".", "asList", "(", "queries", ")", ",", "boost", ")", ";", "}", "public", "static", "MatchAllQuery", "matchAllQuery", "(", "double", "boost", ")", "{", "return", "new", "MatchAllQuery", "(", "boost", ")", ";", "}", "public", "static", "QueryPrefix", "prefix", "(", "String", "field", ",", "String", "value", ",", "double", "boost", ")", "{", "return", "new", "QueryPrefix", "(", "field", ",", "value", ",", "boost", ")", ";", "}", "public", "static", "QueryWildcard", "wildcard", "(", "String", "field", ",", "String", "value", ",", "double", "boost", ")", "{", "return", "new", "QueryWildcard", "(", "field", ",", "value", ",", "boost", ")", ";", "}", "public", "static", "BoolQuery", "bool", "(", "List", "<", "Query", ">", "must", ",", "List", "<", "Query", ">", "must_not", ",", "List", "<", "Query", ">", "should", ",", "int", "minimumNumberShouldMatch", ",", "double", "boost", ",", "boolean", "disableCoord", ")", "{", "return", "new", "BoolQuery", "(", "must", ",", "must_not", ",", "should", ",", "minimumNumberShouldMatch", ",", "boost", ",", "disableCoord", ")", ";", "}", "public", "static", "BoolQuery", "bool", "(", "List", "<", "Query", ">", "must", ",", "List", "<", "Query", ">", "must_not", ",", "List", "<", "Query", ">", "should", ",", "double", "boost", ")", "{", "return", "new", "BoolQuery", "(", "must", ",", "must_not", ",", "should", ",", "null", ",", "boost", ",", "null", ")", ";", "}", "public", "static", "StringQuery", ".", "Builder", "stringQueryBuilder", "(", ")", "{", "return", "StringQuery", ".", "builder", "(", ")", ";", "}", "public", "static", "StringQuery", "stringQuery", "(", "String", "query", ")", "{", "return", "StringQuery", ".", "builder", "(", ")", ".", "query", "(", "query", ")", ".", "build", "(", ")", ";", "}", "public", "static", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ".", "SpanFirst", "spanFirst", "(", "SpanTerm", "match", ",", "int", "end", ",", "double", "boost", ")", "{", "return", "new", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ".", "SpanFirst", "(", "match", ",", "end", ",", "boost", ")", ";", "}", "public", "static", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ".", "SpanNear", "spanNear", "(", "List", "<", "SpanTerm", ">", "clauses", ",", "int", "slop", ",", "boolean", "inOrder", ",", "boolean", "collectPayloads", ",", "double", "boost", ")", "{", "return", "new", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ".", "SpanNear", "(", "clauses", ",", "slop", ",", "inOrder", ",", "collectPayloads", ",", "boost", ")", ";", "}", "public", "static", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ".", "SpanNot", "spanNot", "(", "SpanTerm", "include", ",", "SpanTerm", "exclude", ",", "double", "boost", ")", "{", "return", "new", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ".", "SpanNot", "(", "include", ",", "exclude", ",", "boost", ")", ";", "}", "public", "static", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ".", "SpanOr", "spanOr", "(", "Double", "boost", ",", "SpanTerm", "...", "clauses", ")", "{", "return", "new", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ".", "SpanOr", "(", "Arrays", ".", "asList", "(", "clauses", ")", ",", "boost", ")", ";", "}", "public", "static", "SpanTerm", "spanTerm", "(", "String", "field", ",", "String", "value", ")", "{", "return", "new", "SpanTerm", "(", "field", ",", "value", ",", "null", ")", ";", "}", "public", "static", "SpanTerm", "spanTerm", "(", "String", "field", ",", "String", "value", ",", "Double", "boost", ")", "{", "return", "new", "SpanTerm", "(", "field", ",", "value", ",", "boost", ")", ";", "}", "public", "static", "TextQuery", "textQuery", "(", "String", "field", ",", "String", "text", ",", "Operator", "operator", ",", "Type", "type", ",", "double", "boost", ")", "{", "return", "new", "TextQuery", "(", "field", ",", "text", ",", "operator", ",", "type", ",", "boost", ")", ";", "}", "public", "static", "TextQuery", "textQuery", "(", "String", "field", ",", "String", "text", ",", "Operator", "operator", ",", "double", "boost", ")", "{", "return", "new", "TextQuery", "(", "field", ",", "text", ",", "operator", ",", "null", ",", "boost", ")", ";", "}", "public", "static", "FilteredQuery", "filteredQuery", "(", "Query", "query", ",", "Filter", "filter", ",", "double", "boost", ")", "{", "return", "new", "FilteredQuery", "(", "query", ",", "filter", ",", "boost", ")", ";", "}", "public", "static", "PathQuery", "path", "(", "String", "field", ",", "String", "name", ",", "double", "boost", ")", "{", "return", "new", "PathQuery", "(", "field", ",", "name", ",", "boost", ")", ";", "}", "public", "static", "Term", "term", "(", "String", "field", ",", "String", "value", ",", "double", "boost", ")", "{", "return", "(", "Term", ")", "new", "Term", "(", "value", ",", "boost", ")", ".", "setField", "(", "field", ")", ";", "}", "public", "static", "Terms", "terms", "(", "String", "field", ",", "List", "<", "String", ">", "values", ",", "List", "<", "String", ">", "excludes", ",", "Operator", "op", ",", "int", "minimumMatch", ",", "double", "boost", ")", "{", "return", "(", "Terms", ")", "new", "Terms", "(", "values", ",", "excludes", ",", "op", ",", "minimumMatch", ",", "boost", ")", ".", "setField", "(", "field", ")", ";", "}", "public", "static", "Ids", "ids", "(", "List", "<", "String", ">", "values", ",", "List", "<", "String", ">", "excludes", ",", "double", "boost", ")", "{", "return", "new", "Ids", "(", "values", ",", "excludes", ",", "boost", ")", ";", "}", "public", "static", "Range", "range", "(", "String", "field", ",", "String", "from", ",", "String", "to", ",", "boolean", "includeLower", ",", "boolean", "includeUpper", ",", "double", "boost", ",", "boolean", "noOptimize", ")", "{", "return", "(", "Range", ")", "new", "Range", "(", "from", ",", "to", ",", "includeLower", ",", "includeUpper", ",", "boost", ",", "noOptimize", ")", ".", "setField", "(", "field", ")", ";", "}", "public", "static", "Range", "range", "(", "String", "field", ",", "String", "from", ",", "String", "to", ",", "boolean", "includeLower", ",", "boolean", "includeUpper", ",", "double", "boost", ",", "boolean", "noOptimize", ",", "String", "type", ")", "{", "return", "(", "Range", ")", "new", "Range", "(", "from", ",", "to", ",", "includeLower", ",", "includeUpper", ",", "boost", ",", "noOptimize", ",", "type", ")", ".", "setField", "(", "field", ")", ";", "}", "}", "</s>" ]
6,980
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ";", "import", "java", ".", "util", ".", "List", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonField", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "QueryJsonHandler", ";", "@", "CustomJsonHandler", "(", "QueryJsonHandler", ".", "class", ")", "public", "class", "SpanNear", "extends", "Query", "{", "List", "<", "SpanTerm", ">", "clauses", ";", "private", "int", "slop", ";", "@", "JsonField", "(", "\"in_order\"", ")", "private", "boolean", "inOrder", ";", "@", "JsonField", "(", "\"\"", ")", "private", "boolean", "collectPayloads", ";", "private", "final", "double", "boost", ";", "public", "SpanNear", "(", "List", "<", "SpanTerm", ">", "clauses", ",", "int", "slop", ",", "boolean", "inOrder", ",", "boolean", "collectPayloads", ",", "double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "clauses", "=", "clauses", ";", "this", ".", "slop", "=", "slop", ";", "this", ".", "inOrder", "=", "inOrder", ";", "this", ".", "collectPayloads", "=", "collectPayloads", ";", "this", ".", "boost", "=", "boost", ";", "SpanTerm", ".", "cleanBoosts", "(", "clauses", ")", ";", "}", "}", "</s>" ]
6,981
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "QueryJsonHandler", ";", "@", "CustomJsonHandler", "(", "QueryJsonHandler", ".", "class", ")", "public", "class", "SpanFirst", "extends", "Query", "{", "SpanTerm", "match", ";", "int", "end", ";", "private", "double", "boost", ";", "public", "SpanFirst", "(", "SpanTerm", "match", ",", "int", "end", ",", "double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "match", "=", "match", ";", "this", ".", "end", "=", "end", ";", "this", ".", "boost", "=", "boost", ";", "match", ".", "setBoost", "(", "null", ")", ";", "}", "}", "</s>" ]
6,982
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ";", "import", "java", ".", "util", ".", "List", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "QueryJsonHandler", ";", "@", "CustomJsonHandler", "(", "QueryJsonHandler", ".", "class", ")", "public", "class", "SpanOr", "extends", "Query", "{", "List", "<", "SpanTerm", ">", "clauses", ";", "private", "final", "Double", "boost", ";", "public", "SpanOr", "(", "List", "<", "SpanTerm", ">", "clauses", ",", "Double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "clauses", "=", "clauses", ";", "SpanTerm", ".", "cleanBoosts", "(", "clauses", ")", ";", "this", ".", "boost", "=", "boost", ";", "}", "}", "</s>" ]
6,983
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "QueryJsonHandler", ";", "@", "CustomJsonHandler", "(", "QueryJsonHandler", ".", "class", ")", "public", "class", "SpanNot", "extends", "Query", "{", "SpanTerm", "include", ";", "SpanTerm", "exclude", ";", "private", "final", "double", "boost", ";", "public", "SpanNot", "(", "SpanTerm", "include", ",", "SpanTerm", "exclude", ",", "double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "include", "=", "include", ";", "include", ".", "setBoost", "(", "null", ")", ";", "exclude", ".", "setBoost", "(", "null", ")", ";", "this", ".", "exclude", "=", "exclude", ";", "this", ".", "boost", "=", "boost", ";", "}", "}", "</s>" ]
6,984
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ";", "import", "java", ".", "util", ".", "List", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "FieldAwareQuery", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "QueryJsonHandler", ";", "@", "CustomJsonHandler", "(", "QueryJsonHandler", ".", "class", ")", "public", "class", "SpanTerm", "extends", "FieldAwareQuery", "{", "private", "String", "value", ";", "private", "Double", "boost", ";", "public", "SpanTerm", "(", "String", "field", ",", "String", "value", ",", "Double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "value", "=", "value", ";", "this", ".", "boost", "=", "boost", ";", "this", ".", "field", "=", "field", ";", "}", "public", "String", "getValue", "(", ")", "{", "return", "value", ";", "}", "public", "void", "setValue", "(", "String", "value", ")", "{", "this", ".", "value", "=", "value", ";", "}", "public", "Double", "getBoost", "(", ")", "{", "return", "boost", ";", "}", "public", "void", "setBoost", "(", "Double", "boost", ")", "{", "this", ".", "boost", "=", "boost", ";", "}", "public", "static", "void", "cleanBoosts", "(", "List", "<", "SpanTerm", ">", "spanTerms", ")", "{", "for", "(", "SpanTerm", "spanTerm", ":", "spanTerms", ")", "{", "spanTerm", ".", "setBoost", "(", "null", ")", ";", "}", "}", "}", "</s>" ]
6,985
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonField", ";", "@", "CustomJsonHandler", "(", "value", "=", "QueryJsonHandler", ".", "class", ")", "public", "class", "CustomQuery", "extends", "Query", "{", "@", "JsonField", "(", "\"class\"", ")", "private", "String", "cls", ";", "private", "Map", "<", "String", ",", "String", ">", "params", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "private", "double", "boost", ";", "public", "CustomQuery", "(", "String", "cls", ",", "Map", "<", "String", ",", "String", ">", "params", ",", "double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "cls", "=", "cls", ";", "this", ".", "params", "=", "params", ";", "this", ".", "boost", "=", "boost", ";", "}", "}", "</s>" ]
6,986
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "@", "CustomJsonHandler", "(", "QueryJsonHandler", ".", "class", ")", "public", "class", "QueryWildcard", "extends", "FieldAwareQuery", "{", "private", "String", "value", ";", "private", "double", "boost", ";", "public", "QueryWildcard", "(", "String", "field", ",", "String", "value", ",", "double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "value", "=", "value", ";", "this", ".", "boost", "=", "boost", ";", "this", ".", "field", "=", "field", ";", "}", "}", "</s>" ]
6,987
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Operator", ";", "@", "CustomJsonHandler", "(", "value", "=", "QueryJsonHandler", ".", "class", ")", "public", "class", "TextQuery", "extends", "FieldAwareQuery", "{", "private", "String", "value", ";", "private", "Operator", "operator", ";", "private", "Type", "type", ";", "private", "double", "boost", ";", "public", "TextQuery", "(", "String", "field", ",", "String", "value", ",", "Operator", "operator", ",", "Type", "type", ",", "double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "field", "=", "field", ";", "this", ".", "value", "=", "value", ";", "this", ".", "operator", "=", "operator", ";", "this", ".", "type", "=", "type", ";", "this", ".", "boost", "=", "boost", ";", "}", "public", "static", "enum", "Type", "{", "phrase_prefix", ",", "phrase", ";", "}", "@", "Override", "public", "String", "getField", "(", ")", "{", "return", "field", ";", "}", "public", "String", "getValue", "(", ")", "{", "return", "value", ";", "}", "public", "Operator", "getOperator", "(", ")", "{", "return", "operator", ";", "}", "public", "Type", "getType", "(", ")", "{", "return", "type", ";", "}", "public", "double", "getBoost", "(", ")", "{", "return", "boost", ";", "}", "}", "</s>" ]
6,988
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "public", "class", "FieldAware", "{", "protected", "String", "field", ";", "public", "FieldAware", "setField", "(", "String", "field", ")", "{", "this", ".", "field", "=", "field", ";", "return", "this", ";", "}", "public", "String", "getField", "(", ")", "{", "return", "field", ";", "}", "}", "</s>" ]
6,989
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "@", "CustomJsonHandler", "(", "value", "=", "QueryJsonHandler", ".", "class", ")", "public", "class", "PathQuery", "extends", "FieldAwareQuery", "{", "private", "String", "value", ";", "private", "double", "boost", ";", "public", "PathQuery", "(", "String", "field", ",", "String", "value", ",", "double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "value", "=", "value", ";", "this", ".", "boost", "=", "boost", ";", "this", ".", "field", "=", "field", ";", "}", "}", "</s>" ]
6,990
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "import", "java", ".", "util", ".", "List", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonField", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Term", ";", "@", "CustomJsonHandler", "(", "QueryJsonHandler", ".", "class", ")", "public", "class", "DisMax", "extends", "Query", "{", "@", "JsonField", "(", "\"tie_braker\"", ")", "private", "double", "tieBraker", ";", "private", "double", "boost", ";", "private", "List", "<", "Term", ">", "queries", ";", "public", "DisMax", "(", "double", "tieBraker", ",", "List", "<", "Term", ">", "queries", ",", "double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "tieBraker", "=", "tieBraker", ";", "this", ".", "boost", "=", "boost", ";", "this", ".", "queries", "=", "queries", ";", "}", "}", "</s>" ]
6,991
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "json", ".", "JSONException", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonSerializer", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Range", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Selection", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Term", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Terms", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ".", "Ids", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ".", "SpanFirst", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ".", "SpanNear", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ".", "SpanNot", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ".", "SpanOr", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "span", ".", "SpanTerm", ";", "public", "class", "QueryJsonHandler", "implements", "JsonHandler", "<", "Query", ">", "{", "private", "static", "Map", "<", "Class", "<", "?", "extends", "Query", ">", ",", "String", ">", "typeNames", "=", "new", "HashMap", "<", "Class", "<", "?", "extends", "Query", ">", ",", "String", ">", "(", ")", ";", "static", "{", "typeNames", ".", "put", "(", "StringQuery", ".", "class", ",", "\"query_string\"", ")", ";", "typeNames", ".", "put", "(", "MatchAllQuery", ".", "class", ",", "\"match_all\"", ")", ";", "typeNames", ".", "put", "(", "DisMax", ".", "class", ",", "\"dis_max\"", ")", ";", "typeNames", ".", "put", "(", "QueryPrefix", ".", "class", ",", "\"prefix\"", ")", ";", "typeNames", ".", "put", "(", "QueryWildcard", ".", "class", ",", "\"wildcard\"", ")", ";", "typeNames", ".", "put", "(", "TextQuery", ".", "class", ",", "\"text\"", ")", ";", "typeNames", ".", "put", "(", "SpanFirst", ".", "class", ",", "\"span_first\"", ")", ";", "typeNames", ".", "put", "(", "SpanTerm", ".", "class", ",", "\"span_term\"", ")", ";", "typeNames", ".", "put", "(", "SpanNear", ".", "class", ",", "\"span_near\"", ")", ";", "typeNames", ".", "put", "(", "SpanNot", ".", "class", ",", "\"span_not\"", ")", ";", "typeNames", ".", "put", "(", "SpanOr", ".", "class", ",", "\"span_or\"", ")", ";", "typeNames", ".", "put", "(", "CustomQuery", ".", "class", ",", "\"custom\"", ")", ";", "typeNames", ".", "put", "(", "TextQuery", ".", "class", ",", "\"text\"", ")", ";", "typeNames", ".", "put", "(", "FilteredQuery", ".", "class", ",", "\"filtered\"", ")", ";", "typeNames", ".", "put", "(", "PathQuery", ".", "class", ",", "\"path\"", ")", ";", "typeNames", ".", "put", "(", "BoolQuery", ".", "class", ",", "\"bool\"", ")", ";", "typeNames", ".", "put", "(", "Term", ".", "class", ",", "\"term\"", ")", ";", "typeNames", ".", "put", "(", "Terms", ".", "class", ",", "\"terms\"", ")", ";", "typeNames", ".", "put", "(", "Ids", ".", "class", ",", "\"ids\"", ")", ";", "typeNames", ".", "put", "(", "Range", ".", "class", ",", "\"range\"", ")", ";", "}", "@", "Override", "public", "JSONObject", "serialize", "(", "Query", "bean", ")", "throws", "JSONException", "{", "if", "(", "bean", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "!", "typeNames", ".", "containsKey", "(", "bean", ".", "getClass", "(", ")", ")", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Class", "\"", "+", "bean", ".", "getClass", "(", ")", "+", "\"\"", ")", ";", "}", "JSONObject", "defaultSerialization", "=", "(", "JSONObject", ")", "JsonSerializer", ".", "serialize", "(", "bean", ",", "false", ")", ";", "if", "(", "bean", "instanceof", "FieldAwareQuery", ")", "{", "defaultSerialization", ".", "remove", "(", "\"field\"", ")", ";", "if", "(", "bean", "instanceof", "SpanTerm", "&&", "(", "(", "SpanTerm", ")", "bean", ")", ".", "getBoost", "(", ")", "==", "null", ")", "{", "SpanTerm", "spanTerm", "=", "(", "SpanTerm", ")", "bean", ";", "defaultSerialization", "=", "new", "JSONObject", "(", ")", ".", "put", "(", "spanTerm", ".", "getField", "(", ")", ",", "spanTerm", ".", "getValue", "(", ")", ")", ";", "}", "else", "{", "defaultSerialization", "=", "new", "JSONObject", "(", ")", ".", "put", "(", "(", "(", "FieldAwareQuery", ")", "bean", ")", ".", "getField", "(", ")", ",", "defaultSerialization", ")", ";", "}", "}", "if", "(", "bean", "instanceof", "Selection", ")", "{", "defaultSerialization", ".", "remove", "(", "\"field\"", ")", ";", "defaultSerialization", "=", "new", "JSONObject", "(", ")", ".", "put", "(", "(", "(", "Selection", ")", "bean", ")", ".", "getField", "(", ")", ",", "defaultSerialization", ")", ";", "}", "if", "(", "bean", ".", "getRelevance", "(", ")", "!=", "null", ")", "{", "defaultSerialization", ".", "remove", "(", "\"relevance\"", ")", ";", "defaultSerialization", ".", "put", "(", "\"relevance\"", ",", "JsonSerializer", ".", "serialize", "(", "bean", ".", "getRelevance", "(", ")", ")", ")", ";", "}", "return", "new", "JSONObject", "(", ")", ".", "put", "(", "typeNames", ".", "get", "(", "bean", ".", "getClass", "(", ")", ")", ",", "defaultSerialization", ")", ";", "}", "@", "Override", "public", "Query", "deserialize", "(", "JSONObject", "json", ")", "throws", "JSONException", "{", "return", "null", ";", "}", "}", "</s>" ]
6,992
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "@", "CustomJsonHandler", "(", "QueryJsonHandler", ".", "class", ")", "public", "class", "QueryPrefix", "extends", "FieldAwareQuery", "{", "private", "String", "value", ";", "private", "double", "boost", ";", "public", "QueryPrefix", "(", "String", "field", ",", "String", "value", ",", "double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "value", "=", "value", ";", "this", ".", "boost", "=", "boost", ";", "this", ".", "field", "=", "field", ";", "}", "}", "</s>" ]
6,993
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "public", "class", "FieldAwareQuery", "extends", "Query", "{", "protected", "String", "field", ";", "public", "FieldAwareQuery", "setField", "(", "String", "field", ")", "{", "this", ".", "field", "=", "field", ";", "return", "this", ";", "}", "public", "String", "getField", "(", ")", "{", "return", "field", ";", "}", "}", "</s>" ]
6,994
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "@", "CustomJsonHandler", "(", "QueryJsonHandler", ".", "class", ")", "public", "class", "MatchAllQuery", "extends", "Query", "{", "double", "boost", ";", "public", "MatchAllQuery", "(", "double", "boost", ")", "{", "super", "(", ")", ";", "this", ".", "boost", "=", "boost", ";", "}", "}", "</s>" ]
6,995
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonField", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "Operator", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ".", "Filter", ";", "@", "CustomJsonHandler", "(", "QueryJsonHandler", ".", "class", ")", "public", "class", "StringQuery", "extends", "Query", "{", "@", "JsonField", "(", "\"\"", ")", "private", "String", "defaultField", ";", "private", "String", "query", ";", "@", "JsonField", "(", "\"\"", ")", "private", "Operator", "defaultOperator", ";", "@", "JsonField", "(", "\"\"", ")", "private", "Boolean", "allowLeadingWildCard", ";", "@", "JsonField", "(", "\"\"", ")", "private", "Boolean", "lowercaseExpandedTerms", ";", "@", "JsonField", "(", "\"\"", ")", "private", "Boolean", "enablePositionIncrements", ";", "@", "JsonField", "(", "\"\"", ")", "private", "String", "fuzzyPrefixLength", ";", "@", "JsonField", "(", "\"\"", ")", "private", "Double", "fuzzyMinSim", ";", "@", "JsonField", "(", "\"phrase_slop\"", ")", "private", "Integer", "phraseSlop", ";", "private", "Double", "boost", "=", "1.0", ";", "@", "JsonField", "(", "\"\"", ")", "private", "Boolean", "autoGeneratePhraseQueries", ";", "private", "List", "<", "String", ">", "fields", ";", "@", "JsonField", "(", "\"use_dis_max\"", ")", "private", "Boolean", "useDisMax", ";", "@", "JsonField", "(", "\"tie_breaker\"", ")", "private", "Integer", "tieBreaker", ";", "public", "static", "Builder", "builder", "(", ")", "{", "return", "new", "Builder", "(", ")", ";", "}", "public", "static", "class", "Builder", "{", "private", "StringQuery", "query", "=", "new", "StringQuery", "(", ")", ";", "public", "Builder", "defaultField", "(", "String", "defaultField", ")", "{", "query", ".", "defaultField", "=", "defaultField", ";", "return", "this", ";", "}", "public", "Builder", "allowLeadingWildCard", "(", "boolean", "allowLeadingWildCard", ")", "{", "query", ".", "allowLeadingWildCard", "=", "allowLeadingWildCard", ";", "return", "this", ";", "}", "public", "Builder", "defaultOperator", "(", "Operator", "op", ")", "{", "query", ".", "defaultOperator", "=", "op", ";", "return", "this", ";", "}", "public", "Builder", "lowercaseExpandedTerms", "(", "boolean", "lowercaseExpandedTerms", ")", "{", "query", ".", "lowercaseExpandedTerms", "=", "lowercaseExpandedTerms", ";", "return", "this", ";", "}", "public", "Builder", "enablePositionIncrements", "(", "boolean", "enablePositionIncrements", ")", "{", "query", ".", "enablePositionIncrements", "=", "enablePositionIncrements", ";", "return", "this", ";", "}", "public", "Builder", "fuzzyPrefixLength", "(", "String", "fuzzyPrefixLength", ")", "{", "query", ".", "fuzzyPrefixLength", "=", "fuzzyPrefixLength", ";", "return", "this", ";", "}", "public", "Builder", "fuzzyMinSim", "(", "double", "fuzzyMinSim", ")", "{", "query", ".", "fuzzyMinSim", "=", "fuzzyMinSim", ";", "return", "this", ";", "}", "public", "Builder", "phraseSlop", "(", "int", "phraseSlop", ")", "{", "query", ".", "phraseSlop", "=", "phraseSlop", ";", "return", "this", ";", "}", "public", "Builder", "boost", "(", "double", "boost", ")", "{", "query", ".", "boost", "=", "boost", ";", "return", "this", ";", "}", "public", "Builder", "autoGeneratePhraseQueries", "(", "boolean", "autoGeneratePhraseQueries", ")", "{", "query", ".", "autoGeneratePhraseQueries", "=", "autoGeneratePhraseQueries", ";", "return", "this", ";", "}", "public", "Builder", "fields", "(", "String", "...", "fields", ")", "{", "query", ".", "fields", "=", "Arrays", ".", "asList", "(", "fields", ")", ";", "return", "this", ";", "}", "public", "Builder", "useDisMax", "(", "boolean", "useDisMax", ")", "{", "query", ".", "useDisMax", "=", "useDisMax", ";", "return", "this", ";", "}", "public", "Builder", "tieBreaker", "(", "int", "tieBreaker", ")", "{", "query", ".", "tieBreaker", "=", "tieBreaker", ";", "return", "this", ";", "}", "public", "Builder", "query", "(", "String", "queryParam", ")", "{", "this", ".", "query", ".", "query", "=", "queryParam", ";", "return", "this", ";", "}", "public", "StringQuery", "build", "(", ")", "{", "return", "query", ";", "}", "}", "}", "</s>" ]
6,996
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ".", "Filter", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "relevance", ".", "Relevance", ";", "public", "abstract", "class", "Query", "implements", "Filter", "{", "private", "Relevance", "relevance", ";", "public", "Query", "setRelevance", "(", "Relevance", "relevance", ")", "{", "this", ".", "relevance", "=", "relevance", ";", "return", "this", ";", "}", "public", "Relevance", "getRelevance", "(", ")", "{", "return", "relevance", ";", "}", "}", "</s>" ]
6,997
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonField", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Query", ";", "public", "class", "Range", "extends", "Selection", "{", "private", "String", "from", ";", "private", "String", "to", ";", "@", "JsonField", "(", "\"\"", ")", "private", "boolean", "includeLower", ";", "@", "JsonField", "(", "\"\"", ")", "private", "boolean", "includeUpper", ";", "private", "Double", "boost", ";", "@", "JsonField", "(", "\"_noOptimize\"", ")", "private", "Boolean", "notOptimize", ";", "private", "String", "type", ";", "public", "Range", "(", ")", "{", "}", "public", "Range", "(", "String", "from", ",", "String", "to", ",", "boolean", "includeLower", ",", "boolean", "includeUpper", ")", "{", "super", "(", ")", ";", "this", ".", "from", "=", "from", ";", "this", ".", "to", "=", "to", ";", "this", ".", "includeLower", "=", "includeLower", ";", "this", ".", "includeUpper", "=", "includeUpper", ";", "}", "public", "Range", "(", "String", "from", ",", "String", "to", ",", "boolean", "includeLower", ",", "boolean", "includeUpper", ",", "double", "Doost", ",", "boolean", "noOptimize", ")", "{", "super", "(", ")", ";", "this", ".", "from", "=", "from", ";", "this", ".", "to", "=", "to", ";", "this", ".", "includeLower", "=", "includeLower", ";", "this", ".", "includeUpper", "=", "includeUpper", ";", "this", ".", "boost", "=", "boost", ";", "notOptimize", "=", "noOptimize", ";", "}", "public", "Range", "(", "String", "from", ",", "String", "to", ",", "boolean", "includeLower", ",", "boolean", "includeUpper", ",", "Double", "boost", ",", "boolean", "noOptimize", ",", "String", "type", ")", "{", "super", "(", ")", ";", "this", ".", "from", "=", "from", ";", "this", ".", "to", "=", "to", ";", "this", ".", "includeLower", "=", "includeLower", ";", "this", ".", "includeUpper", "=", "includeUpper", ";", "this", ".", "boost", "=", "boost", ";", "notOptimize", "=", "noOptimize", ";", "this", ".", "type", "=", "type", ";", "}", "public", "String", "getFrom", "(", ")", "{", "return", "from", ";", "}", "public", "String", "getTo", "(", ")", "{", "return", "to", ";", "}", "public", "boolean", "isIncludeLower", "(", ")", "{", "return", "includeLower", ";", "}", "public", "boolean", "isIncludeUpper", "(", ")", "{", "return", "includeUpper", ";", "}", "public", "Double", "getBoost", "(", ")", "{", "return", "boost", ";", "}", "public", "Boolean", "getNotOptimize", "(", ")", "{", "return", "notOptimize", ";", "}", "public", "String", "getType", "(", ")", "{", "return", "type", ";", "}", "}", "</s>" ]
6,998
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "json", ".", "JSONException", ";", "import", "org", ".", "json", ".", "JSONObject", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "CustomJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "json", ".", "JsonField", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ".", "Filter", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "filter", ".", "FilterJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "Query", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "query", ".", "QueryJsonHandler", ";", "import", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ".", "relevance", ".", "Relevance", ";", "public", "class", "SenseiClientRequest", "{", "private", "Integer", "size", ";", "private", "Integer", "from", ";", "private", "GroupBy", "groupBy", ";", "private", "List", "<", "Selection", ">", "selections", "=", "new", "ArrayList", "<", "Selection", ">", "(", ")", ";", "@", "CustomJsonHandler", "(", "value", "=", "QueryJsonHandler", ".", "class", ")", "private", "Query", "query", ";", "private", "Map", "<", "String", ",", "Map", "<", "String", ",", "FacetInit", ">", ">", "facetInit", "=", "new", "HashMap", "<", "String", ",", "Map", "<", "String", ",", "FacetInit", ">", ">", "(", ")", ";", "private", "List", "<", "Object", ">", "sort", "=", "new", "ArrayList", "<", "Object", ">", "(", ")", ";", "private", "Map", "<", "String", ",", "Facet", ">", "facets", "=", "new", "HashMap", "<", "String", ",", "Facet", ">", "(", ")", ";", "private", "boolean", "fetchStored", ";", "private", "List", "<", "String", ">", "termVectors", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "private", "List", "<", "Integer", ">", "partitions", "=", "new", "ArrayList", "<", "Integer", ">", "(", ")", ";", "private", "boolean", "explain", ";", "private", "String", "routeParam", ";", "@", "CustomJsonHandler", "(", "value", "=", "FilterJsonHandler", ".", "class", ")", "private", "Filter", "filter", ";", "private", "Map", "<", "String", ",", "Object", ">", "templateMapping", ";", "private", "MapReduce", "mapReduce", ";", "private", "RequestMetadata", "meta", ";", "public", "static", "class", "Builder", "{", "private", "SenseiClientRequest", "request", "=", "new", "SenseiClientRequest", "(", ")", ";", "public", "Builder", "paging", "(", "int", "size", ",", "int", "offset", ")", "{", "request", ".", "size", "=", "size", ";", "request", ".", "from", "=", "offset", ";", "return", "this", ";", "}", "public", "Builder", "fetchStored", "(", "boolean", "fetchStored", ")", "{", "request", ".", "fetchStored", "=", "fetchStored", ";", "return", "this", ";", "}", "public", "Builder", "partitions", "(", "List", "<", "Integer", ">", "partitions", ")", "{", "request", ".", "partitions", "=", "partitions", ";", "return", "this", ";", "}", "public", "Builder", "explain", "(", "boolean", "explain", ")", "{", "request", ".", "explain", "=", "explain", ";", "return", "this", ";", "}", "public", "Builder", "query", "(", "Query", "query", ")", "{", "request", ".", "query", "=", "query", ";", "return", "this", ";", "}", "public", "Builder", "groupBy", "(", "int", "top", ",", "String", "...", "columns", ")", "{", "request", ".", "groupBy", "=", "new", "GroupBy", "(", "Arrays", ".", "asList", "(", "columns", ")", ",", "top", ")", ";", "return", "this", ";", "}", "public", "Builder", "groupBy", "(", "List", "<", "String", ">", "columns", ",", "int", "top", ")", "{", "request", ".", "groupBy", "=", "new", "GroupBy", "(", "columns", ",", "top", ")", ";", "return", "this", ";", "}", "public", "Builder", "addSelection", "(", "Selection", "selection", ")", "{", "if", "(", "selection", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "request", ".", "selections", ".", "add", "(", "selection", ")", ";", "return", "this", ";", "}", "public", "Builder", "addFacetInit", "(", "String", "name", ",", "Map", "<", "String", ",", "FacetInit", ">", "facetInits", ")", "{", "request", ".", "facetInit", ".", "put", "(", "name", ",", "facetInits", ")", ";", "return", "this", ";", "}", "public", "Builder", "showOnlyFields", "(", "String", "...", "fields", ")", "{", "request", ".", "meta", "=", "new", "RequestMetadata", "(", "Arrays", ".", "asList", "(", "fields", ")", ")", ";", "return", "this", ";", "}", "public", "Builder", "addTemplateMapping", "(", "String", "name", ",", "Object", "value", ")", "{", "if", "(", "request", ".", "templateMapping", "==", "null", ")", "{", "request", ".", "templateMapping", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "}", "request", ".", "templateMapping", ".", "put", "(", "name", ",", "value", ")", ";", "return", "this", ";", "}", "public", "Builder", "addSort", "(", "Sort", "sort", ")", "{", "if", "(", "sort", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "if", "(", "\"_score\"", ".", "equalsIgnoreCase", "(", "sort", ".", "getField", "(", ")", ")", ")", "{", "request", ".", "sort", ".", "add", "(", "\"_score\"", ")", ";", "}", "else", "{", "try", "{", "request", ".", "sort", ".", "add", "(", "new", "JSONObject", "(", ")", ".", "put", "(", "sort", ".", "getField", "(", ")", ",", "sort", ".", "getOrder", "(", ")", ".", "name", "(", ")", ")", ")", ";", "}", "catch", "(", "JSONException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "return", "this", ";", "}", "public", "Builder", "addTermVector", "(", "String", "term", ")", "{", "request", ".", "termVectors", ".", "add", "(", "term", ")", ";", "return", "this", ";", "}", "public", "Builder", "addFacetInit", "(", "String", "name", ",", "String", "parameter", ",", "FacetInit", "facetInit", ")", "{", "if", "(", "!", "request", ".", "facetInit", ".", "containsKey", "(", "name", ")", ")", "{", "request", ".", "facetInit", ".", "put", "(", "name", ",", "new", "HashMap", "<", "String", ",", "FacetInit", ">", "(", ")", ")", ";", "}", "request", ".", "facetInit", ".", "get", "(", "name", ")", ".", "put", "(", "parameter", ",", "facetInit", ")", ";", "return", "this", ";", "}", "public", "Builder", "addFacet", "(", "String", "name", ",", "Facet", "facet", ")", "{", "request", ".", "facets", ".", "put", "(", "name", ",", "facet", ")", ";", "return", "this", ";", "}", "public", "Builder", "routeParam", "(", "String", "routeParam", ")", "{", "request", ".", "routeParam", "=", "routeParam", ";", "return", "this", ";", "}", "public", "Builder", "filter", "(", "Filter", "filter", ")", "{", "request", ".", "filter", "=", "filter", ";", "return", "this", ";", "}", "public", "Builder", "mapReduce", "(", "String", "function", ",", "Map", "<", "String", ",", "Object", ">", "parameters", ")", "{", "request", ".", "mapReduce", "=", "new", "MapReduce", "(", "function", ",", "parameters", ")", ";", "return", "this", ";", "}", "public", "SenseiClientRequest", "build", "(", ")", "{", "return", "request", ";", "}", "}", "public", "static", "Builder", "builder", "(", ")", "{", "return", "new", "Builder", "(", ")", ";", "}", "public", "Paging", "getPaging", "(", ")", "{", "return", "new", "Paging", "(", "size", ",", "from", ")", ";", "}", "public", "GroupBy", "getGroupBy", "(", ")", "{", "return", "groupBy", ";", "}", "public", "List", "<", "Selection", ">", "getSelections", "(", ")", "{", "return", "selections", ";", "}", "public", "Map", "<", "String", ",", "Map", "<", "String", ",", "FacetInit", ">", ">", "getFacetInit", "(", ")", "{", "return", "facetInit", ";", "}", "public", "List", "<", "Object", ">", "getSorts", "(", ")", "{", "return", "sort", ";", "}", "public", "Map", "<", "String", ",", "Facet", ">", "getFacets", "(", ")", "{", "return", "facets", ";", "}", "public", "boolean", "isFetchStored", "(", ")", "{", "return", "fetchStored", ";", "}", "public", "List", "<", "String", ">", "getTermVectors", "(", ")", "{", "return", "termVectors", ";", "}", "public", "List", "<", "Integer", ">", "getPartitions", "(", ")", "{", "return", "partitions", ";", "}", "public", "boolean", "isExplain", "(", ")", "{", "return", "explain", ";", "}", "public", "String", "getRouteParam", "(", ")", "{", "return", "routeParam", ";", "}", "public", "Integer", "getCount", "(", ")", "{", "return", "size", ";", "}", "public", "Integer", "getFrom", "(", ")", "{", "return", "from", ";", "}", "public", "Query", "getQuery", "(", ")", "{", "return", "query", ";", "}", "public", "Filter", "getFilter", "(", ")", "{", "return", "filter", ";", "}", "public", "Map", "<", "String", ",", "Object", ">", "getTemplateMapping", "(", ")", "{", "return", "templateMapping", ";", "}", "public", "void", "setQuery", "(", "Query", "query", ")", "{", "this", ".", "query", "=", "query", ";", "}", "public", "void", "setFilter", "(", "Filter", "filter", ")", "{", "this", ".", "filter", "=", "filter", ";", "}", "public", "void", "setSelections", "(", "List", "<", "Selection", ">", "selections", ")", "{", "this", ".", "selections", "=", "selections", ";", "}", "public", "void", "setMapReduce", "(", "MapReduce", "mapReduce", ")", "{", "this", ".", "mapReduce", "=", "mapReduce", ";", "}", "public", "MapReduce", "getMapReduce", "(", ")", "{", "return", "mapReduce", ";", "}", "}", "</s>" ]
6,999
[ "<s>", "package", "com", ".", "senseidb", ".", "search", ".", "client", ".", "req", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "GroupBy", "{", "private", "List", "<", "String", ">", "columns", ";", "private", "int", "top", ";", "public", "GroupBy", "(", ")", "{", "}", "public", "GroupBy", "(", "List", "<", "String", ">", "columns", ",", "int", "top", ")", "{", "this", ".", "columns", "=", "columns", ";", "this", ".", "top", "=", "top", ";", "}", "}", "</s>" ]